-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtask_form.php
More file actions
99 lines (87 loc) · 4.29 KB
/
task_form.php
File metadata and controls
99 lines (87 loc) · 4.29 KB
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
<?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/>.
defined('MOODLE_INTERNAL') || die();
require_once("$CFG->libdir/formslib.php");
require_once($CFG->dirroot.'/blocks/pbltool/lib.php');
class task_form extends moodleform {
private $teacher = false;
private $status = 0;
public function __construct($teacher = 0, $status = 0, $view = false) {
$this->teacher = $teacher;
$this->status = $status;
$this->view = $view;
parent::__construct();
}
public function definition() {
global $CFG;
global $COURSE;
$mform =& $this->_form;
$mform->addElement('header', 'displayinfo', get_string('taskdefinition', 'block_pbltool'));
// add
$mform->addElement('textarea', 'name', get_string('tasktitle', 'block_pbltool'), 'rows="1" cols="51"');
$mform->setType('name', PARAM_RAW);
$mform->addRule('name', null, 'required', null, 'client');
// add display text field
$mform->addElement('textarea', 'description', get_string('taskdescription', 'block_pbltool'),
'rows="4" cols="51"');
$mform->setType('description', PARAM_RAW);
$mform->addRule('description', null, 'required', null, 'client');
$mform->addElement('date_selector', 'timebegin', get_string('begin_date', 'block_pbltool'));
$mform->addElement('date_selector', 'timeplannedend', get_string('finish_date', 'block_pbltool'));
$progress_array = array(0 => '0%',25 => '25%', 50 => '50%', 75 => '75%', 100 => '100%');
$mform->addElement('select', 'progress', get_string('Progress', 'block_pbltool'), $progress_array);
$mform->addElement('hidden', 'project');
$mform->setType('project', PARAM_INT);
$mform->addElement('hidden', 'courseid');
$mform->setType('courseid', PARAM_INT);
$mform->addElement('hidden', 'groupid');
$mform->setType('groupid', PARAM_INT);
$mform->addElement('hidden', 'blockid');
$mform->setType('blockid', PARAM_INT);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'prev_status');
$mform->setType('prev_status', PARAM_INT);
$legend = array(get_string('working', 'block_pbltool'),
get_string('question', 'block_pbltool'),
get_string('ongoing', 'block_pbltool'), get_string('recycle', 'block_pbltool'),
get_string('pointing', 'block_pbltool'), get_string('checkmark', 'block_pbltool'),
get_string('redcross', 'block_pbltool'));
$mform->addElement('select', 'status', get_string('Status', 'block_pbltool'), $legend);
if ($this->teacher == false) {
$mform->getElement('status')->freeze();
}
// If not teacher and not planning, freeze descriptions
if (!$this->teacher && ($this->status && $this->status != 3)) {
$mform->getElement('name')->freeze();
$mform->getElement('description')->freeze();
$mform->getElement('timebegin')->freeze();
$mform->getElement('timeplannedend')->freeze();
$mform->getElement('status')->freeze();
}
// If not teacher and not working, freeze progress
if (!$this->teacher && $this->status != 2) {
$mform->getElement('progress')->freeze();
}
// If not teacher and not planning and not working, just look
if (!$this->teacher && $this->status != 0 && $this->status != 2) {
$mform->addElement('submit', 'cancel', get_string('Back_to_task_list', 'block_pbltool'));
$mform->closeHeaderBefore('cancel');
} else {
$this->add_action_buttons();
}
}
}