3 require_once('../../config.php');
4 require_once('lib.php');
6 $id = required_param('id', PARAM_INT
); // course
8 $PAGE->set_url('/mod/chat/index.php', array('id'=>$id));
10 if (! $course = $DB->get_record('course', array('id'=>$id))) {
11 print_error('invalidcourseid');
14 require_course_login($course);
15 $PAGE->set_pagelayout('incourse');
18 'context' => context_course
::instance($id)
20 $event = \mod_chat\event\course_module_instance_list_viewed
::create($params);
21 $event->add_record_snapshot('course', $course);
24 /// Get all required strings
26 $strchats = get_string('modulenameplural', 'chat');
27 $strchat = get_string('modulename', 'chat');
31 $PAGE->navbar
->add($strchats);
32 $PAGE->set_title($strchats);
33 $PAGE->set_heading($course->fullname
);
34 echo $OUTPUT->header();
35 echo $OUTPUT->heading($strchats, 2);
37 /// Get all the appropriate data
39 if (! $chats = get_all_instances_in_course('chat', $course)) {
40 notice(get_string('thereareno', 'moodle', $strchats), "../../course/view.php?id=$course->id");
44 $usesections = course_format_uses_sections($course->format
);
46 /// Print the list of instances (your module will probably extend this)
49 $strname = get_string('name');
51 $table = new html_table();
54 $strsectionname = get_string('sectionname', 'format_'.$course->format
);
55 $table->head
= array ($strsectionname, $strname);
56 $table->align
= array ('center', 'left');
58 $table->head
= array ($strname);
59 $table->align
= array ('left');
63 foreach ($chats as $chat) {
64 if (!$chat->visible
) {
65 //Show dimmed if the mod is hidden
66 $link = "<a class=\"dimmed\" href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name
,true)."</a>";
68 //Show normal if the mod is visible
69 $link = "<a href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name
,true)."</a>";
72 if ($chat->section
!== $currentsection) {
74 $printsection = get_section_name($course, $chat->section
);
76 if ($currentsection !== '') {
77 $table->data
[] = 'hr';
79 $currentsection = $chat->section
;
82 $table->data
[] = array ($printsection, $link);
84 $table->data
[] = array ($link);
90 echo html_writer
::table($table);
94 echo $OUTPUT->footer();