Search in sources :

Example 6 with PortfolioService

use of org.olat.modules.portfolio.PortfolioService in project OpenOLAT by OpenOLAT.

the class CmdAddToEPortfolioImpl method execute.

/**
 * might return NULL!, if item clicked was removed meanwhile or if portfolio is disabled or if only the folder-artefact-handler is disabled.
 *
 * @see org.olat.core.commons.modules.bc.commands.FolderCommand#execute(org.olat.core.commons.modules.bc.components.FolderComponent,
 *      org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.WindowControl,
 *      org.olat.core.gui.translator.Translator)
 */
@Override
public Controller execute(FolderComponent folderComponent, UserRequest ureq, WindowControl wControl, Translator translator) {
    String pos = ureq.getParameter(ListRenderer.PARAM_EPORT);
    if (!StringHelper.containsNonWhitespace(pos)) {
        // somehow parameter did not make it to us
        status = FolderCommandStatus.STATUS_FAILED;
        getWindowControl().setError(translator.translate("failed"));
        return null;
    }
    status = FolderCommandHelper.sanityCheck(wControl, folderComponent);
    if (status == FolderCommandStatus.STATUS_SUCCESS) {
        currentItem = folderComponent.getCurrentContainerChildren().get(Integer.parseInt(pos));
        status = FolderCommandHelper.sanityCheck2(wControl, folderComponent, currentItem);
    }
    if (status == FolderCommandStatus.STATUS_FAILED) {
        return null;
    }
    if (portfolioV2Module.isEnabled()) {
        PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
        MediaHandler handler = null;
        String extension = FileUtils.getFileSuffix(currentItem.getName());
        if (StringHelper.containsNonWhitespace(extension)) {
            if ("jpg".equalsIgnoreCase(extension) || "jpeg".equalsIgnoreCase(extension) || "png".equalsIgnoreCase(extension) || "gif".equalsIgnoreCase(extension)) {
                handler = portfolioService.getMediaHandler(ImageHandler.IMAGE_TYPE);
            }
        // TODO video
        }
        if (handler == null) {
            handler = portfolioService.getMediaHandler(FileHandler.FILE_TYPE);
        }
        collectStepsCtrl = new CollectArtefactController(ureq, wControl, currentItem, handler, "");
    } else {
        EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(FileArtefact.FILE_ARTEFACT_TYPE);
        AbstractArtefact artefact = artHandler.createArtefact();
        artHandler.prefillArtefactAccordingToSource(artefact, currentItem);
        artefact.setAuthor(getIdentity());
        collectStepsCtrl = new ArtefactWizzardStepsController(ureq, wControl, artefact, currentItem.getParentContainer());
    }
    return collectStepsCtrl;
}
Also used : PortfolioService(org.olat.modules.portfolio.PortfolioService) MediaHandler(org.olat.modules.portfolio.MediaHandler) CollectArtefactController(org.olat.modules.portfolio.ui.wizard.CollectArtefactController) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact)

Example 7 with PortfolioService

use of org.olat.modules.portfolio.PortfolioService in project OpenOLAT by OpenOLAT.

the class EvaluationFormHandler method getContent.

@Override
public PageRunElement getContent(UserRequest ureq, WindowControl wControl, PageElement element, PageElementRenderingHints hints) {
    Controller ctrl = null;
    if (element instanceof EvaluationFormPart) {
        PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
        // find assignment
        EvaluationFormPart eva = (EvaluationFormPart) element;
        PageBody body = eva.getBody();
        Assignment assignment = portfolioService.getAssignment(body);
        if (assignment == null) {
            ctrl = getController(ureq, wControl, body, eva);
        } else {
            ctrl = getControllerForAssignment(ureq, wControl, body, assignment, hints.isOnePage());
        }
    }
    if (ctrl == null) {
        Translator translator = Util.createPackageTranslator(PortfolioHomeController.class, ureq.getLocale());
        String title = translator.translate("warning.evaluation.not.visible.title");
        String text = translator.translate("warning.evaluation.not.visible.text");
        ctrl = MessageUIFactory.createWarnMessage(ureq, wControl, title, text);
    }
    return new PageRunControllerElement(ctrl);
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) PageRunControllerElement(org.olat.modules.portfolio.ui.editor.PageRunControllerElement) EvaluationFormPart(org.olat.modules.portfolio.model.EvaluationFormPart) PortfolioService(org.olat.modules.portfolio.PortfolioService) Translator(org.olat.core.gui.translator.Translator) MultiEvaluationFormController(org.olat.modules.portfolio.ui.MultiEvaluationFormController) Controller(org.olat.core.gui.control.Controller) EvaluationFormController(org.olat.modules.forms.ui.EvaluationFormController) PortfolioHomeController(org.olat.modules.portfolio.ui.PortfolioHomeController) PageBody(org.olat.modules.portfolio.PageBody)

Example 8 with PortfolioService

use of org.olat.modules.portfolio.PortfolioService in project openolat by klemens.

the class BinderTemplateHandler method cleanupOnDelete.

@Override
public boolean cleanupOnDelete(RepositoryEntry entry, OLATResourceable res) {
    PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
    Binder template = portfolioService.getBinderByResource(entry.getOlatResource());
    return portfolioService.deleteBinderTemplate(template, entry);
}
Also used : Binder(org.olat.modules.portfolio.Binder) PortfolioService(org.olat.modules.portfolio.PortfolioService)

Example 9 with PortfolioService

use of org.olat.modules.portfolio.PortfolioService in project openolat by klemens.

the class EvaluationFormHandler method getContent.

@Override
public PageRunElement getContent(UserRequest ureq, WindowControl wControl, PageElement element, PageElementRenderingHints hints) {
    Controller ctrl = null;
    if (element instanceof EvaluationFormPart) {
        PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
        // find assignment
        EvaluationFormPart eva = (EvaluationFormPart) element;
        PageBody body = eva.getBody();
        Assignment assignment = portfolioService.getAssignment(body);
        if (assignment == null) {
            ctrl = getController(ureq, wControl, body, eva);
        } else {
            ctrl = getControllerForAssignment(ureq, wControl, body, assignment, hints.isOnePage());
        }
    }
    if (ctrl == null) {
        Translator translator = Util.createPackageTranslator(PortfolioHomeController.class, ureq.getLocale());
        String title = translator.translate("warning.evaluation.not.visible.title");
        String text = translator.translate("warning.evaluation.not.visible.text");
        ctrl = MessageUIFactory.createWarnMessage(ureq, wControl, title, text);
    }
    return new PageRunControllerElement(ctrl);
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) PageRunControllerElement(org.olat.modules.portfolio.ui.editor.PageRunControllerElement) EvaluationFormPart(org.olat.modules.portfolio.model.EvaluationFormPart) PortfolioService(org.olat.modules.portfolio.PortfolioService) Translator(org.olat.core.gui.translator.Translator) MultiEvaluationFormController(org.olat.modules.portfolio.ui.MultiEvaluationFormController) Controller(org.olat.core.gui.control.Controller) EvaluationFormController(org.olat.modules.forms.ui.EvaluationFormController) PortfolioHomeController(org.olat.modules.portfolio.ui.PortfolioHomeController) PageBody(org.olat.modules.portfolio.PageBody)

Example 10 with PortfolioService

use of org.olat.modules.portfolio.PortfolioService in project openolat by klemens.

the class EvaluationFormHandler method getController.

private Controller getController(UserRequest ureq, WindowControl wControl, PageBody body, EvaluationFormPart eva) {
    PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
    Controller ctrl = null;
    Page page = portfolioService.getPageByBody(body);
    List<AccessRights> accessRights = portfolioService.getAccessRights(page);
    if (hasRole(PortfolioRoles.owner, ureq.getIdentity(), accessRights)) {
        ctrl = new EvaluationFormController(ureq, wControl, ureq.getIdentity(), body, eva.getContent(), false);
    } else if (hasRole(PortfolioRoles.coach, ureq.getIdentity(), accessRights)) {
        Identity owner = getOwner(accessRights);
        ctrl = new EvaluationFormController(ureq, wControl, owner, body, eva.getContent(), true);
    } else if (hasRole(PortfolioRoles.reviewer, ureq.getIdentity(), accessRights) || hasRole(PortfolioRoles.invitee, ureq.getIdentity(), accessRights)) {
        Identity owner = getOwner(accessRights);
        ctrl = new EvaluationFormController(ureq, wControl, owner, body, eva.getContent(), true);
    }
    return ctrl;
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) MultiEvaluationFormController(org.olat.modules.portfolio.ui.MultiEvaluationFormController) EvaluationFormController(org.olat.modules.forms.ui.EvaluationFormController) PortfolioService(org.olat.modules.portfolio.PortfolioService) Page(org.olat.modules.portfolio.Page) MultiEvaluationFormController(org.olat.modules.portfolio.ui.MultiEvaluationFormController) Controller(org.olat.core.gui.control.Controller) EvaluationFormController(org.olat.modules.forms.ui.EvaluationFormController) PortfolioHomeController(org.olat.modules.portfolio.ui.PortfolioHomeController) Identity(org.olat.core.id.Identity)

Aggregations

PortfolioService (org.olat.modules.portfolio.PortfolioService)24 Binder (org.olat.modules.portfolio.Binder)12 Controller (org.olat.core.gui.control.Controller)10 EvaluationFormController (org.olat.modules.forms.ui.EvaluationFormController)8 MultiEvaluationFormController (org.olat.modules.portfolio.ui.MultiEvaluationFormController)8 RepositoryEntry (org.olat.repository.RepositoryEntry)7 File (java.io.File)6 PortfolioHomeController (org.olat.modules.portfolio.ui.PortfolioHomeController)6 OLATResource (org.olat.resource.OLATResource)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 CalendarController (org.olat.commons.calendar.ui.CalendarController)4 WeeklyCalendarController (org.olat.commons.calendar.ui.WeeklyCalendarController)4 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)4 Translator (org.olat.core.gui.translator.Translator)4 Identity (org.olat.core.id.Identity)4 CourseLinkProviderController (org.olat.course.run.calendar.CourseLinkProviderController)4 InfoGroupRunController (org.olat.group.ui.run.InfoGroupRunController)4 ChatToolController (org.olat.instantMessaging.ui.ChatToolController)4 ContactFormController (org.olat.modules.co.ContactFormController)4