Search in sources :

Example 1 with BlockModel

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);
}
Also used : VideoBlockModel(org.edx.mobile.model.course.VideoBlockModel) BlockModel(org.edx.mobile.model.course.BlockModel) VideoBlockModel(org.edx.mobile.model.course.VideoBlockModel) CourseComponent(org.edx.mobile.model.course.CourseComponent) Before(org.junit.Before)

Example 2 with BlockModel

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;
}
Also used : BlockModel(org.edx.mobile.model.course.BlockModel) DiscussionBlockModel(org.edx.mobile.model.course.DiscussionBlockModel) VideoBlockModel(org.edx.mobile.model.course.VideoBlockModel) HtmlBlockModel(org.edx.mobile.model.course.HtmlBlockModel) CourseContentNotValidException(org.edx.mobile.exception.CourseContentNotValidException) CourseComponent(org.edx.mobile.model.course.CourseComponent) NonNull(android.support.annotation.NonNull)

Aggregations

BlockModel (org.edx.mobile.model.course.BlockModel)2 CourseComponent (org.edx.mobile.model.course.CourseComponent)2 VideoBlockModel (org.edx.mobile.model.course.VideoBlockModel)2 NonNull (android.support.annotation.NonNull)1 CourseContentNotValidException (org.edx.mobile.exception.CourseContentNotValidException)1 DiscussionBlockModel (org.edx.mobile.model.course.DiscussionBlockModel)1 HtmlBlockModel (org.edx.mobile.model.course.HtmlBlockModel)1 Before (org.junit.Before)1