# Users & Participants

## Institution and course owner

Users exist in a variety of levels in Eduflow. [Institutions](https://docs.eduflow.com/guides/institutions) and [courses](https://docs.eduflow.com/guides/courses) allow direct access to their owner. In GraphQL, these are associated with the `User` object type.

### Institution owner

{% tabs %}
{% tab title="Query" %}

```graphql
{
  institution {
    name
    owner {
      name
      email
    }
  }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "data": {
    "institution": {
      "name": "Dunder Mifflin",
      "owner": {
        "name": "Michael Scott",
        "email": "michael.scott@dunder-mifflin.com"
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}

### Course owner

{% tabs %}
{% tab title="Query" %}

```graphql
{
  course(id: "00000000-5945-95c7-65fd-a9747b200320") {
    owner {
      name
      email
    }
  }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "data": {
    "course": {
      "owner": {
        "name": "John Smith",
        "email": "john.smith@example.edu"
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}

## Course participants

In [courses](https://docs.eduflow.com/guides/courses), users are queried through a pageable [connection](https://docs.eduflow.com/graphql/pagination): `Course.participants`. Since course users have course-specific context associated them (their participant type and status), their `User` objects are wrapped in `Participant`.&#x20;

Participant types: `Owner` (creator of course),  `Admin`s, `Instructor`s, `Assistant`s and `Student`s.

{% tabs %}
{% tab title="Query" %}

```graphql
{
  course(id: "00000000-5944-95c7-65fc-a9747b200320") {
    participants(first: 5) {
      edges {
        node {
          participantType
          participantStatus
          user {
            name
            email
          }
        }
      }
    }
  }
}

```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "data": {
    "course": {
      "participants": {
        "edges": [
          {
            "node": {
              "participantType": "Owner",
              "participantStatus": "ACTIVE",
              "user": {
                "name": "Michael Scarn",
                "email": "michael.scott@dunder-mifflin"
              }
            }
          },
          {
            "node": {
              "participantType": "Teacher",
              "participantStatus": "ACTIVE",
              "user": {
                "name": "John Doe",
                "email": "john.doe@example.edu"
              }
            }
          },
          {
            "node": {
              "participantType": "Teacher",
              "participantStatus": "ACTIVE",
              "user": {
                "name": "Gyro",
                "email": "abba.g@example.eu"
              }
            }
          },
          {
            "node": {
              "participantType": "Assistant",
              "participantStatus": "ACTIVE",
              "user": {
                "name": "Dwight Schrute",
                "email": "schrute@dunder-mifflin.com"
              }
            }
          },
          {
            "node": {
              "participantType": "Student",
              "participantStatus": "ACTIVE",
              "user": {
                "name": "Jim Halpert",
                "email": "jim@dundner-mifflin.com"
              }
            }
          }
        ]
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}

### Searching by username

{% tabs %}
{% tab title="Query" %}

```graphql
{
  course(id: "00000000-5945-95c7-65fc-a9747b2003210") {
    participants(first: 1, searchTerm: "Angela") {
      edges {
        node {
          participantType
          participantStatus
          user {
            name
            email
          }
        }
      }
    }
  }
}
```

{% endtab %}

{% tab title="Result" %}

```javascript
{
  "data": {
    "course": {
      "participants": {
        "edges": [
          {
            "node": {
              "participantType": "Student",
              "participantStatus": "ACTIVE",
              "user": {
                "name": "Angela Martin",
                "email": "angela.martin@dunder-mifflin.com"
              }
            }
          }
        ]
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}

### Searching by participant type:

{% tabs %}
{% tab title="Query" %}

```graphql
{
  course(id: "00000000-5945-95c7-65fc-a9747b200120") {
    participants(first: 5, participantTypeFilter: Student) {
      edges {
        node {
          participantType
          participantStatus
          user {
            name
            email
          }
        }
      }
    }
  }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "data": {
    "course": {
      "participants": {
        "edges": [
          {
            "node": {
              "participantType": "Student",
              "participantStatus": "ACTIVE",
              "user": {
                "name": "Pam Beesly",
                "email": "pam.beesly@dunder-mifflin.com"
              }
            }
          },
          {
            "node": {
              "participantType": "Student",
              "participantStatus": "ACTIVE",
              "user": {
                "name": "Ryan Howard",
                "email": "ryan.howard@dunder-mifflin.com"
              }
            }
          },
          {
            "node": {
              "participantType": "Student",
              "participantStatus": "ACTIVE",
              "user": {
                "name": "Kevin Malone",
                "email": "kevin.malone@dunder-mifflin.com"
              }
            }
          },
          {
            "node": {
              "participantType": "Student",
              "participantStatus": "ACTIVE",
              "user": {
                "name": "Andy Bernard",
                "email": "andy.bernard@dunder-mifflin.com"
              }
            }
          },
          {
            "node": {
              "participantType": "Student",
              "participantStatus": "ACTIVE",
              "user": {
                "name": "Phyllis Smith",
                "email": "phyllis.smith@dunder-mifflin.com"
              }
            }
          }
        ]
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}

### Individual participant lookup

{% tabs %}
{% tab title="Query" %}

```graphql
{
  course(id: "00000000-5943-95c7-65fc-a9747b200320") {
    participants(id: "7a41ad8e-f252-449d-8add-13c8ae27470b") {
      edges {
        node {
          participantType
          participantStatus
          user {
            name
            email
          }
        }
      }
    }
  }
}

```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "data": {
    "course": {
      "participants": {
        "edges": [
          {
            "node": {
              "participantType": "Student",
              "participantStatus": "ACTIVE",
              "user": {
                "name": "Pam Beesly",
                "email": "pam.beesly@dunder-mifflin.com"
              }
            }
          }
        ]
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}

### Participant invite links

Invitation links and embed (a.k.a magic links) can be accessed through the `Participant` response object:

{% tabs %}
{% tab title="Query" %}

```graphql
{
  course(id: "00000000-5943-95c7-65fc-a9747b200320") {
    owner {
      name
      email
    }
    participants {
      edges {
        node {
          participantStatus
          invitationLink
          embedLoginLink
        }
      }
    }
  }
}

```

{% endtab %}

{% tab title="Response" %}

```json
{
  "data": {
    "course": {
      "participants": [
        {
          "id": "5a7fdd2c-47d4-4a7f-8576-a640938e5574",
          "participantType": "Student",
          "participantStatus": "INVITATION_PENDING",
          "user": {
            "name": "Thomas Smith"
          },
          "invitationLink": "https://app.eduflow.com/join-from-email?userId=5a7fdd2c-47d4-4a7f-8576-a640938e5574&courseId=00000000-5945-95c7-65fc-a9747b200320&token=eyJ1c2VyX2lkIjoiNWE3ZmRkMmMtNDdkNC00YTdmLTg1NzYtYTY0MDkzOGU1NTc0In0.Fr75Hg.6VbxV2GGVNeKWc4C0xTn5CYTtm0",
          "embedLoginLink": "https://app.eduflow.com/join-from-email?userId=5a7fdd2c-47d4-4a7f-8576-a640938e5574&courseId=00000000-5945-95c7-65fc-a9747b200320&token=eyJ1c2VyX2lkIjoiNWE3ZmRkMmMtNDdkNC00YTdmLTg1NzYtYTY0MDkzOGU1NTc0In0.Fr75Hg.6VbxV2GGVNeKWc4C0xTn5CYTtm0&skip_signup=1"
        }
      ]
    }
  }
}
```

{% endtab %}
{% endtabs %}

* `invitationLink`:  Will prompt user to create a password
* `embedLoginLink`:  "Magic link", takes user directly to to course
