Go to Last Question in Random test

jasonadal
jasonadal Community Member Posts: 447 ♪ Opening Act ♪
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.

Comments

  • jasonadal
    jasonadal Community Member Posts: 447 ♪ Opening Act ♪
    edited October 18, 2022
    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.
  • timk
    timk Community Member Posts: 1,233 ✭ Legend ✭
    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.
  • jasonadal
    jasonadal Community Member Posts: 447 ♪ Opening Act ♪
    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.
  • malqaseer3753
    malqaseer3753 Community Member Posts: 8 ♪ Opening Act ♪
    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.
  • jasonadal
    jasonadal Community Member Posts: 447 ♪ Opening Act ♪

    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...
  • CarlJFink
    CarlJFink Community Member, Lectora® Accessibility Group (LAUG) Member, eLearning Brothers® Partner Posts: 97 ☆ Superstar ☆
    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?
  • andrew-robertson
    andrew-robertson Community Member Posts: 309 ♦ Idol ♦
    CarlJFink said:

    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?

    Andrew R.
    Developing content since 2010 using a mixed bag of tools.
  • timk
    timk Community Member Posts: 1,233 ✭ Legend ✭
    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.
  • andrew-robertson
    andrew-robertson Community Member Posts: 309 ♦ Idol ♦
    timk said:

    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.
    Andrew R.
    Developing content since 2010 using a mixed bag of tools.
  • wheels
    wheels Florida USACommunity Member, Administrator, Moderator, Rockstar Manager Posts: 654 eLearning ROCKSTAR Admin Team
    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.


  • CarlJFink
    CarlJFink Community Member, Lectora® Accessibility Group (LAUG) Member, eLearning Brothers® Partner Posts: 97 ☆ Superstar ☆
    wheels said:


    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.
  • wheels
    wheels Florida USACommunity Member, Administrator, Moderator, Rockstar Manager Posts: 654 eLearning ROCKSTAR Admin Team

    @jasonadal 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');