This commit is contained in:
nicolasconnault 2007-07-08 14:51:41 +00:00
parent a9b24e489b
commit 9aa1e44853
2 changed files with 72 additions and 57 deletions

View File

@ -53,11 +53,12 @@ $type = optional_param('type', 0, PARAM_ALPHA);
$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)) {
@ -215,7 +216,7 @@ if (is_numeric($sortitemid)) {
// 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
@ -385,7 +386,7 @@ foreach ($gtree->levels as $key=>$row) {
$items[$element['object']->sortorder] =& $element['object'];
}
}
$headerhtml .= '</tr>';
@ -480,12 +481,12 @@ foreach ($users as $userid => $user) {
// 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
@ -499,11 +500,11 @@ if ($currentgroup && ($displaygrouptotals || 1)) {
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>';
@ -511,7 +512,7 @@ if ($currentgroup && ($displaygrouptotals || 1)) {
}
$groupsumhtml .= '</tr>';
} else {
$groupsumhtml = '';
$groupsumhtml = '';
}
// user preference not implemented yet
@ -519,10 +520,10 @@ if ($displaytotals || 1) {
/** 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)
@ -538,7 +539,7 @@ if ($displaytotals || 1) {
$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>';
@ -546,7 +547,7 @@ if ($displaytotals || 1) {
}
$gradesumhtml .= '</tr>';
} else {
$gradesumhtml = '';
$gradesumhtml = '';
}
$reporthtml = "<table class=\"boxaligncenter\">$headerhtml";
@ -574,13 +575,13 @@ if ($USER->gradeediting) {
// remove trailing 0s and "."s
function get_grade_clean($gradeval) {
if ($gradeval != 0) {
$gradeval = trim($gradeval, ".0");
} else {
$gradeval = 0;
}
return $gradeval;
}
?>

View File

@ -755,7 +755,11 @@ function grade_get_icons($element, $tree) {
$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) {
@ -776,56 +780,66 @@ function grade_get_icons($element, $tree) {
$html .= '<a href="report/grader/edit_grade.php?courseid='.$object->courseid.'&amp;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.'&amp;id='.$object->id.'">';
$html .= '<img src="'.$CFG->pixpath.'/t/calc.gif" class="iconsmall" alt="'
.$streditcalculation.'" title="'.$streditcalculation.'" /></a>'. "\n";
.$streditcalculation.'" title="'.$streditcalculation.'" /></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 ($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
. "&amp;action=add&amp;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
. "&amp;action=edit&amp;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";
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
. "&amp;action=add&amp;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
. "&amp;action=edit&amp;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";
}
}
}
// Display Hide/Show icon
$html .= '<a href="report.php?report=grader&amp;target='.$eid
. "&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 ($showeyecons) {
// Prepare lock/unlock string
$lock_unlock = 'lock';
if ($object->is_locked()) {
$lock_unlock = 'unlock';
// 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&amp;target='.$eid
. "&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";
}
// Print lock/unlock icon
$html .= '<a href="report.php?report=grader&amp;target='.$eid
. "&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 ($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&amp;target='.$eid
. "&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 object is a category, display expand/contract icon
if (get_class($object) == 'grade_category' && $aggregationview == GRADER_REPORT_AGGREGATION_VIEW_COMPACT) {
@ -843,7 +857,7 @@ function grade_get_icons($element, $tree) {
.${'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