1 <?php 2 3 // This file is part of Moodle - http://moodle.org/ 4 // 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. 9 // 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. 14 // 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/>. 17 18 /** 19 * Prints the list of all workshops in the course 20 * 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 24 */ 25 26 require(__DIR__.'/../../config.php'); 27 require_once (__DIR__.'/lib.php'); 28 29 $id = required_param('id', PARAM_INT); // course 30 31 $course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST); 32 33 require_course_login($course); 34 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')); 40 41 /// Output starts here 42 43 echo $OUTPUT->header(); 44 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); 48 $event->trigger(); 49 50 /// Get all the appropriate data 51 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(); 56 die(); 57 } 58 59 $usesections = course_format_uses_sections($course->format); 60 61 $timenow = time(); 62 $strname = get_string('name'); 63 $table = new html_table(); 64 65 if ($usesections) { 66 $strsectionname = get_string('sectionname', 'format_'.$course->format); 67 $table->head = array ($strsectionname, $strname); 68 $table->align = array ('center', 'left'); 69 } else { 70 $table->head = array ($strname); 71 $table->align = array ('left'); 72 } 73 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')); 78 } else { 79 $link = html_writer::link(new moodle_url('/mod/workshop/view.php', array('id' => $workshop->coursemodule)), 80 $workshop->name); 81 } 82 83 if ($usesections) { 84 $table->data[] = array(get_section_name($course, $workshop->section), $link); 85 } else { 86 $table->data[] = array($link); 87 } 88 } 89 echo $OUTPUT->heading(get_string('modulenameplural', 'workshop'), 3); 90 echo html_writer::table($table); 91 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body