Proyectos de Subversion Moodle

Rev

Rev 1221 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1221 Rev 1441
Línea 22... Línea 22...
22
 * @package core_course
22
 * @package core_course
23
 */
23
 */
Línea 24... Línea 24...
24
 
24
 
25
require_once('../config.php');
25
require_once('../config.php');
26
require_once('lib.php');
26
require_once('lib.php');
Línea 27... Línea 27...
27
require_once($CFG->libdir . '/completionlib.php');
27
require_once($CFG->libdir.'/completionlib.php');
Línea 28... Línea 28...
28
 
28
 
29
redirect_if_major_upgrade_required();
29
redirect_if_major_upgrade_required();
30
 
30
 
31
$id = optional_param('id', 0, PARAM_INT);
31
$id = optional_param('id', 0, PARAM_INT);
32
$name = optional_param('name', '', PARAM_TEXT);
32
$name = optional_param('name', '', PARAM_TEXT);
33
$edit = optional_param('edit', -1, PARAM_BOOL);
33
$edit = optional_param('edit', -1, PARAM_BOOL);
34
$hide = optional_param('hide', 0, PARAM_INT);
34
$hide = optional_param('hide', 0, PARAM_INT); // TODO remove this param as part of MDL-83530.
35
$show = optional_param('show', 0, PARAM_INT);
35
$show = optional_param('show', 0, PARAM_INT); // TODO remove this param as part of MDL-83530.
36
$duplicatesection = optional_param('duplicatesection', 0, PARAM_INT);
36
$duplicatesection = optional_param('duplicatesection', 0, PARAM_INT);
37
$idnumber = optional_param('idnumber', '', PARAM_RAW);
37
$idnumber = optional_param('idnumber', '', PARAM_RAW);
38
$sectionid = optional_param('sectionid', 0, PARAM_INT);
38
$sectionid = optional_param('sectionid', 0, PARAM_INT);
39
$section = optional_param('section', null, PARAM_INT);
39
$section = optional_param('section', null, PARAM_INT);
40
$expandsection = optional_param('expandsection', -1, PARAM_INT);
40
$expandsection = optional_param('expandsection', -1, PARAM_INT);
41
$move = optional_param('move', 0, PARAM_INT);
41
$move = optional_param('move', 0, PARAM_INT); // TODO remove this param as part of MDL-83530.
Línea 42... Línea 42...
42
$marker = optional_param('marker', -1, PARAM_INT);
42
$marker = optional_param('marker', -1 , PARAM_INT); // TODO remove this param as part of MDL-83530.
43
$switchrole = optional_param('switchrole', -1, PARAM_INT); // Deprecated, use course/switchrole.php instead.
43
$switchrole = optional_param('switchrole', -1, PARAM_INT); // Deprecated, use course/switchrole.php instead.
Línea 84... Línea 84...
84
 
84
 
Línea 85... Línea 85...
85
require_login($course);
85
require_login($course);
86
 
86
 
87
// Switchrole - sanity check in cost-order...
-
 
88
$resetuserallowedediting = false;
87
// Switchrole - sanity check in cost-order...
89
if (
88
$resetuserallowedediting = false;
90
    $switchrole > 0 && confirm_sesskey() &&
-
 
91
    has_capability('moodle/role:switchroles', $context)
89
if ($switchrole > 0 && confirm_sesskey() &&
92
) {
90
    has_capability('moodle/role:switchroles', $context)) {
93
    // Is this role assignable in this context?
91
    // Is this role assignable in this context?
94
    // Inquiring minds want to know.
92
    // Inquiring minds want to know.
95
    $aroles = get_switchable_roles($context);
93
    $aroles = get_switchable_roles($context);
Línea 107... Línea 105...
107
    $resetuserallowedediting = true;
105
    $resetuserallowedediting = true;
108
}
106
}
Línea 109... Línea 107...
109
 
107
 
110
// If course is hosted on an external server, redirect to corresponding
108
// If course is hosted on an external server, redirect to corresponding
111
// url with appropriate authentication attached as parameter.
-
 
112
if (file_exists($CFG->dirroot . '/course/externservercourse.php')) {
109
// url with appropriate authentication attached as parameter.
113
    include($CFG->dirroot . '/course/externservercourse.php');
-
 
114
    if (function_exists('extern_server_course')) {
110
$hook = new \core_course\hook\before_course_viewed($course);
115
        if ($externurl = extern_server_course($course)) {
-
 
116
            redirect($externurl);
-
 
117
        }
-
 
118
    }
-
 
Línea 119... Línea 111...
119
}
111
\core\hook\manager::get_instance()->dispatch($hook);
Línea 120... Línea 112...
120
 
112
 
121
require_once($CFG->dirroot . '/calendar/lib.php'); // This is after login because it needs $USER.
113
require_once($CFG->dirroot.'/calendar/lib.php'); // This is after login because it needs $USER.
122
 
114
 
Línea 176... Línea 168...
176
if ($PAGE->user_allowed_editing()) {
168
if ($PAGE->user_allowed_editing()) {
177
    if (($edit == 1) && confirm_sesskey()) {
169
    if (($edit == 1) && confirm_sesskey()) {
178
        $USER->editing = 1;
170
        $USER->editing = 1;
179
        // Redirect to site root if Editing is toggled on frontpage.
171
        // Redirect to site root if Editing is toggled on frontpage.
180
        if ($course->id == SITEID) {
172
        if ($course->id == SITEID) {
181
            redirect($CFG->wwwroot . '/?redirect=0');
173
            redirect($CFG->wwwroot .'/?redirect=0');
182
        } else if (!empty($return)) {
174
        } else if (!empty($return)) {
183
            redirect($CFG->wwwroot . $return);
175
            redirect($CFG->wwwroot . $return);
184
        } else {
176
        } else {
185
            $url = new moodle_url($PAGE->url, ['notifyeditingon' => 1]);
177
            $url = new moodle_url($PAGE->url, ['notifyeditingon' => 1]);
186
            redirect($url);
178
            redirect($url);
Línea 191... Línea 183...
191
            $USER->activitycopy = false;
183
            $USER->activitycopy = false;
192
            $USER->activitycopycourse = null;
184
            $USER->activitycopycourse = null;
193
        }
185
        }
194
        // Redirect to site root if Editing is toggled on frontpage.
186
        // Redirect to site root if Editing is toggled on frontpage.
195
        if ($course->id == SITEID) {
187
        if ($course->id == SITEID) {
196
            redirect($CFG->wwwroot . '/?redirect=0');
188
            redirect($CFG->wwwroot .'/?redirect=0');
197
        } else if (!empty($return)) {
189
        } else if (!empty($return)) {
198
            redirect($CFG->wwwroot . $return);
190
            redirect($CFG->wwwroot . $return);
199
        } else {
191
        } else {
200
            redirect($PAGE->url);
192
            redirect($PAGE->url);
201
        }
193
        }
202
    }
194
    }
Línea -... Línea 195...
-
 
195
 
203
 
196
    // TODO remove this if as part of MDL-83530.
204
    if (has_capability('moodle/course:sectionvisibility', $context)) {
197
    if (has_capability('moodle/course:sectionvisibility', $context)) {
-
 
198
        if ($hide && confirm_sesskey()) {
-
 
199
            debugging(
-
 
200
                'The hide param in course view is deprecated. Please use course/format/update.php instead.',
-
 
201
                DEBUG_DEVELOPER
205
        if ($hide && confirm_sesskey()) {
202
            );
206
            set_section_visible($course->id, $hide, '0');
203
            set_section_visible($course->id, $hide, '0');
207
            if ($sectionid) {
204
            if ($sectionid) {
208
                redirect(course_get_url($course, $section, ['navigation' => true]));
205
                redirect(course_get_url($course, $section, ['navigation' => true]));
209
            } else {
206
            } else {
210
                redirect($PAGE->url);
207
                redirect($PAGE->url);
211
            }
208
            }
Línea 212... Línea 209...
212
        }
209
        }
-
 
210
 
-
 
211
        if ($show && confirm_sesskey()) {
-
 
212
            debugging(
-
 
213
                'The show param in course view is deprecated. Please use course/format/update.php instead.',
213
 
214
                DEBUG_DEVELOPER
214
        if ($show && confirm_sesskey()) {
215
            );
215
            set_section_visible($course->id, $show, '1');
216
            set_section_visible($course->id, $show, '1');
216
            if ($sectionid) {
217
            if ($sectionid) {
217
                redirect(course_get_url($course, $section, ['navigation' => true]));
218
                redirect(course_get_url($course, $section, ['navigation' => true]));
218
            } else {
219
            } else {
219
                redirect($PAGE->url);
220
                redirect($PAGE->url);
220
            }
221
            }
Línea -... Línea 222...
-
 
222
        }
221
        }
223
    }
-
 
224
 
-
 
225
    // TODO remove this if as part of MDL-83530.
-
 
226
    if ($marker >= 0 && confirm_sesskey()) {
-
 
227
        debugging(
222
    }
228
            'The marker param in course view is deprecated. Please use course/format/update.php instead.',
223
 
229
            DEBUG_DEVELOPER
224
    if ($marker >= 0 && confirm_sesskey()) {
230
        );
225
        course_set_marker($course->id, $marker);
231
        course_set_marker($course->id, $marker);
226
        if ($sectionid) {
232
        if ($sectionid) {
Línea 236... Línea 242...
236
    ) {
242
    ) {
237
        $newsection = $format->duplicate_section($coursesections);
243
        $newsection = $format->duplicate_section($coursesections);
238
        redirect(course_get_url($course, $newsection->section));
244
        redirect(course_get_url($course, $newsection->section));
239
    }
245
    }
Línea -... Línea 246...
-
 
246
 
240
 
247
    // TODO remove this if as part of MDL-83530.
-
 
248
    if (
241
    if (
249
        !empty($section)
242
        !empty($section) && !empty($move) &&
250
        && !empty($move)
243
        has_capability('moodle/course:movesections', $context) && confirm_sesskey()
251
        && has_capability('moodle/course:movesections', $context) && confirm_sesskey()
-
 
252
    ) {
-
 
253
        debugging(
-
 
254
            'The move param is deprecated. Please use the standard move modal instead.',
-
 
255
            DEBUG_DEVELOPER
244
    ) {
256
        );
245
        $destsection = $section + $move;
257
        $destsection = $section + $move;
246
        if (move_section_to($course, $section, $destsection)) {
258
        if (move_section_to($course, $section, $destsection)) {
247
            if ($course->id == SITEID) {
259
            if ($course->id == SITEID) {
248
                redirect($CFG->wwwroot . '/?redirect=0');
260
                redirect($CFG->wwwroot . '/?redirect=0');
Línea 264... Línea 276...
264
$SESSION->fromdiscussion = $PAGE->url->out(false);
276
$SESSION->fromdiscussion = $PAGE->url->out(false);
Línea 265... Línea 277...
265
 
277
 
266
 
278
 
267
if ($course->id == SITEID) {
279
if ($course->id == SITEID) {
268
    // This course is not a real course.
280
    // This course is not a real course.
Línea 269... Línea 281...
269
    redirect($CFG->wwwroot . '/?redirect=0');
281
    redirect($CFG->wwwroot .'/?redirect=0');
270
}
282
}
Línea 286... Línea 298...
286
    $editingtitle = 'editing';
298
    $editingtitle = 'editing';
287
}
299
}
Línea 288... Línea 300...
288
 
300
 
289
// If viewing a section, make the title more specific.
301
// If viewing a section, make the title more specific.
290
if ($section && $section > 0 && course_format_uses_sections($course->format)) {
302
if ($section && $section > 0 && course_format_uses_sections($course->format)) {
291
    $sectionname = get_string('sectionname', "format_$course->format");
303
    $sectionname = $format->get_generic_section_name();
292
    $sectiontitle = get_section_name($course, $section);
304
    $sectiontitle = $format->get_section_name($section);
293
    $PAGE->set_title(
305
    $PAGE->set_title(
294
        get_string(
306
        get_string(
295
            'coursesectiontitle' . $editingtitle,
307
            'coursesectiontitle' . $editingtitle,
296
            'moodle',
308
            'moodle',
Línea 306... Línea 318...
306
if (!empty($bulkbutton)) {
318
if (!empty($bulkbutton)) {
307
    $PAGE->add_header_action($bulkbutton);
319
    $PAGE->add_header_action($bulkbutton);
308
}
320
}
Línea 309... Línea 321...
309
 
321
 
-
 
322
$PAGE->set_heading($course->fullname);
-
 
323
 
-
 
324
// Make sure that section 0 exists (this function will create one if it is missing).
-
 
325
course_create_sections_if_missing($course, 0);
-
 
326
 
-
 
327
// Get information about course modules and existing module types.
-
 
328
// format.php in course formats may rely on presence of these variables.
-
 
329
$modinfo = get_fast_modinfo($course);
-
 
330
$modnames = get_module_types_names();
-
 
331
$modnamesplural = get_module_types_names(true);
-
 
332
$modnamesused = $modinfo->get_used_module_names();
-
 
333
$mods = $modinfo->get_cms();
-
 
334
$sections = $modinfo->get_section_info_all();
-
 
335
 
-
 
336
// Include course AJAX. This should be done before starting the UI
-
 
337
// to allow page header, blocks, or drawers use the course editor.
-
 
338
include_course_ajax($course, $modnamesused);
310
$PAGE->set_heading($course->fullname);
339
 
Línea 311... Línea 340...
311
echo $OUTPUT->header();
340
echo $OUTPUT->header();
312
 
341
 
313
// Show communication room status notification.
342
// Show communication room status notification.
314
if (has_capability('moodle/course:update', $context)) {
343
if (has_capability('moodle/course:update', $context)) {
Línea -... Línea 344...
-
 
344
    core_communication\helper::get_course_communication_status_notification($course);
315
    core_communication\helper::get_course_communication_status_notification($course);
345
}
316
}
-
 
317
 
346
 
318
if ($USER->editing == 1) {
347
$containerattributes = ['class' => 'course-content'];
Línea 319... Línea 348...
319
 
348
if ($PAGE->user_is_editing()) {
320
    // MDL-65321 The backup libraries are quite heavy, only require the bare minimum.
349
    // MDL-65321 The backup libraries are quite heavy, only require the bare minimum.
321
    require_once($CFG->dirroot . '/backup/util/helper/async_helper.class.php');
350
    require_once($CFG->dirroot . '/backup/util/helper/async_helper.class.php');
-
 
351
 
-
 
352
    if (async_helper::is_async_pending($id, 'course', 'backup')) {
-
 
353
        echo $OUTPUT->notification(get_string('pendingasyncedit', 'backup'), 'warning');
322
 
354
    }
Línea 323... Línea 355...
323
    if (async_helper::is_async_pending($id, 'course', 'backup')) {
355
 
324
        echo $OUTPUT->notification(get_string('pendingasyncedit', 'backup'), 'warning');
356
    // Allow drag and drop in the course index.
325
    }
-
 
326
}
-
 
327
 
-
 
328
// Course wrapper start.
-
 
329
echo html_writer::start_tag('div', ['class' => 'course-content']);
-
 
330
 
-
 
331
// Make sure that section 0 exists (this function will create one if it is missing).
-
 
332
course_create_sections_if_missing($course, 0);
-
 
333
 
-
 
334
// Get information about course modules and existing module types.
-
 
335
// format.php in course formats may rely on presence of these variables.
-
 
336
$modinfo = get_fast_modinfo($course);
-
 
Línea 337... Línea 357...
337
$modnames = get_module_types_names();
357
    $containerattributes['data-courseindexdndallowed'] = 'true';
338
$modnamesplural = get_module_types_names(true);
358
}
339
$modnamesused = $modinfo->get_used_module_names();
359
 
340
$mods = $modinfo->get_cms();
360
// Course wrapper start.
Línea 341... Línea -...
341
$sections = $modinfo->get_section_info_all();
-
 
342
 
-
 
343
// CAUTION, hacky fundamental variable defintion to follow!
-
 
344
// Note that because of the way course fromats are constructed though
361
echo html_writer::start_tag('div', $containerattributes);
345
// inclusion we pass parameters around this way.
362
 
346
$displaysection = $section;
363
// CAUTION, hacky fundamental variable defintion to follow!
Línea 347... Línea 364...
347
 
364
// Note that because of the way course fromats are constructed though
Línea 348... Línea 365...
348
// Include course AJAX.
365
// inclusion we pass parameters around this way.