2009-09-21 07:22:57 +00:00
|
|
|
<?php
|
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This file contains functions used by the log reports
|
|
|
|
*
|
2011-11-03 08:30:26 +01:00
|
|
|
* @package report
|
|
|
|
* @subpackage log
|
|
|
|
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
2009-09-21 07:22:57 +00:00
|
|
|
*/
|
2006-03-09 09:45:57 +00:00
|
|
|
|
2011-11-03 08:30:26 +01:00
|
|
|
defined('MOODLE_INTERNAL') || die;
|
|
|
|
|
|
|
|
require_once(dirname(__FILE__).'/lib.php');
|
|
|
|
|
2007-01-04 03:22:51 +00:00
|
|
|
function print_mnet_log_selector_form($hostid, $course, $selecteduser=0, $selecteddate='today',
|
|
|
|
$modname="", $modid=0, $modaction='', $selectedgroup=-1, $showcourses=0, $showusers=0, $logformat='showashtml') {
|
|
|
|
|
2009-10-16 03:12:41 +00:00
|
|
|
global $USER, $CFG, $SITE, $DB, $OUTPUT, $SESSION;
|
2007-01-04 03:22:51 +00:00
|
|
|
require_once $CFG->dirroot.'/mnet/peer.php';
|
2009-11-04 08:11:02 +00:00
|
|
|
|
2007-01-04 03:22:51 +00:00
|
|
|
$mnet_peer = new mnet_peer();
|
|
|
|
$mnet_peer->set_id($hostid);
|
|
|
|
|
2008-05-31 14:35:58 +00:00
|
|
|
$sql = "SELECT DISTINCT course, hostid, coursename FROM {mnet_log}";
|
|
|
|
$courses = $DB->get_records_sql($sql);
|
2007-01-04 03:22:51 +00:00
|
|
|
$remotecoursecount = count($courses);
|
|
|
|
|
|
|
|
// first check to see if we can override showcourses and showusers
|
2008-05-31 14:35:58 +00:00
|
|
|
$numcourses = $remotecoursecount + $DB->count_records('course');
|
2007-01-04 03:22:51 +00:00
|
|
|
if ($numcourses < COURSE_MAX_COURSES_PER_DROPDOWN && !$showcourses) {
|
|
|
|
$showcourses = 1;
|
|
|
|
}
|
2009-11-04 08:11:02 +00:00
|
|
|
|
2008-04-23 08:07:42 +00:00
|
|
|
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
2009-11-04 08:11:02 +00:00
|
|
|
|
2007-01-04 03:22:51 +00:00
|
|
|
// Context for remote data is always SITE
|
|
|
|
// Groups for remote data are always OFF
|
|
|
|
if ($hostid == $CFG->mnet_localhost_id) {
|
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
|
|
|
|
|
|
|
/// Setup for group handling.
|
|
|
|
if ($course->groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) {
|
2009-10-16 03:12:41 +00:00
|
|
|
$selectedgroup = -1;
|
2007-01-04 03:22:51 +00:00
|
|
|
$showgroups = false;
|
2009-10-16 03:12:41 +00:00
|
|
|
} else if ($course->groupmode) {
|
2007-01-04 03:22:51 +00:00
|
|
|
$showgroups = true;
|
2009-10-16 03:12:41 +00:00
|
|
|
} else {
|
2007-01-04 03:22:51 +00:00
|
|
|
$selectedgroup = 0;
|
|
|
|
$showgroups = false;
|
|
|
|
}
|
|
|
|
|
2009-10-16 03:12:41 +00:00
|
|
|
if ($selectedgroup === -1) {
|
|
|
|
if (isset($SESSION->currentgroup[$course->id])) {
|
|
|
|
$selectedgroup = $SESSION->currentgroup[$course->id];
|
|
|
|
} else {
|
|
|
|
$selectedgroup = groups_get_all_groups($course->id, $USER->id);
|
|
|
|
if (is_array($selectedgroup)) {
|
|
|
|
$selectedgroup = array_shift(array_keys($selectedgroup));
|
|
|
|
$SESSION->currentgroup[$course->id] = $selectedgroup;
|
|
|
|
} else {
|
|
|
|
$selectedgroup = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-04 03:22:51 +00:00
|
|
|
} else {
|
|
|
|
$context = $sitecontext;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get all the possible users
|
|
|
|
$users = array();
|
|
|
|
|
2009-01-14 18:23:30 +00:00
|
|
|
// Define limitfrom and limitnum for queries below
|
|
|
|
// If $showusers is enabled... don't apply limitfrom and limitnum
|
|
|
|
$limitfrom = empty($showusers) ? 0 : '';
|
|
|
|
$limitnum = empty($showusers) ? COURSE_MAX_USERS_PER_DROPDOWN + 1 : '';
|
|
|
|
|
2007-01-04 03:22:51 +00:00
|
|
|
// If looking at a different host, we're interested in all our site users
|
2007-02-01 09:06:48 +00:00
|
|
|
if ($hostid == $CFG->mnet_localhost_id && $course->id != SITEID) {
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
$courseusers = get_enrolled_users($context, '', $selectedgroup, 'u.id, u.firstname, u.lastname, u.idnumber', 'lastname ASC, firstname ASC', $limitfrom, $limitnum);
|
2007-01-04 03:22:51 +00:00
|
|
|
} else {
|
2008-05-25 11:18:12 +00:00
|
|
|
// this may be a lot of users :-(
|
2009-01-14 18:23:30 +00:00
|
|
|
$courseusers = $DB->get_records('user', array('deleted'=>0), 'lastaccess DESC', 'id, firstname, lastname, idnumber', $limitfrom, $limitnum);
|
2007-01-04 03:22:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (count($courseusers) < COURSE_MAX_USERS_PER_DROPDOWN && !$showusers) {
|
|
|
|
$showusers = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($showusers) {
|
|
|
|
if ($courseusers) {
|
|
|
|
foreach ($courseusers as $courseuser) {
|
|
|
|
$users[$courseuser->id] = fullname($courseuser, has_capability('moodle/site:viewfullnames', $context));
|
|
|
|
}
|
|
|
|
}
|
2010-08-25 08:43:42 +00:00
|
|
|
$users[$CFG->siteguest] = get_string('guestuser');
|
2007-01-04 03:22:51 +00:00
|
|
|
}
|
|
|
|
|
2007-01-11 05:59:57 +00:00
|
|
|
// Get all the hosts that have log records
|
|
|
|
$sql = "select distinct
|
|
|
|
h.id,
|
|
|
|
h.name
|
|
|
|
from
|
2008-05-31 14:35:58 +00:00
|
|
|
{mnet_host} h,
|
|
|
|
{mnet_log} l
|
2007-01-11 05:59:57 +00:00
|
|
|
where
|
|
|
|
h.id = l.hostid
|
|
|
|
order by
|
|
|
|
h.name";
|
2007-01-04 03:22:51 +00:00
|
|
|
|
2008-05-31 14:35:58 +00:00
|
|
|
if ($hosts = $DB->get_records_sql($sql)) {
|
2007-01-15 07:59:28 +00:00
|
|
|
foreach($hosts as $host) {
|
|
|
|
$hostarray[$host->id] = $host->name;
|
|
|
|
}
|
2007-01-04 03:22:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$hostarray[$CFG->mnet_localhost_id] = $SITE->fullname;
|
|
|
|
asort($hostarray);
|
|
|
|
|
2010-01-16 19:48:01 +00:00
|
|
|
$dropdown = array();
|
|
|
|
|
2007-01-04 03:22:51 +00:00
|
|
|
foreach($hostarray as $hostid => $name) {
|
|
|
|
$courses = array();
|
|
|
|
$sites = array();
|
|
|
|
if ($CFG->mnet_localhost_id == $hostid) {
|
2011-11-03 08:30:26 +01:00
|
|
|
if (has_capability('report/log:view', $sitecontext) && $showcourses) {
|
2008-05-31 14:35:58 +00:00
|
|
|
if ($ccc = $DB->get_records("course", null, "fullname","id,fullname,category")) {
|
2007-01-04 03:22:51 +00:00
|
|
|
foreach ($ccc as $cc) {
|
2007-01-15 21:28:25 +00:00
|
|
|
if ($cc->id == SITEID) {
|
2007-03-15 16:03:44 +00:00
|
|
|
$sites["$hostid/$cc->id"] = format_string($cc->fullname).' ('.get_string('site').')';
|
2007-01-04 03:22:51 +00:00
|
|
|
} else {
|
2007-03-15 16:03:44 +00:00
|
|
|
$courses["$hostid/$cc->id"] = format_string($cc->fullname);
|
2007-01-04 03:22:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2011-11-03 08:30:26 +01:00
|
|
|
if (has_capability('report/log:view', $sitecontext) && $showcourses) {
|
2008-05-31 14:35:58 +00:00
|
|
|
$sql = "SELECT DISTINCT course, coursename FROM {mnet_log} where hostid = ?";
|
|
|
|
if ($ccc = $DB->get_records_sql($sql, array($hostid))) {
|
2007-01-04 03:22:51 +00:00
|
|
|
foreach ($ccc as $cc) {
|
2007-01-15 21:28:25 +00:00
|
|
|
if (1 == $cc->course) { // TODO: this might be wrong - site course may have another id
|
|
|
|
$sites["$hostid/$cc->course"] = $cc->coursename.' ('.get_string('site').')';
|
2007-01-04 03:22:51 +00:00
|
|
|
} else {
|
2007-01-15 21:28:25 +00:00
|
|
|
$courses["$hostid/$cc->course"] = $cc->coursename;
|
2007-01-04 03:22:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
asort($courses);
|
2010-01-16 19:48:01 +00:00
|
|
|
$dropdown[] = array($name=>($sites + $courses));
|
2007-01-04 03:22:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$activities = array();
|
|
|
|
$selectedactivity = "";
|
|
|
|
|
|
|
|
/// Casting $course->modinfo to string prevents one notice when the field is null
|
|
|
|
if ($modinfo = unserialize((string)$course->modinfo)) {
|
|
|
|
$section = 0;
|
2010-09-10 08:47:58 +00:00
|
|
|
$sections = get_all_sections($course->id);
|
2007-01-04 03:22:51 +00:00
|
|
|
foreach ($modinfo as $mod) {
|
|
|
|
if ($mod->mod == "label") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ($mod->section > 0 and $section <> $mod->section) {
|
2010-09-10 08:47:58 +00:00
|
|
|
$activities["section/$mod->section"] = '--- '.get_section_name($course, $sections[$mod->section]).' ---';
|
2007-01-04 03:22:51 +00:00
|
|
|
}
|
|
|
|
$section = $mod->section;
|
2010-02-14 20:18:10 +00:00
|
|
|
$mod->name = strip_tags(format_string($mod->name, true));
|
2011-09-10 10:21:31 +02:00
|
|
|
if (textlib::strlen($mod->name) > 55) {
|
|
|
|
$mod->name = textlib::substr($mod->name, 0, 50)."...";
|
2007-01-04 03:22:51 +00:00
|
|
|
}
|
|
|
|
if (!$mod->visible) {
|
|
|
|
$mod->name = "(".$mod->name.")";
|
|
|
|
}
|
|
|
|
$activities["$mod->cm"] = $mod->name;
|
|
|
|
|
|
|
|
if ($mod->cm == $modid) {
|
|
|
|
$selectedactivity = "$mod->cm";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-03 08:30:26 +01:00
|
|
|
if (has_capability('report/log:view', $sitecontext) && !$course->category) {
|
2007-01-04 03:22:51 +00:00
|
|
|
$activities["site_errors"] = get_string("siteerrors");
|
|
|
|
if ($modid === "site_errors") {
|
|
|
|
$selectedactivity = "site_errors";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$strftimedate = get_string("strftimedate");
|
|
|
|
$strftimedaydate = get_string("strftimedaydate");
|
|
|
|
|
|
|
|
asort($users);
|
|
|
|
|
|
|
|
// Prepare the list of action options.
|
|
|
|
$actions = array(
|
|
|
|
'view' => get_string('view'),
|
|
|
|
'add' => get_string('add'),
|
|
|
|
'update' => get_string('update'),
|
|
|
|
'delete' => get_string('delete'),
|
|
|
|
'-view' => get_string('allchanges')
|
|
|
|
);
|
|
|
|
|
|
|
|
// Get all the possible dates
|
|
|
|
// Note that we are keeping track of real (GMT) time and user time
|
|
|
|
// User time is only used in displays - all calcs and passing is GMT
|
|
|
|
|
|
|
|
$timenow = time(); // GMT
|
|
|
|
|
|
|
|
// What day is it now for the user, and when is midnight that day (in GMT).
|
|
|
|
$timemidnight = $today = usergetmidnight($timenow);
|
|
|
|
|
|
|
|
// Put today up the top of the list
|
|
|
|
$dates = array("$timemidnight" => get_string("today").", ".userdate($timenow, $strftimedate) );
|
|
|
|
|
|
|
|
if (!$course->startdate or ($course->startdate > $timenow)) {
|
|
|
|
$course->startdate = $course->timecreated;
|
|
|
|
}
|
|
|
|
|
|
|
|
$numdates = 1;
|
|
|
|
while ($timemidnight > $course->startdate and $numdates < 365) {
|
|
|
|
$timemidnight = $timemidnight - 86400;
|
|
|
|
$timenow = $timenow - 86400;
|
|
|
|
$dates["$timemidnight"] = userdate($timenow, $strftimedaydate);
|
|
|
|
$numdates++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($selecteddate == "today") {
|
|
|
|
$selecteddate = $today;
|
|
|
|
}
|
|
|
|
|
2011-11-03 08:30:26 +01:00
|
|
|
echo "<form class=\"logselectform\" action=\"$CFG->wwwroot/report/log/index.php\" method=\"get\">\n";
|
2007-01-15 21:28:25 +00:00
|
|
|
echo "<div>\n";//invisible fieldset here breaks wrapping
|
2007-01-04 03:22:51 +00:00
|
|
|
echo "<input type=\"hidden\" name=\"chooselog\" value=\"1\" />\n";
|
|
|
|
echo "<input type=\"hidden\" name=\"showusers\" value=\"$showusers\" />\n";
|
|
|
|
echo "<input type=\"hidden\" name=\"showcourses\" value=\"$showcourses\" />\n";
|
2011-11-03 08:30:26 +01:00
|
|
|
if (has_capability('report/log:view', $sitecontext) && $showcourses) {
|
2009-11-04 08:11:02 +00:00
|
|
|
$cid = empty($course->id)? '1' : $course->id;
|
2010-01-16 19:48:01 +00:00
|
|
|
echo html_writer::select($dropdown, "host_course", $hostid.'/'.$cid);
|
2007-01-04 03:22:51 +00:00
|
|
|
} else {
|
|
|
|
$courses = array();
|
2007-01-15 21:28:25 +00:00
|
|
|
$courses[$course->id] = $course->fullname . ((empty($course->category)) ? ' ('.get_string('site').') ' : '');
|
2010-01-16 18:29:51 +00:00
|
|
|
echo html_writer::select($courses,"id",$course->id, false);
|
2011-11-03 08:30:26 +01:00
|
|
|
if (has_capability('report/log:view', $sitecontext)) {
|
2010-09-21 08:13:11 +00:00
|
|
|
$a = new stdClass();
|
2011-11-03 08:30:26 +01:00
|
|
|
$a->url = "$CFG->wwwroot/report/log/index.php?chooselog=0&group=$selectedgroup&user=$selecteduser"
|
2007-01-04 03:22:51 +00:00
|
|
|
."&id=$course->id&date=$selecteddate&modid=$selectedactivity&showcourses=1&showusers=$showusers";
|
|
|
|
print_string('logtoomanycourses','moodle',$a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($showgroups) {
|
2007-08-15 20:21:01 +00:00
|
|
|
if ($cgroups = groups_get_all_groups($course->id)) {
|
2007-01-04 03:22:51 +00:00
|
|
|
foreach ($cgroups as $cgroup) {
|
|
|
|
$groups[$cgroup->id] = $cgroup->name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$groups = array();
|
|
|
|
}
|
2010-01-16 18:29:51 +00:00
|
|
|
echo html_writer::select($groups, "group", $selectedgroup, get_string("allgroups"));
|
2007-01-04 03:22:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($showusers) {
|
2010-01-16 18:29:51 +00:00
|
|
|
echo html_writer::select($users, "user", $selecteduser, get_string("allparticipants"));
|
2007-01-04 03:22:51 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$users = array();
|
|
|
|
if (!empty($selecteduser)) {
|
2008-05-31 14:35:58 +00:00
|
|
|
$user = $DB->get_record('user', array('id'=>$selecteduser));
|
2007-01-04 03:22:51 +00:00
|
|
|
$users[$selecteduser] = fullname($user);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$users[0] = get_string('allparticipants');
|
|
|
|
}
|
2010-01-16 18:29:51 +00:00
|
|
|
echo html_writer::select($users, "user", $selecteduser, false);
|
2011-11-03 08:30:26 +01:00
|
|
|
$a->url = "$CFG->wwwroot/report/log/index.php?chooselog=0&group=$selectedgroup&user=$selecteduser"
|
2007-01-04 03:22:51 +00:00
|
|
|
."&id=$course->id&date=$selecteddate&modid=$selectedactivity&showusers=1&showcourses=$showcourses";
|
|
|
|
print_string('logtoomanyusers','moodle',$a);
|
|
|
|
}
|
2009-11-04 08:11:02 +00:00
|
|
|
|
2010-01-16 18:29:51 +00:00
|
|
|
echo html_writer::select($dates, "date", $selecteddate, get_string("alldays"));
|
|
|
|
echo html_writer::select($activities, "modid", $selectedactivity, get_string("allactivities"));
|
|
|
|
echo html_writer::select($actions, 'modaction', $modaction, get_string("allactions"));
|
2009-11-04 08:11:02 +00:00
|
|
|
|
2007-01-04 03:22:51 +00:00
|
|
|
$logformats = array('showashtml' => get_string('displayonpage'),
|
|
|
|
'downloadascsv' => get_string('downloadtext'),
|
2007-01-15 21:28:25 +00:00
|
|
|
'downloadasods' => get_string('downloadods'),
|
2007-01-04 03:22:51 +00:00
|
|
|
'downloadasexcel' => get_string('downloadexcel'));
|
2010-01-16 18:29:51 +00:00
|
|
|
echo html_writer::select($logformats, 'logformat', $logformat, false);
|
2007-01-04 03:22:51 +00:00
|
|
|
echo '<input type="submit" value="'.get_string('gettheselogs').'" />';
|
2007-01-15 21:28:25 +00:00
|
|
|
echo '</div>';
|
|
|
|
echo '</form>';
|
2007-01-04 03:22:51 +00:00
|
|
|
}
|
|
|
|
|
2006-05-15 05:01:00 +00:00
|
|
|
function print_log_selector_form($course, $selecteduser=0, $selecteddate='today',
|
|
|
|
$modname="", $modid=0, $modaction='', $selectedgroup=-1, $showcourses=0, $showusers=0, $logformat='showashtml') {
|
2006-03-09 09:45:57 +00:00
|
|
|
|
2009-10-16 03:12:41 +00:00
|
|
|
global $USER, $CFG, $DB, $OUTPUT, $SESSION;
|
2006-03-09 09:45:57 +00:00
|
|
|
|
|
|
|
// first check to see if we can override showcourses and showusers
|
2008-05-31 14:35:58 +00:00
|
|
|
$numcourses = $DB->count_records("course");
|
2006-03-09 09:45:57 +00:00
|
|
|
if ($numcourses < COURSE_MAX_COURSES_PER_DROPDOWN && !$showcourses) {
|
|
|
|
$showcourses = 1;
|
|
|
|
}
|
2009-11-04 08:11:02 +00:00
|
|
|
|
2008-04-23 08:07:42 +00:00
|
|
|
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
2006-09-06 08:55:23 +00:00
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
2009-11-04 08:11:02 +00:00
|
|
|
|
2006-03-09 09:45:57 +00:00
|
|
|
/// Setup for group handling.
|
2006-09-06 08:55:23 +00:00
|
|
|
if ($course->groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) {
|
2009-10-16 03:12:41 +00:00
|
|
|
$selectedgroup = -1;
|
2006-03-09 09:45:57 +00:00
|
|
|
$showgroups = false;
|
2009-10-16 03:12:41 +00:00
|
|
|
} else if ($course->groupmode) {
|
2006-03-09 09:45:57 +00:00
|
|
|
$showgroups = true;
|
2009-10-16 03:12:41 +00:00
|
|
|
} else {
|
2006-03-09 09:45:57 +00:00
|
|
|
$selectedgroup = 0;
|
|
|
|
$showgroups = false;
|
|
|
|
}
|
|
|
|
|
2009-10-16 03:12:41 +00:00
|
|
|
if ($selectedgroup === -1) {
|
|
|
|
if (isset($SESSION->currentgroup[$course->id])) {
|
|
|
|
$selectedgroup = $SESSION->currentgroup[$course->id];
|
|
|
|
} else {
|
|
|
|
$selectedgroup = groups_get_all_groups($course->id, $USER->id);
|
|
|
|
if (is_array($selectedgroup)) {
|
|
|
|
$selectedgroup = array_shift(array_keys($selectedgroup));
|
|
|
|
$SESSION->currentgroup[$course->id] = $selectedgroup;
|
|
|
|
} else {
|
|
|
|
$selectedgroup = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-09 09:45:57 +00:00
|
|
|
// Get all the possible users
|
|
|
|
$users = array();
|
|
|
|
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
$courseusers = get_enrolled_users($context, '', $selectedgroup, 'u.id, u.firstname, u.lastname, u.idnumber', 'lastname ASC, firstname ASC');
|
2009-11-04 08:11:02 +00:00
|
|
|
|
2006-03-09 09:45:57 +00:00
|
|
|
if (count($courseusers) < COURSE_MAX_USERS_PER_DROPDOWN && !$showusers) {
|
|
|
|
$showusers = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($showusers) {
|
|
|
|
if ($courseusers) {
|
|
|
|
foreach ($courseusers as $courseuser) {
|
2006-09-06 08:55:23 +00:00
|
|
|
$users[$courseuser->id] = fullname($courseuser, has_capability('moodle/site:viewfullnames', $context));
|
2006-03-09 09:45:57 +00:00
|
|
|
}
|
|
|
|
}
|
2010-08-25 08:43:42 +00:00
|
|
|
$users[$CFG->siteguest] = get_string('guestuser');
|
2006-03-09 09:45:57 +00:00
|
|
|
}
|
|
|
|
|
2011-11-03 08:30:26 +01:00
|
|
|
if (has_capability('report/log:view', $sitecontext) && $showcourses) {
|
2008-05-31 14:35:58 +00:00
|
|
|
if ($ccc = $DB->get_records("course", null, "fullname", "id,fullname,category")) {
|
2006-03-09 09:45:57 +00:00
|
|
|
foreach ($ccc as $cc) {
|
|
|
|
if ($cc->category) {
|
2007-03-15 16:03:44 +00:00
|
|
|
$courses["$cc->id"] = format_string($cc->fullname);
|
2006-03-09 09:45:57 +00:00
|
|
|
} else {
|
2007-03-15 16:03:44 +00:00
|
|
|
$courses["$cc->id"] = format_string($cc->fullname) . ' (Site)';
|
2006-03-09 09:45:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
asort($courses);
|
|
|
|
}
|
|
|
|
|
|
|
|
$activities = array();
|
|
|
|
$selectedactivity = "";
|
|
|
|
|
2006-09-04 21:12:37 +00:00
|
|
|
/// Casting $course->modinfo to string prevents one notice when the field is null
|
|
|
|
if ($modinfo = unserialize((string)$course->modinfo)) {
|
2006-03-09 09:45:57 +00:00
|
|
|
$section = 0;
|
2010-09-10 08:47:58 +00:00
|
|
|
$sections = get_all_sections($course->id);
|
2006-03-09 09:45:57 +00:00
|
|
|
foreach ($modinfo as $mod) {
|
|
|
|
if ($mod->mod == "label") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ($mod->section > 0 and $section <> $mod->section) {
|
2010-09-10 08:47:58 +00:00
|
|
|
$activities["section/$mod->section"] = '--- '.get_section_name($course, $sections[$mod->section]).' ---';
|
2006-03-09 09:45:57 +00:00
|
|
|
}
|
|
|
|
$section = $mod->section;
|
2010-02-14 20:18:10 +00:00
|
|
|
$mod->name = strip_tags(format_string($mod->name, true));
|
2011-09-10 10:21:31 +02:00
|
|
|
if (textlib::strlen($mod->name) > 55) {
|
|
|
|
$mod->name = textlib::substr($mod->name, 0, 50)."...";
|
2006-03-09 09:45:57 +00:00
|
|
|
}
|
|
|
|
if (!$mod->visible) {
|
|
|
|
$mod->name = "(".$mod->name.")";
|
|
|
|
}
|
|
|
|
$activities["$mod->cm"] = $mod->name;
|
|
|
|
|
|
|
|
if ($mod->cm == $modid) {
|
|
|
|
$selectedactivity = "$mod->cm";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-03 08:30:26 +01:00
|
|
|
if (has_capability('report/log:view', $sitecontext) && ($course->id == SITEID)) {
|
2006-03-09 09:45:57 +00:00
|
|
|
$activities["site_errors"] = get_string("siteerrors");
|
|
|
|
if ($modid === "site_errors") {
|
|
|
|
$selectedactivity = "site_errors";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$strftimedate = get_string("strftimedate");
|
|
|
|
$strftimedaydate = get_string("strftimedaydate");
|
|
|
|
|
|
|
|
asort($users);
|
|
|
|
|
2006-03-28 17:33:40 +00:00
|
|
|
// Prepare the list of action options.
|
|
|
|
$actions = array(
|
|
|
|
'view' => get_string('view'),
|
|
|
|
'add' => get_string('add'),
|
|
|
|
'update' => get_string('update'),
|
|
|
|
'delete' => get_string('delete'),
|
|
|
|
'-view' => get_string('allchanges')
|
|
|
|
);
|
|
|
|
|
2006-03-09 09:45:57 +00:00
|
|
|
// Get all the possible dates
|
|
|
|
// Note that we are keeping track of real (GMT) time and user time
|
|
|
|
// User time is only used in displays - all calcs and passing is GMT
|
|
|
|
|
|
|
|
$timenow = time(); // GMT
|
|
|
|
|
|
|
|
// What day is it now for the user, and when is midnight that day (in GMT).
|
|
|
|
$timemidnight = $today = usergetmidnight($timenow);
|
|
|
|
|
|
|
|
// Put today up the top of the list
|
|
|
|
$dates = array("$timemidnight" => get_string("today").", ".userdate($timenow, $strftimedate) );
|
|
|
|
|
|
|
|
if (!$course->startdate or ($course->startdate > $timenow)) {
|
|
|
|
$course->startdate = $course->timecreated;
|
|
|
|
}
|
|
|
|
|
|
|
|
$numdates = 1;
|
|
|
|
while ($timemidnight > $course->startdate and $numdates < 365) {
|
|
|
|
$timemidnight = $timemidnight - 86400;
|
|
|
|
$timenow = $timenow - 86400;
|
|
|
|
$dates["$timemidnight"] = userdate($timenow, $strftimedaydate);
|
|
|
|
$numdates++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($selecteddate == "today") {
|
|
|
|
$selecteddate = $today;
|
|
|
|
}
|
|
|
|
|
2011-11-03 08:30:26 +01:00
|
|
|
echo "<form class=\"logselectform\" action=\"$CFG->wwwroot/report/log/index.php\" method=\"get\">\n";
|
2007-01-15 21:28:25 +00:00
|
|
|
echo "<div>\n";
|
2006-03-09 09:45:57 +00:00
|
|
|
echo "<input type=\"hidden\" name=\"chooselog\" value=\"1\" />\n";
|
|
|
|
echo "<input type=\"hidden\" name=\"showusers\" value=\"$showusers\" />\n";
|
|
|
|
echo "<input type=\"hidden\" name=\"showcourses\" value=\"$showcourses\" />\n";
|
2011-11-03 08:30:26 +01:00
|
|
|
if (has_capability('report/log:view', $sitecontext) && $showcourses) {
|
2010-01-16 18:29:51 +00:00
|
|
|
echo html_writer::select($courses, "id", $course->id, false);
|
2006-03-09 09:45:57 +00:00
|
|
|
} else {
|
|
|
|
// echo '<input type="hidden" name="id" value="'.$course->id.'" />';
|
|
|
|
$courses = array();
|
2007-01-15 21:28:25 +00:00
|
|
|
$courses[$course->id] = $course->fullname . (($course->id == SITEID) ? ' ('.get_string('site').') ' : '');
|
2010-01-16 18:29:51 +00:00
|
|
|
echo html_writer::select($courses,"id",$course->id, false);
|
2011-11-03 08:30:26 +01:00
|
|
|
if (has_capability('report/log:view', $sitecontext)) {
|
2010-09-21 08:13:11 +00:00
|
|
|
$a = new stdClass();
|
2011-11-03 08:30:26 +01:00
|
|
|
$a->url = "$CFG->wwwroot/report/log/index.php?chooselog=0&group=$selectedgroup&user=$selecteduser"
|
2006-03-09 09:45:57 +00:00
|
|
|
."&id=$course->id&date=$selecteddate&modid=$selectedactivity&showcourses=1&showusers=$showusers";
|
|
|
|
print_string('logtoomanycourses','moodle',$a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($showgroups) {
|
2007-08-15 20:21:01 +00:00
|
|
|
if ($cgroups = groups_get_all_groups($course->id)) {
|
2006-03-09 09:45:57 +00:00
|
|
|
foreach ($cgroups as $cgroup) {
|
|
|
|
$groups[$cgroup->id] = $cgroup->name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$groups = array();
|
|
|
|
}
|
2010-01-16 18:29:51 +00:00
|
|
|
echo html_writer::select($groups, "group", $selectedgroup, get_string("allgroups"));
|
2006-03-09 09:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($showusers) {
|
2010-01-16 18:29:51 +00:00
|
|
|
echo html_writer::select($users, "user", $selecteduser, get_string("allparticipants"));
|
2006-03-09 09:45:57 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$users = array();
|
|
|
|
if (!empty($selecteduser)) {
|
2008-05-31 14:35:58 +00:00
|
|
|
$user = $DB->get_record('user', array('id'=>$selecteduser));
|
2006-03-09 09:45:57 +00:00
|
|
|
$users[$selecteduser] = fullname($user);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$users[0] = get_string('allparticipants');
|
|
|
|
}
|
2010-01-16 18:29:51 +00:00
|
|
|
echo html_writer::select($users, "user", $selecteduser, false);
|
2010-09-21 08:13:11 +00:00
|
|
|
$a = new stdClass();
|
2011-11-03 08:30:26 +01:00
|
|
|
$a->url = "$CFG->wwwroot/report/log/index.php?chooselog=0&group=$selectedgroup&user=$selecteduser"
|
2006-03-09 09:45:57 +00:00
|
|
|
."&id=$course->id&date=$selecteddate&modid=$selectedactivity&showusers=1&showcourses=$showcourses";
|
|
|
|
print_string('logtoomanyusers','moodle',$a);
|
|
|
|
}
|
2010-01-16 18:29:51 +00:00
|
|
|
echo html_writer::select($dates, "date", $selecteddate, get_string("alldays"));
|
2009-11-04 08:11:02 +00:00
|
|
|
|
2010-01-16 18:29:51 +00:00
|
|
|
echo html_writer::select($activities, "modid", $selectedactivity, get_string("allactivities"));
|
|
|
|
echo html_writer::select($actions, 'modaction', $modaction, get_string("allactions"));
|
2009-11-04 08:11:02 +00:00
|
|
|
|
2006-05-15 05:01:00 +00:00
|
|
|
$logformats = array('showashtml' => get_string('displayonpage'),
|
|
|
|
'downloadascsv' => get_string('downloadtext'),
|
2006-12-21 10:58:18 +00:00
|
|
|
'downloadasods' => get_string('downloadods'),
|
2006-05-15 05:01:00 +00:00
|
|
|
'downloadasexcel' => get_string('downloadexcel'));
|
2009-11-04 08:11:02 +00:00
|
|
|
|
2010-01-16 18:29:51 +00:00
|
|
|
echo html_writer::select($logformats, 'logformat', $logformat, false);
|
2006-05-15 05:01:00 +00:00
|
|
|
echo '<input type="submit" value="'.get_string('gettheselogs').'" />';
|
2007-01-15 21:28:25 +00:00
|
|
|
echo '</div>';
|
|
|
|
echo '</form>';
|
2006-03-09 09:45:57 +00:00
|
|
|
}
|