Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cms/djangoapps/contentstore/views/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@
from util.date_utils import get_default_time_display
from util.json_request import JsonResponse, JsonResponseBadRequest, expect_json
from util.milestones_helpers import (
is_entrance_exams_enabled,
is_prerequisite_courses_enabled,
is_valid_course_key,
remove_prerequisite_course,
set_prerequisite_courses
)
from util.organizations_helpers import add_organization_course, get_organization_by_short_name, organizations_enabled
from util.string_utils import _has_non_ascii_characters
from openedx.core import toggles as core_toggles
from xblock_django.api import deprecated_xblocks
from xmodule.contentstore.content import StaticContent
from xmodule.course_module import DEFAULT_START_DATE, CourseFields
Expand Down Expand Up @@ -1121,7 +1121,7 @@ def settings_handler(request, course_key_string):
'show_min_grade_warning': False,
'enrollment_end_editable': enrollment_end_editable,
'is_prerequisite_courses_enabled': is_prerequisite_courses_enabled(),
'is_entrance_exams_enabled': is_entrance_exams_enabled(),
'is_entrance_exams_enabled': core_toggles.ENTRANCE_EXAMS.is_enabled(),
'enable_extended_course_details': enable_extended_course_details,
'upgrade_deadline': upgrade_deadline,
'course_authoring_microfrontend_url': course_authoring_microfrontend_url,
Expand Down Expand Up @@ -1183,7 +1183,7 @@ def settings_handler(request, course_key_string):
# feature-specific settings and handle them accordingly
# We have to be careful that we're only executing the following logic if we actually
# need to create or delete an entrance exam from the specified course
if is_entrance_exams_enabled():
if core_toggles.ENTRANCE_EXAMS.is_enabled():
course_entrance_exam_present = course_module.entrance_exam_enabled
entrance_exam_enabled = request.json.get('entrance_exam_enabled', '') == 'true'
ee_min_score_pct = request.json.get('entrance_exam_minimum_score_pct', None)
Expand Down
27 changes: 13 additions & 14 deletions cms/djangoapps/contentstore/views/entrance_exam.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from openedx.core.djangolib.js_utils import dump_js_escaped_json
from student.auth import has_course_author_access
from util import milestones_helpers
from openedx.core import toggles as core_toggles
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError

Expand All @@ -42,23 +43,21 @@ def _get_default_entrance_exam_minimum_pct():
return entrance_exam_minimum_score_pct


def check_feature_enabled(feature_name):
def check_entrance_exams_enabled(view_func):
"""
Ensure the specified feature is turned on. Return an HTTP 400 code if not.
Ensure the entrance exams feature is turned on. Return an HTTP 400 code if not.
"""
def _check_feature_enabled(view_func):
def _decorator(request, *args, **kwargs):
# Deny access if the entrance exam feature is disabled
if not settings.FEATURES.get(feature_name, False):
return HttpResponseBadRequest()
return view_func(request, *args, **kwargs)
return wraps(view_func)(_decorator)
return _check_feature_enabled
def _decorator(request, *args, **kwargs):
# Deny access if the entrance exam feature is disabled
if not core_toggles.ENTRANCE_EXAMS.is_enabled():
return HttpResponseBadRequest()
return view_func(request, *args, **kwargs)
return wraps(view_func)(_decorator)


@login_required
@ensure_csrf_cookie
@check_feature_enabled(feature_name='ENTRANCE_EXAMS')
@check_entrance_exams_enabled
def entrance_exam(request, course_key_string):
"""
The restful handler for entrance exams.
Expand Down Expand Up @@ -105,7 +104,7 @@ def entrance_exam(request, course_key_string):
return HttpResponse(status=405)


@check_feature_enabled(feature_name='ENTRANCE_EXAMS')
@check_entrance_exams_enabled
def create_entrance_exam(request, course_key, entrance_exam_minimum_score_pct):
"""
api method to create an entrance exam.
Expand Down Expand Up @@ -186,7 +185,7 @@ def _get_entrance_exam(request, course_key):
return HttpResponse(status=404)


@check_feature_enabled(feature_name='ENTRANCE_EXAMS')
@check_entrance_exams_enabled
def update_entrance_exam(request, course_key, exam_data):
"""
Operation to update course fields pertaining to entrance exams
Expand All @@ -200,7 +199,7 @@ def update_entrance_exam(request, course_key, exam_data):
CourseMetadata.update_from_dict(metadata, course, request.user)


@check_feature_enabled(feature_name='ENTRANCE_EXAMS')
@check_entrance_exams_enabled
def delete_entrance_exam(request, course_key):
"""
api method to delete an entrance exam
Expand Down
6 changes: 3 additions & 3 deletions cms/djangoapps/contentstore/views/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from cms.djangoapps.models.settings.course_grading import CourseGradingModel
from edxmako.shortcuts import render_to_string
from util.milestones_helpers import is_entrance_exams_enabled
from openedx.core.toggles import ENTRANCE_EXAMS
from xmodule.modulestore.django import modulestore
from xmodule.tabs import StaticTab
from xmodule.x_module import DEPRECATION_VSCOMPAT_EVENT
Expand Down Expand Up @@ -214,7 +214,7 @@ def create_xblock(parent_locator, user, category, display_name, boilerplate=None

# Entrance Exams: Chapter module positioning
child_position = None
if is_entrance_exams_enabled():
if ENTRANCE_EXAMS.is_enabled():
if category == 'chapter' and is_entrance_exam:
fields['is_entrance_exam'] = is_entrance_exam
fields['in_entrance_exam'] = True # Inherited metadata, all children will have it
Expand All @@ -238,7 +238,7 @@ def create_xblock(parent_locator, user, category, display_name, boilerplate=None
)

# Entrance Exams: Grader assignment
if is_entrance_exams_enabled():
if ENTRANCE_EXAMS.is_enabled():
course_key = usage_key.course_key
course = store.get_course(course_key)
if hasattr(course, 'entrance_exam_enabled') and course.entrance_exam_enabled:
Expand Down
4 changes: 2 additions & 2 deletions cms/djangoapps/contentstore/views/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from student.auth import has_studio_read_access, has_studio_write_access
from util.date_utils import get_default_time_display
from util.json_request import JsonResponse, expect_json
from util.milestones_helpers import is_entrance_exams_enabled
from openedx.core.toggles import ENTRANCE_EXAMS
from xblock_django.user_service import DjangoXBlockUserService
from xmodule.course_module import DEFAULT_START_DATE
from xmodule.library_tools import LibraryToolsService
Expand Down Expand Up @@ -100,7 +100,7 @@ def _filter_entrance_exam_grader(graders):
views/controls like the 'Grade as' dropdown that allows a course author to select
the grader type for a given section of a course
"""
if is_entrance_exams_enabled():
if ENTRANCE_EXAMS.is_enabled():
graders = [grader for grader in graders if grader.get('type') != u'Entrance Exam']
return graders

Expand Down
12 changes: 0 additions & 12 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,18 +352,6 @@
'ENABLE_CHANGE_USER_PASSWORD_ADMIN': False,

### ORA Feature Flags ###

# .. toggle_name: ENABLE_ORA_TEAM_SUBMISSIONS
# .. toggle_implementation: DjangoSetting
# .. toggle_default: False
# .. toggle_description: Set to True to enable team-based ORA submissions.
# .. toggle_use_cases: temporary
# .. toggle_creation_date: 2020-03-03
# .. toggle_target_removal_date: None
# .. toggle_tickets: https://openedx.atlassian.net/browse/EDUCATOR-4951
# .. toggle_warnings: This temporary feature toggle does not have a target removal date.
'ENABLE_ORA_TEAM_SUBMISSIONS': False,
Comment thread
robrap marked this conversation as resolved.
Outdated

# .. toggle_name: ENABLE_ORA_ALL_FILE_URLS
Comment thread
regisb marked this conversation as resolved.
Outdated
# .. toggle_implementation: DjangoSetting
# .. toggle_default: False
Expand Down
4 changes: 3 additions & 1 deletion cms/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from openedx.core.apidocs import api_info
from openedx.core.djangoapps.password_policy import compliance as password_policy_compliance
from openedx.core.djangoapps.password_policy.forms import PasswordPolicyAwareAdminAuthForm
from openedx.core import toggles as core_toggles


django_autodiscover()
admin.site.site_header = _('Studio Administration')
Expand Down Expand Up @@ -220,7 +222,7 @@
urlpatterns.append(url(r'^admin/', admin.site.urls))

# enable entrance exams
if settings.FEATURES.get('ENTRANCE_EXAMS'):
if core_toggles.ENTRANCE_EXAMS.is_enabled():
urlpatterns.append(url(r'^course/{}/entrance_exam/?$'.format(settings.COURSE_KEY_PATTERN),
contentstore_views.entrance_exam))

Expand Down
4 changes: 2 additions & 2 deletions common/djangoapps/student/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
from openedx.core.djangolib.model_mixins import DeletableByUserValue
from student.signals import ENROLL_STATUS_CHANGE, ENROLLMENT_TRACK_UPDATED, UNENROLL_DONE
from track import contexts, segment
from util.milestones_helpers import is_entrance_exams_enabled
from openedx.core.toggles import ENTRANCE_EXAMS
from util.model_utils import emit_field_changed_events, get_changed_fields_dict
from util.query import use_read_replica_if_available

Expand Down Expand Up @@ -2659,7 +2659,7 @@ def user_can_skip_entrance_exam(cls, user, course_key):
Return True if given user can skip entrance exam for given course otherwise False.
"""
can_skip = False
if is_entrance_exams_enabled():
if ENTRANCE_EXAMS.is_enabled():
try:
record = EntranceExamConfiguration.objects.get(user=user, course_id=course_key)
can_skip = record.skip_entrance_exam
Expand Down
Loading