-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration_class.php
98 lines (85 loc) · 3.35 KB
/
configuration_class.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 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/>.
// All rights reserved
/**
* @package moodlecore
* @subpackage blocks
* @copyright 2013 gtn gmbh
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
*/
require("inc.php");
require_once($CFG->dirroot . '/blocks/exastud/lib/edit_form.php');
global $DB, $OUTPUT, $PAGE;
$courseid = optional_param('courseid', 1, PARAM_INT); // Course ID
$showall = optional_param('showall', 0, PARAM_BOOL);
$searchtext = optional_param('searchtext', '', PARAM_ALPHANUM); // search string
require_login($courseid);
$PAGE->requires->css('/blocks/styles.css');
//$context = get_context_instance(CONTEXT_COURSE,$courseid);
$context = context_course::instance($courseid);
require_capability('block/exastud:use', $context);
require_capability('block/exastud:headteacher', $context);
$curPeriod = block_exabis_student_review_get_active_period(true);
if (!$class = $DB->get_record('block_exastudclass', array('userid'=>$USER->id,'periodid' => $curPeriod->id))) {
$class = new stdClass();
$class->courseid = $courseid;
$class->class = '';
}
$class->courseid = $courseid;
$classform = new class_edit_form();
if ($classform->is_cancelled()) {
redirect('configuration.php?courseid=' . $courseid);
} else if ($classedit = $classform->get_data()) {
if(!confirm_sesskey()) {
print_error("badsessionkey","block_exastud");
}
$newclass = new stdClass();
$newclass->timemodified = time();
$newclass->userid = $USER->id;
$newclass->class = $classedit->class;
$newclass->periodid = $curPeriod->id;
if(isset($class->id)) {
$newclass->id = $class->id;
if (!$DB->update_record('block_exastudclass', $newclass)) {
error('errorupdatingclass', 'block_exastud');
}
}
else {
if (!($class->id = $DB->insert_record('block_exastudclass', $newclass))) {
error('errorinsertingclass', 'block_exastud');
}
}
redirect('configuration.php?courseid=' . $courseid);
}
$url = "/blocks/exastud/configuration_class.php";
$PAGE->set_url($url);
block_exabis_student_review_print_header(array('configuration', 'editclassname'));
echo '<div id="block_student_review">';
echo "<br />";
echo $OUTPUT->box( text_to_html(block_exabis_student_review_get_string("explainclassname","block_exastud")));
echo '</div>';
echo '<div id="block_student_review">';
echo $OUTPUT->heading($class->class);
$classform->set_data($class);
$classform->display();
echo '</div>';
block_exabis_student_review_print_footer();