diff --git a/client/package-lock.json b/client/package-lock.json index 72fcea719f2d7503990a778ded3a56f7b0e55e5f..2655ad2e5dbc1fb024ba896a3701f49adbfe399d 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -17285,7 +17285,8 @@ }, "ssri": { "version": "6.0.1", - "resolved": "", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.1.tgz", + "integrity": "sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA==", "requires": { "figgy-pudding": "^3.5.1" } diff --git a/server/app/apis/alternatives.py b/server/app/apis/alternatives.py index 94f6d6b1725106a3cf5994570e4d3d5829ba2dbe..d054baa94d4abbd1e9a13f42380ceb5bd3159700 100644 --- a/server/app/apis/alternatives.py +++ b/server/app/apis/alternatives.py @@ -1,10 +1,14 @@ +""" +All API calls concerning question alternatives. +Default route: /api/competitions/<competition_id>/slides/<slide_id>/questions/<question_id>/alternatives +""" + import app.core.http_codes as codes import app.database.controller as dbc from app.apis import item_response, list_response, protect_route from app.core.dto import QuestionAlternativeDTO -from flask_restx import Resource -from flask_restx import reqparse from app.core.parsers import sentinel +from flask_restx import Resource, reqparse api = QuestionAlternativeDTO.api schema = QuestionAlternativeDTO.schema @@ -24,11 +28,15 @@ alternative_parser_edit.add_argument("value", type=int, default=sentinel, locati class QuestionAlternativeList(Resource): @protect_route(allowed_roles=["*"], allowed_views=["*"]) def get(self, competition_id, slide_id, question_id): + """ Gets the all question alternatives to the specified question. """ + items = dbc.get.question_alternative_list(competition_id, slide_id, question_id) return list_response(list_schema.dump(items)) @protect_route(allowed_roles=["*"]) def post(self, competition_id, slide_id, question_id): + """ Posts a new question alternative to the specified question. """ + args = alternative_parser_add.parse_args(strict=True) item = dbc.add.question_alternative(**args, question_id=question_id) return item_response(schema.dump(item)) @@ -39,11 +47,15 @@ class QuestionAlternativeList(Resource): class QuestionAlternatives(Resource): @protect_route(allowed_roles=["*"], allowed_views=["*"]) def get(self, competition_id, slide_id, question_id, alternative_id): + """ Gets the specified question alternative. """ + items = dbc.get.question_alternative(competition_id, slide_id, question_id, alternative_id) return item_response(schema.dump(items)) @protect_route(allowed_roles=["*"]) def put(self, competition_id, slide_id, question_id, alternative_id): + """ Edits the specified question alternative. """ + args = alternative_parser_edit.parse_args(strict=True) item = dbc.get.question_alternative(competition_id, slide_id, question_id, alternative_id) item = dbc.edit.default(item, **args) @@ -51,6 +63,8 @@ class QuestionAlternatives(Resource): @protect_route(allowed_roles=["*"]) def delete(self, competition_id, slide_id, question_id, alternative_id): + """ Deletes the specified question alternative. """ + item = dbc.get.question_alternative(competition_id, slide_id, question_id, alternative_id) dbc.delete.default(item) return {}, codes.NO_CONTENT