Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
/**
18
 * View all instances of subcourse in a particular course
19
 *
20
 * @package     mod_subcourse
21
 * @copyright   2008 David Mudrak <david@moodle.com>
22
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
26
require_once(dirname(__FILE__).'/lib.php');
27
 
28
$id = required_param('id', PARAM_INT);
29
 
30
$course = $DB->get_record('course', ['id' => $id], '*', MUST_EXIST);
31
 
32
require_course_login($course);
33
 
34
$PAGE->set_url(new moodle_url('/mod/subcourse/index.php', ['id' => $id]));
35
$PAGE->set_title($course->fullname);
36
$PAGE->set_heading($course->shortname);
37
$PAGE->set_pagelayout('incourse');
38
$PAGE->navbar->add(get_string('modulenameplural', 'subcourse'));
39
 
40
$event = \mod_subcourse\event\course_module_instance_list_viewed::create([
41
    'context' => context_course::instance($course->id)
42
]);
43
$event->add_record_snapshot('course', $course);
44
$event->trigger();
45
 
46
echo $OUTPUT->header();
47
 
48
if (!$subcourses = get_all_instances_in_course('subcourse', $course)) {
49
    echo $OUTPUT->heading(get_string('nosubcourses', 'subcourse'), 2);
50
    echo $OUTPUT->continue_button(new moodle_url('/course/view.php', ['id' => $course->id]));
51
    echo $OUTPUT->footer();
52
    die();
53
}
54
 
55
$usesections = course_format_uses_sections($course->format);
56
 
57
$timenow = time();
58
$strsectionname = get_string('sectionname', 'format_'.$course->format);
59
$strname = get_string('subcoursename', 'subcourse');
60
$strdesc = get_string('moduleintro');
61
 
62
$table = new html_table();
63
$table->id = 'subcourseslist';
64
 
65
if ($usesections) {
66
    $table->head  = array ($strsectionname, $strname, $strdesc);
67
    $table->align = array ('center', 'left', 'left');
68
} else {
69
    $table->head  = array ($strname, $strdesc);
70
    $table->align = array ('left', 'left');
71
}
72
 
73
foreach ($subcourses as $subcourse) {
74
    $attributes = [];
75
    if (empty($subcourse->visible)) {
76
        $attributes['class'] = 'dimmed';
77
    }
78
    $link = html_writer::link(new moodle_url('/mod/subcourse/view.php',
79
        ['id' => $subcourse->coursemodule]), format_string($subcourse->name), $attributes);
80
    $description = format_module_intro('subcourse', $subcourse, $subcourse->coursemodule);
81
    if ($usesections) {
82
        $table->data[] = [get_section_name($course, $subcourse->section), $link, $description];
83
    } else {
84
        $table->data[] = [$link, $description];
85
    }
86
}
87
 
88
echo $OUTPUT->heading(get_string('modulenameplural', 'subcourse'));
89
echo html_writer::table($table);
90
echo $OUTPUT->footer();