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 file is part of the Database module for Moodle 20 * 21 * @copyright 1990 Martin Dougiamas http://dougiamas.com 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 * @package mod_data 24 */ 25 26 require_once("../../config.php"); 27 require_once ("lib.php"); 28 29 $id = required_param('id', PARAM_INT); // course 30 31 $PAGE->set_url('/mod/data/index.php', array('id'=>$id)); 32 33 if (!$course = $DB->get_record('course', array('id'=>$id))) { 34 throw new \moodle_exception('invalidcourseid'); 35 } 36 37 require_course_login($course); 38 $PAGE->set_pagelayout('incourse'); 39 40 $context = context_course::instance($course->id); 41 42 $params = array( 43 'context' => context_course::instance($course->id) 44 ); 45 $event = \mod_data\event\course_module_instance_list_viewed::create($params); 46 $event->add_record_snapshot('course', $course); 47 $event->trigger(); 48 49 $strname = get_string('name'); 50 $strdata = get_string('modulename','data'); 51 $strdataplural = get_string('modulenameplural','data'); 52 53 $PAGE->navbar->add($strdata, new moodle_url('/mod/data/index.php', array('id'=>$course->id))); 54 $titleparts = [ 55 $strdataplural, 56 format_string($course->fullname), 57 ]; 58 $PAGE->set_title(implode(moodle_page::TITLE_SEPARATOR, $titleparts)); 59 $PAGE->set_heading($course->fullname); 60 echo $OUTPUT->header(); 61 echo $OUTPUT->heading($strdataplural, 2); 62 63 if (! $datas = get_all_instances_in_course("data", $course)) { 64 notice(get_string('thereareno', 'moodle',$strdataplural) , "$CFG->wwwroot/course/view.php?id=$course->id"); 65 } 66 67 $usesections = course_format_uses_sections($course->format); 68 69 $timenow = time(); 70 $strname = get_string('name'); 71 $strdescription = get_string("description"); 72 $strentries = get_string('entries', 'data'); 73 $strnumnotapproved = get_string('numnotapproved', 'data'); 74 75 $table = new html_table(); 76 77 if ($usesections) { 78 $strsectionname = get_string('sectionname', 'format_'.$course->format); 79 $table->head = array ($strsectionname, $strname, $strdescription, $strentries, $strnumnotapproved); 80 $table->align = array ('center', 'center', 'center', 'center', 'center'); 81 } else { 82 $table->head = array ($strname, $strdescription, $strentries, $strnumnotapproved); 83 $table->align = array ('center', 'center', 'center', 'center'); 84 } 85 86 $rss = (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds)); 87 88 if ($rss) { 89 require_once($CFG->libdir."/rsslib.php"); 90 array_push($table->head, 'RSS'); 91 array_push($table->align, 'center'); 92 } 93 94 $currentsection = ""; 95 96 foreach ($datas as $data) { 97 98 $printsection = ""; 99 100 //Calculate the href 101 if (!$data->visible) { 102 //Show dimmed if the mod is hidden 103 $link = "<a class=\"dimmed\" href=\"view.php?id=$data->coursemodule\">".format_string($data->name,true)."</a>"; 104 } else { 105 //Show normal if the mod is visible 106 $link = "<a href=\"view.php?id=$data->coursemodule\">".format_string($data->name,true)."</a>"; 107 } 108 109 // TODO: add group restricted counts here, and limit unapproved to ppl with approve cap only + link to approval page 110 111 $numrecords = $DB->count_records_sql('SELECT COUNT(r.id) FROM {data_records} r WHERE r.dataid =?', array($data->id)); 112 113 if ($data->approval == 1) { 114 $numunapprovedrecords = $DB->count_records_sql('SELECT COUNT(r.id) FROM {data_records} r WHERE r.dataid =? AND r.approved <> 1', array($data->id)); 115 } else { 116 $numunapprovedrecords = '-'; 117 } 118 119 $rsslink = ''; 120 if ($rss && $data->rssarticles > 0) { 121 $rsslink = rss_get_link($context->id, $USER->id, 'mod_data', $data->id, 'RSS'); 122 } 123 124 if ($usesections) { 125 if ($data->section !== $currentsection) { 126 if ($data->section) { 127 $printsection = get_section_name($course, $data->section); 128 } 129 if ($currentsection !== '') { 130 $table->data[] = 'hr'; 131 } 132 $currentsection = $data->section; 133 } 134 $row = array($printsection, $link, format_module_intro('data', $data, $data->coursemodule), 135 $numrecords, $numunapprovedrecords); 136 137 } else { 138 $row = array($link, format_module_intro('data', $data, $data->coursemodule), 139 $numrecords, $numunapprovedrecords); 140 } 141 142 if ($rss) { 143 array_push($row, $rsslink); 144 } 145 146 $table->data[] = $row; 147 } 148 149 echo "<br />"; 150 echo html_writer::tag('div', html_writer::table($table), array('class'=>'no-overflow')); 151 echo $OUTPUT->footer(); 152
title
Description
Body
title
Description
Body
title
Description
Body
title
Body