3 require_once("../../config.php");
4 require_once("lib.php");
5 require_once($CFG->libdir
.'/gradelib.php');
7 $id = required_param('id', PARAM_INT
); // course
9 if (!$course = $DB->get_record('course', array('id'=>$id))) {
10 print_error('invalidcourseid');
13 require_course_login($course);
14 $PAGE->set_pagelayout('incourse');
16 add_to_log($course->id
, "assignment", "view all", "index.php?id=$course->id", "");
18 $strassignments = get_string("modulenameplural", "assignment");
19 $strassignment = get_string("modulename", "assignment");
20 $strassignmenttype = get_string("assignmenttype", "assignment");
21 $strname = get_string("name");
22 $strduedate = get_string("duedate", "assignment");
23 $strsubmitted = get_string("submitted", "assignment");
24 $strgrade = get_string("grade");
27 $PAGE->set_url('/mod/assignment/index.php', array('id'=>$course->id
));
28 $PAGE->navbar
->add($strassignments);
29 $PAGE->set_title($strassignments);
30 $PAGE->set_heading($course->fullname
);
31 echo $OUTPUT->header();
33 if (!$cms = get_coursemodules_in_course('assignment', $course->id
, 'cm.idnumber, m.assignmenttype, m.timedue')) {
34 notice(get_string('noassignments', 'assignment'), "../../course/view.php?id=$course->id");
38 $usesections = course_format_uses_sections($course->format
);
42 $table = new html_table();
45 $strsectionname = get_string('sectionname', 'format_'.$course->format
);
46 $table->head
= array ($strsectionname, $strname, $strassignmenttype, $strduedate, $strsubmitted, $strgrade);
48 $table->head
= array ($strname, $strassignmenttype, $strduedate, $strsubmitted, $strgrade);
53 $types = assignment_types();
55 $modinfo = get_fast_modinfo($course);
56 foreach ($modinfo->instances
['assignment'] as $cm) {
57 if (!$cm->uservisible
) {
61 $assignmenttype = $cms[$cm->id
]->assignmenttype
;
63 //Show dimmed if the mod is hidden
64 $class = $cm->visible ?
'' : 'class="dimmed"';
66 $link = "<a $class href=\"view.php?id=$cm->id\">".format_string($cm->name
)."</a>";
70 if ($cm->sectionnum
!== $currentsection) {
71 if ($cm->sectionnum
) {
72 $printsection = get_section_name($course, $cm->sectionnum
);
74 if ($currentsection !== "") {
75 $table->data
[] = 'hr';
77 $currentsection = $cm->sectionnum
;
81 if (!file_exists($CFG->dirroot
.'/mod/assignment/type/'.$assignmenttype.'/assignment.class.php')) {
85 require_once ($CFG->dirroot
.'/mod/assignment/type/'.$assignmenttype.'/assignment.class.php');
86 $assignmentclass = 'assignment_'.$assignmenttype;
87 $assignmentinstance = new $assignmentclass($cm->id
, NULL, $cm, $course);
89 $submitted = $assignmentinstance->submittedlink(true);
91 $grading_info = grade_get_grades($course->id
, 'mod', 'assignment', $cm->instance
, $USER->id
);
92 if (isset($grading_info->items
[0]) && !$grading_info->items
[0]->grades
[$USER->id
]->hidden
) {
93 $grade = $grading_info->items
[0]->grades
[$USER->id
]->str_grade
;
99 $type = $types[$assignmenttype];
101 // if type has an 'all.php' defined, make this a link
102 $pathtoall = "{$CFG->dirroot}/mod/assignment/type/{$assignmenttype}/all.php";
103 if (file_exists($pathtoall)) {
104 $type = "<a href=\"{$CFG->wwwroot}/mod/assignment/type/{$assignmenttype}/".
105 "all.php?id={$course->id}\">$type</a>";
108 $due = !empty($cms[$cm->id
]->timedue
) ?
userdate($cms[$cm->id
]->timedue
) : '-';
111 $table->data
[] = array ($printsection, $link, $type, $due, $submitted, $grade);
113 $table->data
[] = array ($link, $type, $due, $submitted, $grade);
119 echo html_writer
::table($table);
121 echo $OUTPUT->footer();