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
22 * @subpackage workshop
23 * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 require_once(dirname(dirname(dirname(__FILE__
))).'/config.php');
28 require_once(dirname(__FILE__
).'/lib.php');
30 $id = required_param('id', PARAM_INT
); // course
32 $course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST
);
34 require_course_login($course);
36 add_to_log($course->id
, 'workshop', 'view all', "index.php?id=$course->id", '');
38 $PAGE->set_pagelayout('incourse');
39 $PAGE->set_url('/mod/workshop/index.php', array('id' => $course->id
));
40 $PAGE->set_title($course->fullname
);
41 $PAGE->set_heading($course->shortname
);
42 $PAGE->navbar
->add(get_string('modulenameplural', 'workshop'));
44 /// Output starts here
46 echo $OUTPUT->header();
48 /// Get all the appropriate data
50 if (! $workshops = get_all_instances_in_course('workshop', $course)) {
51 echo $OUTPUT->heading(get_string('noworkshops', 'workshop'), 2);
52 echo $OUTPUT->continue_button(new moodle_url('/course/view.php', array('id' => $course->id
)));
53 echo $OUTPUT->footer();
57 $usesections = course_format_uses_sections($course->format
);
59 $sections = get_all_sections($course->id
);
63 $strsectionname = get_string('sectionname', 'format_'.$course->format
);
64 $strname = get_string('name');
65 $table = new html_table();
68 $table->head
= array ($strsectionname, $strname);
69 $table->align
= array ('center', 'left');
71 $table->head
= array ($strname);
72 $table->align
= array ('left');
75 foreach ($workshops as $workshop) {
76 if (empty($workshop->visible
)) {
77 $link = html_writer
::link(new moodle_url('/mod/workshop/view.php', array('id' => $workshop->coursemodule
)),
78 $workshop->name
, array('class' => 'dimmed'));
80 $link = html_writer
::link(new moodle_url('/mod/workshop/view.php', array('id' => $workshop->coursemodule
)),
85 $table->data
[] = array(get_section_name($course, $sections[$workshop->section
]), $link);
87 $table->data
[] = array($link);
91 echo $OUTPUT->heading(get_string('modulenameplural', 'workshop'), 2);
92 echo html_writer
::table($table);
93 echo $OUTPUT->footer();