2009-09-24 08:36:06 +00:00
|
|
|
<?php
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2003-01-05 14:19:20 +00:00
|
|
|
require_once("../../config.php");
|
|
|
|
require_once("lib.php");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2005-10-29 16:45:58 +00:00
|
|
|
$id = required_param('id', PARAM_INT); // Course Module ID
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2010-01-16 15:39:56 +00:00
|
|
|
$PAGE->set_url('/mod/survey/index.php', array('id'=>$id));
|
2009-09-24 08:36:06 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2004-08-22 14:38:47 +00:00
|
|
|
require_course_login($course);
|
2009-12-27 12:02:04 +00:00
|
|
|
$PAGE->set_pagelayout('incourse');
|
2002-05-31 09:07:11 +00:00
|
|
|
|
|
|
|
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");
|
2008-01-24 20:33:50 +00:00
|
|
|
|
2009-09-08 02:02:03 +00:00
|
|
|
$PAGE->navbar->add($strsurveys);
|
|
|
|
$PAGE->set_title($strsurveys);
|
|
|
|
echo $OUTPUT->header();
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2008-02-05 21:40:21 +00:00
|
|
|
if (! $surveys = get_all_instances_in_course("survey", $course)) {
|
2007-10-29 10:44:50 +00:00
|
|
|
notice(get_string('thereareno', 'moodle', $strsurveys), "../../course/view.php?id=$course->id");
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
2008-01-24 20:33:50 +00:00
|
|
|
|
2009-08-20 08:46:16 +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 = '';
|
|
|
|
|
2008-02-05 21:40:21 +00:00
|
|
|
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 = "";
|
2008-02-05 21:40:21 +00:00
|
|
|
if ($survey->section !== $currentsection) {
|
|
|
|
if ($survey->section) {
|
|
|
|
$printsection = $survey->section;
|
2004-01-26 12:29:02 +00:00
|
|
|
}
|
|
|
|
if ($currentsection !== "") {
|
|
|
|
$table->data[] = 'hr';
|
|
|
|
}
|
2008-02-05 21:40:21 +00:00
|
|
|
$currentsection = $survey->section;
|
2002-12-29 17:32:32 +00:00
|
|
|
}
|
2003-04-24 18:28:30 +00:00
|
|
|
//Calculate the href
|
2008-02-05 21:40:21 +00:00
|
|
|
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>";
|
|
|
|
}
|
2003-04-24 18:28:30 +00:00
|
|
|
|
2002-06-25 16:42:34 +00:00
|
|
|
if ($course->format == "weeks" or $course->format == "topics") {
|
2008-02-05 21:40:21 +00:00
|
|
|
$table->data[] = array ($printsection, $tt_href, "<a href=\"view.php?id=$survey->coursemodule\">$ss</a>");
|
2002-06-25 16:42:34 +00:00
|
|
|
} else {
|
2008-02-05 21:40:21 +00:00
|
|
|
$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
|
|
|
}
|
|
|
|
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<br />";
|
2010-03-20 22:15:54 +00:00
|
|
|
echo html_writer::table($table);
|
2009-08-06 14:21:09 +00:00
|
|
|
echo $OUTPUT->footer();
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2009-11-01 15:24:58 +00:00
|
|
|
|