]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10210 Added the grader report admin settings, and its corresponding language...
authornicolasconnault <nicolasconnault>
Wed, 4 Jul 2007 10:01:20 +0000 (10:01 +0000)
committernicolasconnault <nicolasconnault>
Wed, 4 Jul 2007 10:01:20 +0000 (10:01 +0000)
grade/report.php
grade/report/grader/edit_feedback.php [new file with mode: 0644]
grade/report/grader/edit_feedback_form.php [new file with mode: 0644]
grade/report/grader/index.php
grade/report/grader/settings.php
lang/en_utf8/grades.php
lib/weblib.php

index a9a7a9b54218e86d517f5ad9907ebb6f26e2b2f1..35bded205656b2185d6f24dcff96d406f66bc37e 100644 (file)
@@ -25,7 +25,7 @@
 
     require_once("../config.php");
     require_once("../lib/gradelib.php");
-grade_grab_grades();
+    
     $courseid = required_param('id');              // course id
     $report   = optional_param('report', 'user', PARAM_FILE);              // course id
     $edit     = optional_param('edit', -1, PARAM_BOOL); // sticky editting mode
diff --git a/grade/report/grader/edit_feedback.php b/grade/report/grader/edit_feedback.php
new file mode 100644 (file)
index 0000000..f8a4e66
--- /dev/null
@@ -0,0 +1,91 @@
+<?php  //$Id$
+
+require_once '../../../config.php';
+require_once $CFG->libdir.'/gradelib.php';
+require_once 'edit_feedback_form.php';
+
+$courseid = required_param('courseid', PARAM_INT);
+$id       = optional_param('id', 0, PARAM_INT);
+
+if (!$course = get_record('course', 'id', $courseid)) {
+    print_error('nocourseid');
+}
+
+require_login($course);
+
+$context = get_context_instance(CONTEXT_COURSE, $course->id);
+//require_capability() here!!
+
+// default return url
+$returnurl = 'index.php?id='.$course->id;
+
+
+$mform = new edit_feedback_form();
+if ($grade_text = get_record('grade_grades_text', 'gradeid', $id)) {
+    $mform->set_data($grade_text);
+} else {
+    $mform->set_data(array('courseid'=>$course->id));
+}
+
+if ($mform->is_cancelled()) {
+    redirect($returnurl);
+
+} else if ($data = $mform->get_data()) {
+    $grade_text = new grade_grades_text(array('gradeid'=>$id));
+    grade_grades_text::set_properties($grade_text, $data);
+
+    if (empty($grade_text->id)) {
+        $grade_text->insert();
+
+    } else {
+        $grade_text->update();
+    }
+
+    redirect($returnurl);
+}
+
+// Get name of student and gradeitem name
+$query = "SELECT a.firstname, a.lastname, b.itemname, c.finalgrade, b.grademin, b.grademax
+            FROM {$CFG->prefix}user AS a, 
+                 {$CFG->prefix}grade_items AS b, 
+                 {$CFG->prefix}grade_grades AS c
+           WHERE c.id = $id
+             AND b.id = c.itemid
+             AND a.id = c.userid";
+
+$extra_info = get_record_sql($query) ;
+$extra_info->grademin = round($extra_info->grademin);
+$extra_info->grademax = round($extra_info->grademax);
+$extra_info->finalgrade = round($extra_info->finalgrade);
+
+$stronascaleof   = get_string('onascaleof', 'grades', $extra_info);
+$strgrades       = get_string('grades');
+$strgrade        = get_string('grade');
+$strgraderreport = get_string('graderreport', 'grades');
+$strfeedbackedit = get_string('feedbackedit', 'grades');
+$strstudent      = get_string('student', 'grades');
+$strgradeitem    = get_string('gradeitem', 'grades');
+
+$nav = array(array('name'=>$strgrades,'link'=>$CFG->wwwroot.'/grade/index.php?id='.$courseid, 'type'=>'misc'),
+             array('name'=>$strgraderreport, 'link'=>$CFG->wwwroot.'/grade/report.php?id='.$courseid.'&amp;report=grader', 'type'=>'misc'),
+             array('name'=>$strfeedbackedit, 'link'=>'', 'type'=>'misc'));
+
+$navigation = build_navigation($nav);
+
+
+print_header_simple($strgrades . ': ' . $strgraderreport, ': ' . $strfeedbackedit, $navigation, '', '', true, '', navmenu($course));
+
+print_heading(get_string('feedbackedit', 'grades'));
+print_box_start('gradefeedbackbox generalbox');
+echo "<p>$strstudent: " . fullname($extra_info) . "</p>";
+echo "<p>$strgradeitem: " . $extra_info->itemname . "</p>";
+if (!empty($extra_info->finalgrade)) {
+    echo "<p>$strgrade: " . $extra_info->finalgrade . "$stronascaleof</p>";
+}
+
+$mform->display();
+
+print_box_end();
+
+print_footer($course);
+die;
diff --git a/grade/report/grader/edit_feedback_form.php b/grade/report/grader/edit_feedback_form.php
new file mode 100644 (file)
index 0000000..023708c
--- /dev/null
@@ -0,0 +1,36 @@
+<?php  //$Id$
+
+require_once $CFG->libdir.'/formslib.php';
+
+class edit_feedback_form extends moodleform {
+    function definition() {
+        global $CFG, $USER;
+        $mform =& $this->_form;
+        
+        $feedbackformat = get_user_preferences('grade_report_feedbackformat', $CFG->grade_report_feedbackformat);
+
+        // visible elements
+        // User preference determines the format
+        if ($CFG->htmleditor && $USER->htmleditor && $feedbackformat == GRADER_REPORT_FEEDBACK_FORMAT_HTML) {
+            $mform->addElement('htmleditor', 'feedback', get_string('feedback', 'grades'), 
+                array('rows'=> '15', 'course' => optional_param('courseid', PARAM_INT), 'cols'=>'45'));
+        } else {
+            $mform->addElement('textarea', 'feedback', get_string('feedback', 'grades'));
+        }
+
+        //TODO: add other elements
+
+        // hidden params
+        $mform->addElement('hidden', 'gradeid', 0);
+        $mform->setType('gradeid', PARAM_INT);
+
+        $mform->addElement('hidden', 'courseid', 0);
+        $mform->setType('courseid', PARAM_INT);
+
+//-------------------------------------------------------------------------------
+        // buttons
+        $this->add_action_buttons();
+    }
+}
+
+?>
index 0689df5d42dc50ab2157a6e910e8ec6e6be012e8..b9045f47825d96fad5a00648ea562a1883dd869e 100644 (file)
@@ -7,7 +7,7 @@ include_once($CFG->libdir.'/gradelib.php');
 
 // Prepare language strings
 $strsortasc  = get_string('sortasc', 'grades');
-$strsortdesc = get_string('sortdesc', 'grades');
+$strsortdesc = get_string('sortasc', 'grades');
 
 /// processing posted grades here
 
@@ -51,12 +51,20 @@ $context       = get_context_instance(CONTEXT_COURSE, $courseid);
 $page          = optional_param('page', 0, PARAM_INT);
 $sortitemid    = optional_param('sortitemid', 0, PARAM_ALPHANUM); // sort by which grade item
 $report        = optional_param('report', 0, PARAM_ALPHANUM);
-$perpage       = optional_param('perpage', 3, PARAM_INT); // number of users on a page
 $action        = optional_param('action', 0, PARAM_ALPHA);
 $move          = optional_param('move', 0, PARAM_INT);
 $type          = optional_param('type', 0, PARAM_ALPHA);
 $target        = optional_param('target', 0, PARAM_ALPHANUM);
 
+// Get the user preferences
+$perpage  = get_user_preferences('grade_report_studentsperpage', $CFG->grade_report_studentsperpage); // number of users on a page
+$decimals = get_user_preferences('grade_report_decimalpoints', $CFG->grade_report_decimalpoints); // decimals in grades
+
+// Override perpage if set in URL
+if ($perpageurl = optional_param('perpage', 0, PARAM_INT)) {
+    $perpage = $perpageurl;
+}
+
 // Grab the grade_tree for this course
 $gtree = new grade_tree($courseid);
 
@@ -244,9 +252,9 @@ if (!$context = get_context_instance(CONTEXT_COURSE, $gtree->courseid)) {
 
 if ($sortitemid === 'lastname') {
     if ($sortorder == 'ASC') {
-        $lastarrow = ' <img src="'.$CFG->pixpath.'/t/up.gif" alt="'.$strsortasc.'" /> ';
+        $lastarrow = print_arrow('up', $strsortasc, true);
     } else {
-        $lastarrow = ' <img src="'.$CFG->pixpath.'/t/down.gif" alt="'.$strsortdesc.'" /> ';
+        $lastarrow = print_arrow('down', $strsortdesc, true);
     }
 } else {
     $lastarrow = '';
@@ -254,9 +262,9 @@ if ($sortitemid === 'lastname') {
 
 if ($sortitemid === 'firstname') {
     if ($sortorder == 'ASC') {
-        $firstarrow = ' <img src="'.$CFG->pixpath.'/t/up.gif" alt="'.$strsortasc.'" /> ';
+        $firstarrow = print_arrow('up', $strsortasc, true);
     } else {
-        $firstarrow = ' <img src="'.$CFG->pixpath.'/t/down.gif" alt="'.$strsortdesc.'" /> ';
+        $firstarrow = print_arrow('down', $strsortdesc, true);
     }
 } else {
     $firstarrow = '';
@@ -317,9 +325,9 @@ foreach ($gtree->levels as $key=>$row) {
         } else {
             if ($element['object']->id == $sortitemid) {
                 if ($sortorder == 'ASC') {
-                    $arrow = ' <img src="'.$CFG->pixpath.'/t/up.gif" alt="'.$strsortasc.'" /> ';
+                    $arrow = print_arrow('up', $strsortasc, true);
                 } else {
-                    $arrow = ' <img src="'.$CFG->pixpath.'/t/down.gif" alt="'.$strsortdesc.'" /> ';
+                    $arrow = print_arrow('down', $strsortdesc, true);
                 }
             } else {
                 $arrow = '';
@@ -416,13 +424,13 @@ foreach ($users as $userid => $user) {
                     if ((int) $gradeval < 1) {
                         $studentshtml .= '-';
                     } else {
-                        $studentshtml .= $scales[$gradeval-1];
+                        $studentshtml .= round($scales[$gradeval-1], $decimals);
                     }
                 } else {
                     // no such scale, throw error?
                 }
             } else {
-                $studentshtml .=  $gradeval;
+                $studentshtml .=  round($gradeval, $decimals);
             }
         }
 
index 35632207493d6a14aff9601d049047c139d02ce3..15c689450f57217cd8c324d223ee8ccc4d29e2d6 100644 (file)
@@ -1,7 +1,44 @@
 <?php // $Id$
 
 /// Add settings for this module to the $settings object (it's already defined)
-
-    $settings->add(new admin_setting_configcheckbox('gradereport_grader_enableajax', 'Enable AJAX in gradebook', 'This setting will enable the AJAX interface in the gradebooks, depending on the site setting and the individual user profile choice.', 1));
-
+$settings->add(new admin_setting_configselect('grade_report_aggregationposition', get_string('aggregationposition', 'grades'),
+                                          get_string('configaggregationposition', 'grades'), false, 
+                                          array( '0' => 'left', 
+                                                 '1' => 'right')));
+$settings->add(new admin_setting_configselect('grade_report_aggregationview', get_string('aggregationview', 'grades'),
+                                          get_string('configaggregationview', 'grades'), false, 
+                                          array( '0' => 'full', 
+                                                 '1' => 'compact')));
+$settings->add(new admin_setting_configcheckbox('grade_report_bulkcheckboxes', get_string('bulkcheckboxes', 'grades'),
+                                            get_string('configbulkcheckboxes', 'grades'), 0));
+$settings->add(new admin_setting_configcheckbox('grade_report_enableajax', get_string('enableajax', 'grades'),
+                                            get_string('configenableajax', 'grades'), 0));
+$settings->add(new admin_setting_configselect('grade_report_gradedisplaytype', get_string('gradedisplaytype', 'grades'),
+                                          get_string('configgradedisplaytype', 'grades'), false, 
+                                          array( '0' => 'raw', 
+                                                 '1' => 'percentage')));
+$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'),
+                                            get_string('configshowgroups', 'grades'), 0));
+$settings->add(new admin_setting_configcheckbox('grade_report_showlocks', get_string('showlocks', 'grades'),
+                                            get_string('configshowlocks', 'grades'), 0));
+$settings->add(new admin_setting_configcheckbox('grade_report_shownotes', get_string('shownotes', 'grades'),
+                                            get_string('configshownotes', 'grades'), 0));
+$settings->add(new admin_setting_configcheckbox('grade_report_showscales', get_string('showscales', 'grades'),
+                                            get_string('configshowscales', 'grades'), 0));
+$settings->add(new admin_setting_configtext('grade_report_studentsperpage', get_string('studentsperpage', 'grades'),
+                                        get_string('configstudentsperpage', 'grades'), 20));
+$settings->add(new admin_setting_configselect('grade_report_feedbackformat', get_string('feedbackformat', 'grades'),
+                                          get_string('configfeedbackformat', 'grades'), false, 
+                                          array( '0' => 'text', 
+                                                 '1' => 'html')));
+$settings->add(new admin_setting_configselect('grade_report_decimalpoints', get_string('decimalpoints', 'grades'),
+                                          get_string('configdecimalpoints', 'grades'), 2, 
+                                          array( '0' => '0', 
+                                                 '1' => '1',
+                                                 '2' => '2',
+                                                 '3' => '3',
+                                                 '4' => '4',
+                                                 '5' => '5'))); 
 ?>
index 6b80db7fefb451cbe6569121ecd79e5074c62b76..af50cbd0c887f9a7d5e24af4c3058ed4adcc43ef 100644 (file)
@@ -7,6 +7,9 @@ $string['addcategoryerror'] = 'Could not add category.';
 $string['addexceptionerror'] = 'Error occurred while adding exception for userid:gradeitem';
 $string['addfeedback'] = 'Add Feedback';
 $string['additem'] = 'Add Grade Item';
+$string['aggregation'] = 'Aggregation';
+$string['aggregationposition'] = 'Aggregation position';
+$string['aggregationview'] = 'Aggregation view';
 $string['allgrades'] = 'All grades by category';
 $string['allstudents'] = 'All Students';
 $string['autosort'] = 'Auto-sort';
@@ -14,17 +17,32 @@ $string['average'] = 'Average';
 $string['badgrade'] = 'Supplied grade is invalid';
 $string['baduser'] = 'Supplied user is invalid';
 $string['bonuspoints'] = 'Bonus Points';
+$string['bulkcheckboxes'] = 'Bulk checkboxes';
 $string['calculation'] = 'Calculation';
 $string['categories'] = 'Categories';
 $string['category'] = 'Category';
 $string['categoriesedit'] = 'Edit Categories';
 $string['categoryname'] = 'Category name';
 $string['choosecategory'] = 'Select Category';
+$string['configaggregationposition'] = 'The position of the aggregation column in the grader report table, in reference to the raw grades.';
+$string['configaggregationview'] = 'The way aggregations are displayed: either alongside the raw grades, or in a compact form in which only one type is shown in the table at once: the raw grades OR the aggregated grades.';
+$string['configbulkcheckboxes'] = 'Checkboxes near each grade for Bulk grade operations.';
+$string['configdecimalpoints'] = 'The number of decimal points to display for each grade. This can be overriden per grading item.';
+$string['configenableajax'] = 'Adds a layer of AJAX functionality to the grader report, simplifying and speeding up common operations. Depends on Javascript being switched on at the user\'s browser level.';
+$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['configshoweyecons'] = 'Whether to show an eye-con near each grade (controlling its visibility to the user).';
+$string['configshowgroups'] = 'Show group totals and means in the grader report.';
+$string['configshowlocks'] = 'Whether to show a lock/unlock icon near each grade.';
+$string['configshownotes'] = 'Whether to show a feedback icon (for adding/editing) near each grade.';
+$string['configshowscales'] = 'Display a row showing the scale for each grading item, in the grader report.';
+$string['configstudentsperpage'] = 'The number of students to display per page in the grader report.';
 $string['contract'] = 'Contract Category';
 $string['createcategory'] = 'Create Category';
 $string['createcategoryerror'] = 'Could not create a new category';
 $string['creatinggradebooksettings'] = 'Creating Gradebook settings';
 $string['curveto'] = 'Curve To';
+$string['decimalpoints'] = 'Decimal points';
 $string['deletecategory'] = 'Delete Category';
 $string['displaylettergrade'] = 'Display Letter Grades';
 $string['displaypercent'] = 'Display Percents';
@@ -34,6 +52,7 @@ $string['dropped'] = 'Dropped';
 $string['dropxlowest'] = 'Drop X Lowest';
 $string['dropxlowestwarning'] = 'Note: If you use drop x lowest the grading assumes that all items in the category have the same point value. If point values differ results will be unpredictable';
 $string['editfeedback'] = 'Edit Feedback';
+$string['enableajax'] = 'Enable AJAX';
 $string['encoding'] = 'Encoding';
 $string['errorgradevaluenonnumeric'] = 'Received non-numeric for low or high grade for';
 $string['errornocategorizedid'] = 'Could not get an uncategorized id!';
@@ -49,12 +68,14 @@ $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';
 $string['feedback'] = 'Feedback';
 $string['feedbackedit'] = 'Edit feedback';
+$string['feedbackformat'] = 'Feedback format';
 $string['forelementtypes'] = ' for the selected $a';
 $string['forstudents'] = 'For Students';
 $string['grade'] = 'Grade';
 $string['gradebook'] = 'Gradebook';
 $string['gradebookhiddenerror'] = 'The gradebook is currently set to hide everything from students.';
 $string['gradecategoryhelp'] = 'Grade Category Help';
+$string['gradedisplaytype'] = 'Grade display type';
 $string['gradeexceptions'] = 'Grade Exceptions';
 $string['gradeexceptionshelp'] = 'Grade Exceptions Help';
 $string['gradehelp'] = 'Grade Help';
@@ -159,6 +180,11 @@ $string['setting'] = 'Setting';
 $string['settings'] = 'Settings';
 $string['setweights'] = 'Set Weights';
 $string['showallstudents'] = 'Show All Students';
+$string['showeyecons'] = 'Show eye-cons';
+$string['showgroups'] = 'Show groups';
+$string['showlocks'] = 'Show locks';
+$string['shownotes'] = 'Show feedback';
+$string['showscales'] = 'Show scales';
 $string['showhiddenitems'] = 'Show Hidden Items';
 $string['sort'] = 'sort';
 $string['sortasc'] = 'Sort in ascending order';
@@ -169,6 +195,7 @@ $string['standarddeviation'] = 'Standard Deviation';
 $string['stats'] = 'Statistics';
 $string['statslink'] = 'Stats';
 $string['student'] = 'Student';
+$string['studentsperpage'] = 'Students per page';
 $string['subcategory'] = 'Normal Category';
 $string['synclegacygrades'] = 'Synchronise legacy grades';
 $string['topcategory'] = 'Super Category';
index 965a800b3553bdfb4441c15acc6bd4cc6ec9ded0..609744076e52a713855307f49a1427def129824e 100644 (file)
@@ -6279,5 +6279,53 @@ function print_location_comment($file, $line, $return = false)
     }
 }
 
+
+/** 
+ * Returns an image of an up or down arrow, used for column sorting. To avoid unnecessary DB accesses, please
+ * provide this function with the language strings for sortasc and sortdesc.
+ * If no sort string is associated with the direction, an arrow with no alt text will be printed/returned.
+ * @param string $direction 'up' or 'down'
+ * @param string $strsort The language string used for the alt attribute of this image
+ * @param bool $return Whether to print directly or return the html string
+ * @return string HTML for the image
+ * 
+ * TODO See if this isn't already defined somewhere. If not, move this to weblib
+ */
+function print_arrow($direction='up', $strsort=null, $return=false) {
+    global $CFG;
+    
+    if (!in_array($direction, array('up', 'down', 'right', 'left'))) {
+        return null;
+    }
+    
+    $return = null; 
+
+    switch ($direction) {
+        case 'up':
+            $sortdir = 'asc';
+            break;
+        case 'down':
+            $sortdir = 'desc';
+            break;
+        default:
+            $sortdir = null;
+            break;
+    }
+
+    // Prepare language string
+    $strsort = '';
+    if (empty($strsort) && !empty($sortdir)) {
+        $strsort  = get_string('sort' . $sortdir, 'grades');
+    }
+
+    $return = ' <img src="'.$CFG->pixpath.'/t/' . $direction . '.gif" alt="'.$strsort.'" /> ';
+
+    if ($return) {
+        return $return;
+    } else {
+        echo $return;
+    }
+}
+
 // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
 ?>