|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 require_once("../../config.php"); 00004 require_once("lib.php"); 00005 00006 $id = required_param('id', PARAM_INT); // Course Module ID 00007 00008 $PAGE->set_url('/mod/survey/index.php', array('id'=>$id)); 00009 00010 if (!$course = $DB->get_record('course', array('id'=>$id))) { 00011 print_error('invalidcourseid'); 00012 } 00013 00014 require_course_login($course); 00015 $PAGE->set_pagelayout('incourse'); 00016 00017 add_to_log($course->id, "survey", "view all", "index.php?id=$course->id", ""); 00018 00019 $strsurveys = get_string("modulenameplural", "survey"); 00020 $strsectionname = get_string('sectionname', 'format_'.$course->format); 00021 $strname = get_string("name"); 00022 $strstatus = get_string("status"); 00023 $strdone = get_string("done", "survey"); 00024 $strnotdone = get_string("notdone", "survey"); 00025 00026 $PAGE->navbar->add($strsurveys); 00027 $PAGE->set_title($strsurveys); 00028 $PAGE->set_heading($course->fullname); 00029 echo $OUTPUT->header(); 00030 00031 if (! $surveys = get_all_instances_in_course("survey", $course)) { 00032 notice(get_string('thereareno', 'moodle', $strsurveys), "../../course/view.php?id=$course->id"); 00033 } 00034 00035 $usesections = course_format_uses_sections($course->format); 00036 if ($usesections) { 00037 $sections = get_all_sections($course->id); 00038 } 00039 00040 $table = new html_table(); 00041 $table->width = '100%'; 00042 00043 if ($usesections) { 00044 $table->head = array ($strsectionname, $strname, $strstatus); 00045 } else { 00046 $table->head = array ($strname, $strstatus); 00047 } 00048 00049 $currentsection = ''; 00050 00051 foreach ($surveys as $survey) { 00052 if (isloggedin() and survey_already_done($survey->id, $USER->id)) { 00053 $ss = $strdone; 00054 } else { 00055 $ss = $strnotdone; 00056 } 00057 $printsection = ""; 00058 if ($usesections) { 00059 if ($survey->section !== $currentsection) { 00060 if ($survey->section) { 00061 $printsection = get_section_name($course, $sections[$survey->section]); 00062 } 00063 if ($currentsection !== "") { 00064 $table->data[] = 'hr'; 00065 } 00066 $currentsection = $survey->section; 00067 } 00068 } 00069 //Calculate the href 00070 if (!$survey->visible) { 00071 //Show dimmed if the mod is hidden 00072 $tt_href = "<a class=\"dimmed\" href=\"view.php?id=$survey->coursemodule\">".format_string($survey->name,true)."</a>"; 00073 } else { 00074 //Show normal if the mod is visible 00075 $tt_href = "<a href=\"view.php?id=$survey->coursemodule\">".format_string($survey->name,true)."</a>"; 00076 } 00077 00078 if ($usesections) { 00079 $table->data[] = array ($printsection, $tt_href, "<a href=\"view.php?id=$survey->coursemodule\">$ss</a>"); 00080 } else { 00081 $table->data[] = array ($tt_href, "<a href=\"view.php?id=$survey->coursemodule\">$ss</a>"); 00082 } 00083 } 00084 00085 echo "<br />"; 00086 echo html_writer::table($table); 00087 echo $OUTPUT->footer(); 00088 00089