MDL-76899 quiz: bulk fix all array literals array() -> []
This was done with PHPStorm's automated tool. No manual editing
This commit is contained in:
@@ -44,7 +44,7 @@ class quizaccess_offlineattempts extends access_rule_base {
|
||||
|
||||
// First, check if the user did something offline.
|
||||
if (!empty($attemptid)) {
|
||||
$timemodifiedoffline = $DB->get_field('quiz_attempts', 'timemodifiedoffline', array('id' => $attemptid));
|
||||
$timemodifiedoffline = $DB->get_field('quiz_attempts', 'timemodifiedoffline', ['id' => $attemptid]);
|
||||
if (empty($timemodifiedoffline)) {
|
||||
return false;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ class quizaccess_offlineattempts extends access_rule_base {
|
||||
MoodleQuickForm $mform, $attemptid) {
|
||||
global $DB;
|
||||
|
||||
$timemodifiedoffline = $DB->get_field('quiz_attempts', 'timemodifiedoffline', array('id' => $attemptid));
|
||||
$timemodifiedoffline = $DB->get_field('quiz_attempts', 'timemodifiedoffline', ['id' => $attemptid]);
|
||||
$lasttime = format_time(time() - $timemodifiedoffline);
|
||||
|
||||
$mform->addElement('header', 'offlineattemptsheader', get_string('mobileapp', 'quizaccess_offlineattempts'));
|
||||
|
||||
@@ -54,7 +54,7 @@ class quizaccess_password extends access_rule_base {
|
||||
// Don't use the 'proper' field name of 'password' since that get's
|
||||
// Firefox's password auto-complete over-excited.
|
||||
$mform->addElement('password', 'quizpassword',
|
||||
get_string('quizpassword', 'quizaccess_password'), array('autofocus' => 'true'));
|
||||
get_string('quizpassword', 'quizaccess_password'), ['autofocus' => 'true']);
|
||||
}
|
||||
|
||||
public function validate_preflight_check($data, $files, $errors, $attemptid) {
|
||||
|
||||
@@ -110,7 +110,7 @@ class access_prevented extends base {
|
||||
* @return array Mapping of object id.
|
||||
*/
|
||||
public static function get_objectid_mapping() : array {
|
||||
return array('db' => 'quiz', 'restore' => 'quiz');
|
||||
return ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -106,7 +106,7 @@ class template_created extends base {
|
||||
* @return array Mapping of object id.
|
||||
*/
|
||||
public static function get_objectid_mapping() : array {
|
||||
return array('db' => 'quizaccess_seb_template', 'restore' => 'quizaccess_seb_template');
|
||||
return ['db' => 'quizaccess_seb_template', 'restore' => 'quizaccess_seb_template'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -100,7 +100,7 @@ class template_deleted extends base {
|
||||
* @return array Mapping of object id.
|
||||
*/
|
||||
public static function get_objectid_mapping() : array {
|
||||
return array('db' => 'quizaccess_seb_template', 'restore' => 'quizaccess_seb_template');
|
||||
return ['db' => 'quizaccess_seb_template', 'restore' => 'quizaccess_seb_template'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -106,7 +106,7 @@ class template_disabled extends base {
|
||||
* @return array Mapping of object id.
|
||||
*/
|
||||
public static function get_objectid_mapping() : array {
|
||||
return array('db' => 'quizaccess_seb_template', 'restore' => 'quizaccess_seb_template');
|
||||
return ['db' => 'quizaccess_seb_template', 'restore' => 'quizaccess_seb_template'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -106,7 +106,7 @@ class template_enabled extends base {
|
||||
* @return array Mapping of object id.
|
||||
*/
|
||||
public static function get_objectid_mapping() : array {
|
||||
return array('db' => 'quizaccess_seb_template', 'restore' => 'quizaccess_seb_template');
|
||||
return ['db' => 'quizaccess_seb_template', 'restore' => 'quizaccess_seb_template'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -106,7 +106,7 @@ class template_updated extends base {
|
||||
* @return array Mapping of object id.
|
||||
*/
|
||||
public static function get_objectid_mapping() : array {
|
||||
return array('db' => 'quizaccess_seb_template', 'restore' => 'quizaccess_seb_template');
|
||||
return ['db' => 'quizaccess_seb_template', 'restore' => 'quizaccess_seb_template'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,7 +47,7 @@ class helper {
|
||||
* @param array $options Display options.
|
||||
* @return string
|
||||
*/
|
||||
public static function format_icon_link($url, $icon, $alt, $iconcomponent = 'moodle', $options = array()) {
|
||||
public static function format_icon_link($url, $icon, $alt, $iconcomponent = 'moodle', $options = []) {
|
||||
global $OUTPUT;
|
||||
|
||||
return $OUTPUT->action_icon(
|
||||
|
||||
@@ -25,213 +25,213 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$capabilities = array(
|
||||
'quizaccess/seb:managetemplates' => array(
|
||||
$capabilities = [
|
||||
'quizaccess/seb:managetemplates' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_SYSTEM,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:bypassseb' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:bypassseb' => [
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_requiresafeexambrowser' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_requiresafeexambrowser' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_templateid' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_templateid' => [
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_filemanager_sebconfigfile' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_filemanager_sebconfigfile' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_showsebdownloadlink' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_showsebdownloadlink' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_allowedbrowserexamkeys' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_allowedbrowserexamkeys' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_linkquitseb' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_linkquitseb' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_userconfirmquit' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_userconfirmquit' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_allowuserquitseb' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_allowuserquitseb' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_quitpassword' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_quitpassword' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_allowreloadinexam' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_allowreloadinexam' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_showsebtaskbar' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_showsebtaskbar' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_showreloadbutton' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_showreloadbutton' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_showtime' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_showtime' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_showkeyboardlayout' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_showkeyboardlayout' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
]
|
||||
],
|
||||
|
||||
'quizaccess/seb:manage_seb_showwificontrol' => array(
|
||||
'quizaccess/seb:manage_seb_showwificontrol' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_enableaudiocontrol' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_enableaudiocontrol' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_muteonstartup' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_muteonstartup' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_allowspellchecking' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_allowspellchecking' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_activateurlfiltering' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_activateurlfiltering' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_filterembeddedcontent' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_filterembeddedcontent' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_expressionsallowed' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_expressionsallowed' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_regexallowed' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_regexallowed' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_expressionsblocked' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_expressionsblocked' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'quizaccess/seb:manage_seb_regexblocked' => array(
|
||||
]
|
||||
],
|
||||
'quizaccess/seb:manage_seb_regexblocked' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
);
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
@@ -38,7 +38,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool false if the file not found, just send the file otherwise and do not return anything
|
||||
*/
|
||||
function quizaccess_seb_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
|
||||
function quizaccess_seb_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options= []) {
|
||||
if ($context->contextlevel != CONTEXT_MODULE) {
|
||||
return false;
|
||||
}
|
||||
@@ -68,4 +68,4 @@ function quizaccess_seb_pluginfile($course, $cm, $context, $filearea, $args, $fo
|
||||
}
|
||||
|
||||
send_stored_file($file, 0, 0, $forcedownload, $options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -543,7 +543,7 @@ class quizaccess_seb extends access_rule_base {
|
||||
// Rendering as a href and not as button in a form to circumvent browser warnings for sending to URL with unknown protocol.
|
||||
$seblink = \quizaccess_seb\link_generator::get_link($this->quiz->cmid, true, is_https());
|
||||
|
||||
$buttonlink = html_writer::start_tag('div', array('class' => 'singlebutton'));
|
||||
$buttonlink = html_writer::start_tag('div', ['class' => 'singlebutton']);
|
||||
$buttonlink .= html_writer::link($seblink, get_string('seblinkbutton', 'quizaccess_seb'),
|
||||
['class' => 'btn btn-secondary', 'title' => get_string('seblinkbutton', 'quizaccess_seb')]);
|
||||
$buttonlink .= html_writer::end_tag('div');
|
||||
@@ -560,7 +560,7 @@ class quizaccess_seb extends access_rule_base {
|
||||
// Rendering as a href and not as button in a form to circumvent browser warnings for sending to URL with unknown protocol.
|
||||
$httplink = \quizaccess_seb\link_generator::get_link($this->quiz->cmid, false, is_https());
|
||||
|
||||
$buttonlink = html_writer::start_tag('div', array('class' => 'singlebutton'));
|
||||
$buttonlink = html_writer::start_tag('div', ['class' => 'singlebutton']);
|
||||
$buttonlink .= html_writer::link($httplink, get_string('httplinkbutton', 'quizaccess_seb'),
|
||||
['class' => 'btn btn-secondary', 'title' => get_string('httplinkbutton', 'quizaccess_seb')]);
|
||||
$buttonlink .= html_writer::end_tag('div');
|
||||
|
||||
@@ -109,7 +109,7 @@ class provider_test extends provider_testcase {
|
||||
// per table, like postgres and mysql do, rendering this useless. In any
|
||||
// case better to have the situation covered by some DBs,
|
||||
// like sqlsrv or oracle than by none).
|
||||
$this->getDataGenerator()->create_module('label', array('course' => $this->course->id));
|
||||
$this->getDataGenerator()->create_module('label', ['course' => $this->course->id]);
|
||||
|
||||
$contextlist = provider::get_contexts_for_userid($this->user->id);
|
||||
$approvedcontextlist = new approved_contextlist(
|
||||
|
||||
@@ -172,9 +172,9 @@ trait quizaccess_seb_test_helper_trait {
|
||||
$questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$cat = $questiongenerator->create_question_category();
|
||||
|
||||
$saq = $questiongenerator->create_question('shortanswer', null, array('category' => $cat->id));
|
||||
$saq = $questiongenerator->create_question('shortanswer', null, ['category' => $cat->id]);
|
||||
quiz_add_quiz_question($saq->id, $quiz);
|
||||
$numq = $questiongenerator->create_question('numerical', null, array('category' => $cat->id));
|
||||
$numq = $questiongenerator->create_question('numerical', null, ['category' => $cat->id]);
|
||||
quiz_add_quiz_question($numq->id, $quiz);
|
||||
|
||||
return $quiz;
|
||||
|
||||
@@ -27,7 +27,7 @@ use mod_quiz\quiz_settings;
|
||||
*/
|
||||
class quizaccess_securewindow extends access_rule_base {
|
||||
/** @var array options that should be used for opening the secure popup. */
|
||||
protected static $popupoptions = array(
|
||||
protected static $popupoptions = [
|
||||
'left' => 0,
|
||||
'top' => 0,
|
||||
'fullscreen' => true,
|
||||
@@ -39,7 +39,7 @@ class quizaccess_securewindow extends access_rule_base {
|
||||
'location' => false,
|
||||
'status' => false,
|
||||
'menubar' => false,
|
||||
);
|
||||
];
|
||||
|
||||
public static function make(quiz_settings $quizobj, $timenow, $canignoretimelimits) {
|
||||
|
||||
@@ -77,7 +77,7 @@ class quizaccess_securewindow extends access_rule_base {
|
||||
* security settings menu.
|
||||
*/
|
||||
public static function get_browser_security_choices() {
|
||||
return array('securewindow' =>
|
||||
get_string('popupwithjavascriptsupport', 'quizaccess_securewindow'));
|
||||
return ['securewindow' =>
|
||||
get_string('popupwithjavascriptsupport', 'quizaccess_securewindow')];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ $category = optional_param('category', 0, PARAM_INT);
|
||||
$scrollpos = optional_param('scrollpos', 0, PARAM_INT);
|
||||
|
||||
// Get the course object and related bits.
|
||||
if (!$course = $DB->get_record('course', array('id' => $quiz->course))) {
|
||||
if (!$course = $DB->get_record('course', ['id' => $quiz->course])) {
|
||||
throw new \moodle_exception('invalidcourseid');
|
||||
}
|
||||
// You need mod/quiz:manage in addition to question capabilities to access this page.
|
||||
@@ -57,7 +57,7 @@ $PAGE->set_url($thispageurl);
|
||||
if ($returnurl) {
|
||||
$returnurl = new moodle_url($returnurl);
|
||||
} else {
|
||||
$returnurl = new moodle_url('/mod/quiz/edit.php', array('cmid' => $cmid));
|
||||
$returnurl = new moodle_url('/mod/quiz/edit.php', ['cmid' => $cmid]);
|
||||
}
|
||||
if ($scrollpos) {
|
||||
$returnurl->param('scrollpos', $scrollpos);
|
||||
@@ -76,7 +76,7 @@ $qcobject = new question_category_object(
|
||||
$contexts->having_cap('moodle/question:add'));
|
||||
|
||||
$mform = new add_random_form(new moodle_url('/mod/quiz/addrandom.php'),
|
||||
array('contexts' => $contexts, 'cat' => $pagevars['cat']));
|
||||
['contexts' => $contexts, 'cat' => $pagevars['cat']]);
|
||||
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($returnurl);
|
||||
@@ -117,12 +117,12 @@ if ($data = $mform->get_data()) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
$mform->set_data(array(
|
||||
$mform->set_data([
|
||||
'addonpage' => $addonpage,
|
||||
'returnurl' => $returnurl,
|
||||
'cmid' => $cm->id,
|
||||
'category' => $category,
|
||||
));
|
||||
]);
|
||||
|
||||
// Setup $PAGE.
|
||||
$streditingquiz = get_string('editinga', 'moodle', get_string('modulename', 'quiz'));
|
||||
@@ -131,7 +131,7 @@ $PAGE->set_title($streditingquiz);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if (!$quizname = $DB->get_field($cm->modname, 'name', array('id' => $cm->instance))) {
|
||||
if (!$quizname = $DB->get_field($cm->modname, 'name', ['id' => $cm->instance])) {
|
||||
throw new \moodle_exception('invalidcoursemodule');
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ if ($id = optional_param('id', 0, PARAM_INT)) {
|
||||
throw new \moodle_exception('invalidquizid', 'quiz');
|
||||
}
|
||||
redirect(new moodle_url('/mod/quiz/startattempt.php',
|
||||
array('cmid' => $cm->id, 'sesskey' => sesskey())));
|
||||
['cmid' => $cm->id, 'sesskey' => sesskey()]));
|
||||
}
|
||||
|
||||
// Get submitted parameters.
|
||||
@@ -101,7 +101,7 @@ if ($accessmanager->is_preflight_check_required($attemptobj->get_attemptid())) {
|
||||
$autosaveperiod = get_config('quiz', 'autosaveperiod');
|
||||
if ($autosaveperiod) {
|
||||
$PAGE->requires->yui_module('moodle-mod_quiz-autosave',
|
||||
'M.mod_quiz.autosave.init', array($autosaveperiod));
|
||||
'M.mod_quiz.autosave.init', [$autosaveperiod]);
|
||||
}
|
||||
|
||||
// Log this page view.
|
||||
|
||||
@@ -50,40 +50,40 @@ class moodle1_mod_quiz_handler extends moodle1_mod_handler {
|
||||
* @return array of {@link convert_path} instances
|
||||
*/
|
||||
public function get_paths() {
|
||||
return array(
|
||||
return [
|
||||
new convert_path(
|
||||
'quiz', '/MOODLE_BACKUP/COURSE/MODULES/MOD/QUIZ',
|
||||
array(
|
||||
'newfields' => array(
|
||||
[
|
||||
'newfields' => [
|
||||
'showuserpicture' => 0,
|
||||
'questiondecimalpoints' => -1,
|
||||
'introformat' => 0,
|
||||
'showblocks' => 0,
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
),
|
||||
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',
|
||||
array(
|
||||
'renamefields' => array(
|
||||
[
|
||||
'renamefields' => [
|
||||
'question' => 'questionid',
|
||||
'grade' => 'maxmark',
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
),
|
||||
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(
|
||||
[
|
||||
'newfields' => [
|
||||
'feedbacktextformat' => FORMAT_HTML,
|
||||
)
|
||||
)
|
||||
]
|
||||
]
|
||||
)
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,10 +126,10 @@ class moodle1_mod_quiz_handler extends moodle1_mod_handler {
|
||||
|
||||
// Start writing quiz.xml.
|
||||
$this->open_xml_writer("activities/quiz_{$this->moduleid}/quiz.xml");
|
||||
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid,
|
||||
$this->xmlwriter->begin_tag('activity', ['id' => $instanceid,
|
||||
'moduleid' => $this->moduleid, 'modulename' => 'quiz',
|
||||
'contextid' => $contextid));
|
||||
$this->xmlwriter->begin_tag('quiz', array('id' => $instanceid));
|
||||
'contextid' => $contextid]);
|
||||
$this->xmlwriter->begin_tag('quiz', ['id' => $instanceid]);
|
||||
|
||||
foreach ($data as $field => $value) {
|
||||
if ($field <> 'id') {
|
||||
@@ -149,7 +149,7 @@ class moodle1_mod_quiz_handler extends moodle1_mod_handler {
|
||||
}
|
||||
|
||||
public function process_quiz_question_instance($data) {
|
||||
$this->write_xml('question_instance', $data, array('/question_instance/id'));
|
||||
$this->write_xml('question_instance', $data, ['/question_instance/id']);
|
||||
}
|
||||
|
||||
public function on_quiz_feedbacks_start() {
|
||||
@@ -169,7 +169,7 @@ class moodle1_mod_quiz_handler extends moodle1_mod_handler {
|
||||
$data['maxgrade'] = 0;
|
||||
}
|
||||
|
||||
$this->write_xml('feedback', $data, array('/feedback/id'));
|
||||
$this->write_xml('feedback', $data, ['/feedback/id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +178,7 @@ class moodle1_mod_quiz_handler extends moodle1_mod_handler {
|
||||
public function on_quiz_end() {
|
||||
|
||||
// Append empty <overrides> subpath element.
|
||||
$this->write_xml('overrides', array());
|
||||
$this->write_xml('overrides', []);
|
||||
|
||||
// Finish writing quiz.xml.
|
||||
$this->xmlwriter->end_tag('quiz');
|
||||
@@ -190,7 +190,7 @@ class moodle1_mod_quiz_handler extends moodle1_mod_handler {
|
||||
$this->xmlwriter->begin_tag('inforef');
|
||||
$this->xmlwriter->begin_tag('fileref');
|
||||
foreach ($this->fileman->get_fileids() as $fileid) {
|
||||
$this->write_xml('file', array('id' => $fileid));
|
||||
$this->write_xml('file', ['id' => $fileid]);
|
||||
}
|
||||
$this->xmlwriter->end_tag('fileref');
|
||||
$this->xmlwriter->end_tag('inforef');
|
||||
|
||||
@@ -56,11 +56,11 @@ class restore_quiz_activity_task extends restore_activity_task {
|
||||
* processed by the link decoder
|
||||
*/
|
||||
public static function define_decode_contents() {
|
||||
$contents = array();
|
||||
$contents = [];
|
||||
|
||||
$contents[] = new restore_decode_content('quiz', array('intro'), 'quiz');
|
||||
$contents[] = new restore_decode_content('quiz', ['intro'], 'quiz');
|
||||
$contents[] = new restore_decode_content('quiz_feedback',
|
||||
array('feedbacktext'), 'quiz_feedback');
|
||||
['feedbacktext'], 'quiz_feedback');
|
||||
|
||||
return $contents;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class restore_quiz_activity_task extends restore_activity_task {
|
||||
* to the activity to be executed by the link decoder
|
||||
*/
|
||||
public static function define_decode_rules() {
|
||||
$rules = array();
|
||||
$rules = [];
|
||||
|
||||
$rules[] = new restore_decode_rule('QUIZVIEWBYID',
|
||||
'/mod/quiz/view.php?id=$1', 'course_module');
|
||||
@@ -90,7 +90,7 @@ class restore_quiz_activity_task extends restore_activity_task {
|
||||
* of {@link restore_log_rule} objects
|
||||
*/
|
||||
public static function define_restore_log_rules() {
|
||||
$rules = array();
|
||||
$rules = [];
|
||||
|
||||
$rules[] = new restore_log_rule('quiz', 'add',
|
||||
'view.php?id={course_module}', '{quiz}');
|
||||
@@ -181,7 +181,7 @@ class restore_quiz_activity_task extends restore_activity_task {
|
||||
* activity level. All them are rules not linked to any module instance (cmid = 0)
|
||||
*/
|
||||
public static function define_restore_log_rules_for_course() {
|
||||
$rules = array();
|
||||
$rules = [];
|
||||
|
||||
$rules[] = new restore_log_rule('quiz', 'view all', 'index.php?id={course}', null);
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class restore_quiz_activity_structure_step extends restore_questions_activity_st
|
||||
|
||||
protected function define_structure() {
|
||||
|
||||
$paths = array();
|
||||
$paths = [];
|
||||
$userinfo = $this->get_setting_value('userinfo');
|
||||
|
||||
$quiz = new restore_path_element('quiz', '/activity/quiz');
|
||||
@@ -568,7 +568,7 @@ class restore_quiz_activity_structure_step extends restore_questions_activity_st
|
||||
|
||||
$this->process_quiz_attempt($data);
|
||||
|
||||
$quiz = $DB->get_record('quiz', array('id' => $this->get_new_parentid('quiz')));
|
||||
$quiz = $DB->get_record('quiz', ['id' => $this->get_new_parentid('quiz')]);
|
||||
$quiz->oldquestions = $this->oldquizlayout;
|
||||
$this->process_legacy_quiz_attempt_data($data, $quiz);
|
||||
}
|
||||
@@ -600,10 +600,10 @@ class restore_quiz_activity_structure_step extends restore_questions_activity_st
|
||||
$this->add_related_files('mod_quiz', 'feedback', 'quiz_feedback');
|
||||
|
||||
if (!$this->sectioncreated) {
|
||||
$DB->insert_record('quiz_sections', array(
|
||||
$DB->insert_record('quiz_sections', [
|
||||
'quizid' => $this->get_new_parentid('quiz'),
|
||||
'firstslot' => 1, 'heading' => '',
|
||||
'shufflequestions' => $this->legacyshufflequestionsoption));
|
||||
'shufflequestions' => $this->legacyshufflequestionsoption]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class review_setting extends \admin_setting {
|
||||
* @return array
|
||||
*/
|
||||
public static function fields() {
|
||||
return array(
|
||||
return [
|
||||
'attempt' => get_string('theattempt', 'quiz'),
|
||||
'correctness' => get_string('whethercorrect', 'question'),
|
||||
'marks' => get_string('marks', 'question'),
|
||||
@@ -68,7 +68,7 @@ class review_setting extends \admin_setting {
|
||||
'generalfeedback' => get_string('generalfeedback', 'question'),
|
||||
'rightanswer' => get_string('rightanswer', 'question'),
|
||||
'overallfeedback' => get_string('overallfeedback', 'quiz'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,12 +101,12 @@ class review_setting extends \admin_setting {
|
||||
* @return array an array of time constant => lang string.
|
||||
*/
|
||||
protected static function times() {
|
||||
return array(
|
||||
return [
|
||||
self::DURING => get_string('reviewduring', 'quiz'),
|
||||
self::IMMEDIATELY_AFTER => get_string('reviewimmediately', 'quiz'),
|
||||
self::LATER_WHILE_OPEN => get_string('reviewopen', 'quiz'),
|
||||
self::AFTER_CLOSE => get_string('reviewclosed', 'quiz'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
protected function normalise_data($data) {
|
||||
|
||||
@@ -51,7 +51,7 @@ abstract class activity_base extends \core_analytics\local\indicator\community_o
|
||||
* @return string[]
|
||||
*/
|
||||
protected function feedback_viewed_events() {
|
||||
return array('\mod_quiz\event\course_module_viewed');
|
||||
return ['\mod_quiz\event\course_module_viewed'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,7 +60,7 @@ class cognitive_depth extends activity_base {
|
||||
* @return string[]
|
||||
*/
|
||||
protected function feedback_submitted_events() {
|
||||
return array('\mod_quiz\event\attempt_submitted');
|
||||
return ['\mod_quiz\event\attempt_submitted'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -84,7 +84,7 @@ class attempt_abandoned extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/review.php', array('attempt' => $this->objectid));
|
||||
return new \moodle_url('/mod/quiz/review.php', ['attempt' => $this->objectid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,13 +128,13 @@ class attempt_abandoned extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'quiz_attempts', 'restore' => 'quiz_attempt');
|
||||
return ['db' => 'quiz_attempts', 'restore' => 'quiz_attempt'];
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['submitterid'] = array('db' => 'user', 'restore' => 'user');
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped = [];
|
||||
$othermapped['submitterid'] = ['db' => 'user', 'restore' => 'user'];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class attempt_becameoverdue extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/review.php', array('attempt' => $this->objectid));
|
||||
return new \moodle_url('/mod/quiz/review.php', ['attempt' => $this->objectid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,13 +130,13 @@ class attempt_becameoverdue extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'quiz_attempts', 'restore' => 'quiz_attempt');
|
||||
return ['db' => 'quiz_attempts', 'restore' => 'quiz_attempt'];
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['submitterid'] = array('db' => 'user', 'restore' => 'user');
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped = [];
|
||||
$othermapped['submitterid'] = ['db' => 'user', 'restore' => 'user'];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class attempt_deleted extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/report.php', array('id' => $this->contextinstanceid));
|
||||
return new \moodle_url('/mod/quiz/report.php', ['id' => $this->contextinstanceid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,8 +84,8 @@ class attempt_deleted extends \core\event\base {
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'quiz', 'delete attempt', 'report.php?id=' . $this->contextinstanceid,
|
||||
$this->objectid, $this->contextinstanceid);
|
||||
return [$this->courseid, 'quiz', 'delete attempt', 'report.php?id=' . $this->contextinstanceid,
|
||||
$this->objectid, $this->contextinstanceid];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,12 +107,12 @@ class attempt_deleted extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'quiz_attempts', 'restore' => 'quiz_attempt');
|
||||
return ['db' => 'quiz_attempts', 'restore' => 'quiz_attempt'];
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped = [];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class attempt_preview_started extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/view.php', array('id' => $this->contextinstanceid));
|
||||
return new \moodle_url('/mod/quiz/view.php', ['id' => $this->contextinstanceid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,8 +85,8 @@ class attempt_preview_started extends \core\event\base {
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'quiz', 'preview', 'view.php?id=' . $this->contextinstanceid,
|
||||
$this->other['quizid'], $this->contextinstanceid);
|
||||
return [$this->courseid, 'quiz', 'preview', 'view.php?id=' . $this->contextinstanceid,
|
||||
$this->other['quizid'], $this->contextinstanceid];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,12 +108,12 @@ class attempt_preview_started extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'quiz_attempts', 'restore' => 'quiz_attempt');
|
||||
return ['db' => 'quiz_attempts', 'restore' => 'quiz_attempt'];
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped = [];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class attempt_regraded extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/review.php', array('attempt' => $this->objectid));
|
||||
return new \moodle_url('/mod/quiz/review.php', ['attempt' => $this->objectid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,7 +105,7 @@ class attempt_regraded extends \core\event\base {
|
||||
* @return array Array of mappings
|
||||
*/
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'quiz_attempts', 'restore' => 'quiz_attempt');
|
||||
return ['db' => 'quiz_attempts', 'restore' => 'quiz_attempt'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,8 +114,8 @@ class attempt_regraded extends \core\event\base {
|
||||
* @return array Array of array mappings
|
||||
*/
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped = [];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class attempt_reviewed extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/review.php', array('attempt' => $this->objectid));
|
||||
return new \moodle_url('/mod/quiz/review.php', ['attempt' => $this->objectid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,8 +84,8 @@ class attempt_reviewed extends \core\event\base {
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'quiz', 'review', 'review.php?attempt=' . $this->objectid,
|
||||
$this->other['quizid'], $this->contextinstanceid);
|
||||
return [$this->courseid, 'quiz', 'review', 'review.php?attempt=' . $this->objectid,
|
||||
$this->other['quizid'], $this->contextinstanceid];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,12 +107,12 @@ class attempt_reviewed extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'quiz_attempts', 'restore' => 'quiz_attempt');
|
||||
return ['db' => 'quiz_attempts', 'restore' => 'quiz_attempt'];
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped = [];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ class attempt_started extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/review.php', array('attempt' => $this->objectid));
|
||||
return new \moodle_url('/mod/quiz/review.php', ['attempt' => $this->objectid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,8 +115,8 @@ class attempt_started extends \core\event\base {
|
||||
protected function get_legacy_logdata() {
|
||||
$attempt = $this->get_record_snapshot('quiz_attempts', $this->objectid);
|
||||
|
||||
return array($this->courseid, 'quiz', 'attempt', 'review.php?attempt=' . $this->objectid,
|
||||
$attempt->quiz, $this->contextinstanceid);
|
||||
return [$this->courseid, 'quiz', 'attempt', 'review.php?attempt=' . $this->objectid,
|
||||
$attempt->quiz, $this->contextinstanceid];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,12 +133,12 @@ class attempt_started extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'quiz_attempts', 'restore' => 'quiz_attempt');
|
||||
return ['db' => 'quiz_attempts', 'restore' => 'quiz_attempt'];
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped = [];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class attempt_submitted extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/review.php', array('attempt' => $this->objectid));
|
||||
return new \moodle_url('/mod/quiz/review.php', ['attempt' => $this->objectid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,13 +129,13 @@ class attempt_submitted extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'quiz_attempts', 'restore' => 'quiz_attempt');
|
||||
return ['db' => 'quiz_attempts', 'restore' => 'quiz_attempt'];
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['submitterid'] = array('db' => 'user', 'restore' => 'user');
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped = [];
|
||||
$othermapped['submitterid'] = ['db' => 'user', 'restore' => 'user'];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class attempt_summary_viewed extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/summary.php', array('attempt' => $this->objectid));
|
||||
return new \moodle_url('/mod/quiz/summary.php', ['attempt' => $this->objectid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,8 +87,8 @@ class attempt_summary_viewed extends \core\event\base {
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'quiz', 'view summary', 'summary.php?attempt=' . $this->objectid,
|
||||
$this->other['quizid'], $this->contextinstanceid);
|
||||
return [$this->courseid, 'quiz', 'view summary', 'summary.php?attempt=' . $this->objectid,
|
||||
$this->other['quizid'], $this->contextinstanceid];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,12 +110,12 @@ class attempt_summary_viewed extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'quiz_attempts', 'restore' => 'quiz_attempt');
|
||||
return ['db' => 'quiz_attempts', 'restore' => 'quiz_attempt'];
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped = [];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -91,8 +91,8 @@ class attempt_viewed extends \core\event\base {
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'quiz', 'continue attempt', 'review.php?attempt=' . $this->objectid,
|
||||
$this->other['quizid'], $this->contextinstanceid);
|
||||
return [$this->courseid, 'quiz', 'continue attempt', 'review.php?attempt=' . $this->objectid,
|
||||
$this->other['quizid'], $this->contextinstanceid];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,12 +118,12 @@ class attempt_viewed extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'quiz_attempts', 'restore' => 'quiz_attempt');
|
||||
return ['db' => 'quiz_attempts', 'restore' => 'quiz_attempt'];
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped = [];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,6 @@ class course_module_viewed extends \core\event\course_module_viewed {
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'quiz', 'restore' => 'quiz');
|
||||
return ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class edit_page_viewed extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/edit.php', array('cmid' => $this->contextinstanceid));
|
||||
return new \moodle_url('/mod/quiz/edit.php', ['cmid' => $this->contextinstanceid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,8 +84,8 @@ class edit_page_viewed extends \core\event\base {
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'quiz', 'editquestions', 'view.php?id=' . $this->contextinstanceid,
|
||||
$this->other['quizid'], $this->contextinstanceid);
|
||||
return [$this->courseid, 'quiz', 'editquestions', 'view.php?id=' . $this->contextinstanceid,
|
||||
$this->other['quizid'], $this->contextinstanceid];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,8 +103,8 @@ class edit_page_viewed extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped = [];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class group_override_created extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/overrideedit.php', array('id' => $this->objectid));
|
||||
return new \moodle_url('/mod/quiz/overrideedit.php', ['id' => $this->objectid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,13 +99,13 @@ class group_override_created extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'quiz_overrides', 'restore' => 'quiz_override');
|
||||
return ['db' => 'quiz_overrides', 'restore' => 'quiz_override'];
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped['groupid'] = array('db' => 'groups', 'restore' => 'group');
|
||||
$othermapped = [];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
$othermapped['groupid'] = ['db' => 'groups', 'restore' => 'group'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class group_override_deleted extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/overrides.php', array('cmid' => $this->contextinstanceid));
|
||||
return new \moodle_url('/mod/quiz/overrides.php', ['cmid' => $this->contextinstanceid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,8 +85,8 @@ class group_override_deleted extends \core\event\base {
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'quiz', 'delete override', 'overrides.php?cmid=' . $this->contextinstanceid,
|
||||
$this->other['quizid'], $this->contextinstanceid);
|
||||
return [$this->courseid, 'quiz', 'delete override', 'overrides.php?cmid=' . $this->contextinstanceid,
|
||||
$this->other['quizid'], $this->contextinstanceid];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,13 +108,13 @@ class group_override_deleted extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'quiz_overrides', 'restore' => 'quiz_override');
|
||||
return ['db' => 'quiz_overrides', 'restore' => 'quiz_override'];
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped['groupid'] = array('db' => 'groups', 'restore' => 'group');
|
||||
$othermapped = [];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
$othermapped['groupid'] = ['db' => 'groups', 'restore' => 'group'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class group_override_updated extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/overrideedit.php', array('id' => $this->objectid));
|
||||
return new \moodle_url('/mod/quiz/overrideedit.php', ['id' => $this->objectid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,8 +85,8 @@ class group_override_updated extends \core\event\base {
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'quiz', 'edit override', 'overrideedit.php?id=' . $this->objectid, $this->other['quizid'],
|
||||
$this->contextinstanceid);
|
||||
return [$this->courseid, 'quiz', 'edit override', 'overrideedit.php?id=' . $this->objectid, $this->other['quizid'],
|
||||
$this->contextinstanceid];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,13 +108,13 @@ class group_override_updated extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'quiz_overrides', 'restore' => 'quiz_override');
|
||||
return ['db' => 'quiz_overrides', 'restore' => 'quiz_override'];
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped['groupid'] = array('db' => 'groups', 'restore' => 'group');
|
||||
$othermapped = [];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
$othermapped['groupid'] = ['db' => 'groups', 'restore' => 'group'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -77,8 +77,8 @@ class question_manually_graded extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/comment.php', array('attempt' => $this->other['attemptid'],
|
||||
'slot' => $this->other['slot']));
|
||||
return new \moodle_url('/mod/quiz/comment.php', ['attempt' => $this->other['attemptid'],
|
||||
'slot' => $this->other['slot']]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,8 +87,8 @@ class question_manually_graded extends \core\event\base {
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'quiz', 'manualgrade', 'comment.php?attempt=' . $this->other['attemptid'] .
|
||||
'&slot=' . $this->other['slot'], $this->other['quizid'], $this->contextinstanceid);
|
||||
return [$this->courseid, 'quiz', 'manualgrade', 'comment.php?attempt=' . $this->other['attemptid'] .
|
||||
'&slot=' . $this->other['slot'], $this->other['quizid'], $this->contextinstanceid];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,13 +114,13 @@ class question_manually_graded extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'question', 'restore' => 'question');
|
||||
return ['db' => 'question', 'restore' => 'question'];
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped['attemptid'] = array('db' => 'quiz_attempts', 'restore' => 'quiz_attempt');
|
||||
$othermapped = [];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
$othermapped['attemptid'] = ['db' => 'quiz_attempts', 'restore' => 'quiz_attempt'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -78,8 +78,8 @@ class report_viewed extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/report.php', array('id' => $this->contextinstanceid,
|
||||
'mode' => $this->other['reportname']));
|
||||
return new \moodle_url('/mod/quiz/report.php', ['id' => $this->contextinstanceid,
|
||||
'mode' => $this->other['reportname']]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,8 +88,8 @@ class report_viewed extends \core\event\base {
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'quiz', 'report', 'report.php?id=' . $this->contextinstanceid . '&mode=' .
|
||||
$this->other['reportname'], $this->other['quizid'], $this->contextinstanceid);
|
||||
return [$this->courseid, 'quiz', 'report', 'report.php?id=' . $this->contextinstanceid . '&mode=' .
|
||||
$this->other['reportname'], $this->other['quizid'], $this->contextinstanceid];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,8 +111,8 @@ class report_viewed extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped = [];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class user_override_created extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/overrideedit.php', array('id' => $this->objectid));
|
||||
return new \moodle_url('/mod/quiz/overrideedit.php', ['id' => $this->objectid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,12 +97,12 @@ class user_override_created extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'quiz_overrides', 'restore' => 'quiz_override');
|
||||
return ['db' => 'quiz_overrides', 'restore' => 'quiz_override'];
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped = [];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class user_override_deleted extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/overrides.php', array('cmid' => $this->contextinstanceid));
|
||||
return new \moodle_url('/mod/quiz/overrides.php', ['cmid' => $this->contextinstanceid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,8 +84,8 @@ class user_override_deleted extends \core\event\base {
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'quiz', 'delete override', 'overrides.php?cmid=' . $this->contextinstanceid,
|
||||
$this->other['quizid'], $this->contextinstanceid);
|
||||
return [$this->courseid, 'quiz', 'delete override', 'overrides.php?cmid=' . $this->contextinstanceid,
|
||||
$this->other['quizid'], $this->contextinstanceid];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,12 +107,12 @@ class user_override_deleted extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'quiz_overrides', 'restore' => 'quiz_override');
|
||||
return ['db' => 'quiz_overrides', 'restore' => 'quiz_override'];
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped = [];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class user_override_updated extends \core\event\base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/mod/quiz/overrideedit.php', array('id' => $this->objectid));
|
||||
return new \moodle_url('/mod/quiz/overrideedit.php', ['id' => $this->objectid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,8 +85,8 @@ class user_override_updated extends \core\event\base {
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'quiz', 'edit override', 'overrideedit.php?id=' . $this->objectid, $this->other['quizid'],
|
||||
$this->contextinstanceid);
|
||||
return [$this->courseid, 'quiz', 'edit override', 'overrideedit.php?id=' . $this->objectid, $this->other['quizid'],
|
||||
$this->contextinstanceid];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,12 +108,12 @@ class user_override_updated extends \core\event\base {
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'quiz_overrides', 'restore' => 'quiz_override');
|
||||
return ['db' => 'quiz_overrides', 'restore' => 'quiz_override'];
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['quizid'] = array('db' => 'quiz', 'restore' => 'quiz');
|
||||
$othermapped = [];
|
||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
|
||||
+223
-223
File diff suppressed because it is too large
Load Diff
@@ -47,7 +47,7 @@ class add_random_form extends moodleform {
|
||||
get_string('randomfromexistingcategory', 'quiz'));
|
||||
|
||||
$mform->addElement('questioncategory', 'category', get_string('category'),
|
||||
array('contexts' => $usablecontexts, 'top' => true));
|
||||
['contexts' => $usablecontexts, 'top' => true]);
|
||||
$mform->setDefault('category', $this->_customdata['cat']);
|
||||
|
||||
$mform->addElement('checkbox', 'includesubcategories', '', get_string('recurse', 'quiz'));
|
||||
@@ -56,15 +56,15 @@ class add_random_form extends moodleform {
|
||||
$mform->hideIf('includesubcategories', 'category', 'in', $tops);
|
||||
|
||||
if ($CFG->usetags) {
|
||||
$tagstrings = array();
|
||||
$tagstrings = [];
|
||||
$tags = core_tag_tag::get_tags_by_area_in_contexts('core_question', 'question', $usablecontexts);
|
||||
foreach ($tags as $tag) {
|
||||
$tagstrings["{$tag->id},{$tag->name}"] = $tag->name;
|
||||
}
|
||||
$options = array(
|
||||
$options = [
|
||||
'multiple' => true,
|
||||
'noselectionstring' => get_string('anytags', 'quiz'),
|
||||
);
|
||||
];
|
||||
$mform->addElement('autocomplete', 'fromtags', get_string('randomquestiontags', 'mod_quiz'), $tagstrings, $options);
|
||||
$mform->addHelpButton('fromtags', 'randomquestiontags', 'mod_quiz');
|
||||
}
|
||||
@@ -92,7 +92,7 @@ class add_random_form extends moodleform {
|
||||
$mform->setType('name', PARAM_TEXT);
|
||||
|
||||
$mform->addElement('questioncategory', 'parent', get_string('parentcategory', 'question'),
|
||||
array('contexts' => $usablecontexts, 'top' => true));
|
||||
['contexts' => $usablecontexts, 'top' => true]);
|
||||
$mform->addHelpButton('parent', 'parentcategory', 'question');
|
||||
|
||||
$mform->addElement('submit', 'newcategory',
|
||||
@@ -136,7 +136,7 @@ class add_random_form extends moodleform {
|
||||
* @return array of integers [1, 2, ..., 100] (or to the smaller of $maxrand and 100.)
|
||||
*/
|
||||
private function get_number_of_questions_to_add_choices($maxrand = 100) {
|
||||
$randomcount = array();
|
||||
$randomcount = [];
|
||||
for ($i = 1; $i <= min(100, $maxrand); $i++) {
|
||||
$randomcount[$i] = $i;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class preflight_check_form extends moodleform {
|
||||
|
||||
protected function definition() {
|
||||
$mform = $this->_form;
|
||||
$this->_form->updateAttributes(array('id' => 'mod_quiz_preflight_form'));
|
||||
$this->_form->updateAttributes(['id' => 'mod_quiz_preflight_form']);
|
||||
|
||||
foreach ($this->_customdata['hidden'] as $name => $value) {
|
||||
if ($name === 'sesskey') {
|
||||
|
||||
@@ -50,22 +50,22 @@ class randomquestion_form extends \moodleform {
|
||||
$mform->addElement('header', 'generalheader', get_string("general", 'form'));
|
||||
|
||||
$mform->addElement('questioncategory', 'category', get_string('category', 'question'),
|
||||
array('contexts' => $usablecontexts, 'top' => true));
|
||||
['contexts' => $usablecontexts, 'top' => true]);
|
||||
|
||||
$mform->addElement('advcheckbox', 'includesubcategories', get_string('recurse', 'quiz'), null, null, array(0, 1));
|
||||
$mform->addElement('advcheckbox', 'includesubcategories', get_string('recurse', 'quiz'), null, null, [0, 1]);
|
||||
|
||||
$tops = question_get_top_categories_for_contexts(array_column($contexts->all(), 'id'));
|
||||
$mform->hideIf('includesubcategories', 'category', 'in', $tops);
|
||||
|
||||
$tags = \core_tag_tag::get_tags_by_area_in_contexts('core_question', 'question', $usablecontexts);
|
||||
$tagstrings = array();
|
||||
$tagstrings = [];
|
||||
foreach ($tags as $tag) {
|
||||
$tagstrings["{$tag->id},{$tag->name}"] = $tag->name;
|
||||
}
|
||||
$options = array(
|
||||
$options = [
|
||||
'multiple' => true,
|
||||
'noselectionstring' => get_string('anytags', 'quiz'),
|
||||
);
|
||||
];
|
||||
$mform->addElement('autocomplete', 'fromtags', get_string('randomquestiontags', 'mod_quiz'), $tagstrings, $options);
|
||||
$mform->addHelpButton('fromtags', 'randomquestiontags', 'mod_quiz');
|
||||
|
||||
@@ -75,10 +75,10 @@ class randomquestion_form extends \moodleform {
|
||||
$mform->addElement('hidden', 'returnurl');
|
||||
$mform->setType('returnurl', PARAM_LOCALURL);
|
||||
|
||||
$buttonarray = array();
|
||||
$buttonarray = [];
|
||||
$buttonarray[] = $mform->createElement('submit', 'submitbutton', get_string('savechanges'));
|
||||
$buttonarray[] = $mform->createElement('cancel');
|
||||
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
|
||||
$mform->addGroup($buttonarray, 'buttonar', '', [' '], false);
|
||||
$mform->closeHeaderBefore('buttonar');
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ class group_observers {
|
||||
quiz_process_group_deleted_in_course($event->courseid);
|
||||
}
|
||||
if (!empty($event->other['reset_options']['reset_groups_members'])) {
|
||||
quiz_update_open_attempts(array('courseid' => $event->courseid));
|
||||
quiz_update_open_attempts(['courseid' => $event->courseid]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class group_observers {
|
||||
* @return void
|
||||
*/
|
||||
public static function group_member_added($event) {
|
||||
quiz_update_open_attempts(array('userid' => $event->relateduserid, 'groupid' => $event->objectid));
|
||||
quiz_update_open_attempts(['userid' => $event->relateduserid, 'groupid' => $event->objectid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,7 +107,7 @@ class group_observers {
|
||||
// We will take care of that once the course reset ends.
|
||||
return;
|
||||
}
|
||||
quiz_update_open_attempts(array('userid' => $event->relateduserid, 'groupid' => $event->objectid));
|
||||
quiz_update_open_attempts(['userid' => $event->relateduserid, 'groupid' => $event->objectid]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class slot_random {
|
||||
if (empty($this->record->quizid)) {
|
||||
throw new \coding_exception('quizid is not set.');
|
||||
}
|
||||
$this->quiz = $DB->get_record('quiz', array('id' => $this->record->quizid));
|
||||
$this->quiz = $DB->get_record('quiz', ['id' => $this->record->quizid]);
|
||||
}
|
||||
|
||||
return $this->quiz;
|
||||
@@ -151,7 +151,7 @@ class slot_random {
|
||||
public function insert($page) {
|
||||
global $DB;
|
||||
|
||||
$slots = $DB->get_records('quiz_slots', array('quizid' => $this->record->quizid),
|
||||
$slots = $DB->get_records('quiz_slots', ['quizid' => $this->record->quizid],
|
||||
'slot', 'id, slot, page');
|
||||
$quiz = $this->get_quiz();
|
||||
|
||||
@@ -173,7 +173,7 @@ class slot_random {
|
||||
$lastslotbefore = 0;
|
||||
foreach (array_reverse($slots) as $otherslot) {
|
||||
if ($otherslot->page > $page) {
|
||||
$DB->set_field('quiz_slots', 'slot', $otherslot->slot + 1, array('id' => $otherslot->id));
|
||||
$DB->set_field('quiz_slots', 'slot', $otherslot->slot + 1, ['id' => $otherslot->id]);
|
||||
} else {
|
||||
$lastslotbefore = $otherslot->slot;
|
||||
break;
|
||||
|
||||
@@ -94,7 +94,7 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
if ($structure->is_last_section($section)) {
|
||||
$output .= \html_writer::start_div('last-add-menu');
|
||||
$output .= html_writer::tag('span', $this->add_menu_actions($structure, 0,
|
||||
$pageurl, $contexts, $pagevars), array('class' => 'add-menu-outer'));
|
||||
$pageurl, $contexts, $pagevars), ['class' => 'add-menu-outer']);
|
||||
$output .= \html_writer::end_div();
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
return '';
|
||||
}
|
||||
|
||||
$output = array();
|
||||
$output = [];
|
||||
foreach ($warnings as $warning) {
|
||||
$output[] = \html_writer::tag('p', $warning);
|
||||
}
|
||||
@@ -163,7 +163,7 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
get_string('numquestionsx', 'quiz', $structure->get_question_count()),
|
||||
'numberofquestions') . ' | ' .
|
||||
html_writer::span($currentstatus, 'quizopeningstatus',
|
||||
array('title' => $explanation));
|
||||
['title' => $explanation]);
|
||||
|
||||
return html_writer::div($output, 'statusbar');
|
||||
}
|
||||
@@ -178,19 +178,19 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
public function maximum_grade_input($structure, \moodle_url $pageurl) {
|
||||
$output = '';
|
||||
$output .= html_writer::start_div('maxgrade');
|
||||
$output .= html_writer::start_tag('form', array('method' => 'post', 'action' => 'edit.php',
|
||||
'class' => 'quizsavegradesform form-inline'));
|
||||
$output .= html_writer::start_tag('fieldset', array('class' => 'invisiblefieldset'));
|
||||
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
|
||||
$output .= html_writer::start_tag('form', ['method' => 'post', 'action' => 'edit.php',
|
||||
'class' => 'quizsavegradesform form-inline']);
|
||||
$output .= html_writer::start_tag('fieldset', ['class' => 'invisiblefieldset']);
|
||||
$output .= html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()]);
|
||||
$output .= html_writer::input_hidden_params($pageurl);
|
||||
$output .= html_writer::tag('label', get_string('maximumgrade') . ' ',
|
||||
array('for' => 'inputmaxgrade'));
|
||||
$output .= html_writer::empty_tag('input', array('type' => 'text', 'id' => 'inputmaxgrade',
|
||||
['for' => 'inputmaxgrade']);
|
||||
$output .= html_writer::empty_tag('input', ['type' => 'text', 'id' => 'inputmaxgrade',
|
||||
'name' => 'maxgrade', 'size' => ($structure->get_decimal_places_for_grades() + 2),
|
||||
'value' => $structure->formatted_quiz_grade(),
|
||||
'class' => 'form-control'));
|
||||
$output .= html_writer::empty_tag('input', array('type' => 'submit', 'class' => 'btn btn-secondary ml-1',
|
||||
'name' => 'savechanges', 'value' => get_string('save', 'quiz')));
|
||||
'class' => 'form-control']);
|
||||
$output .= html_writer::empty_tag('input', ['type' => 'submit', 'class' => 'btn btn-secondary ml-1',
|
||||
'name' => 'savechanges', 'value' => get_string('save', 'quiz')]);
|
||||
$output .= html_writer::end_tag('fieldset');
|
||||
$output .= html_writer::end_tag('form');
|
||||
$output .= html_writer::end_tag('div');
|
||||
@@ -204,10 +204,10 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
protected function repaginate_button(structure $structure, \moodle_url $pageurl) {
|
||||
$header = html_writer::tag('span', get_string('repaginatecommand', 'quiz'), array('class' => 'repaginatecommand'));
|
||||
$header = html_writer::tag('span', get_string('repaginatecommand', 'quiz'), ['class' => 'repaginatecommand']);
|
||||
$form = $this->repaginate_form($structure, $pageurl);
|
||||
|
||||
$buttonoptions = array(
|
||||
$buttonoptions = [
|
||||
'type' => 'submit',
|
||||
'name' => 'repaginate',
|
||||
'id' => 'repaginatecommand',
|
||||
@@ -215,7 +215,7 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
'class' => 'btn btn-secondary mr-1',
|
||||
'data-header' => $header,
|
||||
'data-form' => $form,
|
||||
);
|
||||
];
|
||||
if (!$structure->can_be_repaginated()) {
|
||||
$buttonoptions['disabled'] = 'disabled';
|
||||
} else {
|
||||
@@ -232,13 +232,13 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
protected function selectmultiple_button(structure $structure) {
|
||||
$buttonoptions = array(
|
||||
$buttonoptions = [
|
||||
'type' => 'button',
|
||||
'name' => 'selectmultiple',
|
||||
'id' => 'selectmultiplecommand',
|
||||
'value' => get_string('selectmultipleitems', 'quiz'),
|
||||
'class' => 'btn btn-secondary'
|
||||
);
|
||||
];
|
||||
if (!$structure->can_be_edited()) {
|
||||
$buttonoptions['disabled'] = 'disabled';
|
||||
}
|
||||
@@ -256,7 +256,7 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
$output = '';
|
||||
|
||||
// Bulk action button delete and bulk action button cancel.
|
||||
$buttondeleteoptions = array(
|
||||
$buttondeleteoptions = [
|
||||
'type' => 'button',
|
||||
'id' => 'selectmultipledeletecommand',
|
||||
'value' => get_string('deleteselected', 'mod_quiz'),
|
||||
@@ -265,18 +265,18 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
'data-togglegroup' => $this->togglegroup,
|
||||
'data-toggle' => 'action',
|
||||
'disabled' => true
|
||||
);
|
||||
$buttoncanceloptions = array(
|
||||
];
|
||||
$buttoncanceloptions = [
|
||||
'type' => 'button',
|
||||
'id' => 'selectmultiplecancelcommand',
|
||||
'value' => get_string('cancel', 'moodle'),
|
||||
'class' => 'btn btn-secondary'
|
||||
);
|
||||
];
|
||||
|
||||
$groupoptions = array(
|
||||
$groupoptions = [
|
||||
'class' => 'btn-group selectmultiplecommand actions m-1',
|
||||
'role' => 'group'
|
||||
);
|
||||
];
|
||||
|
||||
$output .= html_writer::tag('div',
|
||||
html_writer::tag('button', get_string('deleteselected', 'mod_quiz'), $buttondeleteoptions) .
|
||||
@@ -284,11 +284,11 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
html_writer::tag('button', get_string('cancel', 'moodle'),
|
||||
$buttoncanceloptions), $groupoptions);
|
||||
|
||||
$toolbaroptions = array(
|
||||
$toolbaroptions = [
|
||||
'class' => 'btn-toolbar m-1',
|
||||
'role' => 'toolbar',
|
||||
'aria-label' => get_string('selectmultipletoolbar', 'quiz'),
|
||||
);
|
||||
];
|
||||
|
||||
// Select all/deselect all questions.
|
||||
$selectallid = 'questionselectall';
|
||||
@@ -315,7 +315,7 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
protected function repaginate_form(structure $structure, \moodle_url $pageurl) {
|
||||
$perpage = array();
|
||||
$perpage = [];
|
||||
$perpage[0] = get_string('allinone', 'quiz');
|
||||
for ($i = 1; $i <= 50; ++$i) {
|
||||
$perpage[$i] = $i;
|
||||
@@ -325,22 +325,22 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
$hiddenurl->param('sesskey', sesskey());
|
||||
|
||||
$select = html_writer::select($perpage, 'questionsperpage',
|
||||
$structure->get_questions_per_page(), false, array('class' => 'custom-select'));
|
||||
$structure->get_questions_per_page(), false, ['class' => 'custom-select']);
|
||||
|
||||
$buttonattributes = array(
|
||||
$buttonattributes = [
|
||||
'type' => 'submit',
|
||||
'name' => 'repaginate',
|
||||
'value' => get_string('go'),
|
||||
'class' => 'btn btn-secondary ml-1'
|
||||
);
|
||||
];
|
||||
|
||||
$formcontent = html_writer::tag('form', html_writer::div(
|
||||
html_writer::input_hidden_params($hiddenurl) .
|
||||
get_string('repaginate', 'quiz', $select) .
|
||||
html_writer::empty_tag('input', $buttonattributes)
|
||||
), array('action' => 'edit.php', 'method' => 'post'));
|
||||
), ['action' => 'edit.php', 'method' => 'post']);
|
||||
|
||||
return html_writer::div($formcontent, '', array('id' => 'repaginatedialog'));
|
||||
return html_writer::div($formcontent, '', ['id' => 'repaginatedialog']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -353,7 +353,7 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
$totalmark = html_writer::span(quiz_format_grade($quiz, $quiz->sumgrades), 'mod_quiz_summarks');
|
||||
return html_writer::tag('span',
|
||||
get_string('totalmarksx', 'quiz', $totalmark),
|
||||
array('class' => 'totalpoints'));
|
||||
['class' => 'totalpoints']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -366,7 +366,7 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
if ($structure->get_section_count() == 1) {
|
||||
$class .= ' only-one-section';
|
||||
}
|
||||
return html_writer::start_tag('ul', array('class' => $class, 'role' => 'presentation'));
|
||||
return html_writer::start_tag('ul', ['class' => $class, 'role' => 'presentation']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -402,9 +402,9 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
$sectionheading = html_writer::span($sectionheadingtext, 'instancesection sr-only');
|
||||
}
|
||||
|
||||
$output .= html_writer::start_tag('li', array('id' => 'section-'.$section->id,
|
||||
$output .= html_writer::start_tag('li', ['id' => 'section-'.$section->id,
|
||||
'class' => 'section main clearfix'.$sectionstyle, 'role' => 'presentation',
|
||||
'data-sectionname' => $sectionheadingtext));
|
||||
'data-sectionname' => $sectionheadingtext]);
|
||||
|
||||
$output .= html_writer::start_div('content');
|
||||
|
||||
@@ -417,8 +417,8 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
} else {
|
||||
$editsectionheadingicon = html_writer::link(new \moodle_url('#'),
|
||||
$this->pix_icon('t/editstring', get_string('sectionheadingedit', 'quiz', $sectionheadingtext),
|
||||
'moodle', array('class' => 'editicon visibleifjs')),
|
||||
array('class' => 'editing_section', 'data-action' => 'edit_section_title', 'role' => 'button'));
|
||||
'moodle', ['class' => 'editicon visibleifjs']),
|
||||
['class' => 'editing_section', 'data-action' => 'edit_section_title', 'role' => 'button']);
|
||||
}
|
||||
$output .= html_writer::div($headingtext . $editsectionheadingicon, 'instancesectioncontainer');
|
||||
|
||||
@@ -440,13 +440,13 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function section_shuffle_questions(structure $structure, $section) {
|
||||
$checkboxattributes = array(
|
||||
$checkboxattributes = [
|
||||
'type' => 'checkbox',
|
||||
'id' => 'shuffle-' . $section->id,
|
||||
'value' => 1,
|
||||
'data-action' => 'shuffle_questions',
|
||||
'class' => 'cm-edit-action',
|
||||
);
|
||||
];
|
||||
|
||||
if (!$structure->can_be_edited()) {
|
||||
$checkboxattributes['disabled'] = 'disabled';
|
||||
@@ -467,7 +467,7 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
$label = html_writer::label(get_string('shufflequestions', 'quiz'),
|
||||
$checkboxattributes['id'], false);
|
||||
return html_writer::span($progressspan . $checkbox . $label. ' ' . $helpspan,
|
||||
'instanceshufflequestions', array('data-action' => 'shuffle_questions'));
|
||||
'instanceshufflequestions', ['data-action' => 'shuffle_questions']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -491,10 +491,10 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
public function section_remove_icon($section) {
|
||||
$title = get_string('sectionheadingremove', 'quiz', format_string($section->heading));
|
||||
$url = new \moodle_url('/mod/quiz/edit.php',
|
||||
array('sesskey' => sesskey(), 'removesection' => '1', 'sectionid' => $section->id));
|
||||
['sesskey' => sesskey(), 'removesection' => '1', 'sectionid' => $section->id]);
|
||||
$image = $this->pix_icon('t/delete', $title);
|
||||
return $this->action_link($url, $image, null, array(
|
||||
'class' => 'cm-edit-action editing_delete', 'data-action' => 'deletesection'));
|
||||
return $this->action_link($url, $image, null, [
|
||||
'class' => 'cm-edit-action editing_delete', 'data-action' => 'deletesection']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -516,7 +516,7 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
foreach ($structure->get_slots_in_section($section->id) as $slot) {
|
||||
$output .= $this->question_row($structure, $slot, $contexts, $pagevars, $pageurl);
|
||||
}
|
||||
return html_writer::tag('ul', $output, array('class' => 'section img-text'));
|
||||
return html_writer::tag('ul', $output, ['class' => 'section img-text']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -546,8 +546,8 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
$questionclasses = 'activity ' . $qtype . ' qtype_' . $qtype . ' slot';
|
||||
|
||||
$output .= html_writer::tag('li', $questionhtml . $joinhtml,
|
||||
array('class' => $questionclasses, 'id' => 'slot-' . $structure->get_slot_id_for_slot($slot),
|
||||
'data-canfinish' => $structure->can_finish_during_the_attempt($slot)));
|
||||
['class' => $questionclasses, 'id' => 'slot-' . $structure->get_slot_id_for_slot($slot),
|
||||
'data-canfinish' => $structure->can_finish_during_the_attempt($slot)]);
|
||||
|
||||
return $output;
|
||||
}
|
||||
@@ -574,13 +574,13 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
// Add the add-menu at the page level.
|
||||
$addmenu = html_writer::tag('span', $this->add_menu_actions($structure,
|
||||
$pagenumber, $pageurl, $contexts, $pagevars),
|
||||
array('class' => 'add-menu-outer'));
|
||||
['class' => 'add-menu-outer']);
|
||||
|
||||
$addquestionform = $this->add_question_form($structure,
|
||||
$pagenumber, $pageurl, $pagevars);
|
||||
|
||||
$output .= html_writer::tag('li', $page . $addmenu . $addquestionform,
|
||||
array('class' => 'pagenumber activity yui3-dd-drop page', 'id' => 'page-' . $pagenumber));
|
||||
['class' => 'pagenumber activity yui3-dd-drop page', 'id' => 'page-' . $pagenumber]);
|
||||
}
|
||||
|
||||
return $output;
|
||||
@@ -604,7 +604,7 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
}
|
||||
$menu = new \action_menu();
|
||||
$menu->set_constraint('.mod-quiz-edit-content');
|
||||
$trigger = html_writer::tag('span', get_string('add', 'quiz'), array('class' => 'add-menu'));
|
||||
$trigger = html_writer::tag('span', get_string('add', 'quiz'), ['class' => 'add-menu']);
|
||||
$menu->set_menu_trigger($trigger);
|
||||
// The menu appears within an absolutely positioned element causing width problems.
|
||||
// Make sure no-wrap is set so that we don't get a squashed menu.
|
||||
@@ -642,61 +642,61 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
$questioncategoryid = question_get_category_id_from_pagevars($pagevars);
|
||||
static $str;
|
||||
if (!isset($str)) {
|
||||
$str = get_strings(array('addasection', 'addaquestion', 'addarandomquestion',
|
||||
'addarandomselectedquestion', 'questionbank'), 'quiz');
|
||||
$str = get_strings(['addasection', 'addaquestion', 'addarandomquestion',
|
||||
'addarandomselectedquestion', 'questionbank'], 'quiz');
|
||||
}
|
||||
|
||||
// Get section, page, slotnumber and maxmark.
|
||||
$actions = array();
|
||||
$actions = [];
|
||||
|
||||
// Add a new question to the quiz.
|
||||
$returnurl = new \moodle_url($pageurl, array('addonpage' => $page));
|
||||
$params = array('returnurl' => $returnurl->out_as_local_url(false),
|
||||
$returnurl = new \moodle_url($pageurl, ['addonpage' => $page]);
|
||||
$params = ['returnurl' => $returnurl->out_as_local_url(false),
|
||||
'cmid' => $structure->get_cmid(), 'category' => $questioncategoryid,
|
||||
'addonpage' => $page, 'appendqnumstring' => 'addquestion');
|
||||
'addonpage' => $page, 'appendqnumstring' => 'addquestion'];
|
||||
|
||||
$actions['addaquestion'] = new \action_menu_link_secondary(
|
||||
new \moodle_url('/question/bank/editquestion/addquestion.php', $params),
|
||||
new \pix_icon('t/add', $str->addaquestion, 'moodle', array('class' => 'iconsmall', 'title' => '')),
|
||||
$str->addaquestion, array('class' => 'cm-edit-action addquestion', 'data-action' => 'addquestion')
|
||||
new \pix_icon('t/add', $str->addaquestion, 'moodle', ['class' => 'iconsmall', 'title' => '']),
|
||||
$str->addaquestion, ['class' => 'cm-edit-action addquestion', 'data-action' => 'addquestion']
|
||||
);
|
||||
|
||||
// Call question bank.
|
||||
$icon = new \pix_icon('t/add', $str->questionbank, 'moodle', array('class' => 'iconsmall', 'title' => ''));
|
||||
$icon = new \pix_icon('t/add', $str->questionbank, 'moodle', ['class' => 'iconsmall', 'title' => '']);
|
||||
if ($page) {
|
||||
$title = get_string('addquestionfrombanktopage', 'quiz', $page);
|
||||
} else {
|
||||
$title = get_string('addquestionfrombankatend', 'quiz');
|
||||
}
|
||||
$attributes = array('class' => 'cm-edit-action questionbank',
|
||||
'data-header' => $title, 'data-action' => 'questionbank', 'data-addonpage' => $page);
|
||||
$attributes = ['class' => 'cm-edit-action questionbank',
|
||||
'data-header' => $title, 'data-action' => 'questionbank', 'data-addonpage' => $page];
|
||||
$actions['questionbank'] = new \action_menu_link_secondary($pageurl, $icon, $str->questionbank, $attributes);
|
||||
|
||||
// Add a random question.
|
||||
if ($structure->can_add_random_questions()) {
|
||||
$returnurl = new \moodle_url('/mod/quiz/edit.php', array('cmid' => $structure->get_cmid(), 'data-addonpage' => $page));
|
||||
$returnurl = new \moodle_url('/mod/quiz/edit.php', ['cmid' => $structure->get_cmid(), 'data-addonpage' => $page]);
|
||||
$params = ['returnurl' => $returnurl, 'cmid' => $structure->get_cmid(), 'appendqnumstring' => 'addarandomquestion'];
|
||||
$url = new \moodle_url('/mod/quiz/addrandom.php', $params);
|
||||
$icon = new \pix_icon('t/add', $str->addarandomquestion, 'moodle', array('class' => 'iconsmall', 'title' => ''));
|
||||
$attributes = array('class' => 'cm-edit-action addarandomquestion', 'data-action' => 'addarandomquestion');
|
||||
$icon = new \pix_icon('t/add', $str->addarandomquestion, 'moodle', ['class' => 'iconsmall', 'title' => '']);
|
||||
$attributes = ['class' => 'cm-edit-action addarandomquestion', 'data-action' => 'addarandomquestion'];
|
||||
if ($page) {
|
||||
$title = get_string('addrandomquestiontopage', 'quiz', $page);
|
||||
} else {
|
||||
$title = get_string('addrandomquestionatend', 'quiz');
|
||||
}
|
||||
$attributes = array_merge(array('data-header' => $title, 'data-addonpage' => $page), $attributes);
|
||||
$attributes = array_merge(['data-header' => $title, 'data-addonpage' => $page], $attributes);
|
||||
$actions['addarandomquestion'] = new \action_menu_link_secondary($url, $icon, $str->addarandomquestion, $attributes);
|
||||
}
|
||||
|
||||
// Add a new section to the add_menu if possible. This is always added to the HTML
|
||||
// then hidden with CSS when no needed, so that as things are re-ordered, etc. with
|
||||
// Ajax it can be relevaled again when necessary.
|
||||
$params = array('cmid' => $structure->get_cmid(), 'addsectionatpage' => $page);
|
||||
$params = ['cmid' => $structure->get_cmid(), 'addsectionatpage' => $page];
|
||||
|
||||
$actions['addasection'] = new \action_menu_link_secondary(
|
||||
new \moodle_url($pageurl, $params),
|
||||
new \pix_icon('t/add', $str->addasection, 'moodle', array('class' => 'iconsmall', 'title' => '')),
|
||||
$str->addasection, array('class' => 'cm-edit-action addasection', 'data-action' => 'addasection')
|
||||
new \pix_icon('t/add', $str->addasection, 'moodle', ['class' => 'iconsmall', 'title' => '']),
|
||||
$str->addasection, ['class' => 'cm-edit-action addasection', 'data-action' => 'addasection']
|
||||
);
|
||||
|
||||
return $actions;
|
||||
@@ -716,18 +716,18 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
$questioncategoryid = question_get_category_id_from_pagevars($pagevars);
|
||||
|
||||
$output = html_writer::tag('input', null,
|
||||
array('type' => 'hidden', 'name' => 'returnurl',
|
||||
'value' => $pageurl->out_as_local_url(false, array('addonpage' => $page))));
|
||||
['type' => 'hidden', 'name' => 'returnurl',
|
||||
'value' => $pageurl->out_as_local_url(false, ['addonpage' => $page])]);
|
||||
$output .= html_writer::tag('input', null,
|
||||
array('type' => 'hidden', 'name' => 'cmid', 'value' => $structure->get_cmid()));
|
||||
['type' => 'hidden', 'name' => 'cmid', 'value' => $structure->get_cmid()]);
|
||||
$output .= html_writer::tag('input', null,
|
||||
array('type' => 'hidden', 'name' => 'appendqnumstring', 'value' => 'addquestion'));
|
||||
['type' => 'hidden', 'name' => 'appendqnumstring', 'value' => 'addquestion']);
|
||||
$output .= html_writer::tag('input', null,
|
||||
array('type' => 'hidden', 'name' => 'category', 'value' => $questioncategoryid));
|
||||
['type' => 'hidden', 'name' => 'category', 'value' => $questioncategoryid]);
|
||||
|
||||
return html_writer::tag('form', html_writer::div($output),
|
||||
array('class' => 'addnewquestion', 'method' => 'post',
|
||||
'action' => new \moodle_url('/question/bank/editquestion/addquestion.php')));
|
||||
['class' => 'addnewquestion', 'method' => 'post',
|
||||
'action' => new \moodle_url('/question/bank/editquestion/addquestion.php')]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -858,8 +858,8 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
*/
|
||||
public function question_move_icon(structure $structure, $slot) {
|
||||
return html_writer::link(new \moodle_url('#'),
|
||||
$this->pix_icon('i/dragdrop', get_string('move'), 'moodle', array('class' => 'iconsmall', 'title' => '')),
|
||||
array('class' => 'editing_move', 'data-action' => 'move')
|
||||
$this->pix_icon('i/dragdrop', get_string('move'), 'moodle', ['class' => 'iconsmall', 'title' => '']),
|
||||
['class' => 'editing_move', 'data-action' => 'move']
|
||||
);
|
||||
}
|
||||
|
||||
@@ -908,7 +908,7 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
\qbank_previewquestion\helper::question_preview_popup_params());
|
||||
|
||||
return $this->action_link($url, $image . $strpreviewlabel, $action,
|
||||
array('title' => $strpreviewquestion, 'class' => 'preview'));
|
||||
['title' => $strpreviewquestion, 'class' => 'preview']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -920,13 +920,13 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function question_remove_icon(structure $structure, $slot, $pageurl) {
|
||||
$url = new \moodle_url($pageurl, array('sesskey' => sesskey(), 'remove' => $slot));
|
||||
$url = new \moodle_url($pageurl, ['sesskey' => sesskey(), 'remove' => $slot]);
|
||||
$strdelete = get_string('delete');
|
||||
|
||||
$image = $this->pix_icon('t/delete', $strdelete);
|
||||
|
||||
return $this->action_link($url, $image, null, array('title' => $strdelete,
|
||||
'class' => 'cm-edit-action editing_delete', 'data-action' => 'delete'));
|
||||
return $this->action_link($url, $image, null, ['title' => $strdelete,
|
||||
'class' => 'cm-edit-action editing_delete', 'data-action' => 'delete']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -938,8 +938,8 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
*/
|
||||
public function page_split_join_button($structure, $slot) {
|
||||
$insertpagebreak = !$structure->is_last_slot_on_page($slot);
|
||||
$url = new \moodle_url('repaginate.php', array('quizid' => $structure->get_quizid(),
|
||||
'slot' => $slot, 'repag' => $insertpagebreak ? 2 : 1, 'sesskey' => sesskey()));
|
||||
$url = new \moodle_url('repaginate.php', ['quizid' => $structure->get_quizid(),
|
||||
'slot' => $slot, 'repag' => $insertpagebreak ? 2 : 1, 'sesskey' => sesskey()]);
|
||||
|
||||
if ($insertpagebreak) {
|
||||
$title = get_string('addpagebreak', 'quiz');
|
||||
@@ -956,8 +956,8 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
if (!$structure->can_be_edited()) {
|
||||
$disabled = 'disabled';
|
||||
}
|
||||
return html_writer::span($this->action_link($url, $image, null, array('title' => $title,
|
||||
'class' => 'page_split_join cm-edit-action', 'disabled' => $disabled, 'data-action' => $action)),
|
||||
return html_writer::span($this->action_link($url, $image, null, ['title' => $title,
|
||||
'class' => 'page_split_join cm-edit-action', 'disabled' => $disabled, 'data-action' => $action]),
|
||||
'page_split_join_wrapper');
|
||||
}
|
||||
|
||||
@@ -970,19 +970,19 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function question_dependency_icon($structure, $slot) {
|
||||
$a = array(
|
||||
$a = [
|
||||
'thisq' => $structure->get_displayed_number_for_slot($slot),
|
||||
'previousq' => $structure->get_displayed_number_for_slot(max($slot - 1, 1)),
|
||||
);
|
||||
];
|
||||
if ($structure->is_question_dependent_on_previous_slot($slot)) {
|
||||
$title = get_string('questiondependencyremove', 'quiz', $a);
|
||||
$image = $this->pix_icon('t/locked', get_string('questiondependsonprevious', 'quiz'),
|
||||
'moodle', array('title' => ''));
|
||||
'moodle', ['title' => '']);
|
||||
$action = 'removedependency';
|
||||
} else {
|
||||
$title = get_string('questiondependencyadd', 'quiz', $a);
|
||||
$image = $this->pix_icon('t/unlocked', get_string('questiondependencyfree', 'quiz'),
|
||||
'moodle', array('title' => ''));
|
||||
'moodle', ['title' => '']);
|
||||
$action = 'adddependency';
|
||||
}
|
||||
|
||||
@@ -995,8 +995,8 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
if (!$structure->can_question_depend_on_previous_slot($slot)) {
|
||||
$extraclass = ' question_dependency_cannot_depend';
|
||||
}
|
||||
return html_writer::span($this->action_link('#', $image, null, array('title' => $title,
|
||||
'class' => 'cm-edit-action', 'disabled' => $disabled, 'data-action' => $action)),
|
||||
return html_writer::span($this->action_link('#', $image, null, ['title' => $title,
|
||||
'class' => 'cm-edit-action', 'disabled' => $disabled, 'data-action' => $action]),
|
||||
'question_dependency_wrapper' . $extraclass);
|
||||
}
|
||||
|
||||
@@ -1015,27 +1015,27 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
$output = '';
|
||||
|
||||
$question = $structure->get_question_in_slot($slot);
|
||||
$editurl = new \moodle_url('/question/bank/editquestion/question.php', array(
|
||||
$editurl = new \moodle_url('/question/bank/editquestion/question.php', [
|
||||
'returnurl' => $pageurl->out_as_local_url(),
|
||||
'cmid' => $structure->get_cmid(), 'id' => $question->questionid));
|
||||
'cmid' => $structure->get_cmid(), 'id' => $question->questionid]);
|
||||
|
||||
$instancename = quiz_question_tostring($question);
|
||||
|
||||
$qtype = \question_bank::get_qtype($question->qtype, false);
|
||||
$namestr = $qtype->local_name();
|
||||
|
||||
$icon = $this->pix_icon('icon', $namestr, $qtype->plugin_name(), array('title' => $namestr,
|
||||
'class' => 'activityicon', 'alt' => ' ', 'role' => 'presentation'));
|
||||
$icon = $this->pix_icon('icon', $namestr, $qtype->plugin_name(), ['title' => $namestr,
|
||||
'class' => 'activityicon', 'alt' => ' ', 'role' => 'presentation']);
|
||||
|
||||
$editicon = $this->pix_icon('t/edit', '', 'moodle', array('title' => ''));
|
||||
$editicon = $this->pix_icon('t/edit', '', 'moodle', ['title' => '']);
|
||||
|
||||
// Need plain question name without html tags for link title.
|
||||
$title = shorten_text(format_string($question->name), 100);
|
||||
|
||||
// Display the link itself.
|
||||
$activitylink = $icon . html_writer::tag('span', $editicon . $instancename, array('class' => 'instancename'));
|
||||
$activitylink = $icon . html_writer::tag('span', $editicon . $instancename, ['class' => 'instancename']);
|
||||
$output .= html_writer::link($editurl, $activitylink,
|
||||
array('title' => get_string('editquestion', 'quiz').' '.$title));
|
||||
['title' => get_string('editquestion', 'quiz').' '.$title]);
|
||||
|
||||
return $output;
|
||||
}
|
||||
@@ -1053,7 +1053,7 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
$question = $structure->get_question_in_slot($slotnumber);
|
||||
$slot = $structure->get_slot_by_number($slotnumber);
|
||||
$editurl = new \moodle_url('/mod/quiz/editrandom.php',
|
||||
array('returnurl' => $pageurl->out_as_local_url(), 'slotid' => $slot->id));
|
||||
['returnurl' => $pageurl->out_as_local_url(), 'slotid' => $slot->id]);
|
||||
|
||||
$temp = clone($question);
|
||||
$temp->questiontext = '';
|
||||
@@ -1063,10 +1063,10 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
$configuretitle = get_string('configurerandomquestion', 'quiz');
|
||||
$qtype = \question_bank::get_qtype($question->qtype, false);
|
||||
$namestr = $qtype->local_name();
|
||||
$icon = $this->pix_icon('icon', $namestr, $qtype->plugin_name(), array('title' => $namestr,
|
||||
'class' => 'icon activityicon', 'alt' => ' ', 'role' => 'presentation'));
|
||||
$icon = $this->pix_icon('icon', $namestr, $qtype->plugin_name(), ['title' => $namestr,
|
||||
'class' => 'icon activityicon', 'alt' => ' ', 'role' => 'presentation']);
|
||||
|
||||
$editicon = $this->pix_icon('t/edit', $configuretitle, 'moodle', array('title' => ''));
|
||||
$editicon = $this->pix_icon('t/edit', $configuretitle, 'moodle', ['title' => '']);
|
||||
$qbankurlparams = [
|
||||
'cmid' => $structure->get_cmid(),
|
||||
'cat' => $slot->category . ',' . $slot->contextid,
|
||||
@@ -1086,9 +1086,9 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
// selected from in the question bank.
|
||||
$qbankurl = new \moodle_url('/question/edit.php', $qbankurlparams);
|
||||
$qbanklink = ' ' . \html_writer::link($qbankurl,
|
||||
get_string('seequestions', 'quiz'), array('class' => 'mod_quiz_random_qbank_link'));
|
||||
get_string('seequestions', 'quiz'), ['class' => 'mod_quiz_random_qbank_link']);
|
||||
|
||||
return html_writer::link($editurl, $icon . $editicon, array('title' => $configuretitle)) .
|
||||
return html_writer::link($editurl, $icon . $editicon, ['title' => $configuretitle]) .
|
||||
' ' . $instancename . ' ' . $qbanklink;
|
||||
}
|
||||
|
||||
@@ -1105,24 +1105,24 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
'instancemaxmark decimalplaces_' . $structure->get_decimal_places_for_question_marks());
|
||||
|
||||
$output .= html_writer::span(
|
||||
$this->pix_icon('spacer', '', 'moodle', array('class' => 'editicon visibleifjs', 'title' => '')),
|
||||
$this->pix_icon('spacer', '', 'moodle', ['class' => 'editicon visibleifjs', 'title' => '']),
|
||||
'editing_maxmark');
|
||||
return html_writer::span($output, 'instancemaxmarkcontainer infoitem');
|
||||
}
|
||||
|
||||
$output = html_writer::span($structure->formatted_question_grade($slot),
|
||||
'instancemaxmark decimalplaces_' . $structure->get_decimal_places_for_question_marks(),
|
||||
array('title' => get_string('maxmark', 'quiz')));
|
||||
['title' => get_string('maxmark', 'quiz')]);
|
||||
|
||||
$output .= html_writer::span(
|
||||
html_writer::link(
|
||||
new \moodle_url('#'),
|
||||
$this->pix_icon('t/editstring', '', 'moodle', array('class' => 'editicon visibleifjs', 'title' => '')),
|
||||
array(
|
||||
$this->pix_icon('t/editstring', '', 'moodle', ['class' => 'editicon visibleifjs', 'title' => '']),
|
||||
[
|
||||
'class' => 'editing_maxmark',
|
||||
'data-action' => 'editmaxmark',
|
||||
'title' => get_string('editmaxmark', 'quiz'),
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
return html_writer::span($output, 'instancemaxmarkcontainer');
|
||||
@@ -1144,7 +1144,7 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
*/
|
||||
public function question_chooser() {
|
||||
$chooser = \mod_quiz\output\question_chooser::get($this->page->course, [], null);
|
||||
$container = html_writer::div($this->render($chooser), '', array('id' => 'qtypechoicecontainer'));
|
||||
$container = html_writer::div($this->render($chooser), '', ['id' => 'qtypechoicecontainer']);
|
||||
return html_writer::div($container, 'createnewquestion');
|
||||
}
|
||||
|
||||
@@ -1173,52 +1173,52 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
$config = new \stdClass();
|
||||
$config->resourceurl = '/mod/quiz/edit_rest.php';
|
||||
$config->sectionurl = '/mod/quiz/edit_rest.php';
|
||||
$config->pageparams = array();
|
||||
$config->pageparams = [];
|
||||
$config->questiondecimalpoints = $structure->get_decimal_places_for_question_marks();
|
||||
$config->pagehtml = $this->new_page_template($structure, $contexts, $pagevars, $pageurl);
|
||||
$config->addpageiconhtml = $this->add_page_icon_template($structure);
|
||||
|
||||
$this->page->requires->yui_module('moodle-mod_quiz-toolboxes',
|
||||
'M.mod_quiz.init_resource_toolbox',
|
||||
array(array(
|
||||
[[
|
||||
'courseid' => $structure->get_courseid(),
|
||||
'quizid' => $structure->get_quizid(),
|
||||
'ajaxurl' => $config->resourceurl,
|
||||
'config' => $config,
|
||||
))
|
||||
]]
|
||||
);
|
||||
unset($config->pagehtml);
|
||||
unset($config->addpageiconhtml);
|
||||
|
||||
$this->page->requires->strings_for_js(array('areyousureremoveselected'), 'quiz');
|
||||
$this->page->requires->strings_for_js(['areyousureremoveselected'], 'quiz');
|
||||
$this->page->requires->yui_module('moodle-mod_quiz-toolboxes',
|
||||
'M.mod_quiz.init_section_toolbox',
|
||||
array(array(
|
||||
[[
|
||||
'courseid' => $structure,
|
||||
'quizid' => $structure->get_quizid(),
|
||||
'ajaxurl' => $config->sectionurl,
|
||||
'config' => $config,
|
||||
))
|
||||
]]
|
||||
);
|
||||
|
||||
$this->page->requires->yui_module('moodle-mod_quiz-dragdrop', 'M.mod_quiz.init_section_dragdrop',
|
||||
array(array(
|
||||
[[
|
||||
'courseid' => $structure,
|
||||
'quizid' => $structure->get_quizid(),
|
||||
'ajaxurl' => $config->sectionurl,
|
||||
'config' => $config,
|
||||
)), null, true);
|
||||
]], null, true);
|
||||
|
||||
$this->page->requires->yui_module('moodle-mod_quiz-dragdrop', 'M.mod_quiz.init_resource_dragdrop',
|
||||
array(array(
|
||||
[[
|
||||
'courseid' => $structure,
|
||||
'quizid' => $structure->get_quizid(),
|
||||
'ajaxurl' => $config->resourceurl,
|
||||
'config' => $config,
|
||||
)), null, true);
|
||||
]], null, true);
|
||||
|
||||
// Require various strings for the command toolbox.
|
||||
$this->page->requires->strings_for_js(array(
|
||||
$this->page->requires->strings_for_js([
|
||||
'clicktohideshow',
|
||||
'deletechecktype',
|
||||
'deletechecktypename',
|
||||
@@ -1237,9 +1237,9 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
'selectall',
|
||||
'show',
|
||||
'tocontent',
|
||||
), 'moodle');
|
||||
], 'moodle');
|
||||
|
||||
$this->page->requires->strings_for_js(array(
|
||||
$this->page->requires->strings_for_js([
|
||||
'addpagebreak',
|
||||
'cannotremoveallsectionslots',
|
||||
'cannotremoveslots',
|
||||
@@ -1256,7 +1256,7 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
'questiondependencyfree',
|
||||
'questiondependencyremove',
|
||||
'questiondependsonprevious',
|
||||
), 'quiz');
|
||||
], 'quiz');
|
||||
|
||||
foreach (\question_bank::get_all_qtypes() as $qtype => $notused) {
|
||||
$this->page->requires->string_for_js('pluginname', 'qtype_' . $qtype);
|
||||
@@ -1284,7 +1284,7 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
|
||||
// Normalise the page number.
|
||||
$pagenumber = $structure->get_page_number_for_slot(1);
|
||||
$strcontexts = array();
|
||||
$strcontexts = [];
|
||||
$strcontexts[] = 'page-';
|
||||
$strcontexts[] = get_string('page') . ' ';
|
||||
$strcontexts[] = 'addonpage%3D';
|
||||
|
||||
@@ -40,7 +40,7 @@ class navigation_panel_attempt extends navigation_panel_base {
|
||||
|
||||
public function render_before_button_bits(renderer $output) {
|
||||
return html_writer::tag('div', get_string('navnojswarning', 'quiz'),
|
||||
array('id' => 'quiznojswarning'));
|
||||
['id' => 'quiznojswarning']);
|
||||
}
|
||||
|
||||
public function render_end_bits(renderer $output) {
|
||||
@@ -49,7 +49,7 @@ class navigation_panel_attempt extends navigation_panel_base {
|
||||
return '';
|
||||
}
|
||||
return html_writer::link($this->attemptobj->summary_url(),
|
||||
get_string('endtest', 'quiz'), array('class' => 'endtestlink aalink')) .
|
||||
get_string('endtest', 'quiz'), ['class' => 'endtestlink aalink']) .
|
||||
$this->render_restart_preview_link($output);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ abstract class navigation_panel_base {
|
||||
* @return renderable[] the buttons, possibly interleaved with section headings.
|
||||
*/
|
||||
public function get_question_buttons() {
|
||||
$buttons = array();
|
||||
$buttons = [];
|
||||
foreach ($this->attemptobj->get_slots() as $slot) {
|
||||
$heading = $this->attemptobj->get_heading_before_slot($slot);
|
||||
if (!is_null($heading)) {
|
||||
@@ -153,7 +153,7 @@ abstract class navigation_panel_base {
|
||||
return '';
|
||||
}
|
||||
return $output->restart_preview_button(new moodle_url(
|
||||
$this->attemptobj->start_attempt_url(), array('forcenew' => true)));
|
||||
$this->attemptobj->start_attempt_url(), ['forcenew' => true]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +174,7 @@ abstract class navigation_panel_base {
|
||||
if ($this->attemptobj->get_quiz()->showuserpicture == QUIZ_SHOWIMAGE_NONE) {
|
||||
return null;
|
||||
}
|
||||
$user = $DB->get_record('user', array('id' => $this->attemptobj->get_userid()));
|
||||
$user = $DB->get_record('user', ['id' => $this->attemptobj->get_userid()]);
|
||||
$userpicture = new user_picture($user);
|
||||
$userpicture->courseid = $this->attemptobj->get_courseid();
|
||||
if ($this->attemptobj->get_quiz()->showuserpicture == QUIZ_SHOWIMAGE_LARGE) {
|
||||
|
||||
@@ -46,7 +46,7 @@ class quiz extends base {
|
||||
|
||||
// Do the opposite of db/install.php scripts - deregister the report.
|
||||
|
||||
$DB->delete_records('quiz_reports', array('name'=>$this->name));
|
||||
$DB->delete_records('quiz_reports', ['name'=>$this->name]);
|
||||
|
||||
parent::uninstall_cleanup();
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ class custom_view extends \core_question\local\bank\view {
|
||||
echo \html_writer::start_tag('div', ['class' => 'pt-2']);
|
||||
if ($canuseall) {
|
||||
// Add selected questions to the quiz.
|
||||
$params = array(
|
||||
$params = [
|
||||
'type' => 'submit',
|
||||
'name' => 'add',
|
||||
'class' => 'btn btn-primary',
|
||||
@@ -210,7 +210,7 @@ class custom_view extends \core_question\local\bank\view {
|
||||
'data-togglegroup' => 'qbank',
|
||||
'data-toggle' => 'action',
|
||||
'disabled' => true,
|
||||
);
|
||||
];
|
||||
echo \html_writer::empty_tag('input', $params);
|
||||
}
|
||||
echo \html_writer::end_tag('div');
|
||||
|
||||
@@ -41,7 +41,7 @@ class qubaids_for_quiz extends \qubaid_join {
|
||||
*/
|
||||
public function __construct(int $quizid, bool $includepreviews = true, bool $onlyfinished = false) {
|
||||
$where = 'quiza.quiz = :quizaquiz';
|
||||
$params = array('quizaquiz' => $quizid);
|
||||
$params = ['quizaquiz' => $quizid];
|
||||
|
||||
if (!$includepreviews) {
|
||||
$where .= ' AND preview = 0';
|
||||
|
||||
@@ -85,14 +85,14 @@ class update_overdue_attempts extends \core\task\scheduled_task {
|
||||
|
||||
// If we have moved on to a different quiz, fetch the new data.
|
||||
if (!$quiz || $attempt->quiz != $quiz->id) {
|
||||
$quiz = $DB->get_record('quiz', array('id' => $attempt->quiz), '*', MUST_EXIST);
|
||||
$quiz = $DB->get_record('quiz', ['id' => $attempt->quiz], '*', MUST_EXIST);
|
||||
$cm = get_coursemodule_from_instance('quiz', $attempt->quiz);
|
||||
$quizcount += 1;
|
||||
}
|
||||
|
||||
// If we have moved on to a different course, fetch the new data.
|
||||
if (!$course || $course->id != $quiz->course) {
|
||||
$course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', ['id' => $quiz->course], '*', MUST_EXIST);
|
||||
}
|
||||
|
||||
// Make a specialised version of the quiz settings, with the relevant overrides.
|
||||
@@ -117,7 +117,7 @@ class update_overdue_attempts extends \core\task\scheduled_task {
|
||||
}
|
||||
|
||||
$attemptstoprocess->close();
|
||||
return array($count, $quizcount);
|
||||
return [$count, $quizcount];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,6 +150,6 @@ class update_overdue_attempts extends \core\task\scheduled_task {
|
||||
AND quiza.timecheckstate <= :processto
|
||||
ORDER BY quiz.course, quiza.quiz",
|
||||
|
||||
array('processto' => $processto, 'iprocessto' => $processto));
|
||||
['processto' => $processto, 'iprocessto' => $processto]);
|
||||
}
|
||||
}
|
||||
|
||||
+17
-17
@@ -30,11 +30,11 @@ $attemptid = required_param('attempt', PARAM_INT);
|
||||
$slot = required_param('slot', PARAM_INT); // The question number in the attempt.
|
||||
$cmid = optional_param('cmid', null, PARAM_INT);
|
||||
|
||||
$PAGE->set_url('/mod/quiz/comment.php', array('attempt' => $attemptid, 'slot' => $slot));
|
||||
$PAGE->set_url('/mod/quiz/comment.php', ['attempt' => $attemptid, 'slot' => $slot]);
|
||||
|
||||
$attemptobj = quiz_create_attempt_handling_errors($attemptid, $cmid);
|
||||
$attemptobj->preload_all_attempt_step_users();
|
||||
$student = $DB->get_record('user', array('id' => $attemptobj->get_userid()));
|
||||
$student = $DB->get_record('user', ['id' => $attemptobj->get_userid()]);
|
||||
|
||||
// Can only grade finished attempts.
|
||||
if (!$attemptobj->is_finished()) {
|
||||
@@ -47,37 +47,37 @@ $attemptobj->require_capability('mod/quiz:grade');
|
||||
|
||||
// Print the page header.
|
||||
$PAGE->set_pagelayout('popup');
|
||||
$PAGE->set_title(get_string('manualgradequestion', 'quiz', array(
|
||||
$PAGE->set_title(get_string('manualgradequestion', 'quiz', [
|
||||
'question' => format_string($attemptobj->get_question_name($slot)),
|
||||
'quiz' => format_string($attemptobj->get_quiz_name()), 'user' => fullname($student))));
|
||||
'quiz' => format_string($attemptobj->get_quiz_name()), 'user' => fullname($student)]));
|
||||
$PAGE->set_heading($attemptobj->get_course()->fullname);
|
||||
$output = $PAGE->get_renderer('mod_quiz');
|
||||
echo $output->header();
|
||||
|
||||
// Prepare summary information about this question attempt.
|
||||
$summarydata = array();
|
||||
$summarydata = [];
|
||||
|
||||
// Student name.
|
||||
$userpicture = new user_picture($student);
|
||||
$userpicture->courseid = $attemptobj->get_courseid();
|
||||
$summarydata['user'] = array(
|
||||
$summarydata['user'] = [
|
||||
'title' => $userpicture,
|
||||
'content' => new action_link(new moodle_url('/user/view.php', array(
|
||||
'id' => $student->id, 'course' => $attemptobj->get_courseid())),
|
||||
'content' => new action_link(new moodle_url('/user/view.php', [
|
||||
'id' => $student->id, 'course' => $attemptobj->get_courseid()]),
|
||||
fullname($student, true)),
|
||||
);
|
||||
];
|
||||
|
||||
// Quiz name.
|
||||
$summarydata['quizname'] = array(
|
||||
$summarydata['quizname'] = [
|
||||
'title' => get_string('modulename', 'quiz'),
|
||||
'content' => format_string($attemptobj->get_quiz_name()),
|
||||
);
|
||||
];
|
||||
|
||||
// Question name.
|
||||
$summarydata['questionname'] = array(
|
||||
$summarydata['questionname'] = [
|
||||
'title' => get_string('question', 'quiz'),
|
||||
'content' => $attemptobj->get_question_name($slot),
|
||||
);
|
||||
];
|
||||
|
||||
// Process any data that was submitted.
|
||||
if (data_submitted() && confirm_sesskey()) {
|
||||
@@ -87,16 +87,16 @@ if (data_submitted() && confirm_sesskey()) {
|
||||
$transaction->allow_commit();
|
||||
|
||||
// Log this action.
|
||||
$params = array(
|
||||
$params = [
|
||||
'objectid' => $attemptobj->get_question_attempt($slot)->get_question_id(),
|
||||
'courseid' => $attemptobj->get_courseid(),
|
||||
'context' => context_module::instance($attemptobj->get_cmid()),
|
||||
'other' => array(
|
||||
'other' => [
|
||||
'quizid' => $attemptobj->get_quizid(),
|
||||
'attemptid' => $attemptobj->get_attemptid(),
|
||||
'slot' => $slot
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
$event = \mod_quiz\event\question_manually_graded::create($params);
|
||||
$event->trigger();
|
||||
|
||||
|
||||
+14
-14
@@ -26,36 +26,36 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$observers = array(
|
||||
$observers = [
|
||||
|
||||
// Handle group events, so that open quiz attempts with group overrides get updated check times.
|
||||
array(
|
||||
[
|
||||
'eventname' => '\core\event\course_reset_started',
|
||||
'callback' => '\mod_quiz\group_observers::course_reset_started',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'eventname' => '\core\event\course_reset_ended',
|
||||
'callback' => '\mod_quiz\group_observers::course_reset_ended',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'eventname' => '\core\event\group_deleted',
|
||||
'callback' => '\mod_quiz\group_observers::group_deleted'
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'eventname' => '\core\event\group_member_added',
|
||||
'callback' => '\mod_quiz\group_observers::group_member_added',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'eventname' => '\core\event\group_member_removed',
|
||||
'callback' => '\mod_quiz\group_observers::group_member_removed',
|
||||
),
|
||||
],
|
||||
|
||||
// Handle our own \mod_quiz\event\attempt_submitted event, as a way to
|
||||
// send confirmation messages asynchronously.
|
||||
array(
|
||||
[
|
||||
'eventname' => '\mod_quiz\event\attempt_submitted',
|
||||
'includefile' => '/mod/quiz/locallib.php',
|
||||
'callback' => 'quiz_attempt_submitted_handler',
|
||||
'internal' => false
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
+17
-17
@@ -25,20 +25,20 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$logs = array(
|
||||
array('module'=>'quiz', 'action'=>'add', 'mtable'=>'quiz', 'field'=>'name'),
|
||||
array('module'=>'quiz', 'action'=>'update', 'mtable'=>'quiz', 'field'=>'name'),
|
||||
array('module'=>'quiz', 'action'=>'view', 'mtable'=>'quiz', 'field'=>'name'),
|
||||
array('module'=>'quiz', 'action'=>'report', 'mtable'=>'quiz', 'field'=>'name'),
|
||||
array('module'=>'quiz', 'action'=>'attempt', 'mtable'=>'quiz', 'field'=>'name'),
|
||||
array('module'=>'quiz', 'action'=>'submit', 'mtable'=>'quiz', 'field'=>'name'),
|
||||
array('module'=>'quiz', 'action'=>'review', 'mtable'=>'quiz', 'field'=>'name'),
|
||||
array('module'=>'quiz', 'action'=>'editquestions', 'mtable'=>'quiz', 'field'=>'name'),
|
||||
array('module'=>'quiz', 'action'=>'preview', 'mtable'=>'quiz', 'field'=>'name'),
|
||||
array('module'=>'quiz', 'action'=>'start attempt', 'mtable'=>'quiz', 'field'=>'name'),
|
||||
array('module'=>'quiz', 'action'=>'close attempt', 'mtable'=>'quiz', 'field'=>'name'),
|
||||
array('module'=>'quiz', 'action'=>'continue attempt', 'mtable'=>'quiz', 'field'=>'name'),
|
||||
array('module'=>'quiz', 'action'=>'edit override', 'mtable'=>'quiz', 'field'=>'name'),
|
||||
array('module'=>'quiz', 'action'=>'delete override', 'mtable'=>'quiz', 'field'=>'name'),
|
||||
array('module'=>'quiz', 'action'=>'view summary', 'mtable'=>'quiz', 'field'=>'name'),
|
||||
);
|
||||
$logs = [
|
||||
['module'=>'quiz', 'action'=>'add', 'mtable'=>'quiz', 'field'=>'name'],
|
||||
['module'=>'quiz', 'action'=>'update', 'mtable'=>'quiz', 'field'=>'name'],
|
||||
['module'=>'quiz', 'action'=>'view', 'mtable'=>'quiz', 'field'=>'name'],
|
||||
['module'=>'quiz', 'action'=>'report', 'mtable'=>'quiz', 'field'=>'name'],
|
||||
['module'=>'quiz', 'action'=>'attempt', 'mtable'=>'quiz', 'field'=>'name'],
|
||||
['module'=>'quiz', 'action'=>'submit', 'mtable'=>'quiz', 'field'=>'name'],
|
||||
['module'=>'quiz', 'action'=>'review', 'mtable'=>'quiz', 'field'=>'name'],
|
||||
['module'=>'quiz', 'action'=>'editquestions', 'mtable'=>'quiz', 'field'=>'name'],
|
||||
['module'=>'quiz', 'action'=>'preview', 'mtable'=>'quiz', 'field'=>'name'],
|
||||
['module'=>'quiz', 'action'=>'start attempt', 'mtable'=>'quiz', 'field'=>'name'],
|
||||
['module'=>'quiz', 'action'=>'close attempt', 'mtable'=>'quiz', 'field'=>'name'],
|
||||
['module'=>'quiz', 'action'=>'continue attempt', 'mtable'=>'quiz', 'field'=>'name'],
|
||||
['module'=>'quiz', 'action'=>'edit override', 'mtable'=>'quiz', 'field'=>'name'],
|
||||
['module'=>'quiz', 'action'=>'delete override', 'mtable'=>'quiz', 'field'=>'name'],
|
||||
['module'=>'quiz', 'action'=>'view summary', 'mtable'=>'quiz', 'field'=>'name'],
|
||||
];
|
||||
|
||||
+12
-12
@@ -24,28 +24,28 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$messageproviders = array(
|
||||
$messageproviders = [
|
||||
// Notify teacher that a student has submitted a quiz attempt.
|
||||
'submission' => array(
|
||||
'submission' => [
|
||||
'capability' => 'mod/quiz:emailnotifysubmission'
|
||||
),
|
||||
],
|
||||
|
||||
// Confirm a student's quiz attempt.
|
||||
'confirmation' => array(
|
||||
'confirmation' => [
|
||||
'capability' => 'mod/quiz:emailconfirmsubmission',
|
||||
'defaults' => array(
|
||||
'defaults' => [
|
||||
'airnotifier' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_ENABLED,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
// Warning to the student that their quiz attempt is now overdue, if the quiz
|
||||
// has a grace period.
|
||||
'attempt_overdue' => array(
|
||||
'attempt_overdue' => [
|
||||
'capability' => 'mod/quiz:emailwarnoverdue',
|
||||
'defaults' => array(
|
||||
'defaults' => [
|
||||
'airnotifier' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_ENABLED,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
'attempt_grading_complete' => [
|
||||
'capability' => 'mod/quiz:emailnotifyattemptgraded',
|
||||
@@ -53,4 +53,4 @@ $messageproviders = array(
|
||||
'airnotifier' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_ENABLED,
|
||||
],
|
||||
],
|
||||
);
|
||||
];
|
||||
|
||||
+56
-56
@@ -26,171 +26,171 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$functions = array(
|
||||
$functions = [
|
||||
|
||||
'mod_quiz_get_quizzes_by_courses' => array(
|
||||
'mod_quiz_get_quizzes_by_courses' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'get_quizzes_by_courses',
|
||||
'description' => 'Returns a list of quizzes in a provided list of courses,
|
||||
if no list is provided all quizzes that the user can view will be returned.',
|
||||
'type' => 'read',
|
||||
'capabilities' => 'mod/quiz:view',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_view_quiz' => array(
|
||||
'mod_quiz_view_quiz' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'view_quiz',
|
||||
'description' => 'Trigger the course module viewed event and update the module completion status.',
|
||||
'type' => 'write',
|
||||
'capabilities' => 'mod/quiz:view',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_get_user_attempts' => array(
|
||||
'mod_quiz_get_user_attempts' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'get_user_attempts',
|
||||
'description' => 'Return a list of attempts for the given quiz and user.',
|
||||
'type' => 'read',
|
||||
'capabilities' => 'mod/quiz:view',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_get_user_best_grade' => array(
|
||||
'mod_quiz_get_user_best_grade' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'get_user_best_grade',
|
||||
'description' => 'Get the best current grade for the given user on a quiz.',
|
||||
'type' => 'read',
|
||||
'capabilities' => 'mod/quiz:view',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_get_combined_review_options' => array(
|
||||
'mod_quiz_get_combined_review_options' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'get_combined_review_options',
|
||||
'description' => 'Combines the review options from a number of different quiz attempts.',
|
||||
'type' => 'read',
|
||||
'capabilities' => 'mod/quiz:view',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_start_attempt' => array(
|
||||
'mod_quiz_start_attempt' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'start_attempt',
|
||||
'description' => 'Starts a new attempt at a quiz.',
|
||||
'type' => 'write',
|
||||
'capabilities' => 'mod/quiz:attempt',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_get_attempt_data' => array(
|
||||
'mod_quiz_get_attempt_data' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'get_attempt_data',
|
||||
'description' => 'Returns information for the given attempt page for a quiz attempt in progress.',
|
||||
'type' => 'read',
|
||||
'capabilities' => 'mod/quiz:attempt',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_get_attempt_summary' => array(
|
||||
'mod_quiz_get_attempt_summary' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'get_attempt_summary',
|
||||
'description' => 'Returns a summary of a quiz attempt before it is submitted.',
|
||||
'type' => 'read',
|
||||
'capabilities' => 'mod/quiz:attempt',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_save_attempt' => array(
|
||||
'mod_quiz_save_attempt' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'save_attempt',
|
||||
'description' => 'Processes save requests during the quiz.
|
||||
This function is intended for the quiz auto-save feature.',
|
||||
'type' => 'write',
|
||||
'capabilities' => 'mod/quiz:attempt',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_process_attempt' => array(
|
||||
'mod_quiz_process_attempt' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'process_attempt',
|
||||
'description' => 'Process responses during an attempt at a quiz and also deals with attempts finishing.',
|
||||
'type' => 'write',
|
||||
'capabilities' => 'mod/quiz:attempt',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_get_attempt_review' => array(
|
||||
'mod_quiz_get_attempt_review' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'get_attempt_review',
|
||||
'description' => 'Returns review information for the given finished attempt, can be used by users or teachers.',
|
||||
'type' => 'read',
|
||||
'capabilities' => 'mod/quiz:reviewmyattempts',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_view_attempt' => array(
|
||||
'mod_quiz_view_attempt' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'view_attempt',
|
||||
'description' => 'Trigger the attempt viewed event.',
|
||||
'type' => 'write',
|
||||
'capabilities' => 'mod/quiz:attempt',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_view_attempt_summary' => array(
|
||||
'mod_quiz_view_attempt_summary' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'view_attempt_summary',
|
||||
'description' => 'Trigger the attempt summary viewed event.',
|
||||
'type' => 'write',
|
||||
'capabilities' => 'mod/quiz:attempt',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_view_attempt_review' => array(
|
||||
'mod_quiz_view_attempt_review' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'view_attempt_review',
|
||||
'description' => 'Trigger the attempt reviewed event.',
|
||||
'type' => 'write',
|
||||
'capabilities' => 'mod/quiz:reviewmyattempts',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_get_quiz_feedback_for_grade' => array(
|
||||
'mod_quiz_get_quiz_feedback_for_grade' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'get_quiz_feedback_for_grade',
|
||||
'description' => 'Get the feedback text that should be show to a student who got the given grade in the given quiz.',
|
||||
'type' => 'read',
|
||||
'capabilities' => 'mod/quiz:view',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_get_quiz_access_information' => array(
|
||||
'mod_quiz_get_quiz_access_information' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'get_quiz_access_information',
|
||||
'description' => 'Return access information for a given quiz.',
|
||||
'type' => 'read',
|
||||
'capabilities' => 'mod/quiz:view',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_get_attempt_access_information' => array(
|
||||
'mod_quiz_get_attempt_access_information' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'get_attempt_access_information',
|
||||
'description' => 'Return access information for a given attempt in a quiz.',
|
||||
'type' => 'read',
|
||||
'capabilities' => 'mod/quiz:view',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_get_quiz_required_qtypes' => array(
|
||||
'mod_quiz_get_quiz_required_qtypes' => [
|
||||
'classname' => 'mod_quiz_external',
|
||||
'methodname' => 'get_quiz_required_qtypes',
|
||||
'description' => 'Return the potential question types that would be required for a given quiz.',
|
||||
'type' => 'read',
|
||||
'capabilities' => 'mod/quiz:view',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE]
|
||||
],
|
||||
|
||||
'mod_quiz_set_question_version' => [
|
||||
'classname' => 'mod_quiz\external\submit_question_version',
|
||||
@@ -199,4 +199,4 @@ $functions = array(
|
||||
'capabilities' => 'mod/quiz:view',
|
||||
'ajax' => true,
|
||||
],
|
||||
);
|
||||
];
|
||||
|
||||
@@ -50,10 +50,10 @@ function quiz_completion_check_passing_grade_or_all_attempts($course, $cm, $user
|
||||
|
||||
// Check for passing grade.
|
||||
require_once($CFG->libdir . '/gradelib.php');
|
||||
$item = grade_item::fetch(array('courseid' => $course->id, 'itemtype' => 'mod',
|
||||
'itemmodule' => 'quiz', 'iteminstance' => $cm->instance, 'outcomeid' => null));
|
||||
$item = grade_item::fetch(['courseid' => $course->id, 'itemtype' => 'mod',
|
||||
'itemmodule' => 'quiz', 'iteminstance' => $cm->instance, 'outcomeid' => null]);
|
||||
if ($item) {
|
||||
$grades = grade_grade::fetch_users_grades($item, array($userid), false);
|
||||
$grades = grade_grade::fetch_users_grades($item, [$userid], false);
|
||||
if (!empty($grades[$userid]) && $grades[$userid]->is_passed($item)) {
|
||||
return true;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ function quiz_get_completion_state($course, $cm, $userid, $type) {
|
||||
|
||||
// No need to call debugging here. Deprecation debugging notice already being called in \completion_info::internal_get_state().
|
||||
|
||||
$quiz = $DB->get_record('quiz', array('id' => $cm->instance), '*', MUST_EXIST);
|
||||
$quiz = $DB->get_record('quiz', ['id' => $cm->instance], '*', MUST_EXIST);
|
||||
if (!$quiz->completionattemptsexhausted && !$cm->completionpassgrade && !$quiz->completionminattempts) {
|
||||
return $type;
|
||||
}
|
||||
|
||||
+6
-6
@@ -62,7 +62,7 @@ $PAGE->set_url($thispageurl);
|
||||
$PAGE->set_secondary_active_tab("mod_quiz_edit");
|
||||
|
||||
// Get the course object and related bits.
|
||||
$course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', ['id' => $quiz->course], '*', MUST_EXIST);
|
||||
$quizobj = new quiz_settings($quiz, $cm, $course);
|
||||
$structure = $quizobj->get_structure();
|
||||
|
||||
@@ -72,7 +72,7 @@ require_capability('mod/quiz:manage', $contexts->lowest());
|
||||
// Process commands ============================================================.
|
||||
|
||||
// Get the list of question ids had their check-boxes ticked.
|
||||
$selectedslots = array();
|
||||
$selectedslots = [];
|
||||
$params = (array) data_submitted();
|
||||
foreach ($params as $key => $value) {
|
||||
if (preg_match('!^s([0-9]+)$!', $key, $matches)) {
|
||||
@@ -191,12 +191,12 @@ echo $OUTPUT->header();
|
||||
|
||||
// Initialise the JavaScript.
|
||||
$quizeditconfig = new stdClass();
|
||||
$quizeditconfig->url = $thispageurl->out(true, array('qbanktool' => '0'));
|
||||
$quizeditconfig->dialoglisteners = array();
|
||||
$quizeditconfig->url = $thispageurl->out(true, ['qbanktool' => '0']);
|
||||
$quizeditconfig->dialoglisteners = [];
|
||||
$numberoflisteners = $DB->get_field_sql("
|
||||
SELECT COALESCE(MAX(page), 1)
|
||||
FROM {quiz_slots}
|
||||
WHERE quizid = ?", array($quiz->id));
|
||||
WHERE quizid = ?", [$quiz->id]);
|
||||
|
||||
for ($pageiter = 1; $pageiter <= $numberoflisteners; $pageiter++) {
|
||||
$quizeditconfig->dialoglisteners[] = 'addrandomdialoglaunch_' . $pageiter;
|
||||
@@ -206,7 +206,7 @@ $PAGE->requires->data_for_js('quiz_edit_config', $quizeditconfig);
|
||||
$PAGE->requires->js('/question/qengine.js');
|
||||
|
||||
// Questions wrapper start.
|
||||
echo html_writer::start_tag('div', array('class' => 'mod-quiz-edit-content'));
|
||||
echo html_writer::start_tag('div', ['class' => 'mod-quiz-edit-content']);
|
||||
|
||||
echo $output->edit_page($quizobj, $structure, $contexts, $thispageurl, $pagevars);
|
||||
|
||||
|
||||
+23
-23
@@ -51,12 +51,12 @@ $shuffle = optional_param('newshuffle', 0, PARAM_INT);
|
||||
$page = optional_param('page', '', PARAM_INT);
|
||||
$ids = optional_param('ids', '', PARAM_SEQUENCE);
|
||||
$PAGE->set_url('/mod/quiz/edit-rest.php',
|
||||
array('quizid' => $quizid, 'class' => $class));
|
||||
['quizid' => $quizid, 'class' => $class]);
|
||||
|
||||
require_sesskey();
|
||||
$quiz = $DB->get_record('quiz', array('id' => $quizid), '*', MUST_EXIST);
|
||||
$quiz = $DB->get_record('quiz', ['id' => $quizid], '*', MUST_EXIST);
|
||||
$cm = get_coursemodule_from_instance('quiz', $quiz->id, $quiz->course);
|
||||
$course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', ['id' => $quiz->course], '*', MUST_EXIST);
|
||||
require_login($course, false, $cm);
|
||||
|
||||
$quizobj = new quiz_settings($quiz, $cm, $course);
|
||||
@@ -88,17 +88,17 @@ switch($requestmethod) {
|
||||
switch ($field) {
|
||||
case 'getsectiontitle':
|
||||
require_capability('mod/quiz:manage', $modcontext);
|
||||
$result = array('instancesection' => $section->heading);
|
||||
$result = ['instancesection' => $section->heading];
|
||||
break;
|
||||
case 'updatesectiontitle':
|
||||
require_capability('mod/quiz:manage', $modcontext);
|
||||
$structure->set_section_heading($id, $newheading);
|
||||
$result = array('instancesection' => format_string($newheading));
|
||||
$result = ['instancesection' => format_string($newheading)];
|
||||
break;
|
||||
case 'updateshufflequestions':
|
||||
require_capability('mod/quiz:manage', $modcontext);
|
||||
$structure->set_section_shuffle($id, $shuffle);
|
||||
$result = array('instanceshuffle' => $section->shufflequestions);
|
||||
$result = ['instanceshuffle' => $section->shufflequestions];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -116,13 +116,13 @@ switch($requestmethod) {
|
||||
}
|
||||
$structure->move_slot($id, $previousid, $page);
|
||||
quiz_delete_previews($quiz);
|
||||
$result = array('visible' => true);
|
||||
$result = ['visible' => true];
|
||||
break;
|
||||
|
||||
case 'getmaxmark':
|
||||
require_capability('mod/quiz:manage', $modcontext);
|
||||
$slot = $DB->get_record('quiz_slots', array('id' => $id), '*', MUST_EXIST);
|
||||
$result = array('instancemaxmark' => quiz_format_question_grade($quiz, $slot->maxmark));
|
||||
$slot = $DB->get_record('quiz_slots', ['id' => $id], '*', MUST_EXIST);
|
||||
$result = ['instancemaxmark' => quiz_format_question_grade($quiz, $slot->maxmark)];
|
||||
break;
|
||||
|
||||
case 'updatemaxmark':
|
||||
@@ -136,19 +136,19 @@ switch($requestmethod) {
|
||||
quiz_update_all_final_grades($quiz);
|
||||
quiz_update_grades($quiz, 0, true);
|
||||
}
|
||||
$result = array('instancemaxmark' => quiz_format_question_grade($quiz, $maxmark),
|
||||
'newsummarks' => quiz_format_grade($quiz, $quiz->sumgrades));
|
||||
$result = ['instancemaxmark' => quiz_format_question_grade($quiz, $maxmark),
|
||||
'newsummarks' => quiz_format_grade($quiz, $quiz->sumgrades)];
|
||||
break;
|
||||
|
||||
case 'updatepagebreak':
|
||||
require_capability('mod/quiz:manage', $modcontext);
|
||||
$slots = $structure->update_page_break($id, $value);
|
||||
$json = array();
|
||||
$json = [];
|
||||
foreach ($slots as $slot) {
|
||||
$json[$slot->slot] = array('id' => $slot->id, 'slot' => $slot->slot,
|
||||
'page' => $slot->page);
|
||||
$json[$slot->slot] = ['id' => $slot->id, 'slot' => $slot->slot,
|
||||
'page' => $slot->page];
|
||||
}
|
||||
$result = array('slots' => $json);
|
||||
$result = ['slots' => $json];
|
||||
break;
|
||||
|
||||
case 'deletemultiple':
|
||||
@@ -156,7 +156,7 @@ switch($requestmethod) {
|
||||
|
||||
$ids = explode(',', $ids);
|
||||
foreach ($ids as $id) {
|
||||
$slot = $DB->get_record('quiz_slots', array('quizid' => $quiz->id, 'id' => $id),
|
||||
$slot = $DB->get_record('quiz_slots', ['quizid' => $quiz->id, 'id' => $id],
|
||||
'*', MUST_EXIST);
|
||||
if ($structure->has_use_capability($slot->slot)) {
|
||||
$structure->remove_slot($slot->slot);
|
||||
@@ -165,8 +165,8 @@ switch($requestmethod) {
|
||||
quiz_delete_previews($quiz);
|
||||
quiz_update_sumgrades($quiz);
|
||||
|
||||
$result = array('newsummarks' => quiz_format_grade($quiz, $quiz->sumgrades),
|
||||
'deleted' => true, 'newnumquestions' => $structure->get_question_count());
|
||||
$result = ['newsummarks' => quiz_format_grade($quiz, $quiz->sumgrades),
|
||||
'deleted' => true, 'newnumquestions' => $structure->get_question_count()];
|
||||
break;
|
||||
|
||||
case 'updatedependency':
|
||||
@@ -174,7 +174,7 @@ switch($requestmethod) {
|
||||
$slot = $structure->get_slot_by_id($id);
|
||||
$value = (bool) $value;
|
||||
$structure->update_question_dependency($slot->id, $value);
|
||||
$result = array('requireprevious' => $value);
|
||||
$result = ['requireprevious' => $value];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -186,12 +186,12 @@ switch($requestmethod) {
|
||||
case 'section':
|
||||
require_capability('mod/quiz:manage', $modcontext);
|
||||
$structure->remove_section_heading($id);
|
||||
$result = array('deleted' => true);
|
||||
$result = ['deleted' => true];
|
||||
break;
|
||||
|
||||
case 'resource':
|
||||
require_capability('mod/quiz:manage', $modcontext);
|
||||
if (!$slot = $DB->get_record('quiz_slots', array('quizid' => $quiz->id, 'id' => $id))) {
|
||||
if (!$slot = $DB->get_record('quiz_slots', ['quizid' => $quiz->id, 'id' => $id])) {
|
||||
throw new moodle_exception('AJAX commands.php: Bad slot ID '.$id);
|
||||
}
|
||||
|
||||
@@ -204,8 +204,8 @@ switch($requestmethod) {
|
||||
$structure->remove_slot($slot->slot);
|
||||
quiz_delete_previews($quiz);
|
||||
quiz_update_sumgrades($quiz);
|
||||
$result = array('newsummarks' => quiz_format_grade($quiz, $quiz->sumgrades),
|
||||
'deleted' => true, 'newnumquestions' => $structure->get_question_count());
|
||||
$result = ['newsummarks' => quiz_format_grade($quiz, $quiz->sumgrades),
|
||||
'deleted' => true, 'newnumquestions' => $structure->get_question_count()];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -77,7 +77,7 @@ $mform = new mod_quiz\form\randomquestion_form(new moodle_url('/mod/quiz/editran
|
||||
$toform = new stdClass();
|
||||
$toform->category = "{$category->id},{$category->contextid}";
|
||||
$toform->includesubcategories = $filterconditions->includingsubcategories;
|
||||
$toform->fromtags = array();
|
||||
$toform->fromtags = [];
|
||||
if (isset($filterconditions->tags)) {
|
||||
$currentslottags = $filterconditions->tags;
|
||||
foreach ($currentslottags as $slottag) {
|
||||
|
||||
+5
-5
@@ -35,8 +35,8 @@ $id = required_param('id', PARAM_INT);
|
||||
$userid = optional_param('userid', 0, PARAM_INT);
|
||||
|
||||
$cm = get_coursemodule_from_id('quiz', $id, 0, false, MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
|
||||
$quiz = $DB->get_record('quiz', array('id' => $cm->instance), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST);
|
||||
$quiz = $DB->get_record('quiz', ['id' => $cm->instance], '*', MUST_EXIST);
|
||||
require_login($course, false, $cm);
|
||||
|
||||
$reportlist = quiz_report_list(context_module::instance($cm->id));
|
||||
@@ -46,7 +46,7 @@ if (empty($reportlist) || $userid == $USER->id) {
|
||||
// (The looking at their own grades case is unlikely, since users who
|
||||
// appear in the gradebook are unlikely to be able to see quiz reports,
|
||||
// but it is possible.)
|
||||
redirect(new moodle_url('/mod/quiz/view.php', array('id' => $cm->id)));
|
||||
redirect(new moodle_url('/mod/quiz/view.php', ['id' => $cm->id]));
|
||||
}
|
||||
|
||||
// Now we know the user is interested in reports. If they are interested in a
|
||||
@@ -91,5 +91,5 @@ if ($userid) {
|
||||
}
|
||||
|
||||
// Send the user to the first report they can see.
|
||||
redirect(new moodle_url('/mod/quiz/report.php', array(
|
||||
'id' => $cm->id, 'mode' => reset($reportlist))));
|
||||
redirect(new moodle_url('/mod/quiz/report.php', [
|
||||
'id' => $cm->id, 'mode' => reset($reportlist)]));
|
||||
|
||||
+9
-9
@@ -27,17 +27,17 @@ require_once("../../config.php");
|
||||
require_once("locallib.php");
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$PAGE->set_url('/mod/quiz/index.php', array('id'=>$id));
|
||||
if (!$course = $DB->get_record('course', array('id' => $id))) {
|
||||
$PAGE->set_url('/mod/quiz/index.php', ['id'=>$id]);
|
||||
if (!$course = $DB->get_record('course', ['id' => $id])) {
|
||||
throw new \moodle_exception('invalidcourseid');
|
||||
}
|
||||
$coursecontext = context_course::instance($id);
|
||||
require_login($course);
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
|
||||
$params = array(
|
||||
$params = [
|
||||
'context' => $coursecontext
|
||||
);
|
||||
];
|
||||
$event = \mod_quiz\event\course_module_instance_list_viewed::create($params);
|
||||
$event->trigger();
|
||||
|
||||
@@ -67,8 +67,8 @@ foreach ($quizzes as $quiz) {
|
||||
}
|
||||
|
||||
// Configure table for displaying the list of instances.
|
||||
$headings = array(get_string('name'));
|
||||
$align = array('left');
|
||||
$headings = [get_string('name')];
|
||||
$align = ['left'];
|
||||
|
||||
array_push($headings, get_string('quizcloses', 'quiz'));
|
||||
array_push($align, 'left');
|
||||
@@ -87,7 +87,7 @@ 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'),
|
||||
} else if (has_any_capability(['mod/quiz:reviewmyattempts', 'mod/quiz:attempt'],
|
||||
$coursecontext)) {
|
||||
array_push($headings, get_string('grade', 'quiz'));
|
||||
array_push($align, 'left');
|
||||
@@ -102,7 +102,7 @@ if (has_capability('mod/quiz:viewreports', $coursecontext)) {
|
||||
FROM {quiz_grades} qg
|
||||
JOIN {quiz} q ON q.id = qg.quiz
|
||||
WHERE q.course = ? AND qg.userid = ?',
|
||||
array($course->id, $USER->id));
|
||||
[$course->id, $USER->id]);
|
||||
}
|
||||
|
||||
$table = new html_table();
|
||||
@@ -116,7 +116,7 @@ $timeclosedates = quiz_get_user_timeclose($course->id);
|
||||
foreach ($quizzes as $quiz) {
|
||||
$cm = get_coursemodule_from_instance('quiz', $quiz->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
$data = array();
|
||||
$data = [];
|
||||
|
||||
// Section number if necessary.
|
||||
$strsection = '';
|
||||
|
||||
+108
-108
@@ -105,8 +105,8 @@ function quiz_add_instance($quiz) {
|
||||
$quiz->id = $DB->insert_record('quiz', $quiz);
|
||||
|
||||
// Create the first section for this quiz.
|
||||
$DB->insert_record('quiz_sections', array('quizid' => $quiz->id,
|
||||
'firstslot' => 1, 'heading' => '', 'shufflequestions' => 0));
|
||||
$DB->insert_record('quiz_sections', ['quizid' => $quiz->id,
|
||||
'firstslot' => 1, 'heading' => '', 'shufflequestions' => 0]);
|
||||
|
||||
// Do the processing required after an add or an update.
|
||||
quiz_after_add_or_update($quiz);
|
||||
@@ -133,7 +133,7 @@ function quiz_update_instance($quiz, $mform) {
|
||||
}
|
||||
|
||||
// Get the current value, so we can see what changed.
|
||||
$oldquiz = $DB->get_record('quiz', array('id' => $quiz->instance));
|
||||
$oldquiz = $DB->get_record('quiz', ['id' => $quiz->instance]);
|
||||
|
||||
// We need two values from the existing DB record that are not in the form,
|
||||
// in some of the function calls below.
|
||||
@@ -156,7 +156,7 @@ function quiz_update_instance($quiz, $mform) {
|
||||
|| $oldquiz->timeclose != $quiz->timeclose
|
||||
|| $oldquiz->graceperiod != $quiz->graceperiod;
|
||||
if ($quizdateschanged) {
|
||||
quiz_update_open_attempts(array('quizid' => $quiz->id));
|
||||
quiz_update_open_attempts(['quizid' => $quiz->id]);
|
||||
}
|
||||
|
||||
// Delete any previous preview attempts.
|
||||
@@ -181,21 +181,21 @@ function quiz_update_instance($quiz, $mform) {
|
||||
function quiz_delete_instance($id) {
|
||||
global $DB;
|
||||
|
||||
$quiz = $DB->get_record('quiz', array('id' => $id), '*', MUST_EXIST);
|
||||
$quiz = $DB->get_record('quiz', ['id' => $id], '*', MUST_EXIST);
|
||||
|
||||
quiz_delete_all_attempts($quiz);
|
||||
quiz_delete_all_overrides($quiz);
|
||||
quiz_delete_references($quiz->id);
|
||||
|
||||
// We need to do the following deletes before we try and delete randoms, otherwise they would still be 'in use'.
|
||||
$DB->delete_records('quiz_slots', array('quizid' => $quiz->id));
|
||||
$DB->delete_records('quiz_sections', array('quizid' => $quiz->id));
|
||||
$DB->delete_records('quiz_slots', ['quizid' => $quiz->id]);
|
||||
$DB->delete_records('quiz_sections', ['quizid' => $quiz->id]);
|
||||
|
||||
$DB->delete_records('quiz_feedback', array('quizid' => $quiz->id));
|
||||
$DB->delete_records('quiz_feedback', ['quizid' => $quiz->id]);
|
||||
|
||||
access_manager::delete_settings($quiz);
|
||||
|
||||
$events = $DB->get_records('event', array('modulename' => 'quiz', 'instance' => $quiz->id));
|
||||
$events = $DB->get_records('event', ['modulename' => 'quiz', 'instance' => $quiz->id]);
|
||||
foreach ($events as $event) {
|
||||
$event = calendar_event::load($event);
|
||||
$event->delete();
|
||||
@@ -203,7 +203,7 @@ function quiz_delete_instance($id) {
|
||||
|
||||
quiz_grade_item_delete($quiz);
|
||||
// We must delete the module record after we delete the grade item.
|
||||
$DB->delete_records('quiz', array('id' => $quiz->id));
|
||||
$DB->delete_records('quiz', ['id' => $quiz->id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -224,18 +224,18 @@ function quiz_delete_override($quiz, $overrideid, $log = true) {
|
||||
$quiz->cmid = $cm->id;
|
||||
}
|
||||
|
||||
$override = $DB->get_record('quiz_overrides', array('id' => $overrideid), '*', MUST_EXIST);
|
||||
$override = $DB->get_record('quiz_overrides', ['id' => $overrideid], '*', MUST_EXIST);
|
||||
|
||||
// Delete the events.
|
||||
if (isset($override->groupid)) {
|
||||
// Create the search array for a group override.
|
||||
$eventsearcharray = array('modulename' => 'quiz',
|
||||
'instance' => $quiz->id, 'groupid' => (int)$override->groupid);
|
||||
$eventsearcharray = ['modulename' => 'quiz',
|
||||
'instance' => $quiz->id, 'groupid' => (int)$override->groupid];
|
||||
$cachekey = "{$quiz->id}_g_{$override->groupid}";
|
||||
} else {
|
||||
// Create the search array for a user override.
|
||||
$eventsearcharray = array('modulename' => 'quiz',
|
||||
'instance' => $quiz->id, 'userid' => (int)$override->userid);
|
||||
$eventsearcharray = ['modulename' => 'quiz',
|
||||
'instance' => $quiz->id, 'userid' => (int)$override->userid];
|
||||
$cachekey = "{$quiz->id}_u_{$override->userid}";
|
||||
}
|
||||
$events = $DB->get_records('event', $eventsearcharray);
|
||||
@@ -244,18 +244,18 @@ function quiz_delete_override($quiz, $overrideid, $log = true) {
|
||||
$eventold->delete();
|
||||
}
|
||||
|
||||
$DB->delete_records('quiz_overrides', array('id' => $overrideid));
|
||||
$DB->delete_records('quiz_overrides', ['id' => $overrideid]);
|
||||
cache::make('mod_quiz', 'overrides')->delete($cachekey);
|
||||
|
||||
if ($log) {
|
||||
// Set the common parameters for one of the events we will be triggering.
|
||||
$params = array(
|
||||
$params = [
|
||||
'objectid' => $override->id,
|
||||
'context' => context_module::instance($quiz->cmid),
|
||||
'other' => array(
|
||||
'other' => [
|
||||
'quizid' => $override->quiz
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
// Determine which override deleted event to fire.
|
||||
if (!empty($override->userid)) {
|
||||
$params['relateduserid'] = $override->userid;
|
||||
@@ -282,7 +282,7 @@ function quiz_delete_override($quiz, $overrideid, $log = true) {
|
||||
function quiz_delete_all_overrides($quiz, $log = true) {
|
||||
global $DB;
|
||||
|
||||
$overrides = $DB->get_records('quiz_overrides', array('quiz' => $quiz->id), 'id');
|
||||
$overrides = $DB->get_records('quiz_overrides', ['quiz' => $quiz->id], 'id');
|
||||
foreach ($overrides as $override) {
|
||||
quiz_delete_override($quiz, $override->id, $log);
|
||||
}
|
||||
@@ -307,7 +307,7 @@ function quiz_update_effective_access($quiz, $userid) {
|
||||
global $DB;
|
||||
|
||||
// Check for user override.
|
||||
$override = $DB->get_record('quiz_overrides', array('quiz' => $quiz->id, 'userid' => $userid));
|
||||
$override = $DB->get_record('quiz_overrides', ['quiz' => $quiz->id, 'userid' => $userid]);
|
||||
|
||||
if (!$override) {
|
||||
$override = new stdClass();
|
||||
@@ -330,11 +330,11 @@ function quiz_update_effective_access($quiz, $userid) {
|
||||
$records = $DB->get_records_sql($sql, $params);
|
||||
|
||||
// Combine the overrides.
|
||||
$opens = array();
|
||||
$closes = array();
|
||||
$limits = array();
|
||||
$attempts = array();
|
||||
$passwords = array();
|
||||
$opens = [];
|
||||
$closes = [];
|
||||
$limits = [];
|
||||
$attempts = [];
|
||||
$passwords = [];
|
||||
|
||||
foreach ($records as $gpoverride) {
|
||||
if (isset($gpoverride->timeopen)) {
|
||||
@@ -388,7 +388,7 @@ function quiz_update_effective_access($quiz, $userid) {
|
||||
}
|
||||
|
||||
// Merge with quiz defaults.
|
||||
$keys = array('timeopen', 'timeclose', 'timelimit', 'attempts', 'password', 'extrapasswords');
|
||||
$keys = ['timeopen', 'timeclose', 'timelimit', 'attempts', 'password', 'extrapasswords'];
|
||||
foreach ($keys as $key) {
|
||||
if (isset($override->{$key})) {
|
||||
$quiz->{$key} = $override->{$key};
|
||||
@@ -407,8 +407,8 @@ function quiz_delete_all_attempts($quiz) {
|
||||
global $CFG, $DB;
|
||||
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
||||
question_engine::delete_questions_usage_by_activities(new qubaids_for_quiz($quiz->id));
|
||||
$DB->delete_records('quiz_attempts', array('quiz' => $quiz->id));
|
||||
$DB->delete_records('quiz_grades', array('quiz' => $quiz->id));
|
||||
$DB->delete_records('quiz_attempts', ['quiz' => $quiz->id]);
|
||||
$DB->delete_records('quiz_grades', ['quiz' => $quiz->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -441,7 +441,7 @@ function quiz_delete_user_attempts($quiz, $user) {
|
||||
function quiz_get_best_grade($quiz, $userid) {
|
||||
global $DB;
|
||||
$grade = $DB->get_field('quiz_grades', 'grade',
|
||||
array('quiz' => $quiz->id, 'userid' => $userid));
|
||||
['quiz' => $quiz->id, 'userid' => $userid]);
|
||||
|
||||
// Need to detect errors/no result, without catching 0 grades.
|
||||
if ($grade === false) {
|
||||
@@ -499,7 +499,7 @@ function quiz_user_outline($course, $user, $mod, $quiz) {
|
||||
|
||||
$result = new stdClass();
|
||||
// If the user can't see hidden grades, don't return that information.
|
||||
$gitem = grade_item::fetch(array('id' => $grades->items[0]->id));
|
||||
$gitem = grade_item::fetch(['id' => $grades->items[0]->id]);
|
||||
if (!$gitem->hidden || has_capability('moodle/grade:viewhidden', context_course::instance($course->id))) {
|
||||
$result->info = get_string('gradenoun') . ': ' . $grade->str_long_grade;
|
||||
} else {
|
||||
@@ -530,7 +530,7 @@ function quiz_user_complete($course, $user, $mod, $quiz) {
|
||||
if (!empty($grades->items[0]->grades)) {
|
||||
$grade = reset($grades->items[0]->grades);
|
||||
// If the user can't see hidden grades, don't return that information.
|
||||
$gitem = grade_item::fetch(array('id' => $grades->items[0]->id));
|
||||
$gitem = grade_item::fetch(['id' => $grades->items[0]->id]);
|
||||
if (!$gitem->hidden || has_capability('moodle/grade:viewhidden', context_course::instance($course->id))) {
|
||||
echo $OUTPUT->container(get_string('gradenoun').': '.$grade->str_long_grade);
|
||||
if ($grade->str_feedback) {
|
||||
@@ -545,7 +545,7 @@ function quiz_user_complete($course, $user, $mod, $quiz) {
|
||||
}
|
||||
|
||||
if ($attempts = $DB->get_records('quiz_attempts',
|
||||
array('userid' => $user->id, 'quiz' => $quiz->id), 'attempt')) {
|
||||
['userid' => $user->id, 'quiz' => $quiz->id], 'attempt')) {
|
||||
foreach ($attempts as $attempt) {
|
||||
echo get_string('attempt', 'quiz', $attempt->attempt) . ': ';
|
||||
if ($attempt->state != quiz_attempt::FINISHED) {
|
||||
@@ -553,7 +553,7 @@ function quiz_user_complete($course, $user, $mod, $quiz) {
|
||||
} else {
|
||||
if (!isset($gitem)) {
|
||||
if (!empty($grades->items[0]->grades)) {
|
||||
$gitem = grade_item::fetch(array('id' => $grades->items[0]->id));
|
||||
$gitem = grade_item::fetch(['id' => $grades->items[0]->id]);
|
||||
} else {
|
||||
$gitem = new stdClass();
|
||||
$gitem->hidden = true;
|
||||
@@ -586,7 +586,7 @@ function quiz_user_complete($course, $user, $mod, $quiz) {
|
||||
function quiz_get_user_attempts($quizids, $userid, $status = 'finished', $includepreviews = false) {
|
||||
global $DB;
|
||||
|
||||
$params = array();
|
||||
$params = [];
|
||||
switch ($status) {
|
||||
case 'all':
|
||||
$statuscondition = '';
|
||||
@@ -631,7 +631,7 @@ function quiz_get_user_attempts($quizids, $userid, $status = 'finished', $includ
|
||||
function quiz_get_user_grades($quiz, $userid = 0) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$params = array($quiz->id);
|
||||
$params = [$quiz->id];
|
||||
$usertest = '';
|
||||
if ($userid) {
|
||||
$params[] = $userid;
|
||||
@@ -741,9 +741,9 @@ function quiz_grade_item_update($quiz, $grades = null) {
|
||||
require_once($CFG->libdir . '/gradelib.php');
|
||||
|
||||
if (property_exists($quiz, 'cmidnumber')) { // May not be always present.
|
||||
$params = array('itemname' => $quiz->name, 'idnumber' => $quiz->cmidnumber);
|
||||
$params = ['itemname' => $quiz->name, 'idnumber' => $quiz->cmidnumber];
|
||||
} else {
|
||||
$params = array('itemname' => $quiz->name);
|
||||
$params = ['itemname' => $quiz->name];
|
||||
}
|
||||
|
||||
if ($quiz->grade > 0) {
|
||||
@@ -843,7 +843,7 @@ function quiz_grade_item_delete($quiz) {
|
||||
require_once($CFG->libdir . '/gradelib.php');
|
||||
|
||||
return grade_update('mod/quiz', $quiz->course, 'mod', 'quiz', $quiz->id, 0,
|
||||
null, array('deleted' => 1));
|
||||
null, ['deleted' => 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -864,7 +864,7 @@ function quiz_refresh_events($courseid = 0, $instance = null, $cm = null) {
|
||||
// If we have instance information then we can just update the one event instead of updating all events.
|
||||
if (isset($instance)) {
|
||||
if (!is_object($instance)) {
|
||||
$instance = $DB->get_record('quiz', array('id' => $instance), '*', MUST_EXIST);
|
||||
$instance = $DB->get_record('quiz', ['id' => $instance], '*', MUST_EXIST);
|
||||
}
|
||||
quiz_update_events($instance);
|
||||
return true;
|
||||
@@ -875,7 +875,7 @@ function quiz_refresh_events($courseid = 0, $instance = null, $cm = null) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (!$quizzes = $DB->get_records('quiz', array('course' => $courseid))) {
|
||||
if (!$quizzes = $DB->get_records('quiz', ['course' => $courseid])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -899,7 +899,7 @@ function quiz_get_recent_mod_activity(&$activities, &$index, $timestart,
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
|
||||
$cm = $modinfo->cms[$cmid];
|
||||
$quiz = $DB->get_record('quiz', array('id' => $cm->instance));
|
||||
$quiz = $DB->get_record('quiz', ['id' => $cm->instance]);
|
||||
|
||||
if ($userid) {
|
||||
$userselect = "AND u.id = :userid";
|
||||
@@ -996,7 +996,7 @@ function quiz_print_recent_mod_activity($activity, $courseid, $detail, $modnames
|
||||
echo '<table border="0" cellpadding="3" cellspacing="0" class="forum-recent">';
|
||||
|
||||
echo '<tr><td class="userpicture" valign="top">';
|
||||
echo $OUTPUT->user_picture($activity->user, array('courseid' => $courseid));
|
||||
echo $OUTPUT->user_picture($activity->user, ['courseid' => $courseid]);
|
||||
echo '</td><td>';
|
||||
|
||||
if ($detail) {
|
||||
@@ -1142,12 +1142,12 @@ function quiz_process_options($quiz) {
|
||||
* @param string $field one of the review option field names.
|
||||
*/
|
||||
function quiz_review_option_form_to_db($fromform, $field) {
|
||||
static $times = array(
|
||||
static $times = [
|
||||
'during' => display_options::DURING,
|
||||
'immediately' => display_options::IMMEDIATELY_AFTER,
|
||||
'open' => display_options::LATER_WHILE_OPEN,
|
||||
'closed' => display_options::AFTER_CLOSE,
|
||||
);
|
||||
];
|
||||
|
||||
$review = 0;
|
||||
foreach ($times as $whenname => $when) {
|
||||
@@ -1173,9 +1173,9 @@ function mod_quiz_inplace_editable(string $itemtype, int $itemid, string $newval
|
||||
if ($itemtype === 'slotdisplaynumber') {
|
||||
global $DB;
|
||||
$record = $DB->get_record('quiz_slots', ['id' => $itemid], '*', MUST_EXIST);
|
||||
$quiz = $DB->get_record('quiz', array('id' => $record->quizid), '*', MUST_EXIST);
|
||||
$quiz = $DB->get_record('quiz', ['id' => $record->quizid], '*', MUST_EXIST);
|
||||
$cm = get_coursemodule_from_instance('quiz', $quiz->id, $quiz->course);
|
||||
$course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', ['id' => $quiz->course], '*', MUST_EXIST);
|
||||
|
||||
// Call validate_context for course module to check access and set current context.
|
||||
$context = context_module::instance($cm->id);
|
||||
@@ -1212,11 +1212,11 @@ function quiz_after_add_or_update($quiz) {
|
||||
$cmid = $quiz->coursemodule;
|
||||
|
||||
// We need to use context now, so we need to make sure all needed info is already in db.
|
||||
$DB->set_field('course_modules', 'instance', $quiz->id, array('id'=>$cmid));
|
||||
$DB->set_field('course_modules', 'instance', $quiz->id, ['id'=>$cmid]);
|
||||
$context = context_module::instance($cmid);
|
||||
|
||||
// Save the feedback.
|
||||
$DB->delete_records('quiz_feedback', array('quizid' => $quiz->id));
|
||||
$DB->delete_records('quiz_feedback', ['quizid' => $quiz->id]);
|
||||
|
||||
for ($i = 0; $i <= $quiz->feedbackboundarycount; $i++) {
|
||||
$feedback = new stdClass();
|
||||
@@ -1228,10 +1228,10 @@ function quiz_after_add_or_update($quiz) {
|
||||
$feedback->id = $DB->insert_record('quiz_feedback', $feedback);
|
||||
$feedbacktext = file_save_draft_area_files((int)$quiz->feedbacktext[$i]['itemid'],
|
||||
$context->id, 'mod_quiz', 'feedback', $feedback->id,
|
||||
array('subdirs' => false, 'maxfiles' => -1, 'maxbytes' => 0),
|
||||
['subdirs' => false, 'maxfiles' => -1, 'maxbytes' => 0],
|
||||
$quiz->feedbacktext[$i]['text']);
|
||||
$DB->set_field('quiz_feedback', 'feedbacktext', $feedbacktext,
|
||||
array('id' => $feedback->id));
|
||||
['id' => $feedback->id]);
|
||||
}
|
||||
|
||||
// Store any settings belonging to the access rules.
|
||||
@@ -1259,8 +1259,8 @@ function quiz_update_events($quiz, $override = null) {
|
||||
global $DB;
|
||||
|
||||
// Load the old events relating to this quiz.
|
||||
$conds = array('modulename'=>'quiz',
|
||||
'instance'=>$quiz->id);
|
||||
$conds = ['modulename'=>'quiz',
|
||||
'instance'=>$quiz->id];
|
||||
if (!empty($override)) {
|
||||
// Only load events for this override.
|
||||
if (isset($override->userid)) {
|
||||
@@ -1274,7 +1274,7 @@ function quiz_update_events($quiz, $override = null) {
|
||||
// Now make a to-do list of all that needs to be updated.
|
||||
if (empty($override)) {
|
||||
// We are updating the primary settings for the quiz, so we need to add all the overrides.
|
||||
$overrides = $DB->get_records('quiz_overrides', array('quiz' => $quiz->id), 'id ASC');
|
||||
$overrides = $DB->get_records('quiz_overrides', ['quiz' => $quiz->id], 'id ASC');
|
||||
// It is necessary to add an empty stdClass to the beginning of the array as the $oldevents
|
||||
// list contains the original (non-override) event for the module. If this is not included
|
||||
// the logic below will end up updating the wrong row when we try to reconcile this $overrides
|
||||
@@ -1282,7 +1282,7 @@ function quiz_update_events($quiz, $override = null) {
|
||||
array_unshift($overrides, new stdClass());
|
||||
} else {
|
||||
// Just do the one override.
|
||||
$overrides = array($override);
|
||||
$overrides = [$override];
|
||||
}
|
||||
|
||||
// Get group override priorities.
|
||||
@@ -1456,7 +1456,7 @@ function quiz_get_group_override_priorities($quizid) {
|
||||
* @return array
|
||||
*/
|
||||
function quiz_get_view_actions() {
|
||||
return array('view', 'view all', 'report', 'review');
|
||||
return ['view', 'view all', 'report', 'review'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1470,8 +1470,8 @@ function quiz_get_view_actions() {
|
||||
* @return array
|
||||
*/
|
||||
function quiz_get_post_actions() {
|
||||
return array('attempt', 'close attempt', 'preview', 'editquestions',
|
||||
'delete attempt', 'manualgrade');
|
||||
return ['attempt', 'close attempt', 'preview', 'editquestions',
|
||||
'delete attempt', 'manualgrade'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1517,9 +1517,9 @@ function quiz_reset_course_form_definition($mform) {
|
||||
* @return array the defaults.
|
||||
*/
|
||||
function quiz_reset_course_form_defaults($course) {
|
||||
return array('reset_quiz_attempts' => 1,
|
||||
return ['reset_quiz_attempts' => 1,
|
||||
'reset_quiz_group_overrides' => 1,
|
||||
'reset_quiz_user_overrides' => 1);
|
||||
'reset_quiz_user_overrides' => 1];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1536,7 +1536,7 @@ function quiz_reset_gradebook($courseid, $type='') {
|
||||
FROM {modules} m
|
||||
JOIN {course_modules} cm ON m.id = cm.module
|
||||
JOIN {quiz} q ON cm.instance = q.id
|
||||
WHERE m.name = 'quiz' AND cm.course = ?", array($courseid));
|
||||
WHERE m.name = 'quiz' AND cm.course = ?", [$courseid]);
|
||||
|
||||
foreach ($quizzes as $quiz) {
|
||||
quiz_grade_item_update($quiz, 'reset');
|
||||
@@ -1558,32 +1558,32 @@ function quiz_reset_userdata($data) {
|
||||
require_once($CFG->libdir . '/questionlib.php');
|
||||
|
||||
$componentstr = get_string('modulenameplural', 'quiz');
|
||||
$status = array();
|
||||
$status = [];
|
||||
|
||||
// Delete attempts.
|
||||
if (!empty($data->reset_quiz_attempts)) {
|
||||
question_engine::delete_questions_usage_by_activities(new qubaid_join(
|
||||
'{quiz_attempts} quiza JOIN {quiz} quiz ON quiza.quiz = quiz.id',
|
||||
'quiza.uniqueid', 'quiz.course = :quizcourseid',
|
||||
array('quizcourseid' => $data->courseid)));
|
||||
['quizcourseid' => $data->courseid]));
|
||||
|
||||
$DB->delete_records_select('quiz_attempts',
|
||||
'quiz IN (SELECT id FROM {quiz} WHERE course = ?)', array($data->courseid));
|
||||
$status[] = array(
|
||||
'quiz IN (SELECT id FROM {quiz} WHERE course = ?)', [$data->courseid]);
|
||||
$status[] = [
|
||||
'component' => $componentstr,
|
||||
'item' => get_string('attemptsdeleted', 'quiz'),
|
||||
'error' => false);
|
||||
'error' => false];
|
||||
|
||||
// Remove all grades from gradebook.
|
||||
$DB->delete_records_select('quiz_grades',
|
||||
'quiz IN (SELECT id FROM {quiz} WHERE course = ?)', array($data->courseid));
|
||||
'quiz IN (SELECT id FROM {quiz} WHERE course = ?)', [$data->courseid]);
|
||||
if (empty($data->reset_gradebook_grades)) {
|
||||
quiz_reset_gradebook($data->courseid);
|
||||
}
|
||||
$status[] = array(
|
||||
$status[] = [
|
||||
'component' => $componentstr,
|
||||
'item' => get_string('gradesdeleted', 'quiz'),
|
||||
'error' => false);
|
||||
'error' => false];
|
||||
}
|
||||
|
||||
$purgeoverrides = false;
|
||||
@@ -1591,21 +1591,21 @@ function quiz_reset_userdata($data) {
|
||||
// Remove user overrides.
|
||||
if (!empty($data->reset_quiz_user_overrides)) {
|
||||
$DB->delete_records_select('quiz_overrides',
|
||||
'quiz IN (SELECT id FROM {quiz} WHERE course = ?) AND userid IS NOT NULL', array($data->courseid));
|
||||
$status[] = array(
|
||||
'quiz IN (SELECT id FROM {quiz} WHERE course = ?) AND userid IS NOT NULL', [$data->courseid]);
|
||||
$status[] = [
|
||||
'component' => $componentstr,
|
||||
'item' => get_string('useroverridesdeleted', 'quiz'),
|
||||
'error' => false);
|
||||
'error' => false];
|
||||
$purgeoverrides = true;
|
||||
}
|
||||
// Remove group overrides.
|
||||
if (!empty($data->reset_quiz_group_overrides)) {
|
||||
$DB->delete_records_select('quiz_overrides',
|
||||
'quiz IN (SELECT id FROM {quiz} WHERE course = ?) AND groupid IS NOT NULL', array($data->courseid));
|
||||
$status[] = array(
|
||||
'quiz IN (SELECT id FROM {quiz} WHERE course = ?) AND groupid IS NOT NULL', [$data->courseid]);
|
||||
$status[] = [
|
||||
'component' => $componentstr,
|
||||
'item' => get_string('groupoverridesdeleted', 'quiz'),
|
||||
'error' => false);
|
||||
'error' => false];
|
||||
$purgeoverrides = true;
|
||||
}
|
||||
|
||||
@@ -1614,23 +1614,23 @@ function quiz_reset_userdata($data) {
|
||||
$DB->execute("UPDATE {quiz_overrides}
|
||||
SET timeopen = timeopen + ?
|
||||
WHERE quiz IN (SELECT id FROM {quiz} WHERE course = ?)
|
||||
AND timeopen <> 0", array($data->timeshift, $data->courseid));
|
||||
AND timeopen <> 0", [$data->timeshift, $data->courseid]);
|
||||
$DB->execute("UPDATE {quiz_overrides}
|
||||
SET timeclose = timeclose + ?
|
||||
WHERE quiz IN (SELECT id FROM {quiz} WHERE course = ?)
|
||||
AND timeclose <> 0", array($data->timeshift, $data->courseid));
|
||||
AND timeclose <> 0", [$data->timeshift, $data->courseid]);
|
||||
|
||||
$purgeoverrides = true;
|
||||
|
||||
// Any changes to the list of dates that needs to be rolled should be same during course restore and course reset.
|
||||
// See MDL-9367.
|
||||
shift_course_mod_dates('quiz', array('timeopen', 'timeclose'),
|
||||
shift_course_mod_dates('quiz', ['timeopen', 'timeclose'],
|
||||
$data->timeshift, $data->courseid);
|
||||
|
||||
$status[] = array(
|
||||
$status[] = [
|
||||
'component' => $componentstr,
|
||||
'item' => get_string('openclosedatesupdated', 'quiz'),
|
||||
'error' => false);
|
||||
'error' => false];
|
||||
}
|
||||
|
||||
if ($purgeoverrides) {
|
||||
@@ -1656,7 +1656,7 @@ function quiz_reset_userdata($data) {
|
||||
*/
|
||||
function quiz_num_attempt_summary($quiz, $cm, $returnzero = false, $currentgroup = 0) {
|
||||
global $DB, $USER;
|
||||
$numattempts = $DB->count_records('quiz_attempts', array('quiz'=> $quiz->id, 'preview'=>0));
|
||||
$numattempts = $DB->count_records('quiz_attempts', ['quiz'=> $quiz->id, 'preview'=>0]);
|
||||
if ($numattempts || $returnzero) {
|
||||
if (groups_get_activity_groupmode($cm)) {
|
||||
$a = new stdClass();
|
||||
@@ -1666,7 +1666,7 @@ function quiz_num_attempt_summary($quiz, $cm, $returnzero = false, $currentgroup
|
||||
'{quiz_attempts} qa JOIN ' .
|
||||
'{groups_members} gm ON qa.userid = gm.userid ' .
|
||||
'WHERE quiz = ? AND preview = 0 AND groupid = ?',
|
||||
array($quiz->id, $currentgroup));
|
||||
[$quiz->id, $currentgroup]);
|
||||
return get_string('attemptsnumthisgroup', 'quiz', $a);
|
||||
} else if ($groups = groups_get_all_groups($cm->course, $USER->id, $cm->groupingid)) {
|
||||
list($usql, $params) = $DB->get_in_or_equal(array_keys($groups));
|
||||
@@ -1674,7 +1674,7 @@ function quiz_num_attempt_summary($quiz, $cm, $returnzero = false, $currentgroup
|
||||
'{quiz_attempts} qa JOIN ' .
|
||||
'{groups_members} gm ON qa.userid = gm.userid ' .
|
||||
'WHERE quiz = ? AND preview = 0 AND ' .
|
||||
"groupid $usql", array_merge(array($quiz->id), $params));
|
||||
"groupid $usql", array_merge([$quiz->id], $params));
|
||||
return get_string('attemptsnumyourgroups', 'quiz', $a);
|
||||
}
|
||||
}
|
||||
@@ -1775,14 +1775,14 @@ function quiz_extend_settings_navigation(settings_navigation $settings, navigati
|
||||
|
||||
if (has_capability('mod/quiz:manage', $settings->get_page()->cm->context)) {
|
||||
$node = navigation_node::create(get_string('questions', 'quiz'),
|
||||
new moodle_url('/mod/quiz/edit.php', array('cmid' => $settings->get_page()->cm->id)),
|
||||
new moodle_url('/mod/quiz/edit.php', ['cmid' => $settings->get_page()->cm->id]),
|
||||
navigation_node::TYPE_SETTING, null, 'mod_quiz_edit', new pix_icon('t/edit', ''));
|
||||
$quiznode->add_node($node, $beforekey);
|
||||
}
|
||||
|
||||
if (has_capability('mod/quiz:preview', $settings->get_page()->cm->context)) {
|
||||
$url = new moodle_url('/mod/quiz/startattempt.php',
|
||||
array('cmid' => $settings->get_page()->cm->id, 'sesskey' => sesskey()));
|
||||
['cmid' => $settings->get_page()->cm->id, 'sesskey' => sesskey()]);
|
||||
$node = navigation_node::create(get_string('preview', 'quiz'), $url,
|
||||
navigation_node::TYPE_SETTING, null, 'mod_quiz_preview',
|
||||
new pix_icon('i/preview', ''));
|
||||
@@ -1792,12 +1792,12 @@ function quiz_extend_settings_navigation(settings_navigation $settings, navigati
|
||||
|
||||
question_extend_settings_navigation($quiznode, $settings->get_page()->cm->context)->trim_if_empty();
|
||||
|
||||
if (has_any_capability(array('mod/quiz:viewreports', 'mod/quiz:grade'), $settings->get_page()->cm->context)) {
|
||||
if (has_any_capability(['mod/quiz:viewreports', 'mod/quiz:grade'], $settings->get_page()->cm->context)) {
|
||||
require_once($CFG->dirroot . '/mod/quiz/report/reportlib.php');
|
||||
$reportlist = quiz_report_list($settings->get_page()->cm->context);
|
||||
|
||||
$url = new moodle_url('/mod/quiz/report.php',
|
||||
array('id' => $settings->get_page()->cm->id, 'mode' => reset($reportlist)));
|
||||
['id' => $settings->get_page()->cm->id, 'mode' => reset($reportlist)]);
|
||||
$reportnode = $quiznode->add_node(navigation_node::create(get_string('results', 'quiz'), $url,
|
||||
navigation_node::TYPE_SETTING,
|
||||
null, 'quiz_report', new pix_icon('i/report', '')));
|
||||
@@ -1825,7 +1825,7 @@ function quiz_extend_settings_navigation(settings_navigation $settings, navigati
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool false if file not found, does not return if found - justsend the file
|
||||
*/
|
||||
function quiz_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
|
||||
function quiz_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options= []) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($context->contextlevel != CONTEXT_MODULE) {
|
||||
@@ -1834,18 +1834,18 @@ function quiz_pluginfile($course, $cm, $context, $filearea, $args, $forcedownloa
|
||||
|
||||
require_login($course, false, $cm);
|
||||
|
||||
if (!$quiz = $DB->get_record('quiz', array('id'=>$cm->instance))) {
|
||||
if (!$quiz = $DB->get_record('quiz', ['id'=>$cm->instance])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The 'intro' area is served by pluginfile.php.
|
||||
$fileareas = array('feedback');
|
||||
$fileareas = ['feedback'];
|
||||
if (!in_array($filearea, $fileareas)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$feedbackid = (int)array_shift($args);
|
||||
if (!$feedback = $DB->get_record('quiz_feedback', array('id'=>$feedbackid))) {
|
||||
if (!$feedback = $DB->get_record('quiz_feedback', ['id'=>$feedbackid])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1876,7 +1876,7 @@ function quiz_pluginfile($course, $cm, $context, $filearea, $args, $forcedownloa
|
||||
* @return bool false if file not found, does not return if found - justsend the file
|
||||
*/
|
||||
function quiz_question_pluginfile($course, $context, $component,
|
||||
$filearea, $qubaid, $slot, $args, $forcedownload, array $options=array()) {
|
||||
$filearea, $qubaid, $slot, $args, $forcedownload, array $options= []) {
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
||||
|
||||
@@ -1918,7 +1918,7 @@ function quiz_question_pluginfile($course, $context, $component,
|
||||
* @param stdClass $currentcontext Current context of block
|
||||
*/
|
||||
function quiz_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
$module_pagetype = array(
|
||||
$module_pagetype = [
|
||||
'mod-quiz-*' => get_string('page-mod-quiz-x', 'quiz'),
|
||||
'mod-quiz-view' => get_string('page-mod-quiz-view', 'quiz'),
|
||||
'mod-quiz-attempt' => get_string('page-mod-quiz-attempt', 'quiz'),
|
||||
@@ -1926,7 +1926,7 @@ function quiz_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
'mod-quiz-review' => get_string('page-mod-quiz-review', 'quiz'),
|
||||
'mod-quiz-edit' => get_string('page-mod-quiz-edit', 'quiz'),
|
||||
'mod-quiz-report' => get_string('page-mod-quiz-report', 'quiz'),
|
||||
);
|
||||
];
|
||||
return $module_pagetype;
|
||||
}
|
||||
|
||||
@@ -1934,10 +1934,10 @@ function quiz_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
* @return the options for quiz navigation.
|
||||
*/
|
||||
function quiz_get_navigation_options() {
|
||||
return array(
|
||||
return [
|
||||
QUIZ_NAVMETHOD_FREE => get_string('navmethod_free', 'quiz'),
|
||||
QUIZ_NAVMETHOD_SEQ => get_string('navmethod_seq', 'quiz')
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1949,14 +1949,14 @@ function quiz_get_navigation_options() {
|
||||
* @return stdClass an object with the different type of areas indicating if they were updated or not
|
||||
* @since Moodle 3.2
|
||||
*/
|
||||
function quiz_check_updates_since(cm_info $cm, $from, $filter = array()) {
|
||||
function quiz_check_updates_since(cm_info $cm, $from, $filter = []) {
|
||||
global $DB, $USER, $CFG;
|
||||
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
||||
|
||||
$updates = course_check_module_updates_since($cm, $from, array(), $filter);
|
||||
$updates = course_check_module_updates_since($cm, $from, [], $filter);
|
||||
|
||||
// Check if questions were updated.
|
||||
$updates->questions = (object) array('updated' => false);
|
||||
$updates->questions = (object) ['updated' => false];
|
||||
$quizobj = quiz_settings::create($cm->instance, $USER->id);
|
||||
$quizobj->preload_questions();
|
||||
$quizobj->load_questions();
|
||||
@@ -1974,10 +1974,10 @@ function quiz_check_updates_since(cm_info $cm, $from, $filter = array()) {
|
||||
}
|
||||
|
||||
// Check for new attempts or grades.
|
||||
$updates->attempts = (object) array('updated' => false);
|
||||
$updates->grades = (object) array('updated' => false);
|
||||
$updates->attempts = (object) ['updated' => false];
|
||||
$updates->grades = (object) ['updated' => false];
|
||||
$select = 'quiz = ? AND userid = ? AND timemodified > ?';
|
||||
$params = array($cm->instance, $USER->id, $from);
|
||||
$params = [$cm->instance, $USER->id, $from];
|
||||
|
||||
$attempts = $DB->get_records_select('quiz_attempts', $select, $params, '', 'id');
|
||||
if (!empty($attempts)) {
|
||||
@@ -1993,7 +1993,7 @@ function quiz_check_updates_since(cm_info $cm, $from, $filter = array()) {
|
||||
// Now, teachers should see other students updates.
|
||||
if (has_capability('mod/quiz:viewreports', $cm->context)) {
|
||||
$select = 'quiz = ? AND timemodified > ?';
|
||||
$params = array($cm->instance, $from);
|
||||
$params = [$cm->instance, $from];
|
||||
|
||||
if (groups_get_activity_groupmode($cm) == SEPARATEGROUPS) {
|
||||
$groupusers = array_keys(groups_get_activity_shared_group_members($cm));
|
||||
@@ -2005,14 +2005,14 @@ function quiz_check_updates_since(cm_info $cm, $from, $filter = array()) {
|
||||
$params = array_merge($params, $inparams);
|
||||
}
|
||||
|
||||
$updates->userattempts = (object) array('updated' => false);
|
||||
$updates->userattempts = (object) ['updated' => false];
|
||||
$attempts = $DB->get_records_select('quiz_attempts', $select, $params, '', 'id');
|
||||
if (!empty($attempts)) {
|
||||
$updates->userattempts->updated = true;
|
||||
$updates->userattempts->itemids = array_keys($attempts);
|
||||
}
|
||||
|
||||
$updates->usergrades = (object) array('updated' => false);
|
||||
$updates->usergrades = (object) ['updated' => false];
|
||||
$grades = $DB->get_records_select('quiz_grades', $select, $params, '', 'id');
|
||||
if (!empty($grades)) {
|
||||
$updates->usergrades->updated = true;
|
||||
@@ -2384,7 +2384,7 @@ function mod_quiz_core_calendar_event_timestart_updated(\calendar_event $event,
|
||||
$DB->update_record('quiz', $quiz);
|
||||
|
||||
if ($closedatechanged) {
|
||||
quiz_update_open_attempts(array('quizid' => $quiz->id));
|
||||
quiz_update_open_attempts(['quizid' => $quiz->id]);
|
||||
}
|
||||
|
||||
// Delete any previous preview attempts.
|
||||
@@ -2424,7 +2424,7 @@ function mod_quiz_output_fragment_quiz_question_bank($args) {
|
||||
question_build_edit_resources('editq', '/mod/quiz/edit.php', $params, custom_view::DEFAULT_PAGE_SIZE);
|
||||
|
||||
// Get the course object and related bits.
|
||||
$course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', ['id' => $quiz->course], '*', MUST_EXIST);
|
||||
require_capability('mod/quiz:manage', $contexts->lowest());
|
||||
|
||||
// Create quiz question bank view.
|
||||
|
||||
+90
-90
@@ -99,8 +99,8 @@ function quiz_create_attempt(quiz_settings $quizobj, $attemptnumber, $lastattemp
|
||||
$quiz = $quizobj->get_quiz();
|
||||
if ($quiz->sumgrades < 0.000005 && $quiz->grade > 0.000005) {
|
||||
throw new moodle_exception('cannotstartgradesmismatch', 'quiz',
|
||||
new moodle_url('/mod/quiz/view.php', array('q' => $quiz->id)),
|
||||
array('grade' => quiz_format_grade($quiz, $quiz->grade)));
|
||||
new moodle_url('/mod/quiz/view.php', ['q' => $quiz->id]),
|
||||
['grade' => quiz_format_grade($quiz, $quiz->grade)]);
|
||||
}
|
||||
|
||||
if ($attemptnumber == 1 || !$quiz->attemptonlast) {
|
||||
@@ -158,7 +158,7 @@ function quiz_create_attempt(quiz_settings $quizobj, $attemptnumber, $lastattemp
|
||||
* @return stdClass modified attempt object
|
||||
*/
|
||||
function quiz_start_new_attempt($quizobj, $quba, $attempt, $attemptnumber, $timenow,
|
||||
$questionids = array(), $forcedvariantsbyslot = array()) {
|
||||
$questionids = [], $forcedvariantsbyslot = []) {
|
||||
|
||||
// Usages for this user's previous quiz attempts.
|
||||
$qubaids = new \mod_quiz\question\qubaids_for_users_attempts(
|
||||
@@ -171,9 +171,9 @@ function quiz_start_new_attempt($quizobj, $quba, $attempt, $attemptnumber, $time
|
||||
// First load all the non-random questions.
|
||||
$randomfound = false;
|
||||
$slot = 0;
|
||||
$questions = array();
|
||||
$maxmark = array();
|
||||
$page = array();
|
||||
$questions = [];
|
||||
$maxmark = [];
|
||||
$page = [];
|
||||
foreach ($quizobj->get_questions() as $questiondata) {
|
||||
$slot += 1;
|
||||
$maxmark[$slot] = $questiondata->maxmark;
|
||||
@@ -191,7 +191,7 @@ function quiz_start_new_attempt($quizobj, $quba, $attempt, $attemptnumber, $time
|
||||
// Then find a question to go in place of each random question.
|
||||
if ($randomfound) {
|
||||
$slot = 0;
|
||||
$usedquestionids = array();
|
||||
$usedquestionids = [];
|
||||
foreach ($questions as $question) {
|
||||
if ($question->id && isset($usedquestions[$question->id])) {
|
||||
$usedquestionids[$question->id] += 1;
|
||||
@@ -265,10 +265,10 @@ function quiz_start_new_attempt($quizobj, $quba, $attempt, $attemptnumber, $time
|
||||
}
|
||||
}
|
||||
|
||||
$layout = array();
|
||||
$layout = [];
|
||||
foreach ($sections as $section) {
|
||||
if ($section->shufflequestions) {
|
||||
$questionsinthissection = array();
|
||||
$questionsinthissection = [];
|
||||
for ($slot = $section->firstslot; $slot <= $section->lastslot; $slot += 1) {
|
||||
$questionsinthissection[] = $slot;
|
||||
}
|
||||
@@ -314,7 +314,7 @@ function quiz_start_new_attempt($quizobj, $quba, $attempt, $attemptnumber, $time
|
||||
function quiz_start_attempt_built_on_last($quba, $attempt, $lastattempt) {
|
||||
$oldquba = question_engine::load_questions_usage_by_activity($lastattempt->uniqueid);
|
||||
|
||||
$oldnumberstonew = array();
|
||||
$oldnumberstonew = [];
|
||||
foreach ($oldquba->get_attempt_iterator() as $oldslot => $oldqa) {
|
||||
$newslot = $quba->add_question($oldqa->get_question(false), $oldqa->get_max_mark());
|
||||
|
||||
@@ -324,7 +324,7 @@ function quiz_start_attempt_built_on_last($quba, $attempt, $lastattempt) {
|
||||
}
|
||||
|
||||
// Update attempt layout.
|
||||
$newlayout = array();
|
||||
$newlayout = [];
|
||||
foreach (explode(',', $lastattempt->layout) as $oldslot) {
|
||||
if ($oldslot != 0) {
|
||||
$newlayout[] = $oldnumberstonew[$oldslot];
|
||||
@@ -352,17 +352,17 @@ function quiz_attempt_save_started($quizobj, $quba, $attempt) {
|
||||
$attempt->id = $DB->insert_record('quiz_attempts', $attempt);
|
||||
|
||||
// Params used by the events below.
|
||||
$params = array(
|
||||
$params = [
|
||||
'objectid' => $attempt->id,
|
||||
'relateduserid' => $attempt->userid,
|
||||
'courseid' => $quizobj->get_courseid(),
|
||||
'context' => $quizobj->get_context()
|
||||
);
|
||||
];
|
||||
// Decide which event we are using.
|
||||
if ($attempt->preview) {
|
||||
$params['other'] = array(
|
||||
$params['other'] = [
|
||||
'quizid' => $quizobj->get_quizid()
|
||||
);
|
||||
];
|
||||
$event = \mod_quiz\event\attempt_preview_started::create($params);
|
||||
} else {
|
||||
$event = \mod_quiz\event\attempt_started::create($params);
|
||||
@@ -404,7 +404,7 @@ function quiz_get_user_attempt_unfinished($quizid, $userid) {
|
||||
function quiz_delete_attempt($attempt, $quiz) {
|
||||
global $DB;
|
||||
if (is_numeric($attempt)) {
|
||||
if (!$attempt = $DB->get_record('quiz_attempts', array('id' => $attempt))) {
|
||||
if (!$attempt = $DB->get_record('quiz_attempts', ['id' => $attempt])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -421,18 +421,18 @@ function quiz_delete_attempt($attempt, $quiz) {
|
||||
}
|
||||
|
||||
question_engine::delete_questions_usage_by_activity($attempt->uniqueid);
|
||||
$DB->delete_records('quiz_attempts', array('id' => $attempt->id));
|
||||
$DB->delete_records('quiz_attempts', ['id' => $attempt->id]);
|
||||
|
||||
// Log the deletion of the attempt if not a preview.
|
||||
if (!$attempt->preview) {
|
||||
$params = array(
|
||||
$params = [
|
||||
'objectid' => $attempt->id,
|
||||
'relateduserid' => $attempt->userid,
|
||||
'context' => context_module::instance($quiz->cmid),
|
||||
'other' => array(
|
||||
'other' => [
|
||||
'quizid' => $quiz->id
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
$event = \mod_quiz\event\attempt_deleted::create($params);
|
||||
$event->add_record_snapshot('quiz_attempts', $attempt);
|
||||
$event->trigger();
|
||||
@@ -442,8 +442,8 @@ function quiz_delete_attempt($attempt, $quiz) {
|
||||
// If none, then delete record for this quiz, this user from quiz_grades
|
||||
// else recalculate best grade.
|
||||
$userid = $attempt->userid;
|
||||
if (!$DB->record_exists('quiz_attempts', array('userid' => $userid, 'quiz' => $quiz->id))) {
|
||||
$DB->delete_records('quiz_grades', array('userid' => $userid, 'quiz' => $quiz->id));
|
||||
if (!$DB->record_exists('quiz_attempts', ['userid' => $userid, 'quiz' => $quiz->id])) {
|
||||
$DB->delete_records('quiz_grades', ['userid' => $userid, 'quiz' => $quiz->id]);
|
||||
} else {
|
||||
quiz_save_best_grade($quiz, $userid);
|
||||
}
|
||||
@@ -459,7 +459,7 @@ function quiz_delete_attempt($attempt, $quiz) {
|
||||
*/
|
||||
function quiz_delete_previews($quiz, $userid = null) {
|
||||
global $DB;
|
||||
$conditions = array('quiz' => $quiz->id, 'preview' => 1);
|
||||
$conditions = ['quiz' => $quiz->id, 'preview' => 1];
|
||||
if (!empty($userid)) {
|
||||
$conditions['userid'] = $userid;
|
||||
}
|
||||
@@ -475,7 +475,7 @@ function quiz_delete_previews($quiz, $userid = null) {
|
||||
*/
|
||||
function quiz_has_attempts($quizid) {
|
||||
global $DB;
|
||||
return $DB->record_exists('quiz_attempts', array('quiz' => $quizid, 'preview' => 0));
|
||||
return $DB->record_exists('quiz_attempts', ['quiz' => $quizid, 'preview' => 0]);
|
||||
}
|
||||
|
||||
// Functions to do with quiz layout and pages //////////////////////////////////
|
||||
@@ -489,8 +489,8 @@ function quiz_repaginate_questions($quizid, $slotsperpage) {
|
||||
global $DB;
|
||||
$trans = $DB->start_delegated_transaction();
|
||||
|
||||
$sections = $DB->get_records('quiz_sections', array('quizid' => $quizid), 'firstslot ASC');
|
||||
$firstslots = array();
|
||||
$sections = $DB->get_records('quiz_sections', ['quizid' => $quizid], 'firstslot ASC');
|
||||
$firstslots = [];
|
||||
foreach ($sections as $section) {
|
||||
if ((int)$section->firstslot === 1) {
|
||||
continue;
|
||||
@@ -498,7 +498,7 @@ function quiz_repaginate_questions($quizid, $slotsperpage) {
|
||||
$firstslots[] = $section->firstslot;
|
||||
}
|
||||
|
||||
$slots = $DB->get_records('quiz_slots', array('quizid' => $quizid),
|
||||
$slots = $DB->get_records('quiz_slots', ['quizid' => $quizid],
|
||||
'slot');
|
||||
$currentpage = 1;
|
||||
$slotsonthispage = 0;
|
||||
@@ -509,7 +509,7 @@ function quiz_repaginate_questions($quizid, $slotsperpage) {
|
||||
$slotsonthispage = 0;
|
||||
}
|
||||
if ($slot->page != $currentpage) {
|
||||
$DB->set_field('quiz_slots', 'page', $currentpage, array('id' => $slot->id));
|
||||
$DB->set_field('quiz_slots', 'page', $currentpage, ['id' => $slot->id]);
|
||||
}
|
||||
$slotsonthispage += 1;
|
||||
}
|
||||
@@ -574,7 +574,7 @@ function quiz_feedback_record_for_grade($grade, $quiz) {
|
||||
$grade = max($grade, 0);
|
||||
|
||||
$feedback = $DB->get_record_select('quiz_feedback',
|
||||
'quizid = ? AND mingrade <= ? AND ? < maxgrade', array($quiz->id, $grade, $grade));
|
||||
'quizid = ? AND mingrade <= ? AND ? < maxgrade', [$quiz->id, $grade, $grade]);
|
||||
|
||||
return $feedback;
|
||||
}
|
||||
@@ -616,12 +616,12 @@ function quiz_feedback_for_grade($grade, $quiz, $context) {
|
||||
*/
|
||||
function quiz_has_feedback($quiz) {
|
||||
global $DB;
|
||||
static $cache = array();
|
||||
static $cache = [];
|
||||
if (!array_key_exists($quiz->id, $cache)) {
|
||||
$cache[$quiz->id] = quiz_has_grades($quiz) &&
|
||||
$DB->record_exists_select('quiz_feedback', "quizid = ? AND " .
|
||||
$DB->sql_isnotempty('quiz_feedback', 'feedbacktext', false, true),
|
||||
array($quiz->id));
|
||||
[$quiz->id]);
|
||||
}
|
||||
return $cache[$quiz->id];
|
||||
}
|
||||
@@ -645,8 +645,8 @@ function quiz_update_sumgrades($quiz) {
|
||||
WHERE quizid = {quiz}.id
|
||||
), 0)
|
||||
WHERE id = ?';
|
||||
$DB->execute($sql, array($quiz->id));
|
||||
$quiz->sumgrades = $DB->get_field('quiz', 'sumgrades', array('id' => $quiz->id));
|
||||
$DB->execute($sql, [$quiz->id]);
|
||||
$quiz->sumgrades = $DB->get_field('quiz', 'sumgrades', ['id' => $quiz->id]);
|
||||
|
||||
if ($quiz->sumgrades < 0.000005 && quiz_has_attempts($quiz->id)) {
|
||||
// If the quiz has been attempted, and the sumgrades has been
|
||||
@@ -673,8 +673,8 @@ function quiz_update_all_attempt_sumgrades($quiz) {
|
||||
{$dm->sum_usage_marks_subquery('uniqueid')}
|
||||
)
|
||||
WHERE quiz = :quizid AND state = :finishedstate";
|
||||
$DB->execute($sql, array('timenow' => $timenow, 'quizid' => $quiz->id,
|
||||
'finishedstate' => quiz_attempt::FINISHED));
|
||||
$DB->execute($sql, ['timenow' => $timenow, 'quizid' => $quiz->id,
|
||||
'finishedstate' => quiz_attempt::FINISHED]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -704,7 +704,7 @@ function quiz_set_grade($newgrade, $quiz) {
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
|
||||
// Update the quiz table.
|
||||
$DB->set_field('quiz', 'grade', $newgrade, array('id' => $quiz->instance));
|
||||
$DB->set_field('quiz', 'grade', $newgrade, ['id' => $quiz->instance]);
|
||||
|
||||
if ($oldgrade < 1) {
|
||||
// If the old grade was zero, we cannot rescale, we have to recompute.
|
||||
@@ -718,7 +718,7 @@ function quiz_set_grade($newgrade, $quiz) {
|
||||
UPDATE {quiz_grades}
|
||||
SET grade = ? * grade, timemodified = ?
|
||||
WHERE quiz = ?
|
||||
", array($newgrade/$oldgrade, $timemodified, $quiz->id));
|
||||
", [$newgrade/$oldgrade, $timemodified, $quiz->id]);
|
||||
}
|
||||
|
||||
if ($oldgrade > 1e-7) {
|
||||
@@ -728,7 +728,7 @@ function quiz_set_grade($newgrade, $quiz) {
|
||||
UPDATE {quiz_feedback}
|
||||
SET mingrade = ? * mingrade, maxgrade = ? * maxgrade
|
||||
WHERE quizid = ?
|
||||
", array($factor, $factor, $quiz->id));
|
||||
", [$factor, $factor, $quiz->id]);
|
||||
}
|
||||
|
||||
// Update grade item and send all grades to gradebook.
|
||||
@@ -762,7 +762,7 @@ function quiz_set_grade($newgrade, $quiz) {
|
||||
* avoid repeated querying.
|
||||
* @return bool Indicates success or failure.
|
||||
*/
|
||||
function quiz_save_best_grade($quiz, $userid = null, $attempts = array()) {
|
||||
function quiz_save_best_grade($quiz, $userid = null, $attempts = []) {
|
||||
global $DB, $OUTPUT, $USER;
|
||||
|
||||
if (empty($userid)) {
|
||||
@@ -780,10 +780,10 @@ function quiz_save_best_grade($quiz, $userid = null, $attempts = array()) {
|
||||
|
||||
// Save the best grade in the database.
|
||||
if (is_null($bestgrade)) {
|
||||
$DB->delete_records('quiz_grades', array('quiz' => $quiz->id, 'userid' => $userid));
|
||||
$DB->delete_records('quiz_grades', ['quiz' => $quiz->id, 'userid' => $userid]);
|
||||
|
||||
} else if ($grade = $DB->get_record('quiz_grades',
|
||||
array('quiz' => $quiz->id, 'userid' => $userid))) {
|
||||
['quiz' => $quiz->id, 'userid' => $userid])) {
|
||||
$grade->grade = $bestgrade;
|
||||
$grade->timemodified = time();
|
||||
$DB->update_record('quiz_grades', $grade);
|
||||
@@ -860,7 +860,7 @@ function quiz_update_all_final_grades($quiz) {
|
||||
return;
|
||||
}
|
||||
|
||||
$param = array('iquizid' => $quiz->id, 'istatefinished' => quiz_attempt::FINISHED);
|
||||
$param = ['iquizid' => $quiz->id, 'istatefinished' => quiz_attempt::FINISHED];
|
||||
$firstlastattemptjoin = "JOIN (
|
||||
SELECT
|
||||
iquiza.userid,
|
||||
@@ -963,7 +963,7 @@ function quiz_update_all_final_grades($quiz) {
|
||||
$param);
|
||||
|
||||
$timenow = time();
|
||||
$todelete = array();
|
||||
$todelete = [];
|
||||
foreach ($changedgrades as $changedgrade) {
|
||||
|
||||
if (is_null($changedgrade->newgrade)) {
|
||||
@@ -989,7 +989,7 @@ function quiz_update_all_final_grades($quiz) {
|
||||
if (!empty($todelete)) {
|
||||
list($test, $params) = $DB->get_in_or_equal($todelete);
|
||||
$DB->delete_records_select('quiz_grades', 'quiz = ? AND userid ' . $test,
|
||||
array_merge(array($quiz->id), $params));
|
||||
array_merge([$quiz->id], $params));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1075,13 +1075,13 @@ function quiz_update_open_attempts(array $conditions) {
|
||||
|
||||
foreach ($conditions as &$value) {
|
||||
if (!is_array($value)) {
|
||||
$value = array($value);
|
||||
$value = [$value];
|
||||
}
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$wheres = array("quiza.state IN ('inprogress', 'overdue')");
|
||||
$iwheres = array("iquiza.state IN ('inprogress', 'overdue')");
|
||||
$params = [];
|
||||
$wheres = ["quiza.state IN ('inprogress', 'overdue')"];
|
||||
$iwheres = ["iquiza.state IN ('inprogress', 'overdue')"];
|
||||
|
||||
if (isset($conditions['courseid'])) {
|
||||
list ($incond, $inparams) = $DB->get_in_or_equal($conditions['courseid'], SQL_PARAMS_NAMED, 'cid');
|
||||
@@ -1257,12 +1257,12 @@ function quiz_calculate_best_attempt($quiz, $attempts) {
|
||||
* from the individual attempt grades.
|
||||
*/
|
||||
function quiz_get_grading_options() {
|
||||
return array(
|
||||
return [
|
||||
QUIZ_GRADEHIGHEST => get_string('gradehighest', 'quiz'),
|
||||
QUIZ_GRADEAVERAGE => get_string('gradeaverage', 'quiz'),
|
||||
QUIZ_ATTEMPTFIRST => get_string('attemptfirst', 'quiz'),
|
||||
QUIZ_ATTEMPTLAST => get_string('attemptlast', 'quiz')
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1280,11 +1280,11 @@ function quiz_get_grading_option_name($option) {
|
||||
* attempts.
|
||||
*/
|
||||
function quiz_get_overdue_handling_options() {
|
||||
return array(
|
||||
return [
|
||||
'autosubmit' => get_string('overduehandlingautosubmit', 'quiz'),
|
||||
'graceperiod' => get_string('overduehandlinggraceperiod', 'quiz'),
|
||||
'autoabandon' => get_string('overduehandlingautoabandon', 'quiz'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1292,11 +1292,11 @@ function quiz_get_overdue_handling_options() {
|
||||
* @return array string => lang string the options for whether to display the user's picture.
|
||||
*/
|
||||
function quiz_get_user_image_options() {
|
||||
return array(
|
||||
return [
|
||||
QUIZ_SHOWIMAGE_NONE => get_string('shownoimage', 'quiz'),
|
||||
QUIZ_SHOWIMAGE_SMALL => get_string('showsmallimage', 'quiz'),
|
||||
QUIZ_SHOWIMAGE_LARGE => get_string('showlargeimage', 'quiz'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1315,7 +1315,7 @@ function quiz_get_user_timeclose($courseid) {
|
||||
FROM {quiz} quiz
|
||||
WHERE quiz.course = :courseid";
|
||||
|
||||
$results = $DB->get_records_sql($sql, array('courseid' => $courseid));
|
||||
$results = $DB->get_records_sql($sql, ['courseid' => $courseid]);
|
||||
return $results;
|
||||
}
|
||||
|
||||
@@ -1332,7 +1332,7 @@ function quiz_get_user_timeclose($courseid) {
|
||||
GROUP BY quiz.id) v
|
||||
JOIN {quiz} q ON q.id = v.quizid";
|
||||
|
||||
$results = $DB->get_records_sql($sql, array('userid' => $USER->id, 'useringroupid' => $USER->id, 'courseid' => $courseid));
|
||||
$results = $DB->get_records_sql($sql, ['userid' => $USER->id, 'useringroupid' => $USER->id, 'courseid' => $courseid]);
|
||||
return $results;
|
||||
|
||||
}
|
||||
@@ -1342,7 +1342,7 @@ function quiz_get_user_timeclose($courseid) {
|
||||
* @return array int => string.
|
||||
*/
|
||||
function quiz_questions_per_page_options() {
|
||||
$pageoptions = array();
|
||||
$pageoptions = [];
|
||||
$pageoptions[0] = get_string('neverallononepage', 'quiz');
|
||||
$pageoptions[1] = get_string('everyquestion', 'quiz');
|
||||
for ($i = 2; $i <= QUIZ_MAX_QPP_OPTION; ++$i) {
|
||||
@@ -1429,7 +1429,7 @@ function quiz_question_edit_button($cmid, $question, $returnurl, $contentafteric
|
||||
if ($returnurl instanceof moodle_url) {
|
||||
$returnurl = $returnurl->out_as_local_url(false);
|
||||
}
|
||||
$questionparams = array('returnurl' => $returnurl, 'cmid' => $cmid, 'id' => $question->id);
|
||||
$questionparams = ['returnurl' => $returnurl, 'cmid' => $cmid, 'id' => $question->id];
|
||||
$questionurl = new moodle_url("$CFG->wwwroot/question/bank/editquestion/question.php", $questionparams);
|
||||
return '<a title="' . $action . '" href="' . $questionurl->out() . '" class="questioneditbutton">' .
|
||||
$OUTPUT->pix_icon($icon, $action) . $contentaftericon .
|
||||
@@ -1530,7 +1530,7 @@ function quiz_get_review_options($quiz, $attempt, $context) {
|
||||
$options->flags = quiz_get_flag_option($attempt, $context);
|
||||
if (!empty($attempt->id)) {
|
||||
$options->questionreviewlink = new moodle_url('/mod/quiz/reviewquestion.php',
|
||||
array('attempt' => $attempt->id));
|
||||
['attempt' => $attempt->id]);
|
||||
}
|
||||
|
||||
// Show a link to the comment box only for closed attempts.
|
||||
@@ -1538,7 +1538,7 @@ function quiz_get_review_options($quiz, $attempt, $context) {
|
||||
!is_null($context) && has_capability('mod/quiz:grade', $context)) {
|
||||
$options->manualcomment = question_display_options::VISIBLE;
|
||||
$options->manualcommentlink = new moodle_url('/mod/quiz/comment.php',
|
||||
array('attempt' => $attempt->id));
|
||||
['attempt' => $attempt->id]);
|
||||
}
|
||||
|
||||
if (!is_null($context) && !$attempt->preview &&
|
||||
@@ -1577,7 +1577,7 @@ function quiz_get_review_options($quiz, $attempt, $context) {
|
||||
* for all attempts.
|
||||
*/
|
||||
function quiz_get_combined_reviewoptions($quiz, $attempts) {
|
||||
$fields = array('feedback', 'generalfeedback', 'rightanswer', 'overallfeedback');
|
||||
$fields = ['feedback', 'generalfeedback', 'rightanswer', 'overallfeedback'];
|
||||
$someoptions = new stdClass();
|
||||
$alloptions = new stdClass();
|
||||
foreach ($fields as $field) {
|
||||
@@ -1589,7 +1589,7 @@ function quiz_get_combined_reviewoptions($quiz, $attempts) {
|
||||
|
||||
// This shouldn't happen, but we need to prevent reveal information.
|
||||
if (empty($attempts)) {
|
||||
return array($someoptions, $someoptions);
|
||||
return [$someoptions, $someoptions];
|
||||
}
|
||||
|
||||
foreach ($attempts as $attempt) {
|
||||
@@ -1602,7 +1602,7 @@ function quiz_get_combined_reviewoptions($quiz, $attempts) {
|
||||
$someoptions->marks = max($someoptions->marks, $attemptoptions->marks);
|
||||
$alloptions->marks = min($alloptions->marks, $attemptoptions->marks);
|
||||
}
|
||||
return array($someoptions, $alloptions);
|
||||
return [$someoptions, $alloptions];
|
||||
}
|
||||
|
||||
// Functions for sending notification messages /////////////////////////////////
|
||||
@@ -1723,7 +1723,7 @@ function quiz_send_notification_messages($course, $quiz, $attempt, $context, $cm
|
||||
throw new coding_exception('$course, $quiz, $attempt, $context and $cm must all be set.');
|
||||
}
|
||||
|
||||
$submitter = $DB->get_record('user', array('id' => $attempt->userid), '*', MUST_EXIST);
|
||||
$submitter = $DB->get_record('user', ['id' => $attempt->userid], '*', MUST_EXIST);
|
||||
|
||||
// Check for confirmation required.
|
||||
$sendconfirm = false;
|
||||
@@ -1810,7 +1810,7 @@ function quiz_send_notification_messages($course, $quiz, $attempt, $context, $cm
|
||||
function quiz_send_overdue_message($attemptobj) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$submitter = $DB->get_record('user', array('id' => $attemptobj->get_userid()), '*', MUST_EXIST);
|
||||
$submitter = $DB->get_record('user', ['id' => $attemptobj->get_userid()], '*', MUST_EXIST);
|
||||
|
||||
if (!$attemptobj->has_capability('mod/quiz:emailwarnoverdue', $submitter->id, false)) {
|
||||
return; // Message not required.
|
||||
@@ -1824,7 +1824,7 @@ function quiz_send_overdue_message($attemptobj) {
|
||||
// the email message.
|
||||
$quizname = format_string($attemptobj->get_quiz_name());
|
||||
|
||||
$deadlines = array();
|
||||
$deadlines = [];
|
||||
if ($attemptobj->get_quiz()->timelimit) {
|
||||
$deadlines[] = $attemptobj->get_attempt()->timestart + $attemptobj->get_quiz()->timelimit;
|
||||
}
|
||||
@@ -1890,7 +1890,7 @@ function quiz_send_overdue_message($attemptobj) {
|
||||
function quiz_attempt_submitted_handler($event) {
|
||||
global $DB;
|
||||
|
||||
$course = $DB->get_record('course', array('id' => $event->courseid));
|
||||
$course = $DB->get_record('course', ['id' => $event->courseid]);
|
||||
$attempt = $event->get_record_snapshot('quiz_attempts', $event->objectid);
|
||||
$quiz = $event->get_record_snapshot('quiz', $attempt->quiz);
|
||||
$cm = get_coursemodule_from_id('quiz', $event->get_context()->instanceid, $event->courseid);
|
||||
@@ -1976,7 +1976,7 @@ function quiz_process_group_deleted_in_course($courseid) {
|
||||
WHERE quiz.course = :courseid
|
||||
AND o.groupid IS NOT NULL
|
||||
AND grp.id IS NULL";
|
||||
$params = array('courseid' => $courseid);
|
||||
$params = ['courseid' => $courseid];
|
||||
$records = $DB->get_records_sql($sql, $params);
|
||||
if (!$records) {
|
||||
return; // Nothing to do.
|
||||
@@ -1996,19 +1996,19 @@ function quiz_process_group_deleted_in_course($courseid) {
|
||||
function quiz_get_js_module() {
|
||||
global $PAGE;
|
||||
|
||||
return array(
|
||||
return [
|
||||
'name' => 'mod_quiz',
|
||||
'fullpath' => '/mod/quiz/module.js',
|
||||
'requires' => array('base', 'dom', 'event-delegate', 'event-key',
|
||||
'core_question_engine'),
|
||||
'strings' => array(
|
||||
array('cancel', 'moodle'),
|
||||
array('flagged', 'question'),
|
||||
array('functiondisabledbysecuremode', 'quiz'),
|
||||
array('startattempt', 'quiz'),
|
||||
array('timesup', 'quiz'),
|
||||
),
|
||||
);
|
||||
'requires' => ['base', 'dom', 'event-delegate', 'event-key',
|
||||
'core_question_engine'],
|
||||
'strings' => [
|
||||
['cancel', 'moodle'],
|
||||
['flagged', 'question'],
|
||||
['functiondisabledbysecuremode', 'quiz'],
|
||||
['startattempt', 'quiz'],
|
||||
['timesup', 'quiz'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -2058,7 +2058,7 @@ function quiz_question_tostring($question, $showicon = false, $showquestiontext
|
||||
// Question text.
|
||||
if ($showquestiontext) {
|
||||
$questiontext = question_utils::to_plain_text($question->questiontext,
|
||||
$question->questiontextformat, array('noclean' => true, 'para' => false));
|
||||
$question->questiontextformat, ['noclean' => true, 'para' => false]);
|
||||
$questiontext = shorten_text($questiontext, 50);
|
||||
if ($questiontext) {
|
||||
$result .= ' ' . html_writer::span(s($questiontext), 'questiontext');
|
||||
@@ -2075,7 +2075,7 @@ function quiz_question_tostring($question, $showicon = false, $showquestiontext
|
||||
*/
|
||||
function quiz_require_question_use($questionid) {
|
||||
global $DB;
|
||||
$question = $DB->get_record('question', array('id' => $questionid), '*', MUST_EXIST);
|
||||
$question = $DB->get_record('question', ['id' => $questionid], '*', MUST_EXIST);
|
||||
question_require_capability_on($question, 'use');
|
||||
}
|
||||
|
||||
@@ -2102,7 +2102,7 @@ function quiz_add_quiz_question($questionid, $quiz, $page = 0, $maxmark = null)
|
||||
}
|
||||
|
||||
// Make sue the question is not of the "random" type.
|
||||
$questiontype = $DB->get_field('question', 'qtype', array('id' => $questionid));
|
||||
$questiontype = $DB->get_field('question', 'qtype', ['id' => $questionid]);
|
||||
if ($questiontype == 'random') {
|
||||
throw new coding_exception(
|
||||
'Adding "random" questions via quiz_add_quiz_question() is deprecated. Please use quiz_add_random_questions().'
|
||||
@@ -2153,7 +2153,7 @@ function quiz_add_quiz_question($questionid, $quiz, $page = 0, $maxmark = null)
|
||||
if ($maxmark !== null) {
|
||||
$slot->maxmark = $maxmark;
|
||||
} else {
|
||||
$slot->maxmark = $DB->get_field('question', 'defaultmark', array('id' => $questionid));
|
||||
$slot->maxmark = $DB->get_field('question', 'defaultmark', ['id' => $questionid]);
|
||||
}
|
||||
|
||||
if (is_int($page) && $page >= 1) {
|
||||
@@ -2161,7 +2161,7 @@ function quiz_add_quiz_question($questionid, $quiz, $page = 0, $maxmark = null)
|
||||
$lastslotbefore = 0;
|
||||
foreach (array_reverse($slots) as $otherslot) {
|
||||
if ($otherslot->page > $page) {
|
||||
$DB->set_field('quiz_slots', 'slot', $otherslot->slot + 1, array('id' => $otherslot->id));
|
||||
$DB->set_field('quiz_slots', 'slot', $otherslot->slot + 1, ['id' => $otherslot->id]);
|
||||
} else {
|
||||
$lastslotbefore = $otherslot->slot;
|
||||
break;
|
||||
@@ -2333,10 +2333,10 @@ function quiz_add_random_questions($quiz, $addonpage, $categoryid, $number,
|
||||
*/
|
||||
function quiz_view($quiz, $course, $cm, $context) {
|
||||
|
||||
$params = array(
|
||||
$params = [
|
||||
'objectid' => $quiz->id,
|
||||
'context' => $context
|
||||
);
|
||||
];
|
||||
|
||||
$event = \mod_quiz\event\course_module_viewed::create($params);
|
||||
$event->add_record_snapshot('quiz', $quiz);
|
||||
@@ -2376,7 +2376,7 @@ function quiz_validate_new_attempt(quiz_settings $quizobj, access_manager $acces
|
||||
// To force the creation of a new preview, we mark the current attempt (if any)
|
||||
// as abandoned. It will then automatically be deleted below.
|
||||
$DB->set_field('quiz_attempts', 'state', quiz_attempt::ABANDONED,
|
||||
array('quiz' => $quizobj->get_quizid(), 'userid' => $USER->id));
|
||||
['quiz' => $quizobj->get_quizid(), 'userid' => $USER->id]);
|
||||
}
|
||||
|
||||
// Look for an existing attempt.
|
||||
@@ -2428,7 +2428,7 @@ function quiz_validate_new_attempt(quiz_settings $quizobj, access_manager $acces
|
||||
$page = 0;
|
||||
}
|
||||
}
|
||||
return array($currentattemptid, $attemptnumber, $lastattempt, $messages, $page);
|
||||
return [$currentattemptid, $attemptnumber, $lastattempt, $messages, $page];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2538,7 +2538,7 @@ function quiz_create_attempt_handling_errors($attemptid, $cmid = null) {
|
||||
} catch (moodle_exception $e) {
|
||||
if (!empty($cmid)) {
|
||||
list($course, $cm) = get_course_and_cm_from_cmid($cmid, 'quiz');
|
||||
$continuelink = new moodle_url('/mod/quiz/view.php', array('id' => $cmid));
|
||||
$continuelink = new moodle_url('/mod/quiz/view.php', ['id' => $cmid]);
|
||||
$context = context_module::instance($cm->id);
|
||||
if (has_capability('mod/quiz:preview', $context)) {
|
||||
throw new moodle_exception('attempterrorcontentchange', 'quiz', $continuelink);
|
||||
|
||||
+40
-40
@@ -39,24 +39,24 @@ use mod_quiz\question\display_options;
|
||||
*/
|
||||
class mod_quiz_mod_form extends moodleform_mod {
|
||||
/** @var array options to be used with date_time_selector fields in the quiz. */
|
||||
public static $datefieldoptions = array('optional' => true);
|
||||
public static $datefieldoptions = ['optional' => true];
|
||||
|
||||
protected $_feedbacks;
|
||||
protected static $reviewfields = array(); // Initialised in the constructor.
|
||||
protected static $reviewfields = []; // Initialised in the constructor.
|
||||
|
||||
/** @var int the max number of attempts allowed in any user or group override on this quiz. */
|
||||
protected $maxattemptsanyoverride = null;
|
||||
|
||||
public function __construct($current, $section, $cm, $course) {
|
||||
self::$reviewfields = array(
|
||||
'attempt' => array('theattempt', 'quiz'),
|
||||
'correctness' => array('whethercorrect', 'question'),
|
||||
'marks' => array('marks', 'quiz'),
|
||||
'specificfeedback' => array('specificfeedback', 'question'),
|
||||
'generalfeedback' => array('generalfeedback', 'question'),
|
||||
'rightanswer' => array('rightanswer', 'question'),
|
||||
'overallfeedback' => array('reviewoverallfeedback', 'quiz'),
|
||||
);
|
||||
self::$reviewfields = [
|
||||
'attempt' => ['theattempt', 'quiz'],
|
||||
'correctness' => ['whethercorrect', 'question'],
|
||||
'marks' => ['marks', 'quiz'],
|
||||
'specificfeedback' => ['specificfeedback', 'question'],
|
||||
'generalfeedback' => ['generalfeedback', 'question'],
|
||||
'rightanswer' => ['rightanswer', 'question'],
|
||||
'overallfeedback' => ['reviewoverallfeedback', 'quiz'],
|
||||
];
|
||||
parent::__construct($current, $section, $cm, $course);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
$mform->addElement('header', 'general', get_string('general', 'form'));
|
||||
|
||||
// Name.
|
||||
$mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
|
||||
$mform->addElement('text', 'name', get_string('name'), ['size'=>'64']);
|
||||
if (!empty($CFG->formatstringstriptags)) {
|
||||
$mform->setType('name', PARAM_TEXT);
|
||||
} else {
|
||||
@@ -94,7 +94,7 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
|
||||
// Time limit.
|
||||
$mform->addElement('duration', 'timelimit', get_string('timelimit', 'quiz'),
|
||||
array('optional' => true));
|
||||
['optional' => true]);
|
||||
$mform->addHelpButton('timelimit', 'timelimit', 'quiz');
|
||||
|
||||
// What to do with overdue attempts.
|
||||
@@ -107,7 +107,7 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
|
||||
// Grace period time.
|
||||
$mform->addElement('duration', 'graceperiod', get_string('graceperiod', 'quiz'),
|
||||
array('optional' => true));
|
||||
['optional' => true]);
|
||||
$mform->addHelpButton('graceperiod', 'graceperiod', 'quiz');
|
||||
$mform->hideIf('graceperiod', 'overduehandling', 'neq', 'graceperiod');
|
||||
|
||||
@@ -125,7 +125,7 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
$mform->setType('grade', PARAM_FLOAT);
|
||||
|
||||
// Number of attempts.
|
||||
$attemptoptions = array('0' => get_string('unlimited'));
|
||||
$attemptoptions = ['0' => get_string('unlimited')];
|
||||
for ($i = 1; $i <= QUIZ_MAX_ATTEMPT_OPTION; $i++) {
|
||||
$attemptoptions[$i] = $i;
|
||||
}
|
||||
@@ -143,14 +143,14 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
// -------------------------------------------------------------------------------
|
||||
$mform->addElement('header', 'layouthdr', get_string('layout', 'quiz'));
|
||||
|
||||
$pagegroup = array();
|
||||
$pagegroup = [];
|
||||
$pagegroup[] = $mform->createElement('select', 'questionsperpage',
|
||||
get_string('newpage', 'quiz'), quiz_questions_per_page_options(), array('id' => 'id_questionsperpage'));
|
||||
get_string('newpage', 'quiz'), quiz_questions_per_page_options(), ['id' => 'id_questionsperpage']);
|
||||
$mform->setDefault('questionsperpage', $quizconfig->questionsperpage);
|
||||
|
||||
if (!empty($this->_cm) && !quiz_has_attempts($this->_cm->instance)) {
|
||||
$pagegroup[] = $mform->createElement('checkbox', 'repaginatenow', '',
|
||||
get_string('repaginatenow', 'quiz'), array('id' => 'id_repaginatenow'));
|
||||
get_string('repaginatenow', 'quiz'), ['id' => 'id_repaginatenow']);
|
||||
}
|
||||
|
||||
$mform->addGroup($pagegroup, 'questionsperpagegrp',
|
||||
@@ -182,7 +182,7 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
$mform->addHelpButton('preferredbehaviour', 'howquestionsbehave', 'question');
|
||||
|
||||
// Can redo completed questions.
|
||||
$redochoices = array(0 => get_string('no'), 1 => get_string('canredoquestionsyes', 'quiz'));
|
||||
$redochoices = [0 => get_string('no'), 1 => get_string('canredoquestionsyes', 'quiz')];
|
||||
$mform->addElement('select', 'canredoquestions', get_string('canredoquestions', 'quiz'), $redochoices);
|
||||
$mform->addHelpButton('canredoquestions', 'canredoquestions', 'quiz');
|
||||
foreach ($behaviours as $behaviour => $notused) {
|
||||
@@ -238,7 +238,7 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
$mform->addHelpButton('showuserpicture', 'showuserpicture', 'quiz');
|
||||
|
||||
// Overall decimal points.
|
||||
$options = array();
|
||||
$options = [];
|
||||
for ($i = 0; $i <= QUIZ_MAX_DECIMAL_OPTION; $i++) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
@@ -247,7 +247,7 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
$mform->addHelpButton('decimalpoints', 'decimalplaces', 'quiz');
|
||||
|
||||
// Question decimal points.
|
||||
$options = array(-1 => get_string('sameasoverall', 'quiz'));
|
||||
$options = [-1 => get_string('sameasoverall', 'quiz')];
|
||||
for ($i = 0; $i <= QUIZ_MAX_Q_DECIMAL_OPTION; $i++) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
@@ -274,14 +274,14 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
|
||||
// Enforced time delay between quiz attempts.
|
||||
$mform->addElement('duration', 'delay1', get_string('delay1st2nd', 'quiz'),
|
||||
array('optional' => true));
|
||||
['optional' => true]);
|
||||
$mform->addHelpButton('delay1', 'delay1st2nd', 'quiz');
|
||||
if ($this->get_max_attempts_for_any_override() < 2) {
|
||||
$mform->hideIf('delay1', 'attempts', 'eq', 1);
|
||||
}
|
||||
|
||||
$mform->addElement('duration', 'delay2', get_string('delaylater', 'quiz'),
|
||||
array('optional' => true));
|
||||
['optional' => true]);
|
||||
$mform->addHelpButton('delay2', 'delaylater', 'quiz');
|
||||
if ($this->get_max_attempts_for_any_override() < 3) {
|
||||
$mform->hideIf('delay2', 'attempts', 'eq', 1);
|
||||
@@ -313,22 +313,22 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
$mform->addElement('static', 'gradeboundarystatic1',
|
||||
get_string('gradeboundary', 'quiz'), '100%');
|
||||
|
||||
$repeatarray = array();
|
||||
$repeatedoptions = array();
|
||||
$repeatarray = [];
|
||||
$repeatedoptions = [];
|
||||
$repeatarray[] = $mform->createElement('editor', 'feedbacktext',
|
||||
get_string('feedback', 'quiz'), array('rows' => 3), array('maxfiles' => EDITOR_UNLIMITED_FILES,
|
||||
'noclean' => true, 'context' => $this->context));
|
||||
get_string('feedback', 'quiz'), ['rows' => 3], ['maxfiles' => EDITOR_UNLIMITED_FILES,
|
||||
'noclean' => true, 'context' => $this->context]);
|
||||
$repeatarray[] = $mform->createElement('text', 'feedbackboundaries',
|
||||
get_string('gradeboundary', 'quiz'), array('size' => 10));
|
||||
get_string('gradeboundary', 'quiz'), ['size' => 10]);
|
||||
$repeatedoptions['feedbacktext']['type'] = PARAM_RAW;
|
||||
$repeatedoptions['feedbackboundaries']['type'] = PARAM_RAW;
|
||||
|
||||
if (!empty($this->_instance)) {
|
||||
$this->_feedbacks = $DB->get_records('quiz_feedback',
|
||||
array('quizid' => $this->_instance), 'mingrade DESC');
|
||||
['quizid' => $this->_instance], 'mingrade DESC');
|
||||
$numfeedbacks = count($this->_feedbacks);
|
||||
} else {
|
||||
$this->_feedbacks = array();
|
||||
$this->_feedbacks = [];
|
||||
$numfeedbacks = $quizconfig->initialnumfeedbacks;
|
||||
}
|
||||
$numfeedbacks = max($numfeedbacks, 1);
|
||||
@@ -339,9 +339,9 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
|
||||
// Put some extra elements in before the button.
|
||||
$mform->insertElementBefore($mform->createElement('editor',
|
||||
"feedbacktext[$nextel]", get_string('feedback', 'quiz'), array('rows' => 3),
|
||||
array('maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true,
|
||||
'context' => $this->context)),
|
||||
"feedbacktext[$nextel]", get_string('feedback', 'quiz'), ['rows' => 3],
|
||||
['maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true,
|
||||
'context' => $this->context]),
|
||||
'boundary_add_fields');
|
||||
$mform->insertElementBefore($mform->createElement('static',
|
||||
'gradeboundarystatic2', get_string('gradeboundary', 'quiz'), '0%'),
|
||||
@@ -375,7 +375,7 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
$when, $withhelp = false) {
|
||||
global $OUTPUT;
|
||||
|
||||
$group = array();
|
||||
$group = [];
|
||||
foreach (self::$reviewfields as $field => $string) {
|
||||
list($identifier, $component) = $string;
|
||||
|
||||
@@ -602,20 +602,20 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
*/
|
||||
public function add_completion_rules() {
|
||||
$mform = $this->_form;
|
||||
$items = array();
|
||||
$items = [];
|
||||
|
||||
$mform->addElement('advcheckbox', 'completionattemptsexhausted', null,
|
||||
get_string('completionattemptsexhausted', 'quiz'),
|
||||
array('group' => 'cattempts'));
|
||||
['group' => 'cattempts']);
|
||||
$mform->disabledIf('completionattemptsexhausted', 'completionpassgrade', 'notchecked');
|
||||
$items[] = 'completionattemptsexhausted';
|
||||
|
||||
$group = array();
|
||||
$group = [];
|
||||
$group[] = $mform->createElement('checkbox', 'completionminattemptsenabled', '',
|
||||
get_string('completionminattempts', 'quiz'));
|
||||
$group[] = $mform->createElement('text', 'completionminattempts', '', array('size' => 3));
|
||||
$group[] = $mform->createElement('text', 'completionminattempts', '', ['size' => 3]);
|
||||
$mform->setType('completionminattempts', PARAM_INT);
|
||||
$mform->addGroup($group, 'completionminattemptsgroup', get_string('completionminattemptsgroup', 'quiz'), array(' '), false);
|
||||
$mform->addGroup($group, 'completionminattemptsgroup', get_string('completionminattemptsgroup', 'quiz'), [' '], false);
|
||||
$mform->disabledIf('completionminattempts', 'completionminattemptsenabled', 'notchecked');
|
||||
|
||||
$items[] = 'completionminattemptsgroup';
|
||||
@@ -653,7 +653,7 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
SELECT MAX(CASE WHEN attempts = 0 THEN 1000 ELSE attempts END)
|
||||
FROM {quiz_overrides}
|
||||
WHERE quiz = ?",
|
||||
array($this->_instance));
|
||||
[$this->_instance]);
|
||||
if ($this->maxattemptsanyoverride < 1) {
|
||||
// This happens when no override alters the number of attempts.
|
||||
$this->maxattemptsanyoverride = 1;
|
||||
|
||||
@@ -31,16 +31,16 @@ require_once($CFG->dirroot.'/mod/quiz/locallib.php');
|
||||
$overrideid = required_param('id', PARAM_INT);
|
||||
$confirm = optional_param('confirm', false, PARAM_BOOL);
|
||||
|
||||
if (! $override = $DB->get_record('quiz_overrides', array('id' => $overrideid))) {
|
||||
if (! $override = $DB->get_record('quiz_overrides', ['id' => $overrideid])) {
|
||||
throw new \moodle_exception('invalidoverrideid', 'quiz');
|
||||
}
|
||||
if (! $quiz = $DB->get_record('quiz', array('id' => $override->quiz))) {
|
||||
if (! $quiz = $DB->get_record('quiz', ['id' => $override->quiz])) {
|
||||
throw new \moodle_exception('invalidcoursemodule');
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_instance("quiz", $quiz->id, $quiz->course)) {
|
||||
throw new \moodle_exception('invalidcoursemodule');
|
||||
}
|
||||
$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', ['id'=>$cm->course], '*', MUST_EXIST);
|
||||
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
@@ -59,9 +59,9 @@ if ($override->groupid) {
|
||||
}
|
||||
}
|
||||
|
||||
$url = new moodle_url('/mod/quiz/overridedelete.php', array('id'=>$override->id));
|
||||
$confirmurl = new moodle_url($url, array('id'=>$override->id, 'confirm'=>1));
|
||||
$cancelurl = new moodle_url('/mod/quiz/overrides.php', array('cmid'=>$cm->id));
|
||||
$url = new moodle_url('/mod/quiz/overridedelete.php', ['id'=>$override->id]);
|
||||
$confirmurl = new moodle_url($url, ['id'=>$override->id, 'confirm'=>1]);
|
||||
$cancelurl = new moodle_url('/mod/quiz/overrides.php', ['cmid'=>$cm->id]);
|
||||
|
||||
if (!empty($override->userid)) {
|
||||
$cancelurl->param('mode', 'user');
|
||||
|
||||
+14
-14
@@ -36,22 +36,22 @@ $reset = optional_param('reset', false, PARAM_BOOL);
|
||||
$override = null;
|
||||
if ($overrideid) {
|
||||
|
||||
if (! $override = $DB->get_record('quiz_overrides', array('id' => $overrideid))) {
|
||||
if (! $override = $DB->get_record('quiz_overrides', ['id' => $overrideid])) {
|
||||
throw new \moodle_exception('invalidoverrideid', 'quiz');
|
||||
}
|
||||
if (! $quiz = $DB->get_record('quiz', array('id' => $override->quiz))) {
|
||||
if (! $quiz = $DB->get_record('quiz', ['id' => $override->quiz])) {
|
||||
throw new \moodle_exception('invalidcoursemodule');
|
||||
}
|
||||
list($course, $cm) = get_course_and_cm_from_instance($quiz, 'quiz');
|
||||
|
||||
} else if ($cmid) {
|
||||
list($course, $cm) = get_course_and_cm_from_cmid($cmid, 'quiz');
|
||||
$quiz = $DB->get_record('quiz', array('id' => $cm->instance), '*', MUST_EXIST);
|
||||
$quiz = $DB->get_record('quiz', ['id' => $cm->instance], '*', MUST_EXIST);
|
||||
|
||||
} else {
|
||||
throw new \moodle_exception('invalidcoursemodule');
|
||||
}
|
||||
$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', ['id'=>$cm->course], '*', MUST_EXIST);
|
||||
|
||||
$url = new moodle_url('/mod/quiz/overrideedit.php');
|
||||
if ($action) {
|
||||
@@ -94,7 +94,7 @@ if ($overrideid) {
|
||||
}
|
||||
|
||||
// Merge quiz defaults with data.
|
||||
$keys = array('timeopen', 'timeclose', 'timelimit', 'attempts', 'password');
|
||||
$keys = ['timeopen', 'timeclose', 'timelimit', 'attempts', 'password'];
|
||||
foreach ($keys as $key) {
|
||||
if (!isset($data->{$key}) || $reset) {
|
||||
$data->{$key} = $quiz->{$key};
|
||||
@@ -112,7 +112,7 @@ if ($action === 'duplicate') {
|
||||
// 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));
|
||||
$overridelisturl = new moodle_url('/mod/quiz/overrides.php', ['cmid'=>$cm->id]);
|
||||
if (!$groupmode) {
|
||||
$overridelisturl->param('mode', 'user');
|
||||
}
|
||||
@@ -150,10 +150,10 @@ if ($mform->is_cancelled()) {
|
||||
}
|
||||
|
||||
if ($userorgroupchanged) {
|
||||
$conditions = array(
|
||||
$conditions = [
|
||||
'quiz' => $quiz->id,
|
||||
'userid' => empty($fromform->userid)? null : $fromform->userid,
|
||||
'groupid' => empty($fromform->groupid)? null : $fromform->groupid);
|
||||
'groupid' => empty($fromform->groupid)? null : $fromform->groupid];
|
||||
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.
|
||||
@@ -169,12 +169,12 @@ if ($mform->is_cancelled()) {
|
||||
}
|
||||
|
||||
// Set the common parameters for one of the events we may be triggering.
|
||||
$params = array(
|
||||
$params = [
|
||||
'context' => $context,
|
||||
'other' => array(
|
||||
'other' => [
|
||||
'quizid' => $quiz->id
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
if (!empty($override->id)) {
|
||||
$fromform->id = $override->id;
|
||||
$DB->update_record('quiz_overrides', $fromform);
|
||||
@@ -213,7 +213,7 @@ if ($mform->is_cancelled()) {
|
||||
$event->trigger();
|
||||
}
|
||||
|
||||
quiz_update_open_attempts(array('quizid'=>$quiz->id));
|
||||
quiz_update_open_attempts(['quizid'=>$quiz->id]);
|
||||
if ($groupmode) {
|
||||
// Priorities may have shifted, so we need to update all of the calendar events for group overrides.
|
||||
quiz_update_events($quiz);
|
||||
@@ -242,7 +242,7 @@ $PAGE->add_body_class('limitedwidth');
|
||||
$PAGE->set_title($pagetitle);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->activityheader->set_attrs([
|
||||
"title" => format_string($quiz->name, true, array('context' => $context)),
|
||||
"title" => format_string($quiz->name, true, ['context' => $context]),
|
||||
"description" => "",
|
||||
"hidecompletion" => true
|
||||
]);
|
||||
|
||||
@@ -39,7 +39,7 @@ if (quiz_has_attempts($quizid)) {
|
||||
$reportlink = quiz_attempt_summary_link_to_reports($quizobj->get_quiz(),
|
||||
$quizobj->get_cm(), $quizobj->get_context());
|
||||
throw new \moodle_exception('cannoteditafterattempts', 'quiz',
|
||||
new moodle_url('/mod/quiz/edit.php', array('cmid' => $quizobj->get_cmid())), $reportlink);
|
||||
new moodle_url('/mod/quiz/edit.php', ['cmid' => $quizobj->get_cmid()]), $reportlink);
|
||||
}
|
||||
|
||||
$slotnumber++;
|
||||
@@ -49,4 +49,4 @@ $repage->repaginate_slots($slotnumber, $repagtype);
|
||||
$structure = $quizobj->get_structure();
|
||||
$slots = $structure->refresh_page_numbers_and_update_db();
|
||||
|
||||
redirect(new moodle_url('edit.php', array('cmid' => $quizobj->get_cmid())));
|
||||
redirect(new moodle_url('edit.php', ['cmid' => $quizobj->get_cmid()]));
|
||||
|
||||
+9
-9
@@ -36,18 +36,18 @@ if ($id) {
|
||||
if (!$cm = get_coursemodule_from_id('quiz', $id)) {
|
||||
throw new \moodle_exception('invalidcoursemodule');
|
||||
}
|
||||
if (!$course = $DB->get_record('course', array('id' => $cm->course))) {
|
||||
if (!$course = $DB->get_record('course', ['id' => $cm->course])) {
|
||||
throw new \moodle_exception('coursemisconf');
|
||||
}
|
||||
if (!$quiz = $DB->get_record('quiz', array('id' => $cm->instance))) {
|
||||
if (!$quiz = $DB->get_record('quiz', ['id' => $cm->instance])) {
|
||||
throw new \moodle_exception('invalidcoursemodule');
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!$quiz = $DB->get_record('quiz', array('id' => $q))) {
|
||||
if (!$quiz = $DB->get_record('quiz', ['id' => $q])) {
|
||||
throw new \moodle_exception('invalidquizid', 'quiz');
|
||||
}
|
||||
if (!$course = $DB->get_record('course', array('id' => $quiz->course))) {
|
||||
if (!$course = $DB->get_record('course', ['id' => $quiz->course])) {
|
||||
throw new \moodle_exception('invalidcourseid');
|
||||
}
|
||||
if (!$cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id)) {
|
||||
@@ -55,7 +55,7 @@ if ($id) {
|
||||
}
|
||||
}
|
||||
|
||||
$url = new moodle_url('/mod/quiz/report.php', array('id' => $cm->id));
|
||||
$url = new moodle_url('/mod/quiz/report.php', ['id' => $cm->id]);
|
||||
if ($mode !== '') {
|
||||
$url->param('mode', $mode);
|
||||
}
|
||||
@@ -99,13 +99,13 @@ $report->display($quiz, $cm, $course);
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
// Log that this report was viewed.
|
||||
$params = array(
|
||||
$params = [
|
||||
'context' => $context,
|
||||
'other' => array(
|
||||
'other' => [
|
||||
'quizid' => $quiz->id,
|
||||
'reportname' => $mode
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
$event = \mod_quiz\event\report_viewed::create($params);
|
||||
$event->add_record_snapshot('course', $course);
|
||||
$event->add_record_snapshot('quiz', $quiz);
|
||||
|
||||
@@ -24,28 +24,28 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$capabilities = array(
|
||||
$capabilities = [
|
||||
// Is the user allowed to see the student's real names while grading?
|
||||
'quiz/grading:viewstudentnames' => array(
|
||||
'quiz/grading:viewstudentnames' => [
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'legacy' => array(
|
||||
'legacy' => [
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
),
|
||||
],
|
||||
'clonepermissionsfrom' => 'mod/quiz:viewreports'
|
||||
),
|
||||
],
|
||||
|
||||
// Is the user allowed to see the student's identity fields while grading?
|
||||
// Note that the name of this capability is now out-of-date, but to preserve
|
||||
// backwards compatibility, the name was not changed when the functionality was updated.
|
||||
'quiz/grading:viewidnumber' => array(
|
||||
'quiz/grading:viewidnumber' => [
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'legacy' => array(
|
||||
'legacy' => [
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
),
|
||||
],
|
||||
'clonepermissionsfrom' => 'mod/quiz:viewreports'
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
|
||||
@@ -36,7 +36,7 @@ require_once($CFG->libdir . '/formslib.php');
|
||||
*/
|
||||
class quiz_grading_settings_form extends moodleform {
|
||||
protected $includeauto;
|
||||
protected $hidden = array();
|
||||
protected $hidden = [];
|
||||
protected $counts;
|
||||
protected $shownames;
|
||||
|
||||
@@ -71,8 +71,8 @@ class quiz_grading_settings_form extends moodleform {
|
||||
|
||||
$mform->addElement('header', 'options', get_string('options', 'quiz_grading'));
|
||||
|
||||
$gradeoptions = array();
|
||||
foreach (array('needsgrading', 'manuallygraded', 'autograded', 'all') as $type) {
|
||||
$gradeoptions = [];
|
||||
foreach (['needsgrading', 'manuallygraded', 'autograded', 'all'] as $type) {
|
||||
if (empty($this->counts->$type)) {
|
||||
continue;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ class quiz_grading_settings_form extends moodleform {
|
||||
$gradeoptions);
|
||||
|
||||
$mform->addElement('text', 'pagesize', get_string('questionsperpage', 'quiz_grading'),
|
||||
array('size' => 3));
|
||||
['size' => 3]);
|
||||
$mform->addRule('pagesize', null, 'positiveint', null, 'client');
|
||||
$mform->setType('pagesize', PARAM_INT);
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class quiz_grading_report extends report_base {
|
||||
$grade = optional_param('grade', null, PARAM_ALPHA);
|
||||
|
||||
$includeauto = optional_param('includeauto', false, PARAM_BOOL);
|
||||
if (!in_array($grade, array('all', 'needsgrading', 'autograded', 'manuallygraded'))) {
|
||||
if (!in_array($grade, ['all', 'needsgrading', 'autograded', 'manuallygraded'])) {
|
||||
$grade = null;
|
||||
}
|
||||
$pagesize = optional_param('pagesize',
|
||||
@@ -92,7 +92,7 @@ class quiz_grading_report extends report_base {
|
||||
PARAM_ALPHAEXT);
|
||||
|
||||
// Assemble the options required to reload this page.
|
||||
$optparams = array('includeauto', 'page');
|
||||
$optparams = ['includeauto', 'page'];
|
||||
foreach ($optparams as $param) {
|
||||
if ($$param) {
|
||||
$this->viewoptions[$param] = $$param;
|
||||
@@ -149,10 +149,10 @@ class quiz_grading_report extends report_base {
|
||||
// Get the group, and the list of significant users.
|
||||
$this->currentgroup = $this->get_current_group($cm, $course, $this->context);
|
||||
if ($this->currentgroup == self::NO_GROUPS_ALLOWED) {
|
||||
$this->userssql = array();
|
||||
$this->userssql = [];
|
||||
} else {
|
||||
$this->userssql = get_enrolled_sql($this->context,
|
||||
array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), $this->currentgroup);
|
||||
['mod/quiz:reviewmyattempts', 'mod/quiz:attempt'], $this->currentgroup);
|
||||
}
|
||||
|
||||
$hasquestions = quiz_has_questions($this->quiz->id);
|
||||
@@ -199,15 +199,15 @@ class quiz_grading_report extends report_base {
|
||||
$where = "quiza.quiz = :mangrquizid AND
|
||||
quiza.preview = 0 AND
|
||||
quiza.state = :statefinished";
|
||||
$params = array('mangrquizid' => $this->cm->instance, 'statefinished' => quiz_attempt::FINISHED);
|
||||
$params = ['mangrquizid' => $this->cm->instance, 'statefinished' => quiz_attempt::FINISHED];
|
||||
|
||||
$usersjoin = '';
|
||||
$currentgroup = groups_get_activity_group($this->cm, true);
|
||||
$enrolleduserscount = count_enrolled_users($this->context,
|
||||
array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), $currentgroup);
|
||||
['mod/quiz:reviewmyattempts', 'mod/quiz:attempt'], $currentgroup);
|
||||
if ($currentgroup) {
|
||||
$userssql = get_enrolled_sql($this->context,
|
||||
array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), $currentgroup);
|
||||
['mod/quiz:reviewmyattempts', 'mod/quiz:attempt'], $currentgroup);
|
||||
if ($enrolleduserscount < 1) {
|
||||
$where .= ' AND quiza.userid = 0';
|
||||
} else {
|
||||
@@ -248,7 +248,7 @@ class quiz_grading_report extends report_base {
|
||||
WHERE quiza.uniqueid $asql AND quiza.state = ? AND quiza.quiz = ?",
|
||||
$params);
|
||||
|
||||
$attempts = array();
|
||||
$attempts = [];
|
||||
foreach ($attemptsbyid as $attempt) {
|
||||
$attempts[$attempt->uniqueid] = $attempt;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class quiz_overview_options extends attempts_report_options {
|
||||
// We only want to show the checkbox to delete attempts
|
||||
// if the user has permissions and if the report mode is showing attempts.
|
||||
$this->checkboxcolumn = has_any_capability(
|
||||
array('mod/quiz:regrade', 'mod/quiz:deleteattempts'), context_module::instance($this->cm->id))
|
||||
['mod/quiz:regrade', 'mod/quiz:deleteattempts'], context_module::instance($this->cm->id))
|
||||
&& ($this->attempts != attempts_report::ENROLLED_WITHOUT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ use mod_quiz\quiz_attempt;
|
||||
*/
|
||||
class quiz_overview_table extends attempts_report_table {
|
||||
|
||||
protected $regradedqs = array();
|
||||
protected $regradedqs = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -109,12 +109,12 @@ class quiz_overview_table extends attempts_report_table {
|
||||
} else {
|
||||
$namekey = 'fullname';
|
||||
}
|
||||
$averagerow = array(
|
||||
$averagerow = [
|
||||
$namekey => $label,
|
||||
'sumgrades' => $this->format_average($record),
|
||||
'feedbacktext' => strip_tags(quiz_report_feedback_for_grade(
|
||||
$record->grade, $this->quiz->id, $this->context))
|
||||
);
|
||||
];
|
||||
|
||||
if ($this->options->slotmarks) {
|
||||
$dm = new question_engine_data_mapper();
|
||||
@@ -150,10 +150,10 @@ class quiz_overview_table extends attempts_report_table {
|
||||
* @return array the (partial) row of data.
|
||||
*/
|
||||
protected function format_average_grade_for_questions($gradeaverages) {
|
||||
$row = array();
|
||||
$row = [];
|
||||
|
||||
if (!$gradeaverages) {
|
||||
$gradeaverages = array();
|
||||
$gradeaverages = [];
|
||||
}
|
||||
|
||||
foreach ($this->questions as $question) {
|
||||
@@ -193,12 +193,12 @@ class quiz_overview_table extends attempts_report_table {
|
||||
return $average;
|
||||
} else if (is_null($record->numaveraged) || $record->numaveraged == 0) {
|
||||
return html_writer::tag('span', html_writer::tag('span',
|
||||
$average, array('class' => 'average')), array('class' => 'avgcell'));
|
||||
$average, ['class' => 'average']), ['class' => 'avgcell']);
|
||||
} else {
|
||||
return html_writer::tag('span', html_writer::tag('span',
|
||||
$average, array('class' => 'average')) . ' ' . html_writer::tag('span',
|
||||
'(' . $record->numaveraged . ')', array('class' => 'count')),
|
||||
array('class' => 'avgcell'));
|
||||
$average, ['class' => 'average']) . ' ' . html_writer::tag('span',
|
||||
'(' . $record->numaveraged . ')', ['class' => 'count']),
|
||||
['class' => 'avgcell']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,8 +251,8 @@ class quiz_overview_table extends attempts_report_table {
|
||||
html_writer::empty_tag('br') . $newsumgrade;
|
||||
}
|
||||
return html_writer::link(new moodle_url('/mod/quiz/review.php',
|
||||
array('attempt' => $attempt->attempt)), $grade,
|
||||
array('title' => get_string('reviewattempt', 'quiz')));
|
||||
['attempt' => $attempt->attempt]), $grade,
|
||||
['title' => get_string('reviewattempt', 'quiz')]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -368,6 +368,6 @@ class quiz_overview_table extends attempts_report_table {
|
||||
$qubaids = $this->get_qubaids_condition();
|
||||
$regradedqs = $DB->get_records_select('quiz_overview_regrades',
|
||||
'questionusageid ' . $qubaids->usage_id_in(), $qubaids->usage_id_in_params());
|
||||
return quiz_report_index_by_keys($regradedqs, array('questionusageid', 'slot'));
|
||||
return quiz_report_index_by_keys($regradedqs, ['questionusageid', 'slot']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class quiz_overview_report extends attempts_report {
|
||||
$questions = quiz_report_get_significant_questions($quiz);
|
||||
// Prepare for downloading, if applicable.
|
||||
$courseshortname = format_string($course->shortname, true,
|
||||
array('context' => context_course::instance($course->id)));
|
||||
['context' => context_course::instance($course->id)]);
|
||||
$table = new quiz_overview_table($quiz, $this->context, $this->qmsubselect,
|
||||
$options, $groupstudentsjoins, $studentsjoins, $questions, $options->get_url());
|
||||
$filename = quiz_report_download_filename(get_string('overviewfilename', 'quiz_overview'),
|
||||
@@ -157,7 +157,7 @@ class quiz_overview_report extends attempts_report {
|
||||
$regradealllabel =
|
||||
get_string('regradeall', 'quiz_overview');
|
||||
}
|
||||
$displayurl = new moodle_url($options->get_url(), array('sesskey' => sesskey()));
|
||||
$displayurl = new moodle_url($options->get_url(), ['sesskey' => sesskey()]);
|
||||
echo '<div class="mdl-align">';
|
||||
echo '<form action="'.$displayurl->out_omit_querystring().'">';
|
||||
echo '<div>';
|
||||
@@ -181,8 +181,8 @@ class quiz_overview_report extends attempts_report {
|
||||
}
|
||||
|
||||
// Define table columns.
|
||||
$columns = array();
|
||||
$headers = array();
|
||||
$columns = [];
|
||||
$headers = [];
|
||||
|
||||
if (!$table->is_downloading() && $options->checkboxcolumn) {
|
||||
$columnname = 'checkbox';
|
||||
@@ -242,7 +242,7 @@ class quiz_overview_report extends attempts_report {
|
||||
}
|
||||
}
|
||||
|
||||
if ($DB->record_exists('quiz_grades', array('quiz'=> $quiz->id))) {
|
||||
if ($DB->record_exists('quiz_grades', ['quiz'=> $quiz->id])) {
|
||||
$data = quiz_report_grade_bands($bandwidth, $bands, $quiz->id, new \core\dml\sql_join());
|
||||
$chart = self::get_chart($labels, $data);
|
||||
$graphname = get_string('overviewreportgraph', 'quiz_overview');
|
||||
@@ -269,7 +269,7 @@ class quiz_overview_report extends attempts_report {
|
||||
|
||||
if (empty($currentgroup) || $this->hasgroupstudents) {
|
||||
if (optional_param('regrade', 0, PARAM_BOOL) && confirm_sesskey()) {
|
||||
if ($attemptids = optional_param_array('attemptid', array(), PARAM_INT)) {
|
||||
if ($attemptids = optional_param_array('attemptid', [], PARAM_INT)) {
|
||||
$this->start_regrade($quiz, $cm);
|
||||
$this->regrade_attempts($quiz, false, $groupstudentsjoins, $attemptids);
|
||||
$this->finish_regrade($redirecturl);
|
||||
@@ -381,14 +381,14 @@ class quiz_overview_report extends attempts_report {
|
||||
if (!$dryrun) {
|
||||
question_engine::save_questions_usage_by_activity($quba);
|
||||
|
||||
$params = array(
|
||||
$params = [
|
||||
'objectid' => $attempt->id,
|
||||
'relateduserid' => $attempt->userid,
|
||||
'context' => $this->context,
|
||||
'other' => array(
|
||||
'other' => [
|
||||
'quizid' => $attempt->quiz
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
$event = \mod_quiz\event\attempt_regraded::create($params);
|
||||
$event->trigger();
|
||||
}
|
||||
@@ -460,7 +460,7 @@ class quiz_overview_report extends attempts_report {
|
||||
* attempts whose id is in this list.
|
||||
*/
|
||||
protected function regrade_attempts($quiz, $dryrun = false,
|
||||
\core\dml\sql_join$groupstudentsjoins = null, $attemptids = array()) {
|
||||
\core\dml\sql_join$groupstudentsjoins = null, $attemptids = []) {
|
||||
global $DB;
|
||||
$this->unlock_session();
|
||||
|
||||
@@ -469,7 +469,7 @@ class quiz_overview_report extends attempts_report {
|
||||
FROM {quiz_attempts} quiza
|
||||
JOIN {user} u ON u.id = quiza.userid";
|
||||
$where = "quiz = :qid AND preview = 0";
|
||||
$params = array('qid' => $quiz->id);
|
||||
$params = ['qid' => $quiz->id];
|
||||
|
||||
if ($this->hasgroupstudents && !empty($groupstudentsjoins->joins)) {
|
||||
$sql .= "\n{$groupstudentsjoins->joins}";
|
||||
@@ -505,7 +505,7 @@ class quiz_overview_report extends attempts_report {
|
||||
|
||||
$join = '{quiz_overview_regrades} qqr ON qqr.questionusageid = quiza.uniqueid';
|
||||
$where = "quiza.quiz = :qid AND quiza.preview = 0 AND qqr.regraded = 0";
|
||||
$params = array('qid' => $quiz->id);
|
||||
$params = ['qid' => $quiz->id];
|
||||
|
||||
// Fetch all attempts that need regrading.
|
||||
if ($this->hasgroupstudents && !empty($groupstudentsjoins->joins)) {
|
||||
@@ -521,7 +521,7 @@ class quiz_overview_report extends attempts_report {
|
||||
JOIN $join
|
||||
WHERE $where", $params);
|
||||
|
||||
$attemptquestions = array();
|
||||
$attemptquestions = [];
|
||||
foreach ($toregrade as $row) {
|
||||
$attemptquestions[$row->uniqueid][] = $row->slot;
|
||||
}
|
||||
@@ -568,10 +568,10 @@ class quiz_overview_report extends attempts_report {
|
||||
$this->clear_regrade_table($quiz, $groupstudentsjoins);
|
||||
|
||||
$progressbar = new progress_bar('quiz_overview_regrade', 500, true);
|
||||
$a = array(
|
||||
$a = [
|
||||
'count' => count($attempts),
|
||||
'done' => 0,
|
||||
);
|
||||
];
|
||||
foreach ($attempts as $attempt) {
|
||||
$a['done']++;
|
||||
$a['attemptnum'] = $attempt->attempt;
|
||||
@@ -615,7 +615,7 @@ class quiz_overview_report extends attempts_report {
|
||||
|
||||
$userjoin = '';
|
||||
$usertest = '';
|
||||
$params = array();
|
||||
$params = [];
|
||||
if ($this->hasgroupstudents) {
|
||||
$userjoin = "JOIN {user} u ON u.id = quiza.userid
|
||||
{$groupstudentsjoins->joins}";
|
||||
@@ -666,7 +666,7 @@ class quiz_overview_report extends attempts_report {
|
||||
SELECT uniqueid
|
||||
FROM {quiz_attempts} quiza";
|
||||
$where = "WHERE quiza.quiz = :qid";
|
||||
$params = array('qid' => $quiz->id);
|
||||
$params = ['qid' => $quiz->id];
|
||||
if ($this->hasgroupstudents && !empty($groupstudentsjoins->joins)) {
|
||||
$select .= "\nJOIN {user} u ON u.id = quiza.userid
|
||||
{$groupstudentsjoins->joins}";
|
||||
|
||||
@@ -70,9 +70,9 @@ class report_test extends \advanced_testcase {
|
||||
$generator = $this->getDataGenerator();
|
||||
$course = $generator->create_course();
|
||||
$quizgenerator = $generator->get_plugin_generator('mod_quiz');
|
||||
$quiz = $quizgenerator->create_instance(array('course' => $course->id,
|
||||
$quiz = $quizgenerator->create_instance(['course' => $course->id,
|
||||
'grademethod' => QUIZ_GRADEHIGHEST, 'grade' => 100.0, 'sumgrades' => 10.0,
|
||||
'attempts' => 10));
|
||||
'attempts' => 10]);
|
||||
|
||||
// Add one question.
|
||||
/** @var core_question_generator $questiongenerator */
|
||||
@@ -104,18 +104,18 @@ class report_test extends \advanced_testcase {
|
||||
|
||||
// The test data.
|
||||
$timestamp = 1234567890;
|
||||
$attempts = array(
|
||||
array($quiz, $student1, 1, 0.0, quiz_attempt::FINISHED),
|
||||
array($quiz, $student1, 2, 5.0, quiz_attempt::FINISHED),
|
||||
array($quiz, $student1, 3, 8.0, quiz_attempt::FINISHED),
|
||||
array($quiz, $student1, 4, null, quiz_attempt::ABANDONED),
|
||||
array($quiz, $student1, 5, null, quiz_attempt::IN_PROGRESS),
|
||||
array($quiz, $student2, 1, null, quiz_attempt::ABANDONED),
|
||||
array($quiz, $student2, 2, null, quiz_attempt::ABANDONED),
|
||||
array($quiz, $student2, 3, 7.0, quiz_attempt::FINISHED),
|
||||
array($quiz, $student2, 4, null, quiz_attempt::ABANDONED),
|
||||
array($quiz, $student2, 5, null, quiz_attempt::ABANDONED),
|
||||
);
|
||||
$attempts = [
|
||||
[$quiz, $student1, 1, 0.0, quiz_attempt::FINISHED],
|
||||
[$quiz, $student1, 2, 5.0, quiz_attempt::FINISHED],
|
||||
[$quiz, $student1, 3, 8.0, quiz_attempt::FINISHED],
|
||||
[$quiz, $student1, 4, null, quiz_attempt::ABANDONED],
|
||||
[$quiz, $student1, 5, null, quiz_attempt::IN_PROGRESS],
|
||||
[$quiz, $student2, 1, null, quiz_attempt::ABANDONED],
|
||||
[$quiz, $student2, 2, null, quiz_attempt::ABANDONED],
|
||||
[$quiz, $student2, 3, 7.0, quiz_attempt::FINISHED],
|
||||
[$quiz, $student2, 4, null, quiz_attempt::ABANDONED],
|
||||
[$quiz, $student2, 5, null, quiz_attempt::ABANDONED],
|
||||
];
|
||||
|
||||
// Load it in to quiz attempts table.
|
||||
foreach ($attempts as $attemptdata) {
|
||||
@@ -170,22 +170,22 @@ class report_test extends \advanced_testcase {
|
||||
$cm = get_coursemodule_from_id('quiz', $quiz->cmid);
|
||||
$qmsubselect = quiz_report_qm_filter_select($quiz);
|
||||
$studentsjoins = get_enrolled_with_capabilities_join($context, '',
|
||||
array('mod/quiz:attempt', 'mod/quiz:reviewmyattempts'));
|
||||
['mod/quiz:attempt', 'mod/quiz:reviewmyattempts']);
|
||||
$empty = new \core\dml\sql_join();
|
||||
|
||||
// Set the options.
|
||||
$reportoptions = new quiz_overview_options('overview', $quiz, $cm, null);
|
||||
$reportoptions->attempts = attempts_report::ENROLLED_ALL;
|
||||
$reportoptions->onlygraded = true;
|
||||
$reportoptions->states = array(quiz_attempt::IN_PROGRESS, quiz_attempt::OVERDUE, quiz_attempt::FINISHED);
|
||||
$reportoptions->states = [quiz_attempt::IN_PROGRESS, quiz_attempt::OVERDUE, quiz_attempt::FINISHED];
|
||||
|
||||
// Now do a minimal set-up of the table class.
|
||||
$q->slot = 1;
|
||||
$q->maxmark = 10;
|
||||
$table = new quiz_overview_table($quiz, $context, $qmsubselect, $reportoptions,
|
||||
$empty, $studentsjoins, array(1 => $q), null);
|
||||
$empty, $studentsjoins, [1 => $q], null);
|
||||
$table->download = $isdownloading; // Cannot call the is_downloading API, because it gives errors.
|
||||
$table->define_columns(array('fullname'));
|
||||
$table->define_columns(['fullname']);
|
||||
$table->sortable(true, 'uniqueid');
|
||||
$table->define_baseurl(new \moodle_url('/mod/quiz/report.php'));
|
||||
$table->setup();
|
||||
|
||||
@@ -45,10 +45,10 @@ use mod_quiz\question\display_options;
|
||||
*/
|
||||
function quiz_report_index_by_keys($datum, $keys, $keysunique = true) {
|
||||
if (!$datum) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
$key = array_shift($keys);
|
||||
$datumkeyed = array();
|
||||
$datumkeyed = [];
|
||||
foreach ($datum as $data) {
|
||||
if ($keys || !$keysunique) {
|
||||
$datumkeyed[$data->{$key}][]= $data;
|
||||
@@ -68,7 +68,7 @@ function quiz_report_unindex($datum) {
|
||||
if (!$datum) {
|
||||
return $datum;
|
||||
}
|
||||
$datumunkeyed = array();
|
||||
$datumunkeyed = [];
|
||||
foreach ($datum as $value) {
|
||||
if (is_array($value)) {
|
||||
$datumunkeyed = array_merge($datumunkeyed, quiz_report_unindex($value));
|
||||
@@ -85,7 +85,7 @@ function quiz_report_unindex($datum) {
|
||||
*/
|
||||
function quiz_has_questions($quizid) {
|
||||
global $DB;
|
||||
return $DB->record_exists('quiz_slots', array('quizid' => $quizid));
|
||||
return $DB->record_exists('quiz_slots', ['quizid' => $quizid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,7 +216,7 @@ function quiz_report_grade_bands($bandwidth, $bands, $quizid, \core\dml\sql_join
|
||||
} else {
|
||||
$userjoin = '';
|
||||
$usertest = '1=1';
|
||||
$params = array();
|
||||
$params = [];
|
||||
}
|
||||
$sql = "
|
||||
SELECT band, COUNT(1)
|
||||
@@ -280,10 +280,10 @@ function quiz_report_highlighting_grading_method($quiz, $qmsubselect, $qmfilter)
|
||||
function quiz_report_feedback_for_grade($grade, $quizid, $context) {
|
||||
global $DB;
|
||||
|
||||
static $feedbackcache = array();
|
||||
static $feedbackcache = [];
|
||||
|
||||
if (!isset($feedbackcache[$quizid])) {
|
||||
$feedbackcache[$quizid] = $DB->get_records('quiz_feedback', array('quizid' => $quizid));
|
||||
$feedbackcache[$quizid] = $DB->get_records('quiz_feedback', ['quizid' => $quizid]);
|
||||
}
|
||||
|
||||
// With CBM etc, it is possible to get -ve grades, which would then not match
|
||||
@@ -350,7 +350,7 @@ function quiz_report_list($context) {
|
||||
$reportdirs = core_component::get_plugin_list('quiz');
|
||||
|
||||
// Order the reports tab in descending order of displayorder.
|
||||
$reportcaps = array();
|
||||
$reportcaps = [];
|
||||
foreach ($reports as $key => $report) {
|
||||
if (array_key_exists($report->name, $reportdirs)) {
|
||||
$reportcaps[$report->name] = $report->capability;
|
||||
@@ -363,7 +363,7 @@ function quiz_report_list($context) {
|
||||
$reportcaps[$reportname] = null;
|
||||
}
|
||||
}
|
||||
$reportlist = array();
|
||||
$reportlist = [];
|
||||
foreach ($reportcaps as $name => $capability) {
|
||||
if (empty($capability)) {
|
||||
$capability = 'mod/quiz:viewreports';
|
||||
@@ -412,7 +412,7 @@ function quiz_no_questions_message($quiz, $cm, $context) {
|
||||
$output .= $OUTPUT->notification(get_string('noquestions', 'quiz'));
|
||||
if (has_capability('mod/quiz:manage', $context)) {
|
||||
$output .= $OUTPUT->single_button(new moodle_url('/mod/quiz/edit.php',
|
||||
array('cmid' => $cm->id)), get_string('editquiz', 'quiz'), 'get');
|
||||
['cmid' => $cm->id]), get_string('editquiz', 'quiz'), 'get');
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
@@ -68,7 +68,7 @@ class quiz_first_or_all_responses_table extends quiz_last_responses_table {
|
||||
$this->questionusagesbyactivity = $dm->load_questions_usages_by_activity($qubaids);
|
||||
|
||||
// Insert an extra field in attempt data and extra rows where necessary.
|
||||
$newrawdata = array();
|
||||
$newrawdata = [];
|
||||
foreach ($this->rawdata as $attempt) {
|
||||
if (!isset($this->questionusagesbyactivity[$attempt->usageid])) {
|
||||
// This is a user without attempts.
|
||||
|
||||
@@ -70,7 +70,7 @@ class quiz_responses_report extends attempts_report {
|
||||
|
||||
// Prepare for downloading, if applicable.
|
||||
$courseshortname = format_string($course->shortname, true,
|
||||
array('context' => context_course::instance($course->id)));
|
||||
['context' => context_course::instance($course->id)]);
|
||||
if ($options->whichtries === question_attempt::LAST_TRY) {
|
||||
$tableclassname = 'quiz_last_responses_table';
|
||||
} else {
|
||||
@@ -137,8 +137,8 @@ class quiz_responses_report extends attempts_report {
|
||||
}
|
||||
|
||||
// Define table columns.
|
||||
$columns = array();
|
||||
$headers = array();
|
||||
$columns = [];
|
||||
$headers = [];
|
||||
|
||||
if (!$table->is_downloading() && $options->checkboxcolumn) {
|
||||
$columnname = 'checkbox';
|
||||
|
||||
@@ -26,14 +26,14 @@ use mod_quiz\local\reports\attempts_report_options_form;
|
||||
class quiz_responses_settings_form extends attempts_report_options_form {
|
||||
|
||||
protected function other_preference_fields(MoodleQuickForm $mform) {
|
||||
$mform->addGroup(array(
|
||||
$mform->addGroup([
|
||||
$mform->createElement('advcheckbox', 'qtext', '',
|
||||
get_string('questiontext', 'quiz_responses')),
|
||||
$mform->createElement('advcheckbox', 'resp', '',
|
||||
get_string('response', 'quiz_responses')),
|
||||
$mform->createElement('advcheckbox', 'right', '',
|
||||
get_string('rightanswer', 'quiz_responses')),
|
||||
), 'coloptions', get_string('showthe', 'quiz_responses'), array(' '), false);
|
||||
], 'coloptions', get_string('showthe', 'quiz_responses'), [' '], false);
|
||||
$mform->disabledIf('qtext', 'attempts', 'eq', attempts_report::ENROLLED_WITHOUT);
|
||||
$mform->disabledIf('resp', 'attempts', 'eq', attempts_report::ENROLLED_WITHOUT);
|
||||
$mform->disabledIf('right', 'attempts', 'eq', attempts_report::ENROLLED_WITHOUT);
|
||||
@@ -53,10 +53,10 @@ class quiz_responses_settings_form extends attempts_report_options_form {
|
||||
protected function other_attempt_fields(MoodleQuickForm $mform) {
|
||||
parent::other_attempt_fields($mform);
|
||||
if (quiz_allows_multiple_tries($this->_customdata['quiz'])) {
|
||||
$mform->addElement('select', 'whichtries', get_string('whichtries', 'question'), array(
|
||||
$mform->addElement('select', 'whichtries', get_string('whichtries', 'question'), [
|
||||
question_attempt::FIRST_TRY => get_string('firsttry', 'question'),
|
||||
question_attempt::LAST_TRY => get_string('lasttry', 'question'),
|
||||
question_attempt::ALL_TRIES => get_string('alltries', 'question'))
|
||||
question_attempt::ALL_TRIES => get_string('alltries', 'question')]
|
||||
);
|
||||
$mform->setDefault('whichtries', question_attempt::LAST_TRY);
|
||||
$mform->disabledIf('whichtries', 'attempts', 'eq', attempts_report::ENROLLED_WITHOUT);
|
||||
|
||||
@@ -41,7 +41,7 @@ class responses_from_steps_walkthrough_test extends \mod_quiz\attempt_walkthroug
|
||||
return __DIR__."/fixtures/{$setname}{$test}.csv";
|
||||
}
|
||||
|
||||
protected $files = array('questions', 'steps', 'responses');
|
||||
protected $files = ['questions', 'steps', 'responses'];
|
||||
|
||||
/**
|
||||
* Create a quiz add questions to it, walk through quiz attempts and then check results.
|
||||
@@ -89,7 +89,7 @@ class responses_from_steps_walkthrough_test extends \mod_quiz\attempt_walkthroug
|
||||
throw new \coding_exception("There is no step no {$responses['submittedstepno']} ".
|
||||
"for slot $slot in quizattempt {$responses['quizattempt']}!");
|
||||
}
|
||||
foreach (array('responsesummary', 'fraction', 'state') as $column) {
|
||||
foreach (['responsesummary', 'fraction', 'state'] as $column) {
|
||||
if (isset($tests[$column]) && $tests[$column] != '') {
|
||||
switch($column) {
|
||||
case 'responsesummary' :
|
||||
|
||||
@@ -127,7 +127,7 @@ class calculated {
|
||||
public function get_formatted_quiz_info_data($course, $cm, $quiz) {
|
||||
|
||||
// You can edit this array to control which statistics are displayed.
|
||||
$todisplay = array('firstattemptscount' => 'number',
|
||||
$todisplay = ['firstattemptscount' => 'number',
|
||||
'allattemptscount' => 'number',
|
||||
'firstattemptsavg' => 'summarks_as_percentage',
|
||||
'allattemptsavg' => 'summarks_as_percentage',
|
||||
@@ -139,10 +139,10 @@ class calculated {
|
||||
'kurtosis' => 'number_format',
|
||||
'cic' => 'number_format_percent',
|
||||
'errorratio' => 'number_format_percent',
|
||||
'standarderror' => 'summarks_as_percentage');
|
||||
'standarderror' => 'summarks_as_percentage'];
|
||||
|
||||
// General information about the quiz.
|
||||
$quizinfo = array();
|
||||
$quizinfo = [];
|
||||
$quizinfo[get_string('quizname', 'quiz_statistics')] = format_string($quiz->name);
|
||||
$quizinfo[get_string('coursename', 'quiz_statistics')] = format_string($course->fullname);
|
||||
if ($cm->idnumber) {
|
||||
@@ -195,10 +195,10 @@ class calculated {
|
||||
/**
|
||||
* @var array of names of properties of this class that are cached in db record.
|
||||
*/
|
||||
protected $fieldsindb = array('whichattempts', 'firstattemptscount', 'allattemptscount', 'firstattemptsavg', 'allattemptsavg',
|
||||
protected $fieldsindb = ['whichattempts', 'firstattemptscount', 'allattemptscount', 'firstattemptsavg', 'allattemptsavg',
|
||||
'lastattemptscount', 'highestattemptscount', 'lastattemptsavg', 'highestattemptsavg',
|
||||
'median', 'standarddeviation', 'skewness',
|
||||
'kurtosis', 'cic', 'errorratio', 'standarderror');
|
||||
'kurtosis', 'cic', 'errorratio', 'standarderror'];
|
||||
|
||||
/**
|
||||
* Cache the stats contained in this class.
|
||||
|
||||
@@ -135,7 +135,7 @@ class calculator {
|
||||
|
||||
$timemodified = time() - self::TIME_TO_CACHE;
|
||||
$fromdb = $DB->get_record_select('quiz_statistics', 'hashcode = ? AND timemodified > ?',
|
||||
array($qubaids->get_hash_code(), $timemodified));
|
||||
[$qubaids->get_hash_code(), $timemodified]);
|
||||
$stats = new calculated();
|
||||
$stats->populate_from_record($fromdb);
|
||||
return $stats;
|
||||
@@ -152,7 +152,7 @@ class calculator {
|
||||
|
||||
$timemodified = time() - self::TIME_TO_CACHE;
|
||||
return $DB->get_field_select('quiz_statistics', 'timemodified', 'hashcode = ? AND timemodified > ?',
|
||||
array($qubaids->get_hash_code(), $timemodified));
|
||||
[$qubaids->get_hash_code(), $timemodified]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,7 +276,7 @@ class calculator {
|
||||
SUM(POWER((quiza.sumgrades - $mean), 4)) AS power4
|
||||
FROM $fromqa
|
||||
WHERE $whereqa";
|
||||
$params = array('mean1' => $mean, 'mean2' => $mean, 'mean3' => $mean) + $qaparams;
|
||||
$params = ['mean1' => $mean, 'mean2' => $mean, 'mean3' => $mean] + $qaparams;
|
||||
|
||||
return $DB->get_record_sql($sql, $params, MUST_EXIST);
|
||||
}
|
||||
|
||||
@@ -24,15 +24,15 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$capabilities = array(
|
||||
'quiz/statistics:view' => array(
|
||||
$capabilities = [
|
||||
'quiz/statistics:view' => [
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'archetypes' => [
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'manager' => CAP_ALLOW
|
||||
),
|
||||
],
|
||||
'clonepermissionsfrom' => 'mod/quiz:viewreports'
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
|
||||
@@ -39,7 +39,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @param array $options additional options affecting the file serving.
|
||||
*/
|
||||
function quiz_statistics_question_preview_pluginfile($previewcontext, $questionid,
|
||||
$filecontext, $filecomponent, $filearea, $args, $forcedownload, $options = array()) {
|
||||
$filecontext, $filecomponent, $filearea, $args, $forcedownload, $options = []) {
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class quiz_statistics_report extends report_base {
|
||||
$whichattempts = optional_param('whichattempts', $quiz->grademethod, PARAM_INT);
|
||||
$whichtries = optional_param('whichtries', question_attempt::LAST_TRY, PARAM_ALPHA);
|
||||
|
||||
$pageoptions = array();
|
||||
$pageoptions = [];
|
||||
$pageoptions['id'] = $cm->id;
|
||||
$pageoptions['mode'] = 'statistics';
|
||||
|
||||
@@ -88,7 +88,7 @@ class quiz_statistics_report extends report_base {
|
||||
|
||||
$mform = new quiz_statistics_settings_form($reporturl, compact('quiz'));
|
||||
|
||||
$mform->set_data(array('whichattempts' => $whichattempts, 'whichtries' => $whichtries));
|
||||
$mform->set_data(['whichattempts' => $whichattempts, 'whichtries' => $whichtries]);
|
||||
|
||||
if ($whichattempts != $quiz->grademethod) {
|
||||
$reporturl->param('whichattempts', $whichattempts);
|
||||
@@ -112,7 +112,7 @@ class quiz_statistics_report extends report_base {
|
||||
} else {
|
||||
// All users who can attempt quizzes and who are in the currently selected group.
|
||||
$groupstudentsjoins = get_enrolled_with_capabilities_join($this->context, '',
|
||||
array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), $currentgroup);
|
||||
['mod/quiz:reviewmyattempts', 'mod/quiz:attempt'], $currentgroup);
|
||||
if (!empty($groupstudentsjoins->joins)) {
|
||||
$sql = "SELECT DISTINCT u.id
|
||||
FROM {user} u
|
||||
@@ -140,7 +140,7 @@ class quiz_statistics_report extends report_base {
|
||||
$report = get_string('questionstatsfilename', 'quiz_statistics');
|
||||
}
|
||||
$courseshortname = format_string($course->shortname, true,
|
||||
array('context' => context_course::instance($course->id)));
|
||||
['context' => context_course::instance($course->id)]);
|
||||
$filename = quiz_report_download_filename($report, $courseshortname, $quiz->name);
|
||||
$this->table->is_downloading($download, $filename,
|
||||
get_string('quizstructureanalysis', 'quiz_statistics'));
|
||||
@@ -234,7 +234,7 @@ class quiz_statistics_report extends report_base {
|
||||
$number = $questionstats->for_slot($slot)->question->number;
|
||||
echo $OUTPUT->heading(get_string('slotstructureanalysis', 'quiz_statistics', $number), 3);
|
||||
}
|
||||
$this->table->define_baseurl(new moodle_url($reporturl, array('slot' => $slot)));
|
||||
$this->table->define_baseurl(new moodle_url($reporturl, ['slot' => $slot]));
|
||||
$this->table->format_and_add_array_of_rows($questionstats->structure_analysis_for_one_slot($slot));
|
||||
} else {
|
||||
$this->output_individual_question_data($quiz, $questionstats->for_slot($slot, $variantno));
|
||||
@@ -296,29 +296,29 @@ class quiz_statistics_report extends report_base {
|
||||
|
||||
// Set up the question info table.
|
||||
$questioninfotable = new html_table();
|
||||
$questioninfotable->align = array('center', 'center');
|
||||
$questioninfotable->align = ['center', 'center'];
|
||||
$questioninfotable->width = '60%';
|
||||
$questioninfotable->attributes['class'] = 'generaltable titlesleft';
|
||||
|
||||
$questioninfotable->data = array();
|
||||
$questioninfotable->data[] = array(get_string('modulename', 'quiz'), $quiz->name);
|
||||
$questioninfotable->data[] = array(get_string('questionname', 'quiz_statistics'),
|
||||
$questionstat->question->name.' '.$datumfromtable['actions']);
|
||||
$questioninfotable->data = [];
|
||||
$questioninfotable->data[] = [get_string('modulename', 'quiz'), $quiz->name];
|
||||
$questioninfotable->data[] = [get_string('questionname', 'quiz_statistics'),
|
||||
$questionstat->question->name.' '.$datumfromtable['actions']];
|
||||
|
||||
if ($questionstat->variant !== null) {
|
||||
$questioninfotable->data[] = array(get_string('variant', 'quiz_statistics'), $questionstat->variant);
|
||||
$questioninfotable->data[] = [get_string('variant', 'quiz_statistics'), $questionstat->variant];
|
||||
|
||||
}
|
||||
$questioninfotable->data[] = array(get_string('questiontype', 'quiz_statistics'),
|
||||
$questioninfotable->data[] = [get_string('questiontype', 'quiz_statistics'),
|
||||
$datumfromtable['icon'] . ' ' .
|
||||
question_bank::get_qtype($questionstat->question->qtype, false)->menu_name() . ' ' .
|
||||
$datumfromtable['icon']);
|
||||
$questioninfotable->data[] = array(get_string('positions', 'quiz_statistics'),
|
||||
$questionstat->positions);
|
||||
$datumfromtable['icon']];
|
||||
$questioninfotable->data[] = [get_string('positions', 'quiz_statistics'),
|
||||
$questionstat->positions];
|
||||
|
||||
// Set up the question statistics table.
|
||||
$questionstatstable = new html_table();
|
||||
$questionstatstable->align = array('center', 'center');
|
||||
$questionstatstable->align = ['center', 'center'];
|
||||
$questionstatstable->width = '60%';
|
||||
$questionstatstable->attributes['class'] = 'generaltable titlesleft';
|
||||
|
||||
@@ -327,7 +327,7 @@ class quiz_statistics_report extends report_base {
|
||||
$actions = $datumfromtable['actions'];
|
||||
unset($datumfromtable['actions']);
|
||||
unset($datumfromtable['name']);
|
||||
$labels = array(
|
||||
$labels = [
|
||||
's' => get_string('attempts', 'quiz_statistics'),
|
||||
'facility' => get_string('facility', 'quiz_statistics'),
|
||||
'sd' => get_string('standarddeviationq', 'quiz_statistics'),
|
||||
@@ -337,9 +337,9 @@ class quiz_statistics_report extends report_base {
|
||||
'discrimination_index' => get_string('discrimination_index', 'quiz_statistics'),
|
||||
'discriminative_efficiency' =>
|
||||
get_string('discriminative_efficiency', 'quiz_statistics')
|
||||
);
|
||||
];
|
||||
foreach ($datumfromtable as $item => $value) {
|
||||
$questionstatstable->data[] = array($labels[$item], $value);
|
||||
$questionstatstable->data[] = [$labels[$item], $value];
|
||||
}
|
||||
|
||||
// Display the various bits.
|
||||
@@ -364,7 +364,7 @@ class quiz_statistics_report extends report_base {
|
||||
$this->context->id, 'quiz_statistics');
|
||||
|
||||
return $OUTPUT->box(format_text($text, $question->questiontextformat,
|
||||
array('noclean' => true, 'para' => false, 'overflowdiv' => true)),
|
||||
['noclean' => true, 'para' => false, 'overflowdiv' => true]),
|
||||
'questiontext boxaligncenter generalbox boxwidthnormal mdl-align');
|
||||
}
|
||||
|
||||
@@ -491,13 +491,13 @@ class quiz_statistics_report extends report_base {
|
||||
protected function output_quiz_info_table($quizinfo) {
|
||||
|
||||
$quizinfotable = new html_table();
|
||||
$quizinfotable->align = array('center', 'center');
|
||||
$quizinfotable->align = ['center', 'center'];
|
||||
$quizinfotable->width = '60%';
|
||||
$quizinfotable->attributes['class'] = 'generaltable titlesleft';
|
||||
$quizinfotable->data = array();
|
||||
$quizinfotable->data = [];
|
||||
|
||||
foreach ($quizinfo as $heading => $value) {
|
||||
$quizinfotable->data[] = array($heading, $value);
|
||||
$quizinfotable->data[] = [$heading, $value];
|
||||
}
|
||||
|
||||
return html_writer::table($quizinfotable);
|
||||
@@ -519,8 +519,8 @@ class quiz_statistics_report extends report_base {
|
||||
}
|
||||
|
||||
// Reformat the data ready for output.
|
||||
$headers = array();
|
||||
$row = array();
|
||||
$headers = [];
|
||||
$row = [];
|
||||
foreach ($quizinfo as $heading => $value) {
|
||||
$headers[] = $heading;
|
||||
$row[] = $value;
|
||||
@@ -546,7 +546,7 @@ class quiz_statistics_report extends report_base {
|
||||
|
||||
$quiz = $quizorid;
|
||||
if (!is_object($quiz)) {
|
||||
$quiz = $DB->get_record('quiz', array('id' => $quizorid), '*', MUST_EXIST);
|
||||
$quiz = $DB->get_record('quiz', ['id' => $quizorid], '*', MUST_EXIST);
|
||||
}
|
||||
|
||||
// Load the rest of the required data.
|
||||
@@ -671,7 +671,7 @@ class quiz_statistics_report extends report_base {
|
||||
$progress->progress(3);
|
||||
$progress->end_progress();
|
||||
|
||||
return array($quizstats, $questionstats);
|
||||
return [$quizstats, $questionstats];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -727,10 +727,10 @@ class quiz_statistics_report extends report_base {
|
||||
* @param int[] $done array keys are ids of questions that have been analysed before calling method.
|
||||
* @return array array keys are ids of questions that were analysed after this method call.
|
||||
*/
|
||||
protected function analyse_responses_for_questions($questions, $qubaids, $whichtries, $progress = null, $done = array()) {
|
||||
protected function analyse_responses_for_questions($questions, $qubaids, $whichtries, $progress = null, $done = []) {
|
||||
$countquestions = count($questions);
|
||||
if (!$countquestions) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
if ($progress === null) {
|
||||
$progress = new \core\progress\none();
|
||||
@@ -760,7 +760,7 @@ class quiz_statistics_report extends report_base {
|
||||
protected function everything_download_options(moodle_url $reporturl) {
|
||||
global $OUTPUT;
|
||||
return $OUTPUT->download_dataformat_selector(get_string('downloadeverything', 'quiz_statistics'),
|
||||
$reporturl->out_omit_querystring(), 'download', $reporturl->params() + array('everything' => 1));
|
||||
$reporturl->out_omit_querystring(), 'download', $reporturl->params() + ['everything' => 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -801,7 +801,7 @@ class quiz_statistics_report extends report_base {
|
||||
$a->count = $count;
|
||||
|
||||
$recalcualteurl = new moodle_url($reporturl,
|
||||
array('recalculate' => 1, 'sesskey' => sesskey()));
|
||||
['recalculate' => 1, 'sesskey' => sesskey()]);
|
||||
$output = '';
|
||||
$output .= $OUTPUT->box_start(
|
||||
'boxaligncenter generalbox boxwidthnormal mdl-align', 'cachingnotice');
|
||||
@@ -821,9 +821,9 @@ class quiz_statistics_report extends report_base {
|
||||
*/
|
||||
public function clear_cached_data($qubaids) {
|
||||
global $DB;
|
||||
$DB->delete_records('quiz_statistics', array('hashcode' => $qubaids->get_hash_code()));
|
||||
$DB->delete_records('question_statistics', array('hashcode' => $qubaids->get_hash_code()));
|
||||
$DB->delete_records('question_response_analysis', array('hashcode' => $qubaids->get_hash_code()));
|
||||
$DB->delete_records('quiz_statistics', ['hashcode' => $qubaids->get_hash_code()]);
|
||||
$DB->delete_records('question_statistics', ['hashcode' => $qubaids->get_hash_code()]);
|
||||
$DB->delete_records('question_response_analysis', ['hashcode' => $qubaids->get_hash_code()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,7 +41,7 @@ class quiz_statistics_settings_form extends moodleform {
|
||||
|
||||
$mform->addElement('header', 'preferencespage', get_string('reportsettings', 'quiz_statistics'));
|
||||
|
||||
$options = array();
|
||||
$options = [];
|
||||
foreach (array_keys(quiz_get_grading_options()) as $which) {
|
||||
$options[$which] = \quiz_statistics\calculator::using_attempts_lang_string($which);
|
||||
}
|
||||
@@ -49,10 +49,10 @@ class quiz_statistics_settings_form extends moodleform {
|
||||
$mform->addElement('select', 'whichattempts', get_string('calculatefrom', 'quiz_statistics'), $options);
|
||||
|
||||
if (quiz_allows_multiple_tries($this->_customdata['quiz'])) {
|
||||
$mform->addElement('select', 'whichtries', get_string('whichtries', 'quiz_statistics'), array(
|
||||
$mform->addElement('select', 'whichtries', get_string('whichtries', 'quiz_statistics'), [
|
||||
question_attempt::FIRST_TRY => get_string('firsttry', 'question'),
|
||||
question_attempt::LAST_TRY => get_string('lasttry', 'question'),
|
||||
question_attempt::ALL_TRIES => get_string('alltries', 'question'))
|
||||
question_attempt::ALL_TRIES => get_string('alltries', 'question')]
|
||||
);
|
||||
$mform->setDefault('whichtries', question_attempt::LAST_TRY);
|
||||
}
|
||||
|
||||
@@ -73,8 +73,8 @@ class quiz_statistics_question_table extends flexible_table {
|
||||
$this->set_attribute('class', 'generaltable generalbox boxaligncenter quizresponseanalysis');
|
||||
|
||||
// Define the table columns.
|
||||
$columns = array();
|
||||
$headers = array();
|
||||
$columns = [];
|
||||
$headers = [];
|
||||
|
||||
if ($responseanalysis->has_subparts()) {
|
||||
$columns[] = 'part';
|
||||
|
||||
@@ -65,8 +65,8 @@ class quiz_statistics_table extends flexible_table {
|
||||
$this->cmid = $cmid;
|
||||
|
||||
// Define the table columns.
|
||||
$columns = array();
|
||||
$headers = array();
|
||||
$columns = [];
|
||||
$headers = [];
|
||||
|
||||
$columns[] = 'number';
|
||||
$headers[] = get_string('questionnumber', 'quiz_statistics');
|
||||
@@ -140,8 +140,8 @@ class quiz_statistics_table extends flexible_table {
|
||||
public function wrap_html_start() {
|
||||
// Horrible Moodle 2.0 wide-content work-around.
|
||||
if (!$this->is_downloading()) {
|
||||
echo html_writer::start_tag('div', array('id' => 'tablecontainer',
|
||||
'class' => 'statistics-tablecontainer'));
|
||||
echo html_writer::start_tag('div', ['id' => 'tablecontainer',
|
||||
'class' => 'statistics-tablecontainer']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,28 +245,28 @@ class quiz_statistics_table extends flexible_table {
|
||||
if (!is_null($questionstat->variant)) {
|
||||
if ($questionstat->subquestion) {
|
||||
// Variant of a sub-question.
|
||||
$url = new moodle_url($baseurl, array('qid' => $questionstat->questionid, 'variant' => $questionstat->variant));
|
||||
$name = html_writer::link($url, $name, array('title' => get_string('detailedanalysisforvariant',
|
||||
$url = new moodle_url($baseurl, ['qid' => $questionstat->questionid, 'variant' => $questionstat->variant]);
|
||||
$name = html_writer::link($url, $name, ['title' => get_string('detailedanalysisforvariant',
|
||||
'quiz_statistics',
|
||||
$questionstat->variant)));
|
||||
$questionstat->variant)]);
|
||||
} else if ($questionstat->slot) {
|
||||
// Variant of a question in a slot.
|
||||
$url = new moodle_url($baseurl, array('slot' => $questionstat->slot, 'variant' => $questionstat->variant));
|
||||
$name = html_writer::link($url, $name, array('title' => get_string('detailedanalysisforvariant',
|
||||
$url = new moodle_url($baseurl, ['slot' => $questionstat->slot, 'variant' => $questionstat->variant]);
|
||||
$name = html_writer::link($url, $name, ['title' => get_string('detailedanalysisforvariant',
|
||||
'quiz_statistics',
|
||||
$questionstat->variant)));
|
||||
$questionstat->variant)]);
|
||||
}
|
||||
} else {
|
||||
if ($questionstat->subquestion && !$questionstat->get_variants()) {
|
||||
// Sub question without variants.
|
||||
$url = new moodle_url($baseurl, array('qid' => $questionstat->questionid));
|
||||
$name = html_writer::link($url, $name, array('title' => get_string('detailedanalysis', 'quiz_statistics')));
|
||||
$url = new moodle_url($baseurl, ['qid' => $questionstat->questionid]);
|
||||
$name = html_writer::link($url, $name, ['title' => get_string('detailedanalysis', 'quiz_statistics')]);
|
||||
} else if ($baseurl->param('slot') === null && $questionstat->slot) {
|
||||
// Question in a slot, we are not on a page showing structural analysis of one slot,
|
||||
// we don't want linking on those pages.
|
||||
$number = $questionstat->question->number;
|
||||
$israndomquestion = $questionstat->question->qtype == 'random';
|
||||
$url = new moodle_url($baseurl, array('slot' => $questionstat->slot));
|
||||
$url = new moodle_url($baseurl, ['slot' => $questionstat->slot]);
|
||||
|
||||
if ($this->is_calculated_question_summary($questionstat)) {
|
||||
// Only make the random question summary row name link to the slot structure
|
||||
@@ -278,14 +278,14 @@ class quiz_statistics_table extends flexible_table {
|
||||
// Question cannot be broken down into sub-questions or variants. Link will show response analysis page.
|
||||
$name = html_writer::link($url,
|
||||
$name,
|
||||
array('title' => get_string('detailedanalysis', 'quiz_statistics')));
|
||||
['title' => get_string('detailedanalysis', 'quiz_statistics')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($this->is_dubious_question($questionstat)) {
|
||||
$name = html_writer::tag('div', $name, array('class' => 'dubious'));
|
||||
$name = html_writer::tag('div', $name, ['class' => 'dubious']);
|
||||
}
|
||||
|
||||
if ($this->is_calculated_question_summary($questionstat)) {
|
||||
@@ -417,7 +417,7 @@ class quiz_statistics_table extends flexible_table {
|
||||
if (!$this->is_downloading()) {
|
||||
$negcovar = html_writer::tag('div',
|
||||
$negcovar . $OUTPUT->help_icon('negcovar', 'quiz_statistics'),
|
||||
array('class' => 'negcovar'));
|
||||
['class' => 'negcovar']);
|
||||
}
|
||||
|
||||
return $negcovar;
|
||||
|
||||
@@ -43,7 +43,7 @@ function quiz_statistics_attempts_sql($quizid, \core\dml\sql_join $groupstudents
|
||||
$whichattempts = QUIZ_GRADEAVERAGE, $includeungraded = false) {
|
||||
$fromqa = "{quiz_attempts} quiza ";
|
||||
$whereqa = 'quiza.quiz = :quizid AND quiza.preview = 0 AND quiza.state = :quizstatefinished';
|
||||
$qaparams = array('quizid' => (int)$quizid, 'quizstatefinished' => quiz_attempt::FINISHED);
|
||||
$qaparams = ['quizid' => (int)$quizid, 'quizstatefinished' => quiz_attempt::FINISHED];
|
||||
|
||||
if (!empty($groupstudentsjoins->joins)) {
|
||||
$fromqa .= "\nJOIN {user} u ON u.id = quiza.userid
|
||||
@@ -61,7 +61,7 @@ function quiz_statistics_attempts_sql($quizid, \core\dml\sql_join $groupstudents
|
||||
$whereqa .= ' AND quiza.sumgrades IS NOT NULL';
|
||||
}
|
||||
|
||||
return array($fromqa, $whereqa, $qaparams);
|
||||
return [$fromqa, $whereqa, $qaparams];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,7 +74,7 @@ class testable_question_statistics extends \core_question\statistics\questions\c
|
||||
* - $summarks array of total marks for each usage, indexed by usage id
|
||||
*/
|
||||
protected function get_latest_steps($qubaids) {
|
||||
$summarks = array();
|
||||
$summarks = [];
|
||||
$fakeusageid = 0;
|
||||
foreach ($this->lateststeps as $step) {
|
||||
// The same 'sumgrades' field is available in step data for every slot, we will ignore all slots but slot 1.
|
||||
@@ -88,7 +88,7 @@ class testable_question_statistics extends \core_question\statistics\questions\c
|
||||
$step->questionusageid = $fakeusageid;
|
||||
}
|
||||
|
||||
return array($this->lateststeps, $summarks);
|
||||
return [$this->lateststeps, $summarks];
|
||||
}
|
||||
|
||||
protected function cache_stats($qubaids) {
|
||||
@@ -118,27 +118,27 @@ class statistics_test extends \basic_testcase {
|
||||
$this->qstats = $calculator->calculate(null);
|
||||
|
||||
// Values expected are taken from contrib/tools/quiz_tools/stats.xls.
|
||||
$facility = array(0, 0, 0, 0, null, null, null, 41.19318182, 81.36363636,
|
||||
$facility = [0, 0, 0, 0, null, null, null, 41.19318182, 81.36363636,
|
||||
71.36363636, 65.45454545, 65.90909091, 36.36363636, 59.09090909, 50,
|
||||
59.09090909, 63.63636364, 45.45454545, 27.27272727, 50);
|
||||
59.09090909, 63.63636364, 45.45454545, 27.27272727, 50];
|
||||
$this->qstats_q_fields('facility', $facility, 100);
|
||||
$sd = array(0, 0, 0, 0, null, null, null, 1912.733589, 251.2738111,
|
||||
$sd = [0, 0, 0, 0, null, null, null, 1912.733589, 251.2738111,
|
||||
322.6312277, 333.4199022, 337.5811591, 492.3659639, 503.2362797,
|
||||
511.7663157, 503.2362797, 492.3659639, 509.6471914, 455.8423058, 511.7663157);
|
||||
511.7663157, 503.2362797, 492.3659639, 509.6471914, 455.8423058, 511.7663157];
|
||||
$this->qstats_q_fields('sd', $sd, 1000);
|
||||
$effectiveweight = array(0, 0, 0, 0, 0, 0, 0, 26.58464457, 3.368456046,
|
||||
$effectiveweight = [0, 0, 0, 0, 0, 0, 0, 26.58464457, 3.368456046,
|
||||
3.253955259, 7.584083694, 3.79658376, 3.183278505, 4.532356904,
|
||||
7.78856243, 10.08351572, 8.381139345, 8.727645713, 7.946277111, 4.769500946);
|
||||
7.78856243, 10.08351572, 8.381139345, 8.727645713, 7.946277111, 4.769500946];
|
||||
$this->qstats_q_fields('effectiveweight', $effectiveweight);
|
||||
$discriminationindex = array(null, null, null, null, null, null, null,
|
||||
$discriminationindex = [null, null, null, null, null, null, null,
|
||||
25.88327077, 1.170256965, -4.207816809, 28.16930644, -2.513606859,
|
||||
-12.99017581, -8.900638238, 8.670004606, 29.63337745, 15.18945843,
|
||||
16.21079629, 15.52451404, -8.396734802);
|
||||
16.21079629, 15.52451404, -8.396734802];
|
||||
$this->qstats_q_fields('discriminationindex', $discriminationindex);
|
||||
$discriminativeefficiency = array(null, null, null, null, null, null, null,
|
||||
$discriminativeefficiency = [null, null, null, null, null, null, null,
|
||||
27.23492723, 1.382386552, -4.691171307, 31.12404354, -2.877487579,
|
||||
-17.5074184, -10.27568922, 10.86956522, 34.58997279, 17.4790556,
|
||||
20.14359793, 22.06477733, -10);
|
||||
20.14359793, 22.06477733, -10];
|
||||
$this->qstats_q_fields('discriminativeefficiency', $discriminativeefficiency);
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ class statistics_test extends \basic_testcase {
|
||||
|
||||
public function get_records_from_csv($filename) {
|
||||
$filecontents = file($filename, FILE_IGNORE_NEW_LINES);
|
||||
$records = array();
|
||||
$records = [];
|
||||
// Skip the first line containing field names.
|
||||
$keys = $this->get_fields_from_csv(array_shift($filecontents));
|
||||
while (null !== ($line = array_shift($filecontents))) {
|
||||
|
||||
@@ -57,7 +57,7 @@ class stats_from_steps_walkthrough_test extends \mod_quiz\attempt_walkthrough_fr
|
||||
return __DIR__."/fixtures/{$setname}{$test}.csv";
|
||||
}
|
||||
|
||||
protected $files = array('questions', 'steps', 'results', 'qstats', 'responsecounts');
|
||||
protected $files = ['questions', 'steps', 'results', 'qstats', 'responsecounts'];
|
||||
|
||||
/**
|
||||
* Create a quiz add questions to it, walk through quiz attempts and then check results.
|
||||
@@ -90,7 +90,7 @@ class stats_from_steps_walkthrough_test extends \mod_quiz\attempt_walkthrough_fr
|
||||
protected function check_question_stats($qstats, $questionstats) {
|
||||
foreach ($qstats as $slotqstats) {
|
||||
foreach ($slotqstats as $statname => $slotqstat) {
|
||||
if (!in_array($statname, array('slot', 'subqname')) && $slotqstat !== '') {
|
||||
if (!in_array($statname, ['slot', 'subqname']) && $slotqstat !== '') {
|
||||
$this->assert_stat_equals($slotqstat,
|
||||
$questionstats,
|
||||
$slotqstats['slot'],
|
||||
@@ -202,19 +202,19 @@ class stats_from_steps_walkthrough_test extends \mod_quiz\attempt_walkthrough_fr
|
||||
$subpartid = $possibleresponsesubpartids[$subpart - 1];
|
||||
|
||||
if ($modelresponse == '[NO RESPONSE]') {
|
||||
return array($subpartid, null);
|
||||
return [$subpartid, null];
|
||||
|
||||
} else if ($modelresponse == '[NO MATCH]') {
|
||||
return array($subpartid, 0);
|
||||
return [$subpartid, 0];
|
||||
}
|
||||
|
||||
$modelresponses = array();
|
||||
$modelresponses = [];
|
||||
foreach ($possibleresponses[$subpartid] as $responseclassid => $subpartpossibleresponse) {
|
||||
$modelresponses[$responseclassid] = $subpartpossibleresponse->responseclass;
|
||||
}
|
||||
$this->assertContains($modelresponse, $modelresponses);
|
||||
$responseclassid = array_search($modelresponse, $modelresponses);
|
||||
return array($subpartid, $responseclassid);
|
||||
return [$subpartid, $responseclassid];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,7 +225,7 @@ class stats_from_steps_walkthrough_test extends \mod_quiz\attempt_walkthrough_fr
|
||||
*/
|
||||
protected function check_response_counts($responsecounts, $qubaids, $questions, $whichtries) {
|
||||
foreach ($responsecounts as $expected) {
|
||||
$defaultsforexpected = array('randq' => '', 'variant' => '1', 'subpart' => '1');
|
||||
$defaultsforexpected = ['randq' => '', 'variant' => '1', 'subpart' => '1'];
|
||||
foreach ($defaultsforexpected as $key => $expecteddefault) {
|
||||
if (!isset($expected[$key])) {
|
||||
$expected[$key] = $expecteddefault;
|
||||
@@ -248,13 +248,13 @@ class stats_from_steps_walkthrough_test extends \mod_quiz\attempt_walkthrough_fr
|
||||
* @param $qubaids
|
||||
*/
|
||||
protected function check_variants_count_for_quiz_00($questions, $questionstats, $whichtries, $qubaids) {
|
||||
$expectedvariantcounts = array(2 => array(1 => 6,
|
||||
$expectedvariantcounts = [2 => [1 => 6,
|
||||
4 => 4,
|
||||
5 => 3,
|
||||
6 => 4,
|
||||
7 => 2,
|
||||
8 => 5,
|
||||
10 => 1));
|
||||
10 => 1]];
|
||||
|
||||
foreach ($questions as $slot => $question) {
|
||||
if (!question_bank::get_qtype($question->qtype, false)->can_analyse_responses()) {
|
||||
@@ -268,15 +268,15 @@ class stats_from_steps_walkthrough_test extends \mod_quiz\attempt_walkthrough_fr
|
||||
// Compare contents, ignore ordering of array, using canonicalize parameter of assertEquals.
|
||||
$this->assertEqualsCanonicalizing(array_keys($expectedvariantcounts[$slot]), $variantsnos);
|
||||
} else {
|
||||
$this->assertEquals(array(1), $variantsnos);
|
||||
$this->assertEquals([1], $variantsnos);
|
||||
}
|
||||
$totalspervariantno = array();
|
||||
$totalspervariantno = [];
|
||||
foreach ($variantsnos as $variantno) {
|
||||
|
||||
$subpartids = $analysis->get_subpart_ids($variantno);
|
||||
foreach ($subpartids as $subpartid) {
|
||||
if (!isset($totalspervariantno[$subpartid])) {
|
||||
$totalspervariantno[$subpartid] = array();
|
||||
$totalspervariantno[$subpartid] = [];
|
||||
}
|
||||
$totalspervariantno[$subpartid][$variantno] = 0;
|
||||
|
||||
@@ -326,7 +326,7 @@ class stats_from_steps_walkthrough_test extends \mod_quiz\attempt_walkthrough_fr
|
||||
* @param $quizstats
|
||||
*/
|
||||
protected function check_quiz_stats_for_quiz_00($quizstats) {
|
||||
$quizstatsexpected = array(
|
||||
$quizstatsexpected = [
|
||||
'median' => 4.5,
|
||||
'firstattemptsavg' => 4.617333332,
|
||||
'allattemptsavg' => 4.617333332,
|
||||
@@ -338,7 +338,7 @@ class stats_from_steps_walkthrough_test extends \mod_quiz\attempt_walkthrough_fr
|
||||
'cic' => -87.2230935542,
|
||||
'errorratio' => 136.8294900795,
|
||||
'standarderror' => 1.1106813066
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($quizstatsexpected as $statname => $statvalue) {
|
||||
$this->assertEqualsWithDelta($statvalue, $quizstats->$statname, abs($statvalue) * 1.5e-5, $quizstats->$statname);
|
||||
@@ -381,9 +381,9 @@ class stats_from_steps_walkthrough_test extends \mod_quiz\attempt_walkthrough_fr
|
||||
}
|
||||
if (isset($csvdata['qstats'])) {
|
||||
$this->check_question_stats($csvdata['qstats'], $questionstats);
|
||||
return array($questions, $quizstats, $questionstats, $qubaids);
|
||||
return [$questions, $quizstats, $questionstats, $qubaids];
|
||||
}
|
||||
return array($questions, $quizstats, $questionstats, $qubaids);
|
||||
return [$questions, $quizstats, $questionstats, $qubaids];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+27
-27
@@ -38,7 +38,7 @@ $page = optional_param('page', 0, PARAM_INT);
|
||||
$showall = optional_param('showall', null, PARAM_BOOL);
|
||||
$cmid = optional_param('cmid', null, PARAM_INT);
|
||||
|
||||
$url = new moodle_url('/mod/quiz/review.php', array('attempt'=>$attemptid));
|
||||
$url = new moodle_url('/mod/quiz/review.php', ['attempt'=>$attemptid]);
|
||||
if ($page !== 0) {
|
||||
$url->param('page', $page);
|
||||
} else if ($showall) {
|
||||
@@ -135,58 +135,58 @@ if ($attempt->state == quiz_attempt::FINISHED) {
|
||||
}
|
||||
|
||||
// Prepare summary informat about the whole attempt.
|
||||
$summarydata = array();
|
||||
$summarydata = [];
|
||||
if (!$attemptobj->get_quiz()->showuserpicture && $attemptobj->get_userid() != $USER->id) {
|
||||
// If showuserpicture is true, the picture is shown elsewhere, so don't repeat it.
|
||||
$student = $DB->get_record('user', array('id' => $attemptobj->get_userid()));
|
||||
$student = $DB->get_record('user', ['id' => $attemptobj->get_userid()]);
|
||||
$userpicture = new user_picture($student);
|
||||
$userpicture->courseid = $attemptobj->get_courseid();
|
||||
$summarydata['user'] = array(
|
||||
$summarydata['user'] = [
|
||||
'title' => $userpicture,
|
||||
'content' => new action_link(new moodle_url('/user/view.php', array(
|
||||
'id' => $student->id, 'course' => $attemptobj->get_courseid())),
|
||||
'content' => new action_link(new moodle_url('/user/view.php', [
|
||||
'id' => $student->id, 'course' => $attemptobj->get_courseid()]),
|
||||
fullname($student, true)),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
if ($attemptobj->has_capability('mod/quiz:viewreports')) {
|
||||
$attemptlist = $attemptobj->links_to_other_attempts($attemptobj->review_url(null, $page,
|
||||
$showall));
|
||||
if ($attemptlist) {
|
||||
$summarydata['attemptlist'] = array(
|
||||
$summarydata['attemptlist'] = [
|
||||
'title' => get_string('attempts', 'quiz'),
|
||||
'content' => $attemptlist,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Timing information.
|
||||
$summarydata['startedon'] = array(
|
||||
$summarydata['startedon'] = [
|
||||
'title' => get_string('startedon', 'quiz'),
|
||||
'content' => userdate($attempt->timestart),
|
||||
);
|
||||
];
|
||||
|
||||
$summarydata['state'] = array(
|
||||
$summarydata['state'] = [
|
||||
'title' => get_string('attemptstate', 'quiz'),
|
||||
'content' => quiz_attempt::state_name($attempt->state),
|
||||
);
|
||||
];
|
||||
|
||||
if ($attempt->state == quiz_attempt::FINISHED) {
|
||||
$summarydata['completedon'] = array(
|
||||
$summarydata['completedon'] = [
|
||||
'title' => get_string('completedon', 'quiz'),
|
||||
'content' => userdate($attempt->timefinish),
|
||||
);
|
||||
$summarydata['timetaken'] = array(
|
||||
];
|
||||
$summarydata['timetaken'] = [
|
||||
'title' => get_string('timetaken', 'quiz'),
|
||||
'content' => $timetaken,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($overtime)) {
|
||||
$summarydata['overdue'] = array(
|
||||
$summarydata['overdue'] = [
|
||||
'title' => get_string('overdue', 'quiz'),
|
||||
'content' => $overtime,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// Show marks (if the user is allowed to see marks at the moment).
|
||||
@@ -197,10 +197,10 @@ if ($options->marks >= question_display_options::MARK_AND_MAX && quiz_has_grades
|
||||
// Cannot display grade.
|
||||
|
||||
} else if (is_null($grade)) {
|
||||
$summarydata['grade'] = array(
|
||||
$summarydata['grade'] = [
|
||||
'title' => get_string('grade', 'quiz'),
|
||||
'content' => quiz_format_grade($quiz, $grade),
|
||||
);
|
||||
];
|
||||
|
||||
} else {
|
||||
// Show raw marks only if they are different from the grade (like on the view page).
|
||||
@@ -208,10 +208,10 @@ if ($options->marks >= question_display_options::MARK_AND_MAX && quiz_has_grades
|
||||
$a = new stdClass();
|
||||
$a->grade = quiz_format_grade($quiz, $attempt->sumgrades);
|
||||
$a->maxgrade = quiz_format_grade($quiz, $quiz->sumgrades);
|
||||
$summarydata['marks'] = array(
|
||||
$summarydata['marks'] = [
|
||||
'title' => get_string('marks', 'quiz'),
|
||||
'content' => get_string('outofshort', 'quiz', $a),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// Now the scaled grade.
|
||||
@@ -228,10 +228,10 @@ if ($options->marks >= question_display_options::MARK_AND_MAX && quiz_has_grades
|
||||
} else {
|
||||
$formattedgrade = get_string('outof', 'quiz', $a);
|
||||
}
|
||||
$summarydata['grade'] = array(
|
||||
$summarydata['grade'] = [
|
||||
'title' => get_string('grade', 'quiz'),
|
||||
'content' => $formattedgrade,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,10 +241,10 @@ $summarydata = array_merge($summarydata, $attemptobj->get_additional_summary_dat
|
||||
// Feedback if there is any, and the user is allowed to see it now.
|
||||
$feedback = $attemptobj->get_overall_feedback($grade);
|
||||
if ($options->overallfeedback && $feedback) {
|
||||
$summarydata['feedback'] = array(
|
||||
$summarydata['feedback'] = [
|
||||
'title' => get_string('feedback', 'quiz'),
|
||||
'content' => $feedback,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// Summary table end. ==============================================================================
|
||||
|
||||
+17
-17
@@ -33,7 +33,7 @@ $seq = optional_param('step', null, PARAM_INT);
|
||||
$cmid = optional_param('cmid', null, PARAM_INT);
|
||||
|
||||
$baseurl = new moodle_url('/mod/quiz/reviewquestion.php',
|
||||
array('attempt' => $attemptid, 'slot' => $slot));
|
||||
['attempt' => $attemptid, 'slot' => $slot]);
|
||||
$currenturl = new moodle_url($baseurl);
|
||||
if (!is_null($seq)) {
|
||||
$currenturl->param('step', $seq);
|
||||
@@ -46,15 +46,15 @@ $attemptobj->preload_all_attempt_step_users();
|
||||
// Check login.
|
||||
require_login($attemptobj->get_course(), false, $attemptobj->get_cm());
|
||||
$attemptobj->check_review_capability();
|
||||
$student = $DB->get_record('user', array('id' => $attemptobj->get_userid()));
|
||||
$student = $DB->get_record('user', ['id' => $attemptobj->get_userid()]);
|
||||
|
||||
$accessmanager = $attemptobj->get_access_manager(time());
|
||||
$options = $attemptobj->get_display_options(true);
|
||||
|
||||
$PAGE->set_pagelayout('popup');
|
||||
$PAGE->set_title(get_string('reviewofquestion', 'quiz', array(
|
||||
$PAGE->set_title(get_string('reviewofquestion', 'quiz', [
|
||||
'question' => format_string($attemptobj->get_question_name($slot)),
|
||||
'quiz' => format_string($attemptobj->get_quiz_name()), 'user' => fullname($student))));
|
||||
'quiz' => format_string($attemptobj->get_quiz_name()), 'user' => fullname($student)]));
|
||||
$PAGE->set_heading($attemptobj->get_course()->fullname);
|
||||
$output = $PAGE->get_renderer('mod_quiz');
|
||||
|
||||
@@ -75,48 +75,48 @@ if ($attemptobj->is_own_attempt()) {
|
||||
}
|
||||
|
||||
// Prepare summary informat about this question attempt.
|
||||
$summarydata = array();
|
||||
$summarydata = [];
|
||||
|
||||
// Student name.
|
||||
$userpicture = new user_picture($student);
|
||||
$userpicture->courseid = $attemptobj->get_courseid();
|
||||
$summarydata['user'] = array(
|
||||
$summarydata['user'] = [
|
||||
'title' => $userpicture,
|
||||
'content' => new action_link(new moodle_url('/user/view.php', array(
|
||||
'id' => $student->id, 'course' => $attemptobj->get_courseid())),
|
||||
'content' => new action_link(new moodle_url('/user/view.php', [
|
||||
'id' => $student->id, 'course' => $attemptobj->get_courseid()]),
|
||||
fullname($student, true)),
|
||||
);
|
||||
];
|
||||
|
||||
// Quiz name.
|
||||
$summarydata['quizname'] = array(
|
||||
$summarydata['quizname'] = [
|
||||
'title' => get_string('modulename', 'quiz'),
|
||||
'content' => format_string($attemptobj->get_quiz_name()),
|
||||
);
|
||||
];
|
||||
|
||||
// Question name.
|
||||
$summarydata['questionname'] = array(
|
||||
$summarydata['questionname'] = [
|
||||
'title' => get_string('question', 'quiz'),
|
||||
'content' => $attemptobj->get_question_name($slot),
|
||||
);
|
||||
];
|
||||
|
||||
// Other attempts at the quiz.
|
||||
if ($attemptobj->has_capability('mod/quiz:viewreports')) {
|
||||
$attemptlist = $attemptobj->links_to_other_attempts($baseurl);
|
||||
if ($attemptlist) {
|
||||
$summarydata['attemptlist'] = array(
|
||||
$summarydata['attemptlist'] = [
|
||||
'title' => get_string('attempts', 'quiz'),
|
||||
'content' => $attemptlist,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Timestamp of this action.
|
||||
$timestamp = $attemptobj->get_question_action_time($slot);
|
||||
if ($timestamp) {
|
||||
$summarydata['timestamp'] = array(
|
||||
$summarydata['timestamp'] = [
|
||||
'title' => get_string('completedon', 'quiz'),
|
||||
'content' => userdate($timestamp),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
echo $output->review_question_page($attemptobj, $slot, $seq,
|
||||
|
||||
+11
-11
@@ -31,7 +31,7 @@ require_once($CFG->dirroot . '/mod/quiz/lib.php');
|
||||
// First get a list of quiz reports with there own settings pages. If there none,
|
||||
// we use a simpler overall menu structure.
|
||||
$reports = core_component::get_plugin_list_with_file('quiz', 'settings.php', false);
|
||||
$reportsbyname = array();
|
||||
$reportsbyname = [];
|
||||
foreach ($reports as $report => $reportdir) {
|
||||
$strreportname = get_string($report . 'report', 'quiz_'.$report);
|
||||
$reportsbyname[$strreportname] = $report;
|
||||
@@ -41,7 +41,7 @@ core_collator::ksort($reportsbyname);
|
||||
// First get a list of quiz reports with there own settings pages. If there none,
|
||||
// we use a simpler overall menu structure.
|
||||
$rules = core_component::get_plugin_list_with_file('quizaccess', 'settings.php', false);
|
||||
$rulesbyname = array();
|
||||
$rulesbyname = [];
|
||||
foreach ($rules as $rule => $ruledir) {
|
||||
$strrulename = get_string('pluginname', 'quizaccess_' . $rule);
|
||||
$rulesbyname[$strrulename] = $rule;
|
||||
@@ -75,7 +75,7 @@ if ($ADMIN->fulltree) {
|
||||
// What to do with overdue attempts.
|
||||
$setting = new \mod_quiz\admin\overdue_handling_setting('quiz/overduehandling',
|
||||
get_string('overduehandling', 'quiz'), get_string('overduehandling_desc', 'quiz'),
|
||||
array('value' => 'autosubmit', 'adv' => false), null);
|
||||
['value' => 'autosubmit', 'adv' => false], null);
|
||||
$setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
|
||||
$quizsettings->add($setting);
|
||||
|
||||
@@ -93,7 +93,7 @@ if ($ADMIN->fulltree) {
|
||||
60, 1));
|
||||
|
||||
// Number of attempts.
|
||||
$options = array(get_string('unlimited'));
|
||||
$options = [get_string('unlimited')];
|
||||
for ($i = 1; $i <= QUIZ_MAX_ATTEMPT_OPTION; $i++) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ if ($ADMIN->fulltree) {
|
||||
// Grading method.
|
||||
$setting = new \mod_quiz\admin\grade_method_setting('quiz/grademethod',
|
||||
get_string('grademethod', 'quiz'), get_string('configgrademethod', 'quiz'),
|
||||
array('value' => QUIZ_GRADEHIGHEST, 'adv' => false), null);
|
||||
['value' => QUIZ_GRADEHIGHEST, 'adv' => false], null);
|
||||
$setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
|
||||
$quizsettings->add($setting);
|
||||
|
||||
@@ -118,7 +118,7 @@ if ($ADMIN->fulltree) {
|
||||
$quizsettings->add($setting);
|
||||
|
||||
// Questions per page.
|
||||
$perpage = array();
|
||||
$perpage = [];
|
||||
$perpage[0] = get_string('never');
|
||||
$perpage[1] = get_string('aftereachquestion', 'quiz');
|
||||
for ($i = 2; $i <= QUIZ_MAX_QPP_OPTION; ++$i) {
|
||||
@@ -158,7 +158,7 @@ if ($ADMIN->fulltree) {
|
||||
$setting = new admin_setting_configselect('quiz/canredoquestions',
|
||||
get_string('canredoquestions', 'quiz'), get_string('canredoquestions_desc', 'quiz'),
|
||||
0,
|
||||
array(0 => get_string('no'), 1 => get_string('canredoquestionsyes', 'quiz')));
|
||||
[0 => get_string('no'), 1 => get_string('canredoquestionsyes', 'quiz')]);
|
||||
$setting->set_advanced_flag_options(admin_setting_flag::ENABLED, true);
|
||||
$setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
|
||||
$quizsettings->add($setting);
|
||||
@@ -191,12 +191,12 @@ if ($ADMIN->fulltree) {
|
||||
// Show the user's picture.
|
||||
$setting = new \mod_quiz\admin\user_image_setting('quiz/showuserpicture',
|
||||
get_string('showuserpicture', 'quiz'), get_string('configshowuserpicture', 'quiz'),
|
||||
array('value' => 0, 'adv' => false), null);
|
||||
['value' => 0, 'adv' => false], null);
|
||||
$setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
|
||||
$quizsettings->add($setting);
|
||||
|
||||
// Decimal places for overall grades.
|
||||
$options = array();
|
||||
$options = [];
|
||||
for ($i = 0; $i <= QUIZ_MAX_DECIMAL_OPTION; $i++) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
@@ -208,7 +208,7 @@ if ($ADMIN->fulltree) {
|
||||
$quizsettings->add($setting);
|
||||
|
||||
// Decimal places for question grades.
|
||||
$options = array(-1 => get_string('sameasoverall', 'quiz'));
|
||||
$options = [-1 => get_string('sameasoverall', 'quiz')];
|
||||
for ($i = 0; $i <= QUIZ_MAX_Q_DECIMAL_OPTION; $i++) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
@@ -262,7 +262,7 @@ if ($ADMIN->fulltree) {
|
||||
// Browser security.
|
||||
$setting = new \mod_quiz\admin\browser_security_setting('quiz/browsersecurity',
|
||||
get_string('showinsecurepopup', 'quiz'), get_string('configpopup', 'quiz'),
|
||||
array('value' => '-', 'adv' => true), null);
|
||||
['value' => '-', 'adv' => true], null);
|
||||
$setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
|
||||
$quizsettings->add($setting);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user