def create_question_variant(): form = QuestionVariantForm(request.form) data = dict(request.form) data.pop('csrf_token', None) if form.validate(): db.sqlalchemy_session.add(ormQuestionVariant(answer_variant_text=data.get('answer_variant_text'), question_id=int(data.get('question_id')))) db.sqlalchemy_session.commit() return redirect('/question_variants') else: return 'errors'
def update_answer_variant(id): form = QuestionVariantForm(request.form) data = dict(request.form) data.pop('csrf_token', None) if form.validate(): answer_variant = db.sqlalchemy_session.query(ormQuestionVariant).filter(ormQuestionVariant.answer_variant_id == id).first() if answer_variant: answer_variant.answer_variant_text = data.get('answer_variant_text', answer_variant.answer_variant_text) db.sqlalchemy_session.commit() return redirect('/question_variants') else: return 'errors'