$string['regradecomplete'] = 'All attempts have been regraded';
$string['regradecount'] = '$a->changed out of $a->attempt grades were changed';
$string['regradedisplayexplanation'] = 'Attempts that change during regrading are displayed as hyperlinks to the question review window';
+$string['regradenotallowed'] = 'You do not have permission to regrade this quiz';
$string['regradingquestion'] = 'Regrading \"$a\".';
$string['regradingquiz'] = 'Regrading Quiz \"$a\"';
$string['relative'] = 'Relative';
$strtimeformat = get_string('strftimedatetime');
$strreviewquestion = get_string('reviewresponse', 'quiz');
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+
// Only print headers if not asked to download data
if (!$download = optional_param('download', NULL)) {
$this->print_header_and_tabs($cm, $course, $quiz, $reportmode="overview");
switch($action) {
case 'delete': // Some attempts need to be deleted
+ require_capability('mod/quiz:deleteattempts', $context);
$attemptids = optional_param('attemptid', array(), PARAM_INT);
foreach($attemptids as $attemptid) {
+ add_to_log($course->id, 'quiz', 'delete attempt', 'report.php?id=' . $cm->id, $attemptid, $cm->id);
quiz_delete_attempt($attemptid, $quiz);
- quiz_update_grades($quiz, $USER->id);
}
break;
}
// Print table
$table->print_html();
+ // Prepare list of available options.
+ $options = array();
+ if (has_capability('mod/quiz:deleteattempts', $context)) {
+ $options['delete'] = get_string('delete');
+ }
+
// Print "Select all" etc.
- if (!empty($attempts)) {
+ if (!empty($attempts) && !empty($options)) {
echo '<table id="commands">';
echo '<tr><td>';
echo '<a href="javascript:select_all_in(\'DIV\',null,\'tablecontainer\');">'.get_string('selectall', 'quiz').'</a> / ';
echo '<a href="javascript:deselect_all_in(\'DIV\',null,\'tablecontainer\');">'.get_string('selectnone', 'quiz').'</a> ';
echo ' ';
- $options = array('delete' => get_string('delete'));
echo choose_from_menu($options, 'action', '', get_string('withselected', 'quiz'), 'if(this.selectedIndex > 0) submitFormById(\'attemptsform\');', '', true);
echo '<noscript id="noscriptmenuaction" style="display: inline;"><div>';
echo '<input type="submit" value="'.get_string('go').'" /></div></noscript>';
// Print header
$this->print_header_and_tabs($cm, $course, $quiz, $reportmode="regrade");
+ // Check permissions
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ if (!has_capability('mod/quiz:grade', $context)) {
+ notify(get_string('regradenotallowed', 'quiz'));
+ return true;
+ }
+
// Fetch all attempts
if (!$attempts = get_records_select('quiz_attempts', "quiz = '$quiz->id' AND preview = 0")) {
print_heading(get_string('noattempts', 'quiz'));