Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
20_21-J09
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
20_21-J09
20_21-J09
Commits
b3ad4f24
Commit
b3ad4f24
authored
Jul 09, 2021
by
Janith Madushanka_IT17142656
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'edited_question.php'
parent
b01f07ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
275 deletions
+5
-275
Admin/pages/update_question.php
Admin/pages/update_question.php
+5
-8
update_question.php
update_question.php
+0
-267
No files found.
Admin/pages/update_question.php
View file @
b3ad4f24
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
{
{
header
(
'location:'
.
SITEURL
.
'admin/index.php?page=questions'
);
header
(
'location:'
.
SITEURL
.
'admin/index.php?page=questions'
);
}
}
?>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
r>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
?>
<div
class=
"main"
>
<div
class=
"main"
>
<div
class=
"content"
>
<div
class=
"content"
>
<div
class=
"report"
>
<div
class=
"report"
>
...
@@ -53,7 +53,7 @@
...
@@ -53,7 +53,7 @@
unset
(
$_SESSION
[
'update'
]);
unset
(
$_SESSION
[
'update'
]);
}
}
?>
?>
<span
class=
"name"
>
Question
</span>
<br
/>
<span
class=
"name"
>
Question
</span>
<textarea
name=
"question"
required=
"true"
>
<?php
echo
$question
;
?>
</textarea>
<br
/>
<textarea
name=
"question"
required=
"true"
>
<?php
echo
$question
;
?>
</textarea>
<br
/>
<script>
<script>
CKEDITOR
.
replace
(
'
question
'
);
CKEDITOR
.
replace
(
'
question
'
);
...
@@ -99,11 +99,8 @@
...
@@ -99,11 +99,8 @@
</select>
</select>
<br
/>
<br
/>
<span
class=
"name"
>
Reason
</span>
<br
/>
<span
class=
"name"
>
Reason
</span>
<textarea
name=
"reason"
>
<?php
echo
$reason
;
?>
</textarea>
<textarea
name=
"reason"
>
<?php
echo
$reason
;
?>
</textarea>
<script>
CKEDITOR
.
replace
(
'
reason
'
);
</script>
<br
/>
<br
/>
<span
class=
"name"
>
Marks
</span>
<span
class=
"name"
>
Marks
</span>
...
@@ -121,7 +118,7 @@
...
@@ -121,7 +118,7 @@
<select
name=
"faculty"
>
<select
name=
"faculty"
>
<?php
<?php
//Get Faculties from database
//Get Faculties from database
$tbl_name
=
"tbl_
class
"
;
$tbl_name
=
"tbl_
faculty
"
;
$query
=
$obj
->
select_data
(
$tbl_name
);
$query
=
$obj
->
select_data
(
$tbl_name
);
$res
=
$obj
->
execute_query
(
$conn
,
$query
);
$res
=
$obj
->
execute_query
(
$conn
,
$query
);
$count_rows
=
$obj
->
num_rows
(
$res
);
$count_rows
=
$obj
->
num_rows
(
$res
);
...
@@ -207,7 +204,7 @@
...
@@ -207,7 +204,7 @@
}
}
//Uploading if the file is valid
//Uploading if the file is valid
//first changing image name
//first changing image name
$new_name
=
'
Exam_Question_Vijay_Thapa
_'
.
$obj
->
uniqid
();
$new_name
=
'
Beyond_Boundaries_Question
_'
.
$obj
->
uniqid
();
$image_name
=
$new_name
.
'.'
.
$ext
;
$image_name
=
$new_name
.
'.'
.
$ext
;
//Adding Watermark to the image fie too
//Adding Watermark to the image fie too
$source
=
$_FILES
[
'image'
][
'tmp_name'
];
$source
=
$_FILES
[
'image'
][
'tmp_name'
];
...
...
update_question.php
deleted
100644 → 0
View file @
b01f07ae
<!--Body Starts Here-->
<?php
if
(
isset
(
$_GET
[
'id'
]))
{
$question_id
=
$_GET
[
'id'
];
$tbl_name
=
'tbl_question'
;
$where
=
"question_id=
$question_id
"
;
$query
=
$obj
->
select_data
(
$tbl_name
,
$where
);
$res
=
$obj
->
execute_query
(
$conn
,
$query
);
$count_rows
=
$obj
->
num_rows
(
$res
);
if
(
$count_rows
==
1
)
{
$row
=
$obj
->
fetch_data
(
$res
);
$question
=
$row
[
'question'
];
$first_answer
=
$row
[
'first_answer'
];
$second_answer
=
$row
[
'second_answer'
];
$third_answer
=
$row
[
'third_answer'
];
$fourth_answer
=
$row
[
'fourth_answer'
];
$fifth_answer
=
$row
[
'fifth_answer'
];
$answer
=
$row
[
'answer'
];
$reason
=
$row
[
'reason'
];
$marks
=
$row
[
'marks'
];
$category
=
$row
[
'category'
];
$faculty_db
=
$row
[
'faculty'
];
$is_active
=
$row
[
'is_active'
];
$previous_image
=
$row
[
'image_name'
];
}
else
{
header
(
'location:'
.
SITEURL
.
'admin/index.php?page=questions'
);
}
}
else
{
header
(
'location:'
.
SITEURL
.
'admin/index.php?page=questions'
);
}
?>
<div
class=
"main"
>
<div
class=
"content"
>
<div
class=
"report"
>
<form
method=
"post"
action=
""
class=
"forms"
enctype=
"multipart/form-data"
>
<h2>
Update Question
</h2>
<?php
if
(
isset
(
$_SESSION
[
'validation'
]))
{
echo
$_SESSION
[
'validation'
];
unset
(
$_SESSION
[
'validation'
]);
}
if
(
isset
(
$_SESSION
[
'update'
]))
{
echo
$_SESSION
[
'update'
];
unset
(
$_SESSION
[
'update'
]);
}
?>
<span
class=
"name"
>
Question
</span>
<textarea
name=
"question"
required=
"true"
>
<?php
echo
$question
;
?>
</textarea>
<br
/>
<script>
CKEDITOR
.
replace
(
'
question
'
);
</script>
<?php
if
(
$previous_image
!=
""
)
{
?>
<span
class=
"name"
>
Previous Image
</span>
<img
src=
"
<?php
echo
SITEURL
;
?>
images/questions/
<?php
echo
$previous_image
;
?>
"
/>
<br
/>
<?php
}
?>
<input
type=
"hidden"
name=
"previous_image"
value=
"
<?php
echo
$previous_image
;
?>
"
/>
<span
class=
"name"
>
New Image
</span>
<input
type=
"file"
name=
"image"
/><br
/>
<span
class=
"name"
>
First Answer
</span>
<input
type=
"text"
name=
"first_answer"
value=
"
<?php
echo
$first_answer
;;
?>
"
required=
"true"
/><br
/>
<span
class=
"name"
>
Second Answer
</span>
<input
type=
"text"
name=
"second_answer"
value=
"
<?php
echo
$second_answer
;
?>
"
required=
"true"
/><br
/>
<span
class=
"name"
>
Third Answer
</span>
<input
type=
"text"
name=
"third_answer"
value=
"
<?php
echo
$third_answer
;
?>
"
required=
"true"
/><br
/>
<span
class=
"name"
>
Fourth Answer
</span>
<input
type=
"text"
name=
"fourth_answer"
value=
"
<?php
echo
$fourth_answer
;
?>
"
required=
"true"
/><br
/>
<span
class=
"name"
>
Fifth Answer
</span>
<input
type=
"text"
name=
"fifth_answer"
value=
"
<?php
echo
$fifth_answer
;
?>
"
required=
"true"
/><br
/>
<span
class=
"name"
>
Answer
</span>
<select
name=
"answer"
>
<option
<?php
if
(
$answer
==
1
){
echo
"selected='seleccted'"
;}
?>
value=
"1"
>
First Answer
</option>
<option
<?php
if
(
$answer
==
2
){
echo
"selected='seleccted'"
;}
?>
value=
"2"
>
Second Answer
</option>
<option
<?php
if
(
$answer
==
3
){
echo
"selected='seleccted'"
;}
?>
value=
"3"
>
Third Answer
</option>
<option
<?php
if
(
$answer
==
4
){
echo
"selected='seleccted'"
;}
?>
value=
"4"
>
Fourth Answer
</option>
<option
<?php
if
(
$answer
==
5
){
echo
"selected='seleccted'"
;}
?>
value=
"5"
>
Fifth Answer
</option>
</select>
<br
/>
<span
class=
"name"
>
Reason
</span>
<textarea
name=
"reason"
>
<?php
echo
$reason
;
?>
</textarea>
<br
/>
<span
class=
"name"
>
Marks
</span>
<input
type=
"text"
name=
"marks"
value=
"
<?php
echo
$marks
;
?>
"
/>
<br
/>
<span
class=
"name"
>
Category
</span>
<select
name=
"category"
>
<option
<?php
if
(
$category
==
"English"
){
echo
"selected='seleccted'"
;}
?>
value=
"English"
>
English
</option>
<option
<?php
if
(
$category
==
"Math"
){
echo
"selected='seleccted'"
;}
?>
value=
"Math"
>
Math
</option>
</select>
<br
/>
<span
class=
"name"
>
Faculty
</span>
<select
name=
"faculty"
>
<?php
//Get Faculties from database
$tbl_name
=
"tbl_faculty"
;
$query
=
$obj
->
select_data
(
$tbl_name
);
$res
=
$obj
->
execute_query
(
$conn
,
$query
);
$count_rows
=
$obj
->
num_rows
(
$res
);
if
(
$count_rows
>
0
)
{
while
(
$row
=
$obj
->
fetch_data
(
$res
))
{
$faculty_id
=
$row
[
'faculty_id'
];
$faculty_name
=
$row
[
'faculty_name'
];
?>
<option
<?php
if
(
$faculty_db
==
$faculty_id
){
echo
"selected='selected'"
;}
?>
value=
"
<?php
echo
$faculty_id
;
?>
"
>
<?php
echo
$faculty_name
;
?>
</option>
<?php
}
}
else
{
?>
<option
value=
"0"
>
Uncategorized
</option>
<?php
}
?>
</select>
<br
/>
<span
class=
"name"
>
Is Active?
</span>
<input
<?php
if
(
$is_active
==
'yes'
){
echo
"checked='checked'"
;}
?>
type=
"radio"
name=
"is_active"
value=
"yes"
/>
Yes
<input
<?php
if
(
$is_active
==
'no'
){
echo
"checked='checked'"
;}
?>
type=
"radio"
name=
"is_active"
value=
"no"
/>
No
<br
/>
<input
type=
"submit"
name=
"submit"
value=
"Update Question"
class=
"btn-update"
style=
"margin-left: 15%;"
/>
<a
href=
"
<?php
echo
SITEURL
;
?>
admin/index.php?page=questions"
><button
type=
"button"
class=
"btn-delete"
>
Cancel
</button></a>
</form>
<?php
if
(
isset
(
$_POST
[
'submit'
]))
{
//echo "Clicked";
$question
=
$obj
->
sanitize
(
$conn
,
$_POST
[
'question'
]);
$first_answer
=
$obj
->
sanitize
(
$conn
,
$_POST
[
'first_answer'
]);
$second_answer
=
$obj
->
sanitize
(
$conn
,
$_POST
[
'second_answer'
]);
$third_answer
=
$obj
->
sanitize
(
$conn
,
$_POST
[
'third_answer'
]);
$fourth_answer
=
$obj
->
sanitize
(
$conn
,
$_POST
[
'fourth_answer'
]);
$fifth_answer
=
$obj
->
sanitize
(
$conn
,
$_POST
[
'fifth_answer'
]);
$answer
=
$obj
->
sanitize
(
$conn
,
$_POST
[
'answer'
]);
$reason
=
$obj
->
sanitize
(
$conn
,
$_POST
[
'reason'
]);
$marks
=
$obj
->
sanitize
(
$conn
,
$_POST
[
'marks'
]);
$category
=
$obj
->
sanitize
(
$conn
,
$_POST
[
'category'
]);
$faculty
=
$obj
->
sanitize
(
$conn
,
$_POST
[
'faculty'
]);
$previous_image
=
$_POST
[
'previous_image'
];
if
(
isset
(
$_POST
[
'is_active'
]))
{
$is_active
=
$_POST
[
'is_active'
];
}
else
{
$is_active
=
"yes"
;
}
$updated_date
=
date
(
'Y-m-d'
);
//Managing Question Images
if
(
$_FILES
[
'image'
][
'name'
]
!=
""
)
{
//echo "Book Cover is Available";
//Getting File Extension
$ext
=
end
(
explode
(
'.'
,
$_FILES
[
'image'
][
'name'
]));
//Checking if the file type is valid or not
$valid_file
=
$obj
->
check_image_type
(
$ext
);
if
(
$valid_file
==
false
)
{
$_SESSION
[
'invalid'
]
=
"<div class='error'>Invalid Image type. Please use JPG or PNG or GIF file type.</div>"
;
header
(
'location:'
.
SITEURL
.
'admin/index.php?page=update_question&id='
.
$question_id
);
die
();
}
//Removing Previous Image
if
(
$previous_image
!=
""
)
{
$path
=
"../images/questions/"
.
$previous_image
;
$remove
=
$obj
->
remove_file
(
$path
);
if
(
$remove
==
false
)
{
$_SESSION
[
'remove_book'
]
=
"Failed to remove previous Image. Try again."
;
header
(
'location:'
.
SITEURL
.
'admin/index.php?page=update_question&id='
.
$question_id
);
die
();
}
}
//Uploading if the file is valid
//first changing image name
$new_name
=
'Beyond_Boundaries_Question_'
.
$obj
->
uniqid
();
$image_name
=
$new_name
.
'.'
.
$ext
;
//Adding Watermark to the image fie too
$source
=
$_FILES
[
'image'
][
'tmp_name'
];
$destination
=
"../images/questions/"
.
$image_name
;
$upload
=
$obj
->
upload_file
(
$source
,
$destination
);
if
(
$upload
==
false
)
{
$_SESSION
[
'upload'
]
=
"<div class='error'>Failed to upload question image. Try again.</div>"
;
header
(
'location:'
.
SITEURL
.
'admin/index.php?page=update_question&id='
.
$question_id
);
die
();
}
}
else
{
$image_name
=
$previous_image
;
}
//Normal PHP Validation
if
((
$question
==
null
)
or
(
$first_answer
==
null
)
or
(
$second_answer
==
null
)
or
(
$third_answer
==
null
)
or
(
$fourth_answer
==
null
)
or
(
$answer
==
null
))
{
$_SESSION
[
'validation'
]
=
"<div class='error'>Either Question or One of the Answers field is empty.</div>"
;
header
(
'location:'
.
SITEURL
.
'admin/index.php?page=update_question&id='
.
$question_id
);
}
//Updating Question
$tbl_name
=
"tbl_question"
;
$data
=
"
question='
$question
',
first_answer='
$first_answer
',
second_answer='
$second_answer
',
third_answer='
$third_answer
',
fourth_answer='
$fourth_answer
',
fifth_answer='
$fifth_answer
',
answer='
$answer
',
reason='
$reason
',
marks='
$marks
',
category='
$category
',
faculty='
$faculty
',
is_active='
$is_active
',
updated_date='
$updated_date
',
image_name='
$image_name
'
"
;
$where
=
"question_id='
$question_id
'"
;
$query
=
$obj
->
update_data
(
$tbl_name
,
$data
,
$where
);
$res
=
$obj
->
execute_query
(
$conn
,
$query
);
if
(
$res
===
true
)
{
$_SESSION
[
'update'
]
=
"<div class='success'>Question successfully updated.</div>"
;
header
(
'location:'
.
SITEURL
.
'admin/index.php?page=questions'
);
}
else
{
$_SESSION
[
'update'
]
=
"<div class='error'>Failed to update question.</div>"
;
header
(
'location:'
.
SITEURL
.
'admin/index.php?page=update_question&id='
.
$question_id
);
}
}
?>
</div>
</div>
</div>
<!--Body Ends Here-->
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment