Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

104 lines (77 sloc) 3.027 kB
<?PHP // $Id$
require("../../config.php");
require("lib.php");
require_variable($id); // course module
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course module is misconfigured");
}
require_login($course->id);
if (!isteacher($course->id)) {
error("Only teachers can look at this page");
}
if (! $choice = get_record("choice", "id", $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",
"<A HREF=/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 ( $allanswers = get_records("choice_answers", "choice", $choice->id)) {
foreach ($allanswers as $aa) {
$answers[$aa->user] = $aa;
}
} else {
$answers = array () ;
}
$timenow = time();
for ($i=0; $i<=2; $i++) { // number of choices (presently hardcoded)
$useranswer[$i] = array();
}
foreach ($users as $user) {
$answer = $answers[$user->id];
$useranswer[(int)$answer->answer][] = $user;
}
ksort($useranswer);
$tablewidth = (int) (100.0 / count($useranswer));
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>";
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 "<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 "</TR></TABLE>";
print_footer($course);
?>
Jump to Line
Something went wrong with that request. Please try again.