Browse Source

Don't display grade and percent when module grade option is "No grade"

MOODLE_23_STABLE
Artem Andreev 15 years ago
parent
commit
af6443c38f
  1. 2
      lib.php
  2. 19
      locallib.php
  3. 8
      view.php

2
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;

19
locallib.php

@ -197,11 +197,9 @@ function print_row($left, $right) {
echo "\n<tr><td nowrap=\"nowrap\" align=\"right\" valign=\"top\" class=\"cell c0\">$left</td><td align=\"left\" valign=\"top\" class=\"info c1\">$right</td></tr>\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).'&nbsp;%';
$grade = get_grade($user->id, $course);
echo '<table border="0" cellpadding="0" cellspacing="0" class="list">';
print_row(get_string('sessionscompleted','attforblock').':', "<strong>$complete</strong>");
@ -209,14 +207,19 @@ function print_attendance_table($user, $course) {
foreach($statuses as $st) {
print_row($st->description.': ', '<strong>'.get_attendance($user->id, $course, $st->id).'</strong>');
}
print_row(get_string('attendancepercent','attforblock').':', "<strong>$percent</strong>");
print_row(get_string('attendancegrade','attforblock').':', "<strong>$grade</strong> / ".get_maxgrade($user->id, $course));
if ($attforblock->grade) {
$percent = get_percent($user->id, $course).'&nbsp;%';
$grade = get_grade($user->id, $course);
print_row(get_string('attendancepercent','attforblock').':', "<strong>$percent</strong>");
print_row(get_string('attendancegrade','attforblock').':', "<strong>$grade</strong> / ".get_maxgrade($user->id, $course));
}
print_row('&nbsp;', '&nbsp;');
echo '</table>';
}
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 '<table class="userinfobox">';
@ -240,7 +243,7 @@ function print_user_attendaces($user, $cm, $course = 0, $printing = null) {
echo '<hr />';
$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 '<td align="right">';
$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');
}

8
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);

Loading…
Cancel
Save