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

Label is now nullable

parent b148cc14
No related branches found
No related tags found
1 merge request!5Add multiple choice checkbox location to database
Pipeline #17405 passed
""" empty message
Revision ID: 31224fbb20ca
Revision ID: f97aa3c73453
Revises: 4204f4a83863
"""
......@@ -9,34 +9,26 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '31224fbb20ca'
revision = 'f97aa3c73453'
down_revision = '4204f4a83863'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('mc_option',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('x', sa.Integer(), nullable=False),
sa.Column('y', sa.Integer(), nullable=False),
sa.Column('page', sa.Integer(), nullable=False),
sa.Column('label', sa.String(), nullable=False),
sa.Column('problem_id', sa.Integer(), nullable=True),
sa.Column('label', sa.String(), nullable=True),
sa.Column('problem_id', sa.Integer(), nullable=False),
sa.Column('feedback_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['feedback_id'], ['feedback_option.id'], ),
sa.ForeignKeyConstraint(['problem_id'], ['solution.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('sqlite_sequence',
sa.Column('name', sa.NullType(), nullable=True),
sa.Column('seq', sa.NullType(), nullable=True)
)
op.drop_table('mc_option')
# ### end Alembic commands ###
......@@ -11,7 +11,7 @@ class MultipleChoice(Resource):
put_parser.add_argument('x', type=int, required=True)
put_parser.add_argument('y', type=int, required=True)
put_parser.add_argument('page', type=int, required=True)
put_parser.add_argument('label', type=str, required=True)
put_parser.add_argument('label', type=str, required=False)
put_parser.add_argument('problem_id', type=int, required=True)
put_parser.add_argument('feedback_id', type=int, required=True)
......@@ -81,11 +81,15 @@ class MultipleChoice(Resource):
if not mult_choice:
return dict(status=404, message='Multiple choice question does not exist.'), 404
return {
json = {
"id": mult_choice.id,
"x": mult_choice.x,
"y": mult_choice.y,
"label": mult_choice.label,
"problem_id": mult_choice.problem_id,
"feedback_id": mult_choice.feedback_id
}
if mult_choice.label:
json['label'] = mult_choice.label
return json
......@@ -168,10 +168,10 @@ class MultipleChoiceOption(db.Model):
y = Column(Integer, nullable=False)
page = Column(Integer, nullable=False)
label = Column(String, nullable=False)
label = Column(String, nullable=True)
problem_id = Column(Integer, ForeignKey('solution.id'))
feedback_id = Column(Integer, ForeignKey('feedback_option.id'))
problem_id = Column(Integer, ForeignKey('solution.id'), nullable=False)
feedback_id = Column(Integer, ForeignKey('feedback_option.id'), nullable=True)
class ExamWidget(Widget):
......
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