From 3b0d5ca3016eacb155d7c18ef97f491cbc473c6a Mon Sep 17 00:00:00 2001 From: thepurpleblob Date: Tue, 13 May 2008 14:46:10 +0000 Subject: [PATCH] MDL-14045: Add ability to list all online assignments in a course. Rather like what Journal used to do. --- mod/assignment/type/online/all.php | 152 +++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 mod/assignment/type/online/all.php diff --git a/mod/assignment/type/online/all.php b/mod/assignment/type/online/all.php new file mode 100644 index 0000000000..1cf0935436 --- /dev/null +++ b/mod/assignment/type/online/all.php @@ -0,0 +1,152 @@ +dirroot}/mod/assignment/lib.php"); + require_once($CFG->libdir.'/gradelib.php'); + require_once('assignment.class.php'); + + // get parameter + $id = required_param('id', PARAM_INT); // course + + if (! $course = get_record("course", "id", $id)) { + error("Course ID is incorrect"); + } + + require_course_login($course); + + // various strings + $str = new stdClass; + $str->assignments = get_string("modulenameplural", "assignment"); + $str->duedate = get_string('duedate','assignment'); + $str->editmysubmission = get_string('editmysubmission','assignment'); + $str->emptysubmission = get_string('emptysubmission','assignment'); + $str->noassignments = get_string('noassignments','assignment'); + $str->onlinetext = get_string('typeonline','assignment'); + $str->submitted = get_string('submitted','assignment'); + $str->topic = get_string('topic'); + $str->week = get_string('week'); + + // build navigation + $navlinks = array(); + $navlinks[] = array('name' => $str->assignments, + 'link' => "$CFG->wwwroot/mod/assignment/index.php?id=$id", 'type' => 'activity'); + $navlinks[] = array('name' => $str->onlinetext, 'link' => '', 'type' => 'activity'); + $navigation = build_navigation($navlinks); + + + // get all the assignments in the course + $assignments = get_all_instances_in_course('assignment',$course, $USER->id ); + + // get correct text for course type + if ($course->format=='weeks') { + $courseformat = $str->week; + } + elseif ($course->format=='topics') { + $courseformat = $str->topic; + } + else { + $courseformat = ''; + } + + // array to hold display data + $views = array(); + + // loop over assignments finding online ones + foreach( $assignments as $assignment ) { + // only interested in online assignments + if ($assignment->assignmenttype != 'online') { + continue; + } + + // create instance of assignment class to get + // submitted assignments + $onlineinstance = new assignment_online( $assignment->coursemodule ); + $submitted = $onlineinstance->submittedlink(true); + $submission = $onlineinstance->get_submission(); + + // submission (if there is one) + if (empty($submission)) { + $submissiontext = $str->emptysubmission; + $submissiondate = "{$str->duedate} ".userdate( $assignment->timedue ); + } + else { + $submissiontext = format_text( $submission->data1, $submission->data2 ); + $submissiondate = "{$str->submitted} ".userdate( $submission->timemodified ); + } + + // edit link + $editlink = "wwwroot}/mod/assignment/view.php?". + "id={$assignment->coursemodule}&edit=1\">{$str->editmysubmission}"; + + // format options for description + $formatoptions = new stdClass; + $formatoptions->noclean = true; + + // object to hold display data for assignment + $view = new stdClass; + + // start to build view object + if (!empty($courseformat)) { + $view->section = "$courseformat {$assignment->section}"; + } + else { + $view->section = ''; + } + + $view->name = $assignment->name; + $view->submitted = $submitted; + $view->description = format_text( $assignment->description, $assignment->format, $formatoptions ); + $view->editlink = $editlink; + $view->submissiontext = $submissiontext; + $view->submissiondate = $submissiondate; + $view->cm = $assignment->coursemodule; + + // get grading information for this assignment + $grading_info = grade_get_grades( $course->id, 'mod', 'assignment', $assignment->id, $USER->id ); + + $views[] = $view; + } + +//=================== +// DISPLAY +//=================== + + print_header_simple($str->assignments, "", $navigation, "", "", true, "", navmenu($course)); + + foreach ($views as $view) { + print_container_start(true,'generalbox'); + + // info bit + print_container_start(true,'generalbox highlight' ); + echo "$view->section - $view->name\n"; + echo "$view->submitted"; + print_container_end(); + + // description part + echo "

$view->description

\n"; + + //submission part + print_container_start(false,'generalbox'); + echo "

$view->submissiondate

\n"; + echo "

$view->submissiontext

\n"; + echo "

$view->editlink

\n"; + print_container_end(); + + // feedback part + $onlineinstance = new assignment_online( $view->cm ); + $onlineinstance->view_feedback(); + + print_container_end(); + } + print_footer($course); +?> -- 2.39.5