Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Don't show column grade when there's nothing to show

  • Loading branch information...
commit 4db9d14dad0f9a92cc468b92dbf48f8cf185c879 1 parent caadf00
moodler authored

Showing 3 changed files with 29 additions and 22 deletions. Show diff stats Hide diff stats

  1. +21 20 course/grades.php
  2. +6 0 mod/forum/lib.php
  3. +2 2 mod/forum/mod.html
41 course/grades.php
@@ -61,28 +61,29 @@
61 61 require_once($libfile);
62 62 $gradefunction = $mod->modname."_grades";
63 63 if (function_exists($gradefunction)) { // Skip modules without grade function
64   - $modgrades = $gradefunction($mod->instance);
  64 + if ($modgrades = $gradefunction($mod->instance)) {
65 65
66   - if ($modgrades->maxgrade) {
67   - $maxgrade = "<BR>$strmax: $modgrades->maxgrade";
68   - } else {
69   - $maxgrade = "";
70   - }
71   -
72   - $image = "<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\"".
73   - " TITLE=\"$mod->modfullname\">".
74   - "<IMG BORDER=0 VALIGN=absmiddle SRC=\"../mod/$mod->modname/icon.gif\" ".
75   - "HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\"></A>";
76   - $columnhtml[] = "$image ".
77   - "<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
78   - "$instance->name".
79   - "</A>$maxgrade";
80   - $columns[] = "$mod->modfullname: $instance->name - $modgrades->maxgrade";
81   -
82   - foreach ($students as $student) {
83   - $grades[$student->id][] = $modgrades->grades[$student->id]; // may be empty, that's ok
84 66 if ($modgrades->maxgrade) {
85   - $totals[$student->id] = (float)($totals[$student->id]) + (float)($modgrades->grades[$student->id]);
  67 + $maxgrade = "<BR>$strmax: $modgrades->maxgrade";
  68 + } else {
  69 + $maxgrade = "";
  70 + }
  71 +
  72 + $image = "<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\"".
  73 + " TITLE=\"$mod->modfullname\">".
  74 + "<IMG BORDER=0 VALIGN=absmiddle SRC=\"../mod/$mod->modname/icon.gif\" ".
  75 + "HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\"></A>";
  76 + $columnhtml[] = "$image ".
  77 + "<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
  78 + "$instance->name".
  79 + "</A>$maxgrade";
  80 + $columns[] = "$mod->modfullname: $instance->name - $modgrades->maxgrade";
  81 +
  82 + foreach ($students as $student) {
  83 + $grades[$student->id][] = $modgrades->grades[$student->id]; // may be empty, that's ok
  84 + if ($modgrades->maxgrade) {
  85 + $totals[$student->id] = (float)($totals[$student->id]) + (float)($modgrades->grades[$student->id]);
  86 + }
86 87 }
87 88 }
88 89 }
6 mod/forum/lib.php
@@ -366,6 +366,12 @@ function forum_grades($forumid) {
366 366 /// Must return an array of grades, indexed by user, and a max grade.
367 367 global $FORUM_POST_RATINGS;
368 368
  369 + if (!$forum = get_record("forum", "id", $forumid)) {
  370 + return false;
  371 + }
  372 + if (!$forum->assessed) {
  373 + return false;
  374 + }
369 375 if ($ratings = get_records_sql_menu("SELECT p.user, r.rating
370 376 FROM forum_discussions d, forum_posts p, forum_ratings r
371 377 WHERE d.forum = '$forumid'
4 mod/forum/mod.html
@@ -34,8 +34,8 @@
34 34 <tr valign=top>
35 35 <td align=right><P><B><? print_string("allowdiscussions", "forum", strtolower("$course->student")) ?>:</B></P></TD>
36 36 <td>
37   - <? choose_from_menu($FORUM_OPEN_MODES, "open", $form->open, ""); ?>
38   - <? helpbutton("allowdiscussions", get_string("allowdiscussions", "forum"), "forum") ?>
  37 + <? choose_from_menu($FORUM_OPEN_MODES, "open", $form->open, ""); ?>
  38 + <? helpbutton("allowdiscussions", get_string("allowdiscussions", "forum", strtolower("$course->student")), "forum") ?>
39 39 </td>
40 40 </tr>
41 41

0 comments on commit 4db9d14

Please sign in to comment.
Something went wrong with that request. Please try again.