Script.php: [bugfix] fix -- "Students unable to submit assignment after a recent change"

This commit temporarily fixed the bug reported at http://118.25.96.118/bugzilla/show_bug.cgi?id=65

This bug was introduced after a recent functionality addition, i.e., allowing Lecturer to edit assignment information.
See the following pull request for details.
https://github.com/lanlab-org/LRR/pull/21

It seems that $group_id is not properly assigned after merging the above pull request.
Therefore, when someone tried to insert a record to the database table lab_report_submissions, he encountered a running error.

In this fix, I just set $group_id 0 to avoid the database insertion error.
This is OK when an assignment is of type Individual.
Of course, this fix is not ideal, as it cannot handle the situation where the assignment is of type Group.
In the future, $group_id must be properly initialized, depending on the assignment type.

-Hui
SIMPLICITY_Bug-189_Course_Delete_btn
Hui Lan 2020-04-21 20:48:13 +08:00
parent 18f2e7023a
commit b7d6ae1bcf
1 changed files with 7 additions and 1 deletions

View File

@ -827,7 +827,13 @@ if(strlen($_FILES['attachment1']['name']) > 2 ) {
if ($con->query($sql1) === TRUE) {
}
// When $group_id is not properly initialized, use integer 0 as its value.
// This temporarily fixed the "Students unable to submit assignment after a recent change" bug at http://118.25.96.118/bugzilla/show_bug.cgi?id=65
if (trim($group_id) === '') {
$group_id = 0; // FIXME
}
$sql="INSERT INTO `lab_report_submissions`(`Submission_Date`, `Lab_Report_ID`, `Student_id`,"
. " `Course_Group_id`, `Attachment1`, `Notes`, `Attachment2`, `Attachment3`, `Attachment4`, `Status`, `Title`,`Remarking_Reason`)"
. " VALUES ('$date',$lab_id,$student_id,$group_id,'$targetfile','$instructions','$targetfile2','$targetfile3','$targetfile4',"