course)) { error("Course module is misconfigured"); } require_login($course->id); if (!isteacher($course->id)) { error("Only teachers can look at this page"); } if (!$choice = choice_get_choice($cm->instance)) { error("Course module is incorrect"); } $strchoice = get_string("modulename", "choice"); $strchoices = get_string("modulenameplural", "choice"); $strresponses = get_string("responses", "choice"); add_to_log($course->id, "choice", "report", "report.php?id=$cm->id", "$choice->id"); print_header("$course->shortname: $choice->name: $strresponses", "$course->fullname", "wwwroot/course/view.php?id=$course->id\">$course->shortname -> id\">$strchoices -> id\">$choice->name -> $strresponses", ""); if (! $users = get_course_users($course->id, "u.firstname ASC")) { error("No users found (very strange)"); } if ( $allanswers = get_records("choice_answers", "choice", $choice->id)) { foreach ($allanswers as $aa) { $answers[$aa->userid] = $aa; } } else { $answers = array () ; } $timenow = time(); foreach ($choice->answer as $key => $answer) { $useranswer[$key] = array(); } foreach ($users as $user) { $answer = $answers[$user->id]; $useranswer[(int)$answer->answer][] = $user; } foreach ($choice->answer as $key => $answer) { if (!$choice->answer[$key]) { unset($useranswer[$key]); // Throw away any data that doesn't apply } } ksort($useranswer); $tablewidth = (int) (100.0 / count($useranswer)); echo ""; echo ""; foreach ($useranswer as $key => $answer) { if ($key) { echo ""; } echo ""; foreach ($useranswer as $key => $answer) { if ($key) { echo ""; } echo "
"; } else { echo "body\" WIDTH=\"$tablewidth%\">"; } echo choice_get_answer($choice, $key); echo "
cellcontent\">"; } else { echo "body\">"; } echo ""; foreach ($answer as $user) { echo ""; } echo "
"; print_user_picture($user->id, $course->id, $user->picture); echo ""; echo "

$user->firstname $user->lastname

"; echo "
"; echo "
"; print_footer($course); ?>