Skip to content
Snippets Groups Projects
Commit 2c002e87 authored by Thomas Roos's avatar Thomas Roos
Browse files

Get api for feedback(options)

parent f09dd532
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ from .resources.students import Students
from .resources.submissions import Submissions
from .resources import signature
from .resources.problems import Problems
from .resources.feedback import Feedback
api_bp = Blueprint(__name__, __name__)
......@@ -29,6 +30,8 @@ api.add_resource(Submissions,
'/submissions/<int:exam_id>',
'/submissions/<int:exam_id>/<int:submission_id>')
api.add_resource(Problems, '/problems/<int:exam_id>')
api.add_resource(Feedback, '/feedback/<int:problem_id>')
# Other resources that don't return JSON
# It is possible to get flask_restful to work with these, but not
......
""" REST api for problems """
from flask_restful import Resource
from pony import orm
from ..models import Problem, FeedbackOption
class Feedback(Resource):
""" List of feedback options of a problem """
@orm.db_session
def get(self, problem_id):
"""get list of feedback connected to a specific problem
Returns
-------
list of:
id: int
name: str
description: str
score: int
"""
problem = Problem[problem_id]
return [
{
'id': fb.id,
'name': fb.text,
'description': fb.description,
'score': fb.score
}
for fb in FeedbackOption.select(lambda fb: fb.problem == problem)
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment