Fork me on GitHub

In the context of API, the Lecture is referred as lecture. A Lecture is the minimum unit of content, such as a text or video, which has social interactions (see Status). Many lectures can be grouped and sorted into a subject.

Types of Lecture

There are five types of lectures:

  • Page: Content in Rich Text Format.
  • Document: Text file (txt, pdf, doc, docx, ppt, pptx, etc).
  • Media: Video file (mov, avi, mpeg, mp4, etc), or video hosted in Youtube.
  • Exercise: It has questions to be answered.
  • Canvas: Application.

Attributes

Below are described the attributes of a lecture:

Attribute Description
created_at Date of creation
name Name (title)
position Sorted position in the subject
type Type (Canvas, Document, Exercise, Page, Media)
id Identifier
rating Evaluation by users
view_count Number of views
updated_at Last update date

Links

Below are described the links that are in the representation of a lecture:

Link Description
self Lecture in question
self_link Lecture in Redu (HTML)
subject Subject where the Lecture is
space Space where the Lecture is
course Course where the Lecture is
environment Environment where the Lecture is

Types of lectures

Page

This lecture is just content based on Rich Text Format , originated by CKEditor.

Key Description
content Content generated by CKEditor. It includes HTML and CSS formatting
raw Raw content of the lecture. No formatting and style are applied to it

Document

This type of lecture is basically composed of a document, which can be in one of these formats: txt, pdf, doc, docx, ppt, pptx, etc.

Key Description
mimetype File format

This type of class also has the following links:

Link Description
raw Download address of raw file
scribd Address of file hosted on Scribd (with player to be used embedded)

Media

This type of Lecture represents media files – audio or video -, including YouTube medias.

Key Description
mimetype MimeType of media file
Link Description
raw Download address of file

In case of Youtube videos, the MimeType returned will be video/x-youtube. For example:

Exercise

Canvas

More information can be found in Canvas documentation.

GET /api/subjects/:id/lectures

Lists all the Lectures that belong to the specified Subject.

Authorization

You need to be enrolled in the Course to which the Subject belongs.

Parameters

Attribute Description Restrictions
id Subject ID. N/A

Example

Request: GET /api/spaces/12/lectures

Response:

[{
  "name": "Aula youtube",
    "position": 1,
    "rating": 0,
    "type": "Media",
    "links": [
    { "rel": "next_lecture", "href": "http://www.redu.com.br/api/lectures/105-conheca-o-seu-cliente" },
    { "rel": "course", "href": "http://www.redu.com.br/api/courses/recife" },
    { "rel": "environment", "href": "http://www.redu.com.br/api/environments/www" },
    { "rel": "subject", "href": "http://www.redu.com.br/api/subjects/114" },
    { "rel": "self", "href": "http://www.redu.com.br/api/lectures/107-aula-youtube" },
    { "rel": "raw", "href": "http://www.youtube.com/watch?v=GrV2SZuRPv0" },
    { "rel": "self_link", "href": "http://www.redu.com.br/espacos/27/modulos/114/aulas/107-aula-youtube" },
    { "rel": "space", "href": "http://www.redu.com.br/api/spaces/27" }
  ],
    "view_count": 6,
    "mimetype": "video/x-youtube",
    "updated_at": "2011-11-22T22:56:59-02:00",
    "id": 107,
    "created_at": "2011-02-21T10:11:05-03:00"
}]

GET /api/lectures/:id

Returns the Lecture in question.

Authorization

You need to be enrolled in the Course to which the Subject belongs (i.e., the course to which the space belongs).

Parameters

Parâmetro Description Restrictions
id Lecture ID N/A

Example

Request: GET /api/lectures/1

Response:

  • Page
{
  "created_at": "2013-01-16T10:28:23-02:00",
  "name": "Nome da aula",
  "links": [
    { "href": "http://www.redu.com.br/api/lectures/4877-novo", "rel": "self" },
    { "href": "http://www.redu.com.br/espacos/1412/modulos/3111/aulas/4877-novo", "rel": "self_link" },
    { "href": "http://www.redu.com.br/api/subjects/3111", "rel": "subject" },
    { "href": "http://www.redu.com.br/api/spaces/1412", "rel": "space" },
    { "href": "http://www.redu.com.br/api/courses/curso-de-exemplo", "rel": "course" },
    { "href": "http://www.redu.com.br/api/environments/ambiente-de-exemplo-api", "rel": "environment" },
    { "href": "http://www.redu.com.br/api/lectures/4877/statuses", "rel": "statuses" },
  ],
  "position": 1,
  "content": "<html></html>",
  "raw": "lorem lipsum",
  "type": "Page",
  "mimetype": "text/html",
  "id": 4877,
  "rating": 0,
  "view_count": 1,
  "updated_at": "2013-01-16T10:28:23-02:00"
}
  • Document
{
  "created_at": "2013-01-16T10:28:23-02:00",
    "name": "Nome da aula",
    "links": [
      { "href": "http://www.redu.com.br/api/lectures/4877-novo", "rel": "self" },
      { "href": "http://www.redu.com.br/espacos/1412/modulos/3111/aulas/4877-novo", "rel": "self_link" },
      { "href": "http://www.redu.com.br/api/subjects/3111", "rel": "subject" },
      { "href": "http://www.redu.com.br/api/spaces/1412", "rel": "space" },
      { "href": "http://www.redu.com.br/api/courses/curso-de-exemplo", "rel": "course" },
      { "href": "http://www.redu.com.br/api/environments/ambiente-de-exemplo-api", "rel": "environment" },
      { "href": "http://www.redu.com.br/api/lectures/4877/statuses", "rel": "statuses" },
      { "href": "http://s3.amazonaws.com/redu_uploads/documents/attachments/1837/original/04-platform-101.pdf?1358254757", "rel" : "raw" },
      { "href": "http://www.scribd.com/embeds/120454644/content?start_page=1&view_mode=list&access_key=key-1k5p2ziz2wckhlhjsm9n", "rel" : "scribd" },
    ],
    "mimetype": "application/pdf",
    "position": 1,
    "type": "Document",
    "id": 4877,
    "rating": 0,
    "view_count": 1,
    "updated_at": "2013-01-16T10:28:23-02:00"
}
  • Exercise
  • Media

For Youtube videos:

{
  "created_at": "2013-01-16T10:28:23-02:00",
    "name": "Nome da aula",
    "links": [
      { "href": "http://www.redu.com.br/api/lectures/4877-novo", "rel": "self" },
      { "href": "http://www.redu.com.br/espacos/1412/modulos/3111/aulas/4877-novo", "rel": "self_link" },
      { "href": "http://www.redu.com.br/api/subjects/3111", "rel": "subject" },
      { "href": "http://www.redu.com.br/api/spaces/1412", "rel": "space" },
      { "href": "http://www.redu.com.br/api/courses/curso-de-exemplo", "rel": "course" },
      { "href": "http://www.redu.com.br/api/environments/ambiente-de-exemplo-api", "rel": "environment" },
      { "href": "http://www.redu.com.br/api/lectures/4877/statuses", "rel": "statuses" },
      { "href": "http://www.youtube.com/watch?v=zm5GcMjPFOU", "rel": "raw" }
    ]
    "position": 1,
    "mimetype": "video/x-youtube",
    "type": "Media",
    "id": 4877,
    "rating": 0,
    "view_count": 1,
    "updated_at": "2013-01-16T10:28:23-02:00"
}

For videos hosted in Redu:

{
  "created_at": "2013-01-16T10:28:23-02:00",
    "name": "Nome da aula",
    "links": [
    { "href": "http://www.redu.com.br/api/lectures/4877-novo", "rel": "self" },
    { "href": "http://www.redu.com.br/espacos/1412/modulos/3111/aulas/4877-novo", "rel": "self_link" },
    { "href": "http://www.redu.com.br/api/subjects/3111", "rel": "subject" },
    { "href": "http://www.redu.com.br/api/spaces/1412", "rel": "space" },
    { "href": "http://www.redu.com.br/api/courses/curso-de-exemplo", "rel": "course" },
    { "href": "http://www.redu.com.br/api/environments/ambiente-de-exemplo-api", "rel": "environment" },
    { "href": "http://www.redu.com.br/api/lectures/4877/statuses", "rel": "statuses" },
    { "href": "http://s3.amazonaws.com/redu/video-name.mpg", "rel": "raw" }
  ],
  "position": 1,
  "mimetype": "video/mpeg",
  "type": "Media",
  "id": 4877,
  "rating": 0,
  "view_count": 1,
  "updated_at": "2013-01-16T10:28:23-02:00"
}

POST /api/subjects/:subject_id/lectures

Creates a lecture.

Authorization

You need to be enrolled in the Course to which the Subject belongs (i.e., the course to which the space belongs), and have either environment_admin or teacher role.

Parameters

Attribute Description Restrictions
lecture[name] Lecture name N/A
lecture[type] Type It must be Media, Document, or Page
lecture[media] File or URL from youtube Only Media, and Document lectures
lecture[content] Text content Only Page lectures

Upload files

In cases of uploading a file, the following HTTP headers are required::

1. Content-Type: multipart/form-data
2. Content-Length: 13951 (size of file in bytes)

The usage of Content-type multipart/form-data makes possible that the HTTP request body is composed of multiple sets of data, where each one has its own Content-type. In this way, we can send the binary data of an image or PDF file, besides the name and type.

Redu is able to automatically detect Content-type for images. However, when uploading other types of media, you must tell their Content-type. Most HTTP libraries have this feature implemented. Below you can see an example of body of an HTTP request to upload a video in MPEG format:

------------------------------17c3f87d4b40
Content-Disposition: form-data; name="lecture[media]"; filename=
"video_example.avi"
Content-Type: video/mpeg

<dados binários>
------------------------------17c3f87d4b40
Content-Disposition: form-data; name="lecture[name]"

testando_upload_de_aula
------------------------------17c3f87d4b40
Content-Disposition: form-data; name="lecture[type]"

Media

This behavior is described in details in RFC 2388

Example

In all the examples, we use cURL to test the creation of Lecture.An Java example can be found here.

  • Document

In this example, a Document lecture will be created from pdf_example.pdf file in the current directory.

curl \
  -H 'Authorization: OAuth AJOBibdmecfKxOpEeRWbdmVVCGujGRU3JKA0jyQM' \
  -F 'lecture[media]=@pdf_example.pdf;type=application/pdf' \
  -F 'lecture[name]=My lecture' \
  -F 'lecture[type]=Document' \
  http://www.redu.com.br/api/subjects/117/lectures -vv
  • Media (upload)

In this example, a Media lecture will be created from video.avi file in the current diretory.

curl \
  -H 'Authorization: OAuth AJOBibdmecfKxOpEeRWbdmVVCGujGRU3JKA0jyQM' \
  -F 'lecture[media]=@video.avi;type=video/mpeg' \
  -F 'lecture[name]=My lecture' \
  -F 'lecture[type]=Media' \
  http://www.redu.com.br/api/subjects/117/lectures -vv
  • Media (YouTube)

In this example, a Media lecture will be created from a Youtube link.

curl \
  -H 'Authorization: OAuth AJOBibdmecfKxOpEeRWbdmVVCGujGRU3JKA0jyQM' \
  -H 'Content-type: application/json' \
  -d '{ "lecture" : { "name" : "Youtube", "media" : "http://www.youtube.com/watch?v=GrV2SZuRPv0", "type" : "Media" } }' \
  http://redu.com.br/api/subjects/117/lectures -vv
  • Page
curl \
  -H 'Authorization: OAuth AJOBibdmecfKxOpEeRWbdmVVCGujGRU3JKA0jyQM' \
  -H 'Content-type: application/json' \
  -d '{ "lecture" : { "name" : "Minha pag", "content" : "<strong>meu conteudo</strong>", "type" : "Page" } }' \
  http://redu.com.br/api/subjects/117/lectures -vv

DELETE /api/lectures/:id

Deletes a lecture.

Authorization

You need to be enrolled in the Course to which the Subject belongs (i.e., the course to which the space belongs), and have either environment_admin or teacher role.