Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/lesson/index.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00028 require_once("../../config.php");
00029 require_once($CFG->dirroot.'/mod/lesson/locallib.php');
00030 
00031 $id = required_param('id', PARAM_INT);   // course
00032 
00033 $PAGE->set_url('/mod/lesson/index.php', array('id'=>$id));
00034 
00035 if (!$course = $DB->get_record("course", array("id" => $id))) {
00036     print_error('invalidcourseid');
00037 }
00038 
00039 require_login($course);
00040 $PAGE->set_pagelayout('incourse');
00041 
00042 add_to_log($course->id, "lesson", "view all", "index.php?id=$course->id", "");
00043 
00044 
00046 
00047 $strlessons = get_string("modulenameplural", "lesson");
00048 $strlesson  = get_string("modulename", "lesson");
00049 
00050 
00052 $PAGE->navbar->add($strlessons);
00053 $PAGE->set_title("$course->shortname: $strlessons");
00054 $PAGE->set_heading($course->fullname);
00055 echo $OUTPUT->header();
00056 
00058 
00059 if (! $lessons = get_all_instances_in_course("lesson", $course)) {
00060     notice(get_string('thereareno', 'moodle', $strlessons), "../../course/view.php?id=$course->id");
00061     die;
00062 }
00063 
00064 $usesections = course_format_uses_sections($course->format);
00065 if ($usesections) {
00066     $sections = get_all_sections($course->id);
00067 }
00068 
00070 
00071 $timenow = time();
00072 $strsectionname  = get_string('sectionname', 'format_'.$course->format);
00073 $strname  = get_string("name");
00074 $strgrade  = get_string("grade");
00075 $strdeadline  = get_string("deadline", "lesson");
00076 $strnodeadline = get_string("nodeadline", "lesson");
00077 $table = new html_table();
00078 
00079 if ($usesections) {
00080     $table->head  = array ($strsectionname, $strname, $strgrade, $strdeadline);
00081     $table->align = array ("center", "left", "center", "center");
00082 } else {
00083     $table->head  = array ($strname, $strgrade, $strdeadline);
00084     $table->align = array ("left", "center", "center");
00085 }
00086 
00087 foreach ($lessons as $lesson) {
00088     if (!$lesson->visible) {
00089         //Show dimmed if the mod is hidden
00090         $link = "<a class=\"dimmed\" href=\"view.php?id=$lesson->coursemodule\">".format_string($lesson->name,true)."</a>";
00091     } else {
00092         //Show normal if the mod is visible
00093         $link = "<a href=\"view.php?id=$lesson->coursemodule\">".format_string($lesson->name,true)."</a>";
00094     }
00095     $cm = get_coursemodule_from_instance('lesson', $lesson->id);
00096     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
00097 
00098     if ($lesson->deadline == 0) {
00099         $due = $strnodeadline;
00100     } else if ($lesson->deadline > $timenow) {
00101         $due = userdate($lesson->deadline);
00102     } else {
00103         $due = "<font color=\"red\">".userdate($lesson->deadline)."</font>";
00104     }
00105 
00106     if ($usesections) {
00107         if (has_capability('mod/lesson:manage', $context)) {
00108             $grade_value = $lesson->grade;
00109         } else {
00110             // it's a student, show their grade
00111             $grade_value = 0;
00112             if ($return = lesson_get_user_grades($lesson, $USER->id)) {
00113                 $grade_value = $return[$USER->id]->rawgrade;
00114             }
00115         }
00116         $table->data[] = array (get_section_name($course, $sections[$lesson->section]), $link, $grade_value, $due);
00117     } else {
00118         $table->data[] = array ($link, $lesson->grade, $due);
00119     }
00120 }
00121 echo html_writer::table($table);
00122 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations