From af6443c38f081d11f717768f2242afadcbb26a6a Mon Sep 17 00:00:00 2001 From: Artem Andreev Date: Mon, 12 Jul 2010 15:11:46 +0400 Subject: [PATCH] Don't display grade and percent when module grade option is "No grade" --- lib.php | 2 +- locallib.php | 19 +++++++++++-------- view.php | 8 ++++---- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib.php b/lib.php index eabf781..e1bc832 100644 --- a/lib.php +++ b/lib.php @@ -187,7 +187,7 @@ function attforblock_user_complete($course, $user, $mod, $attforblock) { // if (! $cm = get_coursemodule_from_instance("attforblock", $attforblock->id, $course->id)) { // error("Course Module ID was incorrect"); // } - print_user_attendaces($user, $mod, $course); + print_user_attendaces($user, $mod, $attforblock, $course); } //return true; diff --git a/locallib.php b/locallib.php index 817e1d5..f452ab0 100644 --- a/locallib.php +++ b/locallib.php @@ -197,11 +197,9 @@ function print_row($left, $right) { echo "\n$left$right\n"; } -function print_attendance_table($user, $course) { +function print_attendance_table($user, $course, $attforblock) { $complete = get_attendance($user->id, $course); - $percent = get_percent($user->id, $course).' %'; - $grade = get_grade($user->id, $course); echo ''; print_row(get_string('sessionscompleted','attforblock').':', "$complete"); @@ -209,14 +207,19 @@ function print_attendance_table($user, $course) { foreach($statuses as $st) { print_row($st->description.': ', ''.get_attendance($user->id, $course, $st->id).''); } - print_row(get_string('attendancepercent','attforblock').':', "$percent"); - print_row(get_string('attendancegrade','attforblock').':', "$grade / ".get_maxgrade($user->id, $course)); + + if ($attforblock->grade) { + $percent = get_percent($user->id, $course).' %'; + $grade = get_grade($user->id, $course); + print_row(get_string('attendancepercent','attforblock').':', "$percent"); + print_row(get_string('attendancegrade','attforblock').':', "$grade / ".get_maxgrade($user->id, $course)); + } print_row(' ', ' '); echo '
'; } -function print_user_attendaces($user, $cm, $course = 0, $printing = null) { +function print_user_attendaces($user, $cm, $attforblock, $course = 0, $printing = null) { global $CFG, $COURSE, $mode; echo ''; @@ -240,7 +243,7 @@ function print_user_attendaces($user, $cm, $course = 0, $printing = null) { echo '
'; $complete = get_attendance($user->id, $course); if($complete) { - print_attendance_table($user, $course); + print_attendance_table($user, $course, $attforblock); } else { echo get_string('attendancenotstarted','attforblock'); } @@ -261,7 +264,7 @@ function print_user_attendaces($user, $cm, $course = 0, $printing = null) { echo '
'; $complete = get_attendance($user->id, $nextcourse); if($complete) { - print_attendance_table($user, $nextcourse); + print_attendance_table($user, $nextcourse, $attforblock); } else { echo get_string('attendancenotstarted','attforblock'); } diff --git a/view.php b/view.php index 3393fbe..f3bfeec 100644 --- a/view.php +++ b/view.php @@ -78,10 +78,10 @@ if ($printing) { if ($mode === 'thiscourse') { print_header('', $course->fullname.' - '.get_string('attendancereport','attforblock')); - print_user_attendaces($user, $cm, $course, 'printing'); + print_user_attendaces($user, $cm, $attforblock, $course, 'printing'); } else { print_header('', get_string('attendancereport','attforblock')); - print_user_attendaces($user, $cm, 0, 'printing'); + print_user_attendaces($user, $cm, $attforblock, 0, 'printing'); } exit(); } @@ -108,9 +108,9 @@ print_tabs(array($toprow), $currenttab); if ($mode === 'thiscourse') { - print_user_attendaces($user, $cm, $course); + print_user_attendaces($user, $cm, $attforblock, $course); } else { - print_user_attendaces($user, $cm); + print_user_attendaces($user, $cm, $attforblock); } print_footer($course);