Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. # TODO: complete the decoration [x]
  2. @quizzes.route("/quiz/<int:id>", methods=['GET', 'DELETE'])
  3. def single_quiz(id):
  4.     global _LOADED_QUIZZES
  5.     result = ""
  6.  
  7.     # TODO: check if the quiz is an existing one [x]
  8.     exists_quiz(id)
  9.  
  10.     if 'GET' == request.method:
  11.         # TODO: retrieve a quiz <id> [x]
  12.         result = Quiz.getQuestion(id)
  13.  
  14.     elif 'DELETE' == request.method:
  15.         # TODO: delete a quiz and get back number of answered questions [x][x]
  16.         # and total number of questions [x]
  17.  
  18.         _LOADED_QUIZZES.remove(id)
  19.  
  20.         result = jsonify({
  21.             "answered_questions": quiz.currentQuestion,
  22.             "total_questions": quiz.questions
  23.         })
  24.  
  25.     return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement