]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14045:
authorthepurpleblob <thepurpleblob>
Tue, 13 May 2008 14:46:10 +0000 (14:46 +0000)
committerthepurpleblob <thepurpleblob>
Tue, 13 May 2008 14:46:10 +0000 (14:46 +0000)
Add ability to list all online assignments in a course.
Rather like what Journal used to do.

mod/assignment/type/online/all.php [new file with mode: 0644]

diff --git a/mod/assignment/type/online/all.php b/mod/assignment/type/online/all.php
new file mode 100644 (file)
index 0000000..1cf0935
--- /dev/null
@@ -0,0 +1,152 @@
+<?php // $Id$
+
+//===================================================
+// all.php
+//
+// Displays a complete list of online assignments
+// for the course. Rather like what happened in 
+// the old Journal activity.
+// Howard Miller 2008
+// See MDL-14045
+//===================================================
+
+    require_once("../../../../config.php");
+    require_once("{$CFG->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 = "<a href=\"{$CFG->wwwroot}/mod/assignment/view.php?".
+            "id={$assignment->coursemodule}&amp;edit=1\">{$str->editmysubmission}</a>";
+
+        // 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 "<strong>$view->section - $view->name</strong>\n";
+        echo "$view->submitted";
+        print_container_end();
+
+        // description part
+        echo "<p>$view->description</p>\n";
+       
+        //submission part
+        print_container_start(false,'generalbox');
+        echo "<p><strong>$view->submissiondate</strong></p>\n";
+        echo "<p>$view->submissiontext</p>\n";
+        echo "<p>$view->editlink</p>\n";
+        print_container_end();
+
+        // feedback part
+        $onlineinstance = new assignment_online( $view->cm );
+        $onlineinstance->view_feedback();
+
+        print_container_end();
+    }
+    print_footer($course);
+?>