mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
Performance improvements
- better checking of data before processing - used logs are removed to avoid re-processing by other modules
This commit is contained in:
parent
38e5dbf319
commit
ad08fdc277
@ -189,20 +189,23 @@ function assignment_print_recent_activity(&$logs, $isteacher=false) {
|
||||
$content = false;
|
||||
$assignments = NULL;
|
||||
|
||||
foreach ($logs as $log) {
|
||||
if ($log->module == "assignment" and $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;
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,46 +304,49 @@ function forum_print_recent_activity(&$logs, $isteacher=false) {
|
||||
|
||||
$strftimerecent = get_string("strftimerecent");
|
||||
|
||||
foreach ($logs as $log) {
|
||||
foreach ($logs as $key => $log) {
|
||||
if ($log->module == "forum") {
|
||||
//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 ($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>";
|
||||
} else {
|
||||
echo "$post->subject";
|
||||
}
|
||||
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") {
|
||||
echo "<b>$post->subject</b>";
|
||||
} else {
|
||||
echo "$post->subject";
|
||||
}
|
||||
echo "</a>\"</font></p>";
|
||||
}
|
||||
}
|
||||
unset($logs[$key]); // No longer need this record
|
||||
}
|
||||
}
|
||||
return $content;
|
||||
|
@ -125,7 +125,7 @@ function journal_print_recent_activity(&$logs, $isteacher=false) {
|
||||
$content = false;
|
||||
$journals = NULL;
|
||||
|
||||
foreach ($logs as $log) {
|
||||
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
|
||||
@ -146,6 +146,7 @@ function journal_print_recent_activity(&$logs, $isteacher=false) {
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($logs[$key]); // No longer need this record
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,20 +106,23 @@ function survey_print_recent_activity(&$logs, $isteacher=false) {
|
||||
$content = false;
|
||||
$surveys = NULL;
|
||||
|
||||
foreach ($logs as $log) {
|
||||
if ($log->module == "survey" and $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;
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user