2009-11-04 11:58:30 +00:00
|
|
|
<?php
|
2011-02-21 16:13:25 +00:00
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines the quiz module ettings form.
|
|
|
|
*
|
2014-02-16 11:59:15 +13:00
|
|
|
* @package mod_quiz
|
2011-02-21 16:13:25 +00:00
|
|
|
* @copyright 2006 Jamie Pratt
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
|
2011-02-03 18:06:10 +00:00
|
|
|
|
2011-02-23 15:03:35 +00:00
|
|
|
defined('MOODLE_INTERNAL') || die();
|
2010-05-13 02:02:05 +00:00
|
|
|
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
require_once($CFG->dirroot . '/course/moodleform_mod.php');
|
|
|
|
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
|
|
|
|
2022-12-14 18:07:22 +00:00
|
|
|
use mod_quiz\access_manager;
|
2022-12-07 23:02:31 +00:00
|
|
|
use mod_quiz\question\display_options;
|
2011-02-03 18:06:10 +00:00
|
|
|
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
/**
|
|
|
|
* Settings form for the quiz module.
|
2009-04-22 06:48:15 +00:00
|
|
|
*
|
2011-02-21 16:13:25 +00:00
|
|
|
* @copyright 2006 Jamie Pratt
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
*/
|
2006-12-28 09:32:45 +00:00
|
|
|
class mod_quiz_mod_form extends moodleform_mod {
|
2014-02-28 08:58:58 +01:00
|
|
|
/** @var array options to be used with date_time_selector fields in the quiz. */
|
2023-01-16 17:07:44 +00:00
|
|
|
public static $datefieldoptions = ['optional' => true];
|
2014-02-28 08:58:58 +01:00
|
|
|
|
2023-01-16 18:48:27 +00:00
|
|
|
/** @var array caches the quiz overall feedback, for convenience. */
|
2011-02-03 18:06:10 +00:00
|
|
|
protected $_feedbacks;
|
2023-01-16 18:48:27 +00:00
|
|
|
|
|
|
|
/** @var array for convenience stores the list of types of review option. Initialised in the constructor. */
|
|
|
|
protected static $reviewfields = [];
|
2011-02-03 18:06:10 +00:00
|
|
|
|
2014-09-14 14:14:11 +01:00
|
|
|
/** @var int the max number of attempts allowed in any user or group override on this quiz. */
|
|
|
|
protected $maxattemptsanyoverride = null;
|
|
|
|
|
2011-02-04 15:47:52 +00:00
|
|
|
public function __construct($current, $section, $cm, $course) {
|
2023-01-16 17:07:44 +00:00
|
|
|
self::$reviewfields = [
|
|
|
|
'attempt' => ['theattempt', 'quiz'],
|
|
|
|
'correctness' => ['whethercorrect', 'question'],
|
|
|
|
'marks' => ['marks', 'quiz'],
|
|
|
|
'specificfeedback' => ['specificfeedback', 'question'],
|
|
|
|
'generalfeedback' => ['generalfeedback', 'question'],
|
|
|
|
'rightanswer' => ['rightanswer', 'question'],
|
|
|
|
'overallfeedback' => ['reviewoverallfeedback', 'quiz'],
|
|
|
|
];
|
2011-02-04 15:47:52 +00:00
|
|
|
parent::__construct($current, $section, $cm, $course);
|
2011-02-03 18:06:10 +00:00
|
|
|
}
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2011-03-23 16:22:25 +00:00
|
|
|
protected function definition() {
|
2023-01-16 18:48:27 +00:00
|
|
|
global $CFG, $DB, $PAGE;
|
2008-08-26 01:05:01 +00:00
|
|
|
$quizconfig = get_config('quiz');
|
2011-02-03 18:06:10 +00:00
|
|
|
$mform = $this->_form;
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2012-05-04 12:40:21 +01:00
|
|
|
// -------------------------------------------------------------------------------
|
2006-12-19 07:03:08 +00:00
|
|
|
$mform->addElement('header', 'general', get_string('general', 'form'));
|
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
// Name.
|
2023-01-16 18:32:04 +00:00
|
|
|
$mform->addElement('text', 'name', get_string('name'), ['size' => '64']);
|
2008-07-26 15:15:25 +00:00
|
|
|
if (!empty($CFG->formatstringstriptags)) {
|
|
|
|
$mform->setType('name', PARAM_TEXT);
|
|
|
|
} else {
|
2010-09-02 18:29:39 +00:00
|
|
|
$mform->setType('name', PARAM_CLEANHTML);
|
2008-07-26 15:15:25 +00:00
|
|
|
}
|
2007-08-03 10:33:29 +00:00
|
|
|
$mform->addRule('name', null, 'required', null, 'client');
|
2013-04-30 17:39:56 +01:00
|
|
|
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
// Introduction.
|
2015-03-17 09:28:16 +00:00
|
|
|
$this->standard_intro_elements(get_string('introduction', 'quiz'));
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2012-05-04 12:40:21 +01:00
|
|
|
// -------------------------------------------------------------------------------
|
2011-11-10 17:25:49 +00:00
|
|
|
$mform->addElement('header', 'timing', get_string('timing', 'quiz'));
|
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
// Open and close dates.
|
2011-02-03 18:06:10 +00:00
|
|
|
$mform->addElement('date_time_selector', 'timeopen', get_string('quizopen', 'quiz'),
|
2014-02-28 08:58:58 +01:00
|
|
|
self::$datefieldoptions);
|
2011-02-04 15:47:52 +00:00
|
|
|
$mform->addHelpButton('timeopen', 'quizopenclose', 'quiz');
|
2011-02-03 18:06:10 +00:00
|
|
|
|
|
|
|
$mform->addElement('date_time_selector', 'timeclose', get_string('quizclose', 'quiz'),
|
2014-02-28 08:58:58 +01:00
|
|
|
self::$datefieldoptions);
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
// Time limit.
|
|
|
|
$mform->addElement('duration', 'timelimit', get_string('timelimit', 'quiz'),
|
2023-01-16 17:07:44 +00:00
|
|
|
['optional' => true]);
|
MDL-21695 quiz: deprecated setHelpButton() and old_help_icon() replaced with new calls
Some help icons dropped without replacement as suggested by Helen, the
Help Writer. Some strings moved to core_question.
AMOS BEGIN
HLP quiz/timelimit.html,[timelimit_help,mod_quiz]
HLP quiz/grademethod.html,[grademethod_help,mod_quiz]
HLP quiz/questionsperpage.html,[newpage_help,mod_quiz]
HLP quiz/shufflewithin.html,[shufflewithin_help,mod_quiz]
HLP quiz/penaltyscheme.html,[penaltyscheme_help,mod_quiz]
HLP quiz/repeatattempts.html,[eachattemptbuildsonthelast_help,mod_quiz]
HLP quiz/reviewoptions.html,[reviewoptionsheading_help,mod_quiz]
HLP quiz/showuserpicture.html,[showuserpicture_help,mod_quiz]
HLP quiz/decimalpoints.html,[decimalplaces_help,mod_quiz]
HLP quiz/decimalplacesquestion.html,[decimalplacesquestion_help,mod_quiz]
HLP quiz/requirepassword.html,[requirepassword_help,mod_quiz]
HLP quiz/requiresubnet.html,[requiresubnet_help,mod_quiz]
HLP quiz/timedelay1.html,[delay1st2nd_help,mod_quiz]
HLP quiz/timedelay2.html,[delaylater_help,mod_quiz]
HLP quiz/overallfeedback.html,[overallfeedback_help,mod_quiz]
HLP quiz_statistics/negcovar.html,[negcovar_help,quiz_statistics]
MOV [penaltyfactor,mod_quiz],[penaltyfactor,core_question]
MOV [penaltyfactor_help,mod_quiz],[penaltyfactor_help,core_question]
HLP quiz/penalty.html,[penaltyfactor_help,core_question]
AMOS END
2010-08-02 20:56:15 +00:00
|
|
|
$mform->addHelpButton('timelimit', 'timelimit', 'quiz');
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2011-11-10 18:27:31 +00:00
|
|
|
// What to do with overdue attempts.
|
|
|
|
$mform->addElement('select', 'overduehandling', get_string('overduehandling', 'quiz'),
|
|
|
|
quiz_get_overdue_handling_options());
|
2012-06-07 17:33:46 +01:00
|
|
|
$mform->addHelpButton('overduehandling', 'overduehandling', 'quiz');
|
2012-04-30 10:24:02 +08:00
|
|
|
// TODO Formslib does OR logic on disableif, and we need AND logic here.
|
2011-11-10 18:27:31 +00:00
|
|
|
// $mform->disabledIf('overduehandling', 'timelimit', 'eq', 0);
|
|
|
|
// $mform->disabledIf('overduehandling', 'timeclose', 'eq', 0);
|
|
|
|
|
|
|
|
// Grace period time.
|
|
|
|
$mform->addElement('duration', 'graceperiod', get_string('graceperiod', 'quiz'),
|
2023-01-16 17:07:44 +00:00
|
|
|
['optional' => true]);
|
2011-11-10 18:27:31 +00:00
|
|
|
$mform->addHelpButton('graceperiod', 'graceperiod', 'quiz');
|
2019-02-27 08:42:59 +00:00
|
|
|
$mform->hideIf('graceperiod', 'overduehandling', 'neq', 'graceperiod');
|
2011-11-10 18:27:31 +00:00
|
|
|
|
2012-05-04 12:40:21 +01:00
|
|
|
// -------------------------------------------------------------------------------
|
|
|
|
// Grade settings.
|
2011-11-10 17:25:49 +00:00
|
|
|
$this->standard_grading_coursemodule_elements();
|
|
|
|
|
|
|
|
$mform->removeElement('grade');
|
2014-11-10 17:34:22 +00:00
|
|
|
if (property_exists($this->current, 'grade')) {
|
|
|
|
$currentgrade = $this->current->grade;
|
|
|
|
} else {
|
|
|
|
$currentgrade = $quizconfig->maximumgrade;
|
|
|
|
}
|
|
|
|
$mform->addElement('hidden', 'grade', $currentgrade);
|
2012-05-11 11:34:34 +08:00
|
|
|
$mform->setType('grade', PARAM_FLOAT);
|
2011-11-10 17:25:49 +00:00
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
// Number of attempts.
|
2023-01-16 17:07:44 +00:00
|
|
|
$attemptoptions = ['0' => get_string('unlimited')];
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
for ($i = 1; $i <= QUIZ_MAX_ATTEMPT_OPTION; $i++) {
|
|
|
|
$attemptoptions[$i] = $i;
|
2006-12-19 07:03:08 +00:00
|
|
|
}
|
2011-05-13 00:33:44 +01:00
|
|
|
$mform->addElement('select', 'attempts', get_string('attemptsallowed', 'quiz'),
|
|
|
|
$attemptoptions);
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
// Grading method.
|
|
|
|
$mform->addElement('select', 'grademethod', get_string('grademethod', 'quiz'),
|
|
|
|
quiz_get_grading_options());
|
MDL-21695 quiz: deprecated setHelpButton() and old_help_icon() replaced with new calls
Some help icons dropped without replacement as suggested by Helen, the
Help Writer. Some strings moved to core_question.
AMOS BEGIN
HLP quiz/timelimit.html,[timelimit_help,mod_quiz]
HLP quiz/grademethod.html,[grademethod_help,mod_quiz]
HLP quiz/questionsperpage.html,[newpage_help,mod_quiz]
HLP quiz/shufflewithin.html,[shufflewithin_help,mod_quiz]
HLP quiz/penaltyscheme.html,[penaltyscheme_help,mod_quiz]
HLP quiz/repeatattempts.html,[eachattemptbuildsonthelast_help,mod_quiz]
HLP quiz/reviewoptions.html,[reviewoptionsheading_help,mod_quiz]
HLP quiz/showuserpicture.html,[showuserpicture_help,mod_quiz]
HLP quiz/decimalpoints.html,[decimalplaces_help,mod_quiz]
HLP quiz/decimalplacesquestion.html,[decimalplacesquestion_help,mod_quiz]
HLP quiz/requirepassword.html,[requirepassword_help,mod_quiz]
HLP quiz/requiresubnet.html,[requiresubnet_help,mod_quiz]
HLP quiz/timedelay1.html,[delay1st2nd_help,mod_quiz]
HLP quiz/timedelay2.html,[delaylater_help,mod_quiz]
HLP quiz/overallfeedback.html,[overallfeedback_help,mod_quiz]
HLP quiz_statistics/negcovar.html,[negcovar_help,quiz_statistics]
MOV [penaltyfactor,mod_quiz],[penaltyfactor,core_question]
MOV [penaltyfactor_help,mod_quiz],[penaltyfactor_help,core_question]
HLP quiz/penalty.html,[penaltyfactor_help,core_question]
AMOS END
2010-08-02 20:56:15 +00:00
|
|
|
$mform->addHelpButton('grademethod', 'grademethod', 'quiz');
|
2014-09-14 14:14:11 +01:00
|
|
|
if ($this->get_max_attempts_for_any_override() < 2) {
|
2019-02-27 08:42:59 +00:00
|
|
|
$mform->hideIf('grademethod', 'attempts', 'eq', 1);
|
2014-09-14 14:14:11 +01:00
|
|
|
}
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
|
2012-05-04 12:40:21 +01:00
|
|
|
// -------------------------------------------------------------------------------
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
$mform->addElement('header', 'layouthdr', get_string('layout', 'quiz'));
|
|
|
|
|
2023-01-16 17:07:44 +00:00
|
|
|
$pagegroup = [];
|
2011-05-13 00:33:44 +01:00
|
|
|
$pagegroup[] = $mform->createElement('select', 'questionsperpage',
|
2023-01-16 17:07:44 +00:00
|
|
|
get_string('newpage', 'quiz'), quiz_questions_per_page_options(), ['id' => 'id_questionsperpage']);
|
2020-06-09 09:24:19 -04:00
|
|
|
$mform->setDefault('questionsperpage', $quizconfig->questionsperpage);
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2022-03-12 16:21:53 +00:00
|
|
|
if (!empty($this->_cm) && !quiz_has_attempts($this->_cm->instance)) {
|
2011-05-13 00:33:44 +01:00
|
|
|
$pagegroup[] = $mform->createElement('checkbox', 'repaginatenow', '',
|
2023-01-16 17:07:44 +00:00
|
|
|
get_string('repaginatenow', 'quiz'), ['id' => 'id_repaginatenow']);
|
2009-03-17 07:08:33 +00:00
|
|
|
}
|
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
$mform->addGroup($pagegroup, 'questionsperpagegrp',
|
|
|
|
get_string('newpage', 'quiz'), null, false);
|
MDL-21695 quiz: deprecated setHelpButton() and old_help_icon() replaced with new calls
Some help icons dropped without replacement as suggested by Helen, the
Help Writer. Some strings moved to core_question.
AMOS BEGIN
HLP quiz/timelimit.html,[timelimit_help,mod_quiz]
HLP quiz/grademethod.html,[grademethod_help,mod_quiz]
HLP quiz/questionsperpage.html,[newpage_help,mod_quiz]
HLP quiz/shufflewithin.html,[shufflewithin_help,mod_quiz]
HLP quiz/penaltyscheme.html,[penaltyscheme_help,mod_quiz]
HLP quiz/repeatattempts.html,[eachattemptbuildsonthelast_help,mod_quiz]
HLP quiz/reviewoptions.html,[reviewoptionsheading_help,mod_quiz]
HLP quiz/showuserpicture.html,[showuserpicture_help,mod_quiz]
HLP quiz/decimalpoints.html,[decimalplaces_help,mod_quiz]
HLP quiz/decimalplacesquestion.html,[decimalplacesquestion_help,mod_quiz]
HLP quiz/requirepassword.html,[requirepassword_help,mod_quiz]
HLP quiz/requiresubnet.html,[requiresubnet_help,mod_quiz]
HLP quiz/timedelay1.html,[delay1st2nd_help,mod_quiz]
HLP quiz/timedelay2.html,[delaylater_help,mod_quiz]
HLP quiz/overallfeedback.html,[overallfeedback_help,mod_quiz]
HLP quiz_statistics/negcovar.html,[negcovar_help,quiz_statistics]
MOV [penaltyfactor,mod_quiz],[penaltyfactor,core_question]
MOV [penaltyfactor_help,mod_quiz],[penaltyfactor_help,core_question]
HLP quiz/penalty.html,[penaltyfactor_help,core_question]
AMOS END
2010-08-02 20:56:15 +00:00
|
|
|
$mform->addHelpButton('questionsperpagegrp', 'newpage', 'quiz');
|
2020-06-09 09:24:19 -04:00
|
|
|
$mform->setAdvanced('questionsperpagegrp', $quizconfig->questionsperpage_adv);
|
2009-03-17 07:08:33 +00:00
|
|
|
|
2012-05-04 12:40:21 +01:00
|
|
|
// Navigation method.
|
2012-01-20 16:52:17 -08:00
|
|
|
$mform->addElement('select', 'navmethod', get_string('navmethod', 'quiz'),
|
|
|
|
quiz_get_navigation_options());
|
|
|
|
$mform->addHelpButton('navmethod', 'navmethod', 'quiz');
|
|
|
|
|
2012-05-04 12:40:21 +01:00
|
|
|
// -------------------------------------------------------------------------------
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
$mform->addElement('header', 'interactionhdr', get_string('questionbehaviour', 'quiz'));
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
// Shuffle within questions.
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
$mform->addElement('selectyesno', 'shuffleanswers', get_string('shufflewithin', 'quiz'));
|
MDL-21695 quiz: deprecated setHelpButton() and old_help_icon() replaced with new calls
Some help icons dropped without replacement as suggested by Helen, the
Help Writer. Some strings moved to core_question.
AMOS BEGIN
HLP quiz/timelimit.html,[timelimit_help,mod_quiz]
HLP quiz/grademethod.html,[grademethod_help,mod_quiz]
HLP quiz/questionsperpage.html,[newpage_help,mod_quiz]
HLP quiz/shufflewithin.html,[shufflewithin_help,mod_quiz]
HLP quiz/penaltyscheme.html,[penaltyscheme_help,mod_quiz]
HLP quiz/repeatattempts.html,[eachattemptbuildsonthelast_help,mod_quiz]
HLP quiz/reviewoptions.html,[reviewoptionsheading_help,mod_quiz]
HLP quiz/showuserpicture.html,[showuserpicture_help,mod_quiz]
HLP quiz/decimalpoints.html,[decimalplaces_help,mod_quiz]
HLP quiz/decimalplacesquestion.html,[decimalplacesquestion_help,mod_quiz]
HLP quiz/requirepassword.html,[requirepassword_help,mod_quiz]
HLP quiz/requiresubnet.html,[requiresubnet_help,mod_quiz]
HLP quiz/timedelay1.html,[delay1st2nd_help,mod_quiz]
HLP quiz/timedelay2.html,[delaylater_help,mod_quiz]
HLP quiz/overallfeedback.html,[overallfeedback_help,mod_quiz]
HLP quiz_statistics/negcovar.html,[negcovar_help,quiz_statistics]
MOV [penaltyfactor,mod_quiz],[penaltyfactor,core_question]
MOV [penaltyfactor_help,mod_quiz],[penaltyfactor_help,core_question]
HLP quiz/penalty.html,[penaltyfactor_help,core_question]
AMOS END
2010-08-02 20:56:15 +00:00
|
|
|
$mform->addHelpButton('shuffleanswers', 'shufflewithin', 'quiz');
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
// How questions behave (question behaviour).
|
2011-02-04 15:47:52 +00:00
|
|
|
if (!empty($this->current->preferredbehaviour)) {
|
|
|
|
$currentbehaviour = $this->current->preferredbehaviour;
|
2011-02-03 18:06:10 +00:00
|
|
|
} else {
|
|
|
|
$currentbehaviour = '';
|
|
|
|
}
|
|
|
|
$behaviours = question_engine::get_behaviour_options($currentbehaviour);
|
2011-05-13 00:33:44 +01:00
|
|
|
$mform->addElement('select', 'preferredbehaviour',
|
|
|
|
get_string('howquestionsbehave', 'question'), $behaviours);
|
2011-02-04 15:47:52 +00:00
|
|
|
$mform->addHelpButton('preferredbehaviour', 'howquestionsbehave', 'question');
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2015-03-09 18:40:18 +00:00
|
|
|
// Can redo completed questions.
|
2023-01-16 17:07:44 +00:00
|
|
|
$redochoices = [0 => get_string('no'), 1 => get_string('canredoquestionsyes', 'quiz')];
|
2015-03-09 18:40:18 +00:00
|
|
|
$mform->addElement('select', 'canredoquestions', get_string('canredoquestions', 'quiz'), $redochoices);
|
|
|
|
$mform->addHelpButton('canredoquestions', 'canredoquestions', 'quiz');
|
2014-12-03 11:24:46 +00:00
|
|
|
foreach ($behaviours as $behaviour => $notused) {
|
2015-03-09 18:40:18 +00:00
|
|
|
if (!question_engine::can_questions_finish_during_the_attempt($behaviour)) {
|
2019-02-27 08:42:59 +00:00
|
|
|
$mform->hideIf('canredoquestions', 'preferredbehaviour', 'eq', $behaviour);
|
2014-12-03 11:24:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
// Each attempt builds on last.
|
|
|
|
$mform->addElement('selectyesno', 'attemptonlast',
|
|
|
|
get_string('eachattemptbuildsonthelast', 'quiz'));
|
MDL-21695 quiz: deprecated setHelpButton() and old_help_icon() replaced with new calls
Some help icons dropped without replacement as suggested by Helen, the
Help Writer. Some strings moved to core_question.
AMOS BEGIN
HLP quiz/timelimit.html,[timelimit_help,mod_quiz]
HLP quiz/grademethod.html,[grademethod_help,mod_quiz]
HLP quiz/questionsperpage.html,[newpage_help,mod_quiz]
HLP quiz/shufflewithin.html,[shufflewithin_help,mod_quiz]
HLP quiz/penaltyscheme.html,[penaltyscheme_help,mod_quiz]
HLP quiz/repeatattempts.html,[eachattemptbuildsonthelast_help,mod_quiz]
HLP quiz/reviewoptions.html,[reviewoptionsheading_help,mod_quiz]
HLP quiz/showuserpicture.html,[showuserpicture_help,mod_quiz]
HLP quiz/decimalpoints.html,[decimalplaces_help,mod_quiz]
HLP quiz/decimalplacesquestion.html,[decimalplacesquestion_help,mod_quiz]
HLP quiz/requirepassword.html,[requirepassword_help,mod_quiz]
HLP quiz/requiresubnet.html,[requiresubnet_help,mod_quiz]
HLP quiz/timedelay1.html,[delay1st2nd_help,mod_quiz]
HLP quiz/timedelay2.html,[delaylater_help,mod_quiz]
HLP quiz/overallfeedback.html,[overallfeedback_help,mod_quiz]
HLP quiz_statistics/negcovar.html,[negcovar_help,quiz_statistics]
MOV [penaltyfactor,mod_quiz],[penaltyfactor,core_question]
MOV [penaltyfactor_help,mod_quiz],[penaltyfactor_help,core_question]
HLP quiz/penalty.html,[penaltyfactor_help,core_question]
AMOS END
2010-08-02 20:56:15 +00:00
|
|
|
$mform->addHelpButton('attemptonlast', 'eachattemptbuildsonthelast', 'quiz');
|
2014-09-14 14:14:11 +01:00
|
|
|
if ($this->get_max_attempts_for_any_override() < 2) {
|
2019-02-27 08:42:59 +00:00
|
|
|
$mform->hideIf('attemptonlast', 'attempts', 'eq', 1);
|
2014-09-14 14:14:11 +01:00
|
|
|
}
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2012-05-04 12:40:21 +01:00
|
|
|
// -------------------------------------------------------------------------------
|
2011-05-13 00:33:44 +01:00
|
|
|
$mform->addElement('header', 'reviewoptionshdr',
|
|
|
|
get_string('reviewoptionsheading', 'quiz'));
|
MDL-21695 quiz: deprecated setHelpButton() and old_help_icon() replaced with new calls
Some help icons dropped without replacement as suggested by Helen, the
Help Writer. Some strings moved to core_question.
AMOS BEGIN
HLP quiz/timelimit.html,[timelimit_help,mod_quiz]
HLP quiz/grademethod.html,[grademethod_help,mod_quiz]
HLP quiz/questionsperpage.html,[newpage_help,mod_quiz]
HLP quiz/shufflewithin.html,[shufflewithin_help,mod_quiz]
HLP quiz/penaltyscheme.html,[penaltyscheme_help,mod_quiz]
HLP quiz/repeatattempts.html,[eachattemptbuildsonthelast_help,mod_quiz]
HLP quiz/reviewoptions.html,[reviewoptionsheading_help,mod_quiz]
HLP quiz/showuserpicture.html,[showuserpicture_help,mod_quiz]
HLP quiz/decimalpoints.html,[decimalplaces_help,mod_quiz]
HLP quiz/decimalplacesquestion.html,[decimalplacesquestion_help,mod_quiz]
HLP quiz/requirepassword.html,[requirepassword_help,mod_quiz]
HLP quiz/requiresubnet.html,[requiresubnet_help,mod_quiz]
HLP quiz/timedelay1.html,[delay1st2nd_help,mod_quiz]
HLP quiz/timedelay2.html,[delaylater_help,mod_quiz]
HLP quiz/overallfeedback.html,[overallfeedback_help,mod_quiz]
HLP quiz_statistics/negcovar.html,[negcovar_help,quiz_statistics]
MOV [penaltyfactor,mod_quiz],[penaltyfactor,core_question]
MOV [penaltyfactor_help,mod_quiz],[penaltyfactor_help,core_question]
HLP quiz/penalty.html,[penaltyfactor_help,core_question]
AMOS END
2010-08-02 20:56:15 +00:00
|
|
|
$mform->addHelpButton('reviewoptionshdr', 'reviewoptionsheading', 'quiz');
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
// Review options.
|
|
|
|
$this->add_review_options_group($mform, $quizconfig, 'during',
|
2022-12-07 23:02:31 +00:00
|
|
|
display_options::DURING, true);
|
2011-05-13 00:33:44 +01:00
|
|
|
$this->add_review_options_group($mform, $quizconfig, 'immediately',
|
2022-12-07 23:02:31 +00:00
|
|
|
display_options::IMMEDIATELY_AFTER);
|
2011-05-13 00:33:44 +01:00
|
|
|
$this->add_review_options_group($mform, $quizconfig, 'open',
|
2022-12-07 23:02:31 +00:00
|
|
|
display_options::LATER_WHILE_OPEN);
|
2011-05-13 00:33:44 +01:00
|
|
|
$this->add_review_options_group($mform, $quizconfig, 'closed',
|
2022-12-07 23:02:31 +00:00
|
|
|
display_options::AFTER_CLOSE);
|
2011-02-03 18:06:10 +00:00
|
|
|
|
|
|
|
foreach ($behaviours as $behaviour => $notused) {
|
|
|
|
$unusedoptions = question_engine::get_behaviour_unused_display_options($behaviour);
|
|
|
|
foreach ($unusedoptions as $unusedoption) {
|
|
|
|
$mform->disabledIf($unusedoption . 'during', 'preferredbehaviour',
|
|
|
|
'eq', $behaviour);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$mform->disabledIf('attemptduring', 'preferredbehaviour',
|
|
|
|
'neq', 'wontmatch');
|
|
|
|
$mform->disabledIf('overallfeedbackduring', 'preferredbehaviour',
|
|
|
|
'neq', 'wontmatch');
|
2017-12-15 13:11:57 +00:00
|
|
|
foreach (self::$reviewfields as $field => $notused) {
|
|
|
|
$mform->disabledIf($field . 'closed', 'timeclose[enabled]');
|
|
|
|
}
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2012-05-04 12:40:21 +01:00
|
|
|
// -------------------------------------------------------------------------------
|
2014-03-28 17:58:48 +00:00
|
|
|
$mform->addElement('header', 'display', get_string('appearance'));
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
// Show user picture.
|
2014-04-25 18:48:05 +01:00
|
|
|
$mform->addElement('select', 'showuserpicture', get_string('showuserpicture', 'quiz'),
|
|
|
|
quiz_get_user_image_options());
|
MDL-21695 quiz: deprecated setHelpButton() and old_help_icon() replaced with new calls
Some help icons dropped without replacement as suggested by Helen, the
Help Writer. Some strings moved to core_question.
AMOS BEGIN
HLP quiz/timelimit.html,[timelimit_help,mod_quiz]
HLP quiz/grademethod.html,[grademethod_help,mod_quiz]
HLP quiz/questionsperpage.html,[newpage_help,mod_quiz]
HLP quiz/shufflewithin.html,[shufflewithin_help,mod_quiz]
HLP quiz/penaltyscheme.html,[penaltyscheme_help,mod_quiz]
HLP quiz/repeatattempts.html,[eachattemptbuildsonthelast_help,mod_quiz]
HLP quiz/reviewoptions.html,[reviewoptionsheading_help,mod_quiz]
HLP quiz/showuserpicture.html,[showuserpicture_help,mod_quiz]
HLP quiz/decimalpoints.html,[decimalplaces_help,mod_quiz]
HLP quiz/decimalplacesquestion.html,[decimalplacesquestion_help,mod_quiz]
HLP quiz/requirepassword.html,[requirepassword_help,mod_quiz]
HLP quiz/requiresubnet.html,[requiresubnet_help,mod_quiz]
HLP quiz/timedelay1.html,[delay1st2nd_help,mod_quiz]
HLP quiz/timedelay2.html,[delaylater_help,mod_quiz]
HLP quiz/overallfeedback.html,[overallfeedback_help,mod_quiz]
HLP quiz_statistics/negcovar.html,[negcovar_help,quiz_statistics]
MOV [penaltyfactor,mod_quiz],[penaltyfactor,core_question]
MOV [penaltyfactor_help,mod_quiz],[penaltyfactor_help,core_question]
HLP quiz/penalty.html,[penaltyfactor_help,core_question]
AMOS END
2010-08-02 20:56:15 +00:00
|
|
|
$mform->addHelpButton('showuserpicture', 'showuserpicture', 'quiz');
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
// Overall decimal points.
|
2023-01-16 17:07:44 +00:00
|
|
|
$options = [];
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
for ($i = 0; $i <= QUIZ_MAX_DECIMAL_OPTION; $i++) {
|
|
|
|
$options[$i] = $i;
|
|
|
|
}
|
2011-05-13 00:33:44 +01:00
|
|
|
$mform->addElement('select', 'decimalpoints', get_string('decimalplaces', 'quiz'),
|
|
|
|
$options);
|
MDL-21695 quiz: deprecated setHelpButton() and old_help_icon() replaced with new calls
Some help icons dropped without replacement as suggested by Helen, the
Help Writer. Some strings moved to core_question.
AMOS BEGIN
HLP quiz/timelimit.html,[timelimit_help,mod_quiz]
HLP quiz/grademethod.html,[grademethod_help,mod_quiz]
HLP quiz/questionsperpage.html,[newpage_help,mod_quiz]
HLP quiz/shufflewithin.html,[shufflewithin_help,mod_quiz]
HLP quiz/penaltyscheme.html,[penaltyscheme_help,mod_quiz]
HLP quiz/repeatattempts.html,[eachattemptbuildsonthelast_help,mod_quiz]
HLP quiz/reviewoptions.html,[reviewoptionsheading_help,mod_quiz]
HLP quiz/showuserpicture.html,[showuserpicture_help,mod_quiz]
HLP quiz/decimalpoints.html,[decimalplaces_help,mod_quiz]
HLP quiz/decimalplacesquestion.html,[decimalplacesquestion_help,mod_quiz]
HLP quiz/requirepassword.html,[requirepassword_help,mod_quiz]
HLP quiz/requiresubnet.html,[requiresubnet_help,mod_quiz]
HLP quiz/timedelay1.html,[delay1st2nd_help,mod_quiz]
HLP quiz/timedelay2.html,[delaylater_help,mod_quiz]
HLP quiz/overallfeedback.html,[overallfeedback_help,mod_quiz]
HLP quiz_statistics/negcovar.html,[negcovar_help,quiz_statistics]
MOV [penaltyfactor,mod_quiz],[penaltyfactor,core_question]
MOV [penaltyfactor_help,mod_quiz],[penaltyfactor_help,core_question]
HLP quiz/penalty.html,[penaltyfactor_help,core_question]
AMOS END
2010-08-02 20:56:15 +00:00
|
|
|
$mform->addHelpButton('decimalpoints', 'decimalplaces', 'quiz');
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
// Question decimal points.
|
2023-01-16 17:07:44 +00:00
|
|
|
$options = [-1 => get_string('sameasoverall', 'quiz')];
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
for ($i = 0; $i <= QUIZ_MAX_Q_DECIMAL_OPTION; $i++) {
|
|
|
|
$options[$i] = $i;
|
|
|
|
}
|
2011-05-13 00:33:44 +01:00
|
|
|
$mform->addElement('select', 'questiondecimalpoints',
|
|
|
|
get_string('decimalplacesquestion', 'quiz'), $options);
|
2011-05-12 00:30:25 +01:00
|
|
|
$mform->addHelpButton('questiondecimalpoints', 'decimalplacesquestion', 'quiz');
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
|
2012-05-04 12:40:21 +01:00
|
|
|
// Show blocks during quiz attempt.
|
2010-05-21 03:15:48 +00:00
|
|
|
$mform->addElement('selectyesno', 'showblocks', get_string('showblocks', 'quiz'));
|
MDL-21695 quiz: deprecated setHelpButton() and old_help_icon() replaced with new calls
Some help icons dropped without replacement as suggested by Helen, the
Help Writer. Some strings moved to core_question.
AMOS BEGIN
HLP quiz/timelimit.html,[timelimit_help,mod_quiz]
HLP quiz/grademethod.html,[grademethod_help,mod_quiz]
HLP quiz/questionsperpage.html,[newpage_help,mod_quiz]
HLP quiz/shufflewithin.html,[shufflewithin_help,mod_quiz]
HLP quiz/penaltyscheme.html,[penaltyscheme_help,mod_quiz]
HLP quiz/repeatattempts.html,[eachattemptbuildsonthelast_help,mod_quiz]
HLP quiz/reviewoptions.html,[reviewoptionsheading_help,mod_quiz]
HLP quiz/showuserpicture.html,[showuserpicture_help,mod_quiz]
HLP quiz/decimalpoints.html,[decimalplaces_help,mod_quiz]
HLP quiz/decimalplacesquestion.html,[decimalplacesquestion_help,mod_quiz]
HLP quiz/requirepassword.html,[requirepassword_help,mod_quiz]
HLP quiz/requiresubnet.html,[requiresubnet_help,mod_quiz]
HLP quiz/timedelay1.html,[delay1st2nd_help,mod_quiz]
HLP quiz/timedelay2.html,[delaylater_help,mod_quiz]
HLP quiz/overallfeedback.html,[overallfeedback_help,mod_quiz]
HLP quiz_statistics/negcovar.html,[negcovar_help,quiz_statistics]
MOV [penaltyfactor,mod_quiz],[penaltyfactor,core_question]
MOV [penaltyfactor_help,mod_quiz],[penaltyfactor_help,core_question]
HLP quiz/penalty.html,[penaltyfactor_help,core_question]
AMOS END
2010-08-02 20:56:15 +00:00
|
|
|
$mform->addHelpButton('showblocks', 'showblocks', 'quiz');
|
2010-05-21 03:15:48 +00:00
|
|
|
|
2012-05-04 12:40:21 +01:00
|
|
|
// -------------------------------------------------------------------------------
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
$mform->addElement('header', 'security', get_string('extraattemptrestrictions', 'quiz'));
|
|
|
|
|
2012-01-31 14:39:23 -05:00
|
|
|
// Require password to begin quiz attempt.
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
$mform->addElement('passwordunmask', 'quizpassword', get_string('requirepassword', 'quiz'));
|
2007-05-08 16:11:58 +00:00
|
|
|
$mform->setType('quizpassword', PARAM_TEXT);
|
MDL-21695 quiz: deprecated setHelpButton() and old_help_icon() replaced with new calls
Some help icons dropped without replacement as suggested by Helen, the
Help Writer. Some strings moved to core_question.
AMOS BEGIN
HLP quiz/timelimit.html,[timelimit_help,mod_quiz]
HLP quiz/grademethod.html,[grademethod_help,mod_quiz]
HLP quiz/questionsperpage.html,[newpage_help,mod_quiz]
HLP quiz/shufflewithin.html,[shufflewithin_help,mod_quiz]
HLP quiz/penaltyscheme.html,[penaltyscheme_help,mod_quiz]
HLP quiz/repeatattempts.html,[eachattemptbuildsonthelast_help,mod_quiz]
HLP quiz/reviewoptions.html,[reviewoptionsheading_help,mod_quiz]
HLP quiz/showuserpicture.html,[showuserpicture_help,mod_quiz]
HLP quiz/decimalpoints.html,[decimalplaces_help,mod_quiz]
HLP quiz/decimalplacesquestion.html,[decimalplacesquestion_help,mod_quiz]
HLP quiz/requirepassword.html,[requirepassword_help,mod_quiz]
HLP quiz/requiresubnet.html,[requiresubnet_help,mod_quiz]
HLP quiz/timedelay1.html,[delay1st2nd_help,mod_quiz]
HLP quiz/timedelay2.html,[delaylater_help,mod_quiz]
HLP quiz/overallfeedback.html,[overallfeedback_help,mod_quiz]
HLP quiz_statistics/negcovar.html,[negcovar_help,quiz_statistics]
MOV [penaltyfactor,mod_quiz],[penaltyfactor,core_question]
MOV [penaltyfactor_help,mod_quiz],[penaltyfactor_help,core_question]
HLP quiz/penalty.html,[penaltyfactor_help,core_question]
AMOS END
2010-08-02 20:56:15 +00:00
|
|
|
$mform->addHelpButton('quizpassword', 'requirepassword', 'quiz');
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
// IP address.
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
$mform->addElement('text', 'subnet', get_string('requiresubnet', 'quiz'));
|
2007-05-08 16:11:58 +00:00
|
|
|
$mform->setType('subnet', PARAM_TEXT);
|
MDL-21695 quiz: deprecated setHelpButton() and old_help_icon() replaced with new calls
Some help icons dropped without replacement as suggested by Helen, the
Help Writer. Some strings moved to core_question.
AMOS BEGIN
HLP quiz/timelimit.html,[timelimit_help,mod_quiz]
HLP quiz/grademethod.html,[grademethod_help,mod_quiz]
HLP quiz/questionsperpage.html,[newpage_help,mod_quiz]
HLP quiz/shufflewithin.html,[shufflewithin_help,mod_quiz]
HLP quiz/penaltyscheme.html,[penaltyscheme_help,mod_quiz]
HLP quiz/repeatattempts.html,[eachattemptbuildsonthelast_help,mod_quiz]
HLP quiz/reviewoptions.html,[reviewoptionsheading_help,mod_quiz]
HLP quiz/showuserpicture.html,[showuserpicture_help,mod_quiz]
HLP quiz/decimalpoints.html,[decimalplaces_help,mod_quiz]
HLP quiz/decimalplacesquestion.html,[decimalplacesquestion_help,mod_quiz]
HLP quiz/requirepassword.html,[requirepassword_help,mod_quiz]
HLP quiz/requiresubnet.html,[requiresubnet_help,mod_quiz]
HLP quiz/timedelay1.html,[delay1st2nd_help,mod_quiz]
HLP quiz/timedelay2.html,[delaylater_help,mod_quiz]
HLP quiz/overallfeedback.html,[overallfeedback_help,mod_quiz]
HLP quiz_statistics/negcovar.html,[negcovar_help,quiz_statistics]
MOV [penaltyfactor,mod_quiz],[penaltyfactor,core_question]
MOV [penaltyfactor_help,mod_quiz],[penaltyfactor_help,core_question]
HLP quiz/penalty.html,[penaltyfactor_help,core_question]
AMOS END
2010-08-02 20:56:15 +00:00
|
|
|
$mform->addHelpButton('subnet', 'requiresubnet', 'quiz');
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
// Enforced time delay between quiz attempts.
|
|
|
|
$mform->addElement('duration', 'delay1', get_string('delay1st2nd', 'quiz'),
|
2023-01-16 17:07:44 +00:00
|
|
|
['optional' => true]);
|
MDL-21695 quiz: deprecated setHelpButton() and old_help_icon() replaced with new calls
Some help icons dropped without replacement as suggested by Helen, the
Help Writer. Some strings moved to core_question.
AMOS BEGIN
HLP quiz/timelimit.html,[timelimit_help,mod_quiz]
HLP quiz/grademethod.html,[grademethod_help,mod_quiz]
HLP quiz/questionsperpage.html,[newpage_help,mod_quiz]
HLP quiz/shufflewithin.html,[shufflewithin_help,mod_quiz]
HLP quiz/penaltyscheme.html,[penaltyscheme_help,mod_quiz]
HLP quiz/repeatattempts.html,[eachattemptbuildsonthelast_help,mod_quiz]
HLP quiz/reviewoptions.html,[reviewoptionsheading_help,mod_quiz]
HLP quiz/showuserpicture.html,[showuserpicture_help,mod_quiz]
HLP quiz/decimalpoints.html,[decimalplaces_help,mod_quiz]
HLP quiz/decimalplacesquestion.html,[decimalplacesquestion_help,mod_quiz]
HLP quiz/requirepassword.html,[requirepassword_help,mod_quiz]
HLP quiz/requiresubnet.html,[requiresubnet_help,mod_quiz]
HLP quiz/timedelay1.html,[delay1st2nd_help,mod_quiz]
HLP quiz/timedelay2.html,[delaylater_help,mod_quiz]
HLP quiz/overallfeedback.html,[overallfeedback_help,mod_quiz]
HLP quiz_statistics/negcovar.html,[negcovar_help,quiz_statistics]
MOV [penaltyfactor,mod_quiz],[penaltyfactor,core_question]
MOV [penaltyfactor_help,mod_quiz],[penaltyfactor_help,core_question]
HLP quiz/penalty.html,[penaltyfactor_help,core_question]
AMOS END
2010-08-02 20:56:15 +00:00
|
|
|
$mform->addHelpButton('delay1', 'delay1st2nd', 'quiz');
|
2014-09-14 14:14:11 +01:00
|
|
|
if ($this->get_max_attempts_for_any_override() < 2) {
|
2019-02-27 08:42:59 +00:00
|
|
|
$mform->hideIf('delay1', 'attempts', 'eq', 1);
|
2014-09-14 14:14:11 +01:00
|
|
|
}
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
$mform->addElement('duration', 'delay2', get_string('delaylater', 'quiz'),
|
2023-01-16 17:07:44 +00:00
|
|
|
['optional' => true]);
|
MDL-21695 quiz: deprecated setHelpButton() and old_help_icon() replaced with new calls
Some help icons dropped without replacement as suggested by Helen, the
Help Writer. Some strings moved to core_question.
AMOS BEGIN
HLP quiz/timelimit.html,[timelimit_help,mod_quiz]
HLP quiz/grademethod.html,[grademethod_help,mod_quiz]
HLP quiz/questionsperpage.html,[newpage_help,mod_quiz]
HLP quiz/shufflewithin.html,[shufflewithin_help,mod_quiz]
HLP quiz/penaltyscheme.html,[penaltyscheme_help,mod_quiz]
HLP quiz/repeatattempts.html,[eachattemptbuildsonthelast_help,mod_quiz]
HLP quiz/reviewoptions.html,[reviewoptionsheading_help,mod_quiz]
HLP quiz/showuserpicture.html,[showuserpicture_help,mod_quiz]
HLP quiz/decimalpoints.html,[decimalplaces_help,mod_quiz]
HLP quiz/decimalplacesquestion.html,[decimalplacesquestion_help,mod_quiz]
HLP quiz/requirepassword.html,[requirepassword_help,mod_quiz]
HLP quiz/requiresubnet.html,[requiresubnet_help,mod_quiz]
HLP quiz/timedelay1.html,[delay1st2nd_help,mod_quiz]
HLP quiz/timedelay2.html,[delaylater_help,mod_quiz]
HLP quiz/overallfeedback.html,[overallfeedback_help,mod_quiz]
HLP quiz_statistics/negcovar.html,[negcovar_help,quiz_statistics]
MOV [penaltyfactor,mod_quiz],[penaltyfactor,core_question]
MOV [penaltyfactor_help,mod_quiz],[penaltyfactor_help,core_question]
HLP quiz/penalty.html,[penaltyfactor_help,core_question]
AMOS END
2010-08-02 20:56:15 +00:00
|
|
|
$mform->addHelpButton('delay2', 'delaylater', 'quiz');
|
2014-09-14 14:14:11 +01:00
|
|
|
if ($this->get_max_attempts_for_any_override() < 3) {
|
2019-02-27 08:42:59 +00:00
|
|
|
$mform->hideIf('delay2', 'attempts', 'eq', 1);
|
|
|
|
$mform->hideIf('delay2', 'attempts', 'eq', 2);
|
2014-09-14 14:14:11 +01:00
|
|
|
}
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
|
2012-05-04 12:40:21 +01:00
|
|
|
// Browser security choices.
|
2011-10-06 20:15:01 +01:00
|
|
|
$mform->addElement('select', 'browsersecurity', get_string('browsersecurity', 'quiz'),
|
2022-12-14 18:07:22 +00:00
|
|
|
access_manager::get_browser_security_choices());
|
2011-10-06 20:15:01 +01:00
|
|
|
$mform->addHelpButton('browsersecurity', 'browsersecurity', 'quiz');
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
|
2011-10-05 11:47:37 +01:00
|
|
|
// Any other rule plugins.
|
2022-12-14 18:07:22 +00:00
|
|
|
access_manager::add_settings_form_fields($this, $mform);
|
2011-10-05 11:47:37 +01:00
|
|
|
|
2012-05-04 12:40:21 +01:00
|
|
|
// -------------------------------------------------------------------------------
|
2007-01-08 13:58:42 +00:00
|
|
|
$mform->addElement('header', 'overallfeedbackhdr', get_string('overallfeedback', 'quiz'));
|
MDL-21695 quiz: deprecated setHelpButton() and old_help_icon() replaced with new calls
Some help icons dropped without replacement as suggested by Helen, the
Help Writer. Some strings moved to core_question.
AMOS BEGIN
HLP quiz/timelimit.html,[timelimit_help,mod_quiz]
HLP quiz/grademethod.html,[grademethod_help,mod_quiz]
HLP quiz/questionsperpage.html,[newpage_help,mod_quiz]
HLP quiz/shufflewithin.html,[shufflewithin_help,mod_quiz]
HLP quiz/penaltyscheme.html,[penaltyscheme_help,mod_quiz]
HLP quiz/repeatattempts.html,[eachattemptbuildsonthelast_help,mod_quiz]
HLP quiz/reviewoptions.html,[reviewoptionsheading_help,mod_quiz]
HLP quiz/showuserpicture.html,[showuserpicture_help,mod_quiz]
HLP quiz/decimalpoints.html,[decimalplaces_help,mod_quiz]
HLP quiz/decimalplacesquestion.html,[decimalplacesquestion_help,mod_quiz]
HLP quiz/requirepassword.html,[requirepassword_help,mod_quiz]
HLP quiz/requiresubnet.html,[requiresubnet_help,mod_quiz]
HLP quiz/timedelay1.html,[delay1st2nd_help,mod_quiz]
HLP quiz/timedelay2.html,[delaylater_help,mod_quiz]
HLP quiz/overallfeedback.html,[overallfeedback_help,mod_quiz]
HLP quiz_statistics/negcovar.html,[negcovar_help,quiz_statistics]
MOV [penaltyfactor,mod_quiz],[penaltyfactor,core_question]
MOV [penaltyfactor_help,mod_quiz],[penaltyfactor_help,core_question]
HLP quiz/penalty.html,[penaltyfactor_help,core_question]
AMOS END
2010-08-02 20:56:15 +00:00
|
|
|
$mform->addHelpButton('overallfeedbackhdr', 'overallfeedback', 'quiz');
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2011-02-04 15:47:52 +00:00
|
|
|
if (isset($this->current->grade)) {
|
|
|
|
$needwarning = $this->current->grade === 0;
|
2009-03-18 07:33:56 +00:00
|
|
|
} else {
|
2011-02-04 15:47:52 +00:00
|
|
|
$needwarning = $quizconfig->maximumgrade == 0;
|
2009-03-18 07:33:56 +00:00
|
|
|
}
|
|
|
|
if ($needwarning) {
|
2011-05-13 00:33:44 +01:00
|
|
|
$mform->addElement('static', 'nogradewarning', '',
|
|
|
|
get_string('nogradewarning', 'quiz'));
|
2009-03-18 07:33:56 +00:00
|
|
|
}
|
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
$mform->addElement('static', 'gradeboundarystatic1',
|
|
|
|
get_string('gradeboundary', 'quiz'), '100%');
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2023-01-16 17:07:44 +00:00
|
|
|
$repeatarray = [];
|
|
|
|
$repeatedoptions = [];
|
2012-03-18 18:39:37 +01:00
|
|
|
$repeatarray[] = $mform->createElement('editor', 'feedbacktext',
|
2023-01-16 17:07:44 +00:00
|
|
|
get_string('feedback', 'quiz'), ['rows' => 3], ['maxfiles' => EDITOR_UNLIMITED_FILES,
|
|
|
|
'noclean' => true, 'context' => $this->context]);
|
2012-03-18 18:39:37 +01:00
|
|
|
$repeatarray[] = $mform->createElement('text', 'feedbackboundaries',
|
2023-01-16 17:07:44 +00:00
|
|
|
get_string('gradeboundary', 'quiz'), ['size' => 10]);
|
2011-04-11 14:40:04 +01:00
|
|
|
$repeatedoptions['feedbacktext']['type'] = PARAM_RAW;
|
|
|
|
$repeatedoptions['feedbackboundaries']['type'] = PARAM_RAW;
|
2006-12-19 07:03:08 +00:00
|
|
|
|
|
|
|
if (!empty($this->_instance)) {
|
2011-04-11 14:40:04 +01:00
|
|
|
$this->_feedbacks = $DB->get_records('quiz_feedback',
|
2023-01-16 17:07:44 +00:00
|
|
|
['quizid' => $this->_instance], 'mingrade DESC');
|
2015-05-14 10:21:16 +01:00
|
|
|
$numfeedbacks = count($this->_feedbacks);
|
2006-12-19 07:03:08 +00:00
|
|
|
} else {
|
2023-01-16 17:07:44 +00:00
|
|
|
$this->_feedbacks = [];
|
2015-05-14 10:21:16 +01:00
|
|
|
$numfeedbacks = $quizconfig->initialnumfeedbacks;
|
2006-12-19 07:03:08 +00:00
|
|
|
}
|
2015-05-14 10:21:16 +01:00
|
|
|
$numfeedbacks = max($numfeedbacks, 1);
|
2006-12-28 16:44:47 +00:00
|
|
|
|
2011-04-11 14:40:04 +01:00
|
|
|
$nextel = $this->repeat_elements($repeatarray, $numfeedbacks - 1,
|
|
|
|
$repeatedoptions, 'boundary_repeats', 'boundary_add_fields', 3,
|
2007-10-09 15:44:06 +00:00
|
|
|
get_string('addmoreoverallfeedbacks', 'quiz'), true);
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2012-05-04 12:40:21 +01:00
|
|
|
// Put some extra elements in before the button.
|
2012-03-18 18:39:37 +01:00
|
|
|
$mform->insertElementBefore($mform->createElement('editor',
|
2023-01-16 17:07:44 +00:00
|
|
|
"feedbacktext[$nextel]", get_string('feedback', 'quiz'), ['rows' => 3],
|
|
|
|
['maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true,
|
|
|
|
'context' => $this->context]),
|
2011-04-11 14:40:04 +01:00
|
|
|
'boundary_add_fields');
|
2012-03-18 18:39:37 +01:00
|
|
|
$mform->insertElementBefore($mform->createElement('static',
|
2011-04-11 14:40:04 +01:00
|
|
|
'gradeboundarystatic2', get_string('gradeboundary', 'quiz'), '0%'),
|
|
|
|
'boundary_add_fields');
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2009-03-18 07:33:56 +00:00
|
|
|
// Add the disabledif rules. We cannot do this using the $repeatoptions parameter to
|
2011-07-06 14:19:25 +01:00
|
|
|
// repeat_elements because we don't want to dissable the first feedbacktext.
|
2009-03-18 07:33:56 +00:00
|
|
|
for ($i = 0; $i < $nextel; $i++) {
|
|
|
|
$mform->disabledIf('feedbackboundaries[' . $i . ']', 'grade', 'eq', 0);
|
|
|
|
$mform->disabledIf('feedbacktext[' . ($i + 1) . ']', 'grade', 'eq', 0);
|
|
|
|
}
|
|
|
|
|
2012-05-04 12:40:21 +01:00
|
|
|
// -------------------------------------------------------------------------------
|
2009-04-21 08:57:20 +00:00
|
|
|
$this->standard_coursemodule_elements();
|
quiz settings: MDL-18485 Improve quiz settings form
* Reorder form fields to group things more logically.
** and on the corresponding admin page too.
* Set some options to be 'Advanced' by default:
** Apply penalties.
** Each attempt builds on the last.
** Decimal places for question grades.
** The five 'Extra restrictions on attempts' settings. (password, etc.)
* Admins can still change this to suit their institiution at Administration > Plugins > Activity modules > Quiz.
* These new defaults are applied if the admin had not previously set any fields to be advanced.
* Disable some filds when they are not applicable:
** Grading method, if num attempts = 1
** Penaly scheme, if adaptive mode = no
** Each attempt builds of last, if num attempts = 1
** Review after quiz closed options, if no close date.
** Delay between 1st and 2nd attempts, if num attempts = 1
** Delay between later attempts, if num attempts < 3
* Convert quiz.timelimit to be in seconds, for consistency, and ready for the new duration field type (MDL 18500).
** Including ensuring that backup and restore is backwards compatible.
* MDL-5537 New setting, questiondecimalpoints, so, for example, you can show the quiz grade as an integer, but have fractional question grades.
** There is a 'Same as overall decimal points' option, which is the default.
* Improve some field labels.
* Make corresponding changes in the help files.
2009-03-10 08:39:51 +00:00
|
|
|
|
2012-10-16 10:33:03 +01:00
|
|
|
// Check and act on whether setting outcomes is considered an advanced setting.
|
|
|
|
$mform->setAdvanced('modoutcomes', !empty($quizconfig->outcomes_adv));
|
|
|
|
|
2013-03-05 22:58:51 +00:00
|
|
|
// The standard_coursemodule_elements method sets this to 100, but the
|
|
|
|
// quiz has its own setting, so use that.
|
|
|
|
$mform->setDefault('grade', $quizconfig->maximumgrade);
|
|
|
|
|
2012-05-04 12:40:21 +01:00
|
|
|
// -------------------------------------------------------------------------------
|
2020-01-30 10:50:01 +11:00
|
|
|
$this->apply_admin_defaults();
|
2006-12-19 07:03:08 +00:00
|
|
|
$this->add_action_buttons();
|
MDL-43089 quiz: improved interface for building quizzes
This commit is actually the joint work of Mahmoud Kassaei, Colin
Chambers and Tim Hunt from The Open University. We could only use one
persons name for the commit, and this time Colin gets the credit/blame.
The goal of this work was to increase usability, and also clean up
the page enough that it will be possible to add new features in future.
Display of mod/quiz/edit.php is now entirely generated by
mod_quiz\output\edit_renderer. This uses a helper class
mod_quiz\structure to provide details of the structure of the quiz, and
mod_quiz\repaginate to alter that structure. (Acutally, there are still
some modification methods on mod_quiz\structure. Expect that to be
cleaned up in future.)
The new code uses much more ajax, and there are new scripts
mod/quiz/edit_rest.php and mod/quiz/repaginate.php to handle this.
(Again, don't be surprised if those two scripts get merged in future.)
Also questionbank.ajax.php (which may, in future, be made more generic,
and moved into the core question bank code.)
Most of the new JavaScript code has intentionally copied the way things
are done when editing activities on the course page.
As a result of this, mod/quiz/editlib.php is now much shorter than it
was. (In future, expect the remaining code in here to move into
mod/quiz/classes.)
2013-12-05 16:18:24 +00:00
|
|
|
|
|
|
|
$PAGE->requires->yui_module('moodle-mod_quiz-modform', 'M.mod_quiz.modform.init');
|
2007-05-08 16:11:58 +00:00
|
|
|
}
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2012-04-02 16:13:29 +01:00
|
|
|
protected function add_review_options_group($mform, $quizconfig, $whenname,
|
|
|
|
$when, $withhelp = false) {
|
|
|
|
global $OUTPUT;
|
|
|
|
|
2023-01-16 17:07:44 +00:00
|
|
|
$group = [];
|
2012-04-02 16:13:29 +01:00
|
|
|
foreach (self::$reviewfields as $field => $string) {
|
|
|
|
list($identifier, $component) = $string;
|
|
|
|
|
|
|
|
$label = get_string($identifier, $component);
|
2020-10-19 15:17:11 +07:00
|
|
|
$group[] = $mform->createElement('html', html_writer::start_div('review_option_item'));
|
|
|
|
$el = $mform->createElement('checkbox', $field . $whenname, '', $label);
|
2012-04-02 16:13:29 +01:00
|
|
|
if ($withhelp) {
|
2020-10-19 15:17:11 +07:00
|
|
|
$el->_helpbutton = $OUTPUT->render(new help_icon($identifier, $component));
|
2012-04-02 16:13:29 +01:00
|
|
|
}
|
2020-10-19 15:17:11 +07:00
|
|
|
$group[] = $el;
|
|
|
|
$group[] = $mform->createElement('html', html_writer::end_div());
|
2011-02-03 18:06:10 +00:00
|
|
|
}
|
2011-05-13 00:33:44 +01:00
|
|
|
$mform->addGroup($group, $whenname . 'optionsgrp',
|
|
|
|
get_string('review' . $whenname, 'quiz'), null, false);
|
2011-02-03 18:06:10 +00:00
|
|
|
|
|
|
|
foreach (self::$reviewfields as $field => $notused) {
|
2011-02-10 18:32:04 +00:00
|
|
|
$cfgfield = 'review' . $field;
|
|
|
|
if ($quizconfig->$cfgfield & $when) {
|
2011-02-03 18:06:10 +00:00
|
|
|
$mform->setDefault($field . $whenname, 1);
|
|
|
|
} else {
|
|
|
|
$mform->setDefault($field . $whenname, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-15 14:41:48 +00:00
|
|
|
if ($whenname != 'during') {
|
|
|
|
$mform->disabledIf('correctness' . $whenname, 'attempt' . $whenname);
|
|
|
|
$mform->disabledIf('specificfeedback' . $whenname, 'attempt' . $whenname);
|
|
|
|
$mform->disabledIf('generalfeedback' . $whenname, 'attempt' . $whenname);
|
|
|
|
$mform->disabledIf('rightanswer' . $whenname, 'attempt' . $whenname);
|
|
|
|
}
|
2011-02-03 18:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function preprocessing_review_settings(&$toform, $whenname, $when) {
|
|
|
|
foreach (self::$reviewfields as $field => $notused) {
|
|
|
|
$fieldname = 'review' . $field;
|
|
|
|
if (array_key_exists($fieldname, $toform)) {
|
|
|
|
$toform[$field . $whenname] = $toform[$fieldname] & $when;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-28 11:40:15 +01:00
|
|
|
public function data_preprocessing(&$toform) {
|
2011-02-03 18:06:10 +00:00
|
|
|
if (isset($toform['grade'])) {
|
2011-05-13 00:33:44 +01:00
|
|
|
// Convert to a real number, so we don't get 0.0000.
|
|
|
|
$toform['grade'] = $toform['grade'] + 0;
|
2009-03-18 07:33:56 +00:00
|
|
|
}
|
|
|
|
|
2006-12-19 07:03:08 +00:00
|
|
|
if (count($this->_feedbacks)) {
|
|
|
|
$key = 0;
|
2011-05-13 00:33:44 +01:00
|
|
|
foreach ($this->_feedbacks as $feedback) {
|
2010-08-10 09:56:48 +00:00
|
|
|
$draftid = file_get_submitted_draft_itemid('feedbacktext['.$key.']');
|
2011-02-03 18:06:10 +00:00
|
|
|
$toform['feedbacktext['.$key.']']['text'] = file_prepare_draft_area(
|
2012-05-04 12:40:21 +01:00
|
|
|
$draftid, // Draftid.
|
|
|
|
$this->context->id, // Context.
|
|
|
|
'mod_quiz', // Component.
|
|
|
|
'feedback', // Filarea.
|
|
|
|
!empty($feedback->id) ? (int) $feedback->id : null, // Itemid.
|
2010-08-10 09:56:48 +00:00
|
|
|
null,
|
2012-05-04 12:40:21 +01:00
|
|
|
$feedback->feedbacktext // Text.
|
2010-08-10 09:56:48 +00:00
|
|
|
);
|
2011-02-03 18:06:10 +00:00
|
|
|
$toform['feedbacktext['.$key.']']['format'] = $feedback->feedbacktextformat;
|
|
|
|
$toform['feedbacktext['.$key.']']['itemid'] = $draftid;
|
2010-08-10 09:56:48 +00:00
|
|
|
|
2011-03-04 17:48:13 +00:00
|
|
|
if ($toform['grade'] == 0) {
|
|
|
|
// When a quiz is un-graded, there can only be one lot of
|
|
|
|
// feedback. If the quiz previously had a maximum grade and
|
|
|
|
// several lots of feedback, we must now avoid putting text
|
|
|
|
// into input boxes that are disabled, but which the
|
|
|
|
// validation will insist are blank.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-12-19 07:03:08 +00:00
|
|
|
if ($feedback->mingrade > 0) {
|
2011-05-13 00:33:44 +01:00
|
|
|
$toform['feedbackboundaries['.$key.']'] =
|
2014-11-10 17:34:22 +00:00
|
|
|
round(100.0 * $feedback->mingrade / $toform['grade'], 6) . '%';
|
2006-12-19 07:03:08 +00:00
|
|
|
}
|
|
|
|
$key++;
|
|
|
|
}
|
|
|
|
}
|
2008-08-13 03:17:49 +00:00
|
|
|
|
2011-02-03 18:06:10 +00:00
|
|
|
if (isset($toform['timelimit'])) {
|
|
|
|
$toform['timelimitenable'] = $toform['timelimit'] > 0;
|
2006-12-19 07:03:08 +00:00
|
|
|
}
|
|
|
|
|
2011-05-13 00:33:44 +01:00
|
|
|
$this->preprocessing_review_settings($toform, 'during',
|
2022-12-07 23:02:31 +00:00
|
|
|
display_options::DURING);
|
2011-05-13 00:33:44 +01:00
|
|
|
$this->preprocessing_review_settings($toform, 'immediately',
|
2022-12-07 23:02:31 +00:00
|
|
|
display_options::IMMEDIATELY_AFTER);
|
2011-05-13 00:33:44 +01:00
|
|
|
$this->preprocessing_review_settings($toform, 'open',
|
2022-12-07 23:02:31 +00:00
|
|
|
display_options::LATER_WHILE_OPEN);
|
2011-05-13 00:33:44 +01:00
|
|
|
$this->preprocessing_review_settings($toform, 'closed',
|
2022-12-07 23:02:31 +00:00
|
|
|
display_options::AFTER_CLOSE);
|
2011-02-03 18:06:10 +00:00
|
|
|
$toform['attemptduring'] = true;
|
|
|
|
$toform['overallfeedbackduring'] = false;
|
|
|
|
|
|
|
|
// Password field - different in form to stop browsers that remember
|
|
|
|
// passwords from getting confused.
|
|
|
|
if (isset($toform['password'])) {
|
|
|
|
$toform['quizpassword'] = $toform['password'];
|
|
|
|
unset($toform['password']);
|
2007-04-27 08:33:11 +00:00
|
|
|
}
|
2011-10-05 12:55:22 +01:00
|
|
|
|
|
|
|
// Load any settings belonging to the access rules.
|
|
|
|
if (!empty($toform['instance'])) {
|
2022-12-14 18:07:22 +00:00
|
|
|
$accesssettings = access_manager::load_settings($toform['instance']);
|
2011-10-05 12:55:22 +01:00
|
|
|
foreach ($accesssettings as $name => $value) {
|
|
|
|
$toform[$name] = $value;
|
|
|
|
}
|
|
|
|
}
|
2020-06-09 14:26:50 -04:00
|
|
|
|
|
|
|
if (empty($toform['completionminattempts'])) {
|
|
|
|
$toform['completionminattempts'] = 1;
|
|
|
|
} else {
|
|
|
|
$toform['completionminattemptsenabled'] = $toform['completionminattempts'] > 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allows module to modify the data returned by form get_data().
|
|
|
|
* This method is also called in the bulk activity completion form.
|
|
|
|
*
|
|
|
|
* Only available on moodleform_mod.
|
|
|
|
*
|
|
|
|
* @param stdClass $data the form data to be modified.
|
|
|
|
*/
|
|
|
|
public function data_postprocessing($data) {
|
|
|
|
parent::data_postprocessing($data);
|
|
|
|
if (!empty($data->completionunlocked)) {
|
|
|
|
// Turn off completion settings if the checkboxes aren't ticked.
|
|
|
|
$autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
|
|
|
|
if (empty($data->completionminattemptsenabled) || !$autocompletion) {
|
|
|
|
$data->completionminattempts = 0;
|
|
|
|
}
|
|
|
|
}
|
2007-05-08 16:11:58 +00:00
|
|
|
}
|
2006-12-19 07:03:08 +00:00
|
|
|
|
2011-03-23 16:22:25 +00:00
|
|
|
public function validation($data, $files) {
|
2007-11-23 22:15:07 +00:00
|
|
|
$errors = parent::validation($data, $files);
|
2007-08-02 10:38:18 +00:00
|
|
|
|
2006-12-19 07:03:08 +00:00
|
|
|
// Check open and close times are consistent.
|
2011-05-13 00:33:44 +01:00
|
|
|
if ($data['timeopen'] != 0 && $data['timeclose'] != 0 &&
|
|
|
|
$data['timeclose'] < $data['timeopen']) {
|
2006-12-19 07:03:08 +00:00
|
|
|
$errors['timeclose'] = get_string('closebeforeopen', 'quiz');
|
|
|
|
}
|
|
|
|
|
2012-06-07 19:17:07 +01:00
|
|
|
// Check that the grace period is not too short.
|
|
|
|
if ($data['overduehandling'] == 'graceperiod') {
|
|
|
|
$graceperiodmin = get_config('quiz', 'graceperiodmin');
|
|
|
|
if ($data['graceperiod'] <= $graceperiodmin) {
|
|
|
|
$errors['graceperiod'] = get_string('graceperiodtoosmall', 'quiz', format_time($graceperiodmin));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-09 14:26:50 -04:00
|
|
|
if (!empty($data['completionminattempts'])) {
|
|
|
|
if ($data['attempts'] > 0 && $data['completionminattempts'] > $data['attempts']) {
|
|
|
|
$errors['completionminattemptsgroup'] = get_string('completionminattemptserror', 'quiz');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-19 07:03:08 +00:00
|
|
|
// Check the boundary value is a number or a percentage, and in range.
|
|
|
|
$i = 0;
|
|
|
|
while (!empty($data['feedbackboundaries'][$i] )) {
|
|
|
|
$boundary = trim($data['feedbackboundaries'][$i]);
|
2012-12-11 17:59:31 +00:00
|
|
|
if (strlen($boundary) > 0) {
|
|
|
|
if ($boundary[strlen($boundary) - 1] == '%') {
|
|
|
|
$boundary = trim(substr($boundary, 0, -1));
|
|
|
|
if (is_numeric($boundary)) {
|
|
|
|
$boundary = $boundary * $data['grade'] / 100.0;
|
|
|
|
} else {
|
|
|
|
$errors["feedbackboundaries[$i]"] =
|
|
|
|
get_string('feedbackerrorboundaryformat', 'quiz', $i + 1);
|
|
|
|
}
|
|
|
|
} else if (!is_numeric($boundary)) {
|
2011-05-13 00:33:44 +01:00
|
|
|
$errors["feedbackboundaries[$i]"] =
|
|
|
|
get_string('feedbackerrorboundaryformat', 'quiz', $i + 1);
|
2006-12-19 07:03:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (is_numeric($boundary) && $boundary <= 0 || $boundary >= $data['grade'] ) {
|
2011-05-13 00:33:44 +01:00
|
|
|
$errors["feedbackboundaries[$i]"] =
|
|
|
|
get_string('feedbackerrorboundaryoutofrange', 'quiz', $i + 1);
|
2006-12-19 07:03:08 +00:00
|
|
|
}
|
2011-05-13 00:33:44 +01:00
|
|
|
if (is_numeric($boundary) && $i > 0 &&
|
|
|
|
$boundary >= $data['feedbackboundaries'][$i - 1]) {
|
|
|
|
$errors["feedbackboundaries[$i]"] =
|
|
|
|
get_string('feedbackerrororder', 'quiz', $i + 1);
|
2006-12-19 07:03:08 +00:00
|
|
|
}
|
|
|
|
$data['feedbackboundaries'][$i] = $boundary;
|
|
|
|
$i += 1;
|
|
|
|
}
|
|
|
|
$numboundaries = $i;
|
|
|
|
|
|
|
|
// Check there is nothing in the remaining unused fields.
|
2009-03-18 07:33:56 +00:00
|
|
|
if (!empty($data['feedbackboundaries'])) {
|
|
|
|
for ($i = $numboundaries; $i < count($data['feedbackboundaries']); $i += 1) {
|
2011-05-13 00:33:44 +01:00
|
|
|
if (!empty($data['feedbackboundaries'][$i] ) &&
|
|
|
|
trim($data['feedbackboundaries'][$i] ) != '') {
|
|
|
|
$errors["feedbackboundaries[$i]"] =
|
|
|
|
get_string('feedbackerrorjunkinboundary', 'quiz', $i + 1);
|
2009-03-18 07:33:56 +00:00
|
|
|
}
|
2006-12-19 07:03:08 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-18 07:33:56 +00:00
|
|
|
for ($i = $numboundaries + 1; $i < count($data['feedbacktext']); $i += 1) {
|
2011-05-13 00:33:44 +01:00
|
|
|
if (!empty($data['feedbacktext'][$i]['text']) &&
|
|
|
|
trim($data['feedbacktext'][$i]['text'] ) != '') {
|
|
|
|
$errors["feedbacktext[$i]"] =
|
|
|
|
get_string('feedbackerrorjunkinfeedback', 'quiz', $i + 1);
|
2006-12-19 07:03:08 +00:00
|
|
|
}
|
|
|
|
}
|
2007-08-02 10:38:18 +00:00
|
|
|
|
2017-05-16 22:21:27 +02:00
|
|
|
// If CBM is involved, don't show the warning for grade to pass being larger than the maximum grade.
|
|
|
|
if (($data['preferredbehaviour'] == 'deferredcbm') OR ($data['preferredbehaviour'] == 'immediatecbm')) {
|
|
|
|
unset($errors['gradepass']);
|
|
|
|
}
|
2013-04-17 14:24:38 +01:00
|
|
|
// Any other rule plugins.
|
2022-12-14 18:07:22 +00:00
|
|
|
$errors = access_manager::validate_settings_form_fields($errors, $data, $files, $this);
|
2013-04-17 14:24:38 +01:00
|
|
|
|
2008-06-01 17:53:25 +00:00
|
|
|
return $errors;
|
2007-05-08 16:11:58 +00:00
|
|
|
}
|
2014-05-30 11:39:42 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Display module-specific activity completion rules.
|
|
|
|
* Part of the API defined by moodleform_mod
|
|
|
|
* @return array Array of string IDs of added items, empty array if none
|
|
|
|
*/
|
|
|
|
public function add_completion_rules() {
|
|
|
|
$mform = $this->_form;
|
2023-01-16 17:07:44 +00:00
|
|
|
$items = [];
|
2014-05-30 11:39:42 -05:00
|
|
|
|
2020-06-24 11:55:01 +08:00
|
|
|
$mform->addElement('advcheckbox', 'completionattemptsexhausted', null,
|
|
|
|
get_string('completionattemptsexhausted', 'quiz'),
|
2023-01-16 17:07:44 +00:00
|
|
|
['group' => 'cattempts']);
|
2020-06-24 11:55:01 +08:00
|
|
|
$mform->disabledIf('completionattemptsexhausted', 'completionpassgrade', 'notchecked');
|
|
|
|
$items[] = 'completionattemptsexhausted';
|
2020-06-09 14:26:50 -04:00
|
|
|
|
2023-01-16 17:07:44 +00:00
|
|
|
$group = [];
|
2020-06-09 14:26:50 -04:00
|
|
|
$group[] = $mform->createElement('checkbox', 'completionminattemptsenabled', '',
|
|
|
|
get_string('completionminattempts', 'quiz'));
|
2023-01-16 17:07:44 +00:00
|
|
|
$group[] = $mform->createElement('text', 'completionminattempts', '', ['size' => 3]);
|
2020-06-09 14:26:50 -04:00
|
|
|
$mform->setType('completionminattempts', PARAM_INT);
|
2023-01-16 17:07:44 +00:00
|
|
|
$mform->addGroup($group, 'completionminattemptsgroup', get_string('completionminattemptsgroup', 'quiz'), [' '], false);
|
2020-06-09 14:26:50 -04:00
|
|
|
$mform->disabledIf('completionminattempts', 'completionminattemptsenabled', 'notchecked');
|
|
|
|
|
|
|
|
$items[] = 'completionminattemptsgroup';
|
|
|
|
|
2014-05-30 11:39:42 -05:00
|
|
|
return $items;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called during validation. Indicates whether a module-specific completion rule is selected.
|
|
|
|
*
|
|
|
|
* @param array $data Input data (not yet validated)
|
|
|
|
* @return bool True if one or more rules is enabled, false if none are.
|
|
|
|
*/
|
|
|
|
public function completion_rule_enabled($data) {
|
2020-06-09 14:26:50 -04:00
|
|
|
return !empty($data['completionattemptsexhausted']) ||
|
|
|
|
!empty($data['completionminattemptsenabled']);
|
2014-05-30 11:39:42 -05:00
|
|
|
}
|
2014-09-14 14:14:11 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the maximum number of attempts that anyone might have due to a user
|
|
|
|
* or group override. Used to decide whether disabledIf rules should be applied.
|
|
|
|
* @return int the number of attempts allowed. For the purpose of this method,
|
|
|
|
* unlimited is returned as 1000, not 0.
|
|
|
|
*/
|
|
|
|
public function get_max_attempts_for_any_override() {
|
|
|
|
global $DB;
|
|
|
|
|
|
|
|
if (empty($this->_instance)) {
|
|
|
|
// Quiz not created yet, so no overrides.
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->maxattemptsanyoverride === null) {
|
|
|
|
$this->maxattemptsanyoverride = $DB->get_field_sql("
|
|
|
|
SELECT MAX(CASE WHEN attempts = 0 THEN 1000 ELSE attempts END)
|
|
|
|
FROM {quiz_overrides}
|
|
|
|
WHERE quiz = ?",
|
2023-01-16 17:07:44 +00:00
|
|
|
[$this->_instance]);
|
2014-09-14 14:14:11 +01:00
|
|
|
if ($this->maxattemptsanyoverride < 1) {
|
|
|
|
// This happens when no override alters the number of attempts.
|
|
|
|
$this->maxattemptsanyoverride = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->maxattemptsanyoverride;
|
|
|
|
}
|
2006-12-19 07:03:08 +00:00
|
|
|
}
|