Kerikim commited on
Commit
573db59
·
1 Parent(s): b677163

elkay: quiz.py

Browse files
Files changed (1) hide show
  1. phase/Student_view/quiz.py +12 -10
phase/Student_view/quiz.py CHANGED
@@ -18,16 +18,18 @@ def _get_quiz_from_source(quiz_id: int):
18
  # backend: expose GET /quizzes/{quiz_id}
19
  return api.get_quiz(quiz_id)
20
 
21
- def _submit_quiz_result(student_id: int, assignment_id: int, quiz_id: int,
22
- score: int, total: int, details: dict):
23
- """
24
- Submit a quiz result either to the local DB or to the backend API.
25
- """
26
- if USE_LOCAL_DB and hasattr(dbapi, "submit_quiz"):
27
- return dbapi.submit_quiz(student_id=student_id,
28
- assignment_id=assignment_id,
29
- quiz_id=quiz_id,
30
- score=score, total=total, details=details)
 
 
31
  # backend: POST /quizzes/submit (or your route of choice)
32
  return api.submit_quiz(student_id=student_id,
33
  assignment_id=assignment_id,
 
18
  # backend: expose GET /quizzes/{quiz_id}
19
  return api.get_quiz(quiz_id)
20
 
21
+ # phase/Student_view/quiz.py
22
+ def _submit_quiz_result(*, student_id: int, assignment_id: int, quiz_id: int,
23
+ score: int, total: int, answers: dict):
24
+ # answers -> goes to DB as 'details'
25
+ return api.submit_quiz(
26
+ student_id=student_id,
27
+ assignment_id=assignment_id,
28
+ quiz_id=quiz_id,
29
+ score=score,
30
+ total=total,
31
+ details=answers,
32
+ )
33
  # backend: POST /quizzes/submit (or your route of choice)
34
  return api.submit_quiz(student_id=student_id,
35
  assignment_id=assignment_id,