Skip to content
Snippets Groups Projects
Commit 74899114 authored by Ruben Young On's avatar Ruben Young On
Browse files

Added hybrid property to problem, removed direct relation between mc_option...

Added hybrid property to problem, removed direct relation between mc_option and problem, changed API
parent b9a66ed2
No related branches found
No related tags found
1 merge request!12Fix relation between MultipleChoiceOption and FeedbackOption
Pipeline #17706 passed
This commit is part of merge request !12. Comments created here will be created in the context of that merge request.
......@@ -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
......
......@@ -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"""
......
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