feat: added discussion enabled for unit in studio (#31394)
Co-authored-by: adeel.tajamul <adeel.tajamul@arbisoft.com>
This commit is contained in:
committed by
GitHub
parent
5dc8dc54e1
commit
6ef0aba48d
@@ -20,6 +20,7 @@ from common.djangoapps.student.models import CourseEnrollment
|
||||
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
|
||||
@@ -731,3 +732,38 @@ 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
|
||||
|
||||
@@ -34,6 +34,7 @@ from organizations.api import add_organization_course, ensure_organization
|
||||
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
|
||||
@@ -66,6 +67,7 @@ from openedx.core import toggles as core_toggles
|
||||
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
|
||||
@@ -724,6 +726,11 @@ def course_index(request, course_key):
|
||||
advanced_dict = CourseMetadata.fetch(course_module)
|
||||
proctoring_errors = CourseMetadata.validate_proctoring_settings(course_module, 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_module,
|
||||
|
||||
@@ -114,7 +114,11 @@ if (is_proctored_exam) {
|
||||
>
|
||||
<span class="icon fa fa-caret-down" aria-hidden="true"></span>
|
||||
<% } else { %>
|
||||
<h3 class="<%- xblockType %>-header-details">
|
||||
<% if (xblockType == "unit") { %>
|
||||
<h3 class="unit-header-details" style="width: 50%">
|
||||
<% } else { %>
|
||||
<h3 class="<%- xblockType %>-header-details">
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if (xblockInfo.isVertical()) { %>
|
||||
<span class="unit-title item-title">
|
||||
@@ -128,8 +132,19 @@ if (is_proctored_exam) {
|
||||
</span>
|
||||
<% } %>
|
||||
</h3>
|
||||
<div class="<%- xblockType %>-header-actions">
|
||||
<% if (xblockType == "unit") {%>
|
||||
<div class="unit-header-actions" style="width: 50%">
|
||||
<% } else { %>
|
||||
<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>
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if (xblockInfo.isSequential() && xblockInfo.get('proctoring_exam_configuration_link')) { %>
|
||||
<li class="action-item">
|
||||
<a href="<%- xblockInfo.get('proctoring_exam_configuration_link') %>" data-tooltip="<%- gettext('Proctoring Settings') %>" class="proctoring-configuration-button" rel="noopener" target="_blank">
|
||||
|
||||
Reference in New Issue
Block a user