Spaces:
Build error
Build error
| from app import db | |
| from flask_sqlalchemy import SQLAlchemy | |
| import json | |
| class Feedback(db.Model): | |
| id = db.Column(db.Integer, primary_key=True) | |
| piece_id = db.Column(db.Integer, nullable=False) | |
| slot_id = db.Column(db.Integer, nullable=False) | |
| suggestions = db.Column(db.Text, nullable=False) | |
| user_choice = db.Column(db.Integer, nullable=False) | |
| is_correct = db.Column(db.Boolean, nullable=False) | |
| class FeedbackManager: | |
| def record_feedback(self, piece_id: int, slot_id: int, suggestions: dict, user_choice: int, is_correct: bool): | |
| feedback = Feedback( | |
| piece_id=piece_id, | |
| slot_id=slot_id, | |
| suggestions=json.dumps(suggestions), | |
| user_choice=user_choice, | |
| is_correct=is_correct | |
| ) | |
| db.session.add(feedback) | |
| db.session.commit() |