forked from jayeshanandani/moodle-mod_qpractice
/
startattempt_form.php
69 lines (61 loc) · 2.55 KB
/
startattempt_form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
// 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/>.
/**
* The form for starting a new session.
*
* It uses the standard core Moodle formslib. For more info about them, please
* visit: http://docs.moodle.org/en/Development:lib/formslib.php
*
* @package mod_qpractice
* @copyright 2013 Jayesh Anandani
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once("$CFG->libdir/formslib.php");
/**
* Runs when the student makes an attempt
*
* @package mod_qpractice
* @copyright 2019 Marcus Green
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_qpractice_startattempt_form extends moodleform {
/**
* set up the form elements
*
* @return void
*/
public function definition() {
$mform = $this->_form;
// Adding the "general" fieldset, where all the common settings are showed.
/* Stops headers being collapsible */
$mform->setDisableShortForms(true);
$mform->addElement('header', 'general', get_string('setuppractice', 'qpractice'));
$categories = $this->_customdata['categories'];
if (count($categories) > 1) {
$mform->addElement('select', 'categories', get_string('category'), $this->_customdata['categories']);
$mform->addHelpButton('categories', 'categoryselect', 'qpractice');
}else{
$mform->addElement('static', 'categories', get_string('category'), reset($categories));
}
$mform->addElement('select', 'behaviour', get_string('behaviour', 'qpractice'), $this->_customdata['behaviours']);
$this->add_action_buttons(true, get_string('startpractice', 'qpractice'));
$mform->addElement('hidden', 'id', 0);
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'instanceid', $this->_customdata['instanceid']);
$mform->setType('instanceid', PARAM_INT);
}
}