diff --git a/mod/quiz/report/attemptsreport.php b/mod/quiz/report/attemptsreport.php index 49bdb8d99f1..0786d4c023a 100644 --- a/mod/quiz/report/attemptsreport.php +++ b/mod/quiz/report/attemptsreport.php @@ -263,6 +263,25 @@ abstract class quiz_attempts_report extends quiz_default_report { $table->collapsible($collapsible); } + /** + * Process any submitted actions. + * @param object $quiz the quiz settings. + * @param int $currentgroup the currently selected group. + * @param array $groupstudents the students in the current group. + * @param array $allowed the users whose attempt this user is allowed to modify. + */ + protected function process_actions($quiz, $currentgroup, $groupstudents, $allowed) { + if (empty($currentgroup) || $groupstudents) { + if (optional_param('delete', 0, PARAM_BOOL) && confirm_sesskey()) { + if ($attemptids = optional_param_array('attemptid', array(), PARAM_INT)) { + require_capability('mod/quiz:deleteattempts', $this->context); + $this->delete_selected_attempts($quiz, $cm, $attemptids, $allowed); + redirect($options->get_url()); + } + } + } + } + /** * Delete the quiz attempts * @param object $quiz the quiz settings. Attempts that don't belong to diff --git a/mod/quiz/report/overview/report.php b/mod/quiz/report/overview/report.php index 3870fd2774d..d352ca1e002 100644 --- a/mod/quiz/report/overview/report.php +++ b/mod/quiz/report/overview/report.php @@ -78,47 +78,12 @@ class quiz_overview_report extends quiz_attempts_report { raise_memory_limit(MEMORY_EXTRA); } - // Process actions. - if (empty($currentgroup) || $groupstudents) { - if (optional_param('delete', 0, PARAM_BOOL) && confirm_sesskey()) { - if ($attemptids = optional_param_array('attemptid', array(), PARAM_INT)) { - require_capability('mod/quiz:deleteattempts', $this->context); - $this->delete_selected_attempts($quiz, $cm, $attemptids, $allowed); - redirect($options->get_url()); - } - - } else 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->regrade_attempts($quiz, false, $groupstudents, $attemptids); - redirect($options->get_url()); - } - } - } - - $regradeall = optional_param('regradeall', 0, PARAM_BOOL); - $regradealldry = optional_param('regradealldry', 0, PARAM_BOOL); - $regradealldrydo = optional_param('regradealldrydo', 0, PARAM_BOOL); - if ($regradeall && confirm_sesskey()) { - require_capability('mod/quiz:regrade', $this->context); - $this->regrade_attempts($quiz, false, $groupstudents); - redirect($options->get_url(), '', 5); - - } else if ($regradealldry && confirm_sesskey()) { - require_capability('mod/quiz:regrade', $this->context); - $this->regrade_attempts($quiz, true, $groupstudents); - redirect($options->get_url(), '', 5); - - } else if ($regradealldrydo && confirm_sesskey()) { - require_capability('mod/quiz:regrade', $this->context); - $this->regrade_attempts_needing_it($quiz, $groupstudents); - redirect($options->get_url(), '', 5); - } + $this->process_actions($quiz, $currentgroup, $groupstudents, $allowed); // Start output. if (!$table->is_downloading()) { // Only print headers if not asked to download data. - $this->print_header_and_tabs($cm, $course, $quiz, 'overview'); + $this->print_header_and_tabs($cm, $course, $quiz, $this->mode); } if ($groupmode = groups_get_activity_groupmode($cm)) { @@ -301,6 +266,36 @@ class quiz_overview_report extends quiz_attempts_report { return true; } + protected function process_actions($quiz, $currentgroup, $groupstudents, $allowed) { + parent::process_actions($quiz, $currentgroup, $groupstudents, $allowed); + + 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->regrade_attempts($quiz, false, $groupstudents, $attemptids); + redirect($options->get_url()); + } + } + } + + if (optional_param('regradeall', 0, PARAM_BOOL) && confirm_sesskey()) { + require_capability('mod/quiz:regrade', $this->context); + $this->regrade_attempts($quiz, false, $groupstudents); + redirect($options->get_url(), '', 5); + + } else if (optional_param('regradealldry', 0, PARAM_BOOL) && confirm_sesskey()) { + require_capability('mod/quiz:regrade', $this->context); + $this->regrade_attempts($quiz, true, $groupstudents); + redirect($options->get_url(), '', 5); + + } else if (optional_param('regradealldrydo', 0, PARAM_BOOL) && confirm_sesskey()) { + require_capability('mod/quiz:regrade', $this->context); + $this->regrade_attempts_needing_it($quiz, $groupstudents); + redirect($options->get_url(), '', 5); + } + } + /** * Regrade a particular quiz attempt. Either for real ($dryrun = false), or * as a pretend regrade to see which fractions would change. The outcome is diff --git a/mod/quiz/report/responses/report.php b/mod/quiz/report/responses/report.php index 5401ec1d7ff..7118daeea20 100644 --- a/mod/quiz/report/responses/report.php +++ b/mod/quiz/report/responses/report.php @@ -86,21 +86,12 @@ class quiz_responses_report extends quiz_attempts_report { raise_memory_limit(MEMORY_EXTRA); } - // Process actions. - if (empty($currentgroup) || $groupstudents) { - if (optional_param('delete', 0, PARAM_BOOL) && confirm_sesskey()) { - if ($attemptids = optional_param_array('attemptid', array(), PARAM_INT)) { - require_capability('mod/quiz:deleteattempts', $this->context); - $this->delete_selected_attempts($quiz, $cm, $attemptids, $allowed); - redirect($options->get_url()); - } - } - } + $this->process_actions($quiz, $currentgroup, $groupstudents, $allowed); // Start output. if (!$table->is_downloading()) { // Only print headers if not asked to download data. - $this->print_header_and_tabs($cm, $course, $quiz, 'responses'); + $this->print_header_and_tabs($cm, $course, $quiz, $this->mode); } if ($groupmode = groups_get_activity_groupmode($cm)) {