Commit 039e21bd authored by Thomas Roos's avatar Thomas Roos

Add option to get single student from api

parent 8d25b2d8
......@@ -23,7 +23,7 @@ api.add_resource(Graders, '/graders')
api.add_resource(Exams, '/exams')
api.add_resource(ExamConfig, '/exams/<int:exam_id>')
api.add_resource(Pdfs, '/pdfs/<int:exam_id>')
api.add_resource(Students, '/students')
api.add_resource(Students, '/students', '/students/<int:student_id>')
api.add_resource(Submissions,
'/submissions/<int:exam_id>',
'/submissions/<int:exam_id>/<int:submission_id>')
......
......@@ -7,17 +7,37 @@ class Students(Resource):
"""Getting a list of students."""
@orm.db_session
def get(self):
def get(self, student_id=None):
"""get all students for the course.
Parameters
----------
student_id : int, optional
The ID of the student, often the studentnumber but mainly used as unique identifier
Returns
-------
list of:
If a valid 'student_id' is provided the single instance of the student will be returned:
id: int
first_name: str
last_name: str
email: str
email: str
If no student_id is provided the entire list of students will be returned.
"""
if student_id is not None:
s = Student.get(id=student_id)
if not s:
raise orm.core.ObjectNotFound(Student)
return {
'id': s.id,
'firstName': s.first_name,
'lastName': s.last_name,
'email': s.email,
}
return [
{
'id': s.id,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment