Ejemplo n.º 1
0
 def get_quiz_result_by_quiz_id_user_id(quiz_id, user_id):
     hs = Historysession.get_current_history_session_by_user_id_quiz_id(user_id)
     if hs:
         qr = QuizResult.query.filter_by(session_id=hs.hsid).first()
         if qr:
             qr.quiz = Quiz.get_quiz_only_by_id(qr.quiz_id)
         return qr
     else:
         return None
Ejemplo n.º 2
0
def jdelete(quiz_id):
    current_app.logger.debug("jdelete. quiz_id - " + str(quiz_id))
    
    quiz = Quiz.get_quiz_only_by_id(quiz_id)
    
    if quiz:
        if current_user.id == quiz.user_id:

            QuizResult.delete_quiz_results_by_quiz_id(quiz_id)
            Quiz.delete_quiz_by_id(quiz_id)

            db.session.commit()
            current_app.logger.debug("Quiz deleted")

            return jsonify({"status": "OK"})
        else:
            msg = auth_failure_message + u"delete this quiz(id = " + str(quiz_id).decode("UTF-8")+")"
            current_app.logger.warning(msg)
            return jsonify({"status": "ERROR", "message" : msg})
    else:
        msg = u"No quiz found with such quiz_id" + str(quiz_id).decode("UTF-8")
        current_app.logger.warning(msg)        
        return jsonify({"status": "ERROR", "message": msg})
Ejemplo n.º 3
0
 def get_quiz_result_by_id(session_id):
     quiz_result = QuizResult.query.filter_by(session_id=session_id).first()
     if quiz_result:
         quiz_result.quiz = Quiz.get_quiz_only_by_id(quiz_result.quiz_id)
         quiz_result.question_results = QuestionResult.get_question_results_by_id(session_id)
     return quiz_result