1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// This program 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 |
// This program 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 |
* Index for edu-sharing plugin
|
|
|
19 |
*
|
|
|
20 |
* @package mod_edusharing
|
|
|
21 |
* @copyright metaVentis GmbH — http://metaventis.com
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
use mod_edusharing\event\course_module_instance_list_viewed;
|
|
|
26 |
|
|
|
27 |
require_once(dirname(__FILE__, 3) . '/config.php');
|
|
|
28 |
require_once(dirname(__FILE__) . '/lib.php');
|
|
|
29 |
|
|
|
30 |
global $DB, $PAGE, $OUTPUT;
|
|
|
31 |
|
|
|
32 |
try {
|
|
|
33 |
$id = required_param('id', PARAM_INT);
|
|
|
34 |
if (!$course = $DB->get_record('course', ['id' => $id])) {
|
|
|
35 |
trigger_error(get_string('error_load_course', 'edusharing'), E_USER_WARNING);
|
|
|
36 |
}
|
|
|
37 |
require_course_login($course);
|
|
|
38 |
$event = course_module_instance_list_viewed::create([
|
|
|
39 |
'context' => context_course::instance($course->id),
|
|
|
40 |
]);
|
|
|
41 |
$event->trigger();
|
|
|
42 |
$PAGE->set_url('mod/edusharing/view.php', ['id' => $id]);
|
|
|
43 |
$PAGE->set_title($course->fullname);
|
|
|
44 |
$PAGE->set_heading($course->shortname);
|
|
|
45 |
|
|
|
46 |
echo $OUTPUT->header();
|
|
|
47 |
|
|
|
48 |
if (!$edusharings = get_all_instances_in_course('edusharing', $course)) {
|
|
|
49 |
echo $OUTPUT->heading(get_string('noedusharings', 'edusharing'), 2);
|
|
|
50 |
echo $OUTPUT->continue_button("view.php?id=$course->id");
|
|
|
51 |
echo $OUTPUT->footer();
|
|
|
52 |
die();
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
$timenow = time();
|
|
|
57 |
$strname = get_string('name');
|
|
|
58 |
$strweek = get_string('week');
|
|
|
59 |
$strtopic = get_string('topic');
|
|
|
60 |
$table = new html_table();
|
|
|
61 |
if ($course->format == 'weeks') {
|
|
|
62 |
$table->head = [$strweek, $strname];
|
|
|
63 |
$table->align = ['center', 'left'];
|
|
|
64 |
} else if ($course->format == 'topics') {
|
|
|
65 |
$table->head = [$strtopic, $strname];
|
|
|
66 |
$table->align = ['center', 'left', 'left', 'left'];
|
|
|
67 |
} else {
|
|
|
68 |
$table->head = [$strname];
|
|
|
69 |
$table->align = ['left', 'left', 'left'];
|
|
|
70 |
}
|
|
|
71 |
foreach ($edusharings as $edusharing) {
|
|
|
72 |
if (!$edusharing->visible) {
|
|
|
73 |
// Show dimmed if the mod is hidden.
|
|
|
74 |
$link = '<a class="dimmed" href="view.php?id='
|
|
|
75 |
. $edusharing->coursemodule . '">' . format_string($edusharing->name) . '</a>';
|
|
|
76 |
} else {
|
|
|
77 |
// Show normal if the mod is visible.
|
|
|
78 |
$link = '<a href="view.php?id=' . $edusharing->coursemodule . '">' . format_string($edusharing->name) . '</a>';
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
if ($course->format == 'weeks' || $course->format == 'topics') {
|
|
|
82 |
$table->data[] = [$edusharing->section, $link];
|
|
|
83 |
} else {
|
|
|
84 |
$table->data[] = [$link];
|
|
|
85 |
}
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
echo $OUTPUT->heading(get_string('modulenameplural', 'mod_edusharing'), 2);
|
|
|
89 |
} catch (Exception $exception) {
|
|
|
90 |
debugging($exception->getLine() . ': ' . $exception->getMessage());
|
|
|
91 |
unset($exception);
|
|
|
92 |
echo('error');
|
|
|
93 |
die();
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
echo html_writer::table($table);
|
|
|
97 |
echo $OUTPUT->footer();
|