/scaffolding

Backend Webservices for Realtime Hints Providing System

Primary LanguagePython

Scaffolding

Build Status

Installation

Prerequisites

Python 2.7, PHP 7, Composer, Node.js, couchDB, docker, MySQL

Follow the installation instruction in each app.

Services and Ports

Service Port
PublicServer 5000
HintsProvider 5001
StatsAnalyser 5005
StatsUpdater 5002
ExerciseManager 5003
TestRunner 5004

RESTful APIs

PublicServer

Get all exercises

Title Content
URL /api/exercises
Method Allowed GET
Headers Required access_token=<token>,
Content-Type=application/json
Successful Response Code: HTTP 200 OK,
Content: {
id : [string],
name : [string],
description: [string],
template: [string]
}
Error Responses HTTP 401 Unauthorized,
HTTP 400 400 Bad Request

Get stats for all exercises and students belong to an instructor

Title Content
URL /api/stats
Method Allowed GET
Headers Required access_token=<token>,
Content-Type=application/json
Successful Response Code: HTTP 200 OK,
Content: {
time_spent : [integer],
student_id : [integer],
average_time_spent : [integer]
}
Error Responses HTTP 401 Unauthorized,
HTTP 400 400 Bad Request

Post students stats and get hints

Title Content
URL /api/hints
Method Allowed POST
Headers Required access_token=<token>,
Content-Type=application/json
Data Params {
exercise_id : [string],
time_spent : [int],
code : [string],
hints_number : [int]
}
Successful Response Code: HTTP 200 OK,
Content: {
student_id : [integer],
exercise_id : [string],
hints : [string]
}
Error Responses HTTP 401 Unauthorized,
HTTP 404 Not Found

HintsProvider

Post students stats and get hints

Title Content
URL /hints
Method Allowed POST
Headers Required Content-Type=application/json
Data Params {
student_id : [integer],
instructor_id : [integer],
exercise_id : [string],
time_spent : [int],
code : [string],
hints_number : [int]
}
Successful Response Code: HTTP 200 OK,
Content: {
student_id : [integer],
exercise_id : [string],
hints : [string]
}
Error Responses HTTP 401 Unauthorized,
HTTP 404 Not Found

StatsAnalyser

Get all stats for an instructor

Title Content
URL /docs/<instructor_id>
Method Allowed GET
Successful Response Code : HTTP 200 OK,
Content: {docs: [list], exercise: [list], exercise_stats:[list], student_stats: [list] }
Error Response None

Get all stats for an exercise belongs to an instructor

Title Content
URL /docs/<instructor_id>/<exercise_id>
Method Allowed GET
Successful Response Code : HTTP 200 OK,
Content: {docs: [list]}
Error Response None

Get all stats for a student belongs to an instructor

Title Content
URL /docs/<instructor_id>/<student_id>
Method Allowed GET
Successful Response Code : HTTP 200 OK,
Content: {docs: [list]}
Error Response None

Get average time spent for an exercise

Title Content
URL /average/<exercise_id>
Method Allowed GET
Successful Response Code : HTTP 200 OK,
Content: {average_time_spent: [integer]}
Error Response None

StatsUpdater

Title Content
URL /stats/<int:student_id>/<exercise_id>
Method Allowed POST
Headers Required Content-Type=application/json
Data Params {
instructor_id : [integer],
time_spent : [integer],
code : [string],
test_status : [string],
hints_number : [integer]
}
Successful Response Code: HTTP 201 Created,
Content: {
id : [string],
rev : [string]
}
Error Responses HTTP 400 Bad Request

ExerciseManager

Get all exercises

Title Content
URL /exercises
Method Allowed GET
Headers Required Content-Type=application/json
Successful Response Code: HTTP 200 OK,
Content: {
id : [string],
name : [string],
description: [string],
template: [string]
}
Error Responses HTTP 400 400 Bad Request

Get all exercises for an instructor

Title Content
URL /exercises/<instructor_id>
Method Allowed GET
Headers Required Content-Type=application/json
Successful Response Code: HTTP 200 OK,
Content: {
id : [string],
name : [string],
description: [string],
template: [string]
}
Error Responses HTTP 400 400 Bad Request

Get one exercise info

Title Content
URL /exercise/<exercise_id>
Method Allowed GET
Headers Required Content-Type=application/json
Successful Response Code: HTTP 200 OK,
Content: {
id : [string],
rev : [string],
instructor_id : [integer],
name : [string],
test_code : [string],
hints : [string],
description: [string],
template: [string]
}
Error Responses HTTP 400 400 Bad Request

Post new exercise

Title Content
URL /exercise/<instructor_id>/<exercise_index>
Method Allowed POST
Headers Required Content-Type=application/json
Data Params {
name : [string],
test_code : [string],
hints : [string],
description : [string],
template : [string]
}
Successful Response Code: HTTP 201 Created,
Content: {
id : [string],
rev : [string]
}
Error Responses HTTP 400 400 Bad Request

Fetch exercise names

Title Content
URL /names
Method Allowed POST
Headers Required Content-Type=application/json
Data Params {
ids : [list]
}
Successful Response Code: HTTP 200 OK,
Content: {
id : [string],
name : [string]
}
Error Responses HTTP 400 400 Bad Request

TestRunner

Title Content
URL /test
Method Allowed POST
Headers Required Content-Type=application/json
Data Params {
code : [string],
testCode : [string]
}
Successful Response Code: HTTP 200 OK,
Content:
{
    results:{
         failed:{
            number:[integer],
            tests:[list]
        },
        passed: {
            number: [integer]
        }
    },
    errors:[string],
    time: [string]
}
Error Responses HTTP 400 400 Bad Request