use of org.edx.mobile.model.course.BlockModel in project edx-app-android by edx.
the class CourseComponentTest method setUp.
@Before
public void setUp() throws Exception {
BlockModel bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.COURSE;
bm.id = UUID.randomUUID().toString();
course = new CourseComponent(bm, null);
course.setCourseId(UUID.randomUUID().toString());
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.CHAPTER;
bm.id = UUID.randomUUID().toString();
chapter1 = new CourseComponent(bm, course);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.SECTION;
bm.id = UUID.randomUUID().toString();
sequential1 = new CourseComponent(bm, chapter1);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.VERTICAL;
bm.id = UUID.randomUUID().toString();
vertical1 = new CourseComponent(bm, sequential1);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.VIDEO;
bm.id = UUID.randomUUID().toString();
unit1 = new VideoBlockModel(bm, vertical1);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.HTML;
bm.id = UUID.randomUUID().toString();
unit2 = new CourseComponent(bm, vertical1);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.CHAPTER;
bm.id = UUID.randomUUID().toString();
chapter2 = new CourseComponent(bm, course);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.SECTION;
bm.id = UUID.randomUUID().toString();
sequential2 = new CourseComponent(bm, chapter2);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.VERTICAL;
bm.id = UUID.randomUUID().toString();
vertical2 = new CourseComponent(bm, sequential2);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.VIDEO;
bm.id = UUID.randomUUID().toString();
unit3 = new VideoBlockModel(bm, vertical2);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.HTML;
bm.id = UUID.randomUUID().toString();
unit4 = new CourseComponent(bm, vertical2);
}
use of org.edx.mobile.model.course.BlockModel in project edx-app-android by edx.
the class CourseAPI method normalizeCourseStructure.
/**
* Mapping from raw data structure from getCourseStructure() API
* @param courseStructureV1Model
* @return
*/
@NonNull
public static IBlock normalizeCourseStructure(@NonNull final CourseStructureV1Model courseStructureV1Model, @NonNull final String courseId) throws CourseContentNotValidException {
BlockModel topBlock = courseStructureV1Model.getBlockById(courseStructureV1Model.root);
if (topBlock == null) {
throw new CourseContentNotValidException("Server didn't send a proper response for this course: " + courseStructureV1Model.root);
}
CourseComponent course = new CourseComponent(topBlock, null);
course.setCourseId(courseId);
for (BlockModel m : courseStructureV1Model.getDescendants(topBlock)) {
normalizeCourseStructure(courseStructureV1Model, m, course);
}
return course;
}
Aggregations