Skip to content

Commit

Permalink
Merge branch 'master' into rpenido/fal-3532-import-taxonomy-bare-bones
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido authored Nov 10, 2023
2 parents a8d0c9e + 893157d commit 9913e78
Show file tree
Hide file tree
Showing 36 changed files with 342 additions and 73 deletions.
19 changes: 17 additions & 2 deletions cms/djangoapps/contentstore/rest_api/v1/serializers/videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ class VideoModelSerializer(serializers.Serializer):
)


class VideoActiveTranscriptPreferencesSerializer(serializers.Serializer):
"""Serializer for a videos active transcript preferences"""
course_id = serializers.CharField()
provider = serializers.CharField()
cielo24_fidelity = serializers.CharField()
cielo24_turnaround = serializers.CharField()
three_play_turnaround = serializers.CharField()
preferred_languages = serializers.ListField(
child=serializers.CharField()
)
video_source_language = serializers.CharField()
modified = serializers.CharField()


class CourseVideosSerializer(serializers.Serializer):
"""Serializer for course videos"""
image_upload_url = serializers.CharField()
Expand All @@ -72,15 +86,16 @@ class CourseVideosSerializer(serializers.Serializer):
video_upload_max_file_size = serializers.CharField()
video_image_settings = VideoImageSettingsSerializer(required=True, allow_null=False)
is_video_transcript_enabled = serializers.BooleanField()
active_transcript_preferences = serializers.BooleanField(required=False, allow_null=True)
active_transcript_preferences = VideoActiveTranscriptPreferencesSerializer(required=False, allow_null=True)
transcript_credentials = serializers.DictField(
child=serializers.CharField()
child=serializers.BooleanField()
)
transcript_available_languages = serializers.ListField(
child=serializers.DictField(
child=serializers.CharField()
)
)
# transcript_available_languages = serializers.BooleanField(required=False, allow_null=True)
video_transcript_settings = VideoTranscriptSettingsSerializer()
pagination_context = serializers.DictField(
child=serializers.CharField(),
Expand Down
13 changes: 11 additions & 2 deletions cms/djangoapps/contentstore/tests/test_contentstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@

from cms.djangoapps.contentstore.config import waffle
from cms.djangoapps.contentstore.tests.utils import AjaxEnabledTestClient, CourseTestCase, get_url, parse_json
from cms.djangoapps.contentstore.utils import delete_course, reverse_course_url, reverse_url
from cms.djangoapps.contentstore.utils import (
delete_course,
reverse_course_url,
reverse_url,
get_taxonomy_tags_widget_url,
)
from cms.djangoapps.contentstore.views.component import ADVANCED_COMPONENT_TYPES
from common.djangoapps.course_action_state.managers import CourseActionStateItemNotFoundError
from common.djangoapps.course_action_state.models import CourseRerunState, CourseRerunUIStateManager
Expand Down Expand Up @@ -1410,12 +1415,16 @@ def test_course_overview_view_with_course(self):
'assets_handler',
course.location.course_key
)

taxonomy_tags_widget_url = get_taxonomy_tags_widget_url(course.id)

self.assertContains(
resp,
'<article class="outline outline-complex outline-course" data-locator="{locator}" data-course-key="{course_key}" data-course-assets="{assets_url}">'.format( # lint-amnesty, pylint: disable=line-too-long
'<article class="outline outline-complex outline-course" data-locator="{locator}" data-course-key="{course_key}" data-course-assets="{assets_url}" data-taxonomy-tags-widget-url="{taxonomy_tags_widget_url}" >'.format( # lint-amnesty, pylint: disable=line-too-long
locator=str(course.location),
course_key=str(course.id),
assets_url=assets_url,
taxonomy_tags_widget_url=taxonomy_tags_widget_url,
),
status_code=200,
html=True
Expand Down
21 changes: 16 additions & 5 deletions cms/djangoapps/contentstore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
)
from common.djangoapps.xblock_django.user_service import DjangoXBlockUserService
from openedx.core import toggles as core_toggles
from openedx.core.djangoapps.course_apps.toggles import proctoring_settings_modal_view_enabled
from openedx.core.djangoapps.credit.api import get_credit_requirements, is_credit_course
from openedx.core.djangoapps.discussions.config.waffle import ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND
from openedx.core.djangoapps.discussions.models import DiscussionsConfiguration
Expand Down Expand Up @@ -246,10 +245,7 @@ def get_proctored_exam_settings_url(course_locator) -> str:
mfe_base_url = get_course_authoring_url(course_locator)
course_mfe_url = f'{mfe_base_url}/course/{course_locator}'
if mfe_base_url:
if proctoring_settings_modal_view_enabled(course_locator):
proctored_exam_settings_url = f'{course_mfe_url}/pages-and-resources/proctoring/settings'
else:
proctored_exam_settings_url = f'{course_mfe_url}/proctored-exam-settings'
proctored_exam_settings_url = f'{course_mfe_url}/pages-and-resources/proctoring/settings'
return proctored_exam_settings_url


Expand Down Expand Up @@ -446,6 +442,21 @@ def get_taxonomy_list_url():
return taxonomy_list_url


def get_taxonomy_tags_widget_url(course_locator) -> str:
"""
Gets course authoring microfrontend URL for taxonomy tags drawer widget view.
The `content_id` needs to be appended to the end of the URL when using it.
"""
taxonomy_tags_widget_url = None
# Uses the same waffle flag as taxonomy list page
if use_tagging_taxonomy_list_page():
mfe_base_url = get_course_authoring_url(course_locator)
if mfe_base_url:
taxonomy_tags_widget_url = f'{mfe_base_url}/tagging/components/widget/'
return taxonomy_tags_widget_url


def course_import_olx_validation_is_enabled():
"""
Check if course olx validation is enabled on course import.
Expand Down
2 changes: 2 additions & 0 deletions cms/djangoapps/contentstore/views/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
get_lms_link_for_item,
get_proctored_exam_settings_url,
get_course_outline_url,
get_taxonomy_tags_widget_url,
get_studio_home_url,
get_updates_url,
get_advanced_settings_url,
Expand Down Expand Up @@ -688,6 +689,7 @@ def course_index(request, course_key):
'mfe_proctored_exam_settings_url': get_proctored_exam_settings_url(course_block.id),
'advance_settings_url': reverse_course_url('advanced_settings_handler', course_block.id),
'proctoring_errors': proctoring_errors,
'taxonomy_tags_widget_url': get_taxonomy_tags_widget_url(course_block.id),
})


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from xblock.fields import Scope

from cms.djangoapps.contentstore.config.waffle import SHOW_REVIEW_RULES_FLAG
from cms.djangoapps.contentstore.toggles import ENABLE_COPY_PASTE_UNITS
from cms.djangoapps.contentstore.toggles import ENABLE_COPY_PASTE_UNITS, use_tagging_taxonomy_list_page
from cms.djangoapps.models.settings.course_grading import CourseGradingModel
from cms.lib.ai_aside_summary_config import AiAsideSummaryConfig
from common.djangoapps.edxmako.services import MakoService
Expand Down Expand Up @@ -1397,6 +1397,10 @@ def create_xblock_info( # lint-amnesty, pylint: disable=too-many-statements
# If the ENABLE_COPY_PASTE_UNITS feature flag is enabled, we show the newer menu that allows copying/pasting
xblock_info["enable_copy_paste_units"] = ENABLE_COPY_PASTE_UNITS.is_enabled()

# If the ENABLE_TAGGING_TAXONOMY_LIST_PAGE feature flag is enabled, we show the "Manage Tags" options
if use_tagging_taxonomy_list_page():
xblock_info["use_tagging_taxonomy_list_page"] = True

xblock_info[
"has_partition_group_components"
] = has_children_visible_to_specific_partition_groups(xblock)
Expand Down
41 changes: 41 additions & 0 deletions cms/static/js/views/course_outline.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,43 @@ function(
event.stopPropagation();
},

closeManageTagsDrawer(drawer, drawerCover) {
$(drawerCover).css('display', 'none');
$(drawer).empty();
$(drawer).css('display', 'none');
$('body').removeClass('drawer-open');
},

openManageTagsDrawer(event) {
const drawer = document.querySelector("#manage-tags-drawer");
const drawerCover = document.querySelector(".drawer-cover")
const article = document.querySelector('[data-taxonomy-tags-widget-url]');
const taxonomyTagsWidgetUrl = $(article).attr('data-taxonomy-tags-widget-url');
const contentId = this.model.get('id');

// Add handler to close drawer when dark background is clicked
$(drawerCover).click(function() {
this.closeManageTagsDrawer(drawer, drawerCover);
}.bind(this));

// Add event listen to close drawer when close button is clicked from within the Iframe
window.addEventListener("message", function (event) {
if (event.data === 'closeManageTagsDrawer') {
this.closeManageTagsDrawer(drawer, drawerCover)
}
}.bind(this));

$(drawerCover).css('display', 'block');
// xss-lint: disable=javascript-jquery-html
$(drawer).html(
`<iframe src="${taxonomyTagsWidgetUrl}${contentId}" onload="this.contentWindow.focus()" frameborder="0" style="width: 100%; height: 100%;"></iframe>`
);
$(drawer).css('display', 'block');

// Prevent background from being scrollable when drawer is open
$('body').addClass('drawer-open');
},

addButtonActions: function(element) {
XBlockOutlineView.prototype.addButtonActions.apply(this, arguments);
element.find('.configure-button').click(function(event) {
Expand All @@ -478,6 +515,10 @@ function(
event.preventDefault();
this.copyXBlock();
});
element.find('.manage-tags-button').click((event) => {
event.preventDefault();
this.openManageTagsDrawer();
});
element.find('.paste-component-button').click((event) => {
event.preventDefault();
this.pasteUnit(event);
Expand Down
1 change: 1 addition & 0 deletions cms/static/js/views/xblock_outline.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ function($, _, gettext, BaseView, ViewUtils, XBlockViewUtils, XBlockStringFieldE
staffOnlyMessage: this.model.get('staff_only_message'),
course: course,
enableCopyPasteUnits: this.model.get("enable_copy_paste_units"), // ENABLE_COPY_PASTE_UNITS waffle flag
useTaggingTaxonomyListPage: this.model.get("use_tagging_taxonomy_list_page"), // ENABLE_TAGGING_TAXONOMY_LIST_PAGE waffle flag
};
},

Expand Down
1 change: 1 addition & 0 deletions cms/static/sass/_build-v1.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
@import 'elements/uploaded-assets'; // layout for asset tables
@import 'elements/creative-commons';
@import 'elements/tooltip';
@import 'elements/drawer';

// +Base - Specific Views
// ====================
Expand Down
30 changes: 30 additions & 0 deletions cms/static/sass/elements/_drawer.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// studio - elements - side drawers
// ====================

.drawer-cover {
@extend %ui-depth3;

display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
}

.drawer {
@extend %ui-depth4;

display: none;
position: fixed;
top: 0;
right: 0;
width: 33.33vw;
height: 100vh;
background-color: $gray-l4;
}

body.drawer-open {
overflow: hidden;
}
5 changes: 4 additions & 1 deletion cms/templates/course_outline.html
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ <h3 class="sr">${_("Page Actions")}</h3>
assets_url = reverse('assets_handler', kwargs={'course_key_string': str(course_locator.course_key)})
%>
<h2 class="sr">${_("Course Outline")}</h2>
<article class="outline outline-complex outline-course" data-locator="${course_locator}" data-course-key="${course_locator.course_key}" data-course-assets="${assets_url}">
<article class="outline outline-complex outline-course" data-locator="${course_locator}" data-course-key="${course_locator.course_key}" data-course-assets="${assets_url}" data-taxonomy-tags-widget-url="${taxonomy_tags_widget_url}">
</article>
</div>
<div class="ui-loading">
Expand Down Expand Up @@ -321,4 +321,7 @@ <h3 class="title-3">${_("Changing the content learners see")}</h3>
</aside>
</section>
</div>

<div id="manage-tags-drawer" class="drawer"></div>
<div class="drawer-cover"></div>
</%block>
16 changes: 16 additions & 0 deletions cms/templates/js/course-outline.underscore
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ if (is_proctored_exam) {
</a>
</li>
<% } %>

<% if (xblockInfo.isVertical() && typeof useTaggingTaxonomyListPage !== "undefined" && useTaggingTaxonomyListPage) { %>
<li class="action-item">
<a href="#" data-tooltip="<%- gettext('Manage Tags') %>" class="manage-tags-button action-button">
<span class="icon fa fa-tag" aria-hidden="true"></span>
<span>?</span>
<span class="sr action-button-text"><%- gettext('Manage Tags') %></span>
</a>
</li>
<% } %>

<% if (typeof enableCopyPasteUnits !== "undefined" && enableCopyPasteUnits) { %>
<!--
If the ENABLE_COPY_PASTE_UNITS feature flag is enabled, all these actions (besides "Publish")
Expand All @@ -192,6 +203,11 @@ if (is_proctored_exam) {
<li class="nav-item">
<a class="copy-button" href="#" role="button"><%- gettext('Copy to Clipboard') %></a>
</li>
<% if (typeof useTaggingTaxonomyListPage !== "undefined" && useTaggingTaxonomyListPage) { %>
<li class="nav-item">
<a class="manage-tags-button" href="#" role="button"><%- gettext('Manage Tags') %></a>
</li>
<% } %>
<% } %>
<% if (xblockInfo.isDuplicable()) { %>
<li class="nav-item">
Expand Down
14 changes: 14 additions & 0 deletions common/djangoapps/student/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from django.test import TestCase, override_settings
from django.test.client import Client
from django.urls import reverse
from edx_toggles.toggles.testutils import override_waffle_switch
from markupsafe import escape
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locations import CourseLocator
Expand All @@ -33,6 +34,7 @@
user_by_anonymous_id
)
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
from common.djangoapps.student.toggles import REDIRECT_TO_COURSEWARE_AFTER_ENROLLMENT
from common.djangoapps.student.views import complete_course_mode_info
from common.djangoapps.util.model_utils import USER_SETTINGS_CHANGED_EVENT_NAME
from common.djangoapps.util.testing import EventTestMixin
Expand Down Expand Up @@ -893,6 +895,7 @@ def test_change_enrollment_modes(self):


@skip_unless_lms
@ddt.ddt
class ChangeEnrollmentViewTest(ModuleStoreTestCase):
"""Tests the student.views.change_enrollment view"""

Expand All @@ -913,6 +916,17 @@ def _enroll_through_view(self, course):
)
return response

@ddt.data(
(True, 'courseware'),
(False, None),
)
@ddt.unpack
def test_enrollment_url(self, waffle_flag_enabled, returned_view):
with override_waffle_switch(REDIRECT_TO_COURSEWARE_AFTER_ENROLLMENT, waffle_flag_enabled):
response = self._enroll_through_view(self.course)
data = reverse(returned_view, args=[str(self.course.id)]) if returned_view else ''
assert response.content.decode('utf8') == data

def test_enroll_as_default(self):
"""Tests that a student can successfully enroll through this view"""
response = self._enroll_through_view(self.course)
Expand Down
20 changes: 19 additions & 1 deletion common/djangoapps/student/toggles.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Toggles for Dashboard page.
"""
from edx_toggles.toggles import WaffleFlag
from edx_toggles.toggles import WaffleFlag, WaffleSwitch

# Namespace for student waffle flags.
WAFFLE_FLAG_NAMESPACE = 'student'
Expand Down Expand Up @@ -75,3 +75,21 @@ def should_show_2u_recommendations():

def should_send_enrollment_email():
return ENROLLMENT_CONFIRMATION_EMAIL.is_enabled()


# Waffle flag to enable control redirecting after enrolment.
# .. toggle_name: student.redirect_to_courseware_after_enrollment
# .. toggle_implementation: WaffleSwitch
# .. toggle_default: False
# .. toggle_description: Redirect to courseware after enrollment instead of dashboard.
# .. toggle_use_cases: open_edx
# .. toggle_creation_date: 2023-02-06
# .. toggle_target_removal_date: None
# .. toggle_warning: None
REDIRECT_TO_COURSEWARE_AFTER_ENROLLMENT = WaffleSwitch(
f'{WAFFLE_FLAG_NAMESPACE}.redirect_to_courseware_after_enrollment', __name__
)


def should_redirect_to_courseware_after_enrollment():
return REDIRECT_TO_COURSEWARE_AFTER_ENROLLMENT.is_enabled()
7 changes: 5 additions & 2 deletions common/djangoapps/student/views/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from rest_framework.decorators import api_view, authentication_classes, permission_classes
from rest_framework.permissions import IsAuthenticated

from common.djangoapps.student.toggles import should_redirect_to_courseware_after_enrollment
from common.djangoapps.track import views as track_views
from lms.djangoapps.bulk_email.models import Optout
from common.djangoapps.course_modes.models import CourseMode
Expand Down Expand Up @@ -400,8 +401,10 @@ def change_enrollment(request, check_access=True):
reverse("course_modes_choose", kwargs={'course_id': str(course_id)})
)

# Otherwise, there is only one mode available (the default)
return HttpResponse()
if should_redirect_to_courseware_after_enrollment():
return HttpResponse(reverse('courseware', args=[str(course_id)]))
else:
return HttpResponse()
elif action == "unenroll":
if configuration_helpers.get_value(
"DISABLE_UNENROLLMENT",
Expand Down
Loading

0 comments on commit 9913e78

Please sign in to comment.