-
Notifications
You must be signed in to change notification settings - Fork 0
/
block_quickset.php
executable file
·136 lines (120 loc) · 5.88 KB
/
block_quickset.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
126
127
128
129
130
131
132
133
134
135
136
<?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/>.
/* Quickset to set most commonly changed course settings
* as well as rename, rearrange, insert and delete course sections
* @package quickset
* @author: Bob Puffer Luther College <[email protected]>
* @date: 2010 ->
*/
class block_quickset extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_quickset');
$this->cron = 1;
}
// Only one instance of this block is required
function instance_allow_multiple() {
return false;
}
// Label and button values can be set in admin
function has_config() {
return false;
}
function get_content() {
global $CFG, $COURSE, $USER, $PAGE, $DB;
$available = 1;
$unavailable = 0;
$updatesettings = get_string('updatesettings', 'block_quickset');
$blockinvisible = get_string('blockinvisible', 'block_quickset');
$moresettings = get_string('moresettings', 'block_quickset');
$editsections = get_string('editsections', 'block_quickset');
$this->content = new stdClass;
$returnurl = "$CFG->wwwroot/course/view.php?id=$COURSE->id";
$numsections = $DB->get_field('course_format_options', 'value', array('courseid' => $COURSE->id, 'name' => 'numsections', 'format' => $COURSE->format));
$context = context_course::instance($COURSE->id);
if (has_capability('moodle/course:update', $context)) {
if ($COURSE->visible == 1) {
$students = 'green';
$studentschecked = ' checked="checked"';
$studentsunchecked = '';
} else {
$students = 'red';
$studentsunchecked = ' checked="checked"';
$studentschecked = '';
}
if ($COURSE->showgrades == 1) {
$grades = 'green';
$gradeschecked = ' checked="checked"';
$gradesunchecked = '';
} else {
$grades = 'red';
$gradesunchecked = ' checked="checked"';
$gradeschecked = '';
}
$this->content->text = '<form id="quickset" action="' . $CFG->wwwroot . '/blocks/quickset/edit.php" method="post">'
. '<input type="hidden" value="'.$PAGE->course->id.'" name="courseid" />'
. '<input type="hidden" value="'.sesskey().'" name="sesskey" />'
. '<input type="hidden" value="' . $returnurl . '" name="pageurl"/>'
. '<input type="hidden" value="grader" name="report"/>';
$this->content->text .= '<div id="context">'
. '<div class="ynlabel" style="margin-right:0em">Yes | No</div>'
. '<div class="setleft ' . $students . '">Students see course?</div>'
. '<div class="setright">'
. '<span class="leftradio">'
. '<input type="radio" name="course" value=' . $available . $studentschecked . ' />'
. '</span>'
. '<span class="rightradio">'
. '<input type="radio" name="course" value=' . $unavailable . $studentsunchecked . ' />'
. '</span>'
. '</div>'
. '<div class="setleft ' . $grades . '">Grades visible?</div>'
. '<div>'
. '<span class="leftradio">'
. '<input type="radio" name="grades" value=' . $available . $gradeschecked . ' />'
. '</span>'
. '<span class="rightradio">'
. '<input type="radio" name="grades" value=' . $unavailable . $gradesunchecked . ' />'
. '</span>'
. '</div>'
. '<div class="setleft blue toplevel" >Visible sections </div>'
. '<div class="setright">'
. '<input type="text" class="numsections" name="number" value="'.$numsections.'"/>'
. '</div>'
. '<br /><br />'
. '<div>'
. '<span class="nodisplay defaultaction">'
. '<input type="submit" name="updatesettings" value="' . $updatesettings . '">'
. '</span>'
. '<span class="noaction">'
. '<input type="submit" name="noaction" value="' . $editsections . '">'
. '</span>'
. '<span class="updatesettings">'
. '<input type="submit" name="updatesettings" value="' . $updatesettings . '">'
. '</span>'
. '</div>'
. '<br /><br />'
. '<div class="textcenter">
<a href="' . $CFG->wwwroot . '/course/edit.php?id=' . $COURSE->id . '">' . $moresettings . '</a>
</div>'
. '</div></form>';
$this->content->text .= '<div class="smallred">"' . $blockinvisible . '"</div>';
}
$this->content->footer = '';
return $this->content;
}
function specialisation() {
// empty!
}
}