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

Multiple choice options can now be added to the database

parent 7e84c347
No related branches found
No related tags found
1 merge request!5Add multiple choice checkbox location to database
Pipeline #17376 passed
No preview for this file type
""" empty message
Revision ID: d7b1f5d92589
Revises: 4204f4a83863
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'd7b1f5d92589'
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('label', sa.String(), nullable=False),
sa.Column('problem_id', sa.Integer(), nullable=True),
sa.Column('feedback_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['feedback_id'], ['feedback_option.id'], ),
sa.ForeignKeyConstraint(['problem_id'], ['solution.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.drop_table('sqlite_sequence')
# 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,6 +11,7 @@ from .feedback import Feedback
from .solutions import Solutions
from .widgets import Widgets
from .emails import EmailTemplate, RenderedEmailTemplate, Email
from .mult_choice import MultipleChoice
from . import signature
from . import images
from . import summary_plot
......@@ -55,6 +56,8 @@ api.add_resource(RenderedEmailTemplate,
api.add_resource(Email,
'/email/<int:exam_id>',
'/email/<int:exam_id>/<int:student_id>')
api.add_resource(MultipleChoice,
'/mult-choice/<int:id>/<int:x>/<int:y>/<string:label>/<int:problem_id>/<int:feedback_id>')
# Other resources that don't return JSON
......
from flask_restful import Resource
from ..database import db, MultipleChoiceOption
class MultipleChoice(Resource):
def put(self, id, x, y, label, problem_id, feedback_id):
mc_entry = MultipleChoiceOption(id=id, x=x, y=y, label=label, problem_id=problem_id, feedback_id=feedback_id)
db.session.add(mc_entry)
db.session.commit()
return dict(status=200, message="ok"), 200
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