id); if ($advancedfilter) { // Get all the possible users $users = array(); if ($courseusers = get_course_users($course->id, '', '', 'u.id, u.firstname, u.lastname')) { foreach ($courseusers as $courseuser) { $users[$courseuser->id] = fullname($courseuser, $isteacher); } } if ($guest = get_guest()) { $users[$guest->id] = fullname($guest); } if (isadmin()) { if ($ccc = get_records("course", "", "", "fullname")) { foreach ($ccc as $cc) { if ($cc->category) { $courses["$cc->id"] = "$cc->fullname"; } else { $courses["$cc->id"] = " $cc->fullname (Site)"; } } } asort($courses); } $activities = array(); $selectedactivity = $modid; if ($modinfo = unserialize($course->modinfo)) { $section = 0; if ($course->format == 'weeks') { // Body $strsection = get_string("week"); } else { $strsection = get_string("topic"); } $activities["activity/All"] = "All activities"; $activities["activity/Assignments"] = "All assignments"; $activities["activity/Chats"] = "All chats"; $activities["activity/Forums"] = "All forums"; $activities["activity/Quizzes"] = "All quizzes"; $activities["activity/Workshops"] = "All workshops"; $activities["section/individual"] = "------------- Individual Activities --------------"; foreach ($modinfo as $mod) { if ($mod->mod == "label") { continue; } if (!$mod->visible and !$isteacher) { continue; } if ($mod->section > 0 and $section <> $mod->section) { $activities["section/$mod->section"] = "-------------- $strsection $mod->section --------------"; } $section = $mod->section; $mod->name = strip_tags(format_string(urldecode($mod->name),true)); if (strlen($mod->name) > 55) { $mod->name = substr($mod->name, 0, 50)."..."; } if (!$mod->visible) { $mod->name = "(".$mod->name.")"; } $activities["$mod->cm"] = $mod->name; if ($mod->cm == $modid) { $selectedactivity = "$mod->cm"; } } } $strftimedate = get_string("strftimedate"); $strftimedaydate = get_string("strftimedaydate"); asort($users); // 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); $dates = array(); $dates["$USER->lastlogin"] = get_string("lastlogin").", ".userdate($USER->lastlogin, $strftimedate); $dates["$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 === "lastlogin") { $selecteddate = $USER->lastlogin; } echo '
"; } else { $day_list = array("1","7","14","21","30"); $strsince = get_string("since"); $strlastlogin = get_string("lastlogin"); $strday = get_string("day"); $strdays = get_string("days"); $heading = ""; foreach ($day_list as $count) { if ($count == "1") { $day = $strday; } else { $day = $strdays; } $tmpdate = time() - ($count * 3600 * 24); $heading = $heading . "wwwroot/course/recent.php?id=$course->id&date=$tmpdate\"> $count $day | "; } $heading = $strsince . ": wwwroot/course/recent.php?id=$course->id\">$strlastlogin" . " | " . $heading; print_heading($heading); $advancedlink = "wwwroot/course/recent.php?id=$course->id&advancedfilter=1\">" . get_string("advancedfilter") . ""; print_heading($advancedlink); } } function make_log_url($module, $url) { switch ($module) { case "user": case "course": case "file": case "login": case "lib": case "admin": case "message": case "calendar": return "/$module/$url"; break; case "upload": return "$url"; break; case "library": case "": return "/"; break; default: return "/mod/$module/$url"; break; } } function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $perpage=100, $url="", $modname="", $modid=0, $modaction="", $groupid=0) { // It is assumed that $date is the GMT time of midnight for that day, // and so the next 86400 seconds worth of logs are printed. global $CFG, $db; /// Setup for group handling. $isteacher = isteacher($course->id); $isteacheredit = isteacheredit($course->id); /// If the group mode is separate, and this user does not have editing privileges, /// then only the user's group can be viewed. if ($course->groupmode == SEPARATEGROUPS and !$isteacheredit) { $groupid = get_current_group($course->id); } /// If this course doesn't have groups, no groupid can be specified. else if (!$course->groupmode) { $groupid = 0; } $joins = array(); if ($course->category) { $joins[] = "l.course='$course->id'"; } else { $courses[0] = ''; if ($ccc = get_courses("all", "c.id ASC", "c.id,c.shortname")) { foreach ($ccc as $cc) { $courses[$cc->id] = "$cc->shortname"; } } } if ($modname) { $joins[] = "l.module = '$modname'"; } if ('site_errors' === $modid) { $joins[] = "( l.action='error' OR l.action='infected' )"; } else if ($modid) { $joins[] = "l.cmid = '$modid'"; } if ($modaction) { $firstletter = substr($modaction, 0, 1); if (ctype_alpha($firstletter)) { $joins[] = "lower(l.action) LIKE '%" . strtolower($modaction) . "%'"; } else if ($firstletter == '-') { $joins[] = "lower(l.action) NOT LIKE '%" . strtolower(substr($modaction, 1)) . "%'"; } } /// Getting all members of a group. if ($groupid and !$user) { if ($gusers = get_records('groups_members', 'groupid', $groupid)) { $first = true; foreach($gusers as $guser) { if ($first) { $gselect = '(l.userid='.$guser->userid; $first = false; } else { $gselect .= ' OR l.userid='.$guser->userid; } } if (!$first) $gselect .= ')'; $joins[] = $gselect; } } else if ($user) { $joins[] = "l.userid = '$user'"; } if ($date) { $enddate = $date + 86400; $joins[] = "l.time > '$date' AND l.time < '$enddate'"; } $selector = ''; for ($i = 0; $i < count($joins); $i++) { $selector .= $joins[$i] . (($i == count($joins)-1) ? " " : " AND "); } $totalcount = 0; // Initialise if (!$logs = get_logs($selector, $order, $page*$perpage, $perpage, $totalcount)) { notify("No logs found!"); print_footer($course); exit; } $count=0; $ldcache = array(); $tt = getdate(time()); $today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]); $strftimedatetime = get_string("strftimedatetime"); $isteacher = isteacher($course->id); echo "\n"; print_string("displayingrecords", "", $totalcount); echo "
\n"; print_paging_bar($totalcount, $page, $perpage, "$url&perpage=$perpage&"); echo "".get_string('course')." | \n"; } echo "".get_string('time')." | \n"; echo "".get_string('ip_address')." | \n"; echo "".get_string('fullname')." | \n"; echo "".get_string('action')." | \n"; echo "".get_string('info')." | \n"; echo "
---|---|---|---|---|---|
\n"; echo " course}\">".$courses[$log->course]."\n"; echo " | \n"; } echo "".userdate($log->time, '%a'). ' '.userdate($log->time, $strftimedatetime)." | \n"; echo "\n"; link_to_popup_window("/iplookup/index.php?ip=$log->ip&user=$log->userid", 'iplookup',$log->ip, 400, 700); echo " | \n"; $fullname = fullname($log, $isteacher); echo "\n"; echo " userid}&course={$log->course}\">$fullname\n"; echo " | \n"; echo "\n"; link_to_popup_window( make_log_url($log->module,$log->url), 'fromloglive',"$log->module $log->action", 400, 600); echo " | \n";; echo "{$log->info} | \n"; echo "
'.$change['text'].'
'; } } } } // Now display new things from each module $mods = get_records('modules', 'visible', '1', 'name', 'id, name'); foreach ($mods as $mod) { // Each module gets it's own logs and prints them include_once($CFG->dirroot.'/mod/'.$mod->name.'/lib.php'); $print_recent_activity = $mod->name.'_print_recent_activity'; if (function_exists($print_recent_activity)) { $modcontent = $print_recent_activity($course, $isteacher, $timestart); if ($modcontent) { $content = true; } } } if (! $content) { echo ' '; } } function get_array_of_activities($courseid) { // For a given course, returns an array of course activity objects // Each item in the array contains he following properties: // cm - course module id // mod - name of the module (eg forum) // section - the number of the section (eg week or topic) // name - the name of the instance // visible - is the instance visible or not // extra - contains extra string to include in any link global $CFG; $mod = array(); if (!$rawmods = get_course_mods($courseid)) { return NULL; } if ($sections = get_records("course_sections", "course", $courseid, "section ASC")) { foreach ($sections as $section) { if (!empty($section->sequence)) { $sequence = explode(",", $section->sequence); foreach ($sequence as $seq) { if (empty($rawmods[$seq])) { continue; } $mod[$seq]->cm = $rawmods[$seq]->id; $mod[$seq]->mod = $rawmods[$seq]->modname; $mod[$seq]->section = $section->section; $mod[$seq]->name = urlencode(get_field($rawmods[$seq]->modname, "name", "id", $rawmods[$seq]->instance)); $mod[$seq]->visible = $rawmods[$seq]->visible; $mod[$seq]->extra = ""; $modname = $mod[$seq]->mod; $functionname = $modname."_get_coursemodule_info"; include_once("$CFG->dirroot/mod/$modname/lib.php"); if (function_exists($functionname)) { if ($info = $functionname($rawmods[$seq])) { if (!empty($info->extra)) { $mod[$seq]->extra = $info->extra; } if (!empty($info->icon)) { $mod[$seq]->icon = $info->icon; } } } } } } } return $mod; } function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modnamesused) { // Returns a number of useful structures for course displays $mods = NULL; // course modules indexed by id $modnames = NULL; // all course module names (except resource!) $modnamesplural= NULL; // all course module names (plural form) $modnamesused = NULL; // course module names used if ($allmods = get_records("modules")) { foreach ($allmods as $mod) { if ($mod->visible) { $modnames[$mod->name] = get_string("modulename", "$mod->name"); $modnamesplural[$mod->name] = get_string("modulenameplural", "$mod->name"); } } asort($modnames); } else { error("No modules are installed!"); } if ($rawmods = get_course_mods($courseid)) { foreach($rawmods as $mod) { // Index the mods if (empty($modnames[$mod->modname])) { continue; } $mods[$mod->id] = $mod; $mods[$mod->id]->modfullname = $modnames[$mod->modname]; if ($mod->visible or isteacher($courseid)) { $modnamesused[$mod->modname] = $modnames[$mod->modname]; } } if ($modnamesused) { asort($modnamesused); } } unset($modnames['resource']); unset($modnames['label']); } function get_all_sections($courseid) { return get_records("course_sections", "course", "$courseid", "section", "section, id, course, summary, sequence, visible"); } function course_set_display($courseid, $display=0) { global $USER; if (empty($USER->id)) { return false; } if ($display == "all" or empty($display)) { $display = 0; } if (record_exists("course_display", "userid", $USER->id, "course", $courseid)) { set_field("course_display", "display", $display, "userid", $USER->id, "course", $courseid); } else { $record->userid = $USER->id; $record->course = $courseid; $record->display = $display; if (!insert_record("course_display", $record)) { notify("Could not save your course display!"); } } return $USER->display[$courseid] = $display; // Note: = not == } function set_section_visible($courseid, $sectionnumber, $visibility) { /// For a given course section, markes it visible or hidden, /// and does the same for every activity in that section if ($section = get_record("course_sections", "course", $courseid, "section", $sectionnumber)) { set_field("course_sections", "visible", "$visibility", "id", $section->id); if (!empty($section->sequence)) { $modules = explode(",", $section->sequence); foreach ($modules as $moduleid) { set_coursemodule_visible($moduleid, $visibility); } } rebuild_course_cache($courseid); } } function print_section($course, $section, $mods, $modnamesused, $absolute=false, $width="100%") { /// Prints a section full of activity modules global $CFG, $USER; static $groupbuttons; static $groupbuttonslink; static $isteacher; static $isediting; static $ismoving; static $strmovehere; static $strmovefull; static $strunreadpostsone; static $untracked; static $usetracking; $labelformatoptions = New stdClass; if (!isset($isteacher)) { $groupbuttons = ($course->groupmode or (!$course->groupmodeforce)); $groupbuttonslink = (!$course->groupmodeforce); $isteacher = isteacher($course->id); $isediting = isediting($course->id); $ismoving = $isediting && ismoving($course->id); if ($ismoving) { $strmovehere = get_string("movehere"); $strmovefull = strip_tags(get_string("movefull", "", "'$USER->activitycopyname'")); } include_once($CFG->dirroot.'/mod/forum/lib.php'); if ($usetracking = forum_tp_can_track_forums()) { $strunreadpostsone = get_string('unreadpostsone', 'forum'); $untracked = forum_tp_get_untracked_forums($USER->id, $course->id); } } $labelformatoptions->noclean = true; $modinfo = unserialize($course->modinfo); //Acccessibility: replace table with list'; print_spacer(10, $indent); echo ' | '; } echo ''.$catimage.' | '; echo ''; echo ''.$category->name.''; echo ' | '; echo ''; echo ' |
'; echo ' | '; echo ''.$course->fullname.''; echo ' | ';
if ($course->guest ) {
echo '';
echo '![]() ![]() ![]() ![]() ![]() ![]() | |
'; print_spacer(10, $indent); echo ' | '; } echo ''; echo ''.$category->name.''; echo ' | '; echo ''; if ($category->coursecount) { echo $category->coursecount; } echo ' |
';
echo ''.
$course->fullname.' '; if ($teachers = get_course_teachers($course->id)) { echo "\n"; foreach ($teachers as $teacher) { if ($teacher->authority > 0) { if (!$teacher->role) { $teacher->role = $course->teacher; } $fullname = fullname($teacher, isteacher($course->id)); // is the USER a teacher of that course echo $teacher->role.': '.$fullname.' '; } } echo "\n"; } echo $enrol->get_access_icons($course); echo ' | '; $options = NULL; $options->noclean = true; $options->para = false; echo format_text($course->summary, FORMAT_MOODLE, $options, $course->id); echo " |
"; print_course_search("", false, "short"); echo " | "; print_single_button("$CFG->wwwroot/course/index.php", NULL, get_string("fulllistofcourses"), "get"); echo " |