moodle/mod/survey/index.php

78 lines
2.6 KiB
PHP
Raw Normal View History

2001-11-22 06:23:56 +00:00
<?PHP // $Id$
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_login($course->id);
add_to_log($course->id, "survey", "view all", "index.php?id=$course->id", "");
2001-11-22 06:23:56 +00:00
if ($course->category) {
$navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
}
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");
2002-11-10 08:43:44 +00:00
print_header("$course->shortname: $strsurveys", "$course->fullname", "$navigation $strsurveys",
"", "", 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
foreach ($surveys as $survey) {
if (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
}
if ($survey->section) {
$section = "$survey->section";
} else {
$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 ($section, $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
}
2002-07-20 18:20:19 +00:00
echo "<BR>";
2001-11-22 06:23:56 +00:00
print_table($table);
print_footer($course);
?>