From a91139d4c0726aa723fef6d5dc369c7a60291656 Mon Sep 17 00:00:00 2001 From: "adeel.tajamul" Date: Tue, 21 Jun 2022 18:43:38 +0500 Subject: [PATCH 1/2] fix: fixed topics api sort to same as legacy sort --- lms/djangoapps/discussion/rest_api/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/djangoapps/discussion/rest_api/api.py b/lms/djangoapps/discussion/rest_api/api.py index 7324b9d607..dd1f2ac97c 100644 --- a/lms/djangoapps/discussion/rest_api/api.py +++ b/lms/djangoapps/discussion/rest_api/api.py @@ -376,7 +376,7 @@ def get_courseware_topics( for category in sorted(xblocks_by_category.keys()): children = [] - for xblock in get_sorted_xblocks(category): + for xblock in xblocks_by_category[category]: if not topic_ids or xblock.discussion_id in topic_ids: discussion_topic = DiscussionTopic( xblock.discussion_id, From 7d6ce90213c3d3211d72bb916842a121aef045b9 Mon Sep 17 00:00:00 2001 From: "adeel.tajamul" Date: Wed, 22 Jun 2022 06:25:40 +0500 Subject: [PATCH 2/2] fix: fixed topics test cases --- .../discussion/rest_api/tests/test_api.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lms/djangoapps/discussion/rest_api/tests/test_api.py b/lms/djangoapps/discussion/rest_api/tests/test_api.py index ae79fd5d52..469ddc0c91 100644 --- a/lms/djangoapps/discussion/rest_api/tests/test_api.py +++ b/lms/djangoapps/discussion/rest_api/tests/test_api.py @@ -453,13 +453,13 @@ class GetCourseTopicsTest(CommentsServiceMockMixin, ForumsEnableMixin, UrlResetM "Z": {"id": "non-courseware-4", "sort_key": "W"}, } self.store.update_item(self.course, self.user.id) - self.make_discussion_xblock("courseware-1", "First", "A", sort_key="D") - self.make_discussion_xblock("courseware-2", "First", "B", sort_key="B") + self.make_discussion_xblock("courseware-1", "First", "A", sort_key="B") + self.make_discussion_xblock("courseware-2", "First", "B", sort_key="D") self.make_discussion_xblock("courseware-3", "First", "C", sort_key="E") - self.make_discussion_xblock("courseware-4", "Second", "A", sort_key="F") - self.make_discussion_xblock("courseware-5", "Second", "B", sort_key="G") + self.make_discussion_xblock("courseware-4", "Second", "A", sort_key="A") + self.make_discussion_xblock("courseware-5", "Second", "B", sort_key="B") self.make_discussion_xblock("courseware-6", "Second", "C") - self.make_discussion_xblock("courseware-7", "Second", "D", sort_key="A") + self.make_discussion_xblock("courseware-7", "Second", "D", sort_key="D") actual = self.get_course_topics() expected = { @@ -468,8 +468,8 @@ class GetCourseTopicsTest(CommentsServiceMockMixin, ForumsEnableMixin, UrlResetM None, "First", [ - self.make_expected_tree("courseware-2", "B"), self.make_expected_tree("courseware-1", "A"), + self.make_expected_tree("courseware-2", "B"), self.make_expected_tree("courseware-3", "C"), ] ), @@ -477,10 +477,10 @@ class GetCourseTopicsTest(CommentsServiceMockMixin, ForumsEnableMixin, UrlResetM None, "Second", [ - self.make_expected_tree("courseware-7", "D"), - self.make_expected_tree("courseware-6", "C"), self.make_expected_tree("courseware-4", "A"), self.make_expected_tree("courseware-5", "B"), + self.make_expected_tree("courseware-6", "C"), + self.make_expected_tree("courseware-7", "D"), ] ), ], @@ -522,7 +522,6 @@ class GetCourseTopicsTest(CommentsServiceMockMixin, ForumsEnableMixin, UrlResetM with self.store.bulk_operations(self.course.id, emit_signals=False): self.store.update_item(self.course, self.user.id) - self.make_discussion_xblock("courseware-1", "First", "Everybody") self.make_discussion_xblock( "courseware-2", "First", @@ -535,13 +534,14 @@ class GetCourseTopicsTest(CommentsServiceMockMixin, ForumsEnableMixin, UrlResetM "Cohort B", group_access={self.partition.id: [self.partition.groups[1].id]} ) - self.make_discussion_xblock("courseware-4", "Second", "Staff Only", visible_to_staff_only=True) + self.make_discussion_xblock("courseware-1", "First", "Everybody") self.make_discussion_xblock( "courseware-5", "Second", "Future Start Date", start=datetime.now(UTC) + timedelta(days=1) ) + self.make_discussion_xblock("courseware-4", "Second", "Staff Only", visible_to_staff_only=True) student_actual = self.get_course_topics() student_expected = {