Search in sources :

Example 66 with Controller

use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.

the class AdditionalConditionManager method nextUserInputController.

/**
 * used to get the gui element for the next condition that a user can influence or sees a more detailed error-message in
 * call only if the evaluateCondtions() call answered with false or null
 * @param ureq
 * @param wControl
 * @return null if either nothing is wrong or the user is unable to influence the condition in olat (and won't get a more detailed error-message)
 */
public Controller nextUserInputController(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv) {
    for (AdditionalCondition cond : node.getAdditionalConditions()) {
        cond.setNode(node);
        cond.setCourseId(courseId);
        boolean retVal = cond.evaluate(answers);
        if (!retVal) {
            Controller ctrl = cond.getUserInputController(ureq, wControl, userCourseEnv);
            CourseNodeConfiguration config = CourseNodeFactory.getInstance().getCourseNodeConfiguration(node.getType());
            return TitledWrapperHelper.getWrapper(ureq, wControl, ctrl, node, config.getIconCSSClass());
        }
    }
    return null;
}
Also used : CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration) Controller(org.olat.core.gui.control.Controller)

Example 67 with Controller

use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.

the class GroupInfoMainController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty()) {
        addToHistory(ureq);
        return;
    }
    ContextEntry entry = entries.get(0);
    String menuItem = entry.getOLATResourceable().getResourceableTypeName();
    Object nodeUserObject = null;
    Controller selectedController = null;
    if ("Infos".equals(menuItem)) {
        selectedController = getInfosController(ureq);
        nodeUserObject = COMMAND_MENU_GROUPINFO;
    } else if ("Contact".equals(menuItem)) {
        selectedController = getContactController(ureq);
        nodeUserObject = COMMAND_MENU_GROUPCONTACT;
    } else if ("Members".equals(menuItem)) {
        selectedController = getMembersController(ureq);
        nodeUserObject = COMMAND_MENU_GROUPMEMBERS;
    }
    if (selectedController != null) {
        TreeNode node = TreeHelper.findNodeByUserObject(nodeUserObject, menuTree.getTreeModel().getRootNode());
        if (node != null) {
            menuTree.setSelectedNode(node);
        }
        addToHistory(ureq, selectedController);
    }
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) WeeklyCalendarController(org.olat.commons.calendar.ui.WeeklyCalendarController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) Controller(org.olat.core.gui.control.Controller) MainLayoutBasicController(org.olat.core.gui.control.controller.MainLayoutBasicController) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 68 with Controller

use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.

the class QTI21ResultsExportMediaResource method createResultDetail.

private List<ResultDetail> createResultDetail(Identity identity, ZipOutputStream zout, String idDir) throws IOException {
    List<ResultDetail> assessments = new ArrayList<>();
    List<AssessmentTestSession> sessions = qtiService.getAssessmentTestSessions(entry, courseNode.getIdent(), identity);
    for (AssessmentTestSession session : sessions) {
        Long assessmentID = session.getKey();
        String idPath = idDir + translator.translate("table.user.attempt") + (sessions.indexOf(session) + 1) + SEP;
        createZipDirectory(zout, idPath);
        // content of result table
        ResultDetail resultDetail = new ResultDetail(assessmentID.toString(), assessmentDateFormat.format(session.getCreationDate()), displayDateFormat.format(new Date(session.getDuration())), session.getScore(), session.getManualScore(), createPassedIcons(session.getPassed() == null ? true : session.getPassed()), idPath.replace(idDir, "") + assessmentID + ".html");
        assessments.add(resultDetail);
        // WindowControlMocker needed because this is not a controller
        WindowControl mockwControl = new WindowControlMocker();
        FileResourceManager frm = FileResourceManager.getInstance();
        RepositoryEntry testEntry = session.getTestEntry();
        testEntries.add(testEntry);
        File fUnzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
        // add test repo key
        String mapperUri = "../../../test" + testEntry.getKey() + "/";
        String submissionMapperUri = ".";
        String exportUri = "../" + translator.translate("table.user.attempt") + (sessions.indexOf(session) + 1);
        Controller assessmentResultController = new AssessmentResultController(ureq, mockwControl, identity, false, session, fUnzippedDirRoot, mapperUri, submissionMapperUri, QTI21AssessmentResultsOptions.allOptions(), false, true, false, exportUri);
        Component component = assessmentResultController.getInitialComponent();
        String componentHTML = createResultHTML(component);
        convertToZipEntry(zout, idPath + assessmentID + ".html", componentHTML);
        File resultXML = qtiService.getAssessmentResultFile(session);
        convertToZipEntry(zout, idPath + assessmentID + ".xml", resultXML);
        File signatureXML = qtiService.getAssessmentResultSignature(session);
        if (signatureXML != null) {
            convertToZipEntry(zout, idPath + "assessmentResultSignature.xml", signatureXML);
        }
        File submissionDir = qtiService.getSubmissionDirectory(session);
        String baseDir = idPath + "submissions";
        ZipUtil.addDirectoryToZip(submissionDir.toPath(), baseDir, zout);
    }
    return assessments;
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) AssessmentResultController(org.olat.ims.qti21.ui.AssessmentResultController) Controller(org.olat.core.gui.control.Controller) Date(java.util.Date) FileResourceManager(org.olat.fileresource.FileResourceManager) AssessmentResultController(org.olat.ims.qti21.ui.AssessmentResultController) Component(org.olat.core.gui.components.Component) File(java.io.File) WindowControlMocker(org.olat.core.gui.util.WindowControlMocker)

Example 69 with Controller

use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.

the class EPArtefactViewController method initForm.

/**
 * @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
 */
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (detailsLinkEnabled && !artefactChooseMode) {
        detailsLink = uifactory.addFormLink("details.link", formLayout, Link.BUTTON);
        detailsLink.setElementCssClass("o_sel_artefact_details");
    }
    title = uifactory.addInlineTextElement("title", artefact.getTitle(), formLayout, this);
    flc.contextPut("cssClosed", artefactInClosedMap ? "o_artefact_closed" : "");
    flc.contextPut("viewOnly", viewOnlyMode);
    if (viewOnlyMode || artefactInClosedMap)
        title.setEnabled(false);
    // get tags and prepare textboxlist-component
    List<String> tagL = ePFMgr.getArtefactTags(artefact);
    Map<String, String> tagLM = new HashMap<String, String>();
    for (String tag : tagL) {
        tagLM.put(tag, tag);
    }
    tblE = uifactory.addTextBoxListElement("tagTextbox", null, "tag.textboxlist.hint", tagLM, formLayout, getTranslator());
    if (viewOnlyMode || artefactInClosedMap) {
        tblE.setEnabled(false);
    } else {
        Map<String, String> allUsersTags = ePFMgr.getUsersMostUsedTags(getIdentity(), -1);
        tblE.setAutoCompleteContent(allUsersTags);
    }
    // get maps wherein this artefact is linked and create links to them
    List<PortfolioStructure> linkedMaps = ePFMgr.getReferencedMapsForArtefact(artefact);
    if (linkedMaps != null && linkedMaps.size() != 0) {
        List<FormLink> selectMapNames = new ArrayList<FormLink>(linkedMaps.size());
        int count = 0;
        for (PortfolioStructure ePMap : linkedMaps) {
            String mapTitle = StringHelper.escapeHtml(ePMap.getTitle());
            FormLink selectMap = uifactory.addFormLink("map-" + count++, "map", mapTitle, null, formLayout, Link.NONTRANSLATED);
            selectMap.setUserObject(ePMap.getOlatResource());
            selectMap.setEnabled(!viewOnlyMode && !artefactChooseMode);
            selectMapNames.add(selectMap);
        }
        flc.contextPut("maps", selectMapNames);
    }
    // build link to original source
    if (StringHelper.containsNonWhitespace(artefact.getBusinessPath())) {
        String sourceLink = createLinkToArtefactSource(ureq, artefact.getBusinessPath());
        flc.contextPut("artefactSourceLink", sourceLink);
    }
    // create a delete button
    deleteBtn = uifactory.addFormLink("delete.artefact", formLayout, Link.BUTTON);
    deleteBtn.setIconLeftCSS("o_icon o_icon_delete");
    deleteBtn.addActionListener(FormEvent.ONCLICK);
    if (viewOnlyMode || artefactChooseMode || artefactInClosedMap)
        deleteBtn.setVisible(false);
    // let the artefact-handler paint what is special for this kind of artefact
    EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
    Controller detCtrl = artHandler.createDetailsController(ureq, getWindowControl(), artefact, viewOnlyMode || artefactInClosedMap);
    if (detCtrl != null) {
        flc.put("detailsController", detCtrl.getInitialComponent());
    }
    // create edit buttons the adapt meta-data
    if (!(viewOnlyMode || artefactChooseMode || artefactInClosedMap)) {
        String reflexion = artefact.getReflexion();
        reflexion = FilterFactory.getHtmlTagAndDescapingFilter().filter(reflexion);
        reflexion = StringHelper.xssScan(reflexion);
        reflexion = Formatter.truncate(reflexion, 50);
        if (!StringHelper.containsNonWhitespace(reflexion)) {
            // show a link even if empty
            reflexion = "&nbsp; ";
        }
        reflexionBtn = uifactory.addFormLink("reflexionBtn", reflexion, null, formLayout, Link.NONTRANSLATED);
        reflexionBtn.setIconLeftCSS("o_icon o_icon_inline_editable");
        String description = artefact.getDescription();
        description = FilterFactory.getHtmlTagAndDescapingFilter().filter(description);
        description = Formatter.truncate(description, 50);
        description = StringHelper.xssScan(description);
        if (!StringHelper.containsNonWhitespace(description)) {
            // show a link even if empty
            description = "&nbsp; ";
        }
        descriptionBtn = uifactory.addFormLink("descriptionBtn", description, null, formLayout, Link.NONTRANSLATED);
        descriptionBtn.setIconLeftCSS("o_icon o_icon_inline_editable");
    }
    // if in artefactChooseMode, add an "choose this" button
    if (artefactChooseMode) {
        chooseBtn = uifactory.addFormLink("choose.artefact", formLayout, Link.BUTTON);
        chooseBtn.addActionListener(FormEvent.ONCLICK);
    }
    flc.contextPut("artefact", artefact);
    setArtAttribConfig(artAttribConfig);
}
Also used : HashMap(java.util.HashMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController) Controller(org.olat.core.gui.control.Controller) CloseableCalloutWindowController(org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController)

Example 70 with Controller

use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.

the class EPMultipleArtefactSmallReadOnlyPreviewController method init.

private void init(UserRequest ureq) {
    if (artefactCtrls != null)
        disposeArtefactControllers();
    if (optionLinkCtrls != null)
        disposeOptionLinkControllers();
    optionLinkCtrls = new ArrayList<Controller>();
    artefactCtrls = new ArrayList<Controller>();
    List<List<Panel>> artefactCtrlCompLines = new ArrayList<List<Panel>>();
    List<Panel> artefactCtrlCompLine = new ArrayList<Panel>();
    int i = 1;
    for (AbstractArtefact artefact : artefacts) {
        EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
        Controller artCtrl;
        // check for special art-display:
        boolean special = artHandler.isProvidingSpecialMapViewController();
        if (special) {
            artCtrl = artHandler.getSpecialMapViewController(ureq, getWindowControl(), artefact);
            if (artCtrl != null) {
                // add the optionsLink to the artefact
                EPArtefactViewOptionsLinkController optionsLinkCtrl = new EPArtefactViewOptionsLinkController(ureq, getWindowControl(), artefact, secCallback, struct);
                vC.put("optionsLink" + i, optionsLinkCtrl.getInitialComponent());
                listenTo(optionsLinkCtrl);
                optionLinkCtrls.add(optionsLinkCtrl);
            }
        } else {
            artCtrl = new EPArtefactViewReadOnlyController(ureq, getWindowControl(), artefact, struct, secCallback, true);
        }
        if (artCtrl != null) {
            artefactCtrls.add(artCtrl);
            Component artefactCtrlComponent = artCtrl.getInitialComponent();
            listenTo(artCtrl);
            Panel namedPanel = new Panel("artCtrl" + i);
            namedPanel.setContent(artefactCtrlComponent);
            if (special) {
                if (!artefactCtrlCompLine.isEmpty()) {
                    artefactCtrlCompLines.add(artefactCtrlCompLine);
                }
                artefactCtrlCompLines.add(Collections.singletonList(namedPanel));
                artefactCtrlCompLine = new ArrayList<Panel>();
            } else {
                if (artefactCtrlCompLine.size() == 3) {
                    if (!artefactCtrlCompLine.isEmpty()) {
                        artefactCtrlCompLines.add(artefactCtrlCompLine);
                    }
                    artefactCtrlCompLine = new ArrayList<Panel>();
                }
                artefactCtrlCompLine.add(namedPanel);
            }
            vC.put("artCtrl" + i, namedPanel);
            if (special) {
                // need a flag in a lopp for the velociy template
                vC.put("specialartCtrl" + i, artefactCtrlComponent);
            }
            i++;
        }
    }
    if (!artefactCtrlCompLine.isEmpty()) {
        artefactCtrlCompLines.add(artefactCtrlCompLine);
    }
    vC.contextPut("artefactCtrlCompLines", artefactCtrlCompLines);
}
Also used : ArrayList(java.util.ArrayList) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController) Panel(org.olat.core.gui.components.panel.Panel) ArrayList(java.util.ArrayList) List(java.util.List) Component(org.olat.core.gui.components.Component)

Aggregations

Controller (org.olat.core.gui.control.Controller)372 BasicController (org.olat.core.gui.control.controller.BasicController)114 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)82 NodeEditController (org.olat.course.editor.NodeEditController)82 WindowControl (org.olat.core.gui.control.WindowControl)78 TabbableController (org.olat.core.gui.control.generic.tabbable.TabbableController)74 NodeRunConstructionResult (org.olat.course.run.navigation.NodeRunConstructionResult)62 RepositoryEntry (org.olat.repository.RepositoryEntry)60 Translator (org.olat.core.gui.translator.Translator)54 UserRequest (org.olat.core.gui.UserRequest)52 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)50 OLATResourceable (org.olat.core.id.OLATResourceable)46 ArrayList (java.util.ArrayList)40 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)40 MainLayoutBasicController (org.olat.core.gui.control.controller.MainLayoutBasicController)36 Component (org.olat.core.gui.components.Component)34 Roles (org.olat.core.id.Roles)34 Activateable2 (org.olat.core.gui.control.generic.dtabs.Activateable2)32 FormBasicController (org.olat.core.gui.components.form.flexible.impl.FormBasicController)30 ContextEntry (org.olat.core.id.context.ContextEntry)30