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

# Learning Resource Assignment

> This shows the operations that you need to perform for viewing and assigning Learning resources to people in your company on SkillsDB.

<Info>
  **Quick Summary:** This tutorial covers the GraphQL operations for viewing, assigning, and updating learning resources (IDPs) for people in your SkillsDB company, including migration paths from the legacy API.
</Info>

### Get/List People Learnings (IDP)

* On the **legacy API** access the used to an API which list all learnings (IDPs) which are assigned to peoples. The below API:
  * `GET - {{baseURI}}/IDP/{{companyID}}?part={{part}}`
* On the **new GraphQL API** use the below query to list/get people learnings (IDPs)

  ```graphql theme={null}
  query GetAllPeopleLearningSummary {
      getAllPeopleLearningSummary(
          input: { limit: 20, offset: 0, where: { emailAddress: { _like: "" } } }
      ) {
          count
          data {
              PersonId
              FirstName
              LastName
              EmployeeId
              MgrPersonId
              MgrFirstName
              MgrLastName
              MgrEmailAddress
              LearningId
              ReferenceId # LearningPlanActivityIDOutsideSystem on the legacy API
              LearningTitle
              Status
              PercentComplete # LearningPlanPercentComplete on the legacy API
              DateStarted # LearningPlanStartDate on the legacy API
              DateCompleted # LearningPlanEndDate on the legacy API
          }
      }
  }
  ```

### Get/List Learnings(IDPs) for Person with Email Address

* On the **legacy API** there used to be an API to get learnings/IDPs for specific person by Email Address.
* On the **new GraphQL API** we'll use the above `getAllPeopleLearningSummary` query by using email filter as below, for more on filtering please check out **Filtering** documentation.

  ```graphql theme={null}
  where: { emailAddress: { _eq: "email@domain.com" }
  ```

### Create and Assign Learning to a Person

* On the legacy API there used to be an API to create IDP record and assign to a person at the same time. Which is:
  * `POST- {{baseURI}}/CreateIDPRecord/{{companyID}}` with the below payload:

    ```
    {
        // Learning plan (course) outside Id used in other system (if there is), So it can be referenced. OPTIONAL, But good to have field.
        "LearningPlanActivityIDOutsideSystem":"SDB62540021",
        // Person email address to assign or update the learning plan current status. REQUIRED
        "EmailAddress": "tadesse@skillsdb.com",
        // Short Title for the learning plan, if this learning plan doesn't exists in the system, it will be created. REQUIRED
        "LearningPlanTitle": "NEST AND GRAPHQL INTEGRATION",
        // Long description of the learning plan, OPTIONAL
        "LearningPlanDescription":"Programming",
        // The duration that will take to complete this course. OPTIONAL
        "LearningPlanDurationHours":10,
        // A url in which the learning plan (course) could be redirected. OPTIONAL
        "LearningPlanURL":"https://www.sampleurl.com/pathtothecourse",
        // A unique Id of learning plan types which is generated by skillsdb system, you can get those ids from SkillDb web app. If you don't want to use Id you can use learning plan type Name. OPTIONAL
        "LearningPlanTypeId": 15,
        // This is a learning plan type name in which the system will take the Id based on this name. New learning plan type will be created if there is no learning plan type with the given name. Please make sure you are using the exact names of existing learning plan types (to avoid unneccesary duplicates). OPTIONAL
        "LearningPlanTypeName":"Sample Learning Plan Type",
        // Percentage representation of the course(learning plan) completion. OPTIONAL, but Reuired if you want to score with this API.
        "LearningPlanPercentComplete": 100,
        // The time when this course(learning Plan) started by an employee.The Date Format shuld be (dd.MM.yyyy). OPTIONAL
        "LearningPlanStartDate": "15.06.2023",
        // The time when this course(learning plan) gets completed by an employee. The Date Format shuld be (dd.MM.yyyy). OPTIONAL
        "LearningPlanEndDate": "30.12.2023"
    }
    ```
* On the new GraphQL API we'll use the below mutation to create and assign learning/IDP to a person using email address:

```graphql theme={null}
mutation AddAndAssignlearningComposite {
    addAndAssignlearningComposite(
        input: {
            EmailAddress: "tadesse@skillsdb.com"
            Title: "NeW Updated Learning" # title of the learning plan
            Description: null # any description
            DurationInHours: 12 # leaning plan duration (master data level) when this learning gets assigned to other person, this duration will be used
            OverrideDurationHours: 23 # this will override the above learning plan duration for this person
            PercentageCompleted: 50 # percentage completed
            StartDate: "2025-01-15" # start date of the learning
            EndDate: "2025-06-20" # percentage should be 100% to log this
            ReferenceId: "LNOPS-11222" # reference Id to other system (for your reference) LearningPlanActivityIDOutsideSystem equivalent from legacy system
            LearningPlanURL: "htts://learn.domain.com/lnops-11222" # url of the learning plan
        }
    ) {
        success
        message
        rowsAffected
    }
}
```

### Update Person learning (IDP)

* On the **legacy API** there used to be an update API for persons learning plan (IDP). Which is:
  * `POST - {{baseURI}}/skills/{{companyID}}` with the below json

    ```json theme={null}
    {
        "LearningPlanActivityIDOutsideSystem": "SDB62540021",
        "EmailAddress": "emial@domain.com",
        "LearningPlanPercentComplete": "85",
        "LearningPlanStartDate": "15.06.2023",
        "LearningPlanEndDate": "15.06.2023"
    }
    ```
* On the new GraphQL API we'll use the above addAndAssignlearningComposite mutation with the below payload:

  ```
  mutation AddAndAssignlearningComposite {
      addAndAssignlearningComposite(
          input: {
              EmailAddress: "email@domain.com"
              ReferenceId: "LNOPS-11222" # reference Id to other system (for your reference) LearningPlanActivityIDOutsideSystem equivalent from legacy system
              PercentageCompleted: 100 # percentage completed
              StartDate: "2025-01-15" # start date of the learning
              EndDate: "2025-06-20" # percentage should be 100% to log this

          }
      ) {
          success
          message
          rowsAffected
      }
  }
  ```

***

# Need Help?

<Info>
  If you run into any issues or have questions, reach out to your organization's SkillsDB administrator or contact [SkillsDB Support](https://www.skillsdb.com/support).
</Info>
