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 '
'; +echo ''; echo $attemptobj->render_question_for_commenting($slot); ?>
@@ -83,8 +84,10 @@ echo $attemptobj->render_question_for_commenting($slot);
- - + +
diff --git a/mod/quiz/index.php b/mod/quiz/index.php index eac25bbb786..3d6afabb74e 100644 --- a/mod/quiz/index.php +++ b/mod/quiz/index.php @@ -75,7 +75,7 @@ foreach ($quizzes as $quiz) { if (quiz_has_feedback($quiz)) { $showfeedback=true; } - if($showclosingheader && $showfeedback) { + if ($showclosingheader && $showfeedback) { break; } } @@ -99,7 +99,8 @@ if (has_capability('mod/quiz:viewreports', $coursecontext)) { array_push($align, 'left'); $showing = 'stats'; -} else if (has_any_capability(array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), $coursecontext)) { +} else if (has_any_capability(array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), + $coursecontext)) { array_push($headings, get_string('grade', 'quiz')); array_push($align, 'left'); if ($showfeedback) { @@ -146,7 +147,8 @@ foreach ($quizzes as $quiz) { if (!$quiz->visible) { $class = ' class="dimmed"'; } - $data[] = "coursemodule\">" . format_string($quiz->name, true) . ''; + $data[] = "coursemodule\">" . + format_string($quiz->name, true) . ''; // Close date. if ($quiz->timeclose) { @@ -163,11 +165,12 @@ foreach ($quizzes as $quiz) { } else if ($showing == 'grades') { // Grade and feedback. $attempts = quiz_get_user_attempts($quiz->id, $USER->id, 'all'); - list($someoptions, $alloptions) = quiz_get_combined_reviewoptions($quiz, $attempts, $context); + list($someoptions, $alloptions) = quiz_get_combined_reviewoptions( + $quiz, $attempts, $context); $grade = ''; $feedback = ''; - if ($quiz->grade && array_key_exists($quiz->id, grades)) { + if ($quiz->grade && array_key_exists($quiz->id, $grades)) { if ($alloptions->marks >= question_display_options::MARK_AND_MAX) { $a = new stdClass(); $a->grade = quiz_format_grade($quiz, $grades[$quiz->id]); diff --git a/mod/quiz/overridedelete.php b/mod/quiz/overridedelete.php index 4ba06fc3b81..af1d68d4b0f 100644 --- a/mod/quiz/overridedelete.php +++ b/mod/quiz/overridedelete.php @@ -88,8 +88,7 @@ echo $OUTPUT->header(); if ($override->groupid) { $group = $DB->get_record('groups', array('id' => $override->groupid), 'id,name'); $confirmstr = get_string("overridedeletegroupsure", "quiz", $group->name); -} -else { +} else { $user = $DB->get_record('user', array('id' => $override->userid), 'id,firstname,lastname'); $confirmstr = get_string("overridedeleteusersure", "quiz", fullname($user)); } diff --git a/mod/quiz/overrideedit.php b/mod/quiz/overrideedit.php index 542dbc796b3..804916c66fb 100644 --- a/mod/quiz/overrideedit.php +++ b/mod/quiz/overrideedit.php @@ -31,10 +31,10 @@ require_once($CFG->dirroot.'/mod/quiz/locallib.php'); require_once($CFG->dirroot.'/mod/quiz/override_form.php'); -$cmid = optional_param('cmid', 0, PARAM_INT); // course module ID, if new override -$overrideid = optional_param('id', 0, PARAM_INT); // override ID, if editing existing override -$action = optional_param('action', null, PARAM_ALPHA); // if creating new override, one of 'adduser','addgroup', or 'duplicate' -$reset = optional_param('reset', false, PARAM_BOOL); // reset form to defaults +$cmid = optional_param('cmid', 0, PARAM_INT); +$overrideid = optional_param('id', 0, PARAM_INT); +$action = optional_param('action', null, PARAM_ALPHA); +$reset = optional_param('reset', false, PARAM_BOOL); $override = null; if ($overrideid) { @@ -84,28 +84,29 @@ require_capability('mod/quiz:manageoverrides', $context); if ($overrideid) { // editing override $data = clone $override; -} -else { +} else { // new override $data = new stdClass(); } // merge quiz defaults with data -$keys = array('timeopen','timeclose', 'timelimit', 'attempts', 'password'); +$keys = array('timeopen', 'timeclose', 'timelimit', 'attempts', 'password'); foreach ($keys as $key) { if (!isset($data->{$key}) || $reset) { $data->{$key} = $quiz->{$key}; } } -// If we are duplicating an override, then clear the user/group and override id since they will change +// If we are duplicating an override, then clear the user/group and override id +// since they will change. if ($action === 'duplicate') { $override->id = null; $override->userid = null; $override->groupid = null; } -$groupmode = !empty($data->groupid) || ($action === 'addgroup' && empty($overrideid)); // true if group-based override +// true if group-based override +$groupmode = !empty($data->groupid) || ($action === 'addgroup' && empty($overrideid)); $overridelisturl = new moodle_url('/mod/quiz/overrides.php', array('cmid'=>$cm->id)); if (!$groupmode) { @@ -151,7 +152,7 @@ if ($mform->is_cancelled()) { if ($oldoverride = $DB->get_record('quiz_overrides', $conditions)) { // There is an old override, so we merge any new settings on top of // the older override - foreach ($keys as $key) { + foreach ($keys as $key) { if (is_null($fromform->{$key})) { $fromform->{$key} = $oldoverride->{$key}; } @@ -164,8 +165,7 @@ if ($mform->is_cancelled()) { if (!empty($override->id)) { $fromform->id = $override->id; $DB->update_record('quiz_overrides', $fromform); - } - else { + } else { unset($fromform->id); $fromform->id = $DB->insert_record('quiz_overrides', $fromform); } diff --git a/mod/quiz/processattempt.php b/mod/quiz/processattempt.php index a9d2e4eff51..d28eae8a3c9 100644 --- a/mod/quiz/processattempt.php +++ b/mod/quiz/processattempt.php @@ -85,7 +85,8 @@ if (!$attemptobj->is_preview_user()) { // If the attempt is already closed, send them to the review page. if ($attemptobj->is_finished()) { - throw new moodle_quiz_exception($attemptobj->get_quizobj(), 'attemptalreadyclosed', null, $attemptobj->review_url()); + throw new moodle_quiz_exception($attemptobj->get_quizobj(), + 'attemptalreadyclosed', null, $attemptobj->review_url()); } // Don't log - we will end with a redirect to a page that is logged. @@ -94,7 +95,7 @@ if (!$finishattempt) { // Just process the responses for this page and go to the next page. try { $attemptobj->process_all_actions($timenow); - } catch (question_out_of_sequence_exception $e){ + } catch (question_out_of_sequence_exception $e) { print_error('submissionoutofsequencefriendlymessage', 'question', $attemptobj->attempt_url(0, $thispage)); } diff --git a/mod/quiz/report.php b/mod/quiz/report.php index 1135b4db304..bb3d9415b75 100644 --- a/mod/quiz/report.php +++ b/mod/quiz/report.php @@ -88,13 +88,17 @@ add_to_log($course->id, 'quiz', 'report', 'report.php?id=' . $cm->id . '&mode=' $quiz->id, $cm->id); // Open the selected quiz report and display it -include("report/$mode/report.php"); +$file = $CFG->dirroot . '/mod/quiz/report/' . $mode . '/report.php'; +if (is_readable($file)) { + include_once($file); +} $reportclassname = 'quiz_' . $mode . '_report'; -$report = new $reportclassname(); - -if (!$report->display($quiz, $cm, $course)) { +if (!class_exists($reportclassname)) { print_error('preprocesserror', 'quiz'); } +$report = new $reportclassname(); +$report->display($quiz, $cm, $course); + // Print footer echo $OUTPUT->footer(); diff --git a/mod/quiz/report/grading/gradingsettings_form.php b/mod/quiz/report/grading/gradingsettings_form.php index 06930fe6908..991df206131 100644 --- a/mod/quiz/report/grading/gradingsettings_form.php +++ b/mod/quiz/report/grading/gradingsettings_form.php @@ -66,11 +66,14 @@ class quiz_grading_settings extends moodleform { if ($type == 'autograded' && !$this->includeauto) { continue; } - $gradeoptions[$type] = get_string('gradeattempts' . $type, 'quiz_grading', $this->counts->$type); + $gradeoptions[$type] = get_string('gradeattempts' . $type, 'quiz_grading', + $this->counts->$type); } - $mform->addElement('select', 'grade', get_string('attemptstograde', 'quiz_grading'), $gradeoptions); + $mform->addElement('select', 'grade', get_string('attemptstograde', 'quiz_grading'), + $gradeoptions); - $mform->addElement('text', 'pagesize', get_string('questionsperpage', 'quiz_grading'), array('size' => 3)); + $mform->addElement('text', 'pagesize', get_string('questionsperpage', 'quiz_grading'), + array('size' => 3)); $mform->setType('pagesize', PARAM_INT); $orderoptions = array( @@ -83,7 +86,8 @@ class quiz_grading_settings extends moodleform { if ($this->showidnumbers) { $orderoptions['idnumber'] = get_string('bystudentidnumber', 'quiz_grading'); } - $mform->addElement('select', 'order', get_string('orderattempts', 'quiz_grading'), $orderoptions); + $mform->addElement('select', 'order', get_string('orderattempts', 'quiz_grading'), + $orderoptions); foreach ($this->hidden as $name => $value) { $mform->addElement('hidden', $name, $value); diff --git a/mod/quiz/report/grading/report.php b/mod/quiz/report/grading/report.php index 6fe4a1e0217..b09050e3c80 100644 --- a/mod/quiz/report/grading/report.php +++ b/mod/quiz/report/grading/report.php @@ -534,7 +534,8 @@ class quiz_grading_report extends quiz_default_report { $params = array(); if ($orderby == 'date') { - list($statetest, $params) = $dm->in_summary_state_test('manuallygraded', false, 'mangrstate'); + list($statetest, $params) = $dm->in_summary_state_test( + 'manuallygraded', false, 'mangrstate'); $orderby = "( SELECT MAX(sortqas.timecreated) FROM {question_attempt_steps} sortqas diff --git a/mod/quiz/report/overview/overviewgraph.php b/mod/quiz/report/overview/overviewgraph.php index 4b5f2a7137d..4fb5f93cfbd 100644 --- a/mod/quiz/report/overview/overviewgraph.php +++ b/mod/quiz/report/overview/overviewgraph.php @@ -48,7 +48,9 @@ if ($groupid && $groupmode = groups_get_activity_groupmode($cm)) { print_error('errorinvalidgroup', 'group', null, $groupid); } $group = $groups[$groupid]; - $groupusers = get_users_by_capability($modcontext, array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'),'','','','',$group->id,'',false); + $groupusers = get_users_by_capability($modcontext, + array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), + '', '', '', '', $group->id, '', false); if (!$groupusers) { print_error('nostudentsingroup'); } @@ -57,7 +59,7 @@ if ($groupid && $groupmode = groups_get_activity_groupmode($cm)) { $groupusers = array(); } -$line = new graph(800,600); +$line = new graph(800, 600); $line->parameter['title'] = ''; $line->parameter['y_label_left'] = get_string('participants'); $line->parameter['x_label'] = get_string('grade'); @@ -69,8 +71,10 @@ $line->parameter['x_axis_angle'] = 60; $line->y_tick_labels = null; $line->offset_relation = null; -$line->parameter['bar_size'] = 1; // will make size > 1 to get overlap effect when showing groups -$line->parameter['bar_spacing'] = 10; // don't forget to increase spacing so that graph doesn't become one big block of colour +// will make size > 1 to get overlap effect when showing groups +$line->parameter['bar_size'] = 1; +// don't forget to increase spacing so that graph doesn't become one big block of colour +$line->parameter['bar_spacing'] = 10; //pick a sensible number of bands depending on quiz maximum grade. $bands = $quiz->grade; diff --git a/mod/quiz/report/responses/report.php b/mod/quiz/report/responses/report.php index d48276ee084..c5c454bac30 100644 --- a/mod/quiz/report/responses/report.php +++ b/mod/quiz/report/responses/report.php @@ -180,7 +180,8 @@ class quiz_responses_report extends quiz_attempt_report { if ($hasquestions && ($hasstudents || $attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL)) { // Print information on the grading method and whether we are displaying if (!$table->is_downloading()) { //do not print notices when downloading - if ($strattempthighlight = quiz_report_highlighting_grading_method($quiz, $qmsubselect, $qmfilter)) { + if ($strattempthighlight = quiz_report_highlighting_grading_method( + $quiz, $qmsubselect, $qmfilter)) { echo '
' . $strattempthighlight . '
'; } } @@ -198,7 +199,7 @@ class quiz_responses_report extends quiz_attempt_report { if (!$table->is_downloading() && $candelete) { $columns[] = 'checkbox'; - $headers[] = NULL; + $headers[] = null; } $this->add_user_columns($table, $columns, $headers); diff --git a/mod/quiz/report/responses/responses_table.php b/mod/quiz/report/responses/responses_table.php index a2901e818f7..1f15f1b2d1b 100644 --- a/mod/quiz/report/responses/responses_table.php +++ b/mod/quiz/report/responses/responses_table.php @@ -65,7 +65,7 @@ class quiz_report_responses_table extends quiz_attempt_report_table { echo html_writer::input_hidden_params($url); echo '
'; $PAGE->requires->event_handler('#attemptsform', 'submit', 'M.util.show_confirm_dialog', - array('message' => get_string('deleteattemptcheck','quiz'))); + array('message' => get_string('deleteattemptcheck', 'quiz'))); } public function wrap_html_finish() { @@ -97,7 +97,8 @@ class quiz_report_responses_table extends quiz_attempt_report_table { return $grade; } - $gradehtml = ''.$grade.''; + $gradehtml = '' . $grade . ''; return $gradehtml; } @@ -139,7 +140,7 @@ class quiz_report_responses_table extends quiz_attempt_report_table { return $this->data_col($matches[1], 'rightanswer', $attempt); } else { - return NULL; + return null; } } diff --git a/mod/quiz/report/simpletest/testreportlib.php b/mod/quiz/report/simpletest/testreportlib.php index cf07620d247..439e7710c16 100644 --- a/mod/quiz/report/simpletest/testreportlib.php +++ b/mod/quiz/report/simpletest/testreportlib.php @@ -52,14 +52,14 @@ class question_reportlib_test extends UnitTestCase { $object->grade = 3; $datum[] = $object; - $indexed = quiz_report_index_by_keys($datum, array('aid','qid')); + $indexed = quiz_report_index_by_keys($datum, array('aid', 'qid')); $this->assertEqual($indexed[101][3]->qid, 3); $this->assertEqual($indexed[101][3]->aid, 101); $this->assertEqual($indexed[101][3]->response, ''); $this->assertEqual($indexed[101][3]->grade, 3); - $indexed = quiz_report_index_by_keys($datum, array('aid','qid'), false); + $indexed = quiz_report_index_by_keys($datum, array('aid', 'qid'), false); $this->assertEqual($indexed[101][3][0]->qid, 3); $this->assertEqual($indexed[101][3][0]->aid, 101); diff --git a/mod/quiz/report/statistics/cron.php b/mod/quiz/report/statistics/cron.php index c768fa713bd..3b40971440c 100644 --- a/mod/quiz/report/statistics/cron.php +++ b/mod/quiz/report/statistics/cron.php @@ -32,11 +32,12 @@ require_once($CFG->dirroot . '/question/engine/compatibility.php'); /** * Quiz statistics report cron code. Deletes cached data more than a certain age. */ - function quiz_report_statistics_cron() { +function quiz_report_statistics_cron() { global $DB; $expiretime = time() - 5*HOURSECS; - $todelete = $DB->get_records_select_menu('quiz_statistics', 'timemodified < ?', array($expiretime), '', 'id,1'); + $todelete = $DB->get_records_select_menu('quiz_statistics', 'timemodified < ?', + array($expiretime), '', 'id, 1'); if (!$todelete) { return true; @@ -44,15 +45,18 @@ require_once($CFG->dirroot . '/question/engine/compatibility.php'); list($todeletesql, $todeleteparams) = $DB->get_in_or_equal(array_keys($todelete)); - if (!$DB->delete_records_select('quiz_question_statistics', 'quizstatisticsid ' . $todeletesql, $todeleteparams)){ + if (!$DB->delete_records_select('quiz_question_statistics', + 'quizstatisticsid ' . $todeletesql, $todeleteparams)) { mtrace('Error deleting out of date quiz_question_statistics records.'); } - if (!$DB->delete_records_select('quiz_question_response_stats', 'quizstatisticsid ' . $todeletesql, $todeleteparams)) { + if (!$DB->delete_records_select('quiz_question_response_stats', + 'quizstatisticsid ' . $todeletesql, $todeleteparams)) { mtrace('Error deleting out of date quiz_question_response_stats records.'); } - if (!$DB->delete_records_select('quiz_statistics', 'id ' . $todeletesql, $todeleteparams)){ + if (!$DB->delete_records_select('quiz_statistics', + 'id ' . $todeletesql, $todeleteparams)) { mtrace('Error deleting out of date quiz_statistics records.'); } diff --git a/mod/quiz/report/statistics/responseanalysis.php b/mod/quiz/report/statistics/responseanalysis.php index b3dd4336fa7..425169766b5 100644 --- a/mod/quiz/report/statistics/responseanalysis.php +++ b/mod/quiz/report/statistics/responseanalysis.php @@ -67,8 +67,9 @@ class quiz_statistics_response_analyser { public function __construct($questiondata) { $this->questiondata = $questiondata; - $this->responseclasses = question_bank::get_qtype($questiondata->qtype)-> - get_possible_responses($questiondata); + $this->responseclasses = + question_bank::get_qtype($questiondata->qtype)->get_possible_responses( + $questiondata); foreach ($this->responseclasses as $subpartid => $responseclasses) { foreach ($responseclasses as $responseclassid => $notused) { $this->responses[$subpartid][$responseclassid] = array(); @@ -138,7 +139,8 @@ class quiz_statistics_response_analyser { $partresponses = $qa->classify_response(); foreach ($partresponses as $subpartid => $partresponse) { - if (!isset($this->responses[$subpartid][$partresponse->responseclassid][$partresponse->response])) { + if (!isset($this->responses[$subpartid][$partresponse->responseclassid] + [$partresponse->response])) { $resp = new stdClass(); $resp->count = 0; if (!is_null($partresponse->fraction)) { @@ -169,7 +171,8 @@ class quiz_statistics_response_analyser { global $DB; $rows = $DB->get_records('quiz_question_response_stats', - array('quizstatisticsid' => $quizstatisticsid, 'questionid' => $this->questiondata->id)); + array('quizstatisticsid' => $quizstatisticsid, + 'questionid' => $this->questiondata->id)); if (!$rows) { return false; } @@ -191,7 +194,8 @@ class quiz_statistics_response_analyser { global $DB; if (!$this->loaded) { - throw new coding_exception('Question responses have not been analyised. Cannot store in the database.'); + throw new coding_exception( + 'Question responses have not been analyised. Cannot store in the database.'); } foreach ($this->responses as $subpartid => $partdata) { diff --git a/mod/quiz/report/statistics/statistics_form.php b/mod/quiz/report/statistics/statistics_form.php index 21b70ee067c..0af385c9897 100644 --- a/mod/quiz/report/statistics/statistics_form.php +++ b/mod/quiz/report/statistics/statistics_form.php @@ -40,14 +40,17 @@ class quiz_statistics_statistics_settings_form extends moodleform { protected function definition() { $mform = $this->_form; - $mform->addElement('header', 'preferencespage', get_string('preferencespage', 'quiz_overview')); + $mform->addElement('header', 'preferencespage', + get_string('preferencespage', 'quiz_overview')); $options = array(); - $options[0] = get_string('attemptsfirst','quiz_statistics'); - $options[1] = get_string('attemptsall','quiz_statistics'); - $mform->addElement('select', 'useallattempts', get_string('calculatefrom', 'quiz_statistics'), $options); + $options[0] = get_string('attemptsfirst', 'quiz_statistics'); + $options[1] = get_string('attemptsall', 'quiz_statistics'); + $mform->addElement('select', 'useallattempts', + get_string('calculatefrom', 'quiz_statistics'), $options); $mform->setDefault('useallattempts', 0); - $mform->addElement('submit', 'submitbutton', get_string('preferencessave', 'quiz_overview')); + $mform->addElement('submit', 'submitbutton', + get_string('preferencessave', 'quiz_overview')); } } diff --git a/mod/quiz/report/statistics/statistics_graph.php b/mod/quiz/report/statistics/statistics_graph.php index d2c30140420..854421b3788 100644 --- a/mod/quiz/report/statistics/statistics_graph.php +++ b/mod/quiz/report/statistics/statistics_graph.php @@ -81,7 +81,7 @@ $questionstatistics = $DB->get_records_select('quiz_question_statistics', 'quizstatisticsid = ? AND slot IS NOT NULL', array($quizstatistics->id)); // Create the graph, and set the basic options. -$graph = new graph(800,600); +$graph = new graph(800, 600); $graph->parameter['title'] = ''; $graph->parameter['y_label_left'] = '%'; diff --git a/mod/quiz/report/statistics/statistics_question_table.php b/mod/quiz/report/statistics/statistics_question_table.php index fed8467ce46..abd09d15b85 100644 --- a/mod/quiz/report/statistics/statistics_question_table.php +++ b/mod/quiz/report/statistics/statistics_question_table.php @@ -62,7 +62,8 @@ class quiz_report_statistics_question_table extends flexible_table { * @param object $question a question with a _stats field * @param bool $hassubqs */ - public function setup($reporturl, $questiondata, quiz_statistics_response_analyser $responesstats) { + public function setup($reporturl, $questiondata, + quiz_statistics_response_analyser $responesstats) { $this->questiondata = $questiondata; $this->define_baseurl($reporturl->out()); diff --git a/mod/quiz/report/statistics/statistics_table.php b/mod/quiz/report/statistics/statistics_table.php index 5dc1159d7f1..6ffdd37f194 100644 --- a/mod/quiz/report/statistics/statistics_table.php +++ b/mod/quiz/report/statistics/statistics_table.php @@ -284,7 +284,8 @@ class quiz_report_statistics_table extends flexible_table { $negcovar = get_string('negcovar', 'quiz_statistics'); if (!$this->is_downloading()) { - $negcovar .= helpbutton('negcovar', $negcovar, 'quiz_statistics', true, false, '', true); + $negcovar .= helpbutton('negcovar', $negcovar, 'quiz_statistics', + true, false, '', true); $negcovar = '
' . $negcovar . '
'; } diff --git a/mod/quiz/reviewquestion.php b/mod/quiz/reviewquestion.php index 4b6483bd608..4c63f2a1245 100644 --- a/mod/quiz/reviewquestion.php +++ b/mod/quiz/reviewquestion.php @@ -59,7 +59,8 @@ if ($attemptobj->is_own_attempt()) { die(); } else if (!$options->responses) { $accessmanager = $attemptobj->get_access_manager(time()); - echo $OUTPUT->notification($accessmanager->cannot_review_message($attemptobj->get_review_options())); + echo $OUTPUT->notification($accessmanager->cannot_review_message( + $attemptobj->get_review_options())); echo $OUTPUT->close_window_button(); echo $OUTPUT->footer(); die(); diff --git a/mod/quiz/settings.php b/mod/quiz/settings.php index fa07060431d..c0f00d4dda7 100644 --- a/mod/quiz/settings.php +++ b/mod/quiz/settings.php @@ -116,11 +116,13 @@ $quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/penaltys // Each attempt builds on last. $quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/attemptonlast', - get_string('eachattemptbuildsonthelast', 'quiz'), get_string('configeachattemptbuildsonthelast', 'quiz'), + get_string('eachattemptbuildsonthelast', 'quiz'), + get_string('configeachattemptbuildsonthelast', 'quiz'), array('value' => 0, 'adv' => true))); // Review options. -$quizsettings->add(new admin_setting_heading('reviewheading', get_string('reviewoptionsheading', 'quiz'), '')); +$quizsettings->add(new admin_setting_heading('reviewheading', + get_string('reviewoptionsheading', 'quiz'), '')); foreach (mod_quiz_admin_review_setting::fields() as $field => $name) { $default = mod_quiz_admin_review_setting::all_on(); $forceduring = null; @@ -154,7 +156,8 @@ for ($i = 0; $i <= QUIZ_MAX_Q_DECIMAL_OPTION; $i++) { $options[$i] = $i; } $quizsettings->add(new admin_setting_configselect_with_advanced('quiz/questiondecimalpoints', - get_string('decimalplacesquestion', 'quiz'), get_string('configdecimalplacesquestion', 'quiz'), + get_string('decimalplacesquestion', 'quiz'), + get_string('configdecimalplacesquestion', 'quiz'), array('value' => -1, 'fix' => true), $options)); // Show blocks during quiz attempts @@ -185,19 +188,21 @@ $quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/popup', get_string('showinsecurepopup', 'quiz'), get_string('configpopup', 'quiz'), array('value' => 0, 'adv' => true))); -/// Now, depending on whether any reports have their own settings page, add -/// the quiz setting page to the appropriate place in the tree. +// Now, depending on whether any reports have their own settings page, add +// the quiz setting page to the appropriate place in the tree. if (empty($reportsbyname)) { $ADMIN->add('modsettings', $quizsettings); } else { - $ADMIN->add('modsettings', new admin_category('modsettingsquizcat', get_string('modulename', 'quiz'), !$module->visible)); + $ADMIN->add('modsettings', new admin_category('modsettingsquizcat', + get_string('modulename', 'quiz'), !$module->visible)); $ADMIN->add('modsettingsquizcat', $quizsettings); -/// Add the report pages for the settings.php files in sub directories of mod/quiz/report + // Add the report pages for the settings.php files in sub directories of mod/quiz/report foreach ($reportsbyname as $strreportname => $report) { $reportname = $report; - $settings = new admin_settingpage('modsettingsquizcat'.$reportname, $strreportname, 'moodle/site:config', !$module->visible); + $settings = new admin_settingpage('modsettingsquizcat'.$reportname, + $strreportname, 'moodle/site:config', !$module->visible); if ($ADMIN->fulltree) { include($CFG->dirroot."/mod/quiz/report/$reportname/settings.php"); } @@ -205,4 +210,4 @@ if (empty($reportsbyname)) { } } -$settings = NULL; // we do not want standard settings link +$settings = null; // we do not want standard settings link diff --git a/mod/quiz/settingslib.php b/mod/quiz/settingslib.php index 7d646f2c80c..6c1dc7774c4 100644 --- a/mod/quiz/settingslib.php +++ b/mod/quiz/settingslib.php @@ -68,7 +68,8 @@ class mod_quiz_admin_review_setting extends admin_setting { ); } - public function __construct($name, $visiblename, $description, $defaultsetting, $duringstate = null) { + public function __construct($name, $visiblename, $description, + $defaultsetting, $duringstate = null) { $this->duringstate = $duringstate; parent::__construct($name, $visiblename, $description, $defaultsetting); } diff --git a/mod/quiz/simpletest/testlocallib.php b/mod/quiz/simpletest/testlocallib.php index a81954954bc..be09184c846 100644 --- a/mod/quiz/simpletest/testlocallib.php +++ b/mod/quiz/simpletest/testlocallib.php @@ -105,11 +105,13 @@ class quiz_locallib_test extends UnitTestCase { $quiz->sumgrades = 10; $this->assertEqual(quiz_rescale_grade(0.12345678, $quiz, false), 0.12345678); $this->assertEqual(quiz_rescale_grade(0.12345678, $quiz, true), format_float(0.12, 2)); - $this->assertEqual(quiz_rescale_grade(0.12345678, $quiz, 'question'), format_float(0.123, 3)); + $this->assertEqual(quiz_rescale_grade(0.12345678, $quiz, 'question'), + format_float(0.123, 3)); $quiz->sumgrades = 5; $this->assertEqual(quiz_rescale_grade(0.12345678, $quiz, false), 0.24691356); $this->assertEqual(quiz_rescale_grade(0.12345678, $quiz, true), format_float(0.25, 2)); - $this->assertEqual(quiz_rescale_grade(0.12345678, $quiz, 'question'), format_float(0.247, 3)); + $this->assertEqual(quiz_rescale_grade(0.12345678, $quiz, 'question'), + format_float(0.247, 3)); } public function test_quiz_get_slot_for_question() { diff --git a/mod/quiz/simpletest/testquizdisplayoptions.php b/mod/quiz/simpletest/testquizdisplayoptions.php index f17808d63b7..239e9e40393 100644 --- a/mod/quiz/simpletest/testquizdisplayoptions.php +++ b/mod/quiz/simpletest/testquizdisplayoptions.php @@ -49,7 +49,8 @@ class mod_quiz_display_options_test extends UnitTestCase { $quiz->reviewrightanswer = 0x00100; $quiz->reviewoverallfeedback = 0x00010; - $options = mod_quiz_display_options::make_from_quiz($quiz, mod_quiz_display_options::DURING); + $options = mod_quiz_display_options::make_from_quiz($quiz, + mod_quiz_display_options::DURING); $this->assertEqual(true, $options->attempt); $this->assertEqual(mod_quiz_display_options::VISIBLE, $options->correctness); @@ -57,19 +58,22 @@ class mod_quiz_display_options_test extends UnitTestCase { $this->assertEqual(2, $options->markdp); $quiz->questiondecimalpoints = 5; - $options = mod_quiz_display_options::make_from_quiz($quiz, mod_quiz_display_options::IMMEDIATELY_AFTER); + $options = mod_quiz_display_options::make_from_quiz($quiz, + mod_quiz_display_options::IMMEDIATELY_AFTER); $this->assertEqual(mod_quiz_display_options::MARK_AND_MAX, $options->marks); $this->assertEqual(mod_quiz_display_options::VISIBLE, $options->generalfeedback); $this->assertEqual(mod_quiz_display_options::HIDDEN, $options->feedback); $this->assertEqual(5, $options->markdp); - $options = mod_quiz_display_options::make_from_quiz($quiz, mod_quiz_display_options::LATER_WHILE_OPEN); + $options = mod_quiz_display_options::make_from_quiz($quiz, + mod_quiz_display_options::LATER_WHILE_OPEN); $this->assertEqual(mod_quiz_display_options::VISIBLE, $options->rightanswer); $this->assertEqual(mod_quiz_display_options::HIDDEN, $options->generalfeedback); - $options = mod_quiz_display_options::make_from_quiz($quiz, mod_quiz_display_options::AFTER_CLOSE); + $options = mod_quiz_display_options::make_from_quiz($quiz, + mod_quiz_display_options::AFTER_CLOSE); $this->assertEqual(mod_quiz_display_options::VISIBLE, $options->overallfeedback); $this->assertEqual(mod_quiz_display_options::HIDDEN, $options->rightanswer); diff --git a/mod/quiz/startattempt.php b/mod/quiz/startattempt.php index 3c496733db6..58bfbd1af79 100644 --- a/mod/quiz/startattempt.php +++ b/mod/quiz/startattempt.php @@ -72,16 +72,17 @@ if (!$quizobj->is_preview_user()) { // Check to see if a new preview was requested. if ($quizobj->is_preview_user() && $forcenew) { -// To force the creation of a new preview, we set a finish time on the -// current attempt (if any). It will then automatically be deleted below - $DB->set_field('quiz_attempts', 'timefinish', time(), array('quiz' => $quiz->id, 'userid' => $USER->id)); + // To force the creation of a new preview, we set a finish time on the + // current attempt (if any). It will then automatically be deleted below + $DB->set_field('quiz_attempts', 'timefinish', time(), + array('quiz' => $quiz->id, 'userid' => $USER->id)); } // Look for an existing attempt. $lastattempt = quiz_get_latest_attempt_by_user($quiz->id, $USER->id); if ($lastattempt && !$lastattempt->timefinish) { -// Continuation of an attempt - check password then redirect. + // Continuation of an attempt - check password then redirect. $accessmanager->do_password_check($quizobj->is_preview_user()); redirect($quizobj->attempt_url($lastattempt->id)); } @@ -110,7 +111,8 @@ $quba = question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj-> $quba->set_preferred_behaviour($quiz->preferredbehaviour); // Create the new attempt and initialize the question sessions -$attempt = quiz_create_attempt($quiz, $attemptnumber, $lastattempt, time(), $quizobj->is_preview_user()); +$attempt = quiz_create_attempt($quiz, $attemptnumber, $lastattempt, time(), + $quizobj->is_preview_user()); if (!($quiz->attemptonlast && $lastattempt)) { // Starting a normal, new, quiz attempt. diff --git a/mod/quiz/summary.php b/mod/quiz/summary.php index 791f7aeae8d..daa5b7374ed 100644 --- a/mod/quiz/summary.php +++ b/mod/quiz/summary.php @@ -68,7 +68,8 @@ $accessmanager->do_password_check($attemptobj->is_preview_user()); $displayoptions = $attemptobj->get_display_options(false); // Log this page view. -add_to_log($attemptobj->get_courseid(), 'quiz', 'view summary', 'summary.php?attempt=' . $attemptobj->get_attemptid(), +add_to_log($attemptobj->get_courseid(), 'quiz', 'view summary', + 'summary.php?attempt=' . $attemptobj->get_attemptid(), $attemptobj->get_quizid(), $attemptobj->get_cmid()); // Print the page header @@ -80,8 +81,9 @@ $title = get_string('summaryofattempt', 'quiz'); if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) { $accessmanager->setup_secure_page($attemptobj->get_course()->shortname . ': ' . format_string($attemptobj->get_quiz_name()), ''); -} elseif ($accessmanager->safebrowser_required($attemptobj->is_preview_user())) { - $PAGE->set_title($attemptobj->get_course()->shortname . ': '.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_heading($attemptobj->get_course()->fullname); $PAGE->set_cacheable(false); echo $OUTPUT->header(); diff --git a/mod/quiz/view.php b/mod/quiz/view.php index de86ca42190..25223d1daf2 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -69,7 +69,7 @@ $canpreview = has_capability('mod/quiz:preview', $context); // Create an object to manage all the other (non-roles) access rules. $timenow = time(); $accessmanager = new quiz_access_manager(quiz::create($quiz->id, $USER->id), $timenow, - has_capability('mod/quiz:ignoretimelimits', $context, NULL, false)); + has_capability('mod/quiz:ignoretimelimits', $context, null, false)); // Log this request. add_to_log($course->id, 'quiz', 'view', 'view.php?id=' . $cm->id, $quiz->id, $cm->id); @@ -96,7 +96,8 @@ if (trim(strip_tags($quiz->intro))) { // Display information about this quiz. $messages = $accessmanager->describe_rules(); if ($quiz->attempts != 1) { - $messages[] = get_string('gradingmethod', 'quiz', quiz_get_grading_option_name($quiz->grademethod)); + $messages[] = get_string('gradingmethod', 'quiz', + quiz_get_grading_option_name($quiz->grademethod)); } echo $OUTPUT->box_start('quizinfo'); $accessmanager->print_messages($messages); @@ -170,7 +171,8 @@ if ($attempts) { $attemptcolumn = $quiz->attempts != 1; - $gradecolumn = $someoptions->marks >= question_display_options::MARK_AND_MAX && quiz_has_grades($quiz); + $gradecolumn = $someoptions->marks >= question_display_options::MARK_AND_MAX && + quiz_has_grades($quiz); $markcolumn = $gradecolumn && ($quiz->grade != $quiz->sumgrades); $overallstats = $alloptions->marks >= question_display_options::MARK_AND_MAX; @@ -191,12 +193,14 @@ if ($attempts) { $table->align[] = 'left'; $table->size[] = ''; if ($markcolumn) { - $table->head[] = get_string('marks', 'quiz') . ' / ' . quiz_format_grade($quiz, $quiz->sumgrades); + $table->head[] = get_string('marks', 'quiz') . ' / ' . + quiz_format_grade($quiz, $quiz->sumgrades); $table->align[] = 'center'; $table->size[] = ''; } if ($gradecolumn) { - $table->head[] = get_string('grade') . ' / ' . quiz_format_grade($quiz, $quiz->grade); + $table->head[] = get_string('grade') . ' / ' . + quiz_format_grade($quiz, $quiz->grade); $table->align[] = 'center'; $table->size[] = ''; } @@ -259,7 +263,8 @@ if ($attempts) { $attemptgrade = quiz_rescale_grade($attempt->sumgrades, $quiz, false); if ($gradecolumn) { - if ($attemptoptions->marks >= question_display_options::MARK_AND_MAX && $attempt->timefinish > 0) { + if ($attemptoptions->marks >= question_display_options::MARK_AND_MAX && + $attempt->timefinish > 0) { $formattedgrade = quiz_format_grade($quiz, $attemptgrade); // highlight the highest grade if appropriate if ($overallstats && !$attempt->preview && $numattempts > 1 && !is_null($mygrade) && @@ -324,7 +329,8 @@ if ($numattempts && $gradecolumn && !is_null($mygrade)) { } if ($mygradeoverridden) { - $resultinfo .= '

'.get_string('overriddennotice', 'grades')."

\n"; + $resultinfo .= '

' . + get_string('overriddennotice', 'grades') . "

\n"; } if ($gradebookfeedback) { $resultinfo .= $OUTPUT->heading(get_string('comment', 'quiz'), 3, 'main'); @@ -332,7 +338,8 @@ if ($numattempts && $gradecolumn && !is_null($mygrade)) { } if ($feedbackcolumn) { $resultinfo .= $OUTPUT->heading(get_string('overallfeedback', 'quiz'), 3, 'main'); - $resultinfo .= '

'.quiz_feedback_for_grade($mygrade, $quiz, $context, $cm)."

\n"; + $resultinfo .= '

' . + quiz_feedback_for_grade($mygrade, $quiz, $context, $cm) . "

\n"; } if ($resultinfo) { @@ -372,7 +379,8 @@ if (!quiz_clean_layout($quiz->questions, true)) { } } - // If, so far, we think a button should be printed, so check if they will be allowed to access it. + // If, so far, we think a button should be printed, so check if they will be + // allowed to access it. if ($buttontext) { if (!$moreattempts) { $buttontext = '';