| [ 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.25.2.4 2008/03/06 04:57:42 scyrma Exp $ 2 /** 3 * This page lists all the instances of lesson in a particular course 4 * 5 * @version $Id: index.php,v 1.25.2.4 2008/03/06 04:57:42 scyrma Exp $ 6 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 7 * @package lesson 8 **/ 9 10 require_once("../../config.php"); 11 require_once($CFG->dirroot.'/mod/lesson/lib.php'); 12 require_once($CFG->dirroot.'/mod/lesson/locallib.php'); 13 14 $id = required_param('id', PARAM_INT); // course 15 16 if (!$course = get_record("course", "id", $id)) { 17 error("Course ID is incorrect"); 18 } 19 20 require_login($course->id); 21 22 add_to_log($course->id, "lesson", "view all", "index.php?id=$course->id", ""); 23 24 25 /// Get all required strings 26 27 $strlessons = get_string("modulenameplural", "lesson"); 28 $strlesson = get_string("modulename", "lesson"); 29 30 31 /// Print the header 32 $navlinks = array(); 33 $navlinks[] = array('name' => $strlessons, 'link' => '', 'type' => 'activity'); 34 35 $navigation = build_navigation($navlinks); 36 37 print_header("$course->shortname: $strlessons", $course->fullname, $navigation, "", "", true, "", navmenu($course)); 38 39 /// Get all the appropriate data 40 41 if (! $lessons = get_all_instances_in_course("lesson", $course)) { 42 notice(get_string('thereareno', 'moodle', $strlessons), "../../course/view.php?id=$course->id"); 43 die; 44 } 45 46 /// Print the list of instances (your module will probably extend this) 47 48 $timenow = time(); 49 $strname = get_string("name"); 50 $strgrade = get_string("grade"); 51 $strdeadline = get_string("deadline", "lesson"); 52 $strweek = get_string("week"); 53 $strtopic = get_string("topic"); 54 $strnodeadline = get_string("nodeadline", "lesson"); 55 $table = new stdClass; 56 57 if ($course->format == "weeks") { 58 $table->head = array ($strweek, $strname, $strgrade, $strdeadline); 59 $table->align = array ("center", "left", "center", "center"); 60 } else if ($course->format == "topics") { 61 $table->head = array ($strtopic, $strname, $strgrade, $strdeadline); 62 $table->align = array ("center", "left", "center", "center"); 63 } else { 64 $table->head = array ($strname, $strgrade, $strdeadline); 65 $table->align = array ("left", "center", "center"); 66 } 67 68 foreach ($lessons as $lesson) { 69 if (!$lesson->visible) { 70 //Show dimmed if the mod is hidden 71 $link = "<a class=\"dimmed\" href=\"view.php?id=$lesson->coursemodule\">".format_string($lesson->name,true)."</a>"; 72 } else { 73 //Show normal if the mod is visible 74 $link = "<a href=\"view.php?id=$lesson->coursemodule\">".format_string($lesson->name,true)."</a>"; 75 } 76 $cm = get_coursemodule_from_instance('lesson', $lesson->id); 77 $context = get_context_instance(CONTEXT_MODULE, $cm->id); 78 79 if ($lesson->deadline == 0) { 80 $due = $strnodeadline; 81 } else if ($lesson->deadline > $timenow) { 82 $due = userdate($lesson->deadline); 83 } else { 84 $due = "<font color=\"red\">".userdate($lesson->deadline)."</font>"; 85 } 86 87 if ($course->format == "weeks" or $course->format == "topics") { 88 if (has_capability('mod/lesson:manage', $context)) { 89 $grade_value = $lesson->grade; 90 } else { 91 // it's a student, show their grade 92 $grade_value = 0; 93 if ($return = lesson_get_user_grades($lesson, $USER->id)) { 94 $grade_value = $return[$USER->id]->rawgrade; 95 } 96 } 97 $table->data[] = array ($lesson->section, $link, $grade_value, $due); 98 } else { 99 $table->data[] = array ($link, $lesson->grade, $due); 100 } 101 } 102 103 echo "<br />"; 104 105 print_table($table); 106 107 /// Finish the page 108 109 print_footer($course); 110 111 ?>
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 |