diff --git a/mod/quiz/addrandom.php b/mod/quiz/addrandom.php index b20a88aced0..9ff0afe86f9 100644 --- a/mod/quiz/addrandom.php +++ b/mod/quiz/addrandom.php @@ -92,7 +92,8 @@ if ($data = $mform->get_data()) { $returnurl->param('cat', $categoryid . ',' . $contextid); } else { - throw new coding_exception('It seems a form was submitted without any button being pressed???'); + throw new coding_exception( + 'It seems a form was submitted without any button being pressed???'); } quiz_add_random_questions($quiz, $addonpage, $categoryid, 1, $includesubcategories); diff --git a/mod/quiz/addrandomform.php b/mod/quiz/addrandomform.php index 40c0c86548b..e7ebf34cd1b 100644 --- a/mod/quiz/addrandomform.php +++ b/mod/quiz/addrandomform.php @@ -44,8 +44,9 @@ class quiz_add_random_form extends moodleform { $contexts = $this->_customdata; -//-------------------------------------------------------------------------------- - $mform->addElement('header', 'categoryheader', get_string('randomfromexistingcategory', 'quiz')); + //-------------------------------------------------------------------------------- + $mform->addElement('header', 'categoryheader', + get_string('randomfromexistingcategory', 'quiz')); $mform->addElement('questioncategory', 'category', get_string('category'), array('contexts' => $contexts->all(), 'top' => false)); @@ -54,8 +55,9 @@ class quiz_add_random_form extends moodleform { $mform->addElement('submit', 'existingcategory', get_string('addrandomquestion', 'quiz')); -//-------------------------------------------------------------------------------- - $mform->addElement('header', 'categoryheader', get_string('randomquestionusinganewcategory', 'quiz')); + //-------------------------------------------------------------------------------- + $mform->addElement('header', 'categoryheader', + get_string('randomquestionusinganewcategory', 'quiz')); $mform->addElement('text', 'name', get_string('name'), 'maxlength="254" size="50"'); $mform->setType('name', PARAM_MULTILANG); @@ -64,9 +66,10 @@ class quiz_add_random_form extends moodleform { array('contexts' => $contexts->all(), 'top' => true)); $mform->addHelpButton('parent', 'parentcategory', 'question'); - $mform->addElement('submit', 'newcategory', get_string('createcategoryandaddrandomquestion', 'quiz')); + $mform->addElement('submit', 'newcategory', + get_string('createcategoryandaddrandomquestion', 'quiz')); -//-------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------- $mform->addElement('cancel'); $mform->closeHeaderBefore('cancel'); diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php index 5924e9ae255..a6c546ecff8 100644 --- a/mod/quiz/attempt.php +++ b/mod/quiz/attempt.php @@ -34,7 +34,8 @@ if ($id = optional_param('id', 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()); + redirect(new moodle_url('/mod/quiz/startattempt.php', + array('cmid' => $cm->id, 'sesskey' => sesskey()))); } // Get submitted parameters. @@ -111,7 +112,8 @@ if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) { format_string($attemptobj->get_quiz_name())); } else if ($accessmanager->safebrowser_required($attemptobj->is_preview_user())) { - $PAGE->set_title($attemptobj->get_course()->shortname . ': '.format_string($attemptobj->get_quiz_name())); + $PAGE->set_title($attemptobj->get_course()->shortname . ': ' . + format_string($attemptobj->get_quiz_name())); $PAGE->set_cacheable(false); echo $OUTPUT->header(); diff --git a/mod/quiz/backup/moodle2/backup_quiz_activity_task.class.php b/mod/quiz/backup/moodle2/backup_quiz_activity_task.class.php index a461055c14e..dedde469d02 100644 --- a/mod/quiz/backup/moodle2/backup_quiz_activity_task.class.php +++ b/mod/quiz/backup/moodle2/backup_quiz_activity_task.class.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); -require_once($CFG->dirroot . '/mod/quiz/backup/moodle2/backup_quiz_stepslib.php'); // Because it exists (must) +require_once($CFG->dirroot . '/mod/quiz/backup/moodle2/backup_quiz_stepslib.php'); /** @@ -74,7 +74,7 @@ class backup_quiz_activity_task extends backup_activity_task { public static function encode_content_links($content) { global $CFG; - $base = preg_quote($CFG->wwwroot,"/"); + $base = preg_quote($CFG->wwwroot, '/'); // Link to the list of quizzes $search="/(".$base."\/mod\/quiz\/index.php\?id\=)([0-9]+)/"; diff --git a/mod/quiz/backup/moodle2/backup_quiz_stepslib.php b/mod/quiz/backup/moodle2/backup_quiz_stepslib.php index 74880b0435e..5ae20f1b3e3 100644 --- a/mod/quiz/backup/moodle2/backup_quiz_stepslib.php +++ b/mod/quiz/backup/moodle2/backup_quiz_stepslib.php @@ -106,9 +106,11 @@ class backup_quiz_activity_structure_step extends backup_questions_activity_stru // Define sources $quiz->set_source_table('quiz', array('id' => backup::VAR_ACTIVITYID)); - $qinstance->set_source_table('quiz_question_instances', array('quiz' => backup::VAR_PARENTID)); + $qinstance->set_source_table('quiz_question_instances', + array('quiz' => backup::VAR_PARENTID)); - $feedback->set_source_table('quiz_feedback', array('quizid' => backup::VAR_PARENTID)); + $feedback->set_source_table('quiz_feedback', + array('quizid' => backup::VAR_PARENTID)); // Quiz overrides to backup are different depending of user info $overrideparams = array('quiz' => backup::VAR_PARENTID); diff --git a/mod/quiz/backup/moodle2/restore_quiz_stepslib.php b/mod/quiz/backup/moodle2/restore_quiz_stepslib.php index b59ef00deb9..b3a32e72f7e 100644 --- a/mod/quiz/backup/moodle2/restore_quiz_stepslib.php +++ b/mod/quiz/backup/moodle2/restore_quiz_stepslib.php @@ -40,12 +40,14 @@ class restore_quiz_activity_structure_step extends restore_questions_activity_st $userinfo = $this->get_setting_value('userinfo'); $paths[] = new restore_path_element('quiz', '/activity/quiz'); - $paths[] = new restore_path_element('quiz_question_instance', '/activity/quiz/question_instances/question_instance'); + $paths[] = new restore_path_element('quiz_question_instance', + '/activity/quiz/question_instances/question_instance'); $paths[] = new restore_path_element('quiz_feedback', '/activity/quiz/feedbacks/feedback'); $paths[] = new restore_path_element('quiz_override', '/activity/quiz/overrides/override'); if ($userinfo) { $paths[] = new restore_path_element('quiz_grade', '/activity/quiz/grades/grade'); - $quizattempt = new restore_path_element('quiz_attempt', '/activity/quiz/attempts/attempt'); + $quizattempt = new restore_path_element('quiz_attempt', + '/activity/quiz/attempts/attempt'); $paths[] = $quizattempt; // Add states and sessions $this->add_question_attempts_states($quizattempt, $paths); @@ -101,58 +103,82 @@ class restore_quiz_activity_structure_step extends restore_questions_activity_st define('QUIZ_OLD_OPEN', 0x3c00fc0); define('QUIZ_OLD_CLOSED', 0x3c03f000); - define('QUIZ_OLD_RESPONSES', 1*0x1041); // Show responses - define('QUIZ_OLD_SCORES', 2*0x1041); // Show scores - define('QUIZ_OLD_FEEDBACK', 4*0x1041); // Show question feedback - define('QUIZ_OLD_ANSWERS', 8*0x1041); // Show correct answers - define('QUIZ_OLD_SOLUTIONS', 16*0x1041); // Show solutions - define('QUIZ_OLD_GENERALFEEDBACK',32*0x1041); // Show question general feedback - define('QUIZ_OLD_OVERALLFEEDBACK', 1*0x4440000); // Show quiz overall feedback + define('QUIZ_OLD_RESPONSES', 1*0x1041); + define('QUIZ_OLD_SCORES', 2*0x1041); + define('QUIZ_OLD_FEEDBACK', 4*0x1041); + define('QUIZ_OLD_ANSWERS', 8*0x1041); + define('QUIZ_OLD_SOLUTIONS', 16*0x1041); + define('QUIZ_OLD_GENERALFEEDBACK', 32*0x1041); + define('QUIZ_OLD_OVERALLFEEDBACK', 1*0x4440000); } $oldreview = $data->review; $data->reviewattempt = mod_quiz_display_options::DURING | - ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_RESPONSES ? mod_quiz_display_options::IMMEDIATELY_AFTER : 0) | - ($oldreview & QUIZ_OLD_OPEN & QUIZ_OLD_RESPONSES ? mod_quiz_display_options::LATER_WHILE_OPEN : 0) | - ($oldreview & QUIZ_OLD_CLOSED & QUIZ_OLD_RESPONSES ? mod_quiz_display_options::AFTER_CLOSE : 0); + ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_RESPONSES ? + mod_quiz_display_options::IMMEDIATELY_AFTER : 0) | + ($oldreview & QUIZ_OLD_OPEN & QUIZ_OLD_RESPONSES ? + mod_quiz_display_options::LATER_WHILE_OPEN : 0) | + ($oldreview & QUIZ_OLD_CLOSED & QUIZ_OLD_RESPONSES ? + mod_quiz_display_options::AFTER_CLOSE : 0); $data->reviewcorrectness = mod_quiz_display_options::DURING | - ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_SCORES ? mod_quiz_display_options::IMMEDIATELY_AFTER : 0) | - ($oldreview & QUIZ_OLD_OPEN & QUIZ_OLD_SCORES ? mod_quiz_display_options::LATER_WHILE_OPEN : 0) | - ($oldreview & QUIZ_OLD_CLOSED & QUIZ_OLD_SCORES ? mod_quiz_display_options::AFTER_CLOSE : 0); + ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_SCORES ? + mod_quiz_display_options::IMMEDIATELY_AFTER : 0) | + ($oldreview & QUIZ_OLD_OPEN & QUIZ_OLD_SCORES ? + mod_quiz_display_options::LATER_WHILE_OPEN : 0) | + ($oldreview & QUIZ_OLD_CLOSED & QUIZ_OLD_SCORES ? + mod_quiz_display_options::AFTER_CLOSE : 0); $data->reviewmarks = mod_quiz_display_options::DURING | - ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_SCORES ? mod_quiz_display_options::IMMEDIATELY_AFTER : 0) | - ($oldreview & QUIZ_OLD_OPEN & QUIZ_OLD_SCORES ? mod_quiz_display_options::LATER_WHILE_OPEN : 0) | - ($oldreview & QUIZ_OLD_CLOSED & QUIZ_OLD_SCORES ? mod_quiz_display_options::AFTER_CLOSE : 0); + ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_SCORES ? + mod_quiz_display_options::IMMEDIATELY_AFTER : 0) | + ($oldreview & QUIZ_OLD_OPEN & QUIZ_OLD_SCORES ? + mod_quiz_display_options::LATER_WHILE_OPEN : 0) | + ($oldreview & QUIZ_OLD_CLOSED & QUIZ_OLD_SCORES ? + mod_quiz_display_options::AFTER_CLOSE : 0); $data->reviewspecificfeedback = - ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_FEEDBACK ? mod_quiz_display_options::DURING : 0) | - ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_FEEDBACK ? mod_quiz_display_options::IMMEDIATELY_AFTER : 0) | - ($oldreview & QUIZ_OLD_OPEN & QUIZ_OLD_FEEDBACK ? mod_quiz_display_options::LATER_WHILE_OPEN : 0) | - ($oldreview & QUIZ_OLD_CLOSED & QUIZ_OLD_FEEDBACK ? mod_quiz_display_options::AFTER_CLOSE : 0); + ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_FEEDBACK ? + mod_quiz_display_options::DURING : 0) | + ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_FEEDBACK ? + mod_quiz_display_options::IMMEDIATELY_AFTER : 0) | + ($oldreview & QUIZ_OLD_OPEN & QUIZ_OLD_FEEDBACK ? + mod_quiz_display_options::LATER_WHILE_OPEN : 0) | + ($oldreview & QUIZ_OLD_CLOSED & QUIZ_OLD_FEEDBACK ? + mod_quiz_display_options::AFTER_CLOSE : 0); $data->reviewgeneralfeedback = - ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_GENERALFEEDBACK ? mod_quiz_display_options::DURING : 0) | - ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_GENERALFEEDBACK ? mod_quiz_display_options::IMMEDIATELY_AFTER : 0) | - ($oldreview & QUIZ_OLD_OPEN & QUIZ_OLD_GENERALFEEDBACK ? mod_quiz_display_options::LATER_WHILE_OPEN : 0) | - ($oldreview & QUIZ_OLD_CLOSED & QUIZ_OLD_GENERALFEEDBACK ? mod_quiz_display_options::AFTER_CLOSE : 0); + ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_GENERALFEEDBACK ? + mod_quiz_display_options::DURING : 0) | + ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_GENERALFEEDBACK ? + mod_quiz_display_options::IMMEDIATELY_AFTER : 0) | + ($oldreview & QUIZ_OLD_OPEN & QUIZ_OLD_GENERALFEEDBACK ? + mod_quiz_display_options::LATER_WHILE_OPEN : 0) | + ($oldreview & QUIZ_OLD_CLOSED & QUIZ_OLD_GENERALFEEDBACK ? + mod_quiz_display_options::AFTER_CLOSE : 0); $data->reviewrightanswer = - ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_ANSWERS ? mod_quiz_display_options::DURING : 0) | - ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_ANSWERS ? mod_quiz_display_options::IMMEDIATELY_AFTER : 0) | - ($oldreview & QUIZ_OLD_OPEN & QUIZ_OLD_ANSWERS ? mod_quiz_display_options::LATER_WHILE_OPEN : 0) | - ($oldreview & QUIZ_OLD_CLOSED & QUIZ_OLD_ANSWERS ? mod_quiz_display_options::AFTER_CLOSE : 0); + ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_ANSWERS ? + mod_quiz_display_options::DURING : 0) | + ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_ANSWERS ? + mod_quiz_display_options::IMMEDIATELY_AFTER : 0) | + ($oldreview & QUIZ_OLD_OPEN & QUIZ_OLD_ANSWERS ? + mod_quiz_display_options::LATER_WHILE_OPEN : 0) | + ($oldreview & QUIZ_OLD_CLOSED & QUIZ_OLD_ANSWERS ? + mod_quiz_display_options::AFTER_CLOSE : 0); $data->reviewoverallfeedback = 0 | - ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_OVERALLFEEDBACK ? mod_quiz_display_options::IMMEDIATELY_AFTER : 0) | - ($oldreview & QUIZ_OLD_OPEN & QUIZ_OLD_OVERALLFEEDBACK ? mod_quiz_display_options::LATER_WHILE_OPEN : 0) | - ($oldreview & QUIZ_OLD_CLOSED & QUIZ_OLD_OVERALLFEEDBACK ? mod_quiz_display_options::AFTER_CLOSE : 0); + ($oldreview & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_OVERALLFEEDBACK ? + mod_quiz_display_options::IMMEDIATELY_AFTER : 0) | + ($oldreview & QUIZ_OLD_OPEN & QUIZ_OLD_OVERALLFEEDBACK ? + mod_quiz_display_options::LATER_WHILE_OPEN : 0) | + ($oldreview & QUIZ_OLD_CLOSED & QUIZ_OLD_OVERALLFEEDBACK ? + mod_quiz_display_options::AFTER_CLOSE : 0); } // insert the quiz record diff --git a/mod/quiz/comment.php b/mod/quiz/comment.php index 1f5271c49c8..c5cf5547f17 100644 --- a/mod/quiz/comment.php +++ b/mod/quiz/comment.php @@ -67,7 +67,8 @@ if (data_submitted() && confirm_sesskey()) { } // Print the comment form. -echo '