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 Sep 30, 2024
1 parent 07ab43b commit df59cc6
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 @@ -909,10 +909,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 @@ -929,7 +925,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 @@ -939,7 +935,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 @@ -950,6 +946,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 @@ -959,7 +956,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 df59cc6

Please sign in to comment.