Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-31775

"Start at last page seen" function broken in Moodle 2

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.7, 2.1.5, 2.2.2
    • Fix Version/s: 2.1.6, 2.2.3
    • Component/s: Lesson
    • Labels:
    • Testing Instructions:
      Hide

      Create a Lesson
      Settings:
      Practice lesson No
      Re-takes allowed Yes.

      Create 5 question pages
      On each page, create a multiple choice question with Answer 1 (correct) Jump to next page
      and Answer 2 (incorrect) Jump to this page

      Log in as student and attempt lesson
      Answer the questions on pages 1 through 3 (always select the correct choice).
      On page 4, log out.

      Log again and re-attempt Lesson
      You should see this message:
      "You have seen more than one page of this lesson already. Do you want to start at the last page you saw?" answer Yes
      Check that you are taken to page 4.

      Show
      Create a Lesson Settings: Practice lesson No Re-takes allowed Yes. Create 5 question pages On each page, create a multiple choice question with Answer 1 (correct) Jump to next page and Answer 2 (incorrect) Jump to this page Log in as student and attempt lesson Answer the questions on pages 1 through 3 (always select the correct choice). On page 4, log out. Log again and re-attempt Lesson You should see this message: "You have seen more than one page of this lesson already. Do you want to start at the last page you saw?" answer Yes Check that you are taken to page 4.
    • Workaround:
      Hide

      in <yourmoodle>/mod/lesson/locallib.php, around line 1029, in:
      public function get_attempts($retries, $correct=false, $pageid=null, $userid=null)
      replace
      return $DB->get_records('lesson_attempts', $params, 'timeseen ASC');
      with
      return $DB->get_records('lesson_attempts', $params, 'timeseen DESC');
      but this needs more testing

      Show
      in <yourmoodle>/mod/lesson/locallib.php, around line 1029, in: public function get_attempts($retries, $correct=false, $pageid=null, $userid=null) replace return $DB->get_records('lesson_attempts', $params, 'timeseen ASC'); with return $DB->get_records('lesson_attempts', $params, 'timeseen DESC'); but this needs more testing
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      "Start at last page seen" function broken in Moodle 2.
      See this discussion http://moodle.org/mod/forum/discuss.php?d=196918

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            salvetore Michael de Raadt added a comment -

            Thanks for reporting that and providing a potential solution.

            Show
            salvetore Michael de Raadt added a comment - Thanks for reporting that and providing a potential solution.
            Hide
            ankit_frenz Ankit Agarwal added a comment -

            Looks good
            +1 to integrate!

            Show
            ankit_frenz Ankit Agarwal added a comment - Looks good +1 to integrate!
            Hide
            rwijaya Rossiani Wijaya added a comment -

            Thanks Ankit for reviewing.

            Submitting for integration review.

            Show
            rwijaya Rossiani Wijaya added a comment - Thanks Ankit for reviewing. Submitting for integration review.
            Hide
            poltawski Dan Poltawski added a comment -

            It took me a while to understand how this fixed the bug - then I spotted this was a for loop only running once through the array! Wow!

            Show
            poltawski Dan Poltawski added a comment - It took me a while to understand how this fixed the bug - then I spotted this was a for loop only running once through the array! Wow!
            Hide
            poltawski Dan Poltawski added a comment -

            Thanks Rosie, that has been integrated now!

            Show
            poltawski Dan Poltawski added a comment - Thanks Rosie, that has been integrated now!
            Hide
            rezeau Joseph Rézeau added a comment - - edited

            Tested on moodle 22

            the Start at last page seen feature works OK now, but with debug ON I'm getting these errors:

            Notice: Trying to get property of non-object in moodle\mod\lesson\view.php on line 198

            Notice: Trying to get property of non-object in moodle\mod\lesson\view.php on line 201

            I suggest adding the following condition:

            if ($attempt) {
            	        $jumpto = $DB->get_field('lesson_answers', 'jumpto', array('id' => $attempt->answerid));
            	        // convert the jumpto to a proper page id
            	        if ($jumpto == 0) { // unlikely value!
            	            $lastpageseen = $attempt->pageid;
            	        } elseif ($jumpto == LESSON_NEXTPAGE) {
            	            if (!$lastpageseen = $DB->get_field('lesson_pages', 'nextpageid', array('id' => $attempt->pageid))) {
            	                // no nextpage go to end of lesson
            	                $lastpageseen = LESSON_EOL;
            	            }
            	        } else {
            	            $lastpageseen = $jumpto;
            	        }
                    }

            Show
            rezeau Joseph Rézeau added a comment - - edited Tested on moodle 22 the Start at last page seen feature works OK now, but with debug ON I'm getting these errors: Notice: Trying to get property of non-object in moodle\mod\lesson\view.php on line 198 Notice: Trying to get property of non-object in moodle\mod\lesson\view.php on line 201 I suggest adding the following condition: if ($attempt) { $jumpto = $DB->get_field('lesson_answers', 'jumpto', array('id' => $attempt->answerid)); // convert the jumpto to a proper page id if ($jumpto == 0) { // unlikely value! $lastpageseen = $attempt->pageid; } elseif ($jumpto == LESSON_NEXTPAGE) { if (!$lastpageseen = $DB->get_field('lesson_pages', 'nextpageid', array('id' => $attempt->pageid))) { // no nextpage go to end of lesson $lastpageseen = LESSON_EOL; } } else { $lastpageseen = $jumpto; } }
            Hide
            rwijaya Rossiani Wijaya added a comment -

            Hi Joseph,

            Thank you for testing the issue. I've created a new issue to fix the notice errors (MDL-32195).

            Show
            rwijaya Rossiani Wijaya added a comment - Hi Joseph, Thank you for testing the issue. I've created a new issue to fix the notice errors ( MDL-32195 ).
            Hide
            poltawski Dan Poltawski added a comment -

            Just marking this as failed to reset the process

            Show
            poltawski Dan Poltawski added a comment - Just marking this as failed to reset the process
            Hide
            poltawski Dan Poltawski added a comment -

            I've pushed the fixes the issues reported by Joseph as part of this issue.

            So this issue is ready for testing again.

            (I didn't do it in MDL-32195 as unfortunately the branches there didn't apply cleanly (as not on top of current integration branch).

            thanks everyone

            Show
            poltawski Dan Poltawski added a comment - I've pushed the fixes the issues reported by Joseph as part of this issue. So this issue is ready for testing again. (I didn't do it in MDL-32195 as unfortunately the branches there didn't apply cleanly (as not on top of current integration branch). thanks everyone
            Hide
            phalacee Jason Fowler added a comment -

            Just a quick note on accessibility - the "Yes" and "No" options presented to the user should probably be buttons rather than links ...

            Show
            phalacee Jason Fowler added a comment - Just a quick note on accessibility - the "Yes" and "No" options presented to the user should probably be buttons rather than links ...
            Hide
            phalacee Jason Fowler added a comment -

            Test passed perfectly in all the fixed-for versions of moodle

            Show
            phalacee Jason Fowler added a comment - Test passed perfectly in all the fixed-for versions of moodle
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            And this has landed upstream, finally! Yay!

            תודה רבה && شكرا جزيلا



            Closing, ciao

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - And this has landed upstream, finally! Yay! תודה רבה && شكرا جزيلا Closing, ciao
            Hide
            codeone David Wolff added a comment -

            Where (in the file) do we put the patch Joseph suggests? Is the a specific line number? I have changed the ASC to DESC but clicking Yes does not allow the user to continue. Wondering if Joseph's patch is the key?

            Show
            codeone David Wolff added a comment - Where (in the file) do we put the patch Joseph suggests? Is the a specific line number? I have changed the ASC to DESC but clicking Yes does not allow the user to continue. Wondering if Joseph's patch is the key?
            Hide
            rezeau Joseph Rézeau added a comment -

            @David,
            Which version of Moodle are you using?

            Show
            rezeau Joseph Rézeau added a comment - @David, Which version of Moodle are you using?
            Hide
            codeone David Wolff added a comment -

            The installation with the current issue is Moodle 2.1.2+ (Build: 20111019)

            Show
            codeone David Wolff added a comment - The installation with the current issue is Moodle 2.1.2+ (Build: 20111019)
            Hide
            rezeau Joseph Rézeau added a comment -

            @David,
            Any chance you could update to a more current version of Moodle (2.4) where the bug has been fixed?

            Show
            rezeau Joseph Rézeau added a comment - @David, Any chance you could update to a more current version of Moodle (2.4) where the bug has been fixed?
            Hide
            codeone David Wolff added a comment -

            That is in the works but still months in the future (new server required etc.) I was hoping this fix would work until then.

            Show
            codeone David Wolff added a comment - That is in the works but still months in the future (new server required etc.) I was hoping this fix would work until then.
            Hide
            rezeau Joseph Rézeau added a comment -

            @David, the oldest version of Moodle on my test site that I can test this on is Moodle 2.1.7+ (Build: 20120719).
            I do not see any problem, the Lesson "start at last page seen" function works as expected.
            Surely you could at least upgrade to 2.1.7+, this is only a minor upgrade from 2.1.2.
            Joseph

            Show
            rezeau Joseph Rézeau added a comment - @David, the oldest version of Moodle on my test site that I can test this on is Moodle 2.1.7+ (Build: 20120719). I do not see any problem, the Lesson "start at last page seen" function works as expected. Surely you could at least upgrade to 2.1.7+, this is only a minor upgrade from 2.1.2. Joseph
            Hide
            codeone David Wolff added a comment -

            Upgrading is something I have ever done. Is this upgrade simple to do? I thought the fix or maybe even a copy of the php file in question from a newer version would work. I am more of an advanced user than anything and can muddle through some things like installations and configurations but upgrading? Would upgrading itself fix the problem?

            Show
            codeone David Wolff added a comment - Upgrading is something I have ever done. Is this upgrade simple to do? I thought the fix or maybe even a copy of the php file in question from a newer version would work. I am more of an advanced user than anything and can muddle through some things like installations and configurations but upgrading? Would upgrading itself fix the problem?
            Hide
            codeone David Wolff added a comment -

            I can't find a 2.1.7, would 2.1.10 be the wise choice? Also, I can't find any specific info on this upgrade. Any direction to the appropriate documentation?

            Show
            codeone David Wolff added a comment - I can't find a 2.1.7, would 2.1.10 be the wise choice? Also, I can't find any specific info on this upgrade. Any direction to the appropriate documentation?
            Hide
            rezeau Joseph Rézeau added a comment -

            Yes, go for 2.1.10.
            Instructions for upgrade really depend on how you have installed your Moodle site in the first place.
            Try the Moodle documentation or the General problems forum for help.

            Show
            rezeau Joseph Rézeau added a comment - Yes, go for 2.1.10. Instructions for upgrade really depend on how you have installed your Moodle site in the first place. Try the Moodle documentation or the General problems forum for help.
            Hide
            codeone David Wolff added a comment -

            Ok. But before we try the upgrade, where in the php file (what line) do we put your patch? I would like to try that first because it seems easiest. If that doesn't work, we will look at the upgrade to 2.1.10 until we get our new server this summer.

            Show
            codeone David Wolff added a comment - Ok. But before we try the upgrade, where in the php file (what line) do we put your patch? I would like to try that first because it seems easiest. If that doesn't work, we will look at the upgrade to 2.1.10 until we get our new server this summer.
            Hide
            rezeau Joseph Rézeau added a comment -

            @David,
            I understand your problem but, since I no longer have that "old" moodle 2.1.2 version available I cannot test the patch I provided some time ago.
            Can you confirm that you are getting the problem I reported first in this bug report? Can you describe it?

            Show
            rezeau Joseph Rézeau added a comment - @David, I understand your problem but, since I no longer have that "old" moodle 2.1.2 version available I cannot test the patch I provided some time ago. Can you confirm that you are getting the problem I reported first in this bug report? Can you describe it?
            Hide
            codeone David Wolff added a comment -

            The problem I have is when you click on yes, you are not taken back to your page last seen. You are taken back to page 2 (sometimes page 4) (out of a possible 34 pages) in the tests I conducted on my lesson. I can't see why the tests returned me back to different pages other than maybe one test having correct answers and one test having incorrect answers.

            I followed the first patch and changed ASC to DESC with no change. I thought your additional patch would help as the comments after your patch on the tracker all said the problem was resolved.

            Show
            codeone David Wolff added a comment - The problem I have is when you click on yes, you are not taken back to your page last seen. You are taken back to page 2 (sometimes page 4) (out of a possible 34 pages) in the tests I conducted on my lesson. I can't see why the tests returned me back to different pages other than maybe one test having correct answers and one test having incorrect answers. I followed the first patch and changed ASC to DESC with no change. I thought your additional patch would help as the comments after your patch on the tracker all said the problem was resolved.
            Hide
            codeone David Wolff added a comment - - edited

            Joseph, I upgraded to 2.1.10. It went pretty smoothly.

            I tested the lesson. No change. I did discover something though. With the line in lessonlib.php set to ASC, the participant is always sent back to page 5 of 33. With the line set to DESC, the participant is sent back to page 10 of 33.

            My lesson has a question on every page, some are multiple choice, some are multiple-answer multiple choice, and some are matching. The pages the participant is brought back to are both matching questions, regardless of exiting the lesson on a multiple choice or matching question.

            I don't know what to do here. Is it the matching questions? Also, I notice your test says "select the right answer" Does selecting the wrong answer have something to do with it?

            Show
            codeone David Wolff added a comment - - edited Joseph, I upgraded to 2.1.10. It went pretty smoothly. I tested the lesson. No change. I did discover something though. With the line in lessonlib.php set to ASC, the participant is always sent back to page 5 of 33. With the line set to DESC, the participant is sent back to page 10 of 33. My lesson has a question on every page, some are multiple choice, some are multiple-answer multiple choice, and some are matching. The pages the participant is brought back to are both matching questions, regardless of exiting the lesson on a multiple choice or matching question. I don't know what to do here. Is it the matching questions? Also, I notice your test says "select the right answer" Does selecting the wrong answer have something to do with it?
            Hide
            rezeau Joseph Rézeau added a comment -

            @David, the best I can do at this stage is to experiment with your own Lesson instance.
            Please do the following:
            Go to the course where your 33-question Lesson exists and back-up that course, making sure to un-tick everything except that Lesson; do NOT include users in the back-up.
            Send me the export file so I can restore and test it on my moodle 2.1 local test site.
            Send to moodle@rezeau.org and then we can continue the discussion through e-mail.
            Joseph

            Show
            rezeau Joseph Rézeau added a comment - @David, the best I can do at this stage is to experiment with your own Lesson instance. Please do the following: Go to the course where your 33-question Lesson exists and back-up that course, making sure to un-tick everything except that Lesson; do NOT include users in the back-up. Send me the export file so I can restore and test it on my moodle 2.1 local test site. Send to moodle@rezeau.org and then we can continue the discussion through e-mail. Joseph

              People

              • Votes:
                2 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/May/12