]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10368 Added quick toggles
authornicolasconnault <nicolasconnault>
Mon, 9 Jul 2007 13:24:36 +0000 (13:24 +0000)
committernicolasconnault <nicolasconnault>
Mon, 9 Jul 2007 13:24:36 +0000 (13:24 +0000)
grade/report/grader/index.php
lang/en_utf8/grades.php
theme/standard/styles_layout.css

index 1c0c68e3ef294664ca46546c1db203ba0d1c8809..351566ec7070447b98569a5a91ca15887a1be440 100644 (file)
@@ -5,6 +5,52 @@
 require_once($CFG->libdir.'/tablelib.php');
 include_once($CFG->libdir.'/gradelib.php');
 
+
+// remove trailing 0s and "."s
+function get_grade_clean($gradeval) {
+
+    if ($gradeval != 0) {
+        $gradeval = rtrim(trim($gradeval, "0"), ".");
+    } else {
+        $gradeval = 0;
+    }
+
+    return $gradeval;
+}
+
+/**
+* Shortcut function for printing the grader report toggles.
+* @param string $type The type of toggle
+* @param string $baseurl The base of the URL the toggles will link to
+* @param bool $return Whether to return the HTML string rather than printing it
+* @return void
+*/
+function grader_report_print_toggle($type, $baseurl, $return=false) {
+    global $CFG;
+    $pref_name = 'grade_report_show' . $type;
+    $show_pref = get_user_preferences($pref_name, $CFG->$pref_name);
+
+    $strshow = get_string('show' . $type, 'grades');
+    $strhide = get_string('hide' . $type, 'grades');
+
+    $show_hide = 'show';
+    $toggle_action = 1;
+
+    if ($show_pref) {
+        $show_hide = 'hide';
+        $toggle_action = 0;
+    }
+
+    $retval = '<div class="gradertoggle"><a href="' . $baseurl . "&amp;toggle=$toggle_action&amp;toggle_type=$type\">"
+         . ${'str' . $show_hide} . '</a></div>';
+
+    if ($return) {
+        return $retval;
+    } else {
+        echo $retval;
+    }
+}
+
 /// processing posted grades here
 
 if ($data = data_submitted()) {
@@ -51,6 +97,8 @@ $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);
+$toggle        = optional_param('toggle', NULL, PARAM_INT);
+$toggle_type   = optional_param('toggle_type', 0, PARAM_ALPHANUM);
 
 // Get the user preferences
 $perpage              = get_user_preferences('grade_report_studentsperpage', $CFG->grade_report_studentsperpage); // number of users on a page
@@ -68,20 +116,20 @@ if ($perpageurl = optional_param('perpage', 0, PARAM_INT)) {
 /// setting up groups
 
 // Prepare language strings
-$strsortasc     = get_string('sortasc', 'grades');
-$strsortdesc    = get_string('sortdesc', 'grades');
-$strshoweyecons = get_string('showeyecons', 'grades');
-$strhideeyecons = get_string('hideeyecons', 'grades');
-$strshowlocks   = get_string('showlocks', 'grades');
-$strhidelocks   = get_string('hidelocks', 'grades');
-$strshownotes   = get_string('shownotes', 'grades');
-$strhidenotes   = get_string('hidenotes', 'grades');
+$strsortasc          = get_string('sortasc', 'grades');
+$strsortdesc         = get_string('sortdesc', 'grades');
 
 // base url for sorting by first/last name
 $baseurl = 'report.php?id='.$courseid.'&amp;perpage='.$perpage.'&amp;report=grader&amp;page='.$page;
 // base url for paging
 $pbarurl = 'report.php?id='.$courseid.'&amp;perpage='.$perpage.'&amp;report=grader&amp;';
 
+// Handle toggle change request
+// TODO print visual feedback
+if (!is_null($toggle) && !empty($toggle_type)) {
+    set_user_preferences(array('grade_report_show' . $toggle_type => $toggle));
+}
+
 /// find out current groups mode
 $course = get_record('course', 'id', $courseid);
 $groupmode = $course->groupmode;
@@ -311,6 +359,16 @@ include('tabs.php');
 echo $group_selector;
 
 // Show/hide toggles
+if ($USER->gradeediting) {
+    grader_report_print_toggle('eyecons', $baseurl);
+    grader_report_print_toggle('locks', $baseurl);
+    grader_report_print_toggle('calculations', $baseurl);
+}
+
+grader_report_print_toggle('notes', $baseurl);
+grader_report_print_toggle('grandtotals', $baseurl);
+grader_report_print_toggle('groups', $baseurl);
+grader_report_print_toggle('scales', $baseurl);
 
 // Paging bar
 print_paging_bar($numusers, $page, $perpage, $pbarurl);
@@ -597,19 +655,7 @@ echo $reporthtml;
 
 // print submit button
 if ($USER->gradeediting) {
-    echo '<div style="text-align:center"><input type="submit" value="'.get_string('update').'" /></div>';
+    echo '<div class="submit"><input type="submit" value="'.get_string('update').'" /></div>';
     echo '</div></form>';
 }
-
-// remove trailing 0s and "."s
-function get_grade_clean($gradeval) {
-
-    if ($gradeval != 0) {
-        $gradeval = rtrim(trim($gradeval, "0"), ".");
-    } else {
-        $gradeval = 0;
-    }
-
-    return $gradeval;
-}
 ?>
index 3616b23abaa9893e1aecaa879548293b07520970..ce63d9b3dd9baa0cbc1573cf4e7785d5df2b3572 100644 (file)
@@ -118,10 +118,14 @@ $string['gradetype'] = 'Grade type';
 $string['gradeweighthelp'] = 'Grade Weight Help';
 $string['grandtotalsdisplaytype'] = 'Grand totals display type';
 $string['hideadvanced'] = 'Hide Advanced Features';
+$string['hidecalculations'] = 'Hide calculations';
 $string['hidecategory'] = 'Hidden';
 $string['hideeyecons'] = 'Hide eyecons';
+$string['hidegrandtotals'] = 'Hide grandtotals';
+$string['hidegroups'] = 'Hide groups';
 $string['hidelocks'] = 'Hide locks';
 $string['hidenotes'] = 'Hide feedback';
+$string['hidescales'] = 'Hide scales';
 $string['highgradeascending'] = 'Sort by high grade ascending';
 $string['highgradedescending'] = 'Sort by high grade descending';
 $string['highgradeletter'] = 'High';
index 22b15344c57490b4e6b14770a6843d0556ea9e44..e6ab085f1c66d86b51893e93ba9c7a313e8cca54 100644 (file)
@@ -2059,6 +2059,11 @@ body#grade-index .grades .weighted {
   margin-top: 20px;
 }
 
+#grade-report div.submit {
+  margin-top: 20px;
+  text-align: center;
+}
+
 #grade-report table td {
   border-width:1px;
   border-style:solid;
@@ -2106,6 +2111,11 @@ body#grade-index .grades .weighted {
   border-style:solid;
 }
 
+#grade-report div.gradertoggle {
+  display: inline;
+  margin-left: 20px;
+}
+
 /* gradebook edit tree */
 
 #grade-report-grader-category .gradetreebox {