diff --git a/grade/lib.php b/grade/lib.php
index 4422b0b0a06..d52193afd9c 100644
--- a/grade/lib.php
+++ b/grade/lib.php
@@ -3045,8 +3045,9 @@ function print_student_grade($user, $course) {
$sections = get_all_sections($course->id); // Sort everything the same as the course
// prints table
-
- echo ('
| '.get_string('activity').' | '.get_string('yourgrade','grades').' | '.get_string('maxgrade','grades').' |
');
+
+ // flag for detecting whether to print table header or not
+ $nograde = 0;
for ($i=0; $i<=$course->numsections; $i++) {
if (isset($sections[$i])) { // should always be true
@@ -3078,6 +3079,10 @@ function print_student_grade($user, $course) {
}
if ($maxgrade) {
+ if (!$nograde) {
+ echo ('| '.get_string('activity').' | '.get_string('yourgrade','grades').' | '.get_string('maxgrade','grades').' |
');
+ }
+ $nograde++;
$link_id = grade_get_module_link($course->id, $mod->instance, $mod->module);
$link = $CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$link_id->id;
@@ -3085,7 +3090,8 @@ function print_student_grade($user, $course) {
echo '';
if (!empty($modgrades->grades[$user->id])) {
$currentgrade = $modgrades->grades[$user->id];
- echo "| $mod->modfullname: ".format_string($instance->name,true)." | $currentgrade | $maxgrade | "; } else {
+ echo "$mod->modfullname: ".format_string($instance->name,true)." | $currentgrade | $maxgrade | ";
+ } else {
echo "$mod->modfullname: ".format_string($instance->name,true)." | ".get_string('nograde')." | $maxgrade | ";
}
echo '
';
@@ -3097,7 +3103,10 @@ function print_student_grade($user, $course) {
}
}
} // a new Moodle nesting record? ;-)
- echo '
';
+
+ if ($nograde) {
+ echo '
';
+ }
}
function grade_get_course_students($courseid) {