3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
19 * Prints the list of all workshops in the course
21 * @package mod_workshop
22 * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 require(__DIR__
.'/../../config.php');
27 require_once(__DIR__
.'/lib.php');
29 $id = required_param('id', PARAM_INT
); // course
31 $course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST
);
33 require_course_login($course);
35 $PAGE->set_pagelayout('incourse');
36 $PAGE->set_url('/mod/workshop/index.php', array('id' => $course->id
));
37 $PAGE->set_title($course->fullname
);
38 $PAGE->set_heading($course->shortname
);
39 $PAGE->navbar
->add(get_string('modulenameplural', 'workshop'));
41 /// Output starts here
43 echo $OUTPUT->header();
45 $params = array('context' => context_course
::instance($course->id
));
46 $event = \mod_workshop\event\course_module_instance_list_viewed
::create($params);
47 $event->add_record_snapshot('course', $course);
50 /// Get all the appropriate data
52 if (! $workshops = get_all_instances_in_course('workshop', $course)) {
53 echo $OUTPUT->heading(get_string('modulenameplural', 'workshop'));
54 notice(get_string('noworkshops', 'workshop'), new moodle_url('/course/view.php', array('id' => $course->id
)));
55 echo $OUTPUT->footer();
59 $usesections = course_format_uses_sections($course->format
);
62 $strname = get_string('name');
63 $table = new html_table();
66 $strsectionname = get_string('sectionname', 'format_'.$course->format
);
67 $table->head
= array ($strsectionname, $strname);
68 $table->align
= array ('center', 'left');
70 $table->head
= array ($strname);
71 $table->align
= array ('left');
74 foreach ($workshops as $workshop) {
75 if (empty($workshop->visible
)) {
76 $link = html_writer
::link(new moodle_url('/mod/workshop/view.php', array('id' => $workshop->coursemodule
)),
77 $workshop->name
, array('class' => 'dimmed'));
79 $link = html_writer
::link(new moodle_url('/mod/workshop/view.php', array('id' => $workshop->coursemodule
)),
84 $table->data
[] = array(get_section_name($course, $workshop->section
), $link);
86 $table->data
[] = array($link);
89 echo $OUTPUT->heading(get_string('modulenameplural', 'workshop'), 3);
90 echo html_writer
::table($table);
91 echo $OUTPUT->footer();