-
Notifications
You must be signed in to change notification settings - Fork 0
/
post_form.php
98 lines (77 loc) · 3.68 KB
/
post_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
<?php
// This file is part of Assessment module for 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/>.
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
require_once($CFG->libdir.'/formslib.php');
class mod_assessment_post_form extends moodleform {
function definition() {
global $CFG;
$mform =& $this->_form;
$course = $this->_customdata['course'];
$cm = $this->_customdata['cm'];
$coursecontext = $this->_customdata['coursecontext'];
$modcontext = $this->_customdata['modcontext'];
$assessment = $this->_customdata['assessment'];
$post = $this->_customdata['post']; // hack alert
$mform->addElement('header', 'general', '');//fill in the data depending on page params later using set_data
$mform->addElement('text', 'subject', get_string('subject', 'forum'), 'size="48"');
$mform->setType('subject', PARAM_TEXT);
$mform->addRule('subject', get_string('required'), 'required', null, 'client');
$mform->addRule('subject', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$mform->addElement('editor', 'message', get_string('message', 'forum'), null);
$mform->setType('message', PARAM_RAW);
$mform->addRule('message', get_string('required'), 'required', null, 'client');
if (groups_get_activity_groupmode($cm, $course)) { // hack alert
if (empty($post->groupid)) {
$groupname = get_string('allparticipants');
} else {
$group = groups_get_group($post->groupid);
$groupname = format_string($group->name);
}
$mform->addElement('static', 'groupinfo', get_string('group'), $groupname);
}
//-------------------------------------------------------------------------------
// buttons
if (isset($post->edit)) { // hack alert
$submit_string = get_string('savechanges');
} else {
$submit_string = get_string('posttoforum', 'forum');
}
$this->add_action_buttons(false, $submit_string);
$mform->addElement('hidden', 'course');
$mform->setType('course', PARAM_INT);
$mform->addElement('hidden', 'assessment');
$mform->setType('assessment', PARAM_INT);
$mform->addElement('hidden', 'discussion');
$mform->setType('discussion', PARAM_INT);
$mform->addElement('hidden', 'parent');
$mform->setType('parent', PARAM_INT);
$mform->addElement('hidden', 'userid');
$mform->setType('userid', PARAM_INT);
$mform->addElement('hidden', 'groupid');
$mform->setType('groupid', PARAM_INT);
$mform->addElement('hidden', 'edit');
$mform->setType('edit', PARAM_INT);
$mform->addElement('hidden', 'reply');
$mform->setType('reply', PARAM_INT);
}
function validation($data, $files) {
$errors = parent::validation($data, $files);
return $errors;
}
}
?>