NOBUG quiz start attempt Fix the quiz password page.

This commit is contained in:
Tim Hunt 2010-07-28 15:06:28 +00:00
parent d8011b7bde
commit a88ba5700c
3 changed files with 9 additions and 15 deletions

View File

@ -607,11 +607,8 @@ class password_access_rule extends quiz_access_rule_base {
*
* @param boolean $canpreview used to enfore securewindow stuff.
* @param object $accessmanager the accessmanager calling us.
* @param boolean $return if true, return the HTML for the form (if required), instead of
* outputting it at stopping
* @return mixed return null, unless $return is true, and a form needs to be displayed.
*/
public function do_password_check($canpreview, $accessmanager, $return = false) {
public function do_password_check($canpreview, $accessmanager) {
global $CFG, $SESSION, $OUTPUT, $PAGE;
/// We have already checked the password for this quiz this session, so don't ask again.
@ -647,9 +644,7 @@ class password_access_rule extends quiz_access_rule_base {
$output = '';
/// Start the page and print the quiz intro, if any.
if (!$return) {
echo $OUTPUT->header();
}
echo $OUTPUT->header();
if (trim(strip_tags($this->_quiz->intro))) {
$cm = get_coursemodule_from_id('quiz', $this->_quiz->id);
$output .= $OUTPUT->box(format_module_intro('quiz', $this->_quiz, $cm->id), 'generalbox', 'intro');
@ -681,13 +676,9 @@ class password_access_rule extends quiz_access_rule_base {
$output .= $OUTPUT->box_end();
/// return or display form.
if ($return) {
return $output;
} else {
echo $output;
echo $OUTPUT->footer();
exit;
}
echo $output;
echo $OUTPUT->footer();
exit;
}
}

View File

@ -95,7 +95,7 @@ class quiz {
*
* @param integer $quizid the the quiz id.
* @param integer $userid the the userid.
* @return object the new quiz object
* @return quiz the new quiz object
*/
static public function create($quizid, $userid) {
global $DB;

View File

@ -29,12 +29,15 @@ if (!$quiz = $DB->get_record('quiz', array('id' => $cm->instance))) {
}
$quizobj = quiz::create($quiz->id, $USER->id);
// This script should only ever be posted to, so set page URL to the view page.
$PAGE->set_url($quizobj->view_url());
/// 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());
}
$PAGE->set_pagelayout('base');
/// if no questions have been set up yet redirect to edit.php
if (!$quizobj->get_question_ids() && $quizobj->has_capability('mod/quiz:manage')) {