def verify_content_existence(self, modulestore, root_dir, location, dirname, category_name, filename_suffix=''): filesystem = OSFS(root_dir / 'test_export') self.assertTrue(filesystem.exists(dirname)) query_loc = Location('i4x', location.org, location.course, category_name, None) items = modulestore.get_items(query_loc) for item in items: filesystem = OSFS(root_dir / ('test_export/' + dirname)) self.assertTrue(filesystem.exists(item.location.name + filename_suffix))
def _get_usage_info(course, modulestore): """ Get all units names and their urls that have experiments and associated with configurations. Returns: {'user_partition_id': [ {'label': 'Unit Name / Experiment Name', 'url': 'url_to_unit_1'}, {'label': 'Another Unit Name / Another Experiment Name', 'url': 'url_to_unit_1'} ], } """ usage_info = {} descriptors = modulestore.get_items(course.id, category='split_test') for split_test in descriptors: if split_test.user_partition_id not in usage_info: usage_info[split_test.user_partition_id] = [] unit_location = modulestore.get_parent_location(split_test.location) if not unit_location: log.warning("Parent location of split_test module not found: %s", split_test.location) continue try: unit = modulestore.get_item(unit_location) except ItemNotFoundError: log.warning("Unit not found: %s", unit_location) continue unit_url = reverse_usage_url( 'unit_handler', course.location.course_key.make_usage_key(unit.location.block_type, unit.location.name) ) usage_info[split_test.user_partition_id].append({ 'label': '{} / {}'.format(unit.display_name, split_test.display_name), 'url': unit_url }) return usage_info