Skip to content

Commit

Permalink
Merge branch 'MDL-36479_25' of git://github.com/timhunt/moodle into M…
Browse files Browse the repository at this point in the history
…OODLE_25_STABLE
  • Loading branch information
Damyon Wiese committed Jul 9, 2013
2 parents 641595c + 48eec6a commit 218f778
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 8 deletions.
2 changes: 2 additions & 0 deletions mod/quiz/report/overview/lang/en/quiz_overview.php
Expand Up @@ -61,8 +61,10 @@
$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';
Expand Down
57 changes: 49 additions & 8 deletions mod/quiz/report/overview/report.php
Expand Up @@ -78,6 +78,7 @@ public function display($quiz, $cm, $course) {
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.
Expand Down Expand Up @@ -267,30 +268,54 @@ protected function process_actions($quiz, $cm, $currentgroup, $groupstudents, $a
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.
*/
Expand Down Expand Up @@ -392,8 +417,16 @@ protected function regrade_attempts($quiz, $dryrun = false,

$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) {
Expand Down Expand Up @@ -441,8 +474,16 @@ protected function regrade_attempts_needing_it($quiz, $groupstudents) {

$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);
Expand Down

0 comments on commit 218f778

Please sign in to comment.