/// Check that this attempt belongs to this user.
if ($attemptobj->get_userid() != $USER->id) {
- redirect($attemptobj->review_url(0, $page));
+ if ($attemptobj->has_capability('mod/quiz:viewreports')) {
+ redirect($attemptobj->review_url(0, $page));
+ } else {
+ quiz_error($attemptobj->get_quiz(), 'notyourattempt');
+ }
}
/// Check capabilites.
$accessmanager->print_messages($messages);
print_box_end();
}
- } else {
- /// Just a heading.
- if ($attemptobj->get_num_attempts_allowed() != 1) {
- print_heading(format_string($attemptobj->get_quiz_name()).' - '.$title);
- } else {
- print_heading(format_string($attemptobj->get_quiz_name()));
- }
}
// Start the form
- echo '<form id="responseform" method="post" action="', $attemptobj->processattempt_url(),
+ echo '<form id="responseform" method="post" action="', s($attemptobj->processattempt_url()),
'" enctype="multipart/form-data" accept-charset="utf-8">', "\n";
// A quiz page with a lot of questions can take a long time to load, and we
$attemptlist[] = '<strong>' . $at->attempt . '</strong>';
} else {
$changedurl = preg_replace($search, 'attempt=' . $at->id, $url);
- $attemptlist[] = '<a href="' . $changedurl . '">' . $at->attempt . '</a>';
+ $attemptlist[] = '<a href="' . s($changedurl) . '">' . $at->attempt . '</a>';
}
}
return implode(', ', $attemptlist);
}
$param = '';
if ($showall) {
- $param = '&showall=1';
+ $param = '&showall=1';
} else if ($page > 0) {
- $param = '&page=' . $page;
+ $param = '&page=' . $page;
}
return $param . $fragment;
}
/// Form for saving flags if necessary.
if ($options->flags == QUESTION_FLAGSEDITABLE) {
- echo '<form action="' . $attemptobj->review_url(0, $page, $showall) .
+ echo '<form action="' . s($attemptobj->review_url(0, $page, $showall)) .
'" method="post"><div>';
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
}
if ($lastpage) {
$accessmanager->print_finish_review_link($attemptobj->is_preview_user());
} else {
- link_arrow_right(get_string('next'), $attemptobj->review_url(0, $page + 1));
+ link_arrow_right(get_string('next'), s($attemptobj->review_url(0, $page + 1)));
}
echo "</div>";
$flag = ' <img src="' . $OUTPUT->old_icon_url('i/flagged') . '" alt="' .
get_string('flagged', 'question') . '" class="questionflag" />';
}
- $row = array('<a href="' . $attemptobj->attempt_url($question->id) . '">' . $number . $flag . '</a>',
+ $row = array('<a href="' . s($attemptobj->attempt_url($question->id)) . '">' . $number . $flag . '</a>',
get_string($attemptobj->get_question_status($question->id), 'quiz'));
if ($scorescolumn) {
$row[] = $attemptobj->get_question_score($question->id);
'questionids' => '',
'sesskey' => sesskey(),
);
-print_single_button($attemptobj->processattempt_url(), $options, get_string('finishattempt', 'quiz'),
+print_single_button(s($attemptobj->processattempt_url()), $options, get_string('finishattempt', 'quiz'),
'post', '', false, '', false, get_string('confirmclose', 'quiz'), 'responseform');
echo "</div>\n";