Permalink
Browse files

changes to function print_recent_selector_form for normal/advanced fi…

…lters in course/recent.php
  • Loading branch information...
1 parent 08e2111 commit 587510bec519dcd8a94aa2d1c3566b26d869dc23 selliott committed Feb 20, 2004
Showing with 168 additions and 131 deletions.
  1. +168 −131 course/lib.php
View
@@ -20,178 +20,215 @@
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 '<form action="recent.php" method="get">';
- echo '<input type=hidden name=chooserecent value="1">';
- echo "<center>";
- echo "<table>";
+ echo '<form action="recent.php" method="get">';
+ echo '<input type=hidden name=chooserecent value="1">';
+ echo "<center>";
+ echo "<table>";
- if (isadmin()) {
- echo "<tr><td><b>" . get_string("courses") . "</b></td><td>";
- choose_from_menu ($courses, "id", $course->id, "");
+ if (isadmin()) {
+ echo "<tr><td><b>" . get_string("courses") . "</b></td><td>";
+ choose_from_menu ($courses, "id", $course->id, "");
+ echo "</td></tr>";
+ } else {
+ echo "<input type=hidden name=id value=\"$course->id\">";
+ }
+
+ $sortfields = array("default" => "By course order","dateasc" => "Date - Most recent last", "datedesc" => "Date - Most recent first");
+
+ echo "<tr><td><b>" . get_string("participants") . "</b></td><td>";
+ choose_from_menu ($users, "user", $selecteduser, get_string("allparticipants") );
+ echo "</td>";
+
+ echo "<td align='right'><b>" . get_string("since") . "</b></td><td>";
+ choose_from_menu ($dates, "date", $selecteddate, get_string("alldays"));
echo "</td></tr>";
- } else {
- echo "<input type=hidden name=id value=\"$course->id\">";
- }
- $sortfields = array("default" => "By course order","dateasc" => "Date - Most recent last", "datedesc" => "Date - Most recent first");
-
- echo "<tr><td><b>" . get_string("participants") . "</b></td><td>";
- choose_from_menu ($users, "user", $selecteduser, get_string("allparticipants") );
- echo "</td>";
+ echo "<tr><td><b>" . get_string("activities") . "</b></td><td>";
+ choose_from_menu ($activities, "modid", $selectedactivity, "");
+ echo "</td>";
- echo "<td align='right'><b>" . get_string("since") . "</b></td><td>";
- choose_from_menu ($dates, "date", $selecteddate, get_string("alldays"));
- echo "</td></tr>";
-
- echo "<tr><td><b>" . get_string("activities") . "</b></td><td>";
- choose_from_menu ($activities, "modid", $selectedactivity, "");
- echo "</td>";
-
- echo "<td align='right'><b>" . get_string("sortby") . "</b></td><td>";
- choose_from_menu ($sortfields, "sortby", $selectedsort, "");
- echo "</td></tr>";
+ echo "<td align='right'><b>" . get_string("sortby") . "</b></td><td>";
+ choose_from_menu ($sortfields, "sortby", $selectedsort, "");
+ echo "</td></tr>";
- echo '<tr>';
+ echo '<tr>';
- $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 '<td><b>';
- if ($groupmode == VISIBLEGROUPS) {
- print_string('groupsvisible');
+ if ($groupmode == VISIBLEGROUPS) {
+ print_string('groupsvisible');
+ } else {
+ print_string('groupsseparate');
+ }
+ echo ':</b></td><td>';
+ choose_from_menu($groups, "selectedgroup", $selectedgroup, get_string("allgroups"), "", "");
+ echo '</td>';
+ }
+ }
+
+
+ echo "<td colspan='2' align='right'>";
+ echo "<input type=submit value=\"".get_string("showrecent")."\">";
+ echo "</td></tr>";
+
+ echo "</table>";
+
+ $advancedlink = "<a href=\"$CFG->wwwroot/course/recent.php?id=$course->id&advancedfilter=0\">" . get_string("normalfilter") . "</a>";
+ print_heading($advancedlink);
+ echo "</center>";
+ echo "</form>";
+
+ } 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 ':</b></td><td>';
- choose_from_menu($groups, "selectedgroup", $selectedgroup, get_string("allgroups"), "", "");
- echo '</td>';
+ $selecteddate = time() - ($count * 3600 * 24);
+ $heading = $heading .
+ "<a href=\"$CFG->wwwroot/course/recent.php?id=$course->id&date=$selecteddate\"> $count $day</a> | ";
}
- }
+ $heading = $strsince . ": <a href=\"$CFG->wwwroot/course/recent.php?id=$course->id\">$strlastlogin</a>" . " | " . $heading;
+ print_heading($heading);
- echo "<td colspan='2' align='right'>";
- echo "<input type=submit value=\"".get_string("showrecent")."\">";
- echo "</td></tr>";
+ print_heading(get_string("activitysince", "", userdate($selecteddate)));
+
+ $advancedlink = "<a href=\"$CFG->wwwroot/course/recent.php?id=$course->id&advancedfilter=1\">" . get_string("advancedfilter") . "</a>";
+ print_heading($advancedlink);
+
+ }
- echo "</table>";
- echo "</center>";
- echo "</form>";
}
function print_log_selector_form($course, $selecteduser=0, $selecteddate="today",

0 comments on commit 587510b

Please sign in to comment.