moodle/mod/survey/index.php

87 lines
2.9 KiB
PHP
Raw Normal View History

<?php
2001-11-22 06:23:56 +00:00
require_once("../../config.php");
require_once("lib.php");
2001-11-22 06:23:56 +00:00
$id = required_param('id', PARAM_INT); // Course Module ID
2001-11-22 06:23:56 +00:00
$PAGE->set_url('/mod/survey/index.php', array('id'=>$id));
2008-06-01 18:12:24 +00:00
if (!$course = $DB->get_record('course', array('id'=>$id))) {
2008-06-15 09:14:55 +00:00
print_error('invalidcourseid');
2001-11-22 06:23:56 +00:00
}
require_course_login($course);
$PAGE->set_pagelayout('incourse');
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");
$PAGE->navbar->add($strsurveys);
$PAGE->set_title($strsurveys);
echo $OUTPUT->header();
2001-11-22 06:23:56 +00:00
if (! $surveys = get_all_instances_in_course("survey", $course)) {
notice(get_string('thereareno', 'moodle', $strsurveys), "../../course/view.php?id=$course->id");
2001-11-22 06:23:56 +00:00
}
$table = new html_table();
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 = '';
foreach ($surveys as $survey) {
if (!empty($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;
2004-01-26 12:29:02 +00:00
}
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\">".format_string($survey->name,true)."</a>";
} else {
//Show normal if the mod is visible
$tt_href = "<a href=\"view.php?id=$survey->coursemodule\">".format_string($survey->name,true)."</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 />";
echo html_writer::table($table);
echo $OUTPUT->footer();
2001-11-22 06:23:56 +00:00