diff --git a/lms/djangoapps/discussion/rest_api/api.py b/lms/djangoapps/discussion/rest_api/api.py index c512366b70..9a64a2809b 100644 --- a/lms/djangoapps/discussion/rest_api/api.py +++ b/lms/djangoapps/discussion/rest_api/api.py @@ -92,7 +92,7 @@ from .serializers import ( UserStatsSerializer, get_context, ) -from .utils import discussion_open_for_user +from .utils import discussion_open_for_user, set_threads_attribute_value User = get_user_model() @@ -883,6 +883,7 @@ def get_learner_active_thread_list(request, course_key, query_params): profiled_user = comment_client.User(id=user_id, course_id=course_key) threads, page, num_pages = profiled_user.active_threads(query_params) + threads = set_threads_attribute_value(threads, "pinned", False) results = _serialize_discussion_entities( request, context, threads, {'profile_image'}, DiscussionEntity.thread ) diff --git a/lms/djangoapps/discussion/rest_api/utils.py b/lms/djangoapps/discussion/rest_api/utils.py index 5daa90c0ac..4241b22585 100644 --- a/lms/djangoapps/discussion/rest_api/utils.py +++ b/lms/djangoapps/discussion/rest_api/utils.py @@ -14,3 +14,17 @@ def discussion_open_for_user(course, user): user: User to check for privileges in course """ return course.forum_posts_allowed or has_discussion_privileges(user, course.id) + + +def set_threads_attribute_value(threads, attribute, value): + """ + It iterates over thread list and assign thread attribute the value + + Arguments: + threads: List containing threads + attribute: the key for thread dict + value: the value to assign to the thread attribute + """ + for thread in threads: + thread[attribute] = value + return threads