I'm using EE for a basic assessment platform and the questions (entries) are presented to the user need to be in a random order from a fixed list so that the order of questions changes per user.

{exp:channel:entries entry_id="{embed:ids}" orderby="random" dynamic="no" limit="1"} 

This simplified format refreshes the channel:entries loop and results in repeated questions.

How can I ensure that the entry_ids sent through the embed aren't repeated as the user paginates through the entries 1 by 1?


1 Answer 1


There's two issues - the generation of the original ids in the parent and your example not using pagination. You've not given the code for how the entry IDs are generated in the parent, but will it always be different upon each visit for the same user or it generates the same entry IDs?

Assuming that the parent is generating the same Entry ID list for that user consistently, it sounds like you're just repeating the page each time (based on the code you provided), therefore it's randomising each time. Use Pagintion instead:

{exp:channel:entries entry_id="{embed:ids}" orderby="random" dynamic="no" limit="1" paginate="bottom"} 

  Question stuff here.

    <p>Question {current_page} of {total_pages}</p>
    {if next_page}
        <a href="{auto_path}">Next Page</a>
        <a href="completed URL here">Finished</a>

Pagination will build the random order for all results found (the unchanging entry ID list), then only display one question on screen. When using the pagination links, it will refer to the original order created, not regenerate each time.

If the parent that creates the {embed:ids} is generating them differently on each page load, try saving the entry ID list to a session variable instead, and if it exists, use it rather than generate a new list.

{if '{exp:session_variables:get name="question-order"}'}
    Don't generate
    {embed=..... ids="{exp:session_variables:get name="question-order"}"}
    {exp:session_variables:set name="question-order" value="generated entry IDs"}
    {embed=..... ids="generated entry IDs"}

Then once the assessment is complete, clear the variables:

{exp:session_variables:delete name="question-order"}
  • Thanks for taking the time to think this through. Session Variables looks ideal - I'll check it out. Mar 23, 2015 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.