-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathlib.php
211 lines (199 loc) · 8.39 KB
/
lib.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?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/>.
/**
* This file contains main class for the course format Socialwall
*
* @since Moodle 2.7
* @package format_socialwall
* @copyright 2014 Andreas Wagner, Synergy Learning
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/course/format/topics/lib.php');
require_once($CFG->dirroot . '/course/format/socialwall/locallib.php');
require_once($CFG->dirroot . '/course/format/socialwall/pages/post_form.php');
/**
* Main class for the socialwall course format
*
* @package format_socialwall
* @copyright 2014 Andreas Wagner, Synergy Learning
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class format_socialwall extends format_topics {
public static $numsections = 3;
/**
* Custom action after section has been moved in AJAX mode
*
* Used in course/rest.php
*
* @return array This will be passed in ajax respose
*/
public function ajax_section_move() {
return null;
}
/**
* Returns the list of blocks to be automatically added for the newly created course
*
* @return array of default blocks, must contain two keys BLOCK_POS_LEFT and BLOCK_POS_RIGHT
* each of values is an array of block names (for left and right side columns)
*/
public function get_default_blocks() {
return array(
BLOCK_POS_LEFT => array(),
BLOCK_POS_RIGHT => array()
);
}
/**
* The URL to use for the specified course (with section)
*
* Please note that course view page /course/view.php?id=COURSEID is hardcoded in many
* places in core and contributed modules. If course format wants to change the location
* of the view script, it is not enough to change just this function. Do not forget
* to add proper redirection.
*
* @param int|stdClass $section Section object from database or just field course_sections.section
* if null the course view page is returned
* @param array $options options for view URL. At the moment core uses:
* 'navigation' (bool) if true and section has no separate page, the function returns null
* 'sr' (int) used by multipage formats to specify to which section to return
* @return null|moodle_url
*/
public function get_view_url($section, $options = array()) {
$course = $this->get_course();
$url = new moodle_url('/course/view.php', array('id' => $course->id));
return $url;
}
/**
* Definitions of the additional options that this course format uses for course
*
* socialwall format uses the following options:
* - coursedisplay
* - numsections
* - hiddensections
*
* @param bool $foreditform
* @return array of options
*/
public function course_format_options($foreditform = false) {
static $courseformatoptions = false;
if ($courseformatoptions === false) {
$courseconfig = get_config('format_socialwall');
$courseformatoptions = array(
'enablenotification' => array(
'default' => $courseconfig->enablenotification,
'type' => PARAM_BOOL,
),
'enablelikes' => array(
'default' => $courseconfig->enablelikes,
'type' => PARAM_BOOL,
),
'enablestudentupload' => array(
'default' => $courseconfig->enablestudentupload,
'type' => PARAM_BOOL,
),
'tlnumposts' => array(
'default' => $courseconfig->tlnumposts,
'type' => PARAM_INT,
),
'tlnumcomments' => array(
'default' => $courseconfig->tlnumcomments,
'type' => PARAM_INT,
),
'tlnumreplies' => array(
'default' => $courseconfig->tlnumreplies,
'type' => PARAM_INT,
),
'numsections' => array(
'default' => self::$numsections,
'type' => PARAM_INT,
),
'deleteafterunenrol' => array(
'default' => $courseconfig->deleteafterunenrol,
'type' => PARAM_BOOL
),
'deletemodspermanently' => array(
'default' => $courseconfig->deleteafterunenrol,
'type' => PARAM_BOOL
)
);
}
if ($foreditform && !isset($courseformatoptions['enablenotification']['label'])) {
$nums = array(
'1' => 1,
'2' => 2,
'3' => 3,
'4' => 4,
'5' => 5,
'10' => 10,
'20' => 20
);
$courseformatoptionsedit = array(
'enablenotification' => array(
'label' => new lang_string('enablenotification', 'format_socialwall'),
'element_type' => 'selectyesno',
'help' => 'enablenotification',
'help_component' => 'format_socialwall'
),
'enablelikes' => array(
'label' => new lang_string('enablelikes', 'format_socialwall'),
'element_type' => 'selectyesno',
'help' => 'enablelikes',
'help_component' => 'format_socialwall'
),
'enablestudentupload' => array(
'label' => new lang_string('enablestudentupload', 'format_socialwall'),
'element_type' => 'selectyesno',
'help' => 'enablestudentupload',
'help_component' => 'format_socialwall',
),
'tlnumposts' => array(
'label' => new lang_string('tlnumposts', 'format_socialwall'),
'element_type' => 'select',
'element_attributes' => array($nums),
),
'tlnumcomments' => array(
'label' => new lang_string('tlnumcomments', 'format_socialwall'),
'element_type' => 'select',
'element_attributes' => array($nums),
),
'tlnumreplies' => array(
'label' => new lang_string('tlnumreplies', 'format_socialwall'),
'element_type' => 'select',
'element_attributes' => array($nums),
),
'deleteafterunenrol' => array(
'label' => new lang_string('deleteafterunenrol', 'format_socialwall'),
'element_type' => 'selectyesno',
'help' => 'deleteafterunenrol',
'help_component' => 'format_socialwall'
),
'deletemodspermanently' => array(
'label' => new lang_string('deletemodspermanently', 'format_socialwall'),
'element_type' => 'selectyesno',
'help' => 'deletemodspermanently',
'help_component' => 'format_socialwall'
),
'numsections' => array(
// Hidden element needs label value for correct setting of value, because label value is the 3rd parameter for addElement() method.
'label' => self::$numsections,
'element_type' => 'hidden'
)
);
$courseformatoptions = array_merge_recursive($courseformatoptions, $courseformatoptionsedit);
}
return $courseformatoptions;
}
}