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 |
* This page lists all the instances of reengagement in a particular course
|
|
|
19 |
*
|
|
|
20 |
* @package mod_reengagement
|
|
|
21 |
* @author Peter Bulmer
|
|
|
22 |
* @copyright 2016 Catalyst IT {@link http://www.catalyst.net.nz}
|
|
|
23 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
24 |
*/
|
|
|
25 |
|
|
|
26 |
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
|
|
|
27 |
require_once(dirname(__FILE__).'/lib.php');
|
|
|
28 |
|
|
|
29 |
$id = required_param('id', PARAM_INT);
|
|
|
30 |
|
|
|
31 |
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
|
|
|
32 |
|
|
|
33 |
require_login($course);
|
|
|
34 |
|
|
|
35 |
// Get all required stringsreengagement.
|
|
|
36 |
$strreengagements = get_string('modulenameplural', 'reengagement');
|
|
|
37 |
$strreengagement = get_string('modulename', 'reengagement');
|
|
|
38 |
|
|
|
39 |
$params = array();
|
|
|
40 |
|
|
|
41 |
$params['id'] = $id;
|
|
|
42 |
|
|
|
43 |
$PAGE->set_url('/mod/reengagement/index.php', $params);
|
|
|
44 |
|
|
|
45 |
// Print the header.
|
|
|
46 |
|
|
|
47 |
$PAGE->set_title(format_string($strreengagements));
|
|
|
48 |
$PAGE->set_heading(format_string($course->fullname));
|
|
|
49 |
|
|
|
50 |
// Add the page view to the Moodle log.
|
|
|
51 |
$event = \mod_reengagement\event\course_module_instance_list_viewed::create(array(
|
|
|
52 |
'context' => context_course::instance($course->id)
|
|
|
53 |
));
|
|
|
54 |
$event->add_record_snapshot('course', $course);
|
|
|
55 |
$event->trigger();
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
echo $OUTPUT->header();
|
|
|
59 |
// Get all the appropriate data.
|
|
|
60 |
|
|
|
61 |
if (! $reengagements = get_all_instances_in_course('reengagement', $course)) {
|
|
|
62 |
notice('There are no instances of reengagement', "../../course/view.php?id=$course->id");
|
|
|
63 |
die;
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
// Print the list of instances.
|
|
|
67 |
|
|
|
68 |
$timenow = time();
|
|
|
69 |
$strname = get_string('name');
|
|
|
70 |
$strweek = get_string('week');
|
|
|
71 |
$strtopic = get_string('topic');
|
|
|
72 |
$strsectionname = get_string('sectionname', 'format_'.$course->format);
|
|
|
73 |
|
|
|
74 |
$usesections = course_format_uses_sections($course->format);
|
|
|
75 |
|
|
|
76 |
$table = new html_table();
|
|
|
77 |
$table->attributes['class'] = 'generaltable mod_index';
|
|
|
78 |
|
|
|
79 |
if ($usesections) {
|
|
|
80 |
$table->head = array ($strsectionname, $strname);
|
|
|
81 |
$table->align = array ('center', 'left', 'left');
|
|
|
82 |
} else {
|
|
|
83 |
$table->head = array ($strlastmodified, $strname);
|
|
|
84 |
$table->align = array ('left', 'left', 'left');
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
$modinfo = get_fast_modinfo($course);
|
|
|
89 |
$currentsection = '';
|
|
|
90 |
foreach ($reengagements as $reengagement) {
|
|
|
91 |
$cm = $modinfo->cms[$reengagement->coursemodule];
|
|
|
92 |
if ($usesections) {
|
|
|
93 |
$printsection = '';
|
|
|
94 |
if ($reengagement->section !== $currentsection) {
|
|
|
95 |
if ($reengagement->section) {
|
|
|
96 |
$printsection = get_section_name($course, $reengagement->section);
|
|
|
97 |
}
|
|
|
98 |
if ($currentsection !== '') {
|
|
|
99 |
$table->data[] = 'hr';
|
|
|
100 |
}
|
|
|
101 |
$currentsection = $reengagement->section;
|
|
|
102 |
}
|
|
|
103 |
} else {
|
|
|
104 |
$printsection = '<span class="smallinfo">'.userdate($reengagement->timemodified)."</span>";
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
$class = $reengagement->visible ? '' : 'class="dimmed"'; // Hidden modules are dimmed.
|
|
|
108 |
|
|
|
109 |
$table->data[] = array (
|
|
|
110 |
$printsection,
|
|
|
111 |
"<a $class href=\"view.php?id=$cm->id\">".format_string($reengagement->name)."</a>");
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
echo html_writer::table($table);
|
|
|
115 |
|
|
|
116 |
echo $OUTPUT->footer();
|
|
|
117 |
|