From: jamiesensei Date: Mon, 25 Aug 2008 07:44:20 +0000 (+0000) Subject: MDL-16121 "Manual Grading Doesn't Work" grades where not getting saved. Fixed that... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a3668b25c0d9ea0b1ca0be6adda561d033827958;p=moodle.git MDL-16121 "Manual Grading Doesn't Work" grades where not getting saved. Fixed that now. --- diff --git a/mod/quiz/report/grading/report.php b/mod/quiz/report/grading/report.php index 047fda4cad..7cde471fa4 100644 --- a/mod/quiz/report/grading/report.php +++ b/mod/quiz/report/grading/report.php @@ -111,46 +111,47 @@ class quiz_grading_report extends quiz_default_report { echo ''; // for overlib - if ($data = data_submitted() && $this->users) { // post data submitted, process it - confirm_sesskey(); - - // now go through all of the responses and save them. - $allok = true; - foreach($data->manualgrades as $uniqueid => $response) { - // get our attempt - $uniqueid = clean_param($uniqueid, PARAM_INT); - list($usql, $params) = $DB->get_in_or_equal(array_keys($this->users)); - - if (!$attempt = $DB->get_record_sql("SELECT * FROM {quiz_attempts} " . - "WHERE uniqueid = ? AND " . - "userid $usql AND " . - "quiz=?", array_merge(array($uniqueid), $params, array($quiz->id)))){ - error('No such attempt ID exists'); + if ($data = data_submitted()) { // post data submitted, process it + if (confirm_sesskey() && $this->users){ + + // now go through all of the responses and save them. + $allok = true; + foreach($data->manualgrades as $uniqueid => $response) { + // get our attempt + $uniqueid = clean_param($uniqueid, PARAM_INT); + list($usql, $params) = $DB->get_in_or_equal(array_keys($this->users)); + + if (!$attempt = $DB->get_record_sql("SELECT * FROM {quiz_attempts} " . + "WHERE uniqueid = ? AND " . + "userid $usql AND " . + "quiz=?", array_merge(array($uniqueid), $params, array($quiz->id)))){ + error('No such attempt ID exists'); + } + + // Load the state for this attempt (The questions array was created earlier) + $states = get_question_states($questions, $quiz, $attempt); + // The $states array is indexed by question id but because we are dealing + // with only one question there is only one entry in this array + $state = &$states[$question->id]; + + // the following will update the state and attempt + $error = question_process_comment($question, $state, $attempt, $response['comment'], $response['grade']); + if (is_string($error)) { + notify($error); + $allok = false; + } else if ($state->changed) { + // If the state has changed save it and update the quiz grade + save_question_session($question, $state); + quiz_save_best_grade($quiz, $attempt->userid); + } } - - // Load the state for this attempt (The questions array was created earlier) - $states = get_question_states($questions, $quiz, $attempt); - // The $states array is indexed by question id but because we are dealing - // with only one question there is only one entry in this array - $state = &$states[$question->id]; - - // the following will update the state and attempt - $error = question_process_comment($question, $state, $attempt, $response['comment'], $response['grade']); - if (is_string($error)) { - notify($error); - $allok = false; - } else if ($state->changed) { - // If the state has changed save it and update the quiz grade - save_question_session($question, $state); - quiz_save_best_grade($quiz, $attempt->userid); + + if ($allok) { + notify(get_string('changessaved', 'quiz'), 'notifysuccess'); + } else { + notify(get_string('changessavedwitherrors', 'quiz'), 'notifysuccess'); } } - - if ($allok) { - notify(get_string('changessaved', 'quiz'), 'notifysuccess'); - } else { - notify(get_string('changessavedwitherrors', 'quiz'), 'notifysuccess'); - } } $this->viewurl = new moodle_url($CFG->wwwroot.'/mod/quiz/report.php', $viewoptions); /// find out current groups mode