Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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
        $currentversion = $this->_customdata['restartversion'];
53
        $select = $mform->addElement('select', 'restartversion', get_string('questionversion', 'qbank_previewquestion'), $versions);
54
        $select->setSelected($currentversion);
55
        $behaviours = question_engine::get_behaviour_options(
56
                $this->_customdata['quba']->get_preferred_behaviour());
57
        $mform->addElement('select', 'behaviour',
58
                get_string('howquestionsbehave', 'question'), $behaviours);
59
        $mform->addHelpButton('behaviour', 'howquestionsbehave', 'question');
60
 
61
        $mform->addElement('float', 'maxmark', get_string('markedoutof', 'question'), ['size' => '5']);
62
 
63
        if ($this->_customdata['maxvariant'] > 1) {
64
            $variants = range(1, $this->_customdata['maxvariant']);
65
            $mform->addElement('select', 'variant', get_string('questionvariant', 'question'),
66
                    array_combine($variants, $variants));
67
        }
68
        $mform->setType('variant', PARAM_INT);
69
 
70
        $mform->addElement('submit', 'saverestart',
71
                get_string('restartwiththeseoptions', 'question'));
72
 
73
        $mform->addElement('header', 'displayoptionsheader', get_string('displayoptions', 'question'));
74
        $mform->setExpanded('displayoptionsheader', false);
75
 
76
        $mform->addElement('select', 'correctness', get_string('whethercorrect', 'question'),
77
                $hiddenorvisible);
78
 
79
        $marksoptions = [
80
                question_display_options::HIDDEN => get_string('notshown', 'question'),
81
                question_display_options::MAX_ONLY => get_string('showmaxmarkonly', 'question'),
82
                question_display_options::MARK_AND_MAX => get_string('showmarkandmax', 'question'),
83
        ];
84
        $mform->addElement('select', 'marks', get_string('marks', 'question'), $marksoptions);
85
 
86
        $mform->addElement('select', 'markdp', get_string('decimalplacesingrades', 'question'),
87
                question_engine::get_dp_options());
88
 
89
        $mform->addElement('select', 'feedback',
90
                get_string('specificfeedback', 'question'), $hiddenorvisible);
91
 
92
        $mform->addElement('select', 'generalfeedback',
93
                get_string('generalfeedback', 'question'), $hiddenorvisible);
94
 
95
        $mform->addElement('select', 'rightanswer',
96
                get_string('rightanswer', 'question'), $hiddenorvisible);
97
 
98
        $mform->addElement('select', 'history',
99
                get_string('responsehistory', 'question'), $hiddenorvisible);
100
 
101
        $mform->addElement('submit', 'saveupdate',
102
                get_string('updatedisplayoptions', 'question'));
103
    }
104
 
105
}