Skip to content

Commit 6109062

Browse files
ayesha-warisAyesha Waris
andauthored
fix: stoped group TA to see the posts of other cohorts (#36765)
* fix: stoped group TA to see the posts of other cohorts * test: updated test cases --------- Co-authored-by: Ayesha Waris <[email protected]>
1 parent 21399b4 commit 6109062

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

lms/djangoapps/discussion/rest_api/api.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,10 @@ def get_thread_list(
990990
except ValueError:
991991
pass
992992

993-
if (group_id is None) and not context["has_moderation_privilege"]:
993+
if (group_id is None) and (
994+
not context["has_moderation_privilege"]
995+
or request.user.id in context["ta_user_ids"]
996+
):
994997
group_id = get_group_id_for_user(request.user, CourseDiscussionSettings.get(course.id))
995998

996999
query_params = {

lms/djangoapps/discussion/rest_api/tests/test_api.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
FORUM_ROLE_COMMUNITY_TA,
7878
FORUM_ROLE_MODERATOR,
7979
FORUM_ROLE_STUDENT,
80+
FORUM_ROLE_GROUP_MODERATOR,
8081
Role
8182
)
8283
from openedx.core.lib.exceptions import CourseNotFoundError, PageNotFoundError
@@ -885,6 +886,7 @@ def test_thread_content(self):
885886
FORUM_ROLE_MODERATOR,
886887
FORUM_ROLE_COMMUNITY_TA,
887888
FORUM_ROLE_STUDENT,
889+
FORUM_ROLE_GROUP_MODERATOR,
888890
],
889891
[True, False]
890892
)
@@ -897,7 +899,8 @@ def test_request_group(self, role_name, course_is_cohorted):
897899
_assign_role_to_user(user=self.user, course_id=cohort_course.id, role=role_name)
898900
self.get_thread_list([], course=cohort_course)
899901
actual_has_group = "group_id" in httpretty.last_request().querystring # lint-amnesty, pylint: disable=no-member
900-
expected_has_group = (course_is_cohorted and role_name == FORUM_ROLE_STUDENT)
902+
expected_has_group = (course_is_cohorted and
903+
role_name in (FORUM_ROLE_STUDENT, FORUM_ROLE_COMMUNITY_TA, FORUM_ROLE_GROUP_MODERATOR))
901904
assert actual_has_group == expected_has_group
902905

903906
def test_pagination(self):
@@ -1787,10 +1790,10 @@ def test_call_with_paginated_results(self, page):
17871790

17881791
if page in (1, 2):
17891792
assert response.data["pagination"]["next"] is not None
1790-
assert f"page={page+1}" in response.data["pagination"]["next"]
1793+
assert f"page={page + 1}" in response.data["pagination"]["next"]
17911794
if page in (2, 3):
17921795
assert response.data["pagination"]["previous"] is not None
1793-
assert f"page={page-1}" in response.data["pagination"]["previous"]
1796+
assert f"page={page - 1}" in response.data["pagination"]["previous"]
17941797
if page == 1:
17951798
assert response.data["pagination"]["previous"] is None
17961799
if page == 3:

0 commit comments

Comments
 (0)