Skip to content
Snippets Groups Projects
Commit 5075e5a8 authored by Victor Löfgren's avatar Victor Löfgren
Browse files

Add correcting instructions to question

parent b4947d0a
No related branches found
No related tags found
1 merge request!116Resolve "Add correcting instructions in question"
This commit is part of merge request !116. Comments created here will be created in the context of that merge request.
......@@ -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")
......
......@@ -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)
......
......@@ -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):
......
......@@ -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):
......
......@@ -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):
......
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