From 5fc0c0e0f584d2a73ddb8578070f1c8f6652d056 Mon Sep 17 00:00:00 2001 From: Zacharis278 Date: Thu, 14 Dec 2023 16:03:23 -0500 Subject: [PATCH] fix: not all usage keys matching --- edx_exams/apps/api/v1/urls.py | 4 ++-- edx_exams/apps/core/constants.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/edx_exams/apps/api/v1/urls.py b/edx_exams/apps/api/v1/urls.py index a6a80ec8..2207bdde 100644 --- a/edx_exams/apps/api/v1/urls.py +++ b/edx_exams/apps/api/v1/urls.py @@ -13,7 +13,7 @@ ProctoringProvidersView, ProctoringSettingsView ) -from edx_exams.apps.core.constants import CONTENT_ID_PATTERN, COURSE_ID_PATTERN, EXAM_ID_PATTERN +from edx_exams.apps.core.constants import COURSE_ID_PATTERN, EXAM_ID_PATTERN, USAGE_KEY_PATTERN app_name = 'v1' @@ -59,7 +59,7 @@ name='instructor-attempts-list' ), re_path( - fr'student/exam/attempt/course_id/{COURSE_ID_PATTERN}/content_id/{CONTENT_ID_PATTERN}', + fr'student/exam/attempt/course_id/{COURSE_ID_PATTERN}/content_id/{USAGE_KEY_PATTERN}', CourseExamAttemptView.as_view(), name='student-course_exam_attempt' ), diff --git a/edx_exams/apps/core/constants.py b/edx_exams/apps/core/constants.py index 7b3b90ba..8159d000 100644 --- a/edx_exams/apps/core/constants.py +++ b/edx_exams/apps/core/constants.py @@ -15,6 +15,6 @@ class Status: COURSE_ID_PATTERN = rf'(?P({INTERNAL_COURSE_KEY_PATTERN}|{EXTERNAL_COURSE_KEY_PATTERN}))' -CONTENT_ID_PATTERN = r'(?P([A-Za-z0-9-_:@\+]+))' +USAGE_KEY_PATTERN = r'(?P(?:i4x://?[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))' EXAM_ID_PATTERN = r'(?P\d+)'