]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11667, adding 2 global variables to set default export decimal point and display...
authortoyomoyo <toyomoyo>
Wed, 10 Oct 2007 06:43:23 +0000 (06:43 +0000)
committertoyomoyo <toyomoyo>
Wed, 10 Oct 2007 06:43:23 +0000 (06:43 +0000)
14 files changed:
admin/settings/grades.php
grade/export/grade_export_form.php
grade/export/lib.php
grade/export/ods/export.php
grade/export/ods/index.php
grade/export/txt/export.php
grade/export/txt/grade_export_txt.php
grade/export/txt/index.php
grade/export/xls/export.php
grade/export/xls/index.php
grade/export/xml/export.php
grade/export/xml/grade_export_xml.php
grade/export/xml/index.php
lang/en_utf8/grades.php

index 85558dddf5ea5a14cec67bab3e5ab8b0eb2249cd..69b013add80cda4d69f650eba25db74445f43831 100644 (file)
@@ -7,7 +7,7 @@
 require_once $CFG->libdir.'/grade/constants.php';
 
 $temp = new admin_settingpage('gradessettings', get_string('gradessettings', 'grades'));
-$temp->add(new admin_setting_special_gradeexport());
+
 // enable outcomes checkbox
 $temp->add(new admin_setting_configcheckbox('enableoutcomes', get_string('enableoutcomes', 'grades'), get_string('configenableoutcomes', 'grades'), 0, PARAM_INT));
 // enable publishing in exports/imports
@@ -33,6 +33,22 @@ $temp->add(new admin_setting_configselect('grade_decimalpoints', get_string('dec
                                                  '4' => '4',
                                                  '5' => '5')));
 
+$temp->add(new admin_setting_configselect('grade_export_displaytype', get_string('gradeexportdisplaytype', 'grades'),
+                                          get_string('configgradeexportdisplaytype', 'grades'), GRADE_DISPLAY_TYPE_REAL,
+                                          array(GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
+                                                GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
+                                                GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades'))));
+
+$temp->add(new admin_setting_configselect('grade_export_decimalpoints', get_string('gradeexportdecimalpoints', 'grades'),
+                                          get_string('configexportdecimalpoints', 'grades'), 2,
+                                          array( '0' => '0',
+                                                 '1' => '1',
+                                                 '2' => '2',
+                                                 '3' => '3',
+                                                 '4' => '4',
+                                                 '5' => '5')));                                                 
+                                                 
+$temp->add(new admin_setting_special_gradeexport());
 $ADMIN->add('grades', $temp);
 
 /// Scales and outcomes
index 8ea53cc2c70f7f7f85b2ad2cd87d1dd6d6a0df87..210b695c5f48feca8edd3ebc233baca33c030ded 100755 (executable)
@@ -38,11 +38,6 @@ class grade_export_form extends moodleform {
 
         $mform->addElement('header', 'options', get_string('options', 'grades'));
 
-        $mform->addElement('advcheckbox', 'export_letters', get_string('exportletters', 'grades'));
-        $mform->setDefault('export_letters', 0);
-        $mform->setHelpButton('export_letters', array(false, get_string('exportletters', 'grades'),
-                false, true, false, get_string("exportlettershelp", 'grades')));
-
         $mform->addElement('advcheckbox', 'export_feedback', get_string('exportfeedback', 'grades'));
         $mform->setDefault('export_feedback', 0);
 
@@ -52,7 +47,35 @@ class grade_export_form extends moodleform {
         if (!empty($features['updatedgrades'])) {
             $mform->addElement('advcheckbox', 'updatedgradesonly', get_string('updatedgradesonly', 'grades'));
         }
-    
+        
+        /// selections for decimal points and format, MDL-11667, defaults to site settings, if set
+        //$default_gradedisplaytype = $CFG->grade_export_displaytype;
+        $options = array(GRADE_DISPLAY_TYPE_REAL       => get_string('real', 'grades'),
+                         GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
+                         GRADE_DISPLAY_TYPE_LETTER     => get_string('letter', 'grades'));
+        
+        /*
+        foreach ($options as $key=>$option) {
+            if ($key == $default_gradedisplaytype) {
+                $options[GRADE_DISPLAY_TYPE_DEFAULT] = get_string('defaultprev', 'grades', $option);
+                break;
+            }
+        }
+        */
+        $mform->addElement('select', 'display', get_string('gradeexportdisplaytype', 'grades'), $options);  
+        $mform->setDefault('display', $CFG->grade_export_displaytype);
+        
+        //$default_gradedecimals = $CFG->grade_export_decimalpoints;
+        $options = array(0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5);
+        $mform->addElement('select', 'decimals', get_string('gradeexportdecimalpoints', 'grades'), $options);
+        $mform->setDefault('decimals', $CFG->grade_export_decimalpoints);
+        $mform->disabledIf('decimals', 'display', 'eq', GRADE_DISPLAY_TYPE_LETTER);
+        /*
+        if ($default_gradedisplaytype == GRADE_DISPLAY_TYPE_LETTER) {
+            $mform->disabledIf('decimals', 'display', "eq", GRADE_DISPLAY_TYPE_DEFAULT);
+        }
+        */
+
         if (!empty($features['includeseparator'])) {
             $radio = array();
             $radio[] = &MoodleQuickForm::createElement('radio', 'separator', null, get_string('septab', 'grades'), 'tab');
index 39678febbc09b5d7e6eef2c8dab13efed80408cb..9360820e041400712d71822c74298575fd7ad517 100755 (executable)
@@ -45,6 +45,8 @@ class grade_export {
     var $userkey;         // export using private user key
 
     var $updatedgradesonly; // only export updated grades
+    var $displaytype; // display type (e.g. real, percentages, letter) for exports
+    var $decimalpoints; // number of decimal points for exports
     /**
      * Constructor should set up all the private variables ready to be pulled
      * @param object $course
@@ -54,7 +56,7 @@ class grade_export {
      * @param boolean $export_letters
      * @note Exporting as letters will lead to data loss if that exported set it re-imported.
      */
-    function grade_export($course, $groupid=0, $itemlist='', $export_feedback=false, $export_letters=false, $updatedgradesonly = false) {
+    function grade_export($course, $groupid=0, $itemlist='', $export_feedback=false, $updatedgradesonly = false, $displaytype = GRADE_DISPLAY_TYPE_REAL, $decimalpoints = 2) {
         $this->course = $course;
         $this->groupid = $groupid;
         $this->grade_items = grade_item::fetch_all(array('courseid'=>$this->course->id));
@@ -79,6 +81,9 @@ class grade_export {
         $this->userkey         = '';
         $this->previewrows     = false;
         $this->updatedgradesonly = $updatedgradesonly;
+        
+        $this->displaytype = $displaytype;
+        $this->decimalpoints = $decimalpoints;
     }
 
     /**
@@ -148,14 +153,7 @@ class grade_export {
      * @return string
      */
     function format_grade($grade) {
-        $displaytype = null;
-        if ($this->export_letters) {
-            $displaytype = GRADE_DISPLAY_TYPE_LETTER;
-        } else {
-            $displaytype = GRADE_DISPLAY_TYPE_REAL;
-        }
-
-        return grade_format_gradevalue($grade->finalgrade, $this->grade_items[$grade->itemid], false, $displaytype, null);
+        return grade_format_gradevalue($grade->finalgrade, $this->grade_items[$grade->itemid], false, $this->displaytype, $this->decimalpoints);
     }
 
     /**
@@ -266,7 +264,9 @@ echo "status is $status";
                         'itemids'           =>implode(',', $itemids),
                         'export_letters'    =>$this->export_letters,
                         'export_feedback'   =>$this->export_feedback,
-                        'updatedgradesonly' =>$this->updatedgradesonly);
+                        'updatedgradesonly' =>$this->updatedgradesonly,
+                        'displaytype'       =>$this->displaytype,
+                        'decimalpoints'     =>$this->decimalpoints);
 
         return $params;
     }
index bad4edae2e0b378e24f15d27d02de318318a704a..3b163b78319cf2618b6aadec20d60071a6efe560 100755 (executable)
@@ -27,11 +27,13 @@ require_once '../../../config.php';
 require_once $CFG->dirroot.'/grade/export/lib.php';
 require_once 'grade_export_ods.php';
 
-$id              = required_param('id', PARAM_INT); // course id
-$groupid         = optional_param('groupid', 0, PARAM_INT);
-$itemids         = required_param('itemids', PARAM_RAW);
-$export_feedback = optional_param('export_feedback', 0, PARAM_BOOL);
-$export_letters  = optional_param('export_letters', 0, PARAM_BOOL);
+$id                = required_param('id', PARAM_INT); // course id
+$groupid           = optional_param('groupid', 0, PARAM_INT);
+$itemids           = required_param('itemids', PARAM_RAW);
+$export_feedback   = optional_param('export_feedback', 0, PARAM_BOOL);
+$updatedgradesonly = optional_param('updatedgradesonly', false, PARAM_BOOL);
+$displaytype       = optional_param('displaytype', $CFG->grade_export_displaytype, PARAM_INT);
+$decimalpoints     = optional_param('decimalpoints', $CFG->grade_export_decimalpoints, PARAM_INT);
 
 if (!$course = get_record('course', 'id', $id)) {
     print_error('nocourseid');
@@ -45,7 +47,7 @@ require_capability('gradeexport/ods:view', $context);
 
 
 // print all the exported data here
-$export = new grade_export_ods($course, $groupid, $itemids, $export_feedback, $export_letters);
+$export = new grade_export_ods($course, $groupid, $itemids, $export_feedback, $updatedgradesonly, $displaytype, $decimalpoints);
 $export->print_grades();
 
 ?>
index 36015d13c4e017c89895cdad43a23fb50750190a..51c37a34478615a073fb62bcb1838f15f2e763b8 100755 (executable)
@@ -55,7 +55,7 @@ $mform = new grade_export_form(null, array('publishing' => true));
 
 // process post information
 if ($data = $mform->get_data()) {
-    $export = new grade_export_ods($course, groups_get_course_group($course));
+    $export = new grade_export_ods($course, groups_get_course_group($course), '', false, $data->updatedgradesonly, $data->display, $data->decimals);
 
     // print the grades on screen for feedbacks
     $export->process_form($data);
index 80a5388bf8242db999f201f8243bf5d203a1525b..37b0bebc727b97dd17996890160a1ebdea8a9aab 100755 (executable)
@@ -27,12 +27,14 @@ require_once '../../../config.php';
 require_once $CFG->dirroot.'/grade/export/lib.php';
 require_once 'grade_export_txt.php';
 
-$id              = required_param('id', PARAM_INT); // course id
-$groupid         = optional_param('groupid', 0, PARAM_INT);
-$itemids         = required_param('itemids', PARAM_RAW);
-$export_feedback = optional_param('export_feedback', 0, PARAM_BOOL);
-$export_letters  = optional_param('export_letters', 0, PARAM_BOOL);
-$separator       = optional_param('separator', 'comma', PARAM_ALPHA);
+$id                = required_param('id', PARAM_INT); // course id
+$groupid           = optional_param('groupid', 0, PARAM_INT);
+$itemids           = required_param('itemids', PARAM_RAW);
+$export_feedback   = optional_param('export_feedback', 0, PARAM_BOOL);
+$separator         = optional_param('separator', 'comma', PARAM_ALPHA);
+$updatedgradesonly = optional_param('updatedgradesonly', false, PARAM_BOOL);
+$displaytype       = optional_param('displaytype', $CFG->grade_export_displaytype, PARAM_INT);
+$decimalpoints     = optional_param('decimalpoints', $CFG->grade_export_decimalpoints, PARAM_INT);
 
 if (!$course = get_record('course', 'id', $id)) {
     print_error('nocourseid');
@@ -46,7 +48,7 @@ require_capability('gradeexport/txt:view', $context);
 
 
 // print all the exported data here
-$export = new grade_export_txt($course, $groupid, $itemids, $export_feedback, $export_letters, $separator);
+$export = new grade_export_txt($course, $groupid, $itemids, $export_feedback, $updatedgradesonly, $displaytype, $decimalpoints, $separator);
 $export->print_grades();
 
 ?>
index 033c00b1353a2d125d5f03eaa05f0b533736401e..4e8ca4c6a72c1a605b5f0e46d7140c6e83925c03 100755 (executable)
@@ -30,8 +30,8 @@ class grade_export_txt extends grade_export {
 
     var $separator; // default separator
 
-    function grade_export_txt($course, $groupid=0, $itemlist='', $export_feedback=false, $export_letters=false, $separator='comma') {
-        $this->grade_export($course, $groupid, $itemlist, $export_feedback, $export_letters);
+    function grade_export_txt($course, $groupid=0, $itemlist='', $export_feedback=false, $updatedgradesonly = false, $displaytype = GRADE_DISPLAY_TYPE_REAL, $decimalpoints = 2, $separator='comma') {
+        $this->grade_export($course, $groupid, $itemlist, $export_feedback, $updatedgradesonly, $displaytype, $decimalpoints);
         $this->separator = $separator;
     }
 
index 0f537d8dc82e983eaaaaaea0ae667a1de07a33bb..007c4a530d14dcb70d9915ec68948b1c3d6ef832 100755 (executable)
@@ -55,7 +55,7 @@ $mform = new grade_export_form(null, array('includeseparator'=>true, 'publishing
 
 // process post information
 if ($data = $mform->get_data()) {
-    $export = new grade_export_txt($course, groups_get_course_group($course));
+    $export = new grade_export_txt($course, groups_get_course_group($course), '', false, $data->updatedgradesonly, $data->display, $data->decimals);
 
     // print the grades on screen for feedback
 
index 1fc83506cc71fda425f2459aa36735f923941198..3774fde9355ca10067f9b19ef83028ed6c0daf7d 100755 (executable)
@@ -27,11 +27,13 @@ require_once '../../../config.php';
 require_once $CFG->dirroot.'/grade/export/lib.php';
 require_once 'grade_export_xls.php';
 
-$id              = required_param('id', PARAM_INT); // course id
-$groupid         = optional_param('groupid', 0, PARAM_INT);
-$itemids         = required_param('itemids', PARAM_RAW);
-$export_feedback = optional_param('export_feedback', 0, PARAM_BOOL);
-$export_letters  = optional_param('export_letters', 0, PARAM_BOOL);
+$id                = required_param('id', PARAM_INT); // course id
+$groupid           = optional_param('groupid', 0, PARAM_INT);
+$itemids           = required_param('itemids', PARAM_RAW);
+$export_feedback   = optional_param('export_feedback', 0, PARAM_BOOL);
+$updatedgradesonly = optional_param('updatedgradesonly', false, PARAM_BOOL);
+$displaytype       = optional_param('displaytype', $CFG->grade_export_displaytype, PARAM_INT);
+$decimalpoints     = optional_param('decimalpoints', $CFG->grade_export_decimalpoints, PARAM_INT);
 
 if (!$course = get_record('course', 'id', $id)) {
     print_error('nocourseid');
@@ -45,7 +47,7 @@ require_capability('gradeexport/xls:view', $context);
 
 
 // print all the exported data here
-$export = new grade_export_xls($course, $groupid, $itemids, $export_feedback, $export_letters);
+$export = new grade_export_xls($course, $groupid, $itemids, $export_feedback, $updatedgradesonly, $displaytype, $decimalpoints);
 $export->print_grades();
 
 ?>
index 5c3803d3a9ba67fea3f7f246ecb41308134e1e0e..35f0f865e6995cae20fc270aa148bd680fcf8dac 100755 (executable)
@@ -55,7 +55,7 @@ $mform = new grade_export_form(null, array('publishing' => true));
 
 // process post information
 if ($data = $mform->get_data()) {
-    $export = new grade_export_xls($course, groups_get_course_group($course));
+    $export = new grade_export_xls($course, groups_get_course_group($course), '', false, $data->updatedgradesonly, $data->display, $data->decimals);
 
     // print the grades on screen for feedbacks
     $export->process_form($data);
index a9270efa23337c876efe7a0a298f69d9495c38ed..42a7419dd205cf95ab852a37e83c773ffd27d0cc 100755 (executable)
@@ -27,12 +27,13 @@ require_once '../../../config.php';
 require_once $CFG->dirroot.'/grade/export/lib.php';
 require_once 'grade_export_xml.php';
 
-$id              = required_param('id', PARAM_INT); // course id
-$groupid         = optional_param('groupid', 0, PARAM_INT);
-$itemids         = required_param('itemids', PARAM_RAW);
-$export_feedback = optional_param('export_feedback', 0, PARAM_BOOL);
-$export_letters  = optional_param('export_letters', 0, PARAM_BOOL);
+$id                = required_param('id', PARAM_INT); // course id
+$groupid           = optional_param('groupid', 0, PARAM_INT);
+$itemids           = required_param('itemids', PARAM_RAW);
+$export_feedback   = optional_param('export_feedback', 0, PARAM_BOOL);
 $updatedgradesonly = optional_param('updatedgradesonly', false, PARAM_BOOL);
+$displaytype       = optional_param('displaytype', $CFG->grade_export_displaytype, PARAM_INT);
+$decimalpoints     = optional_param('decimalpoints', $CFG->grade_export_decimalpoints, PARAM_INT);
 
 if (!$course = get_record('course', 'id', $id)) {
     print_error('nocourseid');
@@ -46,7 +47,7 @@ require_capability('gradeexport/xml:view', $context);
 
 
 // print all the exported data here
-$export = new grade_export_xml($course, $groupid, $itemids, $export_feedback, $export_letters, $updatedgradesonly);
+$export = new grade_export_xml($course, $groupid, $itemids, $export_feedback, $updatedgradesonly, $displaytype, $decimalpoints);
 $export->print_grades();
 
 ?>
index aa642f168a3734a7464d7d253ba5b329d5ebc319..d28bc37b4ab05b196d8181b3a0507a4cf1e51983 100755 (executable)
@@ -74,7 +74,7 @@ class grade_export_xml extends grade_export {
             foreach ($userdata->grades as $itemid => $grade) {
                 $grade_item = $this->grade_items[$itemid];
                 $grade->grade_item =& $grade_item;
-                $gradestr = $grade->finalgrade; // no formating for now
+                $gradestr = $this->format_grade($grade); // no formating for now
                 
                 // MDL-11669, skip exported grades or bad grades (if setting says so)
                 if ($export_tracking) {
index dc8d95f2c419107fc30e67c134ae4bc880b2a2e8..ee002b40e798dae0968f555e3524d7c9428b3d67 100755 (executable)
@@ -55,7 +55,8 @@ $mform = new grade_export_form(null, array('idnumberrequired'=>true, 'publishing
 
 // process post information
 if ($data = $mform->get_data()) {
-    $export = new grade_export_xml($course, groups_get_course_group($course), '', false, false, $data->updatedgradesonly);
+    $export = new grade_export_xml($course, groups_get_course_group($course), '', false, $data->updatedgradesonly, $data->display, $data->decimals);
+
     // print the grades on screen for feedbacks
     $export->process_form($data);
     $export->print_continue();
index 025a285577adfe67a48f6542069b3caa5a7d4dc4..42dd9f36f8e9d6e23608022aaa1afcb3cddc5ef5 100644 (file)
@@ -69,6 +69,8 @@ $string['configenableajax'] = 'Adds a layer of AJAX functionality to the grader
 $string['configenableoutcomes'] = 'Support for Outcomes (also known as Competencies, Goals, Standards or Criteria) means that we can grade things using one or more scales that are tied to outcome statements. Enabling outcomes makes such special grading possible throughout the site.';
 $string['configgradeboundary'] = 'A percentage boundary over which grades will be assigned a grade letter (if the Letter grade display type is used). ';
 $string['configgradedisplaytype'] = 'Grades can be shown as real grades, as percentages (in reference to the minimum and maximum grades) or as letters (A, B, C etc..)';
+$string['configgradeexportdisplaytype'] = 'Grades can be shown as real grades, as percentages (in reference to the minimum and maximum grades) or as letters (A, B, C etc..) during export. This can be overriden during export.';
+$string['configexportdecimalpoints'] = 'The number of decimal points to display for export. This can be overriden during export.';
 $string['configgradeletter'] = 'A letter or other symbol used to represent a range of grades.';
 $string['configgradeletterdefault'] = 'A letter or other symbol used to represent a range of grades. Leave this field empty to use the site default (currently $a).';
 $string['configgradepublishing'] = 'Enable publishing in exports and imports: Exported grades can be accessed by accessing a URL, without having to log on to a Moodle site. Grades can be imported by accessing such a URL (which means that a moodle site can import grades published by another site). By default only administrators may use this feature, please educate users before adding required capabilities to other roles (dangers of bookmark sharing and download accelerators, IP restrictions, etc.).';
@@ -136,8 +138,6 @@ $string['excludedhelp'] = 'If -excluded- is switched on, this grade will be excl
 $string['expand'] = 'Expand Category';
 $string['export'] = 'Export';
 $string['exportfeedback'] = 'Include feedback in export';
-$string['exportletters'] = 'Export letter grades as letters';
-$string['exportlettershelp'] = 'For grade items that use grade letters instead of values, the letters will be exported instead of the actual values.';
 $string['exportplugins'] = 'Export plugins';
 $string['extracredit'] = 'Extra Credit';
 $string['extracreditwarning'] = 'Note: Setting all items for a category to extra credit will effectively remove them from the grade calculation. Since there will be no point total';
@@ -169,6 +169,8 @@ $string['gradedisplay'] = 'Grade display';
 $string['gradedisplaytype'] = 'Grade display type';
 $string['gradeexceptions'] = 'Grade Exceptions';
 $string['gradeexceptionshelp'] = 'Grade Exceptions Help';
+$string['gradeexportdisplaytype'] = 'Grade export display type';
+$string['gradeexportdecimalpoints'] = 'Grade export decimal points';
 $string['gradehelp'] = 'Grade Help';
 $string['gradeitem'] = 'Grade item';
 $string['gradeitemislocked'] = 'This activity is locked in the gradebook. Changes that are made to grades in this activity will not be copied to the gradebook until it is unlocked.';