mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
94 lines
2.8 KiB
PHP
94 lines
2.8 KiB
PHP
<?PHP // $Id$
|
|
|
|
require_once("../../config.php");
|
|
require_once("lib.php");
|
|
|
|
require_variable($id); // course
|
|
|
|
if (! $course = get_record("course", "id", $id)) {
|
|
error("Course ID is incorrect");
|
|
}
|
|
|
|
require_login($course->id);
|
|
|
|
add_to_log($course->id, "choice", "view all", "index?id=$course->id", "");
|
|
|
|
if ($course->category) {
|
|
$navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
|
|
} else {
|
|
$navigation = "";
|
|
}
|
|
|
|
$strchoice = get_string("modulename", "choice");
|
|
$strchoices = get_string("modulenameplural", "choice");
|
|
|
|
print_header("$course->shortname: $strchoices", "$course->fullname",
|
|
"$navigation $strchoices", "", "", true, "", navmenu($course));
|
|
|
|
|
|
if (! $choices = get_all_instances_in_course("choice", $course->id, "cw.section ASC")) {
|
|
notice("There are no choices", "../../course/view.php?id=$course->id");
|
|
}
|
|
|
|
if ( $allanswers = get_records("choice_answers", "userid", $USER->id)) {
|
|
foreach ($allanswers as $aa) {
|
|
$answers[$aa->choice] = $aa;
|
|
}
|
|
|
|
} else {
|
|
$answers = array () ;
|
|
}
|
|
|
|
|
|
$timenow = time();
|
|
|
|
if ($course->format == "weeks") {
|
|
$table->head = array (get_string("week"), get_string("question"), get_string("answer"));
|
|
$table->align = array ("CENTER", "LEFT", "LEFT");
|
|
} else if ($course->format == "topics") {
|
|
$table->head = array (get_string("topic"), get_string("question"), get_string("answer"));
|
|
$table->align = array ("CENTER", "LEFT", "LEFT");
|
|
} else {
|
|
$table->head = array (get_string("question"), get_string("answer"));
|
|
$table->align = array ("LEFT", "LEFT");
|
|
}
|
|
|
|
foreach ($choices as $choice) {
|
|
if (!empty($answers[$choice->id])) {
|
|
$answer = $answers[$choice->id];
|
|
} else {
|
|
$answer = "";
|
|
}
|
|
if (!empty($answer->answer)) {
|
|
$aa = choice_get_answer($choice, $answer->answer);
|
|
} else {
|
|
$aa = "";
|
|
}
|
|
if (!empty($choice->section)) {
|
|
$section = "$choice->section";
|
|
} else {
|
|
$section = "";
|
|
}
|
|
|
|
//Calculate the href
|
|
if (!$choice->visible) {
|
|
//Show dimmed if the mod is hidden
|
|
$tt_href = "<A class=\"dimmed\" HREF=\"view.php?id=$choice->coursemodule\">$choice->name</A>";
|
|
} else {
|
|
//Show normal if the mod is visible
|
|
$tt_href = "<A HREF=\"view.php?id=$choice->coursemodule\">$choice->name</A>";
|
|
}
|
|
if ($course->format == "weeks" || $course->format == "topics") {
|
|
$table->data[] = array ($section, $tt_href, $aa);
|
|
} else {
|
|
$table->data[] = array ($tt_href, $aa);
|
|
}
|
|
}
|
|
echo "<BR>";
|
|
print_table($table);
|
|
|
|
print_footer($course);
|
|
|
|
?>
|
|
|