Skip to content
Snippets Groups Projects

Toggling pregrading and Identifying blank solutions

Open Ghost User requested to merge feature/toggle-pregrading into develop
Compare and Show latest version
2 files
+ 5
11
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -23,20 +23,13 @@ def upgrade():
sa.Column('name', sa.Text(), nullable=False),
sa.Column('exam_id', sa.Integer(), nullable=False),
sa.Column('grading_policy', sa.Enum('set_nothing', 'set_blank', 'set_blank_single', name='gradingpolicy'),
default=1, nullable=False),
server_default='set_blank', default='set_blank', nullable=False),
sa.ForeignKeyConstraint(['exam_id'], ['exam.id'], ),
sa.PrimaryKeyConstraint('id')
)
conn = op.get_bind()
old_problems = conn.execute('SELECT id, name, exam_id FROM problem').fetchall()
grading_policy = "'set_blank'"
for id, name, exam_id in old_problems:
# Add quotes for SQLite
name = "'" + name + "'"
conn.execute(f'INSERT INTO problem_copy VALUES ({id}, {name}, {exam_id}, {grading_policy})')
op.execute('INSERT INTO problem_copy (id, name, exam_id, grading_policy)' +
'SELECT id, name, exam_id, \'set_blank\' FROM problem')
op.drop_table('problem')
op.rename_table('problem_copy', 'problem')
Loading