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 * This is a one-line short description of the file
21 * You can have a rather longer description of the file as well,
22 * if you like, and it can span multiple lines.
25 * @subpackage workshop
26 * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30 /// Replace workshop with the name of your module and remove this line
32 require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
33 require_once(dirname(__FILE__).'/lib.php');
35 $id = required_param('id', PARAM_INT); // course
37 if (! $course = $DB->get_record('course', array('id' => $id))) {
38 error('Course ID is incorrect');
41 require_course_login($course);
43 add_to_log($course->id, 'workshop', 'view all', "index.php?id=$course->id", '');
45 $PAGE->set_url('/mod/workshop/view.php', array('id' => $id));
46 $PAGE->set_title($course->fullname);
47 $PAGE->set_heading($course->shortname);
48 $PAGE->navbar->add(get_string('modulenameplural', 'workshop'));
50 /// Output starts here
52 echo $OUTPUT->header();
54 /// Get all the appropriate data
56 if (! $workshops = get_all_instances_in_course('workshop', $course)) {
57 echo $OUTPUT->heading(get_string('noworkshops', 'workshop'), 2);
58 echo $OUTPUT->continue_button(new moodle_url('/course/view.php', array('id' => $course->id)));
59 echo $OUTPUT->footer();
63 $usesections = course_format_uses_sections($course->format);
65 $sections = get_all_sections($course->id);
68 /// Print the list of instances (your module will probably extend this)
71 $strsectionname = get_string('sectionname', 'format_'.$course->format);
72 $strname = get_string('name');
74 $table = new html_table();
76 $table->head = array ($strsectionname, $strname);
77 $table->align = array ('center', 'left');
79 $table->head = array ($strname);
80 $table->align = array ('left');
83 foreach ($workshops as $workshop) {
84 if (!$workshop->visible) {
85 //Show dimmed if the mod is hidden
86 $link = "<a class=\"dimmed\" href=\"view.php?id=$workshop->coursemodule\">$workshop->name</a>";
88 //Show normal if the mod is visible
89 $link = "<a href=\"view.php?id=$workshop->coursemodule\">$workshop->name</a>";
93 $table->data[] = array (get_section_name($course, $sections[$workshop->section]), $link);
95 $table->data[] = array ($link);
99 echo $OUTPUT->heading(get_string('modulenameplural', 'workshop'), 2);
100 echo html_writer::table($table);
104 echo $OUTPUT->footer();