]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-18910 moving modedit features to modname_supports()
authorskodak <skodak>
Tue, 21 Apr 2009 08:57:20 +0000 (08:57 +0000)
committerskodak <skodak>
Tue, 21 Apr 2009 08:57:20 +0000 (08:57 +0000)
31 files changed:
course/moodleform_mod.php
lib/moodlelib.php
mod/assignment/lib.php
mod/assignment/mod_form.php
mod/chat/lib.php
mod/chat/mod_form.php
mod/choice/lib.php
mod/choice/mod_form.php
mod/data/lib.php
mod/data/mod_form.php
mod/feedback/lib.php
mod/feedback/mod_form.php
mod/forum/lib.php
mod/forum/mod_form.php
mod/glossary/lib.php
mod/glossary/mod_form.php
mod/label/lib.php
mod/label/mod_form.php
mod/lesson/lib.php
mod/lesson/mod_form.php
mod/quiz/lib.php
mod/quiz/mod_form.php
mod/resource/lib.php
mod/resource/mod_form.php
mod/scorm/lib.php
mod/scorm/mod_form.php
mod/survey/lib.php
mod/survey/mod_form.php
mod/upgrade.txt
mod/wiki/lib.php
mod/wiki/mod_form.php

index 3df6d548864cc038546c1a745f92996118a7ee8c..7c275bd23ea106dbcc93034749bbe82348629dd9 100644 (file)
@@ -1,11 +1,8 @@
 <?php  //$Id$
 require_once ($CFG->libdir.'/formslib.php');
-if(!empty($CFG->enablecompletion)) {
+if (!empty($CFG->enablecompletion) or !empty($CFG->enableavailability)) {
     require_once($CFG->libdir.'/completionlib.php');
 }
-if(!empty($CFG->enableavailability)) {
-    require_once($CFG->libdir.'/conditionlib.php');
-}
 
 /**
  * This class adds extra methods to form wrapper specific to be used for module
@@ -20,38 +17,65 @@ class moodleform_mod extends moodleform {
      *
      * @var mixed
      */
-    var $_instance;
+    protected $_instance;
     /**
      * Section of course that module instance will be put in or is in.
      * This is always the section number itself (column 'section' from 'course_sections' table).
      *
      * @var mixed
      */
-    var $_section;
+    protected $_section;
     /**
      * Coursemodle record of the module that is being updated. Will be null if this is an 'add' form and not an
      * update one.
       *
      * @var mixed
      */
-    var $_cm;
+    protected $_cm;
     /**
      * List of modform features
      */
-    var $_features;
-    
+    protected $_features;
     /**
      * @var array Custom completion-rule elements, if enabled
      */
-    var $_customcompletionelements;
+    protected $_customcompletionelements;
+    /**
+     * @var string name of module
+     */
+    protected $_modname;
 
     function moodleform_mod($instance, $section, $cm) {
         $this->_instance = $instance;
         $this->_section = $section;
         $this->_cm = $cm;
+        // Guess module name
+        $matches = array();
+        if (!preg_match('/^mod_([^_]+)_mod_form$/', get_class($this), $matches)) {
+            debugging('Use $modname parameter or rename form to mod_xx_mod_form, where xx is name of your module');
+            print_error('unknownmodulename');
+        }
+        $this->_modname = $matches[1];
+        $this->init_features();
         parent::moodleform('modedit.php');
     }
 
+    protected function init_features() {
+        global $CFG;
+
+        $this->_features = new object();
+        $this->_features->groups            = plugin_supports('mod', $this->_modname, FEATURE_GROUPS, true);
+        $this->_features->groupings         = plugin_supports('mod', $this->_modname, FEATURE_GROUPINGS, false);
+        $this->_features->groupmembersonly  = plugin_supports('mod', $this->_modname, FEATURE_GROUPMEMBERSONLY, false);
+        $this->_features->outcomes          = (!empty($CFG->enableoutcomes) and plugin_supports('mod', $this->_modname, FEATURE_GRADE_OUTCOMES, true));
+        $this->_features->hasgrades         = plugin_supports('mod', $this->_modname, FEATURE_GRADE_HAS_GRADE, false);
+        $this->_features->idnumber          = plugin_supports('mod', $this->_modname, FEATURE_IDNUMBER, true);
+        $this->_features->introeditor       = plugin_supports('mod', $this->_modname, FEATURE_MODEDIT_INTRO_EDITOR, true);
+        $this->_features->defaultcompletion = plugin_supports('mod', $this->_modname, FEATURE_MODEDIT_DEFAULT_COMPLETION, true);
+
+        $this->_features->gradecat          = ($this->_features->outcomes or $this->_features->hasgrades);
+    }
+
     /**
      * Only available on moodleform_mod.
      *
@@ -276,70 +300,13 @@ class moodleform_mod extends moodleform {
 
     /**
      * Adds all the standard elements to a form to edit the settings for an activity module.
-     *
-     * @param mixed $features array or object describing supported features - groups, groupings, groupmembersonly, etc.
-     * @param string $modname Name of module e.g. 'label'
      */
-    function standard_coursemodule_elements($features=null, $modname=null){
+    function standard_coursemodule_elements(){
         global $COURSE, $CFG, $DB;
         $mform =& $this->_form;
 
-        // Guess module name if not supplied
-        if (!$modname) {
-            $matches=array();
-            if (!preg_match('/^mod_([^_]+)_mod_form$/', $this->_formname, $matches)) {
-                debugging('Use $modname parameter or rename form to mod_xx_mod_form, where xx is name of your module');
-                print_error('unknownmodulename');
-            }
-            $modname=$matches[1];
-        }
-
-        // deal with legacy $supportgroups param
-        if ($features === true or $features === false) {
-            $groupmode = $features;
-            $this->_features = new object();
-            $this->_features->groups = $groupmode;
-
-        } else if (is_array($features)) {
-            $this->_features = (object)$features;
-
-        } else if (empty($features)) {
-            $this->_features = new object();
-
-        } else {
-            $this->_features = $features;
-        }
-
-        if (!isset($this->_features->groups)) {
-            $this->_features->groups = true;
-        }
-
-        if (!isset($this->_features->groupings)) {
-            $this->_features->groupings = false;
-        }
-
-        if (!isset($this->_features->groupmembersonly)) {
-            $this->_features->groupmembersonly = false;
-        }
-
-        if (!isset($this->_features->outcomes)) {
-            $this->_features->outcomes = true;
-        }
-
-        if (!isset($this->_features->gradecat)) {
-            $this->_features->gradecat = true;
-        }
-
-        if (!isset($this->_features->idnumber)) {
-            $this->_features->idnumber = true;
-        }
-        
-        if (!isset($this->_features->defaultcompletion)) {
-            $this->_features->defaultcompletion = true;
-        }
-
         $outcomesused = false;
-        if (!empty($CFG->enableoutcomes) and $this->_features->outcomes) {
+        if ($this->_features->outcomes) {
             if ($outcomes = grade_outcome::fetch_all_available($COURSE->id)) {
                 $outcomesused = true;
                 $mform->addElement('header', 'modoutcomes', get_string('outcomes', 'grades'));
@@ -401,9 +368,9 @@ class moodleform_mod extends moodleform {
             $mform->setHelpButton('availableuntil', array('conditiondates', get_string('help_conditiondates', 'condition'), 'condition'));
 
             // Conditions based on grades
-            $gradeoptions=array();
-            $items=grade_item::fetch_all(array('courseid'=>$COURSE->id));
-            $items=$items ? $items : array();
+            $gradeoptions = array();
+            $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
@@ -411,12 +378,12 @@ class moodleform_mod extends moodleform {
                     && $item->itemtype == 'mod') {
                     continue;
                 }
-                $gradeoptions[$id]=$item->get_name();
+                $gradeoptions[$id] = $item->get_name();
             }
             asort($gradeoptions);
-            $gradeoptions=array(0=>get_string('none','condition'))+$gradeoptions;
+            $gradeoptions = array(0=>get_string('none','condition'))+$gradeoptions;
 
-            $grouparray=array();
+            $grouparray = array();
             $grouparray[] =& $mform->createElement('select','conditiongradeitemid','',$gradeoptions);
             $grouparray[] =& $mform->createElement('static', '', '',' '.get_string('grade_atleast','condition').' ');
             $grouparray[] =& $mform->createElement('text', 'conditiongrademin','',array('size'=>3));
@@ -431,22 +398,22 @@ class moodleform_mod extends moodleform {
             // Get version with condition info and store it so we don't ask
             // twice
             if(!empty($this->_cm)) {           
-                $ci = new condition_info($this->_cm,CONDITION_MISSING_EXTRATABLE);
-                $this->_cm=$ci->get_full_course_module();
-                $count=count($this->_cm->conditionsgrade)+1;
+                $ci = new condition_info($this->_cm, CONDITION_MISSING_EXTRATABLE);
+                $this->_cm = $ci->get_full_course_module();
+                $count = count($this->_cm->conditionsgrade)+1;
             } else {
-                $count=1;
+                $count = 1;
             }
 
-            $this->repeat_elements(array($group),$count,array(),'conditiongraderepeats','conditiongradeadds',2,
-                get_string('addgrades','condition'),true);
+            $this->repeat_elements(array($group), $count, array(), 'conditiongraderepeats', 'conditiongradeadds', 2,
+                                   get_string('addgrades', 'condition'), true);
             $mform->setHelpButton('conditiongradegroup[0]', array('gradecondition', get_string('help_gradecondition', 'condition'), 'condition'));
 
             // Conditions based on completion
             $completion = new completion_info($COURSE);
             if ($completion->is_enabled()) {
-                $completionoptions=array();
-                $modinfo=get_fast_modinfo($COURSE);
+                $completionoptions = array();
+                $modinfo = get_fast_modinfo($COURSE);
                 foreach($modinfo->cms as $id=>$cm) {
                     // Add each course-module if it:
                     // (a) has completion turned on
@@ -456,7 +423,7 @@ class moodleform_mod extends moodleform {
                     }
                 }
                 asort($completionoptions);
-                $completionoptions=array(0=>get_string('none','condition'))+$completionoptions;
+                $completionoptions = array(0=>get_string('none','condition'))+$completionoptions;
 
                 $completionvalues=array(
                     COMPLETION_COMPLETE=>get_string('completion_complete','condition'),
@@ -464,13 +431,13 @@ class moodleform_mod extends moodleform {
                     COMPLETION_COMPLETE_PASS=>get_string('completion_pass','condition'),
                     COMPLETION_COMPLETE_FAIL=>get_string('completion_fail','condition'));
 
-                $grouparray=array();        
+                $grouparray = array();        
                 $grouparray[] =& $mform->createElement('select','conditionsourcecmid','',$completionoptions);
                 $grouparray[] =& $mform->createElement('select','conditionrequiredcompletion','',$completionvalues);
                 $group = $mform->createElement('group','conditioncompletiongroup', 
                     get_string('completioncondition', 'condition'),$grouparray);
 
-                $count=empty($this->_cm) ? 1 : count($this->_cm->conditionscompletion)+1;
+                $count = empty($this->_cm) ? 1 : count($this->_cm->conditionscompletion)+1;
                 $this->repeat_elements(array($group),$count,array(),
                     'conditioncompletionrepeats','conditioncompletionadds',2,
                     get_string('addcompletions','condition'),true);
index e46cda2bc4488c2658e3a560e51fd0c440bd0e83..7076044063997d11c51c75e18a16df0b9d731457 100644 (file)
@@ -300,11 +300,27 @@ define ('PASSWORD_NONALPHANUM', '.,;:!?_-+/*@#&$');
 
 /** True if module can provide a grade */
 define('FEATURE_GRADE_HAS_GRADE', 'grade_has_grade');
+/** True if module supports outcomes */
+define('FEATURE_GRADE_OUTCOMES', 'outcomes');
+
 /** True if module has code to track whether somebody viewed it */
 define('FEATURE_COMPLETION_TRACKS_VIEWS', 'completion_tracks_views');
 /** True if module has custom completion rules */
 define('FEATURE_COMPLETION_HAS_RULES', 'completion_has_rules');
 
+/** True if module supports outcomes */
+define('FEATURE_IDNUMBER', 'idnumber');
+/** True if module supports groups */
+define('FEATURE_GROUPS', 'groups');
+/** True if module supports groupings */
+define('FEATURE_GROUPINGS', 'groupings');
+/** True if module supports groupmembersonly */
+define('FEATURE_GROUPMEMBERSONLY', 'groupmembersonly');
+
+/** True if module supports intro editor */
+define('FEATURE_MODEDIT_INTRO_EDITOR', 'modedit_intro_editor');
+/** True if module has default completion */
+define('FEATURE_MODEDIT_DEFAULT_COMPLETION', 'modedit_default_completion');
 
 
 /// PARAMETER HANDLING ////////////////////////////////////////////////////
index 28a143d57c42a0a4c2b36bdd1c6ea3ab2e6f1247..bc9c50191af784c15716717b9d0a8cf54aaf0fbc 100644 (file)
@@ -3238,9 +3238,14 @@ class assignment_portfolio_caller extends portfolio_module_caller_base {
  */
 function assignment_supports($feature) {
     switch($feature) {
+        case FEATURE_GROUPS:                  return true;
+        case FEATURE_GROUPINGS:               return true;
+        case FEATURE_GROUPMEMBERSONLY:        return true;
+        case FEATURE_MODEDIT_INTRO_EDITOR:    return true;
         case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
-        case FEATURE_GRADE_HAS_GRADE: return true;
+        case FEATURE_GRADE_HAS_GRADE:         return true;
+        case FEATURE_GRADE_OUTCOMES:          return true;
+
         default: return null;
     }
 }
-?>
index be17f2b437a67c79e53b54b0e6bafed2b65f630d..7802a6102a73c47bdbdcd1c7ade9d158b1ff7800 100644 (file)
@@ -60,16 +60,10 @@ class mod_assignment_mod_form extends moodleform_mod {
         $mform->addElement('header', 'typedesc', get_string('type'.$type,'assignment'));
         $assignmentinstance->setup_elements($mform);
 
-        $features = new stdClass;
-        $features->groups = true;
-        $features->groupings = true;
-        $features->groupmembersonly = true;
-        $this->standard_coursemodule_elements($features);
+        $this->standard_coursemodule_elements();
 
         $this->add_action_buttons();
     }
 
-
-
 }
-?>
+
index 212e4bc263bf41aa566bc9a2a1d694bc10d20dcb..9dd173dcf4bb7a5017217c9a36f5d423d201238f 100644 (file)
@@ -971,4 +971,21 @@ class chat_portfolio_caller extends portfolio_module_caller_base {
     }
 }
 
-?>
+/**
+ * @param string $feature FEATURE_xx constant for requested feature
+ * @return mixed True if module supports feature, null if doesn't know
+ */
+function chat_supports($feature) {
+    switch($feature) {
+        case FEATURE_GROUPS:                  return true;
+        case FEATURE_GROUPINGS:               return true;
+        case FEATURE_GROUPMEMBERSONLY:        return true;
+        case FEATURE_MODEDIT_INTRO_EDITOR:    return true;
+        case FEATURE_COMPLETION_TRACKS_VIEWS: return false;
+        case FEATURE_GRADE_HAS_GRADE:         return false;
+        case FEATURE_GRADE_OUTCOMES:          return true;
+
+        default: return null;
+    }
+}
+
index a4b2c74eb53274c90ee1ecfaec2d48ea5d45b8c9..add670f8d7ad09b4f9f0f2dc7201898a0c97a431 100644 (file)
@@ -50,11 +50,7 @@ class mod_chat_mod_form extends moodleform_mod {
 
         $mform->addElement('selectyesno', 'studentlogs', get_string('studentseereports', 'chat'));
 
-        $features = new stdClass;
-        $features->groups = true;
-        $features->groupings = true;
-        $features->groupmembersonly = true;
-        $this->standard_coursemodule_elements($features);
+        $this->standard_coursemodule_elements();
 
         $this->add_action_buttons();
     }
index e448bbeb7f6ad787f0f50813602a02d4696f0dc3..3cc1325a6dcc2058d47f784c56afbef42d666d67 100644 (file)
@@ -762,7 +762,14 @@ function choice_get_extra_capabilities() {
  */
 function choice_supports($feature) {
     switch($feature) {
+        case FEATURE_GROUPS:                  return true;
+        case FEATURE_GROUPINGS:               return true;
+        case FEATURE_GROUPMEMBERSONLY:        return true;
+        case FEATURE_MODEDIT_INTRO_EDITOR:    return true;
         case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
+        case FEATURE_GRADE_HAS_GRADE:         return false;
+        case FEATURE_GRADE_OUTCOMES:          return false;
+
         default: return null;
     }
 }
index d54ef3e9b27aa06a7fd20a62af4055d2e74a2ac2..19d455027ba638a2adaa2ec9bb79ee7b7694c76d 100644 (file)
@@ -91,11 +91,6 @@ class mod_choice_mod_form extends moodleform_mod {
 
 
 //-------------------------------------------------------------------------------
-        $features = new stdClass;
-        $features->groups = true;
-        $features->groupings = true;
-        $features->groupmembersonly = true;
-        $features->gradecat = false;
         $this->standard_coursemodule_elements($features);
 //-------------------------------------------------------------------------------
         $this->add_action_buttons();
index a36e251bcc724af7c56318c331ffa290b58c1695..273015f1a13727bcc022c8b76ed6395b01fc4908 100755 (executable)
@@ -2325,10 +2325,16 @@ function data_get_extra_capabilities() {
  */
 function data_supports($feature) {
     switch($feature) {
+        case FEATURE_GROUPS:                  return true;
+        case FEATURE_GROUPINGS:               return true;
+        case FEATURE_GROUPMEMBERSONLY:        return true;
+        case FEATURE_MODEDIT_INTRO_EDITOR:    return true;
         case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
-        case FEATURE_GRADE_HAS_GRADE: return true;
+        case FEATURE_GRADE_HAS_GRADE:         return true;
+        case FEATURE_GRADE_OUTCOMES:          return true;
+
         default: return null;
-    }
+            }
 }
 function data_export_csv($export, $delimiter_name, $dataname, $count, $return=false) {
     global $CFG;
index 8c2017981491ad8f3000b36a78bcb6b518495918..e1c910cddf7033304f9565f2473a794358ef2574 100644 (file)
@@ -62,7 +62,7 @@ class mod_data_mod_form extends moodleform_mod {
         $mform->disabledIf('scale', 'assessed');
 
 
-        $this->standard_coursemodule_elements(array('groups'=>true, 'groupings'=>true, 'groupmembersonly'=>true));
+        $this->standard_coursemodule_elements();
 
 //-------------------------------------------------------------------------------
         // buttons
index 871585429b6230eac0932879415006587d7c8e36..cf56fdceea0c8910f7bebe28436df355fd9a0a6f 100644 (file)
@@ -35,7 +35,14 @@ if(!isset($SESSION->feedback) OR !is_object($SESSION->feedback)) {
  */
 function feedback_supports($feature) {
     switch($feature) {
+        case FEATURE_GROUPS:                  return true;
+        case FEATURE_GROUPINGS:               return true;
+        case FEATURE_GROUPMEMBERSONLY:        return true;
+        case FEATURE_MODEDIT_INTRO_EDITOR:    return true;
         case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
+        case FEATURE_GRADE_HAS_GRADE:         return false;
+        case FEATURE_GRADE_OUTCOMES:          return false;
+
         default: return null;
     }
 }
index 1365def081d341273ba5565cde4107fc3e5f82a1..10f955534debe2c90fd338ae35162e5e5ead771f 100644 (file)
@@ -85,13 +85,7 @@ class mod_feedback_mod_form extends moodleform_mod {
         $mform->addElement('htmleditor', 'page_after_submit', get_string("page_after_submit", "feedback"), array('rows' => 20));
         $mform->setType('page_after_submit', PARAM_RAW);
         //-------------------------------------------------------------------------------
-        $features = new stdClass;
-        $features->groups = true;
-        $features->groupings = true;
-        $features->groupmembersonly = true;
-        $features->gradecat = false;
-        $features->idnumber = false;
-        $this->standard_coursemodule_elements($features);
+        $this->standard_coursemodule_elements();
         //-------------------------------------------------------------------------------
         // buttons
         $this->add_action_buttons();
index c76ce612745fb1ba75d6cff5a59ee7fc8d768956..04fadf769cab0ef2d724bf84745b9bfe5b6caeae 100644 (file)
@@ -237,8 +237,15 @@ function forum_delete_instance($id) {
  */
 function forum_supports($feature) {
     switch($feature) {
+        case FEATURE_GROUPS:                  return true;
+        case FEATURE_GROUPINGS:               return true;
+        case FEATURE_GROUPMEMBERSONLY:        return true;
+        case FEATURE_MODEDIT_INTRO_EDITOR:    return true;
         case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
-        case FEATURE_COMPLETION_HAS_RULES: return true;
+        case FEATURE_COMPLETION_HAS_RULES:    return true;
+        case FEATURE_GRADE_HAS_GRADE:         return true;
+        case FEATURE_GRADE_OUTCOMES:          return true;
+
         default: return null;
     }
 }
index 3e16366f6aae25d10c8368c66c8ca065e03b88af..b2d049bc5f0bf361270deb782220ee10c3772d4f 100644 (file)
@@ -141,11 +141,7 @@ class mod_forum_mod_form extends moodleform_mod {
         $mform->disabledIf('warnafter', 'blockperiod', 'eq', 0);
 
 //-------------------------------------------------------------------------------
-        $features = new stdClass;
-        $features->groups = true;
-        $features->groupings = true;
-        $features->groupmembersonly = true;
-        $this->standard_coursemodule_elements($features);
+        $this->standard_coursemodule_elements();
 //-------------------------------------------------------------------------------
 // buttons
         $this->add_action_buttons();
index 3b69bd68bed47e75cff5c28cfdc88f34b2e9961f..da878e71e47e72f93a95d70dadcdc27b374ff153 100644 (file)
@@ -2274,8 +2274,14 @@ function glossary_get_extra_capabilities() {
  */
 function glossary_supports($feature) {
     switch($feature) {
+        case FEATURE_GROUPS:                  return false;
+        case FEATURE_GROUPINGS:               return false;
+        case FEATURE_GROUPMEMBERSONLY:        return true;
+        case FEATURE_MODEDIT_INTRO_EDITOR:    return true;
         case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
-        case FEATURE_GRADE_HAS_GRADE: return true;
+        case FEATURE_GRADE_HAS_GRADE:         return true;
+        case FEATURE_GRADE_OUTCOMES:          return true;
+
         default: return null;
     }
 }
index 5c6509264a4bbac2d11c111092a9d114fbfae184..cba8c0102d19d3248851620753ebc71a5ee65a94 100644 (file)
@@ -147,7 +147,7 @@ class mod_glossary_mod_form extends moodleform_mod {
         $mform->disabledIf('assesstimefinish', 'ratingtime');
 
 //-------------------------------------------------------------------------------
-        $this->standard_coursemodule_elements(array('groups'=>false, 'groupmembersonly'=>true));
+        $this->standard_coursemodule_elements();
 
 //-------------------------------------------------------------------------------
         // buttons
index d6a89e0e98325a6926d2cc1bf3f59584c9f6468a..a8a2e2e8de3b0647485a54875da094ab48edb381 100644 (file)
@@ -135,4 +135,23 @@ function lable_get_extra_capabilities() {
     return array('moodle/site:accessallgroups');
 }
 
+/**
+ * @param string $feature FEATURE_xx constant for requested feature
+ * @return mixed True if module supports feature, null if doesn't know
+ */
+function label_supports($feature) {
+    switch($feature) {
+        case FEATURE_IDNUMBER:                return false;
+        case FEATURE_GROUPS:                  return false;
+        case FEATURE_GROUPINGS:               return false;
+        case FEATURE_GROUPMEMBERSONLY:        return true;
+        case FEATURE_MODEDIT_INTRO_EDITOR:    return false;
+        case FEATURE_COMPLETION_TRACKS_VIEWS: return false;
+        case FEATURE_GRADE_HAS_GRADE:         return false;
+        case FEATURE_GRADE_OUTCOMES:          return false;
+
+        default: return null;
+    }
+}
+
 ?>
index a32cc1b7e9047b8355f577aa86db8a5596e7a18d..c8611cf64dacb765441f330b576e6ca3af1a5ba1 100644 (file)
@@ -12,9 +12,7 @@ class mod_label_mod_form extends moodleform_mod {
         $mform->addRule('content', get_string('required'), 'required', null, 'client');
         $mform->setHelpButton('content', array('questions', 'richtext2'), false, 'editorhelpbutton');
 
-        $features = array('groups'=>false, 'groupings'=>false, 'groupmembersonly'=>true,
-                          'outcomes'=>false, 'gradecat'=>false, 'idnumber'=>false);
-        $this->standard_coursemodule_elements($features);
+        $this->standard_coursemodule_elements();
 
 //-------------------------------------------------------------------------------
 // buttons
index 4b216b6d17488e0b661e38ab2147d0d12fbc29f1..e3893b79ba9a2707b72e6d470c3c42a51aec6ebc 100644 (file)
@@ -717,8 +717,14 @@ function lesson_get_extra_capabilities() {
  */
 function lesson_supports($feature) {
     switch($feature) {
+        case FEATURE_GROUPS:                  return false;
+        case FEATURE_GROUPINGS:               return false;
+        case FEATURE_GROUPMEMBERSONLY:        return true;
+        case FEATURE_MODEDIT_INTRO_EDITOR:    return true;
         case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
-        case FEATURE_GRADE_HAS_GRADE: return true;
+        case FEATURE_GRADE_HAS_GRADE:         return true;
+        case FEATURE_GRADE_OUTCOMES:          return true;
+
         default: return null;
     }
 }
index bf03b0c557ecbc972e537cdb9f52938f7a0a1a23..5da6c9768bf810b83121222331739425521f3f07 100644 (file)
@@ -281,11 +281,7 @@ class mod_lesson_mod_form extends moodleform_mod {
         $mform->setDefault('lessondefault', 0);
 
 //-------------------------------------------------------------------------------
-        $features = new stdClass;
-        $features->groups = false;
-        $features->groupings = true;
-        $features->groupmembersonly = true;
-        $this->standard_coursemodule_elements($features);
+        $this->standard_coursemodule_elements();
 //-------------------------------------------------------------------------------
 // buttons
         $this->add_action_buttons();
index ba52e77b76b99607a128d89410d5cc7487afe0e9..e03fbb62c593efae1f0249399c80ee2f717bd311 100644 (file)
@@ -1252,8 +1252,14 @@ function quiz_num_attempt_summary($quiz, $cm, $returnzero = false, $currentgroup
  */
 function quiz_supports($feature) {
     switch($feature) {
-        case FEATURE_GRADE_HAS_GRADE: return true;
+        case FEATURE_GROUPS:                  return true;
+        case FEATURE_GROUPINGS:               return true;
+        case FEATURE_GROUPMEMBERSONLY:        return true;
+        case FEATURE_MODEDIT_INTRO_EDITOR:    return true;
         case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
+        case FEATURE_GRADE_HAS_GRADE:         return true;
+        case FEATURE_GRADE_OUTCOMES:          return true;
+
         default: return null;
     }
 }
index 7d30863c4e77da08d658f71bc5348fb500ea0dd8..3b8f638b4981ff364b8393ab88e8ed6051ab6e1b 100644 (file)
@@ -317,11 +317,7 @@ class mod_quiz_mod_form extends moodleform_mod {
         }
 
 //-------------------------------------------------------------------------------
-        $features = new stdClass;
-        $features->groups = true;
-        $features->groupings = true;
-        $features->groupmembersonly = true;
-        $this->standard_coursemodule_elements($features);
+        $this->standard_coursemodule_elements();
 
 //-------------------------------------------------------------------------------
         // buttons
index 17e5d510d2693fd0f9e4d4dfb258e88e1b220f67..45e5bc8ca6dfb426cffc56ec8d8fb5abfecf0c87 100644 (file)
@@ -761,7 +761,14 @@ class resource_portfolio_caller extends portfolio_module_caller_base {
  */
 function resource_supports($feature) {
     switch($feature) {
+        case FEATURE_GROUPS:                  return false;
+        case FEATURE_GROUPINGS:               return false;
+        case FEATURE_GROUPMEMBERSONLY:        return true;
+        case FEATURE_MODEDIT_INTRO_EDITOR:    return true;
         case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
+        case FEATURE_GRADE_HAS_GRADE:         return false;
+        case FEATURE_GRADE_OUTCOMES:          return false;
+
         default: return null;
     }
 }
index 5078e7cf0a026b42a087da39bf6b1d67553c9f8d..243ee602d954bf793ef19abf7d2470768749b171 100644 (file)
@@ -47,7 +47,7 @@ class mod_resource_mod_form extends moodleform_mod {
         $mform->addElement('header', 'typedesc', resource_get_name($type));
         $this->_resinstance->setup_elements($mform);
 
-        $this->standard_coursemodule_elements(array('groups'=>false, 'groupmembersonly'=>true, 'gradecat'=>false));
+        $this->standard_coursemodule_elements();
 
         $this->add_action_buttons();
     }
index 04bd1f38691bc3c3553a5e4933e9e0d7d94291f8..cfcf39a5a672ece2d63573c8fe83bc5f43b7baea 100755 (executable)
@@ -811,4 +811,21 @@ function scorm_pluginfile($course, $cminfo, $context, $filearea, $args) {
     send_stored_file($file, $lifetime, 0, false);
 }
 
-?>
+/**
+ * @param string $feature FEATURE_xx constant for requested feature
+ * @return mixed True if module supports feature, null if doesn't know
+ */
+function scorm_supports($feature) {
+    switch($feature) {
+        case FEATURE_GROUPS:                  return false;
+        case FEATURE_GROUPINGS:               return false;
+        case FEATURE_GROUPMEMBERSONLY:        return true;
+        case FEATURE_MODEDIT_INTRO_EDITOR:    return true;
+        case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
+        case FEATURE_GRADE_HAS_GRADE:         return true;
+        case FEATURE_GRADE_OUTCOMES:          return true;
+
+        default: return null;
+    }
+}
+
index 33a0f097f887797ac7e82853080759adb67be3d3..5bb3a6cb0922a071c726929d16964bec4caba74e 100644 (file)
@@ -231,11 +231,7 @@ class mod_scorm_mod_form extends moodleform_mod {
 
 
 //-------------------------------------------------------------------------------
-        $features = new stdClass;
-        $features->groups = false;
-        $features->groupings = true;
-        $features->groupmembersonly = true;
-        $this->standard_coursemodule_elements($features);
+        $this->standard_coursemodule_elements();
 //-------------------------------------------------------------------------------
         // buttons
         $this->add_action_buttons();
index a3143dc22e47e7e18c4262ddff001b2a694df935..f181b853f781db2e1305219f82e87cf8bf53a1ab 100644 (file)
@@ -588,4 +588,20 @@ function survey_get_extra_capabilities() {
     return array('moodle/site:accessallgroups');
 }
 
-?>
+/**
+ * @param string $feature FEATURE_xx constant for requested feature
+ * @return mixed True if module supports feature, null if doesn't know
+ */
+function survey_supports($feature) {
+    switch($feature) {
+        case FEATURE_GROUPS:                  return true;
+        case FEATURE_GROUPINGS:               return true;
+        case FEATURE_GROUPMEMBERSONLY:        return true;
+        case FEATURE_MODEDIT_INTRO_EDITOR:    return true;
+        case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
+        case FEATURE_GRADE_HAS_GRADE:         return true;
+        case FEATURE_GRADE_OUTCOMES:          return true;
+
+        default: return null;
+    }
+}
\ No newline at end of file
index b655044a4ccd655a98868bf34da4e07d8415382c..68fe5e0a8051c92276d7bb338937d9b0f3274bed 100644 (file)
@@ -37,11 +37,7 @@ class mod_survey_mod_form extends moodleform_mod {
         $mform->addElement('textarea', 'intro', get_string('customintro', 'survey'), 'wrap="virtual" rows="20" cols="75"');
         $mform->setType('intro', PARAM_RAW);
 
-        $features = new stdClass;
-        $features->groups = true;
-        $features->groupings = true;
-        $features->groupmembersonly = true;
-        $this->standard_coursemodule_elements($features);
+        $this->standard_coursemodule_elements();
 
 //-------------------------------------------------------------------------------
         // buttons
index 3e24896840bdaa4e5d7a3cf7072232878dd89ffa..83330a99a9201a360da0d3174785393cdda314c8 100644 (file)
@@ -12,11 +12,11 @@ required changes in code:
 * completely rewrite file handling
 * rewrite backup/restore
 * rewrite trusstext support - new db table columns needed
+* migrade all module features from mod_edit.php form to lib.php/modulename_supports() function
 
 optional - no changes needed in older code:
 * portfolio support
 * course completion tracking support
-* lib.php/xxx_supports() may describe module features and capabilities
 
 
 
index 5b6fbe653a54cb28a41b961d885e07f1999b791a..3f75c579cf8dbe2df2183c73d76052f2e8b7bbac 100644 (file)
@@ -1768,4 +1768,20 @@ function wiki_get_extra_capabilities() {
     return array('moodle/site:accessallgroups', 'moodle/site:viewfullnames');
 }
 
-?>
+/**
+ * @param string $feature FEATURE_xx constant for requested feature
+ * @return mixed True if module supports feature, null if doesn't know
+ */
+function wiki_supports($feature) {
+    switch($feature) {
+        case FEATURE_GROUPS:                  return true;
+        case FEATURE_GROUPINGS:               return true;
+        case FEATURE_GROUPMEMBERSONLY:        return true;
+        case FEATURE_MODEDIT_INTRO_EDITOR:    return true;
+        case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
+        case FEATURE_GRADE_HAS_GRADE:         return false;
+        case FEATURE_GRADE_OUTCOMES:          return true;
+
+        default: return null;
+    }
+}
\ No newline at end of file
index 7a2115121171dd06a4cebea0bdff104362518f0c..d288f2b258f22a0bd60b0351fbb2d51ec9dd788e 100644 (file)
@@ -83,11 +83,7 @@ class mod_wiki_mod_form extends moodleform_mod {
         $mform->setAdvanced('initialcontent');
 
 //-------------------------------------------------------------------------------
-        $features = new stdClass;
-        $features->groups = true;
-        $features->groupings = true;
-        $features->groupmembersonly = true;
-        $this->standard_coursemodule_elements($features);
+        $this->standard_coursemodule_elements();
 //-------------------------------------------------------------------------------
 // buttons
         $this->add_action_buttons();