mirror of
https://github.com/moodle/moodle.git
synced 2025-02-01 05:18:06 +01:00
MDL-32322 quiz reports: refactor processing actions.
This commit is contained in:
parent
e97d60adce
commit
361cf27d7f
@ -263,6 +263,25 @@ abstract class quiz_attempts_report extends quiz_default_report {
|
|||||||
$table->collapsible($collapsible);
|
$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
|
* Delete the quiz attempts
|
||||||
* @param object $quiz the quiz settings. Attempts that don't belong to
|
* @param object $quiz the quiz settings. Attempts that don't belong to
|
||||||
|
@ -78,47 +78,12 @@ class quiz_overview_report extends quiz_attempts_report {
|
|||||||
raise_memory_limit(MEMORY_EXTRA);
|
raise_memory_limit(MEMORY_EXTRA);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process actions.
|
$this->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());
|
|
||||||
}
|
|
||||||
|
|
||||||
} 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start output.
|
// Start output.
|
||||||
if (!$table->is_downloading()) {
|
if (!$table->is_downloading()) {
|
||||||
// Only print headers if not asked to download data.
|
// 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)) {
|
if ($groupmode = groups_get_activity_groupmode($cm)) {
|
||||||
@ -301,6 +266,36 @@ class quiz_overview_report extends quiz_attempts_report {
|
|||||||
return true;
|
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
|
* Regrade a particular quiz attempt. Either for real ($dryrun = false), or
|
||||||
* as a pretend regrade to see which fractions would change. The outcome is
|
* as a pretend regrade to see which fractions would change. The outcome is
|
||||||
|
@ -86,21 +86,12 @@ class quiz_responses_report extends quiz_attempts_report {
|
|||||||
raise_memory_limit(MEMORY_EXTRA);
|
raise_memory_limit(MEMORY_EXTRA);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process actions.
|
$this->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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start output.
|
// Start output.
|
||||||
if (!$table->is_downloading()) {
|
if (!$table->is_downloading()) {
|
||||||
// Only print headers if not asked to download data.
|
// 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)) {
|
if ($groupmode = groups_get_activity_groupmode($cm)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user