[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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 print_error('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("grade"); 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 89 foreach ($lessons as $lesson) { 90 if (!$lesson->visible) { 91 //Show dimmed if the mod is hidden 92 $link = "<a class=\"dimmed\" href=\"view.php?id=$lesson->coursemodule\">".format_string($lesson->name,true)."</a>"; 93 } else { 94 //Show normal if the mod is visible 95 $link = "<a href=\"view.php?id=$lesson->coursemodule\">".format_string($lesson->name,true)."</a>"; 96 } 97 $cm = get_coursemodule_from_instance('lesson', $lesson->id); 98 $context = context_module::instance($cm->id); 99 100 if ($lesson->deadline == 0) { 101 $due = $strnodeadline; 102 } else if ($lesson->deadline > $timenow) { 103 $due = userdate($lesson->deadline); 104 } else { 105 $due = "<font color=\"red\">".userdate($lesson->deadline)."</font>"; 106 } 107 108 if ($usesections) { 109 if (has_capability('mod/lesson:manage', $context)) { 110 $grade_value = $lesson->grade; 111 } else { 112 // it's a student, show their grade 113 $grade_value = 0; 114 if ($return = lesson_get_user_grades($lesson, $USER->id)) { 115 $grade_value = $return[$USER->id]->rawgrade; 116 } 117 } 118 $table->data[] = array (get_section_name($course, $lesson->section), $link, $grade_value, $due); 119 } else { 120 $table->data[] = array ($link, $lesson->grade, $due); 121 } 122 } 123 echo html_writer::table($table); 124 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |