MDL-36479 quiz regrade: use progress bar to prevent time-outs
This commit is contained in:
@@ -61,8 +61,10 @@ $string['regradealldrydo'] = 'Regrade attempts marked as needing regrading ({$a}
|
||||
$string['regradealldrydogroup'] = 'Regrade attempts ({$a->countregradeneeded}) marked as needing regrading in group \'{$a->groupname}\'';
|
||||
$string['regradealldrygroup'] = 'Dry run a full regrade for group \'{$a->groupname}\'';
|
||||
$string['regradeallgroup'] = 'Full regrade for group \'{$a->groupname}\'';
|
||||
$string['regradecomplete'] = 'Regrade completed successfully';
|
||||
$string['regradeheader'] = 'Regrading';
|
||||
$string['regradeselected'] = 'Regrade selected attempts';
|
||||
$string['regradingattemptxofy'] = 'Regrading attempt ({$a->done}/{$a->count})';
|
||||
$string['show'] = 'Show / download';
|
||||
$string['showattempts'] = 'Only show / download attempts';
|
||||
$string['showdetailedmarks'] = 'Marks for each question';
|
||||
|
||||
@@ -78,6 +78,7 @@ class quiz_overview_report extends quiz_attempts_report {
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
}
|
||||
|
||||
$this->course = $course; // Hack to make this available in process_actions.
|
||||
$this->process_actions($quiz, $cm, $currentgroup, $groupstudents, $allowed, $options->get_url());
|
||||
|
||||
// Start output.
|
||||
@@ -267,30 +268,54 @@ class quiz_overview_report extends quiz_attempts_report {
|
||||
if (empty($currentgroup) || $groupstudents) {
|
||||
if (optional_param('regrade', 0, PARAM_BOOL) && confirm_sesskey()) {
|
||||
if ($attemptids = optional_param_array('attemptid', array(), PARAM_INT)) {
|
||||
require_capability('mod/quiz:regrade', $this->context);
|
||||
$this->start_regrade($quiz, $cm);
|
||||
$this->regrade_attempts($quiz, false, $groupstudents, $attemptids);
|
||||
redirect($redirecturl, '', 5);
|
||||
$this->finish_regrade($redirecturl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (optional_param('regradeall', 0, PARAM_BOOL) && confirm_sesskey()) {
|
||||
require_capability('mod/quiz:regrade', $this->context);
|
||||
$this->start_regrade($quiz, $cm);
|
||||
$this->regrade_attempts($quiz, false, $groupstudents);
|
||||
redirect($redirecturl, '', 5);
|
||||
$this->finish_regrade($redirecturl);
|
||||
|
||||
} else if (optional_param('regradealldry', 0, PARAM_BOOL) && confirm_sesskey()) {
|
||||
require_capability('mod/quiz:regrade', $this->context);
|
||||
$this->start_regrade($quiz, $cm);
|
||||
$this->regrade_attempts($quiz, true, $groupstudents);
|
||||
redirect($redirecturl, '', 5);
|
||||
$this->finish_regrade($redirecturl);
|
||||
|
||||
} else if (optional_param('regradealldrydo', 0, PARAM_BOOL) && confirm_sesskey()) {
|
||||
require_capability('mod/quiz:regrade', $this->context);
|
||||
$this->start_regrade($quiz, $cm);
|
||||
$this->regrade_attempts_needing_it($quiz, $groupstudents);
|
||||
redirect($redirecturl, '', 5);
|
||||
$this->finish_regrade($redirecturl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check necessary capabilities, and start the display of the regrade progress page.
|
||||
* @param object $quiz the quiz settings.
|
||||
* @param object $cm the cm object for the quiz.
|
||||
*/
|
||||
protected function start_regrade($quiz, $cm) {
|
||||
global $OUTPUT, $PAGE;
|
||||
require_capability('mod/quiz:regrade', $this->context);
|
||||
$this->print_header_and_tabs($cm, $this->course, $quiz, $this->mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish displaying the regrade progress page.
|
||||
* @param moodle_url $nexturl where to send the user after the regrade.
|
||||
* @uses exit. This method never returns.
|
||||
*/
|
||||
protected function finish_regrade($nexturl) {
|
||||
global $OUTPUT, $PAGE;
|
||||
echo $OUTPUT->heading(get_string('regradecomplete', 'quiz_overview'));
|
||||
echo $OUTPUT->continue_button($nexturl);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock the session and allow the regrading process to run in the background.
|
||||
*/
|
||||
@@ -392,8 +417,16 @@ class quiz_overview_report extends quiz_attempts_report {
|
||||
|
||||
$this->clear_regrade_table($quiz, $groupstudents);
|
||||
|
||||
$progressbar = new progress_bar('quiz_overview_regrade', 500, true);
|
||||
$a = array(
|
||||
'count' => count($attempts),
|
||||
'done' => 0,
|
||||
);
|
||||
foreach ($attempts as $attempt) {
|
||||
$this->regrade_attempt($attempt, $dryrun);
|
||||
$a['done']++;
|
||||
$progressbar->update($a['done'], $a['count'],
|
||||
get_string('regradingattemptxofy', 'quiz_overview', $a));
|
||||
}
|
||||
|
||||
if (!$dryrun) {
|
||||
@@ -441,8 +474,16 @@ class quiz_overview_report extends quiz_attempts_report {
|
||||
|
||||
$this->clear_regrade_table($quiz, $groupstudents);
|
||||
|
||||
$progressbar = new progress_bar('quiz_overview_regrade', 500, true);
|
||||
$a = array(
|
||||
'count' => count($attempts),
|
||||
'done' => 0,
|
||||
);
|
||||
foreach ($attempts as $attempt) {
|
||||
$this->regrade_attempt($attempt, false, $attemptquestions[$attempt->uniqueid]);
|
||||
$a['done']++;
|
||||
$progressbar->update($a['done'], $a['count'],
|
||||
get_string('regradingattemptxofy', 'quiz_overview', $a));
|
||||
}
|
||||
|
||||
$this->update_overall_grades($quiz);
|
||||
|
||||
Reference in New Issue
Block a user