$timestart = $timemaxrecent;
}
- if (! $logs = get_records_select("log", "time > '$timestart' AND ".
- "course = '$course->id' AND ".
- "module <> 'user' AND ".
- "action <> 'view' AND ".
- "action <> 'view all' ", "time ASC")) {
- return;
- }
-
// Firstly, have there been any new enrolments?
$heading = false;
$content = false;
- foreach ($logs as $key => $log) {
- if ($log->module == "course" and $log->action == "enrol") {
+
+ $logs = get_records_select("log", "time > '$timestart' AND course = '$course->id' AND
+ module = 'course' AND action = 'enrol'", "time ASC");
+
+ if ($logs) {
+ foreach ($logs as $key => $log) {
if (! $heading) {
print_headline(get_string("newusers").":");
$heading = true;
if (isstudent($course->id, $user->id)) {
echo "<p><font size=1><a href=\"../user/view.php?id=$user->id&course=$course->id\">$user->firstname $user->lastname</a></font></p>";
}
- unset($logs[$key]); // No further need for it
}
}
- if (! $logs) {
- return;
- }
+ // Next, have there been any modifications to the course structure?
- // Next, have there been any changes to the course structure?
-
- foreach ($logs as $key => $log) {
- if ($log->module == "course") {
- if ($log->action == "add mod" or $log->action == "update mod" or $log->action == "delete mod") {
- $info = split(" ", $log->info);
- $modname = get_field($info[0], "name", "id", $info[1]);
- //Create a temp valid module structure (course,id)
- $tempmod->course = $log->course;
- $tempmod->id = $info[1];
- //Obtain the visible property from the instance
- $modvisible = instance_is_visible($info[0],$tempmod);
-
- //Only if the mod is visible
- if ($modvisible) {
- switch ($log->action) {
- case "add mod":
- $stradded = get_string("added", "moodle", get_string("modulename", $info[0]));
- $changelist["$log->info"] = array ("operation" => "add", "text" => "$stradded:<BR><A HREF=\"$CFG->wwwroot/course/$log->url\">$modname</A>");
- break;
- case "update mod":
- $strupdated = get_string("updated", "moodle", get_string("modulename", $info[0]));
- if (empty($changelist["$log->info"])) {
- $changelist["$log->info"] = array ("operation" => "update", "text" => "$strupdated:<BR><A HREF=\"$CFG->wwwroot/course/$log->url\">$modname</A>");
- }
- break;
- case "delete mod":
- if (!empty($changelist["$log->info"]["operation"]) and
- $changelist["$log->info"]["operation"] == "add") {
- $changelist["$log->info"] = NULL;
- } else {
- $strdeleted = get_string("deletedactivity", "moodle", get_string("modulename", $info[0]));
- $changelist["$log->info"] = array ("operation" => "delete", "text" => $strdeleted);
- }
- break;
- }
+ $logs = get_records_select("log", "time > '$timestart' AND course = '$course->id' AND
+ module = 'course' AND action LIKE '% mod'", "time ASC");
+
+ if ($logs) {
+ foreach ($logs as $key => $log) {
+ $info = split(" ", $log->info);
+ $modname = get_field($info[0], "name", "id", $info[1]);
+ //Create a temp valid module structure (course,id)
+ $tempmod->course = $log->course;
+ $tempmod->id = $info[1];
+ //Obtain the visible property from the instance
+ $modvisible = instance_is_visible($info[0],$tempmod);
+
+ //Only if the mod is visible
+ if ($modvisible) {
+ switch ($log->action) {
+ case "add mod":
+ $stradded = get_string("added", "moodle", get_string("modulename", $info[0]));
+ $changelist["$log->info"] = array ("operation" => "add", "text" => "$stradded:<BR><A HREF=\"$CFG->wwwroot/course/$log->url\">$modname</A>");
+ break;
+ case "update mod":
+ $strupdated = get_string("updated", "moodle", get_string("modulename", $info[0]));
+ if (empty($changelist["$log->info"])) {
+ $changelist["$log->info"] = array ("operation" => "update", "text" => "$strupdated:<BR><A HREF=\"$CFG->wwwroot/course/$log->url\">$modname</A>");
+ }
+ break;
+ case "delete mod":
+ if (!empty($changelist["$log->info"]["operation"]) and
+ $changelist["$log->info"]["operation"] == "add") {
+ $changelist["$log->info"] = NULL;
+ } else {
+ $strdeleted = get_string("deletedactivity", "moodle", get_string("modulename", $info[0]));
+ $changelist["$log->info"] = array ("operation" => "delete", "text" => $strdeleted);
+ }
+ break;
}
}
- unset($logs[$key]); // No further need for it
}
}
}
}
- if (! $logs) {
- return;
- }
-
// Now display new things from each module
$mods = get_list_of_plugins("mod");
- foreach ($mods as $mod) {
+ $isteacher = isteacher($course->id);
+
+ foreach ($mods as $mod) { // Each module gets it's own logs and prints them
include_once("$CFG->dirroot/mod/$mod/lib.php");
$print_recent_activity = $mod."_print_recent_activity";
- if ($logs and function_exists($print_recent_activity)) {
- $modcontent = $print_recent_activity($logs, isteacher($course->id));
+ if (function_exists($print_recent_activity)) {
+ $modcontent = $print_recent_activity($course, $isteacher, $timestart);
if ($modcontent) {
$content = true;
}
return true;
}
-function assignment_print_recent_activity(&$logs, $isteacher=false) {
+function assignment_print_recent_activity($course, $isteacher, $timestart) {
global $CFG;
$content = false;
$assignments = NULL;
- foreach ($logs as $key => $log) {
- if ($log->module == "assignment") {
- if ($log->action == "upload") {
- //Create a temp valid module structure (course,id)
- $tempmod->course = $log->course;
- $tempmod->id = $log->info;
- //Obtain the visible property from the instance
- $modvisible = instance_is_visible($log->module,$tempmod);
-
- //Only if the mod is visible
- if ($modvisible) {
- $assignments[$log->info] = assignment_log_info($log);
- $assignments[$log->info]->time = $log->time;
- $assignments[$log->info]->url = $log->url;
- }
- }
- unset($logs[$key]); // No longer need this record
+ if (!$logs = get_records_select("log", "time > '$timestart' AND ".
+ "course = '$course->id' AND ".
+ "module = 'assignment' AND ".
+ "action = 'upload' ", "time ASC")) {
+ return false;
+ }
+
+ foreach ($logs as $log) {
+ //Create a temp valid module structure (course,id)
+ $tempmod->course = $log->course;
+ $tempmod->id = $log->info;
+ //Obtain the visible property from the instance
+ $modvisible = instance_is_visible($log->module,$tempmod);
+
+ //Only if the mod is visible
+ if ($modvisible) {
+ $assignments[$log->info] = assignment_log_info($log);
+ $assignments[$log->info]->time = $log->time;
+ $assignments[$log->info]->url = $log->url;
}
}
print_headline(get_string("newsubmissions", "assignment").":");
foreach ($assignments as $assignment) {
$date = userdate($assignment->time, $strftimerecent);
- echo "<P><FONT SIZE=1>$date - $assignment->firstname $assignment->lastname<BR>";
- echo "\"<A HREF=\"$CFG->wwwroot/mod/assignment/$assignment->url\">";
+ echo "<p><font size=1>$date - $assignment->firstname $assignment->lastname<br>";
+ echo "\"<a href=\"$CFG->wwwroot/mod/assignment/$assignment->url\">";
echo "$assignment->name";
- echo "</A>\"</FONT></P>";
+ echo "</a>\"</font></p>";
}
}
}
}
-function forum_print_recent_activity(&$logs, $isteacher=false) {
+function forum_print_recent_activity($course, $isteacher, $timestart) {
global $CFG;
$heading = false;
$content = false;
+ if (!$logs = get_records_select("log", "time > '$timestart' AND ".
+ "course = '$course->id' AND ".
+ "module = 'forum' AND ".
+ "action LIKE 'add %' ", "time ASC")){
+ return false;
+ }
+
$strftimerecent = get_string("strftimerecent");
- foreach ($logs as $key => $log) {
- if ($log->module == "forum") {
- if ($log->action == "add post" or $log->action == "add discussion") {
- //Get post info, I'll need it later
- $post = forum_get_post_from_log($log);
-
- //Create a temp valid module structure (course,id)
- $tempmod->course = $log->course;
- $tempmod->id = $post->forum;
- //Obtain the visible property from the instance
- $modvisible = instance_is_visible($log->module,$tempmod);
-
- //Only if the mod is visible
- if ($modvisible) {
- if ($post) {
- $teacheronly = "";
- if ($forum = get_record("forum", "id", $post->forum) ) {
- if ($forum->type == "teacher") {
- if ($isteacher) {
- $teacheronly = "class=\"teacheronly\"";
- } else {
- continue;
- }
- }
- }
- if (! $heading) {
- print_headline(get_string("newforumposts", "forum").":");
- $heading = true;
- $content = true;
- }
- $date = userdate($post->modified, $strftimerecent);
- echo "<p $teacheronly><font size=1>$date - $post->firstname $post->lastname<br>";
- echo "\"<a href=\"$CFG->wwwroot/mod/forum/$log->url\">";
- if ($log->action == "add discussion") {
- echo "<b>$post->subject</b>";
+ foreach ($logs as $log) {
+ //Get post info, I'll need it later
+ $post = forum_get_post_from_log($log);
+
+ //Create a temp valid module structure (course,id)
+ $tempmod->course = $log->course;
+ $tempmod->id = $post->forum;
+ //Obtain the visible property from the instance
+ $modvisible = instance_is_visible($log->module,$tempmod);
+
+ //Only if the mod is visible
+ if ($modvisible) {
+ if ($post) {
+ $teacheronly = "";
+ if ($forum = get_record("forum", "id", $post->forum) ) {
+ if ($forum->type == "teacher") {
+ if ($isteacher) {
+ $teacheronly = "class=\"teacheronly\"";
} else {
- echo "$post->subject";
+ continue;
}
- echo "</a>\"</font></p>";
}
}
+ if (! $heading) {
+ print_headline(get_string("newforumposts", "forum").":");
+ $heading = true;
+ $content = true;
+ }
+ $date = userdate($post->modified, $strftimerecent);
+ echo "<p $teacheronly><font size=1>$date - $post->firstname $post->lastname<br>";
+ echo "\"<a href=\"$CFG->wwwroot/mod/forum/$log->url\">";
+ if ($log->action == "add discussion") {
+ echo "<b>$post->subject</b>";
+ } else {
+ echo "$post->subject";
+ }
+ echo "</a>\"</font></p>";
}
- unset($logs[$key]); // No longer need this record
}
}
+
return $content;
}
return true;
}
-function journal_print_recent_activity(&$logs, $isteacher=false) {
+function journal_print_recent_activity($course, $isteacher, $timestart) {
global $CFG;
$content = false;
$journals = NULL;
- foreach ($logs as $key => $log) {
- if ($log->module == "journal") {
- if ($log->action == "add entry" or $log->action == "update entry") {
- ///Get journal info. I'll need it later
- $j_log_info = journal_log_info($log);
-
- //Create a temp valid module structure (course,id)
- $tempmod->course = $log->course;
- $tempmod->id = $j_log_info->id;
- //Obtain the visible property from the instance
- $modvisible = instance_is_visible($log->module,$tempmod);
-
- //Only if the mod is visible
- if ($modvisible) {
- if (!isset($journals[$log->info])) {
- $journals[$log->info] = $j_log_info;
- $journals[$log->info]->time = $log->time;
- $journals[$log->info]->url = $log->url;
- }
- }
+ if (!$logs = get_records_select("log", "time > '$timestart' AND ".
+ "course = '$course->id' AND ".
+ "module = 'journal' AND ".
+ "(action = 'add entry' OR action = 'update entry')", "time ASC")){
+ return false;
+ }
+
+ foreach ($logs as $log) {
+ ///Get journal info. I'll need it later
+ $j_log_info = journal_log_info($log);
+
+ //Create a temp valid module structure (course,id)
+ $tempmod->course = $log->course;
+ $tempmod->id = $j_log_info->id;
+ //Obtain the visible property from the instance
+ $modvisible = instance_is_visible($log->module,$tempmod);
+
+ //Only if the mod is visible
+ if ($modvisible) {
+ if (!isset($journals[$log->info])) {
+ $journals[$log->info] = $j_log_info;
+ $journals[$log->info]->time = $log->time;
+ $journals[$log->info]->url = $log->url;
}
- unset($logs[$key]); // No longer need this record
}
}
print_headline(get_string("newjournalentries", "journal").":");
foreach ($journals as $journal) {
$date = userdate($journal->time, $strftimerecent);
- echo "<P><FONT SIZE=1>$date - $journal->firstname $journal->lastname<BR>";
- echo "\"<A HREF=\"$CFG->wwwroot/mod/journal/$journal->url\">";
+ echo "<p><font size=1>$date - $journal->firstname $journal->lastname<br>";
+ echo "\"<a href=\"$CFG->wwwroot/mod/journal/$journal->url\">";
echo "$journal->name";
- echo "</A>\"</FONT></P>";
+ echo "</a>\"</font></p>";
}
}
return true;
}
-function quiz_print_recent_activity(&$logs, $isteacher=false) {
-/// Given a list of logs, assumed to be those since the last login
-/// this function prints a short list of changes related to this module
-/// If isteacher is true then perhaps additional information is printed.
-/// This function is called from course/lib.php: print_recent_activity()
-
- global $CFG;
-
- $content = "";
-
- return $content; // True if anything was printed, otherwise false
-}
-
function quiz_cron () {
/// Function to be run periodically according to the moodle cron
/// This function searches for things that need to be done, such
}
}
-function survey_print_recent_activity(&$logs, $isteacher=false) {
+function survey_print_recent_activity($course, $isteacher, $timestart) {
global $CFG;
$content = false;
$surveys = NULL;
- foreach ($logs as $key => $log) {
- if ($log->module == "survey") {
- if ($log->action == "submit") {
- //Create a temp valid module structure (course,id)
- $tempmod->course = $log->course;
- $tempmod->id = $log->info;
- //Obtain the visible property from the instance
- $modvisible = instance_is_visible($log->module,$tempmod);
-
- //Only if the mod is visible
- if ($modvisible) {
- $surveys[$log->id] = survey_log_info($log);
- $surveys[$log->id]->time = $log->time;
- $surveys[$log->id]->url = $log->url;
- }
- }
- unset($logs[$key]); // No longer need this record
+ if (!$logs = get_records_select("log", "time > '$timestart' AND ".
+ "course = '$course->id' AND ".
+ "module = 'survey' AND ".
+ "action = 'submit' ", "time ASC")) {
+ return false;
+ }
+
+ foreach ($logs as $log) {
+ //Create a temp valid module structure (course,id)
+ $tempmod->course = $log->course;
+ $tempmod->id = $log->info;
+ //Obtain the visible property from the instance
+ $modvisible = instance_is_visible($log->module,$tempmod);
+
+ //Only if the mod is visible
+ if ($modvisible) {
+ $surveys[$log->id] = survey_log_info($log);
+ $surveys[$log->id]->time = $log->time;
+ $surveys[$log->id]->url = $log->url;
}
}
print_headline(get_string("newsurveyresponses", "survey").":");
foreach ($surveys as $survey) {
$date = userdate($survey->time, $strftimerecent);
- echo "<P><FONT SIZE=1>$date - $survey->firstname $survey->lastname<BR>";
- echo "\"<A HREF=\"$CFG->wwwroot/mod/survey/$survey->url\">";
+ echo "<p><font size=1>$date - $survey->firstname $survey->lastname<br>";
+ echo "\"<a href=\"$CFG->wwwroot/mod/survey/$survey->url\">";
echo "$survey->name";
- echo "</A>\"</FONT></P>";
+ echo "</a>\"</font></p>";
}
}