We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Building randomized quizzes from a question pool, looking for the best approach

dylandamico
Tera Contributor

I'm looking to build a quiz system in ServiceNow with the following requirements:

1. Question Pool
Each quiz should draw from its own dedicated pool of questions. Ideally, I'd also like the option to split that pool into multiple categories within a single quiz.

2. Randomization
Every time a user starts a quiz, the system should pull (x amount of) questions at random from the pool, so each attempt produces a different quiz. The answer order should be randomized as well.

3. Results & Review
As soon as the user finishes, I want to display all the questions (grouped by category, where applicable) along with the correct answers. Users should also be able to expand each question to see a brief explanation of the answer, possibly using Now Assist to generate these explanations dynamically. Importantly, users should be able to revisit this results overview at any time in the future, not only right after completing the quiz.

Has anyone built something similar? I'd appreciate any guidance on the best workflow for all of this, how to handle the randomization specifically, and whether Now Assist is a good fit for this use case at all.

Is there an out-of-the-box option that covers any of this, or is it going to require a fully custom implementation?

Thanks in advance!

1 ACCEPTED SOLUTION

Pavan Srivastav
ServiceNow Employee
This use case aligns well with ServiceNow’s custom application capabilities using UI Builder, Flow Designer, and AI integration (Now Assist). Here is a clear breakdown:
 
________________________________________
OOB Capabilities  
  • ServiceNow does not provide an out-of-the-box quiz or exam module.
  • Related OOB features include Survey Management (for questionnaires) and the Assessment Engine; however:
  • Surveys do not support dynamic randomization.
  • Assessments use fixed question sets without random selection per attempt.
  • This means a custom solution is required, though it can leverage existing platform components.
  • ________________________________________
  • Recommended Workflow & Components
  • Suggested architecture:
  • ________________________________________
  1. Question Pool & Categories
  • Create a custom table: quiz_question with the following columns:
    • question_text (String)
    • category (String or reference to quiz_category)
    • answers (array or linked table for multiple options)
    • correct_answer (reference to answer)
    • explanation (optional text field)
  • Create an additional table: quiz_category to organise quiz categories.
  • A single quiz can include multiple categories.
  •  
  • ________________________________________
  1. Randomization Logic
  • Implement a server-side Script Include or Flow in Flow Designer.
  • Inputs: Quiz ID and number of questions per category.
  • Use GlideRecord with addQuery() for filtering.
  • Apply randomisation as follows:
    • var gr = new GlideRecord('quiz_question');
    • gr.addQuery('quiz', quizId);
    • gr.addQuery('category', category);
    • gr.orderBy('RAND()');
    • gr.setLimit(numQuestions);
  •  
  • For randomising answer order:
  • Store answers as related records and shuffle using a JavaScript array sort with Math.random() before rendering in UI Builder.
  •  
  • ________________________________________
  1. Results & Review
  • After quiz submission:
    • Store responses in the quiz_attempt table (User → Quiz → Answers → Timestamp).
    • Generate a results page in UI Builder:
    • Display questions grouped by category.
    • Highlight correct answers and user selections.
    • Provide expandable explanations or invoke Now Assist to generate explanations dynamically:
    • var payload = { question: q, correctAnswer: a };
  •  
  • Enable historical review:
    • Provide access via “My Completed Quizzes” using quiz_attempt records.
  •  
  • ________________________________________
  • Where Does Now Assist Fit?
  • Generate contextual explanations for correct answers dynamically.
  • Respond to user queries such as “Why is this answer correct?” or “Explain category X” using semantic search or generative AI.
  •  
  • ________________________________________
  • Implementation Components
  • UI Layer: UI Builder (Configurable Workspace or custom experience)
  • Logic: Flow Designer or Script Includes
  • Data: Custom tables (quiz_question, quiz_category, quiz_attempt)
  • AI: Now Assist for post-submission explanations
  •  
  • ________________________________________
  • OOB Check
  • Surveys and Assessments do not meet requirements for randomisation, categorisation, and persistent review.
  • A custom-built solution is recommended, leveraging:
    • OOB platform APIs
    • Flow Designer for orchestration
    • Now Assist for dynamic explanations

View solution in original post

2 REPLIES 2

Pavan Srivastav
ServiceNow Employee
This use case aligns well with ServiceNow’s custom application capabilities using UI Builder, Flow Designer, and AI integration (Now Assist). Here is a clear breakdown:
 
________________________________________
OOB Capabilities  
  • ServiceNow does not provide an out-of-the-box quiz or exam module.
  • Related OOB features include Survey Management (for questionnaires) and the Assessment Engine; however:
  • Surveys do not support dynamic randomization.
  • Assessments use fixed question sets without random selection per attempt.
  • This means a custom solution is required, though it can leverage existing platform components.
  • ________________________________________
  • Recommended Workflow & Components
  • Suggested architecture:
  • ________________________________________
  1. Question Pool & Categories
  • Create a custom table: quiz_question with the following columns:
    • question_text (String)
    • category (String or reference to quiz_category)
    • answers (array or linked table for multiple options)
    • correct_answer (reference to answer)
    • explanation (optional text field)
  • Create an additional table: quiz_category to organise quiz categories.
  • A single quiz can include multiple categories.
  •  
  • ________________________________________
  1. Randomization Logic
  • Implement a server-side Script Include or Flow in Flow Designer.
  • Inputs: Quiz ID and number of questions per category.
  • Use GlideRecord with addQuery() for filtering.
  • Apply randomisation as follows:
    • var gr = new GlideRecord('quiz_question');
    • gr.addQuery('quiz', quizId);
    • gr.addQuery('category', category);
    • gr.orderBy('RAND()');
    • gr.setLimit(numQuestions);
  •  
  • For randomising answer order:
  • Store answers as related records and shuffle using a JavaScript array sort with Math.random() before rendering in UI Builder.
  •  
  • ________________________________________
  1. Results & Review
  • After quiz submission:
    • Store responses in the quiz_attempt table (User → Quiz → Answers → Timestamp).
    • Generate a results page in UI Builder:
    • Display questions grouped by category.
    • Highlight correct answers and user selections.
    • Provide expandable explanations or invoke Now Assist to generate explanations dynamically:
    • var payload = { question: q, correctAnswer: a };
  •  
  • Enable historical review:
    • Provide access via “My Completed Quizzes” using quiz_attempt records.
  •  
  • ________________________________________
  • Where Does Now Assist Fit?
  • Generate contextual explanations for correct answers dynamically.
  • Respond to user queries such as “Why is this answer correct?” or “Explain category X” using semantic search or generative AI.
  •  
  • ________________________________________
  • Implementation Components
  • UI Layer: UI Builder (Configurable Workspace or custom experience)
  • Logic: Flow Designer or Script Includes
  • Data: Custom tables (quiz_question, quiz_category, quiz_attempt)
  • AI: Now Assist for post-submission explanations
  •  
  • ________________________________________
  • OOB Check
  • Surveys and Assessments do not meet requirements for randomisation, categorisation, and persistent review.
  • A custom-built solution is recommended, leveraging:
    • OOB platform APIs
    • Flow Designer for orchestration
    • Now Assist for dynamic explanations

Thank you for the detailed answer. I'll start working on this now, but I'll likely have more questions as I go. Hope you don't mind that 🙂