--- mod/quiz/report/grading/report.php Wed Jul 30 14:53:16 2008 +++ mod/quiz/report/grading/report.php Thu Aug 21 09:59:46 2008 @@ -112,49 +112,48 @@ 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); - $usql = 'IN (' . implode(',', array_keys($this->users)) . ')'; - - if (!$attempt = get_record_sql("SELECT * FROM {$CFG->prefix}quiz_attempts " . - "WHERE uniqueid = $uniqueid AND " . - "userid $usql AND " . - "quiz=$quiz->id")){ - error('No such attempt ID exists'); + if ($data = data_submitted()) { // post data submitted, process it + if ($this->users && 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); + $usql = 'IN (' . implode(',', array_keys($this->users)) . ')'; + + if (!$attempt = get_record_sql("SELECT * FROM {$CFG->prefix}quiz_attempts " . + "WHERE uniqueid = $uniqueid AND " . + "userid $usql AND " . + "quiz=$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 if ($groupmode = groups_get_activity_groupmode($this->cm)) { // Groups are being used groups_print_activity_menu($this->cm, $this->viewurl->out(false, array('userid'=>0, 'attemptid'=>0)));