Skip to content

Students

Maxwell Carter edited this page Jul 18, 2017 · 15 revisions

Students

GET

/students

Retrieve a list of all students and their corresponding details.

Request

GET https://smart-classroom-ece452.mybluemix.net/api/v1/students

Response

[
    {
        "_id": "594abc3ddd08c70029b4222f",
        "lastName": "Wayne",
        "firstName": "Bruce",
        "displayName": "Batman",
        "password": "BatMobile",
        "username": "Batman",
        "__v": 1,
        "goals": [],
        "quizHistory": [],
        "attendanceHistory": [],
        "classrooms": [
            "594abefadd08c70029b42235"
        ]
    }
]

/students/:id

Retrieve details of a particular student.

Request

https://smart-classroom-ece452.mybluemix.net/api/v1/students/594abc3ddd08c70029b4222f

Response

{
    "_id": "594abc3ddd08c70029b4222f",
    "lastName": "Wayne",
    "firstName": "Bruce",
    "displayName": "Batman",
    "password": "BatMobile",
    "username": "Batman",
    "__v": 1,
    "goals": [],
    "quizHistory": [],
    "attendanceHistory": [],
    "classrooms": [
        "594abefadd08c70029b42235"
    ]
}

POST

/students

Create a student.

Request

https://smart-classroom-ece452.mybluemix.net/api/v1/students
{
    "lastName": "Wayne",
    "firstName": "Bruce",
    "displayName": "Batman",
    "username": "Batman",
    "password": "BatMobile"
}

Response

{
    "_id": "594abc3ddd08c70029b4222f",
    "lastName": "Wayne",
    "firstName": "Bruce",
    "displayName": "Batman",
    "password": "BatMobile",
    "username": "Batman",
    "__v": 1,
    "goals": [],
    "quizHistory": [],
    "attendanceHistory": [],
    "classrooms": [
        "594abefadd08c70029b42235"
    ]
}

/students/:id/goals

Creates a goal for a student.

Request

POST https://smart-classroom-ece452.mybluemix.net/api/v1/students/594ad1ccdd08c70029b42237/goals
{
    "title": "Shoot an Arrow",
    "startDate": "06/21/17",
    "goal": "594ad28add08c70029b4223a"
}

Response

{
    "_id": "594abc3ddd08c70029b4222f",
    "lastName": "Wayne",
    "firstName": "Bruce",
    "displayName": "Batman",
    "password": "BatMobile",
    "username": "Batman",
    "__v": 1,
    "goals": [
        {
            "title": "Shoot an Arrow",
            "startDate": "2017-06-21T00:00:00.000Z",
            "goal": "594ad28add08c70029b4223a",
            "_id": "594ad32bdd08c70029b4223d",
            "activityLog": [],
            "mark": 0,
            "active": true,
            "completed": false
        }
    ],
    "quizHistory": [],
    "attendanceHistory": [],
    "classrooms": []
}

/students/:id/goals/:goalId/activityLogs

Updates the activity log of a goal for a particular student. Note: goalId is the id of the student goal, not the generic goal!

Request

POST https://smart-classroom-ece452.mybluemix.net/api/v1/students/594ad1ccdd08c70029b42237/goals/594ad32bdd08c70029b4223d/activityLogs
{
    "log": "Shot Bullseye",
    "date": "06/21/17",
    "weight": 1.0,
    "mark": 100
}

Response

Notice that the total goal mark is automatically updated.

{
    "_id": "594abc3ddd08c70029b4222f",
    "lastName": "Wayne",
    "firstName": "Bruce",
    "displayName": "Batman",
    "password": "BatMobile",
    "username": "Batman",
    "__v": 1,
    "goals": [
        {
            "title": "Shoot an Arrow",
            "startDate": "2017-06-21T00:00:00.000Z",
            "goal": "594ad28add08c70029b4223a",
            "_id": "594ad32bdd08c70029b4223d",
            "activityLog": [
                {
                    "log": "Shot Bullseye",
                    "date": "2017-06-21T00:00:00.000Z",
                    "weight": 1,
                    "mark": 100
                }
            ],
            "mark": 100,
            "active": true,
            "completed": false
        }
    ],
    "quizHistory": [],
    "attendanceHistory": [],
    "classrooms": []
}

/students/goals

Creates a goal for a list of students

Request

POST https://smart-classroom-ece452.mybluemix.net/api/v1/students/goals
{
	"students": ["596c50eb80d6b418d49923ef","596c510d80d6b418d49923f3"],
	"goal": {
		"title": "Shoot an Arrow",
		"startDate": "06/21/17",
		"goal": "596d0fed1dcb551b486cbd49"
	}
}

Response

You will receive a response indicating the request was accepted. The backend will then finish assigning the goals to students asynchronously.

{
    "accepted": true
}

/students/:id/quizzes

Submits a quiz

Request

POST https://smart-classroom-ece452.mybluemix.net/api/v1/students/596bbbd9a7b8400ea9f239e2/quizzes
{
    "title": "sample test",
    "quiz": "596c0bf4ba50a0156a05dce8",
    "_id": "596c00a38d9a8a148179be46",
    "results": [{
        "question": "When was the war of 1812?",
        "answer": "1812",
        "correct": true
      }],
    "weight": 0.5,
    "mark": 80
}

Response

{
    "_id": "596bbbd9a7b8400ea9f239e2",
    "username": "mcarter",
    "password": "$2a$10$XSkYb4npT/rS3yYxJfl7l.z/9xXOrtZR2UKC5NNaBxbQfKn1HGmfi",
    "firstName": "Max",
    "lastName": "Carter",
    "__v": 2,
    "goals": [],
    "quizHistory": [
        {
            "title": "sample test",
            "quiz": "596c0bf4ba50a0156a05dce8",
            "_id": "596c00a38d9a8a148179be46",
            "results": [{
                "question": "When was the war of 1812?",
                "answer": "1812",
                "correct": true
              }],
            "weight": 0.5,
            "mark": 80
        }
    ],
    "classrooms": [
        "596bea98afce0f111c7c2762"
    ],
    "attendanceHistory": [],
    "displayName": "Student"
}

DELETE

/students/:id

Delete a student.

Request

DELETE https://smart-classroom-ece452.mybluemix.net/api/v1/students/594abc3ddd08c70029b4222f

Response

Returns the deleted document.

{
    "_id": "594abc3ddd08c70029b4222f",
    "lastName": "Wayne",
    "firstName": "Bruce",
    "displayName": "Batman",
    "password": "BatMobile",
    "username": "Batman",
    "__v": 1,
    "goals": [],
    "quizHistory": [],
    "attendanceHistory": [],
    "classrooms": [
        "594abefadd08c70029b42235"
    ]
}

Clone this wiki locally