> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opigno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get a single challenge

In order to boost learner motivation, increase engagement and make educational experience more enjoyable and effective,
Opigno Enterprise provides endpoints to implement challenges on your learner area.

Challenges is a part of gamification. Every challenge is a set of time-limited questions that can optionally
include bonus points for speed.

Challenges can be created in the backoffice by administrators or content editors,
and then be retrieved and processed with the API endpoints.

<Note>
  Challenges can not be accessed by user contexts that are not associated with any scope.
</Note>

## Challenge API object

`Challenge` object represents a single challenge data:

| Parameter            | Type               | Description                                                                                                                                                   |
| :------------------- | :----------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `attempt`            | `ChallengeAttempt` | **Optional**. The [challenge attempt](/OpignoEnterpriseAPI/Challenge/TakeChallenge#challenge-attempt) (if it has already been taken by the current API user). |
| `bonusPointsEnabled` | `Boolean`          | **Required**. Indicator of bonus points that can be earned for the fast answer.                                                                               |
| `cta`                | `Cta`              | **Optional**. Contains the list of challenge [Call To Action](#challenge-cta) objects for the current API user.                                               |
| `description`        | `String`           | **Required**. A challenge description. Contains an HTML markup.                                                                                               |
| `endDate`            | `Int`              | **Required**. The timestamp when a challenge ends. The challenge will not be available for completion after this time.                                        |
| `id`                 | `ID`               | **Required**. A challenge ID.                                                                                                                                 |
| `image`              | `MediaImage`       | **Optional**. A challenge image data.                                                                                                                         |
| `isRankingEnabled`   | `Boolean`          | **Required**. A marker to indicate if the ranking and leaderboard displaying is enabled for the challenge.                                                    |
| `maxChallengeRank`   | `Int`              | **Optional**. The max rank in the challenge. The value will be empty if the ranking and leaderboard displaying is not enabled for the challenge.              |
| `participantsNumber` | `Int`              | **Required**. The number of users who took part in the challenge and completed it.                                                                            |
| `questionsNumber`    | `Int`              | **Required**. The total number of questions in a challenge.                                                                                                   |
| `startDate`          | `Int`              | **Required**. The timestamp when a challenge starts. The challenge will not be available for completion before this time.                                     |
| `status`             | `ChallengeStatus`  | **Optional**. The challenge status for the current API user (completed/ongoing/upcoming). If empty, the challenge is already finished and missed by the user. |
| `title`              | `String`           | **Required**. A challenge title.                                                                                                                              |

## Challenge CTA

The list of available CTAs can differ depending on the challenge status.

| Action ID                  | Description                                                                                                   | Corresponding mutation/query                                                                        |
| :------------------------- | :------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |
| `CREATE_CHALLENGE_ATTEMPT` | Allows to create a challenge attempt for the current API user. Available if the challenge is not started yet. | [`createChallengeAttempt`](/OpignoEnterpriseAPI/Challenge/TakeChallenge#create-a-challenge-attempt) |
| `VIEW_CHALLENGE`           | Allows to access a challenge information.                                                                     | [`getChallenge`](#retrieve-a-challenge-from-api)                                                    |
| `VIEW_CHALLENGE_RESULTS`   | Allows to view a challenge results. Available when the challenge attempt is completed.                        | [`getChallengeResult`](/OpignoEnterpriseAPI/Challenge/GetChallengeResults)                          |

## Retrieve a challenge from API

To retrieve a single challenge data, execute the `getChallenge` query.
The query has one incoming argument - `challengeId` and returns a `Challenge` object if
the current API user have an access to view the requested entity.

<CodeGroup>
  ```filename GraphQL theme={null}
  query getChallenge {
    getChallenge(challengeId: 1) {
      title
      description
      image {
        alt
        title
        url
      }
      questionsNumber
      startDate
      endDate
      bonusPointsEnabled
      participantsNumber
      maxChallengeRank
      isRankingEnabled
      status
      cta {
        actionId
        title
        arguments {
          key
          value
        }
      }
    }
  }
  ```

  ```File Query result [expandable] theme={null}
  {
    "data": {
      "getChallenge": {
        "title": "Check your geography knowledge",
        "description": "<p>How well do you know this world? Let's start this challenge and see !</p>",
        "image": {
          "alt": "Earth",
          "title": "Earth image",
          "url": "https://****.png"
        },
        "questionsNumber": 10,
        "startDate": 1770595200,
        "endDate": 1773100799,
        "bonusPointsEnabled": true,
        "participantsNumber": 5,
        "maxChallengeRank": 4,
        "isRankingEnabled": true,
        "status": "ONGOING",
        "cta": [
          {
            "actionId": "VIEW_CHALLENGE",
            "title": "See details",
            "arguments": [
              {
                "key": "challengeId",
                "value": "1"
              }
            ]
          },
          {
            "actionId": "CREATE_CHALLENGE_ATTEMPT",
            "title": "Start challenge",
            "arguments": [
              {
                "key": "challengeId",
                "value": "1"
              }
            ]
          }
        ]
      }
    }
  }
  ```
</CodeGroup>

## Related Features

<CardGroup cols={2}>
  <Card title="Authentication" icon="key" href="/OpignoEnterpriseAPI/ConsumerUserAuthentication">
    Understand the authentication requirements and how to properly authenticate your requests.
  </Card>
</CardGroup>
