1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
namespace qbank_previewquestion\form;
|
|
|
18 |
|
|
|
19 |
defined('MOODLE_INTERNAL') || die();
|
|
|
20 |
|
|
|
21 |
require_once($CFG->libdir . '/formslib.php');
|
|
|
22 |
|
|
|
23 |
use moodleform;
|
|
|
24 |
use question_display_options;
|
|
|
25 |
use question_engine;
|
|
|
26 |
use qbank_previewquestion\question_preview_options;
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
* Settings form for the preview options.
|
|
|
30 |
*
|
|
|
31 |
* @package qbank_previewquestion
|
|
|
32 |
* @copyright 2009 The Open University
|
|
|
33 |
* @author 2021 Safat Shahin <safatshahin@catalyst-au.net>
|
|
|
34 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
35 |
*/
|
|
|
36 |
class preview_options_form extends moodleform {
|
|
|
37 |
|
|
|
38 |
public function definition() {
|
|
|
39 |
$mform = $this->_form;
|
|
|
40 |
|
|
|
41 |
$hiddenorvisible = [
|
|
|
42 |
question_display_options::HIDDEN => get_string('notshown', 'question'),
|
|
|
43 |
question_display_options::VISIBLE => get_string('shown', 'question'),
|
|
|
44 |
];
|
|
|
45 |
|
|
|
46 |
$mform->addElement('header', 'attemptoptionsheader', get_string('previewoptions', 'qbank_previewquestion'));
|
|
|
47 |
$mform->setExpanded('attemptoptionsheader', false);
|
|
|
48 |
// Add html element with class to display long text in single line.
|
|
|
49 |
$mform->addElement('html', \html_writer::div(get_string('theoptionsyouselectonlyaffectthepreview',
|
|
|
50 |
'qbank_previewquestion'), "col-md-12 row d-flex col-form-label mb-3"));
|
|
|
51 |
$versions = $this->_customdata['versions'];
|
|
|
52 |
$versions[question_preview_options::ALWAYS_LATEST] = get_string('alwayslatest', 'qbank_previewquestion');
|
|
|
53 |
$currentversion = $this->_customdata['restartversion'];
|
|
|
54 |
$select = $mform->addElement('select', 'restartversion', get_string('questionversion', 'qbank_previewquestion'), $versions);
|
|
|
55 |
$select->setSelected($currentversion);
|
|
|
56 |
$behaviours = question_engine::get_behaviour_options(
|
|
|
57 |
$this->_customdata['quba']->get_preferred_behaviour());
|
|
|
58 |
$mform->addElement('select', 'behaviour',
|
|
|
59 |
get_string('howquestionsbehave', 'question'), $behaviours);
|
|
|
60 |
$mform->addHelpButton('behaviour', 'howquestionsbehave', 'question');
|
|
|
61 |
|
|
|
62 |
$mform->addElement('float', 'maxmark', get_string('markedoutof', 'question'), ['size' => '5']);
|
|
|
63 |
|
|
|
64 |
if ($this->_customdata['maxvariant'] > 1) {
|
|
|
65 |
$variants = range(1, $this->_customdata['maxvariant']);
|
|
|
66 |
$mform->addElement('select', 'variant', get_string('questionvariant', 'question'),
|
|
|
67 |
array_combine($variants, $variants));
|
|
|
68 |
}
|
|
|
69 |
$mform->setType('variant', PARAM_INT);
|
|
|
70 |
|
|
|
71 |
$mform->addElement('submit', 'saverestart',
|
|
|
72 |
get_string('restartwiththeseoptions', 'question'));
|
|
|
73 |
|
|
|
74 |
$mform->addElement('header', 'displayoptionsheader', get_string('displayoptions', 'question'));
|
|
|
75 |
$mform->setExpanded('displayoptionsheader', false);
|
|
|
76 |
|
|
|
77 |
$mform->addElement('select', 'correctness', get_string('whethercorrect', 'question'),
|
|
|
78 |
$hiddenorvisible);
|
|
|
79 |
|
|
|
80 |
$marksoptions = [
|
|
|
81 |
question_display_options::HIDDEN => get_string('notshown', 'question'),
|
|
|
82 |
question_display_options::MAX_ONLY => get_string('showmaxmarkonly', 'question'),
|
|
|
83 |
question_display_options::MARK_AND_MAX => get_string('showmarkandmax', 'question'),
|
|
|
84 |
];
|
|
|
85 |
$mform->addElement('select', 'marks', get_string('marks', 'question'), $marksoptions);
|
|
|
86 |
|
|
|
87 |
$mform->addElement('select', 'markdp', get_string('decimalplacesingrades', 'question'),
|
|
|
88 |
question_engine::get_dp_options());
|
|
|
89 |
|
|
|
90 |
$mform->addElement('select', 'feedback',
|
|
|
91 |
get_string('specificfeedback', 'question'), $hiddenorvisible);
|
|
|
92 |
|
|
|
93 |
$mform->addElement('select', 'generalfeedback',
|
|
|
94 |
get_string('generalfeedback', 'question'), $hiddenorvisible);
|
|
|
95 |
|
|
|
96 |
$mform->addElement('select', 'rightanswer',
|
|
|
97 |
get_string('rightanswer', 'question'), $hiddenorvisible);
|
|
|
98 |
|
|
|
99 |
$mform->addElement('select', 'history',
|
|
|
100 |
get_string('responsehistory', 'question'), $hiddenorvisible);
|
|
|
101 |
|
|
|
102 |
$mform->addElement('submit', 'saveupdate',
|
|
|
103 |
get_string('updatedisplayoptions', 'question'));
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
}
|