From: martin Date: Sun, 18 Aug 2002 09:43:01 +0000 (+0000) Subject: Cleaned up the Choice report - it's easier to make sense of now X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=da664183e15ba60dd3b605e6ad746521af6ff82e;p=moodle.git Cleaned up the Choice report - it's easier to make sense of now --- diff --git a/mod/choice/lib.php b/mod/choice/lib.php index 5021879704..cad24204fc 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -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"); } } diff --git a/mod/choice/report.php b/mod/choice/report.php index 42ff7710d8..10c8b935b9 100644 --- a/mod/choice/report.php +++ b/mod/choice/report.php @@ -35,16 +35,11 @@ id>$choice->name -> $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; } @@ -52,34 +47,50 @@ } else { $answers = array () ; } - - $timenow = time(); - echo ""; - foreach ($participants as $user) { + foreach ($users as $user) { $answer = $answers[$user->id]; + $useranswer[(int)$answer->answer][] = $user; + } + ksort($useranswer); - echo ""; + $tablewidth = (int) (100.0 / count($useranswer)); - echo ""; + echo "
body\" WIDTH=35 VALIGN=TOP>"; - print_user_picture($user->id, $course->id, $user->picture); - echo "
"; + echo ""; + foreach ($useranswer as $key => $answer) { + if ($key) { + echo ""; + } + echo ""; - echo ""; - echo ""; + foreach ($useranswer as $key => $answer) { + if ($key) { + echo ""; + echo "
"; + } else { + echo "body\" WIDTH=\"$tablewidth%\">"; + } + echo choice_get_answer($choice, $key); + echo "
cellheading\">$user->firstname $user->lastname

 "; - if ($answer->timemodified) { - echo userdate($answer->timemodified); - } - - echo "

cellcontent\">"; + } else { + echo "body\">"; + } - echo "cellcontent\">

"; - echo choice_get_answer($choice, $answer->answer); - echo "

"; + foreach ($answer as $user) { + echo ""; + } + echo "
"; + print_user_picture($user->id, $course->id, $user->picture); + echo ""; + echo "

$user->firstname $user->lastname

"; + echo "
"; + + echo ""; } - echo ""; + echo ""; print_footer($course);