MDL-15535 - URLs are changing from attempt.php?id=XXX to attempt.php?attempt =YYY - implement a sensible redirect if we recieve an old-style URL, since they are stored in a few places like the logs. Also update all URLs we generate that point to attempt.php.
This commit is contained in:
+11
-1
@@ -13,7 +13,17 @@
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
||||
|
||||
/// remember the current time as the time any responses were submitted
|
||||
/// Look for old-style URLs, such as may be in the logs, and redirect them to startattemtp.php
|
||||
if ($id = optional_param('id', 0, PARAM_INTEGER)) {
|
||||
redirect($CFG->wwwroot . '/mod/quiz/startattempt.php?cmid=' . $id . '&sesskey=' . sesskey());
|
||||
} else if ($qid = optional_param('q', 0, PARAM_INTEGER)) {
|
||||
if (!$cm = get_coursemodule_from_instance('quiz', $qid)) {
|
||||
print_error('invalidquizid', 'quiz');
|
||||
}
|
||||
redirect($CFG->wwwroot . '/mod/quiz/startattempt.php?cmid=' . $cm->id . '&sesskey=' . sesskey());
|
||||
}
|
||||
|
||||
/// Remember the current time as the time any responses were submitted
|
||||
/// (so as to make sure students don't get penalized for slow processing on this page)
|
||||
$timenow = time();
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
if (!has_capability('mod/quiz:viewreports', $context)) {
|
||||
if (!$attempt->timefinish) {
|
||||
redirect('attempt.php?q='.$quiz->id);
|
||||
redirect('attempt.php?attempt='.$attempt->id);
|
||||
}
|
||||
// If not even responses are to be shown in review then we
|
||||
// don't allow any review
|
||||
|
||||
@@ -28,8 +28,11 @@ if (!$quiz = $DB->get_record('quiz', array('id' => $cm->instance))) {
|
||||
|
||||
$quizobj = new quiz($quiz, $cm, $course);
|
||||
|
||||
/// Check login and get contexts.
|
||||
/// Check login and sesskey.
|
||||
require_login($quizobj->get_courseid(), false, $quizobj->get_cm());
|
||||
if (!confirm_sesskey()) {
|
||||
throw new moodle_exception('confirmsesskeybad', 'error', $quizobj->view_url());
|
||||
}
|
||||
|
||||
/// if no questions have been set up yet redirect to edit.php
|
||||
if (!$quizobj->get_question_ids() && $quizobj->has_capability('mod/quiz:manage')) {
|
||||
@@ -42,14 +45,6 @@ if ($quizobj->is_preview_user() && $forcenew) {
|
||||
$accessmanager->clear_password_access();
|
||||
}
|
||||
|
||||
// This page should only respond to post requests, if not, redirect to the view page.
|
||||
// However, becuase 'secure' mode opens in a new window, we cannot do enforce this rule for them.
|
||||
if (!data_submitted() && !$accessmanager->securewindow_required($quizobj->is_preview_user())) {
|
||||
$accessmanager->back_to_view_page($quizobj->is_preview_user());
|
||||
}
|
||||
if (!confirm_sesskey()) {
|
||||
throw new moodle_exception('confirmsesskeybad', 'error', $quizobj->view_url());
|
||||
}
|
||||
|
||||
/// Check capabilites.
|
||||
if (!$quizobj->is_preview_user()) {
|
||||
@@ -109,11 +104,11 @@ if (!$attempt->id = $DB->insert_record('quiz_attempts', $attempt)) {
|
||||
|
||||
/// Log the new attempt.
|
||||
if ($attempt->preview) {
|
||||
add_to_log($course->id, 'quiz', 'preview', "attempt.php?id=$cm->id",
|
||||
"$quiz->id", $cm->id);
|
||||
add_to_log($course->id, 'quiz', 'preview', 'view.php?id=' . $quizobj->get_cmid(),
|
||||
$quizobj->get_quizid(), $quizobj->get_cmid());
|
||||
} else {
|
||||
add_to_log($course->id, 'quiz', 'attempt', "review.php?attempt=$attempt->id",
|
||||
"$quiz->id", $cm->id);
|
||||
add_to_log($course->id, 'quiz', 'attempt', 'review.php?attempt=' . $attempt->id,
|
||||
$quizobj->get_quizid(), $quizobj->get_cmid());
|
||||
}
|
||||
|
||||
/// Fully load all the questions in this quiz.
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ if (has_capability('mod/quiz:viewreports', $context)) {
|
||||
$row[] = new tabobject('reports', "$CFG->wwwroot/mod/quiz/report.php?q=$quiz->id", get_string('results', 'quiz'));
|
||||
}
|
||||
if (has_capability('mod/quiz:preview', $context)) {
|
||||
$row[] = new tabobject('preview', "$CFG->wwwroot/mod/quiz/attempt.php?q=$quiz->id", get_string('preview', 'quiz'));
|
||||
$row[] = new tabobject('preview', "$CFG->wwwroot/mod/quiz/startattempt.php?q=$quiz->id", get_string('preview', 'quiz'));
|
||||
}
|
||||
if (has_capability('mod/quiz:manage', $context)) {
|
||||
$row[] = new tabobject('edit', "$CFG->wwwroot/mod/quiz/edit.php?cmid=$cm->id", get_string('edit'));
|
||||
|
||||
Reference in New Issue
Block a user