From 587510bec519dcd8a94aa2d1c3566b26d869dc23 Mon Sep 17 00:00:00 2001 From: selliott Date: Fri, 20 Feb 2004 21:38:42 +0000 Subject: [PATCH] changes to function print_recent_selector_form for normal/advanced filters in course/recent.php --- course/lib.php | 299 +++++++++++++++++++++++++++---------------------- 1 file changed, 168 insertions(+), 131 deletions(-) diff --git a/course/lib.php b/course/lib.php index 2c9ad8227c..a88d3c40bf 100644 --- a/course/lib.php +++ b/course/lib.php @@ -20,178 +20,215 @@ define("FRONTPAGENEWS", 0); define("FRONTPAGECOURSELIST", 1); define("FRONTPAGECATEGORYNAMES", 2); -function print_recent_selector_form($course, $selecteduser=0, $selecteddate="lastlogin", +function print_recent_selector_form($course, $advancedfilter=0, $selecteduser=0, $selecteddate="lastlogin", $mod="", $modid="activity/All", $modaction="", $selectedgroup="", $selectedsort="default") { global $USER, $CFG; $isteacher = isteacher($course->id); - // Get all the possible users - $users = array(); + + if ($advancedfilter) { + + // Get all the possible users + $users = array(); - if ($course->category) { - $courseusers = get_course_users($course->id); - } else { - $courseusers = get_site_users("u.lastaccess DESC", "u.id, u.firstname, u.lastname"); - } - - if ($courseusers) { - foreach ($courseusers as $courseuser) { - $users[$courseuser->id] = fullname($courseuser, $isteacher); + if ($course->category) { + $courseusers = get_course_users($course->id); + } else { + $courseusers = get_site_users("u.lastaccess DESC", "u.id, u.firstname, u.lastname"); + } + + if ($courseusers) { + 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)"; - } + 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); - } + asort($courses); + } - $activities = array(); + $activities = array(); - $selectedactivity = $modid; + $selectedactivity = $modid; - if ($modinfo = unserialize($course->modinfo)) { - $section = 0; - if ($course->format == 'weeks') { // Body - $strsection = get_string("week"); - } else { - $strsection = get_string("topic"); - } + 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["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 --------------"; + $activities["section/individual"] = "------------- Individual Activities --------------"; - foreach ($modinfo as $mod) { - if ($mod->mod == "label") { - continue; - } - if ($mod->section > 0 and $section <> $mod->section) { - $activities["section/$mod->section"] = "-------------- $strsection $mod->section --------------"; - } - $section = $mod->section; - $mod->name = urldecode($mod->name); - if (strlen($mod->name) > 55) { - $mod->name = substr($mod->name, 0, 50)."..."; - } - if (!$mod->visible) { - $mod->name = "(".$mod->name.")"; - } - $activities["$mod->cm"] = $mod->name; + foreach ($modinfo as $mod) { + if ($mod->mod == "label") { + continue; + } + if ($mod->section > 0 and $section <> $mod->section) { + $activities["section/$mod->section"] = "-------------- $strsection $mod->section --------------"; + } + $section = $mod->section; + $mod->name = urldecode($mod->name); + 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"; + if ($mod->cm == $modid) { + $selectedactivity = "$mod->cm"; + } } } - } - $strftimedate = get_string("strftimedate"); - $strftimedaydate = get_string("strftimedaydate"); + $strftimedate = get_string("strftimedate"); + $strftimedaydate = get_string("strftimedaydate"); - asort($users); + 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 + // 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 + $timenow = time(); // GMT - // What day is it now for the user, and when is midnight that day (in GMT). - $timemidnight = $today = usergetmidnight($timenow); + // 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); + $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; - } + 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++; - } + $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; - } + if ($selecteddate == "lastlogin") { + $selecteddate = $USER->lastlogin; + } - echo '
'; - echo ''; - echo "
"; - echo ""; + echo ''; + echo ''; + echo "
"; + echo "
"; - if (isadmin()) { - echo ""; + } else { + echo "id\">"; + } + + $sortfields = array("default" => "By course order","dateasc" => "Date - Most recent last", "datedesc" => "Date - Most recent first"); + + echo ""; + + echo ""; - } else { - echo "id\">"; - } - $sortfields = array("default" => "By course order","dateasc" => "Date - Most recent last", "datedesc" => "Date - Most recent first"); - - echo ""; + echo ""; - echo ""; - - echo ""; - - echo ""; + echo ""; - echo ''; + echo ''; - $groupmode = groupmode($course); + $groupmode = groupmode($course); - if ($groupmode == VISIBLEGROUPS or ($groupmode and isteacheredit($course->id))) { - if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) { + if ($groupmode == VISIBLEGROUPS or ($groupmode and isteacheredit($course->id))) { + if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) { echo ''; + } + } + + + echo ""; + + echo "
" . get_string("courses") . ""; - choose_from_menu ($courses, "id", $course->id, ""); + if (isadmin()) { + echo "
" . get_string("courses") . ""; + choose_from_menu ($courses, "id", $course->id, ""); + echo "
" . get_string("participants") . ""; + choose_from_menu ($users, "user", $selecteduser, get_string("allparticipants") ); + echo "" . get_string("since") . ""; + choose_from_menu ($dates, "date", $selecteddate, get_string("alldays")); echo "
" . get_string("participants") . ""; - choose_from_menu ($users, "user", $selecteduser, get_string("allparticipants") ); - echo "
" . get_string("activities") . ""; + choose_from_menu ($activities, "modid", $selectedactivity, ""); + echo "" . get_string("since") . ""; - choose_from_menu ($dates, "date", $selecteddate, get_string("alldays")); - echo "
" . get_string("activities") . ""; - choose_from_menu ($activities, "modid", $selectedactivity, ""); - echo "" . get_string("sortby") . ""; - choose_from_menu ($sortfields, "sortby", $selectedsort, ""); - echo "
" . get_string("sortby") . ""; + choose_from_menu ($sortfields, "sortby", $selectedsort, ""); + echo "
'; - if ($groupmode == VISIBLEGROUPS) { - print_string('groupsvisible'); + if ($groupmode == VISIBLEGROUPS) { + print_string('groupsvisible'); + } else { + print_string('groupsseparate'); + } + echo ':'; + choose_from_menu($groups, "selectedgroup", $selectedgroup, get_string("allgroups"), "", ""); + echo '"; + echo ""; + echo "
"; + + $advancedlink = "wwwroot/course/recent.php?id=$course->id&advancedfilter=0\">" . get_string("normalfilter") . ""; + print_heading($advancedlink); + echo "
"; + 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 { - print_string('groupsseparate'); + $day = $strdays; } - echo ':'; - choose_from_menu($groups, "selectedgroup", $selectedgroup, get_string("allgroups"), "", ""); - echo ''; + $selecteddate = time() - ($count * 3600 * 24); + $heading = $heading . + "wwwroot/course/recent.php?id=$course->id&date=$selecteddate\"> $count $day | "; } - } + $heading = $strsince . ": wwwroot/course/recent.php?id=$course->id\">$strlastlogin" . " | " . $heading; + print_heading($heading); - echo ""; - echo ""; - echo ""; + print_heading(get_string("activitysince", "", userdate($selecteddate))); + + $advancedlink = "wwwroot/course/recent.php?id=$course->id&advancedfilter=1\">" . get_string("advancedfilter") . ""; + print_heading($advancedlink); + + } - echo ""; - echo ""; - echo ""; } function print_log_selector_form($course, $selecteduser=0, $selecteddate="today", -- 2.39.5