Fork me on GitHub

Resource that represents the enrollment of users in courses. It was developed in such a way that abstracts the fact that the user is present or not in Redu.

If the email is not registered in the plataform, an invitation will be sent, allowing the registration, and subsequent invitation to the course. It has a state machine as defined below (property state):

Attributes:

Attribute Description
ID Enrollment identifier
state Current state of enrollment. Example: waiting
email E-mail of the user who will be invited. Only used when the user does not participate in Redu yet
token Token of user invitation
role Role of the user in the Course. Only available if the user has already accepted the invitation. The possible states are: member, teacher, environment_admin, and tutor

States:

State Description
waiting No action was taken
redu_invited When the email is not registered in Redu, and an invitation message was sent
invited When the email is not registered in Redu, and user receives an invitation to the course. Notification will show up in the home page of the user
approved User has accepted the invitation
rejected User has rejected the invitation

GET /api/enrollments/:id

Returns the enrollment in question.

Parameters

Parameter Description Restrictions
id Enrollment ID N/A

POST /api/courses/:course_id/enrollments

Creates an enrollment in the course in question. If the user participates in Redu, the state of the enrollment will go to invited, and a notification will show up in their home page, inviting them to participate in the course. Otherwise, the enrollment will go to redu_invited state before going to the invited state. This means that an email invitation was sent.

Parameters

Parameter Description Restrictions
id ID or path to course N/A
enrollment[email] E-mail of user who will be invited Maximum 40 characters; it must be unique

Example

POST /api/courses/foo/enrollments

Payload:

{
  "enrollment" : {
    "email" : "foo@bar.com"
  }
}

Response:

{
  "created_at": "2012-03-05T07:38:06-03:00",
    "token": "18EM2oxY37g",
    "id": 4,
    "links": [{
      "href": "http://www.redu.com.br/api/enrollments/4",
      "rel": "self"
    }, {
      "href": "http://www.redu.com.br/api/courses/course-name",
      "rel": "course"
    }, {
      "href": "http://www.redu.com.br/api/courses/environment-name",
      "rel": "environment"
    }, {
      "rel": "user"
    }],
    "state": "redu_invited",
    "email": "foo@bar.com"
}

GET /api/courses/:course_id/enrollments

Lists enrollments for a course. It is important to notice that there may be more enrollments than registered users in the course (state redu_invited, or invited).

Parameters

Parameter Description Restrictions
id ID or path to course N/A

GET /api/users/:user_id/enrollments

Lists enrollments for a user.

Authorization

To submit this request you need to have administrative access to a User. In other words, only the user can see their own enrollments.

Parameters

Parameter Description Restrictions
user_id User ID N/A
courses_ids[] Course IDs. It allows filtering Enrollment by courses N/A

Example:

GET /api/users/4/enrollments?courses_ids[]=50&courses_ids[]=81

[
  {
    "links": [
    { "rel": "environment", "href": "http://www.redu.com.br/api/courses/www" },
    { "rel": "course", "href": "http://www.redu.com.br/api/courses/recife" },
    { "rel": "user", "href": "http://www.redu.com.br/api/users/guiocavalcanti" },
    { "rel": "self", "href": "http://www.redu.com.br/api/enrollments/5939" }
    ],
      "state": "approved",
      "id": 5939,
      "created_at": "2012-04-09T20:01:19-03:00",
      "role": "member",
      "updated_at": "2013-04-08T04:06:58-03:00"
  },
  {
    "links": [
    { "rel": "environment", "href": "http://www.redu.com.br/api/courses/ium" },
    { "rel": "course", "href": "http://www.redu.com.br/api/courses/graduacao-em-ciencia-da-computacao" },
    { "rel": "user", "href": "http://www.redu.com.br/api/users/guiocavalcanti" },
    { "rel": "self", "href": "http://www.redu.com.br/api/enrollments/5264" }
    ],
      "state": "approved",
      "id": 5264,
      "created_at": "2012-03-21T23:56:07-03:00",
      "role": "environment_admin",
      "updated_at": "2013-01-24T08:12:39-02:00"
  }
]

DELETE /api/enrollments/:id

Deletes the specified enrollment, as well as the associated user (if any). The user will lose access to the course, and to its spaces.

Parameters

Parameter Description Restrictions
id ID or path to course N/A