See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]
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 * This page lists all the instances of lesson in a particular course 20 * 21 * @package mod_lesson 22 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 **/ 25 26 /** Include required files */ 27 require_once("../../config.php"); 28 require_once($CFG->dirroot.'/mod/lesson/locallib.php'); 29 30 $id = required_param('id', PARAM_INT); // course 31 32 $PAGE->set_url('/mod/lesson/index.php', array('id'=>$id)); 33 34 if (!$course = $DB->get_record("course", array("id" => $id))) { 35 throw new \moodle_exception('invalidcourseid'); 36 } 37 38 require_login($course); 39 $PAGE->set_pagelayout('incourse'); 40 41 // Trigger instances list viewed event. 42 $params = array( 43 'context' => context_course::instance($course->id) 44 ); 45 $event = \mod_lesson\event\course_module_instance_list_viewed::create($params); 46 $event->add_record_snapshot('course', $course); 47 $event->trigger(); 48 49 /// Get all required strings 50 51 $strlessons = get_string("modulenameplural", "lesson"); 52 $strlesson = get_string("modulename", "lesson"); 53 54 55 /// Print the header 56 $PAGE->navbar->add($strlessons); 57 $PAGE->set_title("$course->shortname: $strlessons"); 58 $PAGE->set_heading($course->fullname); 59 echo $OUTPUT->header(); 60 echo $OUTPUT->heading($strlessons, 2); 61 62 /// Get all the appropriate data 63 64 if (! $lessons = get_all_instances_in_course("lesson", $course)) { 65 notice(get_string('thereareno', 'moodle', $strlessons), "../../course/view.php?id=$course->id"); 66 die; 67 } 68 69 $usesections = course_format_uses_sections($course->format); 70 71 /// Print the list of instances (your module will probably extend this) 72 73 $timenow = time(); 74 $strname = get_string("name"); 75 $strgrade = get_string("gradenoun"); 76 $strdeadline = get_string("deadline", "lesson"); 77 $strnodeadline = get_string("nodeadline", "lesson"); 78 $table = new html_table(); 79 80 if ($usesections) { 81 $strsectionname = get_string('sectionname', 'format_'.$course->format); 82 $table->head = array ($strsectionname, $strname, $strgrade, $strdeadline); 83 $table->align = array ("center", "left", "center", "center"); 84 } else { 85 $table->head = array ($strname, $strgrade, $strdeadline); 86 $table->align = array ("left", "center", "center"); 87 } 88 // Get all deadlines. 89 $deadlines = lesson_get_user_deadline($course->id); 90 foreach ($lessons as $lesson) { 91 $cm = get_coursemodule_from_instance('lesson', $lesson->id); 92 $context = context_module::instance($cm->id); 93 94 $class = $lesson->visible ? null : array('class' => 'dimmed'); // Hidden modules are dimmed. 95 $link = html_writer::link(new moodle_url('view.php', array('id' => $cm->id)), format_string($lesson->name, true), $class); 96 97 $deadline = $deadlines[$lesson->id]->userdeadline; 98 if ($deadline == 0) { 99 $due = $strnodeadline; 100 } else if ($deadline > $timenow) { 101 $due = userdate($deadline); 102 } else { 103 $due = html_writer::tag('span', userdate($deadline), array('class' => 'text-danger')); 104 } 105 106 if ($usesections) { 107 if (has_capability('mod/lesson:manage', $context)) { 108 $grade_value = $lesson->grade; 109 } else { 110 // it's a student, show their grade 111 $grade_value = 0; 112 if ($return = lesson_get_user_grades($lesson, $USER->id)) { 113 $grade_value = $return[$USER->id]->rawgrade; 114 } 115 } 116 $table->data[] = array (get_section_name($course, $lesson->section), $link, $grade_value, $due); 117 } else { 118 $table->data[] = array ($link, $lesson->grade, $due); 119 } 120 } 121 echo html_writer::table($table); 122 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body