diff --git a/course/lib.php b/course/lib.php index 667f76bc25b..3c20221f986 100644 --- a/course/lib.php +++ b/course/lib.php @@ -176,29 +176,20 @@ function print_recent_activity($course) { foreach ($logs as $log) { if ($log->module == "course" and $log->action == "enrol") { if (! $heading) { - print_headline("New users"); + print_headline("New users:"); $heading = true; $content = true; } $user = get_record("user", "id", $log->info); - echo "
  • id&course=$course->id\">$user->firstname $user->lastname
  • "; + echo "

    id&course=$course->id\">$user->firstname $user->lastname

    "; } } // Next, have there been any changes to the course structure? - if ($heading) { - echo "
    "; - $heading = false; - } foreach ($logs as $log) { if ($log->module == "course") { if ($log->action == "add mod" or $log->action == "update mod" or $log->action == "delete mod") { - if (! $heading) { - print_headline("Changes"); - $heading = true; - $content = true; - } $info = split(" ", $log->info); $modname = get_field($info[0], "name", "id", $info[1]); @@ -206,19 +197,38 @@ function print_recent_activity($course) { $info[0] = "discussion"; // nasty hack, really. } - echo "
  • "; switch ($log->action) { case "add mod": - echo "Added a ".$info[0].": wwwroot/course/$log->url\">$modname"; + $changelist["$log->info"] = array ("operation" => "add", "text" => "Added a ".$info[0].":
    wwwroot/course/$log->url\">$modname"); break; case "update mod": - echo "Updated the ".$info[0].": wwwroot/course/$log->url\">$modname"; + if (! $changelist["$log->info"]) { + $changelist["$log->info"] = array ("operation" => "update", "text" => "Updated the ".$info[0].":
    wwwroot/course/$log->url\">$modname"); + } break; case "delete mod": - echo "Deleted a ".$info[0]; + if ($changelist["$log->info"]["operation"] == "add") { + $changelist["$log->info"] = NULL; + } else { + $changelist["$log->info"] = array ("operation" => "delete", "text" => "Deleted a ".$info[0]); + } break; } - echo "
  • "; + } + } + } + + if ($changelist) { + foreach ($changelist as $changeinfo => $change) { + if ($change) { + $changes[$changeinfo] = $change; + } + } + if (count($changes) > 0) { + print_headline("Course changes:"); + $content = true; + foreach ($changes as $changeinfo => $change) { + echo "

    ".$change["text"]."

    "; } } } @@ -226,11 +236,7 @@ function print_recent_activity($course) { // Now all we need to know are the new posts. - if ($heading) { - echo "
    "; - $heading = false; - $content = true; - } + $heading = false; foreach ($logs as $log) { if ($log->module == "discuss") { @@ -251,15 +257,18 @@ function print_recent_activity($course) { if ($post) { if (! $heading) { - print_headline("Discussion Posts"); + print_headline("Discussion Posts:"); $heading = true; $content = true; } + echo "

    $post->firstname $post->lastname:
    "; + echo "\"wwwroot/mod/discuss/$log->url\">"; if ($log->action == "add") { - echo "

  • \"wwwroot/mod/discuss/$log->url\">$post->subject\" by $post->firstname $post->lastname
  • "; + echo "$post->subject"; } else { - echo "
  • \"wwwroot/mod/discuss/$log->url\">$post->subject\" by $post->firstname $post->lastname
  • "; + echo "$post->subject"; } + echo "\"

    "; } }