]> git.mjollnir.org Git - moodle.git/commitdiff
Changes to improve the user activity reports
authormartin <martin>
Sat, 27 Jul 2002 09:44:01 +0000 (09:44 +0000)
committermartin <martin>
Sat, 27 Jul 2002 09:44:01 +0000 (09:44 +0000)
course/lib.php
course/loggraph.php
course/user.php

index 88d3061a784abe81b617cf16dfde52e7b8176b6b..f707420ad64fb9c29382d443b4f15978d50e46e7 100644 (file)
@@ -424,4 +424,9 @@ function get_all_sections($courseid) {
                             ORDER BY section");
 }
 
+function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
+    global $CFG;
+    echo "<IMG BORDER=0 SRC=\"$CFG->wwwroot/course/loggraph.php?id=$course->id&user=$userid&type=$type&date=$date\">";
+}
+
 ?>
index 2a78bbe340a206f7f5c1462b2f4e0fd318852ab5..9e4cc97e00e618e5aea00cf8fec8a6a290d9f339 100644 (file)
@@ -7,6 +7,7 @@
     require_variable($id);    // Course ID
     require_variable($type);  // Graph Type
     optional_variable($user);  // Student ID
+    optional_variable($date);  // Midnight of a date
 
     if (! $course = get_record("course", "id", $id)) {
         error("Course is misconfigured");
@@ -15,7 +16,7 @@
     require_login($course->id);
 
     if (!isteacher($course->id)) {
-        if (! ($type == "student.png" and $user == $USER->id) ) {
+        if (! ($type == "usercourse.png" and $user == $USER->id) ) {
             error("Sorry, you aren't allowed to see this.");
         }
     }
@@ -31,7 +32,7 @@
 
     switch ($type) {
 
-     case "user.png":
+     case "usercourse.png":
 
        $timestart = $course->startdate;
        $i = 0;
@@ -51,7 +52,7 @@
        $maxlogs = max($logs);
 
 
-       $graph = new graph(600, 300);
+       $graph = new graph(750, 400);
        $graph->parameter['title'] = "Rough usage of $course->shortname by $user->firstname $user->lastname";
 
        $graph->x_data           = $days;
@@ -59,6 +60,7 @@
        $graph->y_data['logs']   = $logs;
        $graph->y_format['logs'] = array('colour' => 'blue','bar' => 'fill','legend' =>'actual','bar_size' => 0.4);
        $graph->y_label_left     = "Hits";
+       $graph->label_size       = "6";
 
        $graph->y_order = array('logs');
 
 
        break;
 
+     case "userday.png":
+
+       if (! $date) {
+           error("Must specify a date if you use userday.png format");
+       }
+
+       // XXX still to be done.  The day was getting long!
+
+       break;
+
      default:
        break;
    }
index f639d47a4718db6a95afbadce3c563edd94f55df..10b5f48cdb7235a4bd48e4924660f457fc99dc85 100644 (file)
@@ -5,7 +5,7 @@
 
     require_variable($id);       // course id
     require_variable($user);     // user id
-    optional_variable($mode, "graph");
+    optional_variable($mode, "outline");
 
     if (! $course = get_record("course", "id", $id)) {
         error("Course id is incorrect.");
@@ -24,7 +24,7 @@
 
     add_to_log($course->id, "course", "user report", "user.php?id=$course->id&user=$user->id&mode=$mode", "$user->id"); 
 
-    print_header("$course->shortname: Activity Report", "$course->fullname",
+    print_header("$course->shortname: Activity Report ($mode)", "$course->fullname",
                  "<A HREF=\"../course/view.php?id=$course->id\">$course->shortname</A> ->
                   <A HREF=\"../user/index.php?id=$course->id\">Participants</A> ->
                   <A HREF=\"../user/view.php?id=$user->id&course=$course->id\">$user->firstname $user->lastname</A> -> 
 
     echo "<TABLE CELLPADDING=10 ALIGN=CENTER><TR>";
     echo "<TD>Reports: </TD>";
-    if ($mode != "graph") {
-        echo "<TD><A HREF=user.php?id=$course->id&user=$user->id&mode=graph>Graph</A></TD>";
-    } else {
-        echo "<TD><U>Graph</U></TD>";
-    }
     if ($mode != "outline") {
         echo "<TD><A HREF=user.php?id=$course->id&user=$user->id&mode=outline>Outline</A></TD>";
     } else {
     } else {
         echo "<TD><U>Complete</U></TD>";
     }
+    if ($mode != "today") {
+        echo "<TD><A HREF=user.php?id=$course->id&user=$user->id&mode=today>Today</A></TD>";
+    } else {
+        echo "<TD><U>Today</U></TD>";
+    }
+    if ($mode != "alllogs") {
+        echo "<TD><A HREF=user.php?id=$course->id&user=$user->id&mode=alllogs>All logs</A></TD>";
+    } else {
+        echo "<TD><U>All logs</U></TD>";
+    }
     echo "</TR></TABLE>";
 
 
     get_all_mods($course->id, $mods, $modtype);
 
     switch ($mode) {
-        case "graph" :
-            echo "<HR>";
-            echo "<CENTER><IMG SRC=\"loggraph.php?id=$course->id&user=$user->id&type=user.png\">";
+        case "today" :
+            echo "<HR><CENTER>";
+            print_log_graph($course, $user->id, "userday.png", usergetmidnight(time()) );
+            echo "</CENTER>";
+            print_log($course, $user->id, usergetmidnight(time()), "ORDER BY l.time DESC");
+            break;
+
+        case "alllogs" :
+            echo "<HR><CENTER>";
+            print_log_graph($course, $user->id, "usercourse.png");
+            echo "</CENTER>";
+            print_log($course, $user->id, 0, "ORDER BY l.time DESC");
             break;
 
         case "outline" :