From dab563f5a66a54f212e55f1c0f8293a572e1141f Mon Sep 17 00:00:00 2001
From: Adrian Greeve <abgreeve@gmail.com>
Date: Thu, 6 Dec 2018 12:32:33 +0100
Subject: [PATCH] MDL-59081 mod_lesson: Remove continue button if not needed.

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 | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/mod/lesson/continue.php b/mod/lesson/continue.php
index 9960dafa2b7..f513a2f0aba 100644
--- a/mod/lesson/continue.php
+++ b/mod/lesson/continue.php
@@ -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'));