LLMS_Quiz_Attempt::answer_question( int $question_id, string[] $answer )
Answer a question
Description Description
Records the selected option and whether or not the selected option was the correct option.
Automatically updates & saves the attempt to the database
Parameters Parameters
- $question_id
-
(Required) WP_Post ID of the LLMS_Question.
- $answer
-
(Required) Array of selected choice IDs (for core question types) or an array containing the user-submitted answer(s).
Return Return
(LLMS_Quiz_Attempt) Instance of the current attempt.
Source Source
File: includes/models/model.llms.quiz.attempt.php
Changelog Changelog
Version | Description |
---|---|
4.0.0 | Explicitly set earned points to 0 when answering incorrectly. Exit the loop as soon as we find our question. Use strict comparison for IDs. |
3.9.0 | |
3.16.0 | Introduced. |