diff --git a/zesje/api/mult_choice.py b/zesje/api/mult_choice.py index edb091822106ece14ba8aef202a918314b5ff12f..b2f2f4a6522e77fe07e037422b19ad2701069cc5 100644 --- a/zesje/api/mult_choice.py +++ b/zesje/api/mult_choice.py @@ -88,7 +88,7 @@ class MultipleChoice(Resource): if not mc_entry: return dict(status=404, message=f"Multiple choice question with id {id} does not exist"), 404 - set_mc_data(mc_entry, name, x, y, mc_type, problem_id, feedback_id, label) + set_mc_data(mc_entry, name, x, y, mc_type, feedback_id, label) db.session.commit() return dict(status=200, message=f'Multiple choice question with id {id} updated'), 200 diff --git a/zesje/database.py b/zesje/database.py index 16f53b27283d8578e616166e1520845c5804dc80..157eb9b4f1e1935510b1ccd13631528c0c9298d9 100644 --- a/zesje/database.py +++ b/zesje/database.py @@ -8,6 +8,7 @@ from sqlalchemy import Column, Integer, String, Text, DateTime, Boolean, Foreign from flask_sqlalchemy.model import BindMetaMixin, Model from sqlalchemy.ext.declarative import DeclarativeMeta, declarative_base from sqlalchemy.orm.session import object_session +from sqlalchemy.ext.hybrid import hybrid_property # Class for NOT automatically determining table names @@ -98,9 +99,12 @@ class Problem(db.Model): exam_id = Column(Integer, ForeignKey('exam.id'), nullable=False) feedback_options = db.relationship('FeedbackOption', backref='problem', order_by='FeedbackOption.id', lazy=True) solutions = db.relationship('Solution', backref='problem', lazy=True) - mc_options = db.relationship('MultipleChoiceOption', backref='problem', lazy=True) widget = db.relationship('ProblemWidget', backref='problem', uselist=False, lazy=True) + @hybrid_property + def mc_options(self): + return [mc_option for mc_option in self.feedback_options] + class FeedbackOption(db.Model): """feedback option"""