MDL-10209 MDL-10211

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.
This commit is contained in:
nicolasconnault 2007-06-28 11:15:12 +00:00
parent 74c9f514ab
commit 1ec74ea5aa
7 changed files with 128 additions and 61 deletions

View 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
@ -97,8 +98,19 @@
} else if (($edit == 0) and confirm_sesskey()) {
$USER->gradeediting = 0;
}
// Setup feedback mode
if (!isset($USER->gradefeedback)) {
$USER->gradefeedback = 0;
}
// params for the turn editting on button
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 and feedback buttons
$options['id'] = $courseid;
$options['report'] = $report;
@ -113,8 +125,20 @@
$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));

View 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>';

View 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';

View 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";
}
// 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";
}
// 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;
}
$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 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) {
// 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";
}
}
}
// 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";
// 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>';
}
?>

BIN
pix/i/feedback_add.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 B

BIN
pix/t/feedback.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

BIN
pix/t/feedback_add.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 B