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>')
......@@ -7,17 +7,37 @@ class Students(Resource):
"""Getting a list of students."""
def get(self):
def get(self, student_id=None):
"""get all students for the course.
student_id : int, optional
The ID of the student, often the studentnumber but mainly used as unique identifier
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 {
'firstName': s.first_name,
'lastName': s.last_name,
return [
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment