From b3f57fad10bc7bdc8e6579b3b1b91ce58bc48260 Mon Sep 17 00:00:00 2001 From: Deepansh Mathur Date: Fri, 7 Oct 2022 17:55:47 +0530 Subject: [PATCH 1/4] added url decoding of incoming params --- app/routers/reports.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/routers/reports.py b/app/routers/reports.py index ec768bb..d62e7b2 100644 --- a/app/routers/reports.py +++ b/app/routers/reports.py @@ -2,6 +2,7 @@ from fastapi.templating import Jinja2Templates from fastapi import HTTPException from collections import OrderedDict +from urllib.parse import unquote from models.student_quiz_report import StudentQuizReportController @@ -41,6 +42,10 @@ def _parse_section_data(section=None): @api_router.get("/student_quiz_report/{session_id}/{user_id}") def student_quiz_report(request: Request, session_id: str, user_id: str): + # decoding URL encoded values. As this information is coming through a URL, + # it's possible that the strings are URL encoded. + session_id = unquote(session_id) + user_id = unquote(user_id) if session_id is None or user_id is None: raise HTTPException( status_code=400, From 15d7a77e8f577c866528cb35d9b2886a437ef9ee Mon Sep 17 00:00:00 2001 From: Deepansh Mathur Date: Fri, 7 Oct 2022 18:57:09 +0530 Subject: [PATCH 2/4] added a print statement to debug on staging --- app/routers/reports.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/routers/reports.py b/app/routers/reports.py index d62e7b2..fe8c415 100644 --- a/app/routers/reports.py +++ b/app/routers/reports.py @@ -46,6 +46,8 @@ def student_quiz_report(request: Request, session_id: str, user_id: str): # it's possible that the strings are URL encoded. session_id = unquote(session_id) user_id = unquote(user_id) + print(session_id) + print(user_id) if session_id is None or user_id is None: raise HTTPException( status_code=400, From a66bd2db41a84794a7bae2cc655ddea0ed78a04e Mon Sep 17 00:00:00 2001 From: Deepansh Mathur Date: Fri, 7 Oct 2022 19:53:21 +0530 Subject: [PATCH 3/4] trying to print something on cloudwatch --- app/main.py | 1 + app/routers/reports.py | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/main.py b/app/main.py index 4b1cccc..eb95d97 100644 --- a/app/main.py +++ b/app/main.py @@ -29,6 +29,7 @@ @app.get("/") def index(): + print("HAHAHAHA") return "Hello World! Welcome to Reporting Engine!" diff --git a/app/routers/reports.py b/app/routers/reports.py index fe8c415..0f1dfb3 100644 --- a/app/routers/reports.py +++ b/app/routers/reports.py @@ -42,17 +42,17 @@ def _parse_section_data(section=None): @api_router.get("/student_quiz_report/{session_id}/{user_id}") def student_quiz_report(request: Request, session_id: str, user_id: str): + if session_id is None or user_id is None: + raise HTTPException( + status_code=400, + detail="Session ID and User ID have to be specified", + ) # decoding URL encoded values. As this information is coming through a URL, # it's possible that the strings are URL encoded. session_id = unquote(session_id) user_id = unquote(user_id) print(session_id) print(user_id) - if session_id is None or user_id is None: - raise HTTPException( - status_code=400, - detail="Session ID and User ID have to be specified", - ) try: data = self.__student_quiz_reports_controller.get_student_quiz_report( session_id=session_id, user_id=user_id From daa83b0758f975a80893c058c1f4c8059ec3a8d7 Mon Sep 17 00:00:00 2001 From: Deepansh Mathur Date: Sat, 8 Oct 2022 11:07:00 +0530 Subject: [PATCH 4/4] removed debug statements --- app/main.py | 1 - app/routers/reports.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/app/main.py b/app/main.py index eb95d97..4b1cccc 100644 --- a/app/main.py +++ b/app/main.py @@ -29,7 +29,6 @@ @app.get("/") def index(): - print("HAHAHAHA") return "Hello World! Welcome to Reporting Engine!" diff --git a/app/routers/reports.py b/app/routers/reports.py index 0f1dfb3..bb3e568 100644 --- a/app/routers/reports.py +++ b/app/routers/reports.py @@ -51,8 +51,6 @@ def student_quiz_report(request: Request, session_id: str, user_id: str): # it's possible that the strings are URL encoded. session_id = unquote(session_id) user_id = unquote(user_id) - print(session_id) - print(user_id) try: data = self.__student_quiz_reports_controller.get_student_quiz_report( session_id=session_id, user_id=user_id