def discussion_id_map(self): """ Return a mapping of discussion ids to usage keys of the corresponding discussion modules. """ if self.discussion_id_map_json: result = json.loads(self.discussion_id_map_json) for discussion_id in result: # Usage key strings might not include the course run, so we add it back in with map_into_course result[discussion_id] = UsageKey.from_string(result[discussion_id]).map_into_course(self.course_id) return result return None
def test_discussion_id_map(self): id_map = { 'discussion_id_1': 'block-v1:TestX+TS101+T1+type@discussion+block@b141953dff414921a715da37eb14ecdc', 'discussion_id_2': 'i4x://TestX/TS101/discussion/466f474fa4d045a8b7bde1b911e095ca' } id_map_json = json.dumps(id_map) structure = CourseStructure.objects.create(course_id=self.course.id, discussion_id_map_json=id_map_json) expected_id_map = { key: UsageKey.from_string(value).map_into_course(self.course.id) for key, value in id_map.iteritems() } self.assertEqual(structure.discussion_id_map, expected_id_map)
def discussion_id_map(self): """ Return a mapping of discussion ids to usage keys of the corresponding discussion modules. """ if self.discussion_id_map_json: result = json.loads(self.discussion_id_map_json) for discussion_id in result: # Usage key strings might not include the course run, so we add it back in with map_into_course result[discussion_id] = UsageKey.from_string( result[discussion_id]).map_into_course(self.course_id) return result return None