3 require_once("../../config.php");
4 require_once("lib.php");
6 $id = required_param('id', PARAM_INT
); // Course Module ID
8 $PAGE->set_url('/mod/survey/index.php', array('id'=>$id));
10 if (!$course = $DB->get_record('course', array('id'=>$id))) {
11 print_error('invalidcourseid');
14 require_course_login($course);
15 $PAGE->set_pagelayout('incourse');
17 add_to_log($course->id
, "survey", "view all", "index.php?id=$course->id", "");
19 $strsurveys = get_string("modulenameplural", "survey");
20 $strsectionname = get_string('sectionname', 'format_'.$course->format
);
21 $strname = get_string("name");
22 $strstatus = get_string("status");
23 $strdone = get_string("done", "survey");
24 $strnotdone = get_string("notdone", "survey");
26 $PAGE->navbar
->add($strsurveys);
27 $PAGE->set_title($strsurveys);
28 $PAGE->set_heading($course->fullname
);
29 echo $OUTPUT->header();
31 if (! $surveys = get_all_instances_in_course("survey", $course)) {
32 notice(get_string('thereareno', 'moodle', $strsurveys), "../../course/view.php?id=$course->id");
35 $usesections = course_format_uses_sections($course->format
);
37 $sections = get_all_sections($course->id
);
40 $table = new html_table();
41 $table->width
= '100%';
44 $table->head
= array ($strsectionname, $strname, $strstatus);
46 $table->head
= array ($strname, $strstatus);
51 foreach ($surveys as $survey) {
52 if (isloggedin() and survey_already_done($survey->id
, $USER->id
)) {
59 if ($survey->section
!== $currentsection) {
60 if ($survey->section
) {
61 $printsection = get_section_name($course, $sections[$survey->section
]);
63 if ($currentsection !== "") {
64 $table->data
[] = 'hr';
66 $currentsection = $survey->section
;
70 if (!$survey->visible
) {
71 //Show dimmed if the mod is hidden
72 $tt_href = "<a class=\"dimmed\" href=\"view.php?id=$survey->coursemodule\">".format_string($survey->name
,true)."</a>";
74 //Show normal if the mod is visible
75 $tt_href = "<a href=\"view.php?id=$survey->coursemodule\">".format_string($survey->name
,true)."</a>";
79 $table->data
[] = array ($printsection, $tt_href, "<a href=\"view.php?id=$survey->coursemodule\">$ss</a>");
81 $table->data
[] = array ($tt_href, "<a href=\"view.php?id=$survey->coursemodule\">$ss</a>");
86 echo html_writer
::table($table);
87 echo $OUTPUT->footer();