]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17810: Fix to stop you making activities depend on themselves
authorsam_marshall <sam_marshall>
Thu, 2 Apr 2009 12:00:09 +0000 (12:00 +0000)
committersam_marshall <sam_marshall>
Thu, 2 Apr 2009 12:00:09 +0000 (12:00 +0000)
course/moodleform_mod.php

index 74ece3fc97361e38338a7948f6e1964296f54c6d..3df6d548864cc038546c1a745f92996118a7ee8c 100644 (file)
@@ -405,6 +405,12 @@ class moodleform_mod extends moodleform {
             $items=grade_item::fetch_all(array('courseid'=>$COURSE->id));
             $items=$items ? $items : array();
             foreach($items as $id=>$item) {
+                // Do not include grades for current item
+                if (!empty($this->_cm) && $this->_cm->instance == $item->iteminstance
+                    && $this->_cm->modname == $item->itemmodule
+                    && $item->itemtype == 'mod') {
+                    continue;
+                }
                 $gradeoptions[$id]=$item->get_name();
             }
             asort($gradeoptions);
@@ -442,7 +448,10 @@ class moodleform_mod extends moodleform {
                 $completionoptions=array();
                 $modinfo=get_fast_modinfo($COURSE);
                 foreach($modinfo->cms as $id=>$cm) {
-                    if($cm->completion) {
+                    // Add each course-module if it:
+                    // (a) has completion turned on
+                    // (b) is not the same as current course-module
+                    if ($cm->completion && (empty($this->_cm) || $this->_cm->id != $id)) {
                         $completionoptions[$id]=$cm->name;
                     }
                 }