From b7d6ae1bcf48a6ba23148d39388f8a851fe2a537 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Tue, 21 Apr 2020 20:48:13 +0800 Subject: [PATCH] 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 --- Script.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Script.php b/Script.php index 5adff14..65ca093 100644 --- a/Script.php +++ b/Script.php @@ -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',"