]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10209 MDL-10211
authornicolasconnault <nicolasconnault>
Thu, 28 Jun 2007 11:15:12 +0000 (11:15 +0000)
committernicolasconnault <nicolasconnault>
Thu, 28 Jun 2007 11:15:12 +0000 (11:15 +0000)
Added two tiny feedback/add_feedback icons.
Enabled feedback mode with button next to "Turn editing on".
Added tooltip (with overlib for the time being) for "Show feedback" when edit mode is off, and for "Edit feedback" when edit is on.

grade/report.php
grade/report/grader/index.php
lang/en_utf8/grades.php
lib/gradelib.php
pix/i/feedback_add.gif [new file with mode: 0644]
pix/t/feedback.gif [new file with mode: 0644]
pix/t/feedback_add.gif [new file with mode: 0644]

index c9dc916dd6220b30725be7b0d8e8bb2f17e31413..1ca197bb34cd1f0681a6e843f1d16f58fe5a3024 100644 (file)
@@ -29,6 +29,7 @@
     $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
+    $feedback = optional_param('feedback', -1, PARAM_BOOL); // sticky feedback mode
 
 /// Make sure they can even access this course
 
     } else if (($edit == 0) and confirm_sesskey()) {
         $USER->gradeediting = 0;
     }
+    
+    // Setup feedback mode
+    if (!isset($USER->gradefeedback)) {
+        $USER->gradefeedback = 0;
+    }
+
+    if (($feedback == 1) and confirm_sesskey()) {
+        $USER->gradefeedback = 1;
+    } else if (($feedback == 0) and confirm_sesskey()) {
+        $USER->gradefeedback = 0;
+    }
 
-    // params for the turn editting on button
+    // params for the turn editting on and feedback buttons
     $options['id'] = $courseid;
     $options['report'] = $report;
     
     $options['sesskey'] = sesskey();
     $link = 'report.php';
 
-    // turn eidtting on and off buttons
+    // turn editting on and off buttons
     $buttons = print_single_button($link, $options, $string, 'get', '_self', true);
+    unset($options['edit']);
+
+    if ($USER->gradefeedback) {
+        $options['feedback'] = 0;
+        $string = get_string('turnfeedbackoff', 'grades');
+    } else {
+        $options['feedback'] = 1;
+        $string = get_string('turnfeedbackon', 'grades'); 
+    }
+
+    // turn editting on and off buttons
+    $buttons .= print_single_button($link, $options, $string, 'get', '_self', true);
     
     print_header_simple($strgrades.':'.$reportnames[$report], ':'.$strgrades, $navigation, 
                         '', '', true, $buttons, navmenu($course));
index 06672d260733db2ff893a41d2f184ec1356980bc..f00c4588ad684226587cff578b38904cb08ab4bb 100644 (file)
@@ -5,6 +5,10 @@
 require_once($CFG->libdir.'/tablelib.php');
 include_once($CFG->libdir.'/gradelib.php');
 
+// Prepare language strings
+$strsortasc  = get_string('sortasc', 'grades');
+$strsortdesc = get_string('sortdesc', 'grades');
+
 /// processing posted grades here
 
 if ($data = data_submitted()) {
@@ -261,9 +265,9 @@ $cathtml    = '<tr><td class="filler">&nbsp;</td>';
 
 if ($sortitemid === 'lastname') {
     if ($sortorder == 'ASC') {
-        $lastarrow = ' <img src="'.$CFG->pixpath.'/t/up.gif"/> ';
+        $lastarrow = ' <img src="'.$CFG->pixpath.'/t/up.gif" alt="'.$strsortasc.'" /> ';
     } else {
-        $lastarrow = ' <img src="'.$CFG->pixpath.'/t/down.gif"/> ';
+        $lastarrow = ' <img src="'.$CFG->pixpath.'/t/down.gif" alt="'.$strsortdesc.'" /> ';
     }
 } else {
     $lastarrow = '';  
@@ -271,9 +275,9 @@ if ($sortitemid === 'lastname') {
 
 if ($sortitemid === 'firstname') {
     if ($sortorder == 'ASC') {
-        $firstarrow = ' <img src="'.$CFG->pixpath.'/t/up.gif"/> ';
+        $firstarrow = ' <img src="'.$CFG->pixpath.'/t/up.gif" alt="'.$strsortasc.'" /> ';
     } else {
-        $firstarrow = ' <img src="'.$CFG->pixpath.'/t/down.gif"/> ';
+        $firstarrow = ' <img src="'.$CFG->pixpath.'/t/down.gif" alt="'.$strsortdesc.'" /> ';
     }
 } else {
     $firstarrow = '';  
@@ -296,9 +300,9 @@ foreach ($tree as $topcat) {
             
             if ($item['object']->id == $sortitemid) {
                 if ($sortorder == 'ASC') {
-                    $arrow = ' <img src="'.$CFG->pixpath.'/t/up.gif"/> ';
+                    $arrow = ' <img src="'.$CFG->pixpath.'/t/up.gif" alt="'.$strsortasc.'" /> ';
                 } else {
-                    $arrow = ' <img src="'.$CFG->pixpath.'/t/down.gif"/> ';
+                    $arrow = ' <img src="'.$CFG->pixpath.'/t/down.gif" alt="'.$strsortdesc.'" /> ';
                 }
             } else {
                 $arrow = '';
@@ -313,10 +317,8 @@ foreach ($tree as $topcat) {
                       . $item['object']->id .'">'. $item['object']->itemname 
                       . '</a>' . $arrow; 
             
-            // Print icons if grade editing is on 
-            if ($USER->gradeediting) {
-                $itemhtml .= grade_get_icons($item['object'], $gtree) . '</th>';
-            }
+            // Print icons
+            $itemhtml .= grade_get_icons($item['object'], $gtree) . '</th>';
 
             $items[] = $item;
         }
@@ -332,10 +334,8 @@ foreach ($tree as $topcat) {
             $cat['object']->load_grade_item();
             $cathtml .= '<td '.$dimmed.' colspan="' . $catitemcount . '">' . $cat['object']->fullname;
 
-            // Print icons if grade editing is on 
-            if ($USER->gradeediting) {
-                $cathtml .= grade_get_icons($cat['object'], $gtree) . '</td>';
-            }
+            // Print icons 
+            $cathtml .= grade_get_icons($cat['object'], $gtree) . '</td>';
         }
     }
 
@@ -353,10 +353,8 @@ foreach ($tree as $topcat) {
         
         $topcathtml .= '<th '.$dimmed.' colspan="' . $itemcount . '">' . $topcat['object']->fullname;
         
-        // Print icons if grade editing is on 
-        if ($USER->gradeediting) {
-            $topcathtml .= grade_get_icons($topcat['object'], $gtree) . '</th>';
-        }
+        // Print icons
+        $topcathtml .= grade_get_icons($topcat['object'], $gtree) . '</th>';
     }
 }
     
@@ -372,6 +370,7 @@ foreach ($users as $userid => $user) {
         if (isset($finalgrades[$userid][$item['object']->id])) {
             $gradeval = $finalgrades[$userid][$item['object']->id]->finalgrade;
             $grade_grades = new grade_grades($finalgrades[$userid][$item['object']->id], false);
+            $grade_grades->feedback = $finalgrades[$userid][$item['object']->id]->feedback;
         } else {
             $gradeval = '-';  
             $grade_grades = new grade_grades(array('userid' => $userid, 'itemid' => $item['object']->id), false);
@@ -398,10 +397,6 @@ foreach ($users as $userid => $user) {
                 $studentshtml .= '<input type="text" name="grade_'.$userid.'_'.$item['object']->id.'" value="'.$gradeval.'"/>';
             }
             
-            // Do not show any icons if no grade (no record in DB to match)
-            if (!empty($grade_grades->id)) {
-                $studentshtml .= grade_get_icons($grade_grades, $gtree);
-            }
         } else {
             // finalgrades[$userid][$itemid] could be null because of the outer join
             // in this case it's different than a 0  
@@ -423,6 +418,11 @@ foreach ($users as $userid => $user) {
             }
         }
         
+        // Do not show any icons if no grade (no record in DB to match)
+        if (!empty($grade_grades->id)) {
+            $studentshtml .= grade_get_icons($grade_grades, $gtree);
+        }
+        
         $studentshtml .=  '</td>' . "\n";
     }
     $studentshtml .= '</tr>';
index 94963bf185a8773b25f0dd57e3abe9c6f6e66b99..f5d11f7c1b5d3e14d6209fdbfcffc273486feae2 100644 (file)
@@ -5,6 +5,7 @@
 $string['addcategory'] = 'Add Category';
 $string['addcategoryerror'] = 'Could not add category.';
 $string['addexceptionerror'] = 'Error occurred while adding exception for userid:gradeitem';
+$string['addfeedback'] = 'Add Feedback';
 $string['allgrades'] = 'All grades by category';
 $string['allstudents'] = 'All Students';
 $string['average'] = 'Average';
@@ -28,6 +29,7 @@ $string['displayweighted'] = 'Display Weighted Grades';
 $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['encoding'] = 'Encoding';
 $string['errorgradevaluenonnumeric'] = 'Received non-numeric for low or high grade for';
 $string['errornocategorizedid'] = 'Could not get an uncategorized id!';
@@ -138,6 +140,8 @@ $string['setweights'] = 'Set Weights';
 $string['showallstudents'] = 'Show All Students';
 $string['showhiddenitems'] = 'Show Hidden Items';
 $string['sort'] = 'sort';
+$string['sortasc'] = 'Sort in ascending order';
+$string['sortdesc'] = 'Sort in descending order';
 $string['sortbyfirstname'] = 'Sort by Firstname';
 $string['sortbylastname'] = 'Sort by Lastname';
 $string['standarddeviation'] = 'Standard Deviation';
@@ -149,6 +153,8 @@ $string['topcategory'] = 'Super Category';
 $string['total'] = 'Total';
 $string['totalweight100'] = 'The total weight is equal to 100';
 $string['totalweightnot100'] = 'The total weight is not equal to 100';
+$string['turnfeedbackoff'] = 'Turn feedback off';
+$string['turnfeedbackon'] = 'Turn feedback on';
 $string['uncategorised'] = 'Uncategorised';
 $string['unlock'] = 'Unlock';
 $string['uploadgrades'] = 'Upload grades';
index 809758e148c8dfa130485cafcce385631c73c2a3..b8cc8b4578ddc1a948fd75a42ffc136297ce3568 100644 (file)
@@ -688,8 +688,12 @@ function grade_oldgradebook_upgrade($courseid) {
  */
 function grade_get_icons($object, $tree) {
     global $CFG;
+    global $USER;
 
+    $straddfeedback    = get_string("addfeedback", 'grades');
     $stredit           = get_string("edit");
+    $streditfeedback   = get_string("editfeedback", 'grades');
+    $strfeedback       = get_string("feedback");
     $strmove           = get_string("move");
     $strmoveup         = get_string("moveup");
     $strmovedown       = get_string("movedown");
@@ -704,47 +708,80 @@ function grade_get_icons($object, $tree) {
 
     $html = '<div class="grade_icons">';
     
-    // Edit icon (except for grade_grades)
-    if (get_class($object) != 'grade_grades') {
-        $html .= '<a href="report/grader/category.php?target=' . $object->get_sortorder() 
-              . "&amp;action=edit$tree->commonvars\">\n";
-        $html .= '<img src="'.$CFG->pixpath.'/t/edit.gif" class="iconsmall" alt="'
-              .$stredit.'" title="'.$stredit.'" /></a>'. "\n";
-    }
-
-    // Hide/Show icon
-    $hide_show = 'hide';
-    if ($object->is_hidden()) {
-        $hide_show = 'show';
-    }
-    
-    if (get_class($object) != 'grade_grades') {
-        $identifier = $object->get_sortorder();
-    } else {
-        $identifier = 'grade' . $object->id;
-    }
+    // Icons shown when edit mode is on
+    if ($USER->gradeediting) {
+        // Edit icon (except for grade_grades)
+        if (get_class($object) != 'grade_grades') {
+            $html .= '<a href="report/grader/category.php?target=' . $object->get_sortorder() 
+                  . "&amp;action=edit$tree->commonvars\">\n";
+            $html .= '<img src="'.$CFG->pixpath.'/t/edit.gif" class="iconsmall" alt="'
+                  .$stredit.'" title="'.$stredit.'" /></a>'. "\n";
+        }
 
-    $html .= '<a href="report.php?report=grader&amp;target=' . $identifier
-          . "&amp;action=$hide_show$tree->commonvars\">\n";
-    $html .= '<img src="'.$CFG->pixpath.'/t/'.$hide_show.'.gif" class="iconsmall" alt="'
-          .${'str' . $hide_show}.'" title="'.${'str' . $hide_show}.'" /></a>'. "\n";
+        // Prepare Hide/Show icon state
+        $hide_show = 'hide';
+        if ($object->is_hidden()) {
+            $hide_show = 'show';
+        }
+        
+        // Setup object identifier and show feedback icon if applicable
+        if (get_class($object) != 'grade_grades') {
+            $identifier = $object->get_sortorder();
+        } else {
+            $identifier = 'grade' . $object->id;
+            
+            if ($USER->gradefeedback) {
+                // Display Edit/Add feedback icon
+                if (empty($object->feedback)) {
+                    $html .= '<a href="report.php?report=grader&amp;target=' . $object->id
+                          . "&amp;action=addfeedback$tree->commonvars\">\n"; 
+                    $html .= '<img src="'.$CFG->pixpath.'/t/feedback_add.gif" class="iconsmall" alt="'.$straddfeedback.'" '
+                          . 'title="'.$straddfeedback.'" /></a>'. "\n";
+                } else {
+                    $html .= '<a href="report.php?report=grader&amp;target=' . $object->id
+                          . "&amp;action=editfeedback$tree->commonvars\">\n"; 
+                    $html .= '<img src="'.$CFG->pixpath.'/t/feedback.gif" class="iconsmall" alt="'.$streditfeedback.'" '
+                          . 'title="'.$streditfeedback.'" onmouseover="return overlib(\''.$object->feedback.'\', CAPTION, \''
+                      . $strfeedback.'\');" onmouseout="return nd();" /></a>'. "\n";
+                } 
+            }
+        }
 
-    // Prepare lock/unlock string
-    $lock_unlock = 'lock';
-    if ($object->is_locked()) {
-        $lock_unlock = 'unlock';
-    }
-    
-    // Print lock/unlock icon
-    $html .= '<a href="report.php?report=grader&amp;target=' . $identifier
-          . "&amp;action=$lock_unlock$tree->commonvars\">\n";
-    $html .= '<img src="'.$CFG->pixpath.'/t/'.$lock_unlock.'.gif" class="iconsmall" alt="'
-          .${'str' . $lock_unlock}.'" title="'.${'str' . $lock_unlock}.'" /></a>'. "\n";
+        // Display Hide/Show icon
+        $html .= '<a href="report.php?report=grader&amp;target=' . $identifier
+              . "&amp;action=$hide_show$tree->commonvars\">\n";
+        $html .= '<img src="'.$CFG->pixpath.'/t/'.$hide_show.'.gif" class="iconsmall" alt="'
+              .${'str' . $hide_show}.'" title="'.${'str' . $hide_show}.'" /></a>'. "\n";
 
-    if ($grade) {
+        // Prepare lock/unlock string
+        $lock_unlock = 'lock';
+        if ($object->is_locked()) {
+            $lock_unlock = 'unlock';
+        }
         
+        // Print lock/unlock icon
+        $html .= '<a href="report.php?report=grader&amp;target=' . $identifier
+              . "&amp;action=$lock_unlock$tree->commonvars\">\n";
+        $html .= '<img src="'.$CFG->pixpath.'/t/'.$lock_unlock.'.gif" class="iconsmall" alt="'
+              .${'str' . $lock_unlock}.'" title="'.${'str' . $lock_unlock}.'" /></a>'. "\n";
+
+        if ($grade) {
+            
+        }
+    } else {
+        if ($USER->gradefeedback) {
+            // Display Edit/Add feedback icon
+            if (!empty($object->feedback)) {
+                $html .= '<a href="report.php?report=grader&amp;target=' . $object->id
+                      . "&amp;action=viewfeedback$tree->commonvars\">\n"; 
+                $html .= '<img onmouseover="return overlib(\''.$object->feedback.'\', CAPTION, \''
+                      . $strfeedback.'\');" onmouseout="return nd();" ' 
+                      . 'src="'.$CFG->pixpath.'/t/feedback.gif" class="iconsmall" alt="" /></a>'. "\n";
+            }            
+        }
     }
 
     return $html . '</div>';
 }
+
 ?>
diff --git a/pix/i/feedback_add.gif b/pix/i/feedback_add.gif
new file mode 100644 (file)
index 0000000..a39b5fa
Binary files /dev/null and b/pix/i/feedback_add.gif differ
diff --git a/pix/t/feedback.gif b/pix/t/feedback.gif
new file mode 100644 (file)
index 0000000..e1cf9bb
Binary files /dev/null and b/pix/t/feedback.gif differ
diff --git a/pix/t/feedback_add.gif b/pix/t/feedback_add.gif
new file mode 100644 (file)
index 0000000..742ed46
Binary files /dev/null and b/pix/t/feedback_add.gif differ