-
Notifications
You must be signed in to change notification settings - Fork 0
/
team_section.php
121 lines (90 loc) · 3.33 KB
/
team_section.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
<?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/>.
/**
*
* @package block_cps
* @copyright 2014 Louisiana State University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../config.php';
require_once 'classes/lib.php';
require_once 'team_section_form.php';
require_login();
if (!cps_team_request::is_enabled()) {
print_error('not_enabled', 'block_cps', '', cps_team_request::name());
}
if (!ues_user::is_teacher()) {
print_error('not_teacher', 'block_cps');
}
$teacher = ues_teacher::get(array('userid' => $USER->id));
$sections = cps_unwant::active_sections_for($teacher);
if (empty($sections)) {
print_error('no_section', 'block_cps');
}
$semesters = ues_semester::merge_sections($sections);
$key = required_param('id', PARAM_RAW);
list($semid, $couid) = explode('_', $key);
if (!isset($semesters[$semid]) or !isset($semesters[$semid]->courses[$couid])) {
print_error('not_course', 'block_cps');
}
$semester = $semesters[$semid];
$course = $semester->courses[$couid];
$current_requests = cps_team_request::in_course($course, $semester, true);
if (empty($current_requests)) {
print_error('not_approved', 'block_cps');
}
$initial_data = array(
'course' => $course,
'semester' => $semester,
'requests' => $current_requests
);
$_s = ues::gen_str('block_cps');
$blockname = $_s('pluginname');
$heading = cps_team_request::name();
$context = context_system::instance();
$PAGE->set_context($context);
$PAGE->set_heading($blockname . ': '. $heading);
$PAGE->navbar->add($blockname);
$PAGE->navbar->add($heading);
$PAGE->set_title($heading);
$PAGE->set_url('/blocks/cps/team_section.php', array('id' => $key));
$PAGE->set_pagetype('cps-teamteach');
$PAGE->requires->jquery();
$PAGE->requires->js('/blocks/cps/js/selection.js');
$PAGE->requires->js('/blocks/cps/js/crosslist.js');
$form = cps_form::create('team_section', $initial_data);
if ($form->is_cancelled()) {
redirect(new moodle_url('/blocks/cps/team_request.php'));
} else if ($data = $form->get_data()) {
if (isset($data->back)) {
$form->next = $form->prev;
} else if ($form->next == team_section_form::FINISHED) {
$form = new team_section_form_finish();
try {
$form->process($data, $initial_data);
$form->display();
} catch (Exception $e) {
echo $OUTPUT->notification($_s('application_errors', $e->getMessage()));
echo $OUTPUT->continue_button('/my');
}
die();
}
$form = cps_form::next_from('team_section', $form->next, $data, $initial_data);
}
echo $OUTPUT->header();
echo $OUTPUT->heading_with_help($heading, 'team_manage_sections', 'block_cps');
$form->display();
echo $OUTPUT->footer();