MDL-59081 mod_lesson: Remove continue button if not needed.
authorAdrian Greeve <abgreeve@gmail.com>
Thu, 6 Dec 2018 11:32:33 +0000 (12:32 +0100)
committerAdrian Greeve <abgreeve@gmail.com>
Fri, 29 Mar 2019 06:14:01 +0000 (14:14 +0800)
This checks to see if the continue button goes to the same
page as the try again button and removes it if it does.

mod/lesson/continue.php

index 9960daf..f513a2f 100644 (file)
@@ -117,9 +117,14 @@ if (!$result->correctanswer && !$result->noanswer && !$result->isessayquestion &
 }
 
 $url = new moodle_url('/mod/lesson/view.php', array('id'=>$cm->id, 'pageid'=>$result->newpageid));
+
 if ($lesson->review && !$result->correctanswer && !$result->noanswer && !$result->isessayquestion && !$result->maxattemptsreached) {
-    // Button to continue the lesson (the page to go is configured by the teacher).
-    echo $OUTPUT->single_button($url, get_string('reviewquestioncontinue', 'lesson'));
+    // If both the "Yes, I'd like to try again" and "No, I just want to go on  to the next question" point to the same
+    // page then don't show the "No, I just want to go on to the next question" button. It's confusing.
+    if ($page->id != $result->newpageid) {
+        // Button to continue the lesson (the page to go is configured by the teacher).
+        echo $OUTPUT->single_button($url, get_string('reviewquestioncontinue', 'lesson'));
+    }
 } else {
     // Normal continue button
     echo $OUTPUT->single_button($url, get_string('continue', 'lesson'));