]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10364 Added the showcalculations preference and re-factored preferences_form...
authornicolasconnault <nicolasconnault>
Fri, 6 Jul 2007 08:23:17 +0000 (08:23 +0000)
committernicolasconnault <nicolasconnault>
Fri, 6 Jul 2007 08:23:17 +0000 (08:23 +0000)
grade/report/grader/preferences_form.php
grade/report/grader/settings.php
lang/en_utf8/grades.php
lib/grade/grade_tree.php
version.php

index 0274be4f69645649d559e127fd5ed354888f9387..44e56b4e055df5d2aa82ff1dc3d954e2cf20e840 100644 (file)
@@ -20,118 +20,38 @@ class grader_report_preferences_form extends moodleform {
 
 /// form definition with preferences defaults
 //--------------------------------------------------------------------------------
-        $prefs = new stdClass();
-        $prefs->aggregationposition    = get_user_preferences('grade_report_aggregationposition',    $CFG->grade_report_aggregationposition);
-        $prefs->aggregationview        = get_user_preferences('grade_report_aggregationview',        $CFG->grade_report_aggregationview);
-        $prefs->bulkcheckboxes         = get_user_preferences('grade_report_bulkcheckboxes',         $CFG->grade_report_bulkcheckboxes);
-        $prefs->enableajax             = get_user_preferences('grade_report_enableajax',             $CFG->grade_report_enableajax);
-        $prefs->gradedisplaytype       = get_user_preferences('grade_report_gradedisplaytype',       $CFG->grade_report_gradedisplaytype);
-        $prefs->grandtotalsdisplaytype = get_user_preferences('grade_report_grandtotalsdisplaytype', $CFG->grade_report_grandtotalsdisplaytype);
-        $prefs->showeyecons            = get_user_preferences('grade_report_showeyecons',            $CFG->grade_report_showeyecons);
-        $prefs->showgroups             = get_user_preferences('grade_report_showgroups',             $CFG->grade_report_showgroups);
-        $prefs->showlocks              = get_user_preferences('grade_report_showlocks',              $CFG->grade_report_showlocks);
-        $prefs->shownotes              = get_user_preferences('grade_report_shownotes',              $CFG->grade_report_shownotes);
-        $prefs->showscales             = get_user_preferences('grade_report_showscales',             $CFG->grade_report_showscales);
-        $prefs->showgrandtotals        = get_user_preferences('grade_report_showgrandtotals',        $CFG->grade_report_showgrandtotals);
-        $prefs->studentsperpage        = get_user_preferences('grade_report_studentsperpage',        $CFG->grade_report_studentsperpage);
-        $prefs->feedbackformat         = get_user_preferences('grade_report_feedbackformat',         $CFG->grade_report_feedbackformat);
-        $prefs->decimalpoints          = get_user_preferences('grade_report_decimalpoints',          $CFG->grade_report_decimalpoints);
-
-        $mform->addElement('text','grade_report_studentsperpage', get_string('studentsperpage', 'grades'));
-        $mform->setHelpButton('grade_report_studentsperpage', array(false, get_string('studentsperpage', 'grades'), false, true,
-                                                           false, get_string('configstudentsperpage', 'grades')));
-        $mform->setDefault('grade_report_studentsperpage', $prefs->studentsperpage);
-        $mform->setType('grade_report_studentsperpage', PARAM_INT);
-
-        $mform->addElement('select','grade_report_aggregationposition', get_string('aggregationposition', 'grades'),
-                array(get_string('left', 'grades'), get_string('right', 'grades')));
-        $mform->setHelpButton('grade_report_aggregationposition', array(false, get_string('aggregationposition', 'grades'), false, true,
-                                                           false, get_string('configaggregationposition', 'grades')));
-        $mform->setDefault('grade_report_aggregationposition', $prefs->aggregationposition);
-        $mform->setType('grade_report_aggregationposition', PARAM_INT);
-
-        $mform->addElement('select','grade_report_aggregationview', get_string('aggregationview', 'grades'),
-                array(get_string('full', 'grades'), get_string('compact', 'grades')));
-        $mform->setHelpButton('grade_report_aggregationview', array(false, get_string('aggregationview', 'grades'), false, true,
-                                                           false, get_string('configaggregationview', 'grades')));
-        $mform->setDefault('grade_report_aggregationview', $prefs->aggregationview);
-        $mform->setType('grade_report_aggregationview', PARAM_INT);
-
-        $mform->addElement('select','grade_report_gradedisplaytype', get_string('gradedisplaytype', 'grades'),
-                array(get_string('raw', 'grades'), get_string('percentage', 'grades')));
-        $mform->setHelpButton('grade_report_gradedisplaytype', array(false, get_string('gradedisplaytype', 'grades'), false, true,
-                                                           false, get_string('configgradedisplaytype', 'grades')));
-        $mform->setDefault('grade_report_gradedisplaytype', $prefs->gradedisplaytype);
-        $mform->setType('grade_report_gradedisplaytype', PARAM_INT);
-
-        $mform->addElement('select','grade_report_grandtotalsdisplaytype', get_string('grandtotalsdisplaytype', 'grades'), 
-                array(get_string('raw', 'grades'), get_string('percentage', 'grades')));
-        $mform->setHelpButton('grade_report_grandtotalsdisplaytype', array(false, get_string('grandtotalsdisplaytype', 'grades'), false, true,
-                                                           false, get_string('configgrandtotalsdisplaytype', 'grades')));
-        $mform->setDefault('grade_report_grandtotalsdisplaytype', $prefs->grandtotalsdisplaytype);
-        $mform->setType('grade_report_grandtotalsdisplaytype', PARAM_INT);
-
-        $mform->addElement('select','grade_report_feedbackformat', get_string('feedbackformat', 'grades'), 
-                array(get_string('text', 'grades'), get_string('html', 'grades')));
-        $mform->setHelpButton('grade_report_feedbackformat', array(false, get_string('feedbackformat', 'grades'), false, true,
-                                                           false, get_string('configfeedbackformat', 'grades')));
-        $mform->setDefault('grade_report_feedbackformat', $prefs->feedbackformat);
-        $mform->setType('grade_report_feedbackformat', PARAM_INT);
-
-        $mform->addElement('select','grade_report_decimalpoints', get_string('decimalpoints', 'grades'),
-                array(0, 1, 2, 3, 4, 5));
-        $mform->setHelpButton('grade_report_decimalpoints', array(false, get_string('decimalpoints', 'grades'), false, true,
-                                                           false, get_string('configdecimalpoints', 'grades')));
-        $mform->setDefault('grade_report_decimalpoints', $prefs->decimalpoints);
-        $mform->setType('grade_report_decimalpoints', PARAM_INT);
-
-        $mform->addElement('checkbox', 'grade_report_bulkcheckboxes', get_string('bulkcheckboxes', 'grades'));
-        $mform->setHelpButton('grade_report_bulkcheckboxes', array(false, get_string('bulkcheckboxes', 'grades'), false, true,
-                                                           false, get_string('configbulkcheckboxes', 'grades')));
-        $mform->setDefault('grade_report_bulkcheckboxes', $prefs->bulkcheckboxes);
-        $mform->setType('grade_report_bulkcheckboxes', PARAM_INT);
-
-        $mform->addElement('checkbox', 'grade_report_enableajax', get_string('enableajax', 'grades'));
-        $mform->setHelpButton('grade_report_enableajax', array(false, get_string('enableajax', 'grades'), false, true,
-                                                           false, get_string('configenableajax', 'grades')));
-        $mform->setDefault('grade_report_enableajax', $prefs->enableajax);
-        $mform->setType('grade_report_enableajax', PARAM_INT);
-
-        $mform->addElement('checkbox', 'grade_report_showeyecons', get_string('showeyecons', 'grades'));
-        $mform->setHelpButton('grade_report_showeyecons', array(false, get_string('showeyecons', 'grades'), false, true,
-                                                           false, get_string('configshoweyecons', 'grades')));
-        $mform->setDefault('grade_report_showeyecons', $prefs->showeyecons);
-        $mform->setType('grade_report_showeyecons', PARAM_INT);
-
-        $mform->addElement('checkbox', 'grade_report_showgroups', get_string('showgroups', 'grades'));
-        $mform->setHelpButton('grade_report_showgroups', array(false, get_string('showgroups', 'grades'), false, true,
-                                                           false, get_string('configshowgroups', 'grades')));
-        $mform->setDefault('grade_report_showgroups', $prefs->showgroups);
-        $mform->setType('grade_report_showgroups', PARAM_INT);
-
-        $mform->addElement('checkbox', 'grade_report_showlocks', get_string('showlocks', 'grades'));
-        $mform->setHelpButton('grade_report_showlocks', array(false, get_string('showlocks', 'grades'), false, true,
-                                                           false, get_string('configshowlocks', 'grades')));
-        $mform->setDefault('grade_report_showlocks', $prefs->showlocks);
-        $mform->setType('grade_report_showlocks', PARAM_INT);
-
-        $mform->addElement('checkbox', 'grade_report_shownotes', get_string('shownotes', 'grades'));
-        $mform->setHelpButton('grade_report_shownotes', array(false, get_string('shownotes', 'grades'), false, true,
-                                                           false, get_string('configshownotes', 'grades')));
-        $mform->setDefault('grade_report_shownotes', $prefs->shownotes);
-        $mform->setType('grade_report_shownotes', PARAM_INT);
-
-        $mform->addElement('checkbox', 'grade_report_showscales', get_string('showscales', 'grades'));
-        $mform->setHelpButton('grade_report_showscales', array(false, get_string('showscales', 'grades'), false, true,
-                                                           false, get_string('configshowscales', 'grades')));
-        $mform->setDefault('grade_report_showscales', $prefs->showscales);
-        $mform->setType('grade_report_showscales', PARAM_INT); 
-        
-        $mform->addElement('checkbox', 'grade_report_showgrandtotals', get_string('showgrandtotals', 'grades'));
-        $mform->setHelpButton('grade_report_showgrandtotals', array(false, get_string('showgrandtotals', 'grades'), false, true,
-                                                           false, get_string('configshowgrandtotals', 'grades')));
-        $mform->setDefault('grade_report_showgrandtotals', $prefs->showgrandtotals);
-        $mform->setType('grade_report_showgrandtotals', PARAM_INT); 
+        $preferences = array('bulkcheckboxes'         => 'checkbox', 
+                             'enableajax'             => 'checkbox', 
+                             'showcalculations'       => 'checkbox',
+                             'showeyecons'            => 'checkbox', 
+                             'showgrandtotals'        => 'checkbox', 
+                             'showgroups'             => 'checkbox',
+                             'showlocks'              => 'checkbox',
+                             'shownotes'              => 'checkbox',
+                             'showscales'             => 'checkbox', 
+                             'aggregationposition'    => array(get_string('left', 'grades'), get_string('right', 'grades')),
+                             'aggregationview'        => array(get_string('full', 'grades'), get_string('compact', 'grades')),
+                             'gradedisplaytype'       => array(get_string('raw', 'grades'), get_string('percentage', 'grades')),
+                             'grandtotalsdisplaytype' => array(get_string('raw', 'grades'), get_string('percentage', 'grades')),
+                             'feedbackformat'         => array(get_string('text', 'grades'), get_string('html', 'grades')),
+                             'decimalpoints'          => array(0, 1, 2, 3, 4, 5),
+                             'studentsperpage'        => 'text');
+
+        foreach ($preferences as $pref => $type) {
+            $full_pref  = 'grade_report_' . $pref;
+            $pref_value = get_user_preferences($full_pref, $CFG->$full_pref);
+            
+            $options = null;
+            if (is_array($type)) {
+                $options = $type;
+                $type = 'select';
+            }
+
+            $mform->addElement($type, $full_pref, get_string($pref, 'grades'), $options);
+            $mform->setHelpButton($full_pref, array(false, get_string($pref, 'grades'), false, true, false, get_string("config_$pref", 'grades')));
+            $mform->setDefault($full_pref, $pref_value);
+            $mform->setType($full_pref, PARAM_INT);
+        }
         
         $mform->addElement('hidden', 'id');
         $mform->setType('id', PARAM_INT);
index 746735982bd8dfb087ccbd4c53505f6af5198b47..edcf6c1b60705ebfe9f9843e16d5b4ceb6ac8dc1 100644 (file)
@@ -21,6 +21,8 @@ $settings->add(new admin_setting_configselect('grade_report_grandtotalsdisplayty
                                           get_string('configgrandtotalsdisplaytype', 'grades'), false, 
                                           array( '0' => 'raw', 
                                                  '1' => 'percentage')));
+$settings->add(new admin_setting_configcheckbox('grade_report_showcalculations', get_string('showcalculations', 'grades'),
+                                            get_string('configshowcalculations', 'grades'), 0));
 $settings->add(new admin_setting_configcheckbox('grade_report_showeyecons', get_string('showeyecons', 'grades'),
                                             get_string('configshoweyecons', 'grades'), 0));
 $settings->add(new admin_setting_configcheckbox('grade_report_showgroups', get_string('showgroups', 'grades'),
index 73bf82d0bd58ef891267c7f7b49561ec465a91bb..0c1dc822d515f30584597ae7f42480e6bc1f9b76 100644 (file)
@@ -33,6 +33,7 @@ $string['configenableajax'] = 'Adds a layer of AJAX functionality to the grader
 $string['configfeedbackformat'] = 'The format of feedback notes attached to grades. This also determines the interface element used to enter such feedback (htmleditor for HTML format).';
 $string['configgradedisplaytype'] = 'Grades can be shown as raw grades or as percentages (in reference to the minimum and maximum grades).';
 $string['configgrandtotalsdisplaytype'] = 'Grand totals can be shown as raw grades or as percentages (in reference to the minimum and maximum grades).';
+$string['configshowcalculations'] = 'Whether to show calculator icons near each grade item and category, tooltips over calculated items and a visual indicator that a column is calculated.';
 $string['configshoweyecons'] = 'Whether to show an eye-con near each grade (controlling its visibility to the user).';
 $string['configshowgrandtotals'] = 'Show grand totals in the grader report.';
 $string['configshowgroups'] = 'Show group totals and means in the grader report.';
@@ -193,6 +194,7 @@ $string['setting'] = 'Setting';
 $string['settings'] = 'Settings';
 $string['setweights'] = 'Set Weights';
 $string['showallstudents'] = 'Show All Students';
+$string['showcalculations'] = 'Show calculations';
 $string['showeyecons'] = 'Show eye-cons';
 $string['showgrandtotals'] = 'Show grand totals';
 $string['showgroups'] = 'Show groups';
index 859e700ec81fca0199d88156d4c15b79350ff59e..0e344b0f1439670e846b9bafef3a87aa6b5a609b 100644 (file)
@@ -61,11 +61,13 @@ class grade_tree {
      * objects for the given courseid. Full objects are instantiated.
      * and renumbering.
      * @param int $courseid
-     * @param boolean $fillers include fillers and colspans, make the levels var "rectabgular"
+     * @param boolean $fillers include fillers and colspans, make the levels var "rectangular"
      * @param boolean $include_grades
-     * &param boolean $category_grade_last category grade item is the last child
+     * @param boolean $category_grade_last category grade item is the last child
+     * @param boolean $aggregation_view Either full view (0) or compact view (1)
      */
-    function grade_tree($courseid, $fillers=true, $include_grades=false, $category_grade_last=true) {
+    function grade_tree($courseid, $fillers=true, $include_grades=false, $category_grade_last=true, 
+                        $aggregation_view=GRADER_REPORT_AGGREGATION_VIEW_FULL) {
         global $USER;
 
         $this->courseid = $courseid;
@@ -93,6 +95,9 @@ class grade_tree {
 
     /**
      * Static recursive helper - makes the grade_item for category the last children
+     * @static
+     * @param array $element The seed of the recursion
+     * @return void
      */
     function category_grade_last(&$element) {
         if (empty($element['children'])) {
@@ -112,6 +117,11 @@ class grade_tree {
 
     /**
      * Static recursive helper - fills the levels array, useful when accessing tree elements of one level
+     * @static
+     * @param int $levels
+     * @param array $element The seed of the recursion
+     * @param int $depth
+     * @return void
      */
     function fill_levels(&$levels, &$element, $depth) {
         if (!array_key_exists($depth, $levels)) {
index c087f53e4cd0ea050fdaff8009a522116cd3adc0..ffe7f5f7958d638843532c37f79f34f8f4c4cfe6 100644 (file)
@@ -6,7 +6,7 @@
 // This is compared against the values stored in the database to determine
 // whether upgrades should be performed (see lib/db/*.php)
 
-   $version = 2007070600;  // YYYYMMDD = date
+   $version = 2007070601;  // YYYYMMDD = date
                            //       XY = increments within a single day
 
    $release = '1.9 dev';    // Human-friendly version name