# Quest session

> The object startQuest returns. It tracks the timer, the question and the completion of one quest.

Source: https://dashboard.adquest.batriders.ir/docs/sdk/quest-session · Audience: Developers · Section: SDK reference

## Members

| Member | Type | Meaning |
| --- | --- | --- |
| questId | number | The quest this session belongs to. |
| displayDuration | number | Seconds the quest must be shown or watched. |
| deliveryToken | string \| undefined | Token from the start, sent back when you complete. |

## Timing

### `getState`

Returns the current state of the session.

```typescript
getState(): QuestSessionState
```

**Returns:** A QuestSessionState.

### `onProgress`

Subscribes to timer progress. Unsubscribe when the view unmounts.

```typescript
onProgress(callback: (progress: QuestSessionProgress) => void): () => void
```

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| callback | (progress) => void | yes | Called with { elapsed, total, percent, isComplete }. |

**Returns:** A function that removes the listener.

### `syncMediaProgress`

Feeds real video playback into the session. Use it with mediaDriven: true.

```typescript
syncMediaProgress(elapsed: number, total: number): void
```

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| elapsed | number | yes | Seconds played. |
| total | number | yes | Total seconds. |

**Returns:** Nothing.

### `completeDuration`

Marks the timer as finished.

```typescript
completeDuration(): void
```

**Returns:** Nothing.

### `waitForDuration`

Resolves when the required watch time has passed.

```typescript
waitForDuration(): Promise<void>
```

**Returns:** A Promise that resolves when the timer is done.

## Questions and completion

### `registerClick`

Records a real click on the quest’s media.

```typescript
registerClick(): Promise<void>
```

**Returns:** A Promise that resolves when the click is recorded.

### `getQuestion`

Loads the question for a video, banner or survey quest.

```typescript
getQuestion(): Promise<QuestQuestion>
```

**Returns:** A Promise of QuestQuestion.

### `getQuestions`

Loads every question of a survey.

```typescript
getQuestions(): Promise<QuestQuestion[]>
```

**Returns:** A Promise of QuestQuestion[].

### `complete`

Submits the participant’s answer. Never choose the answer for them.

```typescript
complete(answer?: string | number | SurveyAnswerInput[]): Promise<QuestCompleteResult>
```

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| answer | string \| number \| SurveyAnswerInput[] | no | The chosen option ID, or the answers of a multi-question survey. |

**Returns:** A Promise of { status, questId, completedAt?, reason?, rejectionCode?, settlementStatus, tokensAwarded?, tokenReward? }.

> **Read the settlement.** Check status before you show a reward. The API does not send a settlement status. The SDK sets settlementStatus itself: pending when the response says completed: false, success when status is true, and failed otherwise. A pending result can still be rejected after review.

### `submitReview`

Submits evidence for a quest that is checked by review.

```typescript
submitReview(evidence: string): Promise<QuestCompleteResult>
```

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| evidence | string | yes | The evidence the quest asks for. |

**Returns:** A Promise of QuestCompleteResult.

## Growth quests

The session also exposes ingestEvent, getGrowthStatus, getStreakStatus, getCustomStatus and attributeReferral for the quest it was started for. They take the same arguments as the client methods, without the quest ID.

- [Quest methods](https://dashboard.adquest.batriders.ir/docs/sdk/quests): The client versions of these methods.
