moodle/mod/survey/index.php

81 lines
2.7 KiB
PHP
Raw Normal View History

<?php // $Id$
2001-11-22 06:23:56 +00:00
require_once("../../config.php");
require_once("lib.php");
2001-11-22 06:23:56 +00:00
require_variable($id); // course
if (! $course = get_record("course", "id", $id)) {
error("Course ID is incorrect");
}
require_course_login($course);
add_to_log($course->id, "survey", "view all", "index.php?id=$course->id", "");
2001-11-22 06:23:56 +00:00
2002-08-12 17:54:13 +00:00
$strsurveys = get_string("modulenameplural", "survey");
$strweek = get_string("week");
$strtopic = get_string("topic");
$strname = get_string("name");
$strstatus = get_string("status");
$strdone = get_string("done", "survey");
$strnotdone = get_string("notdone", "survey");
print_header_simple("$strsurveys", "", "$strsurveys",
2002-11-10 08:43:44 +00:00
"", "", true, "", navmenu($course));
2001-11-22 06:23:56 +00:00
if (! $surveys = get_all_instances_in_course("survey", $course)) {
2001-11-22 06:23:56 +00:00
notice("There are no surveys.", "../../course/view.php?id=$course->id");
}
2002-06-25 16:42:34 +00:00
if ($course->format == "weeks") {
2002-08-12 17:54:13 +00:00
$table->head = array ($strweek, $strname, $strstatus);
2002-06-25 16:42:34 +00:00
$table->align = array ("CENTER", "LEFT", "LEFT");
} else if ($course->format == "topics") {
2002-08-12 17:54:13 +00:00
$table->head = array ($strtopic, $strname, $strstatus);
2002-06-25 16:42:34 +00:00
$table->align = array ("CENTER", "LEFT", "LEFT");
} else {
2002-08-12 17:54:13 +00:00
$table->head = array ($strname, $strstatus);
2002-06-25 16:42:34 +00:00
$table->align = array ("LEFT", "LEFT");
}
2001-11-22 06:23:56 +00:00
2004-01-26 12:29:02 +00:00
$currentsection = '';
2001-11-22 06:23:56 +00:00
foreach ($surveys as $survey) {
if (isset($USER->id) and survey_already_done($survey->id, $USER->id)) {
2002-08-12 17:54:13 +00:00
$ss = $strdone;
2001-11-22 06:23:56 +00:00
} else {
2002-08-12 17:54:13 +00:00
$ss = $strnotdone;
2001-11-22 06:23:56 +00:00
}
2004-01-26 12:29:02 +00:00
$printsection = "";
if ($survey->section !== $currentsection) {
if ($survey->section) {
$printsection = $survey->section;
}
if ($currentsection !== "") {
$table->data[] = 'hr';
}
$currentsection = $survey->section;
}
//Calculate the href
if (!$survey->visible) {
//Show dimmed if the mod is hidden
$tt_href = "<a class=\"dimmed\" href=\"view.php?id=$survey->coursemodule\">$survey->name</a>";
} else {
//Show normal if the mod is visible
$tt_href = "<a href=\"view.php?id=$survey->coursemodule\">$survey->name</a>";
}
2002-06-25 16:42:34 +00:00
if ($course->format == "weeks" or $course->format == "topics") {
$table->data[] = array ($printsection, $tt_href, "<a href=\"view.php?id=$survey->coursemodule\">$ss</a>");
2002-06-25 16:42:34 +00:00
} else {
$table->data[] = array ($tt_href, "<a href=\"view.php?id=$survey->coursemodule\">$ss</a>");
2002-06-25 16:42:34 +00:00
}
2001-11-22 06:23:56 +00:00
}
echo "<br />";
2001-11-22 06:23:56 +00:00
print_table($table);
print_footer($course);
?>