> ## 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.

# Live session

## Live session

Live session represents offline or online meeting that can be a part of the learning path. Live sessions are not a part of a learning path navigation, they don't affect score and progress, but they can be used as a required condition to pass a training and achieve a certificate.

Live sessions can be added to advanced learning path as a part of the live sessions bucket. A user who has an individual membership in the dedicated learning path can be registered to the only one live session in the bucket.

Users can register to a live session that is added to the bucket with the open registration by themselves or they can be registered by users with the dedicated permission (Administrator).

## **Use API to work with the live sessions**

Opigno Enterprise API provides several queries to retrieve the needed information and data structure to work with the live session.

### **Queries to retrieve live sessions and buckets information**

You can use `getLiveSession` query to retrieve the information about the session by its ID:

<CodeGroup>
  ```filename GraphQL [expandable] theme={null}
  query getLiveSession {
    getLiveSession(liveSessionId: 1) {
      id
      bucketId
      title
      description
      startDate
      endDate
      address
      url
      status
      cta {
        title
        actionId
        arguments {
          key
          value
        }
        metadata {
          key
          value
        }
      }  
    }
  }
  ```

  ```File Query result [expandable] theme={null}
  {
    "data": {
      "getLiveSession": {
        "id": "1",
        "bucketId": "1",
        "title": "Live session bucket 1",
        "description": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>",
        "startDate": 1747299600,
        "endDate": 1749988800,
        "address": "",
        "url": "https://google.com",
        "status": "PUBLISHED",
        "cta": [
          {
            "title": "Register",
            "actionId": "REGISTER_TO_LIVE_SESSION",
            "arguments": [
              {
                "key": "liveSessionId",
                "value": "1"
              }
            ],
            "metadata": [
              {
                "key": "type",
                "value": "button"
              }
            ]
          }
        ]
      }
    }
  }
  ```
</CodeGroup>

To get all live sessions that relate to one bucket, use `getLiveSessions` query.

There are several arguments that can be used in this query:

| Argument   | Type                                                               | Description                                                                                             | Default |
| :--------- | :----------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------ | :------ |
| `bucketId` | `ID`                                                               | Required argument; ID of the bucket to get live sessions for.                                           | —       |
| `status`   | `LiveSessionStatus`, possible options:  - `DISABLED` - `PUBLISHED` | Allows to filter by the live session status. Disabled live sessions are not available for registration. | —       |
| `reverse`  | `Boolean`                                                          | Allows to change the order of the sorting to `DESC`.                                                    | `false` |
| `sortKey`  | `LiveSessionSortKey`, possible options:  - `ID` - `START`          | Allows to change the default sorting (by the start date).                                               | `START` |

<CodeGroup>
  ```filename GraphQL theme={null}
  query getLiveSessions {
    getLiveSessions(bucketId: 1) {
      id
      startDate
      endDate
      address
      url
      status
      cta {
        title
        actionId
        arguments {
          key
          value
        }
        metadata {
          key
          value
        }
      }  
    }
  }
  ```

  ```File Query result [expandable] theme={null}
  {
    "data": {
      "getLiveSessions": [
        {
          "id": "1",
          "startDate": 1747299600,
          "endDate": 1749988800,
          "address": "",
          "url": "https://google.com",
          "status": "PUBLISHED",
          "cta": [
            {
              "title": "Register",
              "actionId": "REGISTER_TO_LIVE_SESSION",
              "arguments": [
                {
                  "key": "liveSessionId",
                  "value": "1"
                }
              ],
              "metadata": [
                {
                  "key": "type",
                  "value": "button"
                }
              ]
            }
          ]
        },
        {
          "id": "2",
          "startDate": 1747382400,
          "endDate": 1747486800,
          "address": "",
          "url": "https://google.com/other-link",
          "status": "PUBLISHED",
          "cta": [
            {
              "title": "Register",
              "actionId": "REGISTER_TO_LIVE_SESSION",
              "arguments": [
                {
                  "key": "liveSessionId",
                  "value": "2"
                }
              ],
              "metadata": [
                {
                  "key": "type",
                  "value": "button"
                }
              ]
            }
          ]
        }
      ]
    }
  }
  ```
</CodeGroup>

As an alternative to this query, you can use `getLiveSessionBucket` query to retrieve the information about the bucket in addition to the list of sessions.

<Note>
  In `getLiveSessionBucket` query there is no possibility to sort live sessions.
</Note>

<CodeGroup>
  ```filename GraphQL [expandable] theme={null}
  query getLiveSessionBucket {
    getLiveSessionBucket(bucketId: 1) {
      id
      learningPathId
      title
      description
      type
      registration
      sessions {
        id
        startDate
        endDate
        address
        url
        status
        cta {
          title
          actionId
          arguments {
            key
            value
          }
          metadata {
            key
            value
          }
        }  
      }
      status
    }
  }
  ```

  ```File Query result [expandable] theme={null}
  {
    "data": {
      "getLiveSessionBucket": {
        "id": "1",
        "learningPathId": "92",
        "title": "Live session bucket 1",
        "description": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>",
        "type": "ONLINE",
        "registration": "OPEN",
        "sessions": [
          {
            "id": "1",
            "startDate": 1747299600,
            "endDate": 1749988800,
            "address": "",
            "url": "https://google.com",
            "status": "PUBLISHED",
            "cta": [
              {
                "title": "Register",
                "actionId": "REGISTER_TO_LIVE_SESSION",
                "arguments": [
                  {
                    "key": "liveSessionId",
                    "value": "1"
                  }
                ],
                "metadata": [
                  {
                    "key": "type",
                    "value": "button"
                  }
                ]
              }
            ]
          },
          {
            "id": "2",
            "startDate": 1747382400,
            "endDate": 1747486800,
            "address": "",
            "url": "https://google.com/other-link",
            "status": "PUBLISHED",
            "cta": [
              {
                "title": "Register",
                "actionId": "REGISTER_TO_LIVE_SESSION",
                "arguments": [
                  {
                    "key": "liveSessionId",
                    "value": "2"
                  }
                ],
                "metadata": [
                  {
                    "key": "type",
                    "value": "button"
                  }
                ]
              }
            ]
          }
        ],
        "status": "PUBLISHED"
      }
    }
  }
  ```
</CodeGroup>

### **Retrieve information about live sessions in context of the learning path**

The list of the related live sessions can be accessed from the `LearningPath` object:

<CodeGroup>
  ```filename GraphQL [expandable] theme={null}
  query learningPath {
    getLearningPath(lpId: 92) {
     liveActivities {
      type
      status
      relatedEntity {
        id
        bucketId
        title
        description
        startDate
        endDate
        address
        url
        status
        isBucketRequired
        cta {
          title
          actionId
          arguments {
            key
            value
          }
          metadata {
            key
            value
          }
        }  
      }
     }
    }
  }
  ```

  ```File Query result [expandable] theme={null}
  {
    "data": {
      "getLearningPath": {
        "liveActivities": [
          {
            "type": "LIVE_SESSION",
            "status": "REGISTRATION_AVAILABLE",
            "relatedEntity": {
              "id": "1",
              "bucketId": "1",
              "title": "Live session bucket 1",
              "description": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>",
              "startDate": 1747299600,
              "endDate": 1749988800,
              "address": "",
              "url": "https://google.com",
              "status": "PUBLISHED",
              "isBucketRequired": true,
              "cta": [
                {
                  "title": "Register",
                  "actionId": "REGISTER_TO_LIVE_SESSION",
                  "arguments": [
                    {
                      "key": "liveSessionId",
                      "value": "1"
                    }
                  ],
                  "metadata": [
                    {
                      "key": "type",
                      "value": "button"
                    }
                  ]
                }
              ]
            }
          },
          {
            "type": "LIVE_SESSION",
            "status": "REGISTRATION_AVAILABLE",
            "relatedEntity": {
              "id": "2",
              "bucketId": "1",
              "title": "Live session bucket 1",
              "description": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>",
              "startDate": 1747382400,
              "endDate": 1747486800,
              "address": "",
              "url": "https://google.com/other-link",
              "status": "PUBLISHED",
              "isBucketRequired": true,
              "cta": [
                {
                  "title": "Register",
                  "actionId": "REGISTER_TO_LIVE_SESSION",
                  "arguments": [
                    {
                      "key": "liveSessionId",
                      "value": "2"
                    }
                  ],
                  "metadata": [
                    {
                      "key": "type",
                      "value": "button"
                    }
                  ]
                }
              ]
            }
          },
          {
            "type": "LIVE_SESSION",
            "status": "REGISTRATION_AVAILABLE",
            "relatedEntity": {
              "id": "3",
              "bucketId": "2",
              "title": "Live session bucket 2 (offline)",
              "description": "",
              "startDate": 1746795600,
              "endDate": 1747404000,
              "address": "Somewhere in your city",
              "url": null,
              "status": "PUBLISHED",
              "isBucketRequired": false,
              "cta": [
                {
                  "title": "Register",
                  "actionId": "REGISTER_TO_LIVE_SESSION",
                  "arguments": [
                    {
                      "key": "liveSessionId",
                      "value": "3"
                    }
                  ],
                  "metadata": [
                    {
                      "key": "type",
                      "value": "button"
                    }
                  ]
                }
              ]
            }
          }
        ]
      }
    }
  }
  ```
</CodeGroup>

Or as an alternative `getLiveSessionBuckets` can be used if you need the list of related buckets.

Here is the list of arguments that can be used:

| Argument  | Type                                                               | Description                                                                                                                  | Default |
| :-------- | :----------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------- | :------ |
| `lpId`    | `ID`                                                               | Required argument; ID of the learning path to get buckets for.                                                               | —       |
| `status`  | `LiveSessionStatus`, possible options:  - `DISABLED` - `PUBLISHED` | Allows to filter by the bucket status. Live sessions that relate to the disabled buckets are not available for registration. | —       |
| `reverse` | `Boolean`                                                          | Allows to change the order of the sorting to `DESC`.                                                                         | `false` |
| `sortKey` | `LiveSessionBucketSortKeys`, possible options:  - `ID` - `TITLE`   | Allows to change the default sorting.                                                                                        | `TITLE` |

<CodeGroup>
  ```filename GraphQL theme={null}
  query getLiveSessionBuckets {
    getLiveSessionBuckets(lpId: 92) {
      id
      learningPathId
      title
      description
      type
      registration
      status
      sessions {
        id
        startDate
        endDate
        address
        url
        status
      }
    }
  }
  ```

  ```File Query result [expandable] theme={null}
  {
    "data": {
      "getLiveSessionBuckets": [
        {
          "id": "1",
          "learningPathId": "92",
          "title": "Live session bucket 1",
          "description": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>",
          "type": "ONLINE",
          "registration": "OPEN",
          "status": "PUBLISHED",
          "sessions": [
            {
              "id": "1",
              "startDate": 1747299600,
              "endDate": 1749988800,
              "address": "",
              "url": "https://google.com",
              "status": "PUBLISHED"
            },
            {
              "id": "2",
              "startDate": 1747382400,
              "endDate": 1747486800,
              "address": "",
              "url": "https://google.com/other-link",
              "status": "PUBLISHED"
            }
          ]
        },
        {
          "id": "2",
          "learningPathId": "92",
          "title": "Live session bucket 2 (offline)",
          "description": null,
          "type": "OFFLINE",
          "registration": "OPEN",
          "status": "PUBLISHED",
          "sessions": [
            {
              "id": "3",
              "startDate": 1746795600,
              "endDate": 1747404000,
              "address": "Somewhere in your city",
              "url": null,
              "status": "PUBLISHED"
            }
          ]
        }
      ]
    }
  }
  ```
</CodeGroup>

## **Registration to a live session**

There are two available types of live session buckets:

* **Open** - available for registration for all users who are enrolled to the related learning path;
* **Admin-signed** - will be visible to a user only after registration by admin.

In both cases the same mutation `registerToLiveSession` is used.

| Argument          | Type | Description                                                                                                                                                                 |
| :---------------- | :--- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `liveSessionId`   | `ID` | Required argument; ID of the live session to register for.                                                                                                                  |
| `userContextUuid` | `ID` | Optional; if set, the user with the given API context will be registered to the live session if it’s possible. Otherwise the current user will be registered (if possible). |

<CodeGroup>
  ```filename GraphQL theme={null}
  mutation registerToLiveSession {
    registerToLiveSession(liveSessionId: 2, userContextUuid: "a1b2c3d4-e5f6-7890-abcd-ef1234567890") {
      errors
      response {
        id
        isAttended
        relatedLpId
      }
    }
  }
  ```

  ```File Query result theme={null}
  {
    "data": {
      "registerToLiveSession": {
        "response": {
          "id": "1",
          "isAttended": false,
          "relatedLpId": "92"
        }
      }
    }
  }
  ```
</CodeGroup>

In a response a created `LiveSessionAttendance` object will be returned.
