From: gregb_cc Date: Wed, 7 May 2003 20:53:24 +0000 (+0000) Subject: fix for bug 324. we are now checking to see if there is a conflict caused by X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=ea6e952d886c7e4107e06ec35449cc787048073f;p=moodle.git fix for bug 324. we are now checking to see if there is a conflict caused by multiple teachers gradign simultaneously. --- diff --git a/mod/assignment/submissions.php b/mod/assignment/submissions.php index 57e1d45c6b..fc15a82739 100644 --- a/mod/assignment/submissions.php +++ b/mod/assignment/submissions.php @@ -6,6 +6,9 @@ require_variable($id); // Assignment optional_variable($sort, ""); + $timewas = $_POST['timenow']; + $timenow = time(); + if (! $assignment = get_record("assignment", "id", $id)) { error("Course module is incorrect"); } @@ -22,7 +25,6 @@ error("Only teachers can look at this page"); } - if ($course->category) { $navigation = "id\">$course->shortname ->"; } @@ -74,17 +76,15 @@ if ($data = data_submitted()) { $feedback = array(); - // Peel out all the data from variable names. foreach ($data as $key => $val) { - if ($key <> "id") { + if (!in_array($key, array("id", "timenow"))) { $type = substr($key,0,1); $num = substr($key,1); $feedback[$num][$type] = $val; } } - $timenow = time(); $count = 0; foreach ($feedback as $num => $vals) { $submission = $submissions[$num]; @@ -97,13 +97,25 @@ $newsubmission->timemarked = $timenow; $newsubmission->mailed = 0; // Make sure mail goes out (again, even) $newsubmission->id = $num; - if (empty($submission->timemodified)) { // eg for offline assignments - $newsubmission->timemodified = $timenow; - } - if (! update_record("assignment_submissions", $newsubmission)) { - notify(get_string("failedupdatefeedback", "assignment", $submission->userid)); - } else { - $count++; + + // Make sure that we aren't overwriting any recent feedback from other teachers. (see bug #324) + if ($timewas < $submission->timemarked && (!empty($submission->grade)) && (!empty($submission->comment))) { + $u = $users[$submission->userid]; + $uname = $u->firstname . " " . $u->lastname; + notify(get_string("failedupdatefeedback", "assignment", $uname) + . "
" . get_string("grade") . ": $newsubmission->grade" + . "
" . get_string("feedback", "assignment") . ": $newsubmission->comment\n"); + unset($u); + unset($uname); + } else { //print out old feedback and grade + if (empty($submission->timemodified)) { // eg for offline assignments + $newsubmission->timemodified = $timenow; + } + if (! update_record("assignment_submissions", $newsubmission)) { + notify(get_string("failedupdatefeedback", "assignment", $submission->userid)); + } else { + $count++; + } } } } @@ -137,6 +149,7 @@ } echo "
"; + echo ""; echo "id\">"; echo ""; echo "
"; @@ -145,4 +158,3 @@ print_footer($course); ?> -