forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassessment_form.php
125 lines (110 loc) · 4.98 KB
/
assessment_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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?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/>.
/**
* This file defines a base class for all assessment forms
*
* @package mod
* @subpackage workshop
* @copyright 2009 David Mudrak <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/formslib.php'); // parent class definition
/**
* Base class for all assessment forms
*
* This defines the common fields that all assessment forms need.
* Strategies should define their own class that inherits from this one, and
* implements the definition_inner() method.
*
* @uses moodleform
*/
class workshop_assessment_form extends moodleform {
/**
* Add the fields that are common for all grading strategies.
*
* If the strategy does not support all these fields, then you can override
* this method and remove the ones you don't want with
* $mform->removeElement().
* Strategy subclassess should define their own fields in definition_inner()
*
* @return void
*/
public function definition() {
global $CFG;
$mform = $this->_form;
$this->mode = $this->_customdata['mode']; // influences the save buttons
$this->strategy = $this->_customdata['strategy']; // instance of the strategy api class
$this->workshop = $this->_customdata['workshop']; // instance of the workshop api class
$this->options = $this->_customdata['options']; // array with addiotional options
// Disable shortforms
$mform->setDisableShortforms();
// add the strategy-specific fields
$this->definition_inner($mform);
// add the data common for all subplugins
$mform->addElement('hidden', 'strategy', $this->workshop->strategy);
$mform->setType('strategy', PARAM_PLUGIN);
if ($this->workshop->overallfeedbackmode and $this->is_editable()) {
$mform->addElement('header', 'overallfeedbacksection', get_string('overallfeedback', 'mod_workshop'));
$mform->addElement('editor', 'feedbackauthor_editor', get_string('feedbackauthor', 'mod_workshop'), null,
$this->workshop->overall_feedback_content_options());
if ($this->workshop->overallfeedbackmode == 2) {
$mform->addRule('feedbackauthor_editor', null, 'required', null, 'client');
}
if ($this->workshop->overallfeedbackfiles) {
$mform->addElement('filemanager', 'feedbackauthorattachment_filemanager',
get_string('feedbackauthorattachment', 'mod_workshop'), null,
$this->workshop->overall_feedback_attachment_options());
}
}
if (!empty($this->options['editableweight']) and $this->is_editable()) {
$mform->addElement('header', 'assessmentsettings', get_string('assessmentweight', 'workshop'));
$mform->addElement('select', 'weight',
get_string('assessmentweight', 'workshop'), workshop::available_assessment_weights_list());
$mform->setDefault('weight', 1);
}
$buttonarray = array();
if ($this->mode == 'preview') {
$buttonarray[] = $mform->createElement('cancel', 'backtoeditform', get_string('backtoeditform', 'workshop'));
}
if ($this->mode == 'assessment') {
if (!empty($this->options['pending'])) {
$buttonarray[] = $mform->createElement('submit', 'saveandshownext', get_string('saveandshownext', 'workshop'));
}
$buttonarray[] = $mform->createElement('submit', 'saveandclose', get_string('saveandclose', 'workshop'));
$buttonarray[] = $mform->createElement('submit', 'saveandcontinue', get_string('saveandcontinue', 'workshop'));
$buttonarray[] = $mform->createElement('cancel');
}
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$mform->closeHeaderBefore('buttonar');
}
/**
* Add any strategy specific form fields.
*
* @param stdClass $mform the form being built.
*/
protected function definition_inner(&$mform) {
// By default, do nothing.
}
/**
* Is the form frozen (read-only)?
*
* @return boolean
*/
public function is_editable() {
return !$this->_form->isFrozen();
}
}