Permalink
Browse files

Cleaned up the Choice report - it's easier to make sense of now

  • Loading branch information...
1 parent 5e7f999 commit da664183e15ba60dd3b605e6ad746521af6ff82e martin committed Aug 18, 2002
Showing with 39 additions and 28 deletions.
  1. +1 −1 mod/choice/lib.php
  2. +38 −27 mod/choice/report.php
View
@@ -91,7 +91,7 @@ function choice_get_answer($choice, $code) {
case 2:
return "$choice->answer2";
default:
- return get_string("undecided");
+ return get_string("notanswered", "choice");
}
}
View
@@ -35,51 +35,62 @@
<A HREF=view.php?id=$cm->id>$choice->name</A> -> $strresponses", "");
- if (! $participants = get_records_sql("SELECT u.* FROM user u, user_students s, user_teachers t
- WHERE (s.course = '$course->id' AND s.user = u.id)
- OR (t.course = '$course->id' AND t.user = u.id)
- ORDER BY u.lastaccess DESC")) {
-
- notify("No participants (strange)", "/course/view.php?id=$course->id");
- die;
+ if (! $users = get_course_users($course->id)) {
+ error("No users found (very strange)");
}
- if ( $allanswers = get_records_sql("SELECT * FROM choice_answers WHERE choice='$choice->id'")) {
+ if ( $allanswers = get_records("choice_answers", "choice", $choice->id)) {
foreach ($allanswers as $aa) {
$answers[$aa->user] = $aa;
}
} else {
$answers = array () ;
}
-
-
$timenow = time();
- echo "<TABLE BORDER=1 CELLSPACING=0 valign=top align=center cellpadding=10>";
- foreach ($participants as $user) {
+ foreach ($users as $user) {
$answer = $answers[$user->id];
+ $useranswer[(int)$answer->answer][] = $user;
+ }
+ ksort($useranswer);
- echo "<TR>";
+ $tablewidth = (int) (100.0 / count($useranswer));
- echo "<TD BGCOLOR=\"$THEME->body\" WIDTH=35 VALIGN=TOP>";
- print_user_picture($user->id, $course->id, $user->picture);
- echo "</TD>";
+ echo "<TABLE CELLPADDING=5 CELLSPACING=10 ALIGN=CENTER>";
+ echo "<TR>";
+ foreach ($useranswer as $key => $answer) {
+ if ($key) {
+ echo "<TH WIDTH=\"$tablewidth%\">";
+ } else {
+ echo "<TH BGCOLOR=\"$THEME->body\" WIDTH=\"$tablewidth%\">";
+ }
+ echo choice_get_answer($choice, $key);
+ echo "</TH>";
+ }
+ echo "</TR><TR>";
- echo "<TD NOWRAP BGCOLOR=\"$THEME->cellheading\">$user->firstname $user->lastname</TD>";
- echo "<TD><P>&nbsp;";
- if ($answer->timemodified) {
- echo userdate($answer->timemodified);
- }
-
- echo "</P> </TD>";
+ foreach ($useranswer as $key => $answer) {
+ if ($key) {
+ echo "<TD WIDTH=\"$tablewidth%\" VALIGN=TOP NOWRAP BGCOLOR=\"$THEME->cellcontent\">";
+ } else {
+ echo "<TD WIDTH=\"$tablewidth%\" VALIGN=TOP NOWRAP BGCOLOR=\"$THEME->body\">";
+ }
- echo "<TD ALIGN=CENTER BGCOLOR=\"$THEME->cellcontent\"><P>";
- echo choice_get_answer($choice, $answer->answer);
- echo "</P></TD></TR>";
+ echo "<TABLE WIDTH=100%>";
+ foreach ($answer as $user) {
+ 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 "</TABLE>";
+
+ echo "</TD>";
}
- echo "</TABLE>";
+ echo "</TR></TABLE>";
print_footer($course);

0 comments on commit da66418

Please sign in to comment.