TIF_E41211115_Genso_quiz_ba.../app/controllers/history_controller.py

33 lines
1.1 KiB
Python

from app.services import HistoryService
from app.helpers import make_error_response, make_response
class HistoryController:
def __init__(self, history_service: HistoryService):
self.history_service = history_service
def get_quiz_by_user(self, user_id: str):
try:
data = self.history_service.get_history_by_user_id(user_id)
return make_response(message="retrive history data", data=data)
except Exception as e:
return make_error_response(e)
def get_detail_quiz_history(self, answer_id: str):
try:
data = self.history_service.get_history_by_answer_id(answer_id)
return make_response(
message="success retrive detail history data", data=data
)
except Exception as e:
return make_error_response(e)
def get_session_history(self, session_id):
try:
result = self.history_service.get_session_history(session_id)
return make_response(message="success get history session", data=result)
except Exception as e:
return make_error_response(e)