Search in sources :

Example 6 with BookSection

use of org.olat.modules.edubase.BookSection in project openolat by klemens.

the class EdubaseRunController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == overviewContainer && EVENT_RUN.equals(event.getCommand().substring(0, EVENT_RUN.length()))) {
        // Start Edubase Reader if description enabled
        int bookSectionIndex = Integer.parseInt(event.getCommand().substring(EVENT_RUN.length()));
        BookSection bookSection = bookSections.get(bookSectionIndex);
        openViewer(ureq, bookSection);
    } else if (source instanceof Link) {
        // Start Edubase Reader if description disabled
        Link startReaderLink = (Link) source;
        BookSection bookSection = (BookSection) startReaderLink.getUserObject();
        openViewer(ureq, bookSection);
    }
}
Also used : BookSection(org.olat.modules.edubase.BookSection) Link(org.olat.core.gui.components.link.Link)

Example 7 with BookSection

use of org.olat.modules.edubase.BookSection in project openolat by klemens.

the class EdubaseManagerImplTest method getLtiLaunchUrlShoudAppendPageFrom.

@Test
public void getLtiLaunchUrlShoudAppendPageFrom() {
    BookSection bookSection = new BookSectionImpl();
    bookSection.setBookId(BOOK_ID);
    Integer pageFrom = 9898;
    bookSection.setPageFrom(pageFrom);
    String baseUrl = "https://edubase.ch";
    when(edubaseModuleMock.getLtiLaunchUrl()).thenReturn(baseUrl);
    String generatedLtiUrl = sut.getLtiLaunchUrl(bookSection);
    String expectedLtiUrl = baseUrl + "/" + BOOK_ID + "/" + pageFrom;
    assertThat(generatedLtiUrl).isEqualTo(expectedLtiUrl);
}
Also used : BookSection(org.olat.modules.edubase.BookSection) BookSectionImpl(org.olat.modules.edubase.model.BookSectionImpl) Test(org.junit.Test)

Example 8 with BookSection

use of org.olat.modules.edubase.BookSection in project OpenOLAT by OpenOLAT.

the class EdubaseRunController method createOverviewComponent.

private Component createOverviewComponent(ModuleConfiguration modulConfiguration) {
    VelocityContainer container;
    if (modulConfiguration.getBooleanSafe(EdubaseCourseNode.CONFIG_DESCRIPTION_ENABLED)) {
        container = createVelocityContainer(OVERVIEW_DESCRIPTION_ENABLED);
    } else {
        container = createVelocityContainer(OVERVIEW_DESCRIPTION_DISABLED);
    }
    bookSections = modulConfiguration.getList(EdubaseCourseNode.CONFIG_BOOK_SECTIONS, BookSection.class).stream().sorted(new PositionComparator()).collect(Collectors.toList());
    container.contextPut("bookSections", bookSections);
    for (BookSection bookSection : bookSections) {
        Link nodeLink = LinkFactory.createLink("startReader_" + bookSection.getPosition(), container, this);
        nodeLink.setCustomDisplayText(getTranslator().translate("open.document"));
        nodeLink.setIconRightCSS("o_icon o_icon_start");
        nodeLink.setUserObject(bookSection);
    }
    EdubaseViewHelper edubaseViewHelper = new EdubaseViewHelper(getTranslator());
    container.contextPut("helper", edubaseViewHelper);
    container.contextPut("run", EVENT_RUN);
    return container;
}
Also used : PositionComparator(org.olat.modules.edubase.model.PositionComparator) BookSection(org.olat.modules.edubase.BookSection) Link(org.olat.core.gui.components.link.Link) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 9 with BookSection

use of org.olat.modules.edubase.BookSection in project OpenOLAT by OpenOLAT.

the class EdubaseRunController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == overviewContainer && EVENT_RUN.equals(event.getCommand().substring(0, EVENT_RUN.length()))) {
        // Start Edubase Reader if description enabled
        int bookSectionIndex = Integer.parseInt(event.getCommand().substring(EVENT_RUN.length()));
        BookSection bookSection = bookSections.get(bookSectionIndex);
        openViewer(ureq, bookSection);
    } else if (source instanceof Link) {
        // Start Edubase Reader if description disabled
        Link startReaderLink = (Link) source;
        BookSection bookSection = (BookSection) startReaderLink.getUserObject();
        openViewer(ureq, bookSection);
    }
}
Also used : BookSection(org.olat.modules.edubase.BookSection) Link(org.olat.core.gui.components.link.Link)

Example 10 with BookSection

use of org.olat.modules.edubase.BookSection in project OpenOLAT by OpenOLAT.

the class EdubaseBookSectionListController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("pane.tab.book.section.list");
    setFormContextHelp("KnowledgeTransfer#_edubase");
    String page = velocity_root + "/bookSectionList.html";
    bookSectionsCont = FormLayoutContainer.createCustomFormLayout("bookSections", getTranslator(), page);
    bookSectionsCont.setRootForm(mainForm);
    formLayout.add(bookSectionsCont);
    // BookSections
    List<BookSection> bookSections = new ArrayList<>(config.getList(EdubaseCourseNode.CONFIG_BOOK_SECTIONS, BookSectionImpl.class));
    bookSections.stream().sorted(new PositionComparator()).forEach(this::wrapBookSection);
    ensureBookSectionWrappersHaveAnEntry();
    bookSectionsCont.contextPut("bookSections", bookSectionWrappers);
    recalculateUpDownLinks();
    // Submit Button
    FormLayoutContainer buttonLayout = FormLayoutContainer.createDefaultFormLayout_2_10("buttons", getTranslator());
    buttonLayout.setRootForm(mainForm);
    formLayout.add(buttonLayout);
    uifactory.addFormSubmitButton("save", buttonLayout);
}
Also used : ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) PositionComparator(org.olat.modules.edubase.model.PositionComparator) BookSection(org.olat.modules.edubase.BookSection) BookSectionImpl(org.olat.modules.edubase.model.BookSectionImpl)

Aggregations

BookSection (org.olat.modules.edubase.BookSection)14 BookSectionImpl (org.olat.modules.edubase.model.BookSectionImpl)8 Link (org.olat.core.gui.components.link.Link)6 PositionComparator (org.olat.modules.edubase.model.PositionComparator)6 Test (org.junit.Test)4 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)4 ArrayList (java.util.ArrayList)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2