From 9b7d92fe454f8804663a94ed1576f59cca69ea3c Mon Sep 17 00:00:00 2001 From: mohtamba Date: Wed, 11 Aug 2021 08:34:46 -0400 Subject: [PATCH 1/3] Initial Attempt at adding proctored exam settings Added proctored settings card, however the page doesn't get the legacy link correctly --- lms/djangoapps/courseware/plugins.py | 49 ++++++++++++++++++++++++++++ setup.py | 1 + 2 files changed, 50 insertions(+) diff --git a/lms/djangoapps/courseware/plugins.py b/lms/djangoapps/courseware/plugins.py index b75b730a3c..e9cb2db722 100644 --- a/lms/djangoapps/courseware/plugins.py +++ b/lms/djangoapps/courseware/plugins.py @@ -1,4 +1,5 @@ """Course app config for courseware apps.""" +from cms.djangoapps.contentstore.utils import get_proctored_exam_settings_url from typing import Dict, Optional from django import urls @@ -161,3 +162,51 @@ class CalculatorCourseApp(CourseApp): # There is nothing to configure for calculator yet. "configure": False, } + +class ProctoringCourseApp(CourseApp): + """ + Course App config for proctoring app. + """ + + app_id = "proctoring" + name = _("Proctoring") + description = _("Maintain exam integrity by enabling a proctoring solution for your course") + + @classmethod + def is_available(cls, course_key: CourseKey) -> bool: + """ + Proctoring is available for all courses. + """ + return True + + @classmethod + def is_enabled(cls, course_key: CourseKey) -> bool: + """ + Get calculator enabled status from course overview model. + """ + return CourseOverview.get_from_id(course_key).enable_proctored_exams + + @classmethod + def set_enabled(cls, course_key: CourseKey, enabled: bool, user: 'User') -> bool: + """ + Update calculator enabled status in modulestore. + """ + course = get_course_by_id(course_key) + course.enable_proctored_exams = enabled + modulestore().update_item(course, user.id) + return enabled + + @classmethod + def get_allowed_operations(cls, course_key: CourseKey, user: Optional[User] = None) -> Dict[str, bool]: + """ + Get allowed operations for calculator app. + """ + return { + "enable": True, + # There is nothing to configure for calculator yet. + "configure": False, + } + + @staticmethod + def legacy_link(course_key: CourseKey): + return get_proctored_exam_settings_url(course_key) diff --git a/setup.py b/setup.py index f24bf90063..d521bb2947 100644 --- a/setup.py +++ b/setup.py @@ -42,6 +42,7 @@ setup( "calculator = lms.djangoapps.courseware.plugins:CalculatorCourseApp", "discussion = openedx.core.djangoapps.discussions.plugins:DiscussionCourseApp", "edxnotes = lms.djangoapps.edxnotes.plugins:EdxNotesCourseApp", + "proctoring = lms.djangoapps.courseware.plugins:ProctoringCourseApp", "progress = lms.djangoapps.courseware.plugins:ProgressCourseApp", "teams = lms.djangoapps.teams.plugins:TeamsCourseApp", "textbooks = lms.djangoapps.courseware.plugins:TextbooksCourseApp", From e39d82ab249dfa34ca7de29f80fd49d9704029f3 Mon Sep 17 00:00:00 2001 From: mohtamba Date: Wed, 11 Aug 2021 16:15:08 -0400 Subject: [PATCH 2/3] Add check for Special Exams toggle --- lms/djangoapps/courseware/plugins.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/courseware/plugins.py b/lms/djangoapps/courseware/plugins.py index e9cb2db722..ce53647d98 100644 --- a/lms/djangoapps/courseware/plugins.py +++ b/lms/djangoapps/courseware/plugins.py @@ -163,6 +163,7 @@ class CalculatorCourseApp(CourseApp): "configure": False, } + class ProctoringCourseApp(CourseApp): """ Course App config for proctoring app. @@ -177,7 +178,7 @@ class ProctoringCourseApp(CourseApp): """ Proctoring is available for all courses. """ - return True + return settings.FEATURES.get("ENABLE_SPECIAL_EXAMS", False) @classmethod def is_enabled(cls, course_key: CourseKey) -> bool: From 0dd41df4f2b2f7933d95e5a05394da8b9a3987f5 Mon Sep 17 00:00:00 2001 From: mohtamba Date: Thu, 12 Aug 2021 14:28:49 -0400 Subject: [PATCH 3/3] Fix comments and adjust allowed settings Fix the allowed permissions on the proctored exam cards. --- lms/djangoapps/courseware/plugins.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lms/djangoapps/courseware/plugins.py b/lms/djangoapps/courseware/plugins.py index ce53647d98..40c8cd60f6 100644 --- a/lms/djangoapps/courseware/plugins.py +++ b/lms/djangoapps/courseware/plugins.py @@ -183,28 +183,25 @@ class ProctoringCourseApp(CourseApp): @classmethod def is_enabled(cls, course_key: CourseKey) -> bool: """ - Get calculator enabled status from course overview model. + Get proctoring enabled status from course overview model. """ return CourseOverview.get_from_id(course_key).enable_proctored_exams @classmethod def set_enabled(cls, course_key: CourseKey, enabled: bool, user: 'User') -> bool: """ - Update calculator enabled status in modulestore. + Don't allow proctored exam settings to be enabled from the card """ - course = get_course_by_id(course_key) - course.enable_proctored_exams = enabled - modulestore().update_item(course, user.id) - return enabled + raise ValueError("Teams cannot be enabled/disabled via this API.") @classmethod def get_allowed_operations(cls, course_key: CourseKey, user: Optional[User] = None) -> Dict[str, bool]: """ - Get allowed operations for calculator app. + Get allowed operations for proctoring app. """ return { - "enable": True, - # There is nothing to configure for calculator yet. + "enable": False, + # There is nothing to configure for proctored exams yet. "configure": False, }