File size: 665 Bytes
b7a7f32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from cruds.base import CRUDBase
from schemas import QuizAnswerCreate, QuizAnswerUpdate
from models import QuizAnswer
from sqlalchemy.orm import Session


class CRUDQuizAnswer(CRUDBase[QuizAnswer, QuizAnswerCreate, QuizAnswerUpdate]):
    def get_by_quiz_id(self, db: Session, *, quizId: int, studentId: int):
        return (
            db.query(self.model)
            .filter_by(quiz_id=quizId)
            .filter_by(student_id=studentId)
            .first()
        )

    def get_all_by_quiz_id_as_teacher(self, db: Session, *, quizId: int):
        return db.query(self.model).filter_by(quiz_id=quizId).all()


crud_quiz_answer = CRUDQuizAnswer(QuizAnswer)