From 9b7d92fe454f8804663a94ed1576f59cca69ea3c Mon Sep 17 00:00:00 2001 From: mohtamba Date: Wed, 11 Aug 2021 08:34:46 -0400 Subject: [PATCH] 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",