]> git.mjollnir.org Git - moodle.git/commitdiff
Slight tweaks to survey display after it's been done (list # of students)
authormartin <martin>
Tue, 25 Jun 2002 07:10:01 +0000 (07:10 +0000)
committermartin <martin>
Tue, 25 Jun 2002 07:10:01 +0000 (07:10 +0000)
mod/survey/lib.php
mod/survey/report.php
mod/survey/view.php

index 518d1e6f7e7536b8dc0fc6d0c330a1c313cf6314..ffe96ab5ecf55b70de9dbfe57b8399318086444e 100644 (file)
@@ -49,6 +49,42 @@ function get_responses_for_survey($surveyid) {
         }
 }
 
+function print_all_responses($survey, $results) {
+
+    global $THEME;
+
+    echo "<TABLE CELLPADDING=5 CELLSPACING=2 ALIGN=CENTER>";
+    echo "<TR><TD>Name<TD>Time<TD>Answered</TR>";
+
+    foreach ($results as $a) {
+                 
+        echo "<TR>";
+        echo "<TD><A HREF=\"report.php?action=student&student=$a->id&id=$survey\">$a->firstname $a->lastname</A></TD>";
+        echo "<TD>".userdate($a->time, "j M Y, h:i A")."</TD>";
+        echo "<TD align=right>$a->numanswers</TD>";
+        echo "</TR>";
+    }
+    echo "</TABLE>";
+}
+
+          
+function get_survey_responses($survey) {
+    return get_records_sql("SELECT a.time as time, count(*) as numanswers, u.*
+                            FROM survey_answers AS a, user AS u
+                            WHERE a.answer1 <> '0' AND a.answer2 <> '0'
+                                  AND a.survey = $survey 
+                                  AND a.user = u.id
+                            GROUP BY a.user ORDER BY a.time ASC");
+}
+
+function count_completed_surveys($survey) {
+    if ($responses = get_survey_responses($survey)) {
+        return count($responses);
+    } else {
+        return 0;
+    }
+}
+
 
 function get_template_name($templateid) {
     global $db;
index 13d4e96d2d60c5c30f62e41205db408ee6cde162..7829211aaf6b83f2cc951e3103e6a47b69b6eb9c 100644 (file)
         break;
 
     }
-
-/// FUNCTIONS //////////////////////////////////////////////////////////////
-
-function print_all_responses($survey, $results) {
-
-    global $THEME;
-
-    echo "<TABLE CELLPADDING=5 CELLSPACING=2 ALIGN=CENTER>";
-    echo "<TR><TD>Name<TD>Time<TD>Answered</TR>";
-
-    foreach ($results as $a) {
-                 
-        echo "<TR>";
-        echo "<TD><A HREF=\"report.php?action=student&student=$a->id&id=$survey\">$a->firstname $a->lastname</A></TD>";
-        echo "<TD>".userdate($a->time, "j M Y, h:i A")."</TD>";
-        echo "<TD align=right>$a->numanswers</TD>";
-        echo "</TR>";
-    }
-    echo "</TABLE>";
-}
-
-          
-function get_survey_responses($survey) {
-    return get_records_sql("SELECT a.time as time, count(*) as numanswers, u.*
-                            FROM survey_answers AS a, user AS u
-                            WHERE a.answer1 <> '0' AND a.answer2 <> '0'
-                                  AND a.survey = $survey 
-                                  AND a.user = u.id
-                            GROUP BY a.user ORDER BY a.time ASC");
-}
+?>
index 3c08683639e2083faabab3e1e5ca63c48677a99f..912d5c4c50e8d633ff3bb6ca32fd95edd743eb83 100644 (file)
@@ -35,6 +35,8 @@
     if (survey_already_done($survey->id, $USER->id)) {
         add_to_log($course->id, "survey", "view graph", "view.php?id=$cm->id", "$survey->id");
         print_heading("You've completed this survey.  The graph below shows a summary of your results compared to the class averages.");
+        $numusers = count_completed_surveys($survey->id);
+        print_heading("$numusers people have completed the survey so far");
         echo "<CENTER>";
         echo "<IMG SRC=\"$CFG->wwwroot/mod/survey/graph.php?id=$cm->id&sid=$USER->id&type=student.png\">";
         echo "</CENTER>";