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

Resolve "Add correcting instructions in question"

parent be657153
No related branches found
No related tags found
1 merge request!116Resolve "Add correcting instructions in question"
Pipeline #43039 passed with warnings
...@@ -56,6 +56,7 @@ export interface Question extends NameID { ...@@ -56,6 +56,7 @@ export interface Question extends NameID {
slide_id: number slide_id: number
total_score: number total_score: number
type_id: number type_id: number
correcting_instructions: string
} }
export interface QuestionAlternative { export interface QuestionAlternative {
......
...@@ -36,5 +36,6 @@ export interface RichQuestion { ...@@ -36,5 +36,6 @@ export interface RichQuestion {
total_score: number total_score: number
question_type: QuestionType question_type: QuestionType
type_id: number type_id: number
correcting_instructions: string
alternatives: QuestionAlternative[] alternatives: QuestionAlternative[]
} }
...@@ -30,7 +30,7 @@ const Instructions = ({ activeSlide, competitionId }: InstructionsProps) => { ...@@ -30,7 +30,7 @@ const Instructions = ({ activeSlide, competitionId }: InstructionsProps) => {
.put( .put(
`/api/competitions/${competitionId}/slides/${activeSlide.id}/questions/${activeSlide.questions[0].id}`, `/api/competitions/${competitionId}/slides/${activeSlide.id}/questions/${activeSlide.questions[0].id}`,
{ {
instructions: event.target.value, correcting_instructions: event.target.value,
} }
) )
.then(() => { .then(() => {
...@@ -56,7 +56,7 @@ const Instructions = ({ activeSlide, competitionId }: InstructionsProps) => { ...@@ -56,7 +56,7 @@ const Instructions = ({ activeSlide, competitionId }: InstructionsProps) => {
<Center> <Center>
<TextField <TextField
id="outlined-basic" id="outlined-basic"
defaultValue={''} defaultValue={activeSlide.questions[0].correcting_instructions}
onChange={updateInstructionsText} onChange={updateInstructionsText}
variant="outlined" variant="outlined"
fullWidth={true} fullWidth={true}
......
...@@ -20,7 +20,7 @@ const JudgeScoringInstructions = ({ question }: JudgeScoringInstructionsProps) = ...@@ -20,7 +20,7 @@ const JudgeScoringInstructions = ({ question }: JudgeScoringInstructionsProps) =
return ( return (
<JudgeScoringInstructionsContainer elevation={3}> <JudgeScoringInstructionsContainer elevation={3}>
<Typography variant="h4">Rättningsinstruktioner</Typography> <Typography variant="h4">Rättningsinstruktioner</Typography>
<Typography variant="body1">Såhär rättar du denhär frågan</Typography> <Typography variant="body1">{question?.correcting_instructions}</Typography>
</JudgeScoringInstructionsContainer> </JudgeScoringInstructionsContainer>
) )
} }
......
...@@ -14,11 +14,13 @@ question_parser_add = reqparse.RequestParser() ...@@ -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("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("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("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 = reqparse.RequestParser()
question_parser_edit.add_argument("name", type=str, default=sentinel, location="json") 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("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("type_id", type=int, default=sentinel, location="json")
question_parser_edit.add_argument("correcting_instructions", type=str, default=sentinel, location="json")
@api.route("/questions") @api.route("/questions")
......
...@@ -25,6 +25,7 @@ class QuestionSchemaRich(RichSchema): ...@@ -25,6 +25,7 @@ class QuestionSchemaRich(RichSchema):
total_score = ma.auto_field() total_score = ma.auto_field()
slide_id = ma.auto_field() slide_id = ma.auto_field()
type_id = ma.auto_field() type_id = ma.auto_field()
correcting_instructions = ma.auto_field()
alternatives = fields.Nested(schemas.QuestionAlternativeSchema, many=True) alternatives = fields.Nested(schemas.QuestionAlternativeSchema, many=True)
......
...@@ -63,6 +63,7 @@ class QuestionSchema(BaseSchema): ...@@ -63,6 +63,7 @@ class QuestionSchema(BaseSchema):
total_score = ma.auto_field() total_score = ma.auto_field()
type_id = ma.auto_field() type_id = ma.auto_field()
slide_id = ma.auto_field() slide_id = ma.auto_field()
correcting_instructions = ma.auto_field()
class QuestionAnswerSchema(BaseSchema): class QuestionAnswerSchema(BaseSchema):
......
...@@ -244,12 +244,12 @@ def user(email, password, role_id, city_id, name=None): ...@@ -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)) 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. 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): def question_alternative(text, value, question_id):
......
...@@ -24,6 +24,7 @@ def _question(item_question_old, slide_id): ...@@ -24,6 +24,7 @@ def _question(item_question_old, slide_id):
item_question_old.total_score, item_question_old.total_score,
item_question_old.type_id, item_question_old.type_id,
slide_id, slide_id,
item_question_old.correcting_instructions,
) )
) )
......
...@@ -154,15 +154,17 @@ class Question(db.Model): ...@@ -154,15 +154,17 @@ class Question(db.Model):
total_score = db.Column(db.Integer, nullable=False, default=1) total_score = db.Column(db.Integer, nullable=False, default=1)
type_id = db.Column(db.Integer, db.ForeignKey("question_type.id"), nullable=False) 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) 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") question_answers = db.relationship("QuestionAnswer", backref="question")
alternatives = db.relationship("QuestionAlternative", 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.name = name
self.total_score = total_score self.total_score = total_score
self.type_id = type_id self.type_id = type_id
self.slide_id = slide_id self.slide_id = slide_id
self.correcting_instructions = correcting_instructions
class QuestionAlternative(db.Model): 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