While Quiz And Survey Master is feature-rich, there are many times that you will want to extend the plugin even further. All of the API for Quiz and Survey Master is built into a wrapper class called Plugin Helper.
This class is stored in the main plugin class. To access the plugin helper class, you can use the class like this:
global $mlwQuizMasterNext; $mlwQuizMasterNext->pluginHelper->register_question_type();
You can use the API to do a variety of things such as:
- Creating new tabs in the Edit Quiz/Survey page
- Registering new CSS templates
- Registering new question types
- Registering new settings
- and much more…
QSM rest APIs
This documentation provides information on how to use the Quiz and Survey Master (QSM) plugin’s API to interact with quizzes and survey data. The API includes the following endpoints:
- Get Questions
- Get Quiz
- Submit Quiz
- Get Result
Each API endpoint requires authentication for processing requests. To authenticate, navigate to the QSM global settings page and access the Quiz API Options tab. Generate your API key and update the API permission options by enabling the desired checkboxes for each API request.
Once authentication is set up, you can use the following request parameters and usage instructions for each API endpoint:
Get Quiz Info
- Route:
/wp-json/qsm/quiz
- Method: GET
- Description: Retrieve information about a specific quiz by providing its quizId.
- Headers:
authorization
(required) - Request Parameters:
quizId
: The ID of the quiz to retrieve information for.limit
: Limit the number of quizzes to be fetched in a request (default limit is 10).quiz_name
: Return all quizzes that contain the provided name or letter.from_date
: Format (YYYY-MM-DD) – returns the quizzes with the date after and including that date.
- Response: JSON data containing information about the specified parameters.
Get Quiz Result Info
- Route:
/wp-json/qsm/quiz_result/
- Method: GET
- Description: Retrieve information about a specific quiz result by providing its result ID.
- Headers:
authorization
(required) - Request Parameters:
result_id
: The ID of the quiz result to retrieve information for.limit
: Limit the number of results to be fetched in a request (default limit is 10).quizId
: To get results for a specific quiz.name
: Name of the user (required to enter fullname).email
: Email of the user (required to enter full email).from_date
: Format (YYYY-MM-DD) – returns the results with the date after and including that date.order
: ASC/DESC. By default, ASC.s
: Search all result data with quizname, name, email that contains the provided string or letter.
- Response: JSON data containing information about the specified quiz result.
Get Quiz Questions
- Route:
/wp-json/qsm/get_questions
- Method: GET
- Description: Retrieve a list of quiz questions.
- Headers:
authorization
(required) - Request Parameters:
question_id
: The ID of the question to retrieve information for.question_name
: Return all questions that contain the provided name or letter.quizId
: Returns all the questions for the given quiz ID.limit
: Limit the number of questions to be fetched in a request (default limit is 10).
- Response: JSON data containing a list of quiz questions.
Submit Quiz Results
- Route:
/wp-json/qsm/submitquiz
- Method: POST
- Description: Submit quiz results.
- Headers:
authorization
(required) - Form body parameters:
qmn_quiz_id
(required): The ID of the quiz.qmn_question_list
(required): The quiz question ID list with postfix ‘Q’ (e.g., 331Q332Q333Q).total_questions
(required): Number of total questions in the quiz.questionX
: ‘X’ is the question ID. This contains the answer to the question (e.g., question331, question332, question333).timer
: Quiz time duration in seconds.currentuserTime
: Current time in strtotime() format.currentuserTimeZone
: Asia/Calcutta OR any other.