From 0a1ef2f264f985985406986aa1f806ea6547f8bd Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Wed, 27 Jun 2007 16:15:23 +0000 Subject: [PATCH] MDL-10211 First set of icons --- grade/report/grader/index.php | 80 +++++++++++++++++++++++++---------- lib/gradelib.php | 32 +++++++++----- 2 files changed, 80 insertions(+), 32 deletions(-) diff --git a/grade/report/grader/index.php b/grade/report/grader/index.php index bc6db1a9b2..73df5ee26b 100644 --- a/grade/report/grader/index.php +++ b/grade/report/grader/index.php @@ -200,9 +200,10 @@ if (empty($users)) { // phase 2 sql, we supply the userids in this query, and get all the grades // pulls out all the grades, this does not need to worry about paging -$sql = "SELECT g.id, g.itemid, g.userid, g.finalgrade - FROM {$CFG->prefix}grade_grades g, - {$CFG->prefix}grade_items gi +$sql = "SELECT g.id, g.itemid, g.userid, g.finalgrade, g.hidden, g.locked, g.locktime, gt.feedback + FROM {$CFG->prefix}grade_items gi, + {$CFG->prefix}grade_grades g + LEFT JOIN {$CFG->prefix}grade_grades_text gt ON g.itemid = gt.itemid AND g.userid = gt.userid WHERE g.itemid = gi.id AND gi.courseid = $courseid $userselect"; @@ -213,7 +214,7 @@ $finalgrades = array(); if ($grades = get_records_sql($sql)) { foreach ($grades as $grade) { - $finalgrades[$grade->userid][$grade->itemid] = $grade->finalgrade; + $finalgrades[$grade->userid][$grade->itemid] = $grade; } } @@ -250,9 +251,9 @@ $cathtml = ' '; if ($sortitemid === 'lastname') { if ($sortorder == 'ASC') { - $lastarrow = ' '; + $lastarrow = ' '; } else { - $lastarrow = ' '; + $lastarrow = ' '; } } else { $lastarrow = ''; @@ -260,9 +261,9 @@ if ($sortitemid === 'lastname') { if ($sortitemid === 'firstname') { if ($sortorder == 'ASC') { - $firstarrow = ' '; + $firstarrow = ' '; } else { - $firstarrow = ' '; + $firstarrow = ' '; } } else { $firstarrow = ''; @@ -285,29 +286,46 @@ foreach ($tree as $topcat) { if ($item['object']->id == $sortitemid) { if ($sortorder == 'ASC') { - $arrow = ' '; + $arrow = ' '; } else { - $arrow = ' '; + $arrow = ' '; } } else { $arrow = ''; - } - $itemhtml .= ''. $item['object']->itemname . '' . $arrow; - // Print icons - $itemhtml .= grade_get_icons($item['object'], $gtree) . ''; + // Print icons if grade editing is on + if ($USER->gradeediting) { + $itemhtml .= grade_get_icons($item['object'], $gtree) . ''; + } + $items[] = $item; } if ($cat['object'] == 'filler') { $cathtml .= ' '; } else { + $dimmed = ''; + if ($cat['object']->is_hidden()) { + $dimmed = 'class="dimmed_text"'; + } + $cat['object']->load_grade_item(); - $cathtml .= '' . $cat['object']->fullname; - // Print icons - $cathtml .= grade_get_icons($cat['object'], $gtree) . ''; + $cathtml .= '' . $cat['object']->fullname; + + // Print icons if grade editing is on + if ($USER->gradeediting) { + $cathtml .= grade_get_icons($cat['object'], $gtree) . ''; + } } } @@ -318,9 +336,17 @@ foreach ($tree as $topcat) { } $topcathtml .= ' '; } else { - $topcathtml .= '' . $topcat['object']->fullname; - // Print icons - $topcathtml .= grade_get_icons($topcat['object'], $gtree) . ''; + $dimmed = ''; + if ($topcat['object']->is_hidden()) { + $dimmed = 'class="dimmed_text"'; + } + + $topcathtml .= '' . $topcat['object']->fullname; + + // Print icons if grade editing is on + if ($USER->gradeediting) { + $topcathtml .= grade_get_icons($topcat['object'], $gtree) . ''; + } } } @@ -334,14 +360,19 @@ foreach ($users as $userid => $user) { $studentshtml .= ''; if (isset($finalgrades[$userid][$item['object']->id])) { - $gradeval = $finalgrades[$userid][$item['object']->id]; + $gradeval = $finalgrades[$userid][$item['object']->id]->finalgrade; + $grade_grades = new grade_grades($finalgrades[$userid][$item['object']->id], false); } else { $gradeval = '-'; + $grade_grades = new grade_grades(array('userid' => $userid, 'itemid' => $item['object']->id), false); } // if in editting mode, we need to print either a text box // or a drop down (for scales) if ($USER->gradeediting) { + // We need to retrieve each grade_grade object from DB in order to + // know if they are hidden/locked + if ($item['object']->scaleid) { if ($scale = get_record('scale', 'id', $item['object']->scaleid)) { $scales = explode(",", $scale->scale); @@ -356,6 +387,11 @@ foreach ($users as $userid => $user) { } else { $studentshtml .= ''; } + + // 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 @@ -392,7 +428,7 @@ $reporthtml .= ""; // print submit button if ($USER->gradeediting) { - echo '
'; + echo ''; echo '
'; echo ''; echo ''; diff --git a/lib/gradelib.php b/lib/gradelib.php index df816ed7a6..0399068e05 100644 --- a/lib/gradelib.php +++ b/lib/gradelib.php @@ -683,6 +683,7 @@ function grade_oldgradebook_upgrade($courseid) { * with the icons needed for the grader report. * * @param object $object + * @param object $tree (A complete grade_tree object) * @return string HTML */ function grade_get_icons($object, $tree) { @@ -701,13 +702,15 @@ function grade_get_icons($object, $tree) { $strlock = get_string("lock", 'grades'); $strunlock = get_string("unlock", 'grades'); - $html = '
img
'; + $html = '
'; - // Edit icon - $html .= 'commonvars\">\n"; - $html .= ''
-          .$stredit.''. "\n"; + // Edit icon (except for grade_grades) + if (get_class($object) != 'grade_grades') { + $html .= 'commonvars\">\n"; + $html .= ''
+              .$stredit.''. "\n"; + } // Hide/Show icon $hide_show = 'hide'; @@ -715,7 +718,13 @@ function grade_get_icons($object, $tree) { $hide_show = 'show'; } - $html .= 'commonvars\">\n"; $html .= ''
           .${'str' . $hide_show}.''. "\n"; @@ -725,14 +734,17 @@ function grade_get_icons($object, $tree) { if ($object->is_locked()) { $lock_unlock = 'unlock'; } + // Print lock/unlock icon - $html .= 'commonvars\">\n"; $html .= ''
           .${'str' . $lock_unlock}.''. "\n"; + if ($grade) { + + } - // Lock/Unlock icon - return $html; + return $html . '
'; } ?> -- 2.39.5