V1 QUESTIONNAIRE INSTALLATION

2 min readLast updated

Implementing Exam System

This example demonstrates how to set up an exam system by using the StartExam export. This system is customizable, allowing you to define exam settings, shuffle questions, set minimum passing criteria, and more.

1

Define the Exam Structure

Use the StartExam export to create your exam. You will need to define the following parameters: title – Name of the exam description – Short explanation of the exam logo – URL to an image/logo minimum – Minimum correct answers required to pass shuffleQuestions – Set to true to randomise questions amountOfQuestionsToShow – Number of questions shown per exam questions – Table of all exam questions

2

Add Questions

Populate the questions table with your exam content. Each question must include: question – The question text answers – A table of possible answers (with unique keys) correctAnswer – The key of the correct answer

3

Set Passing Conditions

Configure how the exam is graded: Set minimum to define how many correct answers are required to pass Enable shuffleQuestions if you want each attempt to be randomised

4

Run the Exam

Call the StartExam function with your configured data. Example:

lua
1
local result = exports['ap-questionnaire']:StartExam({     title = "Driving Test",     description = "Basic road knowledge exam",     logo = "https://your-logo-url.com/image.png",     minimum = 3,     shuffleQuestions = true,     amountOfQuestionsToShow = 5,     questions = {         {             question = "What does a red light mean?",             answers = {                 a = "Stop",                 b = "Go",                 c = "Slow down"             },             correctAnswer = "a"         }     } })
5

Handle Results

Use the returned result to determine if the player passed or failed. Example:

lua
1
if result then     print('Exam passed') else     print('Exam failed') end
6

Restart Server

Restart your server to apply all changes.

Example Code

lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
local StartExam = exports['ap-questionnaire']:StartExam({
    title = 'Police Exam',
    Description = 'This exam is to be taken to see if you are able to become a police officer.',
    Logo = 'https://www.policeinspire.co.uk/wp-content/uploads/2020/11/online-study-platform-vector.svg',
    Minimum = 4, -- Minimum questions needed to pass.
    ShuffleQuestions = true, -- Shuffle questions so they are not in order.
    AmountOfQuestionsToShow = 5, -- Show only a selected number of questions.
    Questions = {
        [1] = {
            question = 'What is the primary responsibility of a police officer?',
            answers = { a = 'To enforce the law and maintain order', b = 'To create laws', c = 'To serve as a judge', d = 'To write constitutions' },
            correctAnswer = 'a',
        },
        -- Add more questions as needed
    },
})
if startExam then
    print('Exam passed')
else
    print('Exam failed')
end

Was this page helpful?

© 2026 AP Scripts. Engineered for excellence.