Skip to content

Commit

Permalink
feat: add discussion configuration redirect in unit settings (#34266)
Browse files Browse the repository at this point in the history
* feat: add discussion configuration redirect in unit settings

* test: fix test course index file test cases after adding discussion redirection
  • Loading branch information
awais-ansari authored Feb 22, 2024
1 parent f3dab82 commit 5007418
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from cms.djangoapps.contentstore.config.waffle import CUSTOM_RELATIVE_DATES
from cms.djangoapps.contentstore.rest_api.v1.mixins import PermissionAccessMixin
from cms.djangoapps.contentstore.tests.utils import CourseTestCase
from cms.djangoapps.contentstore.utils import get_lms_link_for_item
from cms.djangoapps.contentstore.utils import get_lms_link_for_item, get_pages_and_resources_url
from cms.djangoapps.contentstore.views.course import _course_outline_json
from common.djangoapps.student.tests.factories import UserFactory
from openedx.core.djangoapps.waffle_utils.testutils import WAFFLE_TABLES
Expand Down Expand Up @@ -82,6 +82,7 @@ def test_course_index_response(self):
"enable_in_context": True,
"enable_graded_units": False,
"unit_level_visibility": True,
'discussion_configuration_url': f'{get_pages_and_resources_url(self.course.id)}/discussion/settings',
},
"advance_settings_url": f"/settings/advanced/{self.course.id}",
}
Expand Down Expand Up @@ -128,6 +129,7 @@ def test_course_index_response_with_show_locators(self):
"enable_in_context": True,
"enable_graded_units": False,
"unit_level_visibility": True,
'discussion_configuration_url': f'{get_pages_and_resources_url(self.course.id)}/discussion/settings',
},
"advance_settings_url": f"/settings/advanced/{self.course.id}",
}
Expand Down
3 changes: 3 additions & 0 deletions cms/djangoapps/contentstore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1756,6 +1756,9 @@ def _get_course_index_context(request, course_key, course_block):
proctoring_errors = CourseMetadata.validate_proctoring_settings(course_block, advanced_dict, request.user)

user_clipboard = content_staging_api.get_user_clipboard_json(request.user.id, request)
course_block.discussions_settings['discussion_configuration_url'] = (
f'{get_pages_and_resources_url(course_block.id)}/discussion/settings'
)

course_index_context = {
'language_code': request.LANGUAGE_CODE,
Expand Down
11 changes: 8 additions & 3 deletions cms/static/js/views/modals/course_outline_modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -985,9 +985,14 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
}
},
getContext: function() {
return {
hasDiscussionEnabled: this.currentValue()
};
return $.extend(
{},
AbstractEditor.prototype.getContext.call(this),
{
hasDiscussionEnabled: this.currentValue(),
discussion_configuration_url: course.get('discussions_settings').discussion_configuration_url
}
);
}
});

Expand Down
14 changes: 13 additions & 1 deletion cms/templates/js/discussion-editor.underscore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,19 @@
<%- gettext('Topics for unpublished units would not be created') %>
</p>
<p class="graded-tip tip tip-inline">
<%- gettext('Please enable discussions for graded units from course authoring app') %>
<span>
<%- gettext('Please enable discussions for graded units from the') %>
<a
id="discussion_configuration_url"
name="discussion_configuration_url"
rel="noreferrer noopener"
target="_blank"
href="<%- discussion_configuration_url %>"
>
<%- gettext('Discussion Configuration') %>
<i class="fa fa-share-square-o" aria-hidden="true"></i>
</a>
</span>
</p>
</div>
</div>
Expand Down

0 comments on commit 5007418

Please sign in to comment.