]> git.mjollnir.org Git - moodle.git/commitdiff
adding new global variable to deter which export should write the exported timestamp...
authortoyomoyo <toyomoyo>
Thu, 10 May 2007 08:23:44 +0000 (08:23 +0000)
committertoyomoyo <toyomoyo>
Thu, 10 May 2007 08:23:44 +0000 (08:23 +0000)
admin/settings/courses.php
lib/adminlib.php

index b1b0edcbaf2fd1b8bd501367456ae6052cd12232..7780c3d4b9a3ae6a4696abe9246c4c00648c0ea9 100644 (file)
@@ -47,4 +47,9 @@ $temp->add(new admin_setting_special_backuptime());
 $temp->add(new admin_setting_special_backupsaveto());
 $ADMIN->add('courses', $temp);
 
+// new CFG variable for coursemanager (what roles to display)
+$temp = new admin_settingpage('gradeexport', get_string('gradeexport', 'admin'));
+$temp->add(new admin_setting_special_gradeexport());
+$ADMIN->add('courses', $temp);
+
 ?>
index 4392c8d7850d32ca6d5a1b1573581831b4ca9b22..b8d41fb423a8c23a449d7b871932ded475a1917c 100644 (file)
@@ -2563,6 +2563,84 @@ class admin_setting_special_coursemanager extends admin_setting {
     }
 }
 
+/*
+ * this is used in config->courses->gradeexports
+ * (which roles to show on course decription page)
+ */
+class admin_setting_special_gradeexport extends admin_setting {
+
+    function admin_setting_special_gradeexport() {
+        $name = 'gradeexport';
+        $visiblename = get_string('gradeexport', 'admin');
+        $description = get_string('configgradeexport', 'admin');
+        $default = array(3=>'1');    // The teahcer role in a default install
+        parent::admin_setting($name, $visiblename, $description, $default);
+    }
+
+    function get_setting() {
+
+        global $CFG;
+        if (!empty($CFG->{$this->name})) {
+            $result = explode(',', $CFG->{$this->name});
+            foreach ($result as $plugin) {
+                $array[$plugin] = 1;  
+            }
+            return $array;
+        } else if (isset($CFG->{$this->name})) {
+            return array();
+        } else {
+            return null;
+        }
+    }
+
+    function write_setting($data) {
+
+        if (!empty($data)) {
+            $str = '';
+            foreach ($data as $key => $value) {
+                if ($value) {
+                    $str .= $key.',';
+                }
+            }
+            return set_config($this->name, rtrim($str, ","))?'':get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
+        } else {
+            return set_config($this->name, '')?'':get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
+        }
+    }
+
+    function output_html() {
+
+        if ($this->get_setting() === NULL) {
+            $currentsetting = $this->defaultsetting;
+        } else {
+            $currentsetting = $this->get_setting();
+        }
+        // from to process which roles to display
+        if ($exports = get_list_of_plugins('grade/export')) {
+            $return = '<div class="form-group">';
+            $first = true;
+            foreach ($exports as $export) {
+                if (is_array($currentsetting) && in_array($export, array_keys($currentsetting))) {
+                    $checked = 'checked="checked"';
+                } else {
+                    $checked = '';
+                }
+                if ($first) {
+                    $first = false;
+                } else {
+                    $return .= '<br />';
+                }
+                $return .= '<input type="checkbox" name="s_'.$this->name.'['.$export.']" value="1" '.$checked.' />&nbsp;'.$export;
+            }
+            $return .= '</div>';
+        }
+        return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false);
+    }
+}
+
+
+
+
 class admin_setting_special_perfdebug extends admin_setting_configcheckbox {
 
     function admin_setting_special_perfdebug() {