$icons = array('eyecons' => 'hide',
'calculations' => 'calc',
'locks' => 'lock',
- 'grandtotals' => 'sigma',
- 'notes' => 'feedback');
+ 'grandtotals' => 'sigma');
$pref_name = 'grade_report_show' . $type;
$show_pref = get_user_preferences($pref_name, $CFG->$pref_name);
$showgroups = get_user_preferences('grade_report_showgroups', $CFG->grade_report_showgroups);
$aggregation_position = get_user_preferences('grade_report_aggregationposition', $CFG->grade_report_aggregationposition);
$showscales = get_user_preferences('grade_report_showscales', $CFG->grade_report_showscales);
+$showfeedback = get_user_preferences('grade_report_showfeedback', $CFG->grade_report_showfeedback);
+$quickgrading = get_user_preferences('grade_report_quickgrading', $CFG->grade_report_quickgrading);
+$quickfeedback = get_user_preferences('grade_report_quickfeedback', $CFG->grade_report_quickfeedback);
// Override perpage if set in URL
if ($perpageurl = optional_param('perpage', 0, PARAM_INT)) {
/// setting up groups
// Prepare language strings
-$strsortasc = get_string('sortasc', 'grades');
-$strsortdesc = get_string('sortdesc', 'grades');
+$strsortasc = get_string('sortasc', 'grades');
+$strsortdesc = get_string('sortdesc', 'grades');
// base url for sorting by first/last name
$baseurl = 'report.php?id='.$courseid.'&perpage='.$perpage.'&report=grader&page='.$page;
grader_report_print_toggle('calculations', $baseurl);
}
-grader_report_print_toggle('notes', $baseurl);
+grader_report_print_toggle('feedback', $baseurl);
grader_report_print_toggle('grandtotals', $baseurl);
grader_report_print_toggle('groups', $baseurl);
grader_report_print_toggle('scales', $baseurl);
foreach ($users as $userid => $user) {
// Student name and link
-
$studentshtml .= '<tr><th class="user"><a href="' . $CFG->wwwroot . '/user/view.php?id='
. $user->id . '">' . fullname($user) . '</a></th>';
foreach ($items as $item) {
$i++;
$scaleopt[$i] = $scaleoption;
}
- $studentshtml .= choose_from_menu($scaleopt, 'grade_'.$userid.'_'.$item->id,
+
+ if ($quickgrading) {
+ $studentshtml .= choose_from_menu($scaleopt, 'grade_'.$userid.'_'.$item->id,
$gradeval, get_string('nograde'), '', -1, true);
+ } elseif ($scale = get_record('scale', 'id', $item->scaleid)) {
+ $scales = explode(",", $scale->scale);
+
+ // invalid grade if gradeval < 1
+ if ((int) $gradeval < 1) {
+ $studentshtml .= '-';
+ } else {
+ $studentshtml .= $scales[$gradeval-1];
+ }
+ } else {
+ // no such scale, throw error?
+ }
}
} else {
- $studentshtml .= '<input size="6" type="text" name="grade_'.$userid.'_'.$item->id.'" value="'.$gradeval.'"/>';
+ if ($quickgrading) {
+ $studentshtml .= '<input size="6" type="text" name="grade_'.$userid.'_'.$item->id.'" value="'.$gradeval.'"/>';
+ } else {
+ $studentshtml .= $gradeval;
+ }
+ }
+
+ $icons_html = '<div class="grade_icons">';
+
+ if (!$quickgrading) {
+ // If quickgrading is off, print an edit icon
+ $icons_html .= grade_get_icons($element, $gtree, array('edit'));
+ }
+
+ if ($showfeedback && $quickfeedback) {
+ $studentshtml .= '<input size="6" type="text" name="feedback_'.$userid.'_'.$item->id.'" value="'. @$grade->feedback . '"/>';
+ } elseif ($showfeedback) { // If quickfeedback is off but showfeedback is on, print an edit feedback icon
+ if (empty($grade->feedback)) {
+ $icons_html .= grade_get_icons($element, $gtree, array('add_feedback'));
+ } else {
+ $icons_html .= grade_get_icons($element, $gtree, array('edit_feedback'));
+ }
}
+ $icons_html .= '</div>';
+ $studentshtml .= $icons_html;
} else {
// finalgrades[$userid][$itemid] could be null because of the outer join
// in this case it's different than a 0
break;
}
}
+
redirect($CFG->wwwroot . '/grade/report.php?report=grader&id='.$courseid, get_string('changessaved'), 1);
exit;
}
/// form definition with preferences defaults
//--------------------------------------------------------------------------------
- $preferences = array('bulkcheckboxes' => 'checkbox',
- 'enableajax' => 'checkbox',
- 'showcalculations' => 'checkbox',
- 'showeyecons' => 'checkbox',
- 'showgrandtotals' => 'checkbox',
- 'showgroups' => 'checkbox',
- 'showlocks' => 'checkbox',
- 'shownotes' => 'checkbox',
- 'showscales' => 'checkbox',
+ $preferences = array('bulkcheckboxes' => 'advcheckbox',
+ 'enableajax' => 'advcheckbox',
+ 'showcalculations' => 'advcheckbox',
+ 'showeyecons' => 'advcheckbox',
+ 'showgrandtotals' => 'advcheckbox',
+ 'showgroups' => 'advcheckbox',
+ 'showlocks' => 'advcheckbox',
+ 'showfeedback' => 'advcheckbox',
+ 'showscales' => 'advcheckbox',
+ 'quickgrading' => 'advcheckbox',
+ 'quickfeedback' => 'advcheckbox',
'aggregationposition' => array(get_string('left', 'grades'), get_string('right', 'grades')),
'aggregationview' => array(get_string('full', 'grades'), get_string('compact', 'grades')),
'gradedisplaytype' => array(get_string('raw', 'grades'), get_string('percentage', 'grades')),
foreach ($preferences as $pref => $type) {
$full_pref = 'grade_report_' . $pref;
$pref_value = get_user_preferences($full_pref, $CFG->$full_pref);
-
+
$options = null;
if (is_array($type)) {
$options = $type;
$mform->setDefault($full_pref, $pref_value);
$mform->setType($full_pref, PARAM_INT);
}
-
+
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->setDefault('id', $course->id);
get_string('configgradedisplaytype', 'grades'), false,
array(get_string('raw', 'grades'), get_string('percentage', 'grades'))));
$settings->add(new admin_setting_configselect('grade_report_grandtotalsdisplaytype', get_string('grandtotalsdisplaytype', 'grades'),
- get_string('configgrandtotalsdisplaytype', 'grades'), false,
+ get_string('configgrandtotalsdisplaytype', 'grades'), false,
array(get_string('raw', 'grades'), get_string('percentage', 'grades'))));
$settings->add(new admin_setting_configcheckbox('grade_report_showcalculations', get_string('showcalculations', 'grades'),
get_string('configshowcalculations', 'grades'), 0));
get_string('configshowgrandtotals', '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_showfeedback', get_string('showfeedback', 'grades'),
+ get_string('configshowfeedback', '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_configcheckbox('grade_report_quickgrading', get_string('quickgrading', 'grades'),
+ get_string('configquickgrading', 'grades'), 1));
+$settings->add(new admin_setting_configcheckbox('grade_report_quickfeedback', get_string('quickfeedback', 'grades'),
+ get_string('configquickfeedback', 'grades'), 1));
$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'),
$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['configgrandtotalsdisplaytype'] = 'Grand totals can be shown as raw grades or as percentages (in reference to the minimum and maximum grades).';
+$string['configquickfeedback'] = 'Quick Feedback adds a text input element in each grade cell on the grader report, allowing you to edit many grades at once. You can then click the Update button to perform all these changes at once, instead of one at a time.';
+$string['configquickgrading'] = 'Quick Grading adds a text input element in each grade cell on the grader report, allowing you to edit the feedback for many grades at once. You can then click the Update button to perform all these changes at once, instead of one at a time.';
$string['configshowcalculations'] = 'Whether to show calculator icons near each grade item and category, tooltips over calculated items and a visual indicator that a column is calculated.';
$string['configshoweyecons'] = 'Whether to show an eye-con near each grade (controlling its visibility to the user).';
$string['configshowgrandtotals'] = 'Show grand totals in the grader report.';
$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['configshowfeedback'] = '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['hidegrandtotals'] = 'Hide grandtotals';
$string['hidegroups'] = 'Hide groups';
$string['hidelocks'] = 'Hide locks';
-$string['hidenotes'] = 'Hide feedback';
+$string['hidefeedback'] = 'Hide feedback';
$string['hidescales'] = 'Hide scales';
$string['highgradeascending'] = 'Sort by high grade ascending';
$string['highgradedescending'] = 'Sort by high grade descending';
$string['pointsascending'] = 'Sort by points ascending';
$string['pointsdescending'] = 'Sort by points descdending';
$string['preferences'] = 'Preferences';
+$string['quickfeedback'] = 'Quick Feedback';
+$string['quickgrading'] = 'Quick Grading';
$string['rank'] = 'Rank';
$string['raw'] = 'Raw';
$string['rawpct'] = 'Raw %%';
$string['showgrandtotals'] = 'Show grand totals';
$string['showgroups'] = 'Show groups';
$string['showlocks'] = 'Show locks';
-$string['shownotes'] = 'Show feedback';
+$string['showfeedback'] = 'Show feedback';
$string['showscales'] = 'Show scales';
$string['showhiddenitems'] = 'Show Hidden Items';
$string['sort'] = 'sort';
*
* @param object $object
* @param object $tree (A complete grade_tree object)
+ * @param array $icons An array of icon names that this function is explicitly requested to print, regardless of settings
+ * @param bool $limit If true, use the $icons array as the only icons that will be printed. If false, use it to exclude these icons.
* @return string HTML
*/
-function grade_get_icons($element, $tree) {
+function grade_get_icons($element, $tree, $icons=null, $limit=true) {
global $CFG;
global $USER;
+
// Load language strings
$straddfeedback = get_string("addfeedback", 'grades');
$stredit = get_string("edit");
$object = $element['object'];
$type = $element['type'];
+ // Add mock attributes in case the object is not of the right type
+ if ($type != 'grade') {
+ $object->feedback = '';
+ }
+
// Load user preferences
$aggregationview = get_user_preferences('grade_report_aggregationview', $CFG->grade_report_aggregationview);
$showeyecons = get_user_preferences('grade_report_showeyecons', $CFG->grade_report_showeyecons);
$showlocks = get_user_preferences('grade_report_showlocks', $CFG->grade_report_showlocks);
- $shownotes = get_user_preferences('grade_report_shownotes', $CFG->grade_report_shownotes);
+ $showfeedback = get_user_preferences('grade_report_showfeedback', $CFG->grade_report_showfeedback);
$showcalculations = get_user_preferences('grade_report_showcalculations', $CFG->grade_report_showcalculations);
+ // Prepare image strings
+ $edit_category_icon = '<a href="report/grader/edit_category.php?courseid='.$object->courseid.'&id='.$object->id.'">'
+ . '<img src="'.$CFG->pixpath.'/t/edit.gif" class="iconsmall" alt="'
+ . $stredit.'" title="'.$stredit.'" /></a>'. "\n";
+
+ $edit_item_icon = '<a href="report/grader/edit_item.php?courseid='.$object->courseid.'&id='.$object->id.'">'
+ . '<img src="'.$CFG->pixpath.'/t/edit.gif" class="iconsmall" alt="'
+ . $stredit.'" title="'.$stredit.'" /></a>'. "\n";
+
+ $edit_grade_icon = '<a href="report/grader/edit_grade.php?courseid='.$object->courseid.'&id='.$object->id.'">'
+ . '<img src="'.$CFG->pixpath.'/t/edit.gif" class="iconsmall" alt="'
+ . $stredit.'" title="'.$stredit.'" /></a>'. "\n";
+
+ $edit_calculation_icon = '<a href="report/grader/edit_calculation.php?courseid='.$object->courseid.'&id='.$object->id.'">'
+ . '<img src="'.$CFG->pixpath.'/t/calc.gif" class="iconsmall" alt="'
+ . $streditcalculation.'" title="'.$streditcalculation.'" /></a>'. "\n";
+
+ $add_feedback_icon = '<a href="report/grader/edit_feedback.php?id=' . $object->id
+ . "&action=add&courseid=$object->courseid\">\n"
+ . '<img src="'.$CFG->pixpath.'/t/feedback_add.gif" class="iconsmall" alt="'.$straddfeedback.'" '
+ . 'title="'.$straddfeedback.'" /></a>'. "\n";
+
+ $edit_feedback_icon = '<a href="report/grader/edit_feedback.php?id=' . $object->id
+ . "&action=edit&courseid=$object->courseid\">\n"
+ . '<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";
+
+ $view_feedback_icon = '<a href="report/grader/edit_feedback.php?id=' . $object->id
+ . "&action=view&courseid=$object->courseid\">\n"
+ . '<img onmouseover="return overlib(\''.$object->feedback.'\', CAPTION, \''
+ . $strfeedback.'\');" onmouseout="return nd();" '
+ . 'src="'.$CFG->pixpath.'/t/feedback.gif" class="iconsmall" alt="" /></a>'. "\n";
+
+ // Prepare Hide/Show icon state
+ $hide_show = 'hide';
+ if ($object->is_hidden()) {
+ $hide_show = 'show';
+ }
+
+ $show_hide_icon = '<a href="report.php?report=grader&target='.$eid
+ . "&action=$hide_show$tree->commonvars\">\n"
+ . '<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
+ $lock_unlock_icon = '<a href="report.php?report=grader&target='.$eid
+ . "&action=$lock_unlock$tree->commonvars\">\n"
+ . '<img src="'.$CFG->pixpath.'/t/'.$lock_unlock.'.gif" class="iconsmall" alt="'
+ . ${'str' . $lock_unlock}.'" title="'.${'str' . $lock_unlock}.'" /></a>'. "\n";
+
+ // Prepare expand/contract string
+ $expand_contract = 'switch_minus'; // Default: expanded
+ $state = get_user_preferences('grade_category_' . $object->id, GRADE_CATEGORY_EXPANDED);
+ if ($state == GRADE_CATEGORY_CONTRACTED) {
+ $expand_contract = 'switch_plus';
+ }
+
+ $contract_expand_icon = '<a href="report.php?report=grader&target=' . $eid
+ . "&action=$expand_contract$tree->commonvars\">\n"
+ . '<img src="'.$CFG->pixpath.'/t/'.$expand_contract.'.gif" class="iconsmall" alt="'
+ . ${'str' . $expand_contract}.'" title="'.${'str' . $expand_contract}.'" /></a>'. "\n";
+
+ // If an array of icon names is given, return only these in the order they are given
+ if (!empty($icons) && is_array($icons)) {
+ $new_html = '';
+
+ foreach ($icons as $icon_name) {
+ if ($icon_name == 'edit') {
+ $icon_name .= "_$type";
+ }
+ if ($limit) {
+ $new_html .= ${$icon_name . '_icon'};
+ } else {
+ ${'show_' . $icon_name} = false;
+ }
+ }
+ if ($limit) {
+ return $new_html;
+ } else {
+ $html .= $new_html;
+ }
+ }
+
// Icons shown when edit mode is on
if ($USER->gradeediting) {
// Edit icon (except for grade_grades)
if ($type == 'category') {
- $html .= '<a href="report/grader/edit_category.php?courseid='.$object->courseid.'&id='.$object->id.'">';
- $html .= '<img src="'.$CFG->pixpath.'/t/edit.gif" class="iconsmall" alt="'
- .$stredit.'" title="'.$stredit.'" /></a>'. "\n";
+ $html .= $edit_category_icon;
} else if ($type == 'item' or $type == 'courseitem' or $type == 'categoryitem') {
- $html .= '<a href="report/grader/edit_item.php?courseid='.$object->courseid.'&id='.$object->id.'">';
- $html .= '<img src="'.$CFG->pixpath.'/t/edit.gif" class="iconsmall" alt="'
- .$stredit.'" title="'.$stredit.'" /></a>'. "\n";
-
- } else if ($type == 'grade') {
- // What is the purpose of edit_grade page?
- /*
- $html .= '<a href="report/grader/edit_grade.php?courseid='.$object->courseid.'&id='.$object->id.'">';
- $html .= '<img src="'.$CFG->pixpath.'/t/edit.gif" class="iconsmall" alt="'
- .$stredit.'" title="'.$stredit.'" /></a>'. "\n";
- */
+ $html .= $edit_item_icon;
}
// Calculation icon for items and categories
if ($showcalculations && $type != 'grade') {
- $html .= '<a href="report/grader/edit_calculation.php?courseid='.$object->courseid.'&id='.$object->id.'">';
- $html .= '<img src="'.$CFG->pixpath.'/t/calc.gif" class="iconsmall" alt="'
- .$streditcalculation.'" title="'.$streditcalculation.'" /></a>'. "\n";
- }
-
- if ($shownotes) {
- // Setup object identifier and show feedback icon if applicable
- if ($type == 'grade' and $shownotes) {
- // Display Edit/Add feedback icon
- if (empty($object->feedback)) {
- $html .= '<a href="report/grader/edit_feedback.php?id=' . $object->id
- . "&action=add&courseid=$object->courseid\">\n";
- $html .= '<img src="'.$CFG->pixpath.'/t/feedback_add.gif" class="iconsmall" alt="'.$straddfeedback.'" '
- . 'title="'.$straddfeedback.'" /></a>'. "\n";
- } else {
- $html .= '<a href="report/grader/edit_feedback.php?id=' . $object->id
- . "&action=edit&courseid=$object->courseid\">\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";
- }
- }
+ $html .= $edit_calculation_icon;
}
if ($showeyecons) {
-
- // Prepare Hide/Show icon state
- $hide_show = 'hide';
- if ($object->is_hidden()) {
- $hide_show = 'show';
- }
-
- // Display Hide/Show icon
- $html .= '<a href="report.php?report=grader&target='.$eid
- . "&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";
+ $html .= $show_hide_icon;
}
if ($showlocks) {
- // 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='.$eid
- . "&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";
+ $html .= $lock_unlock_icon;
}
// If object is a category, display expand/contract icon
if (get_class($object) == 'grade_category' && $aggregationview == GRADER_REPORT_AGGREGATION_VIEW_COMPACT) {
- $expand_contract = 'switch_minus'; // Default: expanded
-
- $state = get_user_preferences('grade_category_' . $object->id, GRADE_CATEGORY_EXPANDED);
-
- if ($state == GRADE_CATEGORY_CONTRACTED) {
- $expand_contract = 'switch_plus';
- }
-
- $html .= '<a href="report.php?report=grader&target=' . $eid
- . "&action=$expand_contract$tree->commonvars\">\n";
- $html .= '<img src="'.$CFG->pixpath.'/t/'.$expand_contract.'.gif" class="iconsmall" alt="'
- .${'str' . $expand_contract}.'" title="'.${'str' . $expand_contract}.'" /></a>'. "\n";
+ $html .= $contract_expand_icon;
}
} else { // Editing mode is off
- if ($shownotes) {
+ if ($showfeedback) {
// Display view feedback icon
if (!empty($object->feedback)) {
- $html .= '<a href="report/grader/edit_feedback.php?id=' . $object->id
- . "&action=view&courseid=$object->courseid\">\n";
- $html .= '<img onmouseover="return overlib(\''.$object->feedback.'\', CAPTION, \''
- . $strfeedback.'\');" onmouseout="return nd();" '
- . 'src="'.$CFG->pixpath.'/t/feedback.gif" class="iconsmall" alt="" /></a>'. "\n";
+ $html .= $view_feedback_icon;
}
}
}
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
- $version = 2007070900; // YYYYMMDD = date
+ $version = 2007070902; // YYYYMMDD = date
// XY = increments within a single day
$release = '1.9 dev'; // Human-friendly version name