]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-13274, MDL-13215 - improved modedit shared forms, label supports groupmembersonly...
authorskodak <skodak>
Thu, 21 Feb 2008 14:12:48 +0000 (14:12 +0000)
committerskodak <skodak>
Thu, 21 Feb 2008 14:12:48 +0000 (14:12 +0000)
course/moodleform_mod.php
mod/label/mod_form.php

index 62760e616b8c7164cc790445625b38d241d4ca46..1947afc2b03184451e8a5e4795879a6187d5c427 100644 (file)
@@ -171,7 +171,7 @@ class moodleform_mod extends moodleform {
     /**
      * Adds all the standard elements to a form to edit the settings for an activity module.
      *
-     * @param mixed array or object describing supported features - groups, groupings, groupmembersonly
+     * @param mixed array or object describing supported features - groups, groupings, groupmembersonly, etc.
      */
     function standard_coursemodule_elements($features=null){
         global $COURSE, $CFG;
@@ -213,10 +213,14 @@ class moodleform_mod extends moodleform {
             $this->_features->gradecat = true;
         }
 
-        $outcomesused = false; 
+        if (!isset($this->_features->idnumber)) {
+            $this->_features->idnumber = true;
+        }
+
+        $outcomesused = false;
         if (!empty($CFG->enableoutcomes) and $this->_features->outcomes) {
             if ($outcomes = grade_outcome::fetch_all_available($COURSE->id)) {
-                $outcomesused = true; 
+                $outcomesused = true;
                 $mform->addElement('header', 'modoutcomes', get_string('outcomes', 'grades'));
                 foreach($outcomes as $outcome) {
                     $mform->addElement('advcheckbox', 'outcome_'.$outcome->id, $outcome->get_name());
@@ -254,8 +258,11 @@ class moodleform_mod extends moodleform {
         }
 
         $mform->addElement('modvisible', 'visible', get_string('visible'));
-        $mform->addElement('text', 'cmidnumber', get_string('idnumbermod'));
-        $mform->setHelpButton('cmidnumber', array('cmidnumber', get_string('idnumbermod')), true);
+
+        if ($this->_features->idnumber) {
+            $mform->addElement('text', 'cmidnumber', get_string('idnumbermod'));
+            $mform->setHelpButton('cmidnumber', array('cmidnumber', get_string('idnumbermod')), true);
+        }
 
         if ($this->_features->gradecat) {
             $categories = grade_get_categories_menu($COURSE->id, $outcomesused);
@@ -297,28 +304,34 @@ class moodleform_mod extends moodleform {
 
     /**
      * Overriding formslib's add_action_buttons() method, to add an extra submit "save changes and return" button.
-     * 
-     * @param bool $cancel
-     * @param string $submitlabel
-     * @param string $submit2label
+     *
+     * @param bool $cancel show cancel button
+     * @param string $submitlabel null means default, false means none, string is label text
+     * @param string $submit2label  null means default, false means none, string is label text
      * @return void
-     */ 
+     */
     function add_action_buttons($cancel=true, $submitlabel=null, $submit2label=null) {
         if (is_null($submitlabel)) {
             $submitlabel = get_string('savechangesanddisplay');
         }
-        
+
         if (is_null($submit2label)) {
             $submit2label = get_string('savechangesandreturntocourse');
         }
-        
+
         $mform =& $this->_form;
-        
-        //when two elements we need a group
-        $buttonarray=array();
-        $buttonarray[] = &$mform->createElement('submit', 'submitbutton2', $submit2label);
-        $buttonarray[] = &$mform->createElement('submit', 'submitbutton', $submitlabel);
-        
+
+        // elements in a row need a group
+        $buttonarray = array();
+
+        if ($submit2label !== false) {
+            $buttonarray[] = &$mform->createElement('submit', 'submitbutton2', $submit2label);
+        }
+
+        if ($submitlabel !== false) {
+            $buttonarray[] = &$mform->createElement('submit', 'submitbutton', $submitlabel);
+        }
+
         if ($cancel) {
             $buttonarray[] = &$mform->createElement('cancel');
         }
index 113811686a342e7a9e6ca2529374dd3ee9dfd343..12f4cc6b5648d48e6ae679b957f1a2e4b50d9827 100644 (file)
@@ -12,13 +12,13 @@ class mod_label_mod_form extends moodleform_mod {
         $mform->addRule('content', get_string('required'), 'required', null, 'client');
         $mform->setHelpButton('content', array('questions', 'richtext'), false, 'editorhelpbutton');
 
-        $this->standard_hidden_coursemodule_elements();
-
-        $mform->addElement('modvisible', 'visible', get_string('visible'));
+        $features = array('groups'=>false, 'groupings'=>false, 'groupmembersonly'=>true,
+                          'outcomes'=>false, 'gradecat'=>false, 'idnumber'=>false);
+        $this->standard_coursemodule_elements($features);
 
 //-------------------------------------------------------------------------------
 // buttons
-        $this->add_action_buttons();
+        $this->add_action_buttons(true, false, null);
 
     }