$target = optional_param('target', 0, PARAM_ALPHANUM);
// Get the user preferences
-$perpage = get_user_preferences('grade_report_studentsperpage', $CFG->grade_report_studentsperpage); // number of users on a page
-$decimals = get_user_preferences('grade_report_decimalpoints', $CFG->grade_report_decimalpoints); // decimals in grades
-$displaytotals = get_user_preferences('grade_report_showgrandtotals', $CFG->grade_report_showgrandtotals);
-$displaygrouptotals = get_user_preferences('grade_report_showgroups', $CFG->grade_report_showgroups);
+$perpage = get_user_preferences('grade_report_studentsperpage', $CFG->grade_report_studentsperpage); // number of users on a page
+$decimals = get_user_preferences('grade_report_decimalpoints', $CFG->grade_report_decimalpoints); // decimals in grades
+$displaytotals = get_user_preferences('grade_report_showgrandtotals', $CFG->grade_report_showgrandtotals);
+$displaygrouptotals = 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);
// Override perpage if set in URL
if ($perpageurl = optional_param('perpage', 0, PARAM_INT)) {
// get users sorted by lastname
$users = get_role_users(@implode(',', $CFG->gradebookroles), $context, false, 'u.id, u.firstname, u.lastname', 'u.'.$sortitemid .' '. $sortorder, false, $page * $perpage, $perpage, $currentgroup);
// need to cut users down by groups
-
+
}
/// count total records for paging
$items[$element['object']->sortorder] =& $element['object'];
}
-
+
}
$headerhtml .= '</tr>';
// if user preference to display group sum
if ($currentgroup && ($displaygrouptotals || 1)) {
-
+
/** SQL for finding group sum */
- $SQL = "SELECT g.itemid, SUM(g.finalgrade) as sum
+ $SQL = "SELECT g.itemid, SUM(g.finalgrade) as sum
FROM {$CFG->prefix}grade_items gi LEFT JOIN
{$CFG->prefix}grade_grades g ON gi.id = g.itemid RIGHT OUTER JOIN
- {$CFG->prefix}user u ON u.id = g.userid LEFT JOIN
+ {$CFG->prefix}user u ON u.id = g.userid LEFT JOIN
{$CFG->prefix}role_assignments ra ON u.id = ra.userid
$groupsql
WHERE gi.courseid = $courseid
foreach ($sums as $itemid => $csum) {
$groupsum[$itemid] = $csum;
}
-
+
$groupsumhtml = '<tr><th>Group total</th>';
foreach ($items as $item) {
if (!isset($groupsum[$item->id])) {
- $groupsumhtml .= '<td>-</td>';
+ $groupsumhtml .= '<td>-</td>';
} else {
$sum = $groupsum[$item->id];
$groupsumhtml .= '<td>'.get_grade_clean($sum->sum).'</td>';
}
$groupsumhtml .= '</tr>';
} else {
- $groupsumhtml = '';
+ $groupsumhtml = '';
}
// user preference not implemented yet
/** SQL for finding the SUM grades of all visible users ($CFG->gradebookroles) */
- $SQL = "SELECT g.itemid, SUM(g.finalgrade) as sum
+ $SQL = "SELECT g.itemid, SUM(g.finalgrade) as sum
FROM {$CFG->prefix}grade_items gi LEFT JOIN
{$CFG->prefix}grade_grades g ON gi.id = g.itemid RIGHT OUTER JOIN
- {$CFG->prefix}user u ON u.id = g.userid LEFT JOIN
+ {$CFG->prefix}user u ON u.id = g.userid LEFT JOIN
{$CFG->prefix}role_assignments ra ON u.id = ra.userid
WHERE gi.courseid = $courseid
AND ra.roleid in ($gradebookroles)
$gradesumhtml = '<tr><th>Total</th>';
foreach ($items as $item) {
if (!isset($classsum[$item->id])) {
- $gradesumhtml .= '<td>-</td>';
+ $gradesumhtml .= '<td>-</td>';
} else {
$sum = $classsum[$item->id];
$gradesumhtml .= '<td>'.get_grade_clean($sum->sum).'</td>';
}
$gradesumhtml .= '</tr>';
} else {
- $gradesumhtml = '';
+ $gradesumhtml = '';
}
$reporthtml = "<table class=\"boxaligncenter\">$headerhtml";
// remove trailing 0s and "."s
function get_grade_clean($gradeval) {
-
+
if ($gradeval != 0) {
$gradeval = trim($gradeval, ".0");
} else {
$gradeval = 0;
}
-
+
return $gradeval;
}
?>
$type = $element['type'];
// Load user preferences
- $aggregationview = get_user_preferences('grade_report_aggregationview', $CFG->grade_report_aggregationview);
+ $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_notes', $CFG->grade_report_notes);
+ $showcalculations = get_user_preferences('grade_report_showcalculations', $CFG->grade_report_showcalculations);
// Icons shown when edit mode is on
if ($USER->gradeediting) {
$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";
- */
+ */
}
-
+
+ /* Not sure if there is a good reason to have a calculation icon: the calculation field is in the grade_edit form */
+ /*
// Calculation icon for items and categories
if ($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";
+ .$streditcalculation.'" title="'.$streditcalculation.'" /></a>'. "\n";
+ }
+ */
+
+ if ($shownotes) {
+ // Setup object identifier and show feedback icon if applicable
+ if ($type == 'grade' and $USER->gradefeedback) {
+ // 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";
+ }
+ }
}
- // Prepare Hide/Show icon state
- $hide_show = 'hide';
- if ($object->is_hidden()) {
- $hide_show = 'show';
- }
+ if ($showeyecons) {
- // Setup object identifier and show feedback icon if applicable
- if ($type == 'grade' and $USER->gradefeedback) {
- // 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";
+ // 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";
}
- // 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";
+ if ($showlocks) {
+ // Prepare lock/unlock string
+ $lock_unlock = 'lock';
+ if ($object->is_locked()) {
+ $lock_unlock = 'unlock';
+ }
- // 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";
}
- // 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";
-
// 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
.${'str' . $expand_contract}.'" title="'.${'str' . $expand_contract}.'" /></a>'. "\n";
}
} else {
- if ($USER->gradefeedback) {
+ if ($shownotes) {
// Display view feedback icon
if (!empty($object->feedback)) {
$html .= '<a href="report/grader/edit_feedback.php?id=' . $object->id