Don't show column grade when there's nothing to show
This commit is contained in:
+21
-20
@@ -61,28 +61,29 @@
|
||||
require_once($libfile);
|
||||
$gradefunction = $mod->modname."_grades";
|
||||
if (function_exists($gradefunction)) { // Skip modules without grade function
|
||||
$modgrades = $gradefunction($mod->instance);
|
||||
if ($modgrades = $gradefunction($mod->instance)) {
|
||||
|
||||
if ($modgrades->maxgrade) {
|
||||
$maxgrade = "<BR>$strmax: $modgrades->maxgrade";
|
||||
} else {
|
||||
$maxgrade = "";
|
||||
}
|
||||
|
||||
$image = "<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\"".
|
||||
" TITLE=\"$mod->modfullname\">".
|
||||
"<IMG BORDER=0 VALIGN=absmiddle SRC=\"../mod/$mod->modname/icon.gif\" ".
|
||||
"HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\"></A>";
|
||||
$columnhtml[] = "$image ".
|
||||
"<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
|
||||
"$instance->name".
|
||||
"</A>$maxgrade";
|
||||
$columns[] = "$mod->modfullname: $instance->name - $modgrades->maxgrade";
|
||||
|
||||
foreach ($students as $student) {
|
||||
$grades[$student->id][] = $modgrades->grades[$student->id]; // may be empty, that's ok
|
||||
if ($modgrades->maxgrade) {
|
||||
$totals[$student->id] = (float)($totals[$student->id]) + (float)($modgrades->grades[$student->id]);
|
||||
$maxgrade = "<BR>$strmax: $modgrades->maxgrade";
|
||||
} else {
|
||||
$maxgrade = "";
|
||||
}
|
||||
|
||||
$image = "<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\"".
|
||||
" TITLE=\"$mod->modfullname\">".
|
||||
"<IMG BORDER=0 VALIGN=absmiddle SRC=\"../mod/$mod->modname/icon.gif\" ".
|
||||
"HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\"></A>";
|
||||
$columnhtml[] = "$image ".
|
||||
"<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
|
||||
"$instance->name".
|
||||
"</A>$maxgrade";
|
||||
$columns[] = "$mod->modfullname: $instance->name - $modgrades->maxgrade";
|
||||
|
||||
foreach ($students as $student) {
|
||||
$grades[$student->id][] = $modgrades->grades[$student->id]; // may be empty, that's ok
|
||||
if ($modgrades->maxgrade) {
|
||||
$totals[$student->id] = (float)($totals[$student->id]) + (float)($modgrades->grades[$student->id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,6 +366,12 @@ function forum_grades($forumid) {
|
||||
/// Must return an array of grades, indexed by user, and a max grade.
|
||||
global $FORUM_POST_RATINGS;
|
||||
|
||||
if (!$forum = get_record("forum", "id", $forumid)) {
|
||||
return false;
|
||||
}
|
||||
if (!$forum->assessed) {
|
||||
return false;
|
||||
}
|
||||
if ($ratings = get_records_sql_menu("SELECT p.user, r.rating
|
||||
FROM forum_discussions d, forum_posts p, forum_ratings r
|
||||
WHERE d.forum = '$forumid'
|
||||
|
||||
+2
-2
@@ -34,8 +34,8 @@
|
||||
<tr valign=top>
|
||||
<td align=right><P><B><? print_string("allowdiscussions", "forum", strtolower("$course->student")) ?>:</B></P></TD>
|
||||
<td>
|
||||
<? choose_from_menu($FORUM_OPEN_MODES, "open", $form->open, ""); ?>
|
||||
<? helpbutton("allowdiscussions", get_string("allowdiscussions", "forum"), "forum") ?>
|
||||
<? choose_from_menu($FORUM_OPEN_MODES, "open", $form->open, ""); ?>
|
||||
<? helpbutton("allowdiscussions", get_string("allowdiscussions", "forum", strtolower("$course->student")), "forum") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user