lms.djangoapps.discussion package#
Subpackages#
- lms.djangoapps.discussion.config package
- lms.djangoapps.discussion.django_comment_client package
- Subpackages
- lms.djangoapps.discussion.django_comment_client.base package
- Submodules
- lms.djangoapps.discussion.django_comment_client.base.event_transformers module
- lms.djangoapps.discussion.django_comment_client.base.tests_v2 module
- lms.djangoapps.discussion.django_comment_client.base.urls module
- lms.djangoapps.discussion.django_comment_client.base.views module
- Module contents
- lms.djangoapps.discussion.django_comment_client.base package
- Submodules
- lms.djangoapps.discussion.django_comment_client.constants module
- lms.djangoapps.discussion.django_comment_client.middleware module
- lms.djangoapps.discussion.django_comment_client.models module
- lms.djangoapps.discussion.django_comment_client.permissions module
- lms.djangoapps.discussion.django_comment_client.settings module
- lms.djangoapps.discussion.django_comment_client.urls module
- lms.djangoapps.discussion.django_comment_client.utils module
DiscussionIdMapIsNotCachedHtmlResponseJsonErrorJsonResponseQueryCountDebugMiddlewareViewNameMiddlewareadd_courseware_context()convert_a_to_markdown()convert_html_to_markdown()convert_img_to_markdown()convert_p_to_markdown()course_discussion_division_enabled()discussion_category_id_access()extend_content()extract()get_ability()get_annotated_content_info()get_annotated_content_infos()get_cached_discussion_id_map()get_cached_discussion_id_map_by_course_id()get_cached_discussion_key()get_discussion_category_map()get_discussion_id_map()get_discussion_id_map_by_course_id()get_discussion_id_map_entry()get_group_id_for_comments_service()get_group_id_for_user()get_group_id_for_user_from_cache()get_group_name()get_metadata_for_threads()get_role_ids()get_user_group_ids()get_user_role_names()get_users_with_moderator_roles()get_users_with_roles()has_discussion_privileges()has_forum_access()is_comment_too_deep()is_commentable_divided()is_content_authored_by()is_discussion_enabled()is_user_community_ta()permalink()prepare_content()sanitize_body()strip_blank()strip_none()
- Module contents
- Subpackages
- lms.djangoapps.discussion.management package
- Subpackages
- lms.djangoapps.discussion.management.commands package
- Submodules
- lms.djangoapps.discussion.management.commands.assign_role module
- lms.djangoapps.discussion.management.commands.assign_roles_for_course module
- lms.djangoapps.discussion.management.commands.create_roles_for_existing module
- lms.djangoapps.discussion.management.commands.get_discussion_link module
- lms.djangoapps.discussion.management.commands.reload_forum_users module
- lms.djangoapps.discussion.management.commands.seed_permissions_roles module
- lms.djangoapps.discussion.management.commands.show_permissions module
- lms.djangoapps.discussion.management.commands.sync_user_info module
- lms.djangoapps.discussion.management.commands.update_user_discussion_stats module
- Module contents
- lms.djangoapps.discussion.management.commands package
- Module contents
- Subpackages
- lms.djangoapps.discussion.notification_prefs package
- lms.djangoapps.discussion.rest_api package
- Submodules
- lms.djangoapps.discussion.rest_api.api module
DiscussionEntityDiscussionTopicadd_stats_for_users_with_null_values()create_comment()create_thread()delete_comment()delete_thread()get_comment_list()get_course()get_course_discussion_user_stats()get_course_topics()get_course_topics_v2()get_courseware_topics()get_learner_active_thread_list()get_non_courseware_topics()get_response_comments()get_thread()get_thread_list()get_thread_list_url()get_user_comments()get_users_without_stats()get_v2_course_topics_as_v1()get_v2_courseware_topics_as_v1()get_v2_non_courseware_topics_as_v1()update_comment()update_thread()
- lms.djangoapps.discussion.rest_api.discussions_notifications module
DiscussionNotificationSenderDiscussionNotificationSender.send_new_comment_notification()DiscussionNotificationSender.send_new_comment_on_response_notification()DiscussionNotificationSender.send_new_response_notification()DiscussionNotificationSender.send_new_thread_created_notification()DiscussionNotificationSender.send_reported_content_notification()DiscussionNotificationSender.send_response_endorsed_notification()DiscussionNotificationSender.send_response_endorsed_on_thread_notification()DiscussionNotificationSender.send_response_on_followed_post_notification()
clean_thread_html_body()is_discussion_cohorted()remove_html_tags()strip_empty_tags()
- lms.djangoapps.discussion.rest_api.exceptions module
- lms.djangoapps.discussion.rest_api.forms module
- lms.djangoapps.discussion.rest_api.pagination module
- lms.djangoapps.discussion.rest_api.permissions module
- lms.djangoapps.discussion.rest_api.render module
- lms.djangoapps.discussion.rest_api.serializers module
BlackoutDateSerializerCommentSerializerCommentSerializer.create()CommentSerializer.get_abuse_flagged_any_user()CommentSerializer.get_children()CommentSerializer.get_endorsed_at()CommentSerializer.get_endorsed_by()CommentSerializer.get_endorsed_by_label()CommentSerializer.get_profile_image()CommentSerializer.non_updatable_fieldsCommentSerializer.to_representation()CommentSerializer.update()CommentSerializer.validate()
CourseMetadataSerailizerDiscussionRolesListSerializerDiscussionRolesMemberSerializerDiscussionRolesSerializerDiscussionTopicSerializerDiscussionTopicSerializerV2ReasonCodeSeralizerThreadSerializerThreadSerializer.create()ThreadSerializer.get_abuse_flagged_count()ThreadSerializer.get_close_reason()ThreadSerializer.get_closed_by()ThreadSerializer.get_closed_by_label()ThreadSerializer.get_comment_count()ThreadSerializer.get_comment_list_url()ThreadSerializer.get_endorsed_comment_list_url()ThreadSerializer.get_following()ThreadSerializer.get_group_name()ThreadSerializer.get_non_endorsed_comment_list_url()ThreadSerializer.get_pinned()ThreadSerializer.get_preview_body()ThreadSerializer.get_unread_comment_count()ThreadSerializer.non_updatable_fieldsThreadSerializer.update()
TopicOrderingUserStatsSerializerfilter_spam_urls_from_html()get_context()validate_close_reason_code()validate_edit_reason_code()validate_not_blank()
- lms.djangoapps.discussion.rest_api.tasks module
- lms.djangoapps.discussion.rest_api.urls module
- lms.djangoapps.discussion.rest_api.utils module
AttributeDictadd_stats_for_users_with_no_discussion_content()add_thread_stats_to_subsection()can_user_notify_all_learners()create_blocks_params()create_discussion_children_from_ids()create_topics_v3_structure()discussion_open_for_user()filter_topic_from_discussion_id()get_archived_topics()get_captcha_site_key_by_platform()get_course_id_from_thread_id()get_course_staff_users_list()get_course_ta_users_list()get_moderator_users_list()get_platform_from_request()get_topic_ids_from_topics()get_usernames_for_course()get_usernames_from_search_string()is_captcha_enabled()is_only_student()is_posting_allowed()remove_empty_sequentials()send_signal_after_commit()set_attribute()verify_recaptcha_token()
- lms.djangoapps.discussion.rest_api.views module
BulkDeleteUserPostsCommentViewSetCommentViewSet.authentication_classesCommentViewSet.basenameCommentViewSet.create()CommentViewSet.descriptionCommentViewSet.destroy()CommentViewSet.detailCommentViewSet.list()CommentViewSet.list_by_thread()CommentViewSet.list_by_user()CommentViewSet.lookup_fieldCommentViewSet.nameCommentViewSet.parser_classesCommentViewSet.partial_update()CommentViewSet.permission_classesCommentViewSet.retrieve()CommentViewSet.suffix
CourseActivityStatsViewCourseDiscussionRolesAPIViewCourseDiscussionSettingsAPIViewCourseTopicsViewCourseTopicsViewV2CourseTopicsViewV3CourseViewCourseViewV2LearnerThreadViewReplaceUsernamesViewRetireUserViewThreadViewSetThreadViewSet.authentication_classesThreadViewSet.basenameThreadViewSet.create()ThreadViewSet.descriptionThreadViewSet.destroy()ThreadViewSet.detailThreadViewSet.list()ThreadViewSet.lookup_fieldThreadViewSet.nameThreadViewSet.parser_classesThreadViewSet.partial_update()ThreadViewSet.permission_classesThreadViewSet.retrieve()ThreadViewSet.suffix
UploadFileView
- Module contents
- lms.djangoapps.discussion.settings package
- lms.djangoapps.discussion.signals package
- Submodules
- lms.djangoapps.discussion.signals.handlers module
create_comment_created_notification()create_message_context()create_message_context_for_reported_content()create_response_endorsed_on_thread_notification()create_thread_created_notification()send_discussion_email_notification()send_message()send_message_for_reported_content()send_reported_content_email_notification()send_reported_content_notification()update_discussions_on_course_publish()
- Module contents
Submodules#
lms.djangoapps.discussion.apps module#
Discussion Application Configuration
Signal handlers are connected here.
- class lms.djangoapps.discussion.apps.DiscussionConfig(app_name, app_module)#
Bases:
AppConfigApplication Configuration for Discussion.
- name = 'lms.djangoapps.discussion'#
- plugin_app = {'settings_config': {'cms.djangoapp': {'common': {'relative_path': 'settings.common'}}, 'lms.djangoapp': {'common': {'relative_path': 'settings.common'}}}, 'url_config': {'lms.djangoapp': {'app_name': 'lms.djangoapps.discussion', 'namespace': '', 'regex': '^courses/(?P<course_id>[^/+]+(/|\\+)[^/+]+(/|\\+)[^/?]+)/discussion/forum/', 'relative_path': 'urls'}}}#
- ready()#
Connect handlers to send notifications about discussions.
lms.djangoapps.discussion.exceptions module#
Custom exceptions raised by Discussion API.
- exception lms.djangoapps.discussion.exceptions.TeamDiscussionHiddenFromUserException#
Bases:
BaseExceptionThis is the exception raised when a user is not permitted to view the discussion thread
lms.djangoapps.discussion.plugins module#
Views handling read (GET) requests for the Discussion tab and inline discussions.
- class lms.djangoapps.discussion.plugins.DiscussionTab(tab_dict)#
Bases:
TabFragmentViewMixin,EnrolledTabA tab for the forums.
- body_class = 'discussion'#
- fragment_view_name = 'lms.djangoapps.discussion.views.DiscussionBoardFragmentView'#
- is_default = False#
- classmethod is_enabled(course, user=None)#
Returns true if this course tab is enabled in the course.
- Parameters:
course (CourseBlock) – the course using the feature
user (User) – an optional user interacting with the course (defaults to None)
- is_hideable = True#
- property link_func#
Returns a function that returns the course tab’s URL.
- online_help_token = 'discussions'#
- priority = 40#
- title = 'Discussion'#
- type = 'discussion'#
- view_name = 'forum_form_discussion'#
lms.djangoapps.discussion.rate_limit module#
Contains all code related to rate limit
- lms.djangoapps.discussion.rate_limit.is_content_creation_rate_limited(request, course_key=None, increment=True)#
Check if the request is rate limited for content creation in discussions.
- lms.djangoapps.discussion.rate_limit.is_rate_limited(request, group, key='user', rate='10/m', method=(None,), increment=True, course_key=None)#
Check if the request is rate limited :param request: The HTTP request object. :param group: The group to which the rate limit applies :param key: The key to identify (user or ip). :param rate: The rate limit (default is ‘10/m’ - 10 requests per minute). :param method: The HTTP method to check (default is ‘POST’). :param increment: Whether to increment the rate limit counter (default is True). :param course_key: The course key for which the rate limit is applied (optional).
- Returns:
True if the request is rate limited, False otherwise.
- Return type:
bool
lms.djangoapps.discussion.tasks module#
Defines asynchronous celery task for sending email notification (through edx-ace) pertaining to new discussion forum comments.
- class lms.djangoapps.discussion.tasks.CommentNotification(*args, **kwargs)#
Bases:
BaseMessageTypeNotify discussion participants of new comments.
- class lms.djangoapps.discussion.tasks.ReportedContentNotification(*args, **kwargs)#
Bases:
BaseMessageType
- class lms.djangoapps.discussion.tasks.ResponseNotification(*args, **kwargs)#
Bases:
BaseMessageType
lms.djangoapps.discussion.toggles module#
Discussions feature toggles
lms.djangoapps.discussion.toggles_utils module#
Utils for Discussions feature toggles
- lms.djangoapps.discussion.toggles_utils.reported_content_email_notification_enabled(course_key)#
Checks for relevant flag and setting and returns boolean for reported content email notification for course
lms.djangoapps.discussion.urls module#
Forum urls for the django_comment_client.
lms.djangoapps.discussion.views module#
Views handling read (GET) requests for the Discussion tab and inline discussions.
- class lms.djangoapps.discussion.views.DiscussionBoardFragmentView(**kwargs)#
Bases:
EdxFragmentViewComponent implementation of the discussion board.
- css_dependencies()#
Returns list of CSS files that this view depends on.
The helper function that it uses to obtain the list of CSS files works in conjunction with the Django pipeline to ensure that in development mode the files are loaded individually, but in production just the single bundle is loaded.
- js_dependencies()#
Returns list of JS files that this view depends on.
The helper function that it uses to obtain the list of JS files works in conjunction with the Django pipeline to ensure that in development mode the files are loaded individually, but in production just the single bundle is loaded.
- render_to_fragment(request, course_id=None, discussion_id=None, thread_id=None, profile_page_context=None, **kwargs)#
Render the discussion board to a fragment.
- Parameters:
request – The Django request.
course_id – The id of the course in question.
discussion_id – An optional discussion ID to be focused upon.
thread_id – An optional ID of the thread to be shown.
- Returns:
The fragment representing the discussion board
- Return type:
Fragment
- vendor_js_dependencies()#
Returns list of vendor JS files that this view depends on.
The helper function that it uses to obtain the list of vendor JS files works in conjunction with the Django pipeline to ensure that in development mode the files are loaded individually, but in production just the single bundle is loaded.
- lms.djangoapps.discussion.views.course_discussions_settings_handler(request, course_key_string)#
The restful handler for divided discussion setting requests. Requires JSON. This will raise 404 if user is not staff. GET
Returns the JSON representation of divided discussion settings for the course.
- PATCH
Updates the divided discussion settings for the course. Returns the JSON representation of updated settings.
- lms.djangoapps.discussion.views.create_user_profile_context(request, course_key, user_id)#
Generate a context dictionary for the user profile.
- lms.djangoapps.discussion.views.discussion_topics(request, course_key_string)#
The handler for divided discussion categories requests. This will raise 404 if user is not staff.
Returns the JSON representation of discussion topics w.r.t categories for the course.
Example
>>> example = { >>> "course_wide_discussions": { >>> "entries": { >>> "General": { >>> "sort_key": "General", >>> "is_divided": True, >>> "id": "i4x-edx-eiorguegnru-course-foobarbaz" >>> } >>> } >>> "children": ["General", "entry"] >>> }, >>> "inline_discussions" : { >>> "subcategories": { >>> "Getting Started": { >>> "subcategories": {}, >>> "children": [ >>> ["Working with Videos", "entry"], >>> ["Videos on edX", "entry"] >>> ], >>> "entries": { >>> "Working with Videos": { >>> "sort_key": None, >>> "is_divided": False, >>> "id": "d9f970a42067413cbb633f81cfb12604" >>> }, >>> "Videos on edX": { >>> "sort_key": None, >>> "is_divided": False, >>> "id": "98d8feb5971041a085512ae22b398613" >>> } >>> } >>> }, >>> "children": ["Getting Started", "subcategory"] >>> }, >>> } >>> }
- lms.djangoapps.discussion.views.followed_threads(request, course_key, user_id)#
Ajax-only endpoint retrieving the threads followed by a specific user.
- lms.djangoapps.discussion.views.forum_form_discussion(request, course_key)#
Renders the main Discussion page, potentially filtered by a search query
- lms.djangoapps.discussion.views.get_threads(request, course, user_info, discussion_id=None, per_page=20)#
This may raise an appropriate subclass of cc.utils.CommentClientError if something goes wrong, or ValueError if the group_id is invalid.
- Parameters:
request (WSGIRequest) – The user request.
course (CourseBlockWithMixins) – The course object.
user_info (dict) – The comment client User object as a dict.
discussion_id (unicode) – Optional discussion id/commentable id for context.
per_page (int) – Optional number of threads per page.
- Returns:
- A tuple of the list of threads and a dict of the
query parameters used for the search.
- Return type:
(tuple of list, dict)
- lms.djangoapps.discussion.views.inline_discussion(request, course_key, discussion_id)#
Renders JSON for DiscussionModules
- lms.djangoapps.discussion.views.is_course_staff(course_key: CourseKey, user: User)#
Check if user has course instructor or course staff role.
- lms.djangoapps.discussion.views.is_privileged_user(course_key: CourseKey, user: User)#
Returns True if user has one of following course role Administrator, Moderator, Group Moderator, Community TA, or Global Staff.
- lms.djangoapps.discussion.views.make_course_settings(course, user, include_category_map=True)#
Generate a JSON-serializable model for course settings, which will be used to initialize a DiscussionCourseSettings object on the client.
- lms.djangoapps.discussion.views.redirect_forum_url_to_new_mfe(request, course_id)#
Returns the redirect link when user opens default discussion homepage
- lms.djangoapps.discussion.views.redirect_thread_url_to_new_mfe(request, course_id, thread_id)#
Returns MFE url of the thread if the user is not privileged
- lms.djangoapps.discussion.views.single_thread(request, course_key, discussion_id, thread_id)#
Renders a response to display a single discussion thread. This could either be a page refresh after navigating to a single thread, a direct link to a single thread, or an AJAX call from the discussions UI loading the responses/comments for a single thread.
Depending on the HTTP headers, we’ll adjust our response accordingly.
- lms.djangoapps.discussion.views.use_bulk_ops(view_func)#
Wraps internal request handling inside a modulestore bulk op, significantly reducing redundant database calls. Also converts the course_id parsed from the request uri to a CourseKey before passing to the view.
- lms.djangoapps.discussion.views.user_profile(request, course_key, user_id)#
Renders a response to display the user profile page (shown after clicking on a post author’s username).