Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

Commit

Permalink
Added support for course/module REST API.
Browse files Browse the repository at this point in the history
Fixes #3 #4
  • Loading branch information
justinabrahms committed Nov 19, 2015
1 parent 69a3a3d commit a999c12
Show file tree
Hide file tree
Showing 34 changed files with 892 additions and 54 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[run]
data_file=/tmp/coverage

[report]
omit=*tox*
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pyc

8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: python
script:
- docker-compose run -e TOX_WORK_DIR=/tmp web tox
- docker-compose run web pylint courses ccxcon
- docker-compose up dredd
- docker-compose run dredd dredd
services:
- docker
44 changes: 44 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM ubuntu:trusty
MAINTAINER ODL DevOps <mitx-devops@mit.edu>

# Add package files
WORKDIR /tmp

# Install base packages
COPY apt.txt /tmp/apt.txt
RUN apt-get update &&\
apt-get install -y $(grep -vE "^\s*#" apt.txt | tr "\n" " ") &&\
ln -s /usr/bin/nodejs /usr/bin/node &&\
pip install pip --upgrade &&\
npm install -g dredd

# Add non-root user.
RUN adduser --disabled-password --gecos "" mitodl

# Install project packages

# Python 2
COPY requirements.pip /tmp/requirements.pip
COPY dredd_requirements.pip /tmp/dredd_requirements.pip

RUN pip install -r requirements.pip &&\
pip install -r dredd_requirements.pip

# Python 3
RUN pip3 install -r requirements.pip

# Add project
COPY . /src
WORKDIR /src
RUN chown -R mitodl:mitodl /src

RUN apt-get clean && apt-get purge
USER mitodl

# Set pip cache folder, as it is breaking pip when it is on a shared volume
ENV XDG_CACHE_HOME /tmp/.cache

# Set and expose port for uwsgi config
EXPOSE 8077
ENV PORT 8077
CMD uwsgi uwsgi.ini
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gem 'apiaryio'
35 changes: 35 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
GEM
remote: https://rubygems.org/
specs:
apiaryio (0.3.2)
json (~> 1.8)
rack (~> 1.6.4)
rake (~> 10.4)
rest-client (~> 1.8)
thor (~> 0.19.1)
domain_name (0.5.25)
unf (>= 0.0.5, < 1.0.0)
http-cookie (1.0.2)
domain_name (~> 0.5)
json (1.8.3)
mime-types (2.6.2)
netrc (0.11.0)
rack (1.6.4)
rake (10.4.2)
rest-client (1.8.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
thor (0.19.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.1)

PLATFORMS
ruby

DEPENDENCIES
apiaryio

BUNDLED WITH
1.10.6
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
# CCXCon
[![Build Status](https://travis-ci.org/mitodl/ccxcon.svg)](https://travis-ci.org/mitodl/ccxcon)

CCXCon is a simple API serves as an interface between edX running instances and different MIT apps.

Implements the APIs as described here http://docs.ccxcon.apiary.io/

## Setup

You can run the entire project through docker.

```
pip install docker-compose
docker-compose up
```

From there, you can visit the minimal web-ui at http://localhost:8077/

## Tests

You can run the dredd API tests via the command `docker-compose up dredd`.
102 changes: 48 additions & 54 deletions apiary.apib
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CCXCon is a simple API serves as an interface between edX running instances and

## Group Courses

## Courses Collection [/coursexs]
## Courses Collection [/api/v1/coursexs/]

### List All Courses [GET]

Expand All @@ -19,17 +19,12 @@ CCXCon is a simple API serves as an interface between edX running instances and
+ Request (application/json)

{
"title": "The Hobbit",
"author": "Bilbo Baggins",
"overview": "A hobbit fights some trolls then goes home.",
"description": "test description",
"video_url": "https://www.youtube.com/watch?v=ROor6_NGIWU",
"modules": [
{
"title": "Gandalf comes to see Bilbo",
"subchapters": ["test", "titles", "go", "here"]
}
]
"title": "Introductory Physics: Classical Mechanics",
"author_name": "David E. Pritchard",
"edx_instance": "https://edx.org",
"overview": "This is the course overview.",
"description": "This is a college level Introductory Newtonian Mechanics",
"video_url": "https://www.youtube.com/watch?v=ROor6_NGIWU"
}

+ Response 201 (application/json)
Expand All @@ -38,10 +33,10 @@ CCXCon is a simple API serves as an interface between edX running instances and

Location: /coursexs/1016dd7e

## Course [/coursexs/{course_uuid}]
## Course [/api/v1/coursexs/{course_uuid}/]

+ Parameters
+ course_uuid: `1016dd7e` (string, required) - UUID of the edX course
+ course_uuid: `7e0e52d0386411df81ce001b631bdd31` (string, required) - UUID of the edX course

### Retrieve a Course [GET]

Expand All @@ -52,7 +47,7 @@ CCXCon is a simple API serves as an interface between edX running instances and

Deletes a course and all of its components and CCXs associated with it.

+ Response 204 (application/json)
+ Response 204

### Partially update Course [PATCH]

Expand All @@ -71,17 +66,13 @@ Deletes a course and all of its components and CCXs associated with it.
+ Request (application/json)

{
"title": "The Hobbit",
"author": "Bilbo Baggins",
"overview": "A hobbit fights some trolls then goes home.",
"description": "test description",
"video_url": "https://www.youtube.com/watch?v=ROor6_NGIWU",
"modules": [
{
"title": "Gandalf comes to see Bilbo",
"subchapters": ["test", "titles", "go", "here"]
}
]
"uuid": "7e0e52d0386411df81ce001b631bdd31",
"title": "CHANGED: Super important physics class",
"author_name": "David E. Pritchard",
"edx_instance": "https://edx.org",
"overview": "This is the course overview.",
"description": "This is a college level Introductory Newtonian Mechanics",
"video_url": "https://www.youtube.com/watch?v=ROor6_NGIWU"
}

+ Response 200 (application/json)
Expand All @@ -90,9 +81,9 @@ Deletes a course and all of its components and CCXs associated with it.

## Group Modules

## Modules collection [/coursexs/{course_uuid}/modules]
## Modules collection [/api/v1/coursexs/{course_uuid}/modules/]
+ Parameters
+ course_uuid: `1016dd7e` (string, required) - UUID of the edX course
+ course_uuid: `7e0e52d0386411df81ce001b631bdd31` (string, required) - UUID of the edX course

### List All modules for a given Course [GET]

Expand All @@ -104,21 +95,21 @@ Deletes a course and all of its components and CCXs associated with it.
+ Request (application/json)

{
"title": "Gandalf comes to see Bilbo",
"subchapters": ["test", "titles", "go", "here"],
"title": "Introduction to Quantum Bits",
"subchapters": ["Quarks and Similar things", "Things that are not quarks"]
}

+ Response 201 (application/json)
+ Attributes (Course)
+ Attributes (Module)
+ Headers

Location: /coursexs/1016dd7e/modules/bcfa43b4/
Location: /coursexs/7e0e52d0386411df81ce001b631bdd31/modules/{uuid}/

## Module [/coursexs/{course_uuid}/modules/{module_uuid}]
## Module [/api/v1/coursexs/{course_uuid}/modules/{module_uuid}/]

+ Parameters
+ course_uuid: `1016dd7e` (string, required) - UUID of the edX course
+ module_uuid: `bcfa43b4` (string, required) - UUID of the module
+ course_uuid: `7e0e52d0386411df81ce001b631bdd31` (string, required) - UUID of the edX course
+ module_uuid: `1db1a8439cbf4a8f8c395ad63fb43e8a` (string, required) - UUID of the module


### Retrieve a Module [GET]
Expand All @@ -130,14 +121,13 @@ Deletes a course and all of its components and CCXs associated with it.

Deletes a CCX course and all of its components associated with it.

+ Response 204 (application/json)
+ Response 204

### Partially update a Module [PATCH]

+ Request (application/json)

{

}

+ Response 200 (application/json)
Expand All @@ -149,9 +139,9 @@ Deletes a CCX course and all of its components associated with it.
+ Request (application/json)

{
"title": "Gandalf comes to see Bilbo",
"subchapters": ["test", "titles", "go", "here"],
"price_cents": 10000
"title": "Introduction to Quantum Bits",
"subchapters": ["Quarks and Similar things", "Things that are not quarks"],
"price_per_seat_cents": 10000
}

+ Response 200 (application/json)
Expand All @@ -160,9 +150,9 @@ Deletes a CCX course and all of its components associated with it.

## Group CCXs

## CCX Collection [/coursexs/{course_uuid}/ccxs]
## CCX Collection [/api/v1/coursexs/{course_uuid}/ccxs]
+ Parameters
+ course_uuid: `1016dd7e` (string, required) - UUID of the edX course
+ course_uuid: `7e0e52d0386411df81ce001b631bdd31` (string, required) - UUID of the edX course

### List All CCXs for a given Course [GET]

Expand All @@ -187,18 +177,18 @@ Deletes a CCX course and all of its components associated with it.

+ Headers

Location: /coursexs/1016dd7e/ccxs/bcfa43b4/
Location: /coursexs/7e0e52d0386411df81ce001b631bdd31/ccxs/bcfa43b4/

+ Body

{

}

## CCX [/coursexs/{course_uuid}/ccxs/{ccx_uuid}]
## CCX [/api/v1/coursexs/{course_uuid}/ccxs/{ccx_uuid}]

+ Parameters
+ course_uuid: `1016dd7e` (string, required) - UUID of the edX course
+ course_uuid: `7e0e52d0386411df81ce001b631bdd31` (string, required) - UUID of the edX course
+ ccx_uuid: `bcfa43b4` (string, required) - UUID of the ccx course


Expand Down Expand Up @@ -250,9 +240,9 @@ Deletes a CCX course and all of its components associated with it.

## Group CCX Modules

## Modules collection [/coursexs/{ccx_uuid}/modules]
## Modules collection [/api/v1/coursexs/{ccx_uuid}/modules]
+ Parameters
+ ccx_uuid: `1016dd7e` (string, required) - UUID of the CCX course
+ ccx_uuid: `7e0e52d0386411df81ce001b631bdd31` (string, required) - UUID of the CCX course

### List All modules associated with a given CCX [GET]

Expand All @@ -264,10 +254,10 @@ Deletes a CCX course and all of its components associated with it.

}

## Module membership [/ccxs/{ccx_uuid}/modules/{module_uuid}]
## Module membership [/api/v1/ccxs/{ccx_uuid}/modules/{module_uuid}]

+ Parameters
+ ccx_uuid: `1016dd7e` (string, required) - UUID of the CCX course
+ ccx_uuid: `7e0e52d0386411df81ce001b631bdd31` (string, required) - UUID of the CCX course
+ module_uuid: `bcfa43b4` (string, required) - UUID of the module

### Add a module to a CCX Course [POST]
Expand Down Expand Up @@ -300,16 +290,20 @@ Deletes the association of a module from a CCX course.
# Data Structures

## Course (object)
+ uuid (string)
+ title: Introductory Physics: Classical Mechanics (string)
+ author: David E. Pritchard (string)
+ video_url (string)
+ terms_url (string)
+ overview (string)
+ description: This is a college-level Introductory Netwonian Mechanics (string)
+ overview: This is the course overview. (string)
+ description: This is a college level Introductory Newtonian Mechanics (string)
+ resources (object)
+ modules (string) - url to list modules

## Module (object)
+ title (string)
+ price_cents: 1000 (number) - price in cents to avoid poor decimal support
+ pages (array[string]) - list of strings representing chapter pages
+ uuid: 1140283aa1b24f5e895e97a76a339040 (string)
+ title: Introduction to Quantum Bits (string)
+ price_per_seat_cents (number, required) - price in cents to avoid poor decimal support
+ subchapters (array[string]): ["Quarks and similar things", "Things that are not quarks"] - list of strings representing chapter pages
+ course: http://localhost:8000/api/v1/coursexs/7e0e52d0386411df81ce001b631bdd31/ (string) - url of the parent course
+ url: /api/v1/coursexs/7e0e52d0386411df81ce001b631bdd31/modules/1140283aa1b24f5e895e97a76a339040/ (string) - url of the module
Loading

0 comments on commit a999c12

Please sign in to comment.