]> git.mjollnir.org Git - moodle.git/commitdiff
Some fixes to make choice reports work better when used at site level.
authormoodler <moodler>
Sat, 17 May 2003 06:17:10 +0000 (06:17 +0000)
committermoodler <moodler>
Sat, 17 May 2003 06:17:10 +0000 (06:17 +0000)
PLus some HTML lowercasing

mod/choice/report.php
mod/choice/view.php

index c333dcfadf1425486ca9331d48096c073aa91b67..77120d2b233723f635c61c7dd2340d3651ba1efa 100644 (file)
     add_to_log($course->id, "choice", "report", "report.php?id=$cm->id", "$choice->id");
 
     print_header("$course->shortname: $choice->name: $strresponses", "$course->fullname",
-                 "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> ->
-                  <A HREF=\"index.php?id=$course->id\">$strchoices</A> ->
-                  <A HREF=\"view.php?id=$cm->id\">$choice->name</A> -> $strresponses", "");
+                 "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
+                  <a href=\"index.php?id=$course->id\">$strchoices</a> ->
+                  <a href=\"view.php?id=$cm->id\">$choice->name</a> -> $strresponses", "");
 
 
-    if (! $users = get_course_users($course->id, "u.firstname ASC")) {
-        error("No users found (very strange)");
+    if ($course->category) {
+        if (! $users = get_course_users($course->id, "u.firstname ASC")) {
+            error("No users found (very strange)");
+        }
+    } else {
+        if (! $users = get_site_users("u.firstname ASC")) {
+            error("No users found (very strange)");
+        }
     }
 
     if ( $allanswers = get_records("choice_answers", "choice", $choice->id)) {
 
     $tablewidth = (int) (100.0 / count($useranswer));
 
-    echo "<TABLE CELLPADDING=5 CELLSPACING=10 ALIGN=CENTER>";
-    echo "<TR>";
+    echo "<table cellpadding=\"5\" cellspacing=\"10\" align=\"center\">";
+    echo "<tr>";
     foreach ($useranswer as $key => $answer) {
         if ($key) {
-            echo "<TH WIDTH=\"$tablewidth%\">";
+            echo "<th width=\"$tablewidth%\">";
         } else {
-            echo "<TH BGCOLOR=\"$THEME->body\" WIDTH=\"$tablewidth%\">";
+            echo "<th bgcolor=\"$theme->body\" width=\"$tablewidth%\">";
         }
         echo choice_get_answer($choice, $key);
-        echo "</TH>";
+        echo "</th>";
     }
-    echo "</TR><TR>";
+    echo "</tr><tr>";
 
     foreach ($useranswer as $key => $answer) {
         if ($key) {
-            echo "<TD WIDTH=\"$tablewidth%\" VALIGN=TOP NOWRAP BGCOLOR=\"$THEME->cellcontent\">";
+            echo "<td width=\"$tablewidth%\" valign=top nowrap bgcolor=\"$theme->cellcontent\">";
         } else {
-            echo "<TD WIDTH=\"$tablewidth%\" VALIGN=TOP NOWRAP BGCOLOR=\"$THEME->body\">";
+            echo "<td width=\"$tablewidth%\" valign=top nowrap bgcolor=\"$theme->body\">";
         }
 
-        echo "<TABLE WIDTH=100%>";
+        echo "<table width=\"100%\">";
         foreach ($answer as $user) {
-            echo "<TR><TD WIDTH=10 NOWRAP>";
+            echo "<tr><td width=\"10\" nowrap>";
             print_user_picture($user->id, $course->id, $user->picture);
-            echo "</TD><TD WIDTH=100% NOWRAP>";
-            echo "<P>$user->firstname $user->lastname</P>";
-            echo "</TD></TR>";
+            echo "</td><td width=\"100%\" nowrap>";
+            echo "<p>$user->firstname $user->lastname</p>";
+            echo "</td></tr>";
         }
-        echo "</TABLE>";
+        echo "</table>";
 
-        echo "</TD>";
+        echo "</td>";
     }
-    echo "</TR></TABLE>";
+    echo "</tr></table>";
 
     print_footer($course);
 
index b8c0c5f56fbb77ba476b4b19546158b73fcfa4b3..f71198c1115a7672aaa1afc6463d22619387418c 100644 (file)
 
         print_heading(get_string("responses", "choice"));
 
-        if (! $users = get_course_users($course->id, "u.firstname ASC")) {
-            error("No users found (very strange)");
+        if ($course->category) {
+            if (! $users = get_course_users($course->id, "u.firstname ASC")) {
+                error("No users found (very strange)");
+            }
+        } else {
+            if (! $users = get_site_users("u.firstname ASC")) {
+                error("No users found (very strange)");
+            }
         }
 
         if ( $allanswers = get_records("choice_answers", "choice", $choice->id)) {
 
             $tablewidth = (int) (100.0 / count($useranswer));
 
-            echo "<TABLE CELLPADDING=5 CELLSPACING=10 ALIGN=CENTER>";
-            echo "<TR>";
+            echo "<table cellpadding=5 cellspacing=10 align=center>";
+            echo "<tr>";
             foreach ($useranswer as $key => $answer) {
                 if ($key) {
-                    echo "<TH WIDTH=\"$tablewidth%\">";
+                    echo "<th width=\"$tablewidth%\">";
                 } else {
-                    echo "<TH BGCOLOR=\"$THEME->body\" WIDTH=\"$tablewidth%\">";
+                    echo "<th bgcolor=\"$theme->body\" width=\"$tablewidth%\">";
                 }
                 echo choice_get_answer($choice, $key);
-                echo "</TH>";
+                echo "</th>";
             }
-            echo "</TR><TR>";
+            echo "</tr><tr>";
         
             foreach ($useranswer as $key => $answer) {
                 if ($key) {
-                    echo "<TD WIDTH=\"$tablewidth%\" VALIGN=TOP NOWRAP BGCOLOR=\"$THEME->cellcontent\">";
+                    echo "<td width=\"$tablewidth%\" valign=top nowrap bgcolor=\"$theme->cellcontent\">";
                 } else {
-                    echo "<TD WIDTH=\"$tablewidth%\" VALIGN=TOP NOWRAP BGCOLOR=\"$THEME->body\">";
+                    echo "<td width=\"$tablewidth%\" valign=top nowrap bgcolor=\"$theme->body\">";
                 }
     
-                echo "<TABLE WIDTH=100%>";
+                echo "<table width=100%>";
                 foreach ($answer as $user) {
-                    echo "<TR><TD WIDTH=10 NOWRAP>";
+                    echo "<tr><td width=10 nowrap>";
                     print_user_picture($user->id, $course->id, $user->picture);
-                    echo "</TD><TD WIDTH=100% NOWRAP>";
-                    echo "<P>$user->firstname $user->lastname</P>";
-                    echo "</TD></TR>";
+                    echo "</td><td width=100% nowrap>";
+                    echo "<p>$user->firstname $user->lastname</p>";
+                    echo "</td></tr>";
                 }
-                echo "</TABLE>";
+                echo "</table>";
         
-                echo "</TD>";
+                echo "</td>";
             }
-            echo "</TR></TABLE>";
+            echo "</tr></table>";
             break;
 
 
           case CHOICE_PUBLISH_ANONYMOUS:
             $tablewidth = (int) (100.0 / count($useranswer));
 
-            echo "<TABLE CELLPADDING=5 CELLSPACING=10 ALIGN=CENTER>";
-            echo "<TR>";
+            echo "<table cellpadding=5 cellspacing=10 align=center>";
+            echo "<tr>";
             foreach ($useranswer as $key => $answer) {
                 if ($key) {
-                    echo "<TH WIDTH=\"$tablewidth%\">";
+                    echo "<th width=\"$tablewidth%\">";
                 } else {
-                    echo "<TH BGCOLOR=\"$THEME->body\" WIDTH=\"$tablewidth%\">";
+                    echo "<th bgcolor=\"$theme->body\" width=\"$tablewidth%\">";
                 }
                 echo choice_get_answer($choice, $key);
-                echo "</TH>";
+                echo "</th>";
             }
-            echo "</TR>";
+            echo "</tr>";
 
             $maxcolumn = 0;
             foreach ($useranswer as $key => $answer) {
                 }
             }
 
-            echo "<TR>";
+            echo "<tr>";
             foreach ($useranswer as $key => $answer) {
                 $height = $COLUMN_HEIGHT * ((float)$column[$key] / (float)$maxcolumn);
-                echo "<TD VALIGN=\"BOTTOM\" ALIGN=\"CENTER\">";
-                echo "<IMG SRC=\"column.png\" HEIGHT=\"$height\" width=\"49\"></TD>";
+                echo "<td valign=\"bottom\" align=\"center\">";
+                echo "<img src=\"column.png\" height=\"$height\" width=\"49\"></td>";
             }
-            echo "</TR>";
+            echo "</tr>";
 
-            echo "<TR>";
+            echo "<tr>";
             foreach ($useranswer as $key => $answer) {
-                echo "<TD ALIGN=\"CENTER\">".$column[$key]."</TD>";
+                echo "<td align=\"center\">".$column[$key]."</td>";
             }
-            echo "</TR></TABLE>";
+            echo "</tr></table>";
 
             break;
         }