[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Course overview report 19 * 20 * @package report 21 * @subpackage courseoverview 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 require_once('../../config.php'); 27 require_once($CFG->dirroot.'/lib/statslib.php'); 28 require_once($CFG->libdir.'/adminlib.php'); 29 require_once($CFG->dirroot.'/report/courseoverview/locallib.php'); 30 31 $report = optional_param('report', STATS_REPORT_ACTIVE_COURSES, PARAM_INT); 32 $time = optional_param('time', 0, PARAM_INT); 33 $numcourses = optional_param('numcourses', 20, PARAM_INT); 34 $systemcontext = context_system::instance(); 35 36 if (empty($CFG->enablestats)) { 37 if (has_capability('moodle/site:config', $systemcontext)) { 38 redirect("$CFG->wwwroot/$CFG->admin/search.php?query=enablestats", get_string('mustenablestats', 'admin'), 3); 39 } else { 40 print_error('statsdisable'); 41 } 42 } 43 44 admin_externalpage_setup('reportcourseoverview', '', null, '', array('pagelayout'=>'report')); 45 echo $OUTPUT->header(); 46 47 $course = get_site(); 48 stats_check_uptodate($course->id); 49 50 $strreports = get_string('reports'); 51 $strcourseoverview = get_string('courseoverview'); 52 53 $reportoptions = stats_get_report_options($course->id,STATS_MODE_RANKED); 54 55 $earliestday = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_daily}'); 56 $earliestweek = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_weekly}'); 57 $earliestmonth = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_monthly}'); 58 59 if (empty($earliestday)) $earliestday = time(); 60 if (empty($earliestweek)) $earliestweek = time(); 61 if (empty($earliestmonth)) $earliestmonth = time(); 62 63 $now = stats_get_base_daily(); 64 $lastweekend = stats_get_base_weekly(); 65 $lastmonthend = stats_get_base_monthly(); 66 67 $timeoptions = stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth); 68 69 if (empty($timeoptions)) { 70 print_error('nostatstodisplay', 'error', $CFG->wwwroot.'/course/view.php?id='.$course->id); 71 } 72 73 echo html_writer::start_tag('form', array('action' => 'index.php', 'method' => 'post')); 74 echo html_writer::start_tag('div'); 75 76 $table = new html_table(); 77 $table->width = '*'; 78 $table->align = array('left','left','left','left','left','left'); 79 80 $reporttypemenu = html_writer::label(get_string('statsreporttype'), 'menureport', false, array('class' => 'accesshide')); 81 $reporttypemenu .= html_writer::select($reportoptions,'report',$report, false); 82 $timeoptionsmenu = html_writer::label(get_string('time'), 'menutime', false, array('class' => 'accesshide')); 83 $timeoptionsmenu .= html_writer::select($timeoptions,'time',$time, false); 84 85 $table->data[] = array(get_string('statsreporttype'),$reporttypemenu, 86 get_string('statstimeperiod'),$timeoptionsmenu, 87 html_writer::label(get_string('numberofcourses'), 'numcourses', false, array('class' => 'accesshide')) . 88 html_writer::empty_tag('input', array('type' => 'text', 'id' => 'numcourses', 'name' => 'numcourses', 'size' => '3', 'maxlength' => '2', 'value' => $numcourses)), 89 html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('view')))); 90 91 echo html_writer::table($table); 92 echo html_writer::end_tag('div'); 93 echo html_writer::end_tag('form'); 94 95 echo $OUTPUT->heading($reportoptions[$report]); 96 97 98 if (!empty($report) && !empty($time)) { 99 $param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED); 100 if (!empty($param->sql)) { 101 $sql = $param->sql; 102 } else { 103 $sql = "SELECT courseid,".$param->fields." 104 FROM {".'stats_'.$param->table."} 105 WHERE timeend >= $param->timeafter AND stattype = 'activity' AND roleid = 0 106 GROUP BY courseid 107 $param->extras 108 ORDER BY $param->orderby"; 109 } 110 111 $courses = $DB->get_records_sql($sql, $param->params, 0, $numcourses); 112 113 if (empty($courses)) { 114 echo $OUTPUT->notification(get_string('statsnodata')); 115 echo '</td></tr></table>'; 116 117 } else { 118 require_capability('report/courseoverview:view', $systemcontext); 119 echo html_writer::start_div(); 120 report_courseoverview_print_chart($report, $time, $numcourses); 121 echo html_writer::end_div(); 122 123 $table = new html_table(); 124 $table->align = array('left','center','center','center'); 125 $table->head = array(get_string('course'),$param->line1); 126 if (!empty($param->line2)) { 127 $table->head[] = $param->line2; 128 } 129 if (!empty($param->line3)) { 130 $table->head[] = $param->line3; 131 } 132 133 foreach ($courses as $c) { 134 $a = array(); 135 $a[] = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$c->courseid.'">'.$DB->get_field('course', 'shortname', array('id'=>$c->courseid)).'</a>'; 136 137 $a[] = $c->line1; 138 if (isset($c->line2)) { 139 $a[] = $c->line2; 140 } 141 if (isset($c->line3)) { 142 $a[] = round($c->line3,2); 143 } 144 $table->data[] = $a; 145 } 146 echo html_writer::table($table); 147 } 148 } 149 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 |