diff --git a/server/app/apis/questions.py b/server/app/apis/questions.py index b14849d224501e48f9cce8a108bfd24f29657e99..94df2a36456baf6e8a492250944dc4156b5aa21f 100644 --- a/server/app/apis/questions.py +++ b/server/app/apis/questions.py @@ -14,11 +14,13 @@ question_parser_add = reqparse.RequestParser() question_parser_add.add_argument("name", type=str, default=None, location="json") question_parser_add.add_argument("total_score", type=int, default=None, location="json") question_parser_add.add_argument("type_id", type=int, required=True, location="json") +question_parser_add.add_argument("correcting_instructions", type=str, default=None, location="json") question_parser_edit = reqparse.RequestParser() question_parser_edit.add_argument("name", type=str, default=sentinel, location="json") question_parser_edit.add_argument("total_score", type=int, default=sentinel, location="json") question_parser_edit.add_argument("type_id", type=int, default=sentinel, location="json") +question_parser_edit.add_argument("correcting_instructions", type=str, default=sentinel, location="json") @api.route("/questions") diff --git a/server/app/core/rich_schemas.py b/server/app/core/rich_schemas.py index 7d883584776677ee1be21975ed5ae413dc2019fa..60f7ac309d37b3be15c0378a94a71dc10cdf7cc8 100644 --- a/server/app/core/rich_schemas.py +++ b/server/app/core/rich_schemas.py @@ -25,6 +25,7 @@ class QuestionSchemaRich(RichSchema): total_score = ma.auto_field() slide_id = ma.auto_field() type_id = ma.auto_field() + correcting_instructions = ma.auto_field() alternatives = fields.Nested(schemas.QuestionAlternativeSchema, many=True) diff --git a/server/app/core/schemas.py b/server/app/core/schemas.py index 73ac21cbd396d1ee175e6151003d05f1a10dc82b..a2e81c2568f6e1c100fbc5c302a200644e11433d 100644 --- a/server/app/core/schemas.py +++ b/server/app/core/schemas.py @@ -63,6 +63,7 @@ class QuestionSchema(BaseSchema): total_score = ma.auto_field() type_id = ma.auto_field() slide_id = ma.auto_field() + correcting_instructions = ma.auto_field() class QuestionAnswerSchema(BaseSchema): diff --git a/server/app/database/controller/add.py b/server/app/database/controller/add.py index 6c5ea14bcd143a4bac5d0f214fc3d14f8f73bfe0..128a3398aa375fb1b59732fc75e1349540e0826f 100644 --- a/server/app/database/controller/add.py +++ b/server/app/database/controller/add.py @@ -244,12 +244,12 @@ def user(email, password, role_id, city_id, name=None): return db_add(User(email, password, role_id, city_id, name)) -def question(name, total_score, type_id, slide_id): +def question(name, total_score, type_id, slide_id, correcting_instructions=None): """ Adds a question to the specified slide using the provided arguments. """ - return db_add(Question(name, total_score, type_id, slide_id)) + return db_add(Question(name, total_score, type_id, slide_id, correcting_instructions)) def question_alternative(text, value, question_id): diff --git a/server/app/database/models.py b/server/app/database/models.py index d4e177b070755d75cada2988e43468f28794146b..4bb95967aaeef34707e3defe7e38a173020dce30 100644 --- a/server/app/database/models.py +++ b/server/app/database/models.py @@ -154,15 +154,17 @@ class Question(db.Model): total_score = db.Column(db.Integer, nullable=False, default=1) type_id = db.Column(db.Integer, db.ForeignKey("question_type.id"), nullable=False) slide_id = db.Column(db.Integer, db.ForeignKey("slide.id"), nullable=False) + correcting_instructions = db.Column(db.Text, nullable=True, default=None) question_answers = db.relationship("QuestionAnswer", backref="question") alternatives = db.relationship("QuestionAlternative", backref="question") - def __init__(self, name, total_score, type_id, slide_id): + def __init__(self, name, total_score, type_id, slide_id, correcting_instructions): self.name = name self.total_score = total_score self.type_id = type_id self.slide_id = slide_id + self.correcting_instructions = correcting_instructions class QuestionAlternative(db.Model):