Search in sources :

Example 11 with Component

use of org.olat.core.gui.components.Component in project OpenOLAT by OpenOLAT.

the class CheckListRunController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    boolean readOnly = isReadOnly();
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("readOnly", Boolean.valueOf(readOnly));
        if (dueDate != null) {
            layoutCont.contextPut("dueDate", dueDate);
            layoutCont.contextPut("in-due-date", isPanelOpen(ureq, "due-date", true));
            if (dueDate.compareTo(new Date()) < 0) {
                layoutCont.contextPut("afterDueDate", Boolean.TRUE);
            }
        }
        layoutCont.contextPut("withScore", new Boolean(withScore));
        if (courseNode.getModuleConfiguration().getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD, false)) {
            HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, courseNode, this.mainForm);
            if (highScoreCtr.isViewHighscore()) {
                Component highScoreComponent = highScoreCtr.getInitialComponent();
                layoutCont.put("highScore", highScoreComponent);
            }
        }
        List<DBCheck> checks = checkboxManager.loadCheck(getIdentity(), courseOres, courseNode.getIdent());
        Map<String, DBCheck> uuidToCheckMap = new HashMap<>();
        for (DBCheck check : checks) {
            uuidToCheckMap.put(check.getCheckbox().getCheckboxId(), check);
        }
        List<Checkbox> list = checkboxList.getList();
        List<CheckboxWrapper> wrappers = new ArrayList<>(list.size());
        for (Checkbox checkbox : list) {
            DBCheck check = uuidToCheckMap.get(checkbox.getCheckboxId());
            CheckboxWrapper wrapper = forgeCheckboxWrapper(checkbox, check, readOnly, formLayout);
            layoutCont.add(wrapper.getCheckboxEl());
            wrappers.add(wrapper);
        }
        layoutCont.contextPut("checkboxList", wrappers);
        if (withScore || withPassed) {
            layoutCont.contextPut("enableScoreInfo", Boolean.TRUE);
            exposeConfigToVC(ureq, layoutCont);
            exposeUserDataToVC(ureq, layoutCont);
        } else {
            layoutCont.contextPut("enableScoreInfo", Boolean.FALSE);
        }
    }
}
Also used : DBCheck(org.olat.course.nodes.cl.model.DBCheck) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) HighScoreRunController(org.olat.course.highscore.ui.HighScoreRunController) Date(java.util.Date) Checkbox(org.olat.course.nodes.cl.model.Checkbox) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Component(org.olat.core.gui.components.Component)

Example 12 with Component

use of org.olat.core.gui.components.Component in project OpenOLAT by OpenOLAT.

the class ScormRunController method doStartPage.

private void doStartPage(UserRequest ureq) {
    // push title and learning objectives, only visible on intro page
    startPage.contextPut("menuTitle", scormNode.getShortTitle());
    startPage.contextPut("displayTitle", scormNode.getLongTitle());
    // Adding learning objectives
    String learningObj = scormNode.getLearningObjectives();
    if (learningObj != null) {
        Component learningObjectives = ObjectivesHelper.createLearningObjectivesComponent(learningObj, getLocale());
        startPage.put("learningObjectives", learningObjectives);
        startPage.contextPut("hasObjectives", Boolean.TRUE);
    } else {
        startPage.contextPut("hasObjectives", Boolean.FALSE);
    }
    if (isAssessable) {
        ScoreEvaluation scoreEval = scormNode.getUserScoreEvaluation(userCourseEnv);
        Float score = scoreEval.getScore();
        if (ScormEditController.CONFIG_ASSESSABLE_TYPE_SCORE.equals(assessableType)) {
            startPage.contextPut("score", score != null ? AssessmentHelper.getRoundedScore(score) : "0");
        }
        startPage.contextPut("hasPassedValue", (scoreEval.getPassed() == null ? Boolean.FALSE : Boolean.TRUE));
        startPage.contextPut("passed", scoreEval.getPassed());
        boolean resultsVisible = scoreEval.getUserVisible() == null || scoreEval.getUserVisible().booleanValue();
        startPage.contextPut("resultsVisible", resultsVisible);
        if (resultsVisible && scormNode.hasCommentConfigured()) {
            StringBuilder comment = Formatter.stripTabsAndReturns(scormNode.getUserUserComment(userCourseEnv));
            startPage.contextPut("comment", StringHelper.xssScan(comment));
        }
        startPage.contextPut("attempts", scormNode.getUserAttempts(userCourseEnv));
        if (ureq == null) {
            // High score need one
            ureq = new SyntheticUserRequest(getIdentity(), getLocale(), userSession);
        }
        HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, scormNode);
        if (highScoreCtr.isViewHighscore()) {
            Component highScoreComponent = highScoreCtr.getInitialComponent();
            startPage.put("highScore", highScoreComponent);
        }
    }
    startPage.contextPut("isassessable", Boolean.valueOf(isAssessable));
    main.setContent(startPage);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) HighScoreRunController(org.olat.course.highscore.ui.HighScoreRunController) SyntheticUserRequest(org.olat.core.gui.util.SyntheticUserRequest) Component(org.olat.core.gui.components.Component)

Example 13 with Component

use of org.olat.core.gui.components.Component in project OpenOLAT by OpenOLAT.

the class MessageListController method addMessageToCurrentMessagesAndVC.

private void addMessageToCurrentMessagesAndVC(UserRequest ureq, MessageLight m, MessageView messageView, Map<String, Mark> marks, Map<String, MarkResourceStat> stats, Map<String, Long> artefactStats, Set<Long> readSet) {
    // all values belonging to a message are stored in this map
    // these values can be accessed in velocity. make sure you clean up
    // everything
    // you create here in disposeCurrentMessages()!
    String keyString = m.getKey().toString();
    if (readSet == null || readSet.contains(m.getKey())) {
        messageView.setNewMessage(false);
    } else {
        // mark now as read
        markRead(m);
        messageView.setNewMessage(true);
    }
    // add some data now
    messageView.setFormattedCreationDate(formatter.formatDateAndTime(m.getCreationDate()));
    messageView.setFormattedLastModified(formatter.formatDateAndTime(m.getLastModified()));
    Identity creator = m.getCreator();
    Identity modifier = m.getModifier();
    if (modifier != null) {
        messageView.setModified(true);
        if (modifier.equals(creator) && StringHelper.containsNonWhitespace(m.getPseudonym())) {
            messageView.setModifierPseudonym(m.getPseudonym());
        } else {
            messageView.setModifierFirstName(modifier.getUser().getProperty(UserConstants.FIRSTNAME, getLocale()));
            messageView.setModifierLastName(modifier.getUser().getProperty(UserConstants.LASTNAME, getLocale()));
        }
    } else {
        messageView.setModified(false);
    }
    boolean userIsMsgCreator = false;
    // keeps the first 15 chars
    if (creator != null) {
        userIsMsgCreator = getIdentity().equals(creator);
        if (!StringHelper.containsNonWhitespace(m.getPseudonym())) {
            messageView.setCreatorFirstname(Formatter.truncate(creator.getUser().getProperty(UserConstants.FIRSTNAME, getLocale()), 18));
            messageView.setCreatorLastname(Formatter.truncate(creator.getUser().getProperty(UserConstants.LASTNAME, getLocale()), 18));
        }
    }
    // message attachments
    VFSContainer msgContainer = forumManager.getMessageContainer(forum.getKey(), m.getKey());
    messageView.setMessageContainer(msgContainer);
    List<VFSItem> attachments = new ArrayList<VFSItem>(msgContainer.getItems(new VFSItemMetaFilter()));
    messageView.setAttachments(attachments);
    // number of children and modify/delete permissions
    int numOfChildren = messageView.getNumOfChildren();
    messageView.setAuthor(userIsMsgCreator);
    boolean threadTop = m.getThreadtop() == null;
    messageView.setThreadTop(threadTop);
    boolean isThreadClosed;
    if (threadTop) {
        isThreadClosed = Status.getStatus(m.getStatusCode()).isClosed();
    } else {
        if (thread == null) {
            isThreadClosed = Status.getStatus(m.getThreadtop().getStatusCode()).isClosed();
        } else {
            isThreadClosed = Status.getStatus(thread.getStatusCode()).isClosed();
        }
    }
    messageView.setClosed(isThreadClosed);
    if (!guestOnly && !m.isGuest() && creator != null && !StringHelper.containsNonWhitespace(m.getPseudonym())) {
        // add portrait to map for later disposal and key for rendering in velocity
        DisplayPortraitController portrait = new DisplayPortraitController(ureq, getWindowControl(), creator, true, true, false, true);
        messageView.setPortrait(portrait);
        mainVC.put("portrait_".concat(keyString), portrait.getInitialComponent());
        // Add link with username that is clickable
        String creatorFullName = StringHelper.escapeHtml(UserManager.getInstance().getUserDisplayName(creator));
        Link visitingCardLink = LinkFactory.createCustomLink("vc_".concat(keyString), "vc", creatorFullName, Link.LINK_CUSTOM_CSS + Link.NONTRANSLATED, mainVC, this);
        visitingCardLink.setUserObject(creator);
        LinkPopupSettings settings = new LinkPopupSettings(800, 600, "_blank");
        visitingCardLink.setPopup(settings);
    }
    if (!isThreadClosed) {
        if ((numOfChildren == 0 && userIsMsgCreator && foCallback.mayDeleteOwnMessage()) || foCallback.mayDeleteMessageAsModerator()) {
            Link deleteLink = LinkFactory.createCustomLink("dl_".concat(keyString), "dl", "msg.delete", Link.BUTTON_SMALL, mainVC, this);
            deleteLink.setIconLeftCSS("o_icon o_icon-fw o_icon_delete_item");
            deleteLink.setUserObject(messageView);
        }
        if ((numOfChildren == 0 && userIsMsgCreator && foCallback.mayEditOwnMessage()) || foCallback.mayEditMessageAsModerator()) {
            Link editLink = LinkFactory.createCustomLink("ed_".concat(keyString), "ed", "msg.update", Link.BUTTON_SMALL, mainVC, this);
            editLink.setIconLeftCSS("o_icon o_icon-fw o_icon_edit");
            editLink.setUserObject(messageView);
        }
        if (foCallback.mayReplyMessage()) {
            Link quoteLink = LinkFactory.createCustomLink("qt_".concat(keyString), "qt", "msg.quote", Link.BUTTON_SMALL, mainVC, this);
            quoteLink.setElementCssClass("o_sel_forum_reply_quoted");
            quoteLink.setIconLeftCSS("o_icon o_icon-fw o_icon_reply_with_quote");
            quoteLink.setUserObject(messageView);
            Link replyLink = LinkFactory.createCustomLink("rp_".concat(keyString), "rp", "msg.reply", Link.BUTTON_SMALL, mainVC, this);
            replyLink.setElementCssClass("o_sel_forum_reply");
            replyLink.setIconLeftCSS("o_icon o_icon-fw o_icon_reply");
            replyLink.setUserObject(messageView);
        }
        if (foCallback.mayEditMessageAsModerator()) {
            if (!threadTop) {
                Link splitLink = LinkFactory.createCustomLink("split_".concat(keyString), "split", "msg.split", Link.LINK, mainVC, this);
                splitLink.setIconLeftCSS("o_icon o_icon-fw o_icon_split");
                splitLink.setUserObject(messageView);
                Link moveLink = LinkFactory.createCustomLink("move_".concat(keyString), "move", "msg.move", Link.LINK, mainVC, this);
                moveLink.setIconLeftCSS("o_icon o_icon-fw o_icon_move");
                moveLink.setUserObject(messageView);
            }
            Link exileLink = LinkFactory.createCustomLink("exile_".concat(keyString), "exile", "msg.exile", Link.LINK, mainVC, this);
            exileLink.setIconLeftCSS("o_icon o_icon-fw o_forum_status_thread_icon");
            exileLink.setUserObject(messageView);
        }
    }
    Mark currentMark = marks.get(keyString);
    MarkResourceStat stat = stats.get(keyString);
    if (!guestOnly) {
        String businessPath = currentMark == null ? getWindowControl().getBusinessControl().getAsString() + "[Message:" + m.getKey() + "]" : currentMark.getBusinessPath();
        Controller markCtrl = markingService.getMarkController(ureq, getWindowControl(), currentMark, stat, forumOres, keyString, businessPath);
        mainVC.put("mark_".concat(keyString), markCtrl.getInitialComponent());
    }
    if (userIsMsgCreator && !StringHelper.containsNonWhitespace(m.getPseudonym())) {
        OLATResourceable messageOres = OresHelper.createOLATResourceableInstance("Forum", m.getKey());
        String businessPath = BusinessControlFactory.getInstance().getAsString(getWindowControl().getBusinessControl()) + "[Message:" + m.getKey() + "]";
        Long artefact = artefactStats.get(businessPath);
        int numOfArtefact = artefact == null ? 0 : artefact.intValue();
        if (portfolioModule.isEnabled()) {
            String collectorId = "eportfolio_" + keyString;
            Component collectorCmp = new MediaCollectorComponent(collectorId, getWindowControl(), m, forumMediaHandler, businessPath);
            mainVC.put(collectorId, collectorCmp);
        } else {
            Controller ePFCollCtrl = EPUIFactory.createArtefactCollectWizzardController(ureq, getWindowControl(), numOfArtefact, messageOres, businessPath);
            if (ePFCollCtrl != null) {
                messageView.setArtefact(ePFCollCtrl);
                mainVC.put("eportfolio_" + keyString, ePFCollCtrl.getInitialComponent());
            }
        }
    }
}
Also used : VFSItemMetaFilter(org.olat.core.util.vfs.filters.VFSItemMetaFilter) DisplayPortraitController(org.olat.user.DisplayPortraitController) MarkResourceStat(org.olat.core.commons.services.mark.MarkResourceStat) MediaCollectorComponent(org.olat.modules.portfolio.ui.component.MediaCollectorComponent) OLATResourceable(org.olat.core.id.OLATResourceable) VFSContainer(org.olat.core.util.vfs.VFSContainer) ArrayList(java.util.ArrayList) VFSItem(org.olat.core.util.vfs.VFSItem) Mark(org.olat.core.commons.services.mark.Mark) DisplayPortraitController(org.olat.user.DisplayPortraitController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController) BasicController(org.olat.core.gui.control.controller.BasicController) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) UserInfoMainController(org.olat.user.UserInfoMainController) Controller(org.olat.core.gui.control.Controller) LinkPopupSettings(org.olat.core.gui.components.link.LinkPopupSettings) Identity(org.olat.core.id.Identity) Component(org.olat.core.gui.components.Component) MediaCollectorComponent(org.olat.modules.portfolio.ui.component.MediaCollectorComponent) Link(org.olat.core.gui.components.link.Link)

Example 14 with Component

use of org.olat.core.gui.components.Component in project OpenOLAT by OpenOLAT.

the class TitleHandler method getContent.

@Override
public PageRunElement getContent(UserRequest ureq, WindowControl wControl, PageElement element, PageElementRenderingHints hints) {
    String content = "";
    if (element instanceof Title) {
        content = ((Title) element).getContent();
    }
    Component cmp = TextFactory.createTextComponentFromString("title_" + idGenerator.incrementAndGet(), content, null, false, null);
    return new PageRunComponent(cmp);
}
Also used : PageRunComponent(org.olat.modules.portfolio.ui.editor.PageRunComponent) Title(org.olat.modules.forms.model.xml.Title) Component(org.olat.core.gui.components.Component) PageRunComponent(org.olat.modules.portfolio.ui.editor.PageRunComponent)

Example 15 with Component

use of org.olat.core.gui.components.Component in project OpenOLAT by OpenOLAT.

the class BinderOnePageController method loadPage.

private void loadPage(UserRequest ureq, Page page) {
    String id = "page_w_" + (++counter);
    VelocityContainer pageVC = createVelocityContainer(id, "page_content_print");
    mainVC.put(id, pageVC);
    components.add(id);
    BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getReadOnlyCallback();
    PageMetadataController metadatCtrl = new PageMetadataController(ureq, getWindowControl(), secCallback, page);
    listenTo(metadatCtrl);
    Component pageMetaCmp = metadatCtrl.getInitialComponent();
    pageVC.put("meta", pageMetaCmp);
    PageController pageCtrl = new PageController(ureq, getWindowControl(), new PortfolioPageProvider(page), renderingHints);
    listenTo(pageCtrl);
    pageCtrl.loadElements(ureq);
    Component pageCmp = pageCtrl.getInitialComponent();
    pageVC.put("page", pageCmp);
    CommentAndRatingSecurityCallback commentSecCallback = new ReadOnlyCommentsSecurityCallback();
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(Page.class, page.getKey());
    UserCommentsController commentsCtrl = new UserCommentsController(ureq, getWindowControl(), ores, null, commentSecCallback);
    listenTo(commentsCtrl);
    if (commentsCtrl.getNumOfComments() > 0) {
        pageVC.put("comments", commentsCtrl.getInitialComponent());
    }
}
Also used : CommentAndRatingSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback) PageController(org.olat.modules.portfolio.ui.editor.PageController) OLATResourceable(org.olat.core.id.OLATResourceable) ReadOnlyCommentsSecurityCallback(org.olat.modules.portfolio.ui.model.ReadOnlyCommentsSecurityCallback) UserCommentsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsController) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) Component(org.olat.core.gui.components.Component) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Aggregations

Component (org.olat.core.gui.components.Component)300 SegmentViewComponent (org.olat.core.gui.components.segmentedview.SegmentViewComponent)90 SegmentViewEvent (org.olat.core.gui.components.segmentedview.SegmentViewEvent)90 ArrayList (java.util.ArrayList)36 Controller (org.olat.core.gui.control.Controller)28 Link (org.olat.core.gui.components.link.Link)22 BasicController (org.olat.core.gui.control.controller.BasicController)22 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)22 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)18 Panel (org.olat.core.gui.components.panel.Panel)12 HighScoreRunController (org.olat.course.highscore.ui.HighScoreRunController)12 Date (java.util.Date)10 UserRequest (org.olat.core.gui.UserRequest)10 ComponentRenderer (org.olat.core.gui.components.ComponentRenderer)10 TreeNode (org.olat.core.gui.components.tree.TreeNode)10 RenderResult (org.olat.core.gui.render.RenderResult)10 StringOutput (org.olat.core.gui.render.StringOutput)10 Translator (org.olat.core.gui.translator.Translator)10 AbstractComponent (org.olat.core.gui.components.AbstractComponent)8 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)8