From 49aaac3e6f10969084c2354576b3fec747ffd479 Mon Sep 17 00:00:00 2001 From: Jean-Michel Vedrine Date: Thu, 30 Oct 2014 22:17:03 +0100 Subject: [PATCH] MDL-18553 Lesson: No gradeinfo display if lesson grade is zero --- mod/lesson/view.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/mod/lesson/view.php b/mod/lesson/view.php index ab18c3bf448..789dc2806d1 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -27,6 +27,7 @@ require_once(dirname(__FILE__) . '/../../config.php'); require_once($CFG->dirroot.'/mod/lesson/locallib.php'); require_once($CFG->dirroot.'/mod/lesson/view_form.php'); require_once($CFG->libdir . '/completionlib.php'); +require_once($CFG->libdir . '/gradelib.php'); $id = required_param('id', PARAM_INT); // Course Module ID $pageid = optional_param('pageid', null, PARAM_INT); // Lesson Page ID @@ -329,12 +330,14 @@ if ($pageid != LESSON_EOL) { $lesson->add_message(get_string('numberofpagesviewednotice', 'lesson', $a)); } - $a = new stdClass; - $a->grade = number_format($gradeinfo->grade * $lesson->grade / 100, 1); - $a->total = $lesson->grade; if (!$reviewmode && !$lesson->retake){ $lesson->add_message(get_string("numberofcorrectanswers", "lesson", $gradeinfo->earned), 'notify'); - $lesson->add_message(get_string('yourcurrentgradeisoutof', 'lesson', $a), 'notify'); + if ($lesson->grade != GRADE_TYPE_NONE) { + $a = new stdClass; + $a->grade = number_format($gradeinfo->grade * $lesson->grade / 100, 1); + $a->total = $lesson->grade; + $lesson->add_message(get_string('yourcurrentgradeisoutof', 'lesson', $a), 'notify'); + } } } } @@ -460,10 +463,12 @@ if ($pageid != LESSON_EOL) { } else { $lessoncontent .= $OUTPUT->box(get_string("displayscorewithoutessays", "lesson", $a), 'center'); } - $a = new stdClass; - $a->grade = number_format($gradeinfo->grade * $lesson->grade / 100, 1); - $a->total = $lesson->grade; - $lessoncontent .= $lessonoutput->paragraph(get_string("yourcurrentgradeisoutof", "lesson", $a), 'center'); + if ($lesson->grade != GRADE_TYPE_NONE) { + $a = new stdClass; + $a->grade = number_format($gradeinfo->grade * $lesson->grade / 100, 1); + $a->total = $lesson->grade; + $lessoncontent .= $lessonoutput->paragraph(get_string("yourcurrentgradeisoutof", "lesson", $a), 'center'); + } $grade = new stdClass(); $grade->lessonid = $lesson->id; @@ -508,7 +513,9 @@ if ($pageid != LESSON_EOL) { } else { // display for teacher - $lessoncontent .= $lessonoutput->paragraph(get_string("displayofgrade", "lesson"), 'center'); + if ($lesson->grade != GRADE_TYPE_NONE) { + $lessoncontent .= $lessonoutput->paragraph(get_string("displayofgrade", "lesson"), 'center'); + } } $lessoncontent .= $OUTPUT->box_end(); //End of Lesson button to Continue. -- 2.11.4.GIT