MDL-29627 fix code-checker issues throughout the quiz code.
This commit is contained in:
@@ -145,12 +145,12 @@ abstract class quiz_access_rule_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the attempt (review or summary) page with any special extra
|
||||
* properties required by this rule. securewindow rule is an example of where
|
||||
* this is used.
|
||||
*
|
||||
* @param moodle_page $page the page object to initialise.
|
||||
*/
|
||||
* Sets up the attempt (review or summary) page with any special extra
|
||||
* properties required by this rule. securewindow rule is an example of where
|
||||
* this is used.
|
||||
*
|
||||
* @param moodle_page $page the page object to initialise.
|
||||
*/
|
||||
public function setup_attempt_page($page) {
|
||||
// Do nothing by default.
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@ require_once($CFG->dirroot . '/mod/quiz/accessrule/accessrulebase.php');
|
||||
|
||||
|
||||
/**
|
||||
* A rule imposing the delay between attempts settings.
|
||||
*
|
||||
* @copyright 2009 Tim Hunt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
* A rule imposing the delay between attempts settings.
|
||||
*
|
||||
* @copyright 2009 Tim Hunt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class quizaccess_delaybetweenattempts extends quiz_access_rule_base {
|
||||
|
||||
public static function make(quiz $quizobj, $timenow, $canignoretimelimits) {
|
||||
@@ -42,7 +42,7 @@ class quizaccess_delaybetweenattempts extends quiz_access_rule_base {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->rules[] = new self($quizobj, $timenow);
|
||||
return new self($quizobj, $timenow);
|
||||
}
|
||||
|
||||
public function prevent_new_attempt($numprevattempts, $lastattempt) {
|
||||
|
||||
@@ -30,11 +30,11 @@ require_once($CFG->dirroot . '/mod/quiz/accessrule/accessrulebase.php');
|
||||
|
||||
|
||||
/**
|
||||
* A rule controlling the number of attempts allowed.
|
||||
*
|
||||
* @copyright 2009 Tim Hunt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
* A rule controlling the number of attempts allowed.
|
||||
*
|
||||
* @copyright 2009 Tim Hunt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class quizaccess_numattempts extends quiz_access_rule_base {
|
||||
|
||||
public static function make(quiz $quizobj, $timenow, $canignoretimelimits) {
|
||||
|
||||
@@ -30,11 +30,11 @@ require_once($CFG->dirroot . '/mod/quiz/accessrule/accessrulebase.php');
|
||||
|
||||
|
||||
/**
|
||||
* A rule representing the safe browser check.
|
||||
*
|
||||
* @copyright 2009 Oliver Rahs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
* A rule representing the safe browser check.
|
||||
*
|
||||
* @copyright 2009 Oliver Rahs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class quizaccess_safebrowser extends quiz_access_rule_base {
|
||||
|
||||
public static function make(quiz $quizobj, $timenow, $canignoretimelimits) {
|
||||
@@ -68,7 +68,7 @@ class quizaccess_safebrowser extends quiz_access_rule_base {
|
||||
*
|
||||
* @return true, if browser is safe browser else false
|
||||
*/
|
||||
function check_safe_browser() {
|
||||
public function check_safe_browser() {
|
||||
return strpos($_SERVER['HTTP_USER_AGENT'], 'SEB') !== false;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,12 +30,12 @@ require_once($CFG->dirroot . '/mod/quiz/accessrule/accessrulebase.php');
|
||||
|
||||
|
||||
/**
|
||||
* A rule for ensuring that the quiz is opened in a popup, with some JavaScript
|
||||
* to prevent copying and pasting, etc.
|
||||
*
|
||||
* @copyright 2009 Tim Hunt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
* A rule for ensuring that the quiz is opened in a popup, with some JavaScript
|
||||
* to prevent copying and pasting, etc.
|
||||
*
|
||||
* @copyright 2009 Tim Hunt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class quizaccess_securewindow extends quiz_access_rule_base {
|
||||
/** @var array options that should be used for opening the secure popup. */
|
||||
protected static $popupoptions = array(
|
||||
|
||||
@@ -30,12 +30,12 @@ require_once($CFG->dirroot . '/mod/quiz/accessrule/accessrulebase.php');
|
||||
|
||||
|
||||
/**
|
||||
* A rule representing the time limit. It does not actually restrict access, but we use this
|
||||
* class to encapsulate some of the relevant code.
|
||||
*
|
||||
* @copyright 2009 Tim Hunt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
* A rule representing the time limit. It does not actually restrict access, but we use this
|
||||
* class to encapsulate some of the relevant code.
|
||||
*
|
||||
* @copyright 2009 Tim Hunt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class quizaccess_timelimit extends quiz_access_rule_base {
|
||||
|
||||
public static function make(quiz $quizobj, $timenow, $canignoretimelimits) {
|
||||
|
||||
@@ -1311,7 +1311,7 @@ abstract class quiz_nav_panel_base {
|
||||
}
|
||||
|
||||
protected function get_state_string(question_attempt $qa, $showcorrectness) {
|
||||
if ($qa->get_question()->length > 0) {
|
||||
if ($qa->get_question()->length > 0) {
|
||||
return $qa->get_state_string($showcorrectness);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -64,10 +63,14 @@ class moodle1_mod_quiz_handler extends moodle1_mod_handler {
|
||||
)
|
||||
)
|
||||
),
|
||||
new convert_path('quiz_question_instances', '/MOODLE_BACKUP/COURSE/MODULES/MOD/QUIZ/QUESTION_INSTANCES'),
|
||||
new convert_path('quiz_question_instance', '/MOODLE_BACKUP/COURSE/MODULES/MOD/QUIZ/QUESTION_INSTANCES/QUESTION_INSTANCE'),
|
||||
new convert_path('quiz_feedbacks', '/MOODLE_BACKUP/COURSE/MODULES/MOD/QUIZ/FEEDBACKS'),
|
||||
new convert_path('quiz_feedback', '/MOODLE_BACKUP/COURSE/MODULES/MOD/QUIZ/FEEDBACKS/FEEDBACK',
|
||||
new convert_path('quiz_question_instances',
|
||||
'/MOODLE_BACKUP/COURSE/MODULES/MOD/QUIZ/QUESTION_INSTANCES'),
|
||||
new convert_path('quiz_question_instance',
|
||||
'/MOODLE_BACKUP/COURSE/MODULES/MOD/QUIZ/QUESTION_INSTANCES/QUESTION_INSTANCE'),
|
||||
new convert_path('quiz_feedbacks',
|
||||
'/MOODLE_BACKUP/COURSE/MODULES/MOD/QUIZ/FEEDBACKS'),
|
||||
new convert_path('quiz_feedback',
|
||||
'/MOODLE_BACKUP/COURSE/MODULES/MOD/QUIZ/FEEDBACKS/FEEDBACK',
|
||||
array(
|
||||
'newfields' => array(
|
||||
'feedbacktextformat' => 0
|
||||
@@ -112,12 +115,14 @@ class moodle1_mod_quiz_handler extends moodle1_mod_handler {
|
||||
// convert course files embedded into the intro
|
||||
$this->fileman->filearea = 'intro';
|
||||
$this->fileman->itemid = 0;
|
||||
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
|
||||
$data['intro'] = moodle1_converter::migrate_referenced_files(
|
||||
$data['intro'], $this->fileman);
|
||||
|
||||
// start writing quiz.xml
|
||||
$this->open_xml_writer("activities/quiz_{$this->moduleid}/quiz.xml");
|
||||
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid,
|
||||
'modulename' => 'quiz', 'contextid' => $contextid));
|
||||
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid,
|
||||
'moduleid' => $this->moduleid, 'modulename' => 'quiz',
|
||||
'contextid' => $contextid));
|
||||
$this->xmlwriter->begin_tag('quiz', array('id' => $instanceid));
|
||||
|
||||
foreach ($data as $field => $value) {
|
||||
|
||||
+3
-2
@@ -369,8 +369,9 @@ function quiz_user_outline($course, $user, $mod, $quiz) {
|
||||
$result->info = get_string('grade') . ': ' . $grade->str_long_grade;
|
||||
|
||||
//datesubmitted == time created. dategraded == time modified or time overridden
|
||||
//if grade was last modified by the user themselves use date graded. Otherwise use date submitted
|
||||
//TODO: move this copied & pasted code somewhere in the grades API. See MDL-26704
|
||||
//if grade was last modified by the user themselves use date graded. Otherwise use
|
||||
// date submitted
|
||||
// TODO: move this copied & pasted code somewhere in the grades API. See MDL-26704
|
||||
if ($grade->usermodified == $user->id || empty($grade->datesubmitted)) {
|
||||
$result->time = $grade->dategraded;
|
||||
} else {
|
||||
|
||||
@@ -715,7 +715,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
|
||||
* @param object $context the quiz context.
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
function no_questions_message($canedit, $editurl) {
|
||||
public function no_questions_message($canedit, $editurl) {
|
||||
$output = '';
|
||||
$output .= $this->notification(get_string('noquestions', 'quiz'));
|
||||
if ($canedit) {
|
||||
@@ -1093,7 +1093,8 @@ class mod_quiz_view_object {
|
||||
public $attempts;
|
||||
/** @var quiz_access_manager $accessmanager contains various access rules. */
|
||||
public $accessmanager;
|
||||
/** @var bool $canreviewmine whether the current user has the capability to review their own attempts. */
|
||||
/** @var bool $canreviewmine whether the current user has the capability to
|
||||
* review their own attempts. */
|
||||
public $canreviewmine;
|
||||
/** @var bool $canedit whether the current user has the capability to edit the quiz. */
|
||||
public $canedit;
|
||||
@@ -1125,7 +1126,8 @@ class mod_quiz_view_object {
|
||||
public $unfinished;
|
||||
/** @var object $lastfinishedattempt the last attempt from the attempts array. */
|
||||
public $lastfinishedattempt;
|
||||
/** @var array $preventmessages of messages telling the user why they can't attempt the quiz now. */
|
||||
/** @var array $preventmessages of messages telling the user why they can't
|
||||
* attempt the quiz now. */
|
||||
public $preventmessages;
|
||||
/** @var string $buttontext caption for the start attempt button. If this is null, show no
|
||||
* button, or if it is '' show a back to the course button. */
|
||||
|
||||
@@ -19,4 +19,4 @@
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</XMLDB>
|
||||
</XMLDB>
|
||||
|
||||
@@ -117,10 +117,12 @@ class quiz_overview_report extends quiz_attempt_report {
|
||||
}
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));
|
||||
$courseshortname = format_string($course->shortname, true,
|
||||
array('context' => $coursecontext));
|
||||
|
||||
$displaycoursecontext = get_context_instance(CONTEXT_COURSE, $COURSE->id);
|
||||
$displaycourseshortname = format_string($COURSE->shortname, true, array('context' => $displaycoursecontext));
|
||||
$displaycourseshortname = format_string($COURSE->shortname, true,
|
||||
array('context' => $displaycoursecontext));
|
||||
|
||||
// Load the required questions.
|
||||
$questions = quiz_report_get_significant_questions($quiz);
|
||||
|
||||
@@ -124,7 +124,8 @@ class quiz_responses_report extends quiz_attempt_report {
|
||||
$allowed = array();
|
||||
}
|
||||
|
||||
if ($attemptids = optional_param_array('attemptid', array(), PARAM_INT) && confirm_sesskey()) {
|
||||
$attemptids = optional_param_array('attemptid', array(), PARAM_INT);
|
||||
if ($attemptids && confirm_sesskey()) {
|
||||
require_capability('mod/quiz:deleteattempts', $this->context);
|
||||
$this->delete_selected_attempts($quiz, $cm, $attemptids, $allowed);
|
||||
redirect($reporturl->out(false, $displayoptions));
|
||||
@@ -134,10 +135,12 @@ class quiz_responses_report extends quiz_attempt_report {
|
||||
$questions = quiz_report_get_significant_questions($quiz);
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));
|
||||
$courseshortname = format_string($course->shortname, true,
|
||||
array('context' => $coursecontext));
|
||||
|
||||
$displaycoursecontext = get_context_instance(CONTEXT_COURSE, $COURSE->id);
|
||||
$displaycourseshortname = format_string($COURSE->shortname, true, array('context' => $displaycoursecontext));
|
||||
$displaycourseshortname = format_string($COURSE->shortname, true,
|
||||
array('context' => $displaycoursecontext));
|
||||
|
||||
$table = new quiz_report_responses_table($quiz, $this->context, $qmsubselect,
|
||||
$groupstudents, $students, $questions, $candelete, $reporturl, $displayoptions);
|
||||
|
||||
@@ -385,7 +385,8 @@ function xmldb_quiz_statistics_upgrade($oldversion) {
|
||||
|
||||
// Changing sign of field maxmark on table quiz_question_statistics to signed
|
||||
$table = new xmldb_table('quiz_question_statistics');
|
||||
$field = new xmldb_field('maxmark', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'subquestions');
|
||||
$field = new xmldb_field('maxmark', XMLDB_TYPE_NUMBER, '12, 7', null,
|
||||
null, null, null, 'subquestions');
|
||||
|
||||
// Launch change of sign for field maxmark
|
||||
$dbman->change_field_unsigned($table, $field);
|
||||
|
||||
@@ -116,7 +116,8 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
$report = get_string('questionstatsfilename', 'quiz_statistics');
|
||||
}
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));
|
||||
$courseshortname = format_string($course->shortname, true,
|
||||
array('context' => $coursecontext));
|
||||
$filename = quiz_report_download_filename($report, $courseshortname, $quiz->name);
|
||||
$this->table->is_downloading($download, $filename,
|
||||
get_string('quizstructureanalysis', 'quiz_statistics'));
|
||||
|
||||
Reference in New Issue
Block a user