Go to Last Question in Random test

Hi all! Long time no chat!

I have a randomized test where the student is allowed to exit the test, return to "learning" part of the course, then at any time, return to test. The goal is that they would return to the last question they were asked. However, I'm yet to figure out how to do that.

I'm setting Lectora to use simplified page names, so each page is "page123567" etc.

I saw an older post with a possible solution for Lectora Online, but it's going back to 2018 (I'm currently on Lectora 19).

There's clearly a process where the "Last Visited Page" is set, since it's an action in the "Go To" options. However, the question is, what's that variable? I feel like if I know that variable, I can sort it to do something like:

In the test, on each page:

OnPageLoad:

Set VAR ReturnToPage = LastVisitedPage

In the "lesson" section, on a button that says "Resume test":

OnClick

Set VAR LastVisitedPage = ReturnToPage

Go To Last visited page

I'm thinking adding the step to set the last visited page to the button in case "Last Visited" is also used to indicate the "Previous" page.

It's been awhile, so I'm hoping this makes sense - I'd upload my course, but it's pretty hefty, so I'll work on a smaller scale sample to post.

Discussion (13)

Ok, here's a quick sample with 4 "learning" pages, the test as I have it set up. The "Resume Test" button is set as "Go To ". However, clicking on it after starting the test brings you back to the first question you were asked rather than the LAST question you were asked or started on.

Within the test, using the "Cancel test" option works fine, since it goes to a "placeholder" page that only needs to use "Go to Last Visited Page" in order to resume.

Hi Jason welcome back,

The action "Go to last visited page" uses the browser history. I'm not sure it can easily be used to navigate to a specific page.

I would save the test page in a variable and use the javascript version of the Goto action to navigate.

If you're in an LMS Lectora saves the page in the bookmark, AICC_Lesson_Location. Just put this into another variable on Page show while in the test. When a user leaves the test it should contain the correct value.

Let the button Run javascript:

trivExitPage(VarYourVariable.getValue(),true);

Add another action to the button that uses the variable in a Lectora action.

Thanks, Tim - I discovered another method inspired by your suggestion and some additional research and have it working, though I'm yet to test it on an LMS. It might be a little "dirty", but it functions at least in a HTML published format.

Essentially, what I did was have a button on the test page with a Run JS to get the current URL (window.location.href) and push it to a custom Lectora variable. Once that's done, the button goes back to the "learning section".

In the learning section, there's a "return to assessment" that uses JavaScript to set a variable to the value of the custom Lectora variable, then use the function "window.location.href" to go to the last question.

I'm confident that this will also work as a PageShow in the assessment. The next hurdle to overcome is bypassing the requirement to answer the question before being allowed back to the learning section.

I hope I'm wrong here, but I don't think you will be able to get this logic to work.

You might be able to work around breaking out of the randomized test using Javascript, easily (relying on Lectora's defined actions would throw you an error when you publish) but when you return to the randomized test, the randomization of the question pages, the number of attempts and scores would not have your intended behaviour for this test.

I hope I'm wrong here, but I don't think you will be able to get this logic to work.

You might be able to work around breaking out of the randomized test using Javascript, easily (relying on Lectora's defined actions would throw you an error when you publish) but when you return to the randomized test, the randomization of the question pages, the number of attempts and scores would not have your intended behaviour for this test.

The combination of in-Lectora variable sets and JavaScript variable sets does work in both Run mode and when published to HTML. On our LMS, however, it ends up failing. It gets the correct URL/page name, alerts it back to me correctly EXCEPT for a random extra slash in the URL.

However, it still redirects to the last question asked, but then closes the course window. Part of me wonders if it's specifically because it's opening in a separate window vs. separate tab - I don't think I pop up window is treated the same as a "baked in" window in terms of targeting URLs.

Back to the drawing board to see if I can sort a separate window solution...

My question is, how do you prevent the test from changing its randomization order every time you reload it?

The only way I can see to do this would be to basically write your own test system in JavaScript, which would rather defeat the purpose of using Lectora, wouldn't it?

The only way I can see to do this would be to basically write your own test system in JavaScript, which would rather defeat the purpose of using Lectora, wouldn't it?

I was thinking this too, as it would provide me more opportunity and flexibility to build in some nice enhancements that aren't already in Lectora. Do you know of a variable or data location that I can get all the pages that are listed within chapter?

Isn't the test newly randomized only when reset?

You wouldn't have to rebuild the whole test system. You only need a randomized array of the pages for navigation and a custom calculation of the score.

Do you know of the array that holds these details of hand? If not, I am sure I can dissect the code.

Isn't the test newly randomized only when reset?

You wouldn't have to rebuild the whole test system. You only need a randomized array of the pages for navigation and a custom calculation of the score.

There are a number of challenges with exiting and returning to a randomized test.

  • When navigating away from a randomized test it is processed / scored.
  • When navigating to a randomized test it will visit a randomized page.

Maybe tests should only randomize once and then maintain the state for each user. If someone wanted to reorder it they could do Reset. Then we wouldn't have all the other special cases that come with a randomized test, we could handle them the same :o

It would also be nice to have an action to save current page to a variable and navigate to page from variable.

It would also be nice to have an action to save current page to a variable and navigate to page from variable.

As Andrew says, it would be nice if a JS array existed to tell the developer which pages were visited/answered already.

However, it still redirects to the last question asked, but then closes the course window. 

I don't know what version you are working with. It might be closing the window because it isn't expecting a navigation to happen. This use to be blocked in the older versions, and would cause those unexpected browser closing events.

Try doing a Run JavaScript action before the navigation back to the test page with this script:

saveVariable( 'TrivantisEPS', 'T'); 

Hi all - Thanks for all the comments, as it's quite a bit to think about. I've only gotten to replying now since I'm a victim of whatever issue is going on with no emails sent on any form of interaction, whether it be on the forums here or from ReviewLink when comments are added.

I had to abandon the use of the JavaScript I'd come up with for the return to actions, as it was resulting in the window closing. It may be something I'll look into for the future.

For now, I'm using an "Exit/Cancel" to go to a separate page that allows the user to return to the quiz or go back to the content. In the content, there's a button with a "GoTo" action that goes to the "section level" of the test. This takes them back into the test and the first question they answered. Their previous answers and question status is saved and in the same order they were initially presented. I have no way of knowing if the next new question they get would be the one they would have if they just continued, but it's not really an issue either way.

Thanks again to everyone for the feedback and apologies for the month-long absence from the thread.

Also, I'm still running on 19, as this project was started and so far along before I got 21, that I won't be converting to 21 until after release.