From 4db9d14dad0f9a92cc468b92dbf48f8cf185c879 Mon Sep 17 00:00:00 2001 From: moodler Date: Mon, 21 Oct 2002 08:19:15 +0000 Subject: [PATCH] Don't show column grade when there's nothing to show --- course/grades.php | 41 +++++++++++++++++++++-------------------- mod/forum/lib.php | 6 ++++++ mod/forum/mod.html | 4 ++-- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/course/grades.php b/course/grades.php index 95de6f5c82..5d030f0c77 100644 --- a/course/grades.php +++ b/course/grades.php @@ -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 = "
$strmax: $modgrades->maxgrade"; - } else { - $maxgrade = ""; - } - - $image = "wwwroot/mod/$mod->modname/view.php?id=$mod->id\"". - " TITLE=\"$mod->modfullname\">". - "modname/icon.gif\" ". - "HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">"; - $columnhtml[] = "$image ". - "wwwroot/mod/$mod->modname/view.php?id=$mod->id\">". - "$instance->name". - "$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 = "
$strmax: $modgrades->maxgrade"; + } else { + $maxgrade = ""; + } + + $image = "wwwroot/mod/$mod->modname/view.php?id=$mod->id\"". + " TITLE=\"$mod->modfullname\">". + "modname/icon.gif\" ". + "HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">"; + $columnhtml[] = "$image ". + "wwwroot/mod/$mod->modname/view.php?id=$mod->id\">". + "$instance->name". + "$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]); + } } } } diff --git a/mod/forum/lib.php b/mod/forum/lib.php index d981ff2ee1..d3a344ceba 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -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' diff --git a/mod/forum/mod.html b/mod/forum/mod.html index 0016350d50..83ad44bfa8 100644 --- a/mod/forum/mod.html +++ b/mod/forum/mod.html @@ -34,8 +34,8 @@

student")) ?>:

- open, ""); ?> - + open, ""); ?> + student")), "forum") ?> -- 2.39.5