| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: index.php,v 1.32.2.6 2008/02/26 23:19:05 skodak Exp $ 2 3 require_once("../../config.php"); 4 require_once ("lib.php"); 5 6 $id = required_param('id',PARAM_INT); // course 7 8 if (! $course = get_record("course", "id", $id)) { 9 error("Course ID is incorrect"); 10 } 11 12 require_course_login($course); 13 14 add_to_log($course->id, "choice", "view all", "index?id=$course->id", ""); 15 16 $strchoice = get_string("modulename", "choice"); 17 $strchoices = get_string("modulenameplural", "choice"); 18 $navlinks = array(); 19 $navlinks[] = array('name' => $strchoices, 'link' => '', 'type' => 'activity'); 20 $navigation = build_navigation($navlinks); 21 22 print_header_simple("$strchoices", "", $navigation, "", "", true, "", navmenu($course)); 23 24 25 if (! $choices = get_all_instances_in_course("choice", $course)) { 26 notice(get_string('thereareno', 'moodle', $strchoices), "../../course/view.php?id=$course->id"); 27 } 28 29 $sql = "SELECT cha.* 30 FROM {$CFG->prefix}choice ch, {$CFG->prefix}choice_answers cha 31 WHERE cha.choiceid = ch.id AND 32 ch.course = $course->id AND cha.userid = $USER->id"; 33 34 $answers = array () ; 35 if (isloggedin() and !isguestuser() and $allanswers = get_records_sql($sql)) { 36 foreach ($allanswers as $aa) { 37 $answers[$aa->choiceid] = $aa; 38 } 39 unset($allanswers); 40 } 41 42 43 $timenow = time(); 44 45 if ($course->format == "weeks") { 46 $table->head = array (get_string("week"), get_string("question"), get_string("answer")); 47 $table->align = array ("center", "left", "left"); 48 } else if ($course->format == "topics") { 49 $table->head = array (get_string("topic"), get_string("question"), get_string("answer")); 50 $table->align = array ("center", "left", "left"); 51 } else { 52 $table->head = array (get_string("question"), get_string("answer")); 53 $table->align = array ("left", "left"); 54 } 55 56 $currentsection = ""; 57 58 foreach ($choices as $choice) { 59 if (!empty($answers[$choice->id])) { 60 $answer = $answers[$choice->id]; 61 } else { 62 $answer = ""; 63 } 64 if (!empty($answer->optionid)) { 65 $aa = format_string(choice_get_option_text($choice, $answer->optionid)); 66 } else { 67 $aa = ""; 68 } 69 $printsection = ""; 70 if ($choice->section !== $currentsection) { 71 if ($choice->section) { 72 $printsection = $choice->section; 73 } 74 if ($currentsection !== "") { 75 $table->data[] = 'hr'; 76 } 77 $currentsection = $choice->section; 78 } 79 80 //Calculate the href 81 if (!$choice->visible) { 82 //Show dimmed if the mod is hidden 83 $tt_href = "<a class=\"dimmed\" href=\"view.php?id=$choice->coursemodule\">".format_string($choice->name,true)."</a>"; 84 } else { 85 //Show normal if the mod is visible 86 $tt_href = "<a href=\"view.php?id=$choice->coursemodule\">".format_string($choice->name,true)."</a>"; 87 } 88 if ($course->format == "weeks" || $course->format == "topics") { 89 $table->data[] = array ($printsection, $tt_href, $aa); 90 } else { 91 $table->data[] = array ($tt_href, $aa); 92 } 93 } 94 echo "<br />"; 95 print_table($table); 96 97 print_footer($course); 98 99 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |