Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Adding 'get_coursemodule_info' to the standard available functions fo…

…r assignment types. As a minimum, this allows assignment types to add their own icon (like resource does).
  • Loading branch information...
commit 9a1dd76cfa2bdf4f82c173398bfc60f532427d0f 1 parent 488fec2
authored July 19, 2007

Showing 1 changed file with 34 additions and 0 deletions. Show diff stats Hide diff stats

  1. 34  mod/assignment/lib.php
34  mod/assignment/lib.php
@@ -1646,6 +1646,21 @@ function custom_feedbackform($submission, $return=false) {
1646 1646
         return '';
1647 1647
     }
1648 1648
 
  1649
+    /**
  1650
+     * Add a get_coursemodule_info function in case any assignment type wants to add 'extra' information
  1651
+     * for the course (see resource).
  1652
+     *
  1653
+     * Given a course_module object, this function returns any "extra" information that may be needed 
  1654
+     * when printing this activity in a course listing.  See get_array_of_activities() in course/lib.php.
  1655
+     * 
  1656
+     * @param $coursemodule object The coursemodule object (record).
  1657
+     * @return object An object on information that the coures will know about (most noticeably, an icon).
  1658
+     * 
  1659
+     */
  1660
+    function get_coursemodule_info($coursemodule) {
  1661
+        return false;
  1662
+    }
  1663
+
1649 1664
 } ////// End of the assignment_base class
1650 1665
 
1651 1666
 
@@ -2291,6 +2306,25 @@ function assignment_get_all_submissions($assignment, $sort="", $dir="DESC") {
2291 2306
     */
2292 2307
 }
2293 2308
 
  2309
+/// Given a course_module object, this function returns any
  2310
+/// "extra" information that may be needed when printing
  2311
+/// this activity in a course listing.
  2312
+///
  2313
+/// See get_array_of_activities() in course/lib.php
  2314
+///
  2315
+function assignment_get_coursemodule_info($coursemodule) {
  2316
+    global $CFG;
  2317
+
  2318
+    if (! $assignment = get_record('assignment', 'id', $coursemodule->instance)) {
  2319
+        return false;
  2320
+    }
  2321
+
  2322
+    require_once("$CFG->dirroot/mod/assignment/type/$assignment->assignmenttype/assignment.class.php");
  2323
+    $assignmentclass = "assignment_$assignment->assignmenttype";
  2324
+    $ass = new $assignmentclass($coursemodule->id, $assignment);
  2325
+
  2326
+    return $ass->get_coursemodule_info($coursemodule);
  2327
+}
2294 2328
 
2295 2329
 
2296 2330
 

0 notes on commit 9a1dd76

Please sign in to comment.
Something went wrong with that request. Please try again.