Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/assignment/index.php
Go to the documentation of this file.
00001 <?php
00002 
00003 require_once("../../config.php");
00004 require_once("lib.php");
00005 require_once($CFG->libdir.'/gradelib.php');
00006 
00007 $id = required_param('id', PARAM_INT);   // course
00008 
00009 if (!$course = $DB->get_record('course', array('id'=>$id))) {
00010     print_error('invalidcourseid');
00011 }
00012 
00013 require_course_login($course);
00014 $PAGE->set_pagelayout('incourse');
00015 
00016 add_to_log($course->id, "assignment", "view all", "index.php?id=$course->id", "");
00017 
00018 $strassignments = get_string("modulenameplural", "assignment");
00019 $strassignment = get_string("modulename", "assignment");
00020 $strassignmenttype = get_string("assignmenttype", "assignment");
00021 $strsectionname  = get_string('sectionname', 'format_'.$course->format);
00022 $strname = get_string("name");
00023 $strduedate = get_string("duedate", "assignment");
00024 $strsubmitted = get_string("submitted", "assignment");
00025 $strgrade = get_string("grade");
00026 
00027 
00028 $PAGE->set_url('/mod/assignment/index.php', array('id'=>$course->id));
00029 $PAGE->navbar->add($strassignments);
00030 $PAGE->set_title($strassignments);
00031 $PAGE->set_heading($course->fullname);
00032 echo $OUTPUT->header();
00033 
00034 if (!$cms = get_coursemodules_in_course('assignment', $course->id, 'cm.idnumber, m.assignmenttype, m.timedue')) {
00035     notice(get_string('noassignments', 'assignment'), "../../course/view.php?id=$course->id");
00036     die;
00037 }
00038 
00039 $usesections = course_format_uses_sections($course->format);
00040 if ($usesections) {
00041     $sections = get_all_sections($course->id);
00042 }
00043 
00044 $timenow = time();
00045 
00046 $table = new html_table();
00047 
00048 if ($usesections) {
00049     $table->head  = array ($strsectionname, $strname, $strassignmenttype, $strduedate, $strsubmitted, $strgrade);
00050 } else {
00051     $table->head  = array ($strname, $strassignmenttype, $strduedate, $strsubmitted, $strgrade);
00052 }
00053 
00054 $currentsection = "";
00055 
00056 $types = assignment_types();
00057 
00058 $modinfo = get_fast_modinfo($course);
00059 foreach ($modinfo->instances['assignment'] as $cm) {
00060     if (!$cm->uservisible) {
00061         continue;
00062     }
00063 
00064     $cm->timedue        = $cms[$cm->id]->timedue;
00065     $cm->assignmenttype = $cms[$cm->id]->assignmenttype;
00066     $cm->idnumber       = $cms[$cm->id]->idnumber;
00067 
00068     //Show dimmed if the mod is hidden
00069     $class = $cm->visible ? '' : 'class="dimmed"';
00070 
00071     $link = "<a $class href=\"view.php?id=$cm->id\">".format_string($cm->name)."</a>";
00072 
00073     $printsection = "";
00074     if ($usesections) {
00075         if ($cm->sectionnum !== $currentsection) {
00076             if ($cm->sectionnum) {
00077                 $printsection = get_section_name($course, $sections[$cm->sectionnum]);
00078             }
00079             if ($currentsection !== "") {
00080                 $table->data[] = 'hr';
00081             }
00082             $currentsection = $cm->sectionnum;
00083         }
00084     }
00085 
00086     if (!file_exists($CFG->dirroot.'/mod/assignment/type/'.$cm->assignmenttype.'/assignment.class.php')) {
00087         continue;
00088     }
00089 
00090     require_once ($CFG->dirroot.'/mod/assignment/type/'.$cm->assignmenttype.'/assignment.class.php');
00091     $assignmentclass = 'assignment_'.$cm->assignmenttype;
00092     $assignmentinstance = new $assignmentclass($cm->id, NULL, $cm, $course);
00093 
00094     $submitted = $assignmentinstance->submittedlink(true);
00095 
00096     $grading_info = grade_get_grades($course->id, 'mod', 'assignment', $cm->instance, $USER->id);
00097     if (isset($grading_info->items[0]) && !$grading_info->items[0]->grades[$USER->id]->hidden ) {
00098         $grade = $grading_info->items[0]->grades[$USER->id]->str_grade;
00099     }
00100     else {
00101         $grade = '-';
00102     }
00103 
00104     $type = $types[$cm->assignmenttype];
00105 
00106     // if type has an 'all.php' defined, make this a link
00107     $pathtoall = "{$CFG->dirroot}/mod/assignment/type/{$cm->assignmenttype}/all.php";
00108     if (file_exists($pathtoall)) {
00109         $type = "<a href=\"{$CFG->wwwroot}/mod/assignment/type/{$cm->assignmenttype}/".
00110             "all.php?id={$course->id}\">$type</a>";
00111     }
00112 
00113     $due = $cm->timedue ? userdate($cm->timedue) : '-';
00114 
00115     if ($usesections) {
00116         $table->data[] = array ($printsection, $link, $type, $due, $submitted, $grade);
00117     } else {
00118         $table->data[] = array ($link, $type, $due, $submitted, $grade);
00119     }
00120 }
00121 
00122 echo "<br />";
00123 
00124 echo html_writer::table($table);
00125 
00126 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations