def get_cohorted_discussions(course, course_settings): """ Returns the course-wide and inline cohorted discussion ids separately. """ cohorted_course_wide_discussions = [] cohorted_inline_discussions = [] course_wide_discussions = [topic['id'] for __, topic in course.discussion_topics.items()] all_discussions = get_discussion_categories_ids(course, None, include_all=True) for cohorted_discussion_id in course_settings.cohorted_discussions: if cohorted_discussion_id in course_wide_discussions: cohorted_course_wide_discussions.append(cohorted_discussion_id) elif cohorted_discussion_id in all_discussions: cohorted_inline_discussions.append(cohorted_discussion_id) return cohorted_course_wide_discussions, cohorted_inline_discussions
def get_cohorted_discussions(course, course_settings): """ Returns the course-wide and inline cohorted discussion ids separately. """ cohorted_course_wide_discussions = [] cohorted_inline_discussions = [] course_wide_discussions = [topic['id'] for __, topic in course.discussion_topics.items()] all_discussions = get_discussion_categories_ids(course, None, include_all=True) for cohorted_discussion_id in course_settings.cohorted_discussions: if cohorted_discussion_id in course_wide_discussions: cohorted_course_wide_discussions.append(cohorted_discussion_id) elif cohorted_discussion_id in all_discussions: cohorted_inline_discussions.append(cohorted_discussion_id) return cohorted_course_wide_discussions, cohorted_inline_discussions
def get_discussion_topics(self, course_id): user_id = self.get_current_user_id() #user id retrieved via function user_logged_in_object = _get_current_user( user_id) #This is User Profile Object for current logged in user course_object = modulestore().get_course( course_id) #This is course object content = get_discussion_category_map(course=course_object, user=user_logged_in_object, cohorted_if_in_list=False, exclude_unstarted=True) categories_id = get_discussion_categories_ids(course_object, user_logged_in_object) discussion_details = [] for category, info in sorted(content["subcategories"].items()): for subcategory, value in sorted(info["entries"].items()): discussion_details.append({ "name": category + " / " + subcategory, "id": value["id"] }) return discussion_details