Get next question
The questions appear for both battle rivals in the same order and can be retrieved one by one, by execution ofgetNextBattleQuestion query.
Like in case of a challenge, battle questions will be returned not as iframe, but as a
ChallengeQuestion object.
The question form should and the answer submission should be implemented on the frontend.Submit the answer
To submit a battle answer, execute thesaveBattleQuestionAnswer mutation.
It has one argument - answerData:
| Parameter | Type | Description |
|---|---|---|
battleId | ID | Required. ID of the related battle. |
questionId | ID | Required. ID of the question that is being answered. |
answerKey | ID | Optional. The key of the selected answer alternative. If empty, the question will be considered as skipped. |
timeSpent | Int | Required. The time that was spent to provide the answer. If the time spent is greater than the limit that is set in the question settings, the question will be considered as skipped. |
BattleQuestionAnswer object will be returned.
When the answer for the last question is submitted, a battle attempt will be automatically closed,
and the user will be able to check their results.
BattleQuestionAnswer object
A question answer is represented in Opigno Enterprise API as a BattleQuestionAnswer object:
| Parameter | Type | Description |
|---|---|---|
attempt | BattleAttempt | Required. The related battle attempt. |
correctAnswer | KeyValuePair | Required. The correct answer. |
givenAnswer | KeyValuePair | Optional. The given answer. |
id | ID | Required. The answer ID. |
isCorrect | Boolean | Required. A marker that indicates if the provided answer is correct or not. |
question | ChallengeQuestion | Required. The related question. The same object as for challenges is used. |
score | Float | Required. The number of points that the user got for the answer. |
timeSpent | Int | Required. The time (in seconds) that is spent by the user to provide an answer for the related question. |
Terminate battle attempt
Battles designed the same way as challenges, and all questions must be answered in a single attempt, without possibility to stop and resume it later. In this flow, a battle attempt should be terminated immediately if the user leaves the question page. To do this, execute theterminateBattleAttempt mutation.
Use
extraTimeSpent parameter to add an extra time (in seconds) to the general time that the current API user spent on the given battle.