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.
$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));
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()) {
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 = '';
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 = '';
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 = '';
. $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;
}
$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>';
}
}
$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>';
}
}
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);
$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
}
}
+ // 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>';
$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';
$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!';
$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';
$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';
*/
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");
$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()
- . "&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()
+ . "&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&target=' . $identifier
- . "&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&target=' . $object->id
+ . "&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&target=' . $object->id
+ . "&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&target=' . $identifier
- . "&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&target=' . $identifier
+ . "&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&target=' . $identifier
+ . "&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&target=' . $object->id
+ . "&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>';
}
+
?>