Skip to content

Commit

Permalink
fix errors in creating proc session on exam
Browse files Browse the repository at this point in the history
  • Loading branch information
usamabinnadeem-10 committed Nov 8, 2024
1 parent 3380d41 commit 24208fa
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions webapp/shop/cred/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,10 +915,6 @@ def cred_exam(trueability_api, proctor_api, **_):
exam_date_time = None
if not assessment_reservation:
return flask.abort(403)
# student_session = proctor_api.get_student_sessions(
# {"ext_exam_id": assessment["id"]}
# )
# ext_exam_id = assessment["id"]
else:
student_session = proctor_api.get_student_sessions(
{"ext_exam_id": assessment_reservation["uuid"]}
Expand All @@ -935,7 +931,7 @@ def cred_exam(trueability_api, proctor_api, **_):
student_session_array = student_session.get("data", [{}])
should_redirect = False

# session exists
# if session exists
if len(student_session_array) > 0:
student_session = student_session_array[0]
# create a new session if it does not exist
Expand All @@ -945,7 +941,7 @@ def cred_exam(trueability_api, proctor_api, **_):
+ "credentials/exam?uuid="
+ f"{assessment_reservation.get('uuid', '')}"
)
student_session = proctor_api.create_student_session(
student_session_response = proctor_api.create_student_session(
{
"first_name": first_name,
"last_name": last_name,
Expand All @@ -956,6 +952,7 @@ def cred_exam(trueability_api, proctor_api, **_):
"exam_link": exam_link,
}
)
student_session = student_session_response.get("data", None)
should_redirect = True

if student_session is None or student_session.get("id", None) is None:
Expand All @@ -965,7 +962,10 @@ def cred_exam(trueability_api, proctor_api, **_):
should_redirect
or student_session.get("status", "not started") == "not started"
):
return flask.redirect(student_session["display_session_link"])
if student_session.get("display_session_link"):
return flask.redirect(student_session["display_session_link"])
if exam_link:
return flask.redirect(exam_link)

assessment_user = assessment["user"]["email"]
sso_user = user_info(flask.session)["email"]
Expand Down

0 comments on commit 24208fa

Please sign in to comment.