Skip to content

Commit

Permalink
fix: updated discussion enabled label (openedx#31572)
Browse files Browse the repository at this point in the history
Co-authored-by: adeel.tajamul <adeel.tajamul@arbisoft.com>
  • Loading branch information
muhammadadeeltajamul and adeel.tajamul committed Jan 24, 2023
1 parent 536fe66 commit a8535ff
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 49 deletions.
36 changes: 0 additions & 36 deletions cms/djangoapps/contentstore/utils.py
Expand Up @@ -20,7 +20,6 @@
from common.djangoapps.student.roles import CourseInstructorRole, CourseStaffRole
from openedx.core.djangoapps.course_apps.toggles import proctoring_settings_modal_view_enabled
from openedx.core.djangoapps.discussions.config.waffle import ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND
from openedx.core.djangoapps.discussions.models import DiscussionTopicLink, Provider
from openedx.core.djangoapps.django_comment_common.models import assign_default_role
from openedx.core.djangoapps.django_comment_common.utils import seed_permissions_roles
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
Expand Down Expand Up @@ -732,38 +731,3 @@ def translation_language(language):
translation.activate(previous)
else:
yield


def mark_verticals_discussion_enabled(course_structure, course_key):
"""
Adds has_discussion attribute on verticals of course_structure
"""
topics = []
topics_query = DiscussionTopicLink.objects.filter(
context_key=course_key,
provider_id=Provider.OPEN_EDX,
)
for topic in topics_query:
topics.append({
"usage_key": str(topic.usage_key)
})

sub_sections_reference = []
if course_structure.get('has_children'):
chapters = course_structure['child_info'].get('children')
for section in chapters:
if section.get('has_children'):
sub_sections = section.get('child_info').get('children')
for sub_section in sub_sections:
sub_sections_reference.append(sub_section)

for sub_section in sub_sections_reference:
if sub_section.get('has_children'):
verticals = sub_section.get('child_info').get('children')
for vertical in verticals:
vertical_id = vertical.get('id')
vertical['has_discussion'] = False
for topic in topics:
if topic.get('usage_key') == vertical_id:
vertical['has_discussion'] = True
return course_structure
7 changes: 0 additions & 7 deletions cms/djangoapps/contentstore/views/course.py
Expand Up @@ -34,7 +34,6 @@
from organizations.exceptions import InvalidOrganizationException
from rest_framework.exceptions import ValidationError

from cms.djangoapps.contentstore.utils import mark_verticals_discussion_enabled
from cms.djangoapps.course_creators.views import add_user_with_status_unrequested, get_course_creator_status
from cms.djangoapps.models.settings.course_grading import CourseGradingModel
from cms.djangoapps.models.settings.course_metadata import CourseMetadata
Expand Down Expand Up @@ -67,7 +66,6 @@
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.credit.api import get_credit_requirements, is_credit_course
from openedx.core.djangoapps.credit.tasks import update_credit_course_requirements
from openedx.core.djangoapps.discussions.models import DiscussionsConfiguration, Provider
from openedx.core.djangoapps.models.course_details import CourseDetails
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangolib.js_utils import dump_js_escaped_json
Expand Down Expand Up @@ -726,11 +724,6 @@ def course_index(request, course_key):
advanced_dict = CourseMetadata.fetch(course_block)
proctoring_errors = CourseMetadata.validate_proctoring_settings(course_block, advanced_dict, request.user)

configuration = DiscussionsConfiguration.get(course_key)
provider = configuration.provider_type
if provider == Provider.OPEN_EDX:
mark_verticals_discussion_enabled(course_structure, course_key)

return render_to_response('course_outline.html', {
'language_code': request.LANGUAGE_CODE,
'context_course': course_block,
Expand Down
3 changes: 2 additions & 1 deletion cms/templates/base.html
Expand Up @@ -158,7 +158,8 @@
revision: "${context_course.location.branch | n, js_escaped_string}",
self_paced: ${ context_course.self_paced | n, dump_js_escaped_json },
is_custom_relative_dates_active: ${CUSTOM_RELATIVE_DATES.is_enabled(context_course.id) | n, dump_js_escaped_json},
start: ${context_course.start | n, dump_js_escaped_json}
start: ${context_course.start | n, dump_js_escaped_json},
discussions_settings: ${context_course.discussions_settings | n, dump_js_escaped_json}
});
</script>
% endif
Expand Down
13 changes: 8 additions & 5 deletions cms/templates/js/course-outline.underscore
Expand Up @@ -138,11 +138,14 @@ if (is_proctored_exam) {
<div class="<%- xblockType %>-header-actions">
<% } %>
<ul class="actions-list">
<% if (xblockInfo.isVertical()) { %>
<% if (xblockInfo.get('has_discussion')) {%>
<li class="action-item" style="font-size: 75%; color:grey">
Discussions enabled
</li>
<% var discussion_settings = course.get('discussions_settings') %>
<% if (xblockInfo.isVertical() && discussion_settings) { %>
<% if (xblockInfo.get('discussion_enabled') && (discussion_settings.provider_type == "openedx")) { %>
<% if (discussion_settings.enable_graded_units || (!discussion_settings.enable_graded_units && !parentInfo.get('graded'))) {%>
<li class="action-item" style="font-size: 75%; color:grey">
<%- gettext('Discussions enabled') %>
</li>
<% } %>
<% } %>
<% } %>
<% if (xblockInfo.isSequential() && xblockInfo.get('proctoring_exam_configuration_link')) { %>
Expand Down

0 comments on commit a8535ff

Please sign in to comment.