3 require_once("../../config.php");
4 require_once("lib.php");
6 $id = required_param('id',PARAM_INT
); // course
8 if (! $course = get_record("course", "id", $id)) {
9 error("Course ID is incorrect");
12 require_course_login($course);
14 add_to_log($course->id
, "choice", "view all", "index?id=$course->id", "");
16 $strchoice = get_string("modulename", "choice");
17 $strchoices = get_string("modulenameplural", "choice");
19 $navlinks[] = array('name' => $strchoices, 'link' => '', 'type' => 'activity');
20 $navigation = build_navigation($navlinks);
22 print_header_simple("$strchoices", "", $navigation, "", "", true, "", navmenu($course));
25 if (! $choices = get_all_instances_in_course("choice", $course)) {
26 notice("There are no choices", "../../course/view.php?id=$course->id");
29 if ( !empty($USER->id
) and $allanswers = get_records("choice_answers", "userid", $USER->id
)) {
30 foreach ($allanswers as $aa) {
31 $answers[$aa->choiceid
] = $aa;
41 if ($course->format
== "weeks") {
42 $table->head
= array (get_string("week"), get_string("question"), get_string("answer"));
43 $table->align
= array ("center", "left", "left");
44 } else if ($course->format
== "topics") {
45 $table->head
= array (get_string("topic"), get_string("question"), get_string("answer"));
46 $table->align
= array ("center", "left", "left");
48 $table->head
= array (get_string("question"), get_string("answer"));
49 $table->align
= array ("left", "left");
54 foreach ($choices as $choice) {
55 if (!empty($answers[$choice->id
])) {
56 $answer = $answers[$choice->id
];
60 if (!empty($answer->optionid
)) {
61 $aa = format_string(choice_get_option_text($choice, $answer->optionid
));
66 if ($choice->section
!== $currentsection) {
67 if ($choice->section
) {
68 $printsection = $choice->section
;
70 if ($currentsection !== "") {
71 $table->data
[] = 'hr';
73 $currentsection = $choice->section
;
77 if (!$choice->visible
) {
78 //Show dimmed if the mod is hidden
79 $tt_href = "<a class=\"dimmed\" href=\"view.php?id=$choice->coursemodule\">".format_string($choice->name
,true)."</a>";
81 //Show normal if the mod is visible
82 $tt_href = "<a href=\"view.php?id=$choice->coursemodule\">".format_string($choice->name
,true)."</a>";
84 if ($course->format
== "weeks" ||
$course->format
== "topics") {
85 $table->data
[] = array ($printsection, $tt_href, $aa);
87 $table->data
[] = array ($tt_href, $aa);
93 print_footer($course);