Search in sources :

Example 36 with StatusDescription

use of org.olat.course.editor.StatusDescription in project openolat by klemens.

the class LLCourseNode method isConfigValid.

/**
 * {@inheritDoc}
 */
public StatusDescription isConfigValid() {
    if (oneClickStatusCache != null) {
        return oneClickStatusCache[0];
    }
    StatusDescription sd = StatusDescription.NOERROR;
    if (!LLEditController.isConfigValid(getModuleConfiguration())) {
        String transPackage = Util.getPackageName(LLEditController.class);
        sd = new StatusDescription(StatusDescription.WARNING, "config.nolinks.short", "config.nolinks.long", null, transPackage);
        sd.setDescriptionForUnit(getIdent());
        sd.setActivateableViewIdentifier(LLEditController.PANE_TAB_LLCONFIG);
    }
    return sd;
}
Also used : StatusDescription(org.olat.course.editor.StatusDescription)

Example 37 with StatusDescription

use of org.olat.course.editor.StatusDescription in project openolat by klemens.

the class VCCourseNode method isConfigValid.

public StatusDescription isConfigValid() {
    if (oneClickStatusCache != null) {
        return oneClickStatusCache[0];
    }
    StatusDescription status = StatusDescription.NOERROR;
    // load configuration
    final String providerId = getModuleConfiguration().getStringValue(CONF_PROVIDER_ID);
    VCProvider provider = providerId == null ? VCProviderFactory.createDefaultProvider() : VCProviderFactory.createProvider(providerId);
    boolean invalid = provider == null || !handleConfig(provider).isConfigValid();
    if (invalid) {
        String[] params = new String[] { this.getShortTitle() };
        String shortKey = "error.config.short";
        String longKey = "error.config.long";
        String translationPackage = VCEditController.class.getPackage().getName();
        status = new StatusDescription(ValidationStatus.ERROR, shortKey, longKey, params, translationPackage);
        status.setDescriptionForUnit(getIdent());
        status.setActivateableViewIdentifier(VCEditController.PANE_TAB_VCCONFIG);
    }
    return status;
}
Also used : VCEditController(de.bps.course.nodes.vc.VCEditController) StatusDescription(org.olat.course.editor.StatusDescription) VCProvider(de.bps.course.nodes.vc.provider.VCProvider)

Example 38 with StatusDescription

use of org.olat.course.editor.StatusDescription in project OpenOLAT by OpenOLAT.

the class ChecklistCourseNode method isConfigValid.

public StatusDescription isConfigValid() {
    if (oneClickStatusCache != null) {
        return oneClickStatusCache[0];
    }
    StatusDescription sd = StatusDescription.NOERROR;
    String transPackage = ChecklistEditController.class.getPackage().getName();
    // no configuration available hence there is no checklist with checkpoints
    if (getModuleConfiguration().get(ChecklistCourseNode.CONF_CHECKLIST) == null) {
        sd = new StatusDescription(ValidationStatus.ERROR, "config.nocheckpoints.short", "config.nocheckpoints.long", null, transPackage);
        sd.setDescriptionForUnit(getIdent());
        sd.setActivateableViewIdentifier(ChecklistEditController.PANE_TAB_CLCONFIG);
        return sd;
    }
    Checklist checklist = (Checklist) getModuleConfiguration().get(ChecklistCourseNode.CONF_CHECKLIST);
    // checklist without any checkpoints makes no sense
    if (!checklist.hasCheckpoints()) {
        sd = new StatusDescription(ValidationStatus.ERROR, "config.nocheckpoints.short", "config.nocheckpoints.long", null, transPackage);
        sd.setDescriptionForUnit(getIdent());
        sd.setActivateableViewIdentifier(ChecklistEditController.PANE_TAB_CLCONFIG);
        return sd;
    }
    // information, if all checkpoints are invisible
    boolean allUnvisible = true;
    boolean noLearners = false;
    if (checklist.hasCheckpoints()) {
        List<Checkpoint> checkpoints = ((Checklist) getModuleConfiguration().get(ChecklistCourseNode.CONF_CHECKLIST)).getCheckpoints();
        for (Checkpoint checkpoint : checkpoints) {
            if (!checkpoint.getMode().equals(CheckpointMode.MODE_HIDDEN))
                allUnvisible = false;
        }
        if (allUnvisible) {
            Condition cond = getPreConditionVisibility();
            if (cond.isEasyModeCoachesAndAdmins())
                noLearners = true;
            if (!noLearners) {
                sd = new StatusDescription(ValidationStatus.WARNING, "config.allhidden.short", "config.allhidden.long", null, transPackage);
                sd.setDescriptionForUnit(getIdent());
                sd.setActivateableViewIdentifier(ChecklistEditController.PANE_TAB_CLCONFIG);
            }
        }
    }
    return sd;
}
Also used : Condition(org.olat.course.condition.Condition) Checkpoint(de.bps.olat.modules.cl.Checkpoint) StatusDescription(org.olat.course.editor.StatusDescription) Checklist(de.bps.olat.modules.cl.Checklist) ChecklistEditController(de.bps.course.nodes.cl.ChecklistEditController)

Example 39 with StatusDescription

use of org.olat.course.editor.StatusDescription in project OpenOLAT by OpenOLAT.

the class CourseCreationHelper method finalizeWorkflow.

/**
 * Finalizes the course creation workflow via wizard.
 * @param ureq
 */
public void finalizeWorkflow(final UserRequest ureq) {
    // --------------------------
    // 1. insert the course nodes
    // --------------------------
    // single page node
    CourseNode singlePageNode = null;
    if (courseConfig.isCreateSinglePage()) {
        singlePageNode = CourseExtensionHelper.createSinglePageNode(course, translator.translate("cce.informationpage"), translator.translate("cce.informationpage.descr"));
        if (singlePageNode instanceof SPCourseNode) {
            final String relPath = CourseEditorHelper.createUniqueRelFilePathFromShortTitle(singlePageNode, course.getCourseFolderContainer());
            HTMLDocumentHelper.createHtmlDocument(course, relPath, courseConfig.getSinglePageText(translator));
            ((SPCourseNode) singlePageNode).getModuleConfiguration().set(SPEditController.CONFIG_KEY_FILE, relPath);
        }
    }
    // enrollment node
    CourseNode enCourseNode = null;
    if (courseConfig.isCreateEnrollment()) {
        enCourseNode = CourseExtensionHelper.createEnrollmentNode(course, translator.translate("cce.enrollment"), translator.translate("cce.enrollment.descr"));
    }
    // download folder node
    CourseNode downloadFolderNode = null;
    if (courseConfig.isCreateDownloadFolder()) {
        downloadFolderNode = CourseExtensionHelper.createDownloadFolderNode(course, translator.translate("cce.downloadfolder"), translator.translate("cce.downloadfolder.descr"));
    }
    // forum node
    CourseNode forumNode = null;
    if (courseConfig.isCreateForum()) {
        forumNode = CourseExtensionHelper.createForumNode(course, translator.translate("cce.forum"), translator.translate("cce.forum.descr"));
    }
    // contact form node
    CourseNode contactNode = null;
    if (courseConfig.isCreateContactForm()) {
        contactNode = CourseExtensionHelper.createContactFormNode(course, translator.translate("cce.contactform"), translator.translate("cce.contactform.descr"));
        if (contactNode instanceof COCourseNode) {
            final List<String> emails = new ArrayList<String>();
            String subject = translator.translate("cce.contactform.subject") + " " + courseConfig.getCourseTitle();
            String email = ureq.getIdentity().getUser().getProperty(UserConstants.EMAIL, ureq.getLocale());
            if (StringHelper.containsNonWhitespace(email)) {
                emails.add(email);
            }
            COCourseNode cocn = (COCourseNode) contactNode;
            cocn.getModuleConfiguration().set(COEditController.CONFIG_KEY_EMAILTOADRESSES, emails);
            cocn.getModuleConfiguration().set(COEditController.CONFIG_KEY_MSUBJECT_DEFAULT, subject);
        }
    }
    // enrollment node
    if (courseConfig.isCreateEnrollment()) {
        // --------------------------
        // 2. setup enrollment
        // --------------------------
        final String groupBaseName = createGroupBaseName();
        final BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
        // get default context for learning groups
        // create n learning groups with m allowed members
        String comma = "";
        String tmpGroupList = "";
        String groupNamesList = "";
        for (int i = 0; i < courseConfig.getGroupCount(); i++) {
            // create group
            String name = groupBaseName + " " + (i + 1);
            BusinessGroup learningGroup = bgs.createBusinessGroup(ureq.getIdentity(), name, null, 0, courseConfig.getSubscriberCount(), courseConfig.getEnableWaitlist(), courseConfig.getEnableFollowup(), addedEntry);
            // enable the contact collaboration tool
            CollaborationTools ct = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(learningGroup);
            ct.setToolEnabled(CollaborationTools.TOOL_CONTACT, true);
            // append to current learning group list
            groupNamesList = tmpGroupList + comma + learningGroup.getName();
            enCourseNode.getModuleConfiguration().set(ENCourseNode.CONFIG_GROUPNAME, groupNamesList);
            if (i == 0) {
                comma = ",";
            }
            tmpGroupList = (String) enCourseNode.getModuleConfiguration().get(ENCourseNode.CONFIG_GROUPNAME);
        }
        // set signout property
        enCourseNode.getModuleConfiguration().set(ENCourseNode.CONF_CANCEL_ENROLL_ENABLED, courseConfig.getEnableSignout());
        // access limits on chosen course elements
        if (courseConfig.getEnableAccessLimit()) {
            if (courseConfig.isEnableAclContactForm()) {
                if (contactNode instanceof COCourseNode) {
                    Condition c = ((COCourseNode) contactNode).getPreConditionVisibility();
                    c.setEasyModeGroupAccess(groupNamesList);
                    ((COCourseNode) contactNode).setNoAccessExplanation(translator.translate("noaccessexplain"));
                    // calculate expression from easy mode form
                    String condString = c.getConditionFromEasyModeConfiguration();
                    c.setConditionExpression(condString);
                    c.setExpertMode(false);
                }
            }
            if (courseConfig.isEnableAclSinglePage()) {
                if (singlePageNode instanceof SPCourseNode) {
                    Condition c = ((SPCourseNode) singlePageNode).getPreConditionVisibility();
                    c.setEasyModeGroupAccess(groupNamesList);
                    ((SPCourseNode) singlePageNode).setNoAccessExplanation(translator.translate("noaccessexplain"));
                    // calculate expression from easy mode form
                    String condString = c.getConditionFromEasyModeConfiguration();
                    c.setConditionExpression(condString);
                    c.setExpertMode(false);
                }
            }
            if (courseConfig.isEnableAclForum()) {
                if (forumNode instanceof FOCourseNode) {
                    Condition c = ((FOCourseNode) forumNode).getPreConditionVisibility();
                    c.setEasyModeGroupAccess(groupNamesList);
                    ((FOCourseNode) forumNode).setNoAccessExplanation(translator.translate("noaccessexplain"));
                    // calculate expression from easy mode form
                    String condString = c.getConditionFromEasyModeConfiguration();
                    c.setConditionExpression(condString);
                    c.setExpertMode(false);
                }
            }
            if (courseConfig.isEnableAclDownloadFolder()) {
                if (downloadFolderNode instanceof BCCourseNode) {
                    Condition c = ((BCCourseNode) downloadFolderNode).getPreConditionVisibility();
                    c.setEasyModeGroupAccess(groupNamesList);
                    ((BCCourseNode) downloadFolderNode).setNoAccessExplanation(translator.translate("noaccessexplain"));
                    // calculate expression from easy mode form
                    String condString = c.getConditionFromEasyModeConfiguration();
                    c.setConditionExpression(condString);
                    c.setExpertMode(false);
                }
            }
        }
    }
    // --------------------------
    if (courseConfig.getPublish()) {
        CourseAccessAndProperties accessAndProps = courseConfig.getAccessAndProperties();
        RepositoryManager manager = RepositoryManager.getInstance();
        addedEntry = manager.setAccessAndProperties(accessAndProps.getRepositoryEntry(), accessAndProps.getAccess(), accessAndProps.isMembersOnly(), accessAndProps.isCanCopy(), accessAndProps.isCanReference(), accessAndProps.isCanDownload());
        addedEntry = manager.setLeaveSetting(addedEntry, accessAndProps.getSetting());
        List<OfferAccess> offerAccess = accessAndProps.getOfferAccess();
        ACService acService = CoreSpringFactory.getImpl(ACService.class);
        for (OfferAccess newLink : offerAccess) {
            acService.saveOfferAccess(newLink);
        }
    }
    course = CourseFactory.openCourseEditSession(course.getResourceableId());
    course.getRunStructure().getRootNode().setShortTitle(addedEntry.getDisplayname());
    course.getRunStructure().getRootNode().setLongTitle(addedEntry.getDisplayname());
    CourseFactory.saveCourse(course.getResourceableId());
    final CourseEditorTreeModel cetm = course.getEditorTreeModel();
    final CourseNode rootNode = cetm.getCourseNode(course.getRunStructure().getRootNode().getIdent());
    rootNode.setShortTitle(addedEntry.getDisplayname());
    rootNode.setLongTitle(addedEntry.getDisplayname());
    course.getEditorTreeModel().nodeConfigChanged(course.getRunStructure().getRootNode());
    CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
    // --------------------------
    // 3.2 publish the course
    // --------------------------
    // fetch publish process
    final PublishProcess pp = PublishProcess.getInstance(course, cetm, ureq.getLocale());
    final StatusDescription[] sds;
    // create publish node list
    List<String> nodeIds = new ArrayList<String>();
    nodeIds.add(cetm.getRootNode().getIdent());
    for (int i = 0; i < cetm.getRootNode().getChildCount(); i++) {
        nodeIds.add(cetm.getRootNode().getChildAt(i).getIdent());
    }
    pp.createPublishSetFor(nodeIds);
    PublishSetInformations set = pp.testPublishSet(ureq.getLocale());
    sds = set.getWarnings();
    boolean isValid = sds.length == 0;
    if (!isValid) {
        // no error and no warnings -> return immediate
        log.error("Course Publishing failed", new AssertionError());
    }
    pp.applyPublishSet(ureq.getIdentity(), ureq.getLocale(), true);
    CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
    // save catalog entry
    if (getConfiguration().getSelectedCatalogEntry() != null) {
        CatalogManager cm = CoreSpringFactory.getImpl(CatalogManager.class);
        CatalogEntry newEntry = cm.createCatalogEntry();
        newEntry.setRepositoryEntry(addedEntry);
        newEntry.setName(addedEntry.getDisplayname());
        newEntry.setDescription(addedEntry.getDescription());
        newEntry.setType(CatalogEntry.TYPE_LEAF);
        newEntry.setOwnerGroup(BaseSecurityManager.getInstance().createAndPersistSecurityGroup());
        // save entry
        cm.addCatalogEntry(getConfiguration().getSelectedCatalogEntry(), newEntry);
    }
}
Also used : OfferAccess(org.olat.resource.accesscontrol.OfferAccess) ArrayList(java.util.ArrayList) CatalogEntry(org.olat.repository.CatalogEntry) FOCourseNode(org.olat.course.nodes.FOCourseNode) PublishProcess(org.olat.course.editor.PublishProcess) StatusDescription(org.olat.course.editor.StatusDescription) RepositoryManager(org.olat.repository.RepositoryManager) FOCourseNode(org.olat.course.nodes.FOCourseNode) ENCourseNode(org.olat.course.nodes.ENCourseNode) CourseNode(org.olat.course.nodes.CourseNode) COCourseNode(org.olat.course.nodes.COCourseNode) BCCourseNode(org.olat.course.nodes.BCCourseNode) SPCourseNode(org.olat.course.nodes.SPCourseNode) COCourseNode(org.olat.course.nodes.COCourseNode) Condition(org.olat.course.condition.Condition) CourseEditorTreeModel(org.olat.course.tree.CourseEditorTreeModel) BusinessGroup(org.olat.group.BusinessGroup) SPCourseNode(org.olat.course.nodes.SPCourseNode) CourseAccessAndProperties(org.olat.course.editor.CourseAccessAndProperties) PublishSetInformations(org.olat.course.editor.PublishSetInformations) CatalogManager(org.olat.repository.manager.CatalogManager) BCCourseNode(org.olat.course.nodes.BCCourseNode) BusinessGroupService(org.olat.group.BusinessGroupService) CollaborationTools(org.olat.collaboration.CollaborationTools) ACService(org.olat.resource.accesscontrol.ACService)

Example 40 with StatusDescription

use of org.olat.course.editor.StatusDescription in project OpenOLAT by OpenOLAT.

the class ENCourseNode method isConfigValid.

/**
 * @see org.olat.course.nodes.CourseNode#isConfigValid(org.olat.course.run.userview.UserCourseEnvironment)
 */
public StatusDescription[] isConfigValid(CourseEditorEnv cev) {
    // this must be nulled before isConfigValid() is called!!
    oneClickStatusCache = null;
    // only here we know which translator to take for translating condition
    // error messages
    List<StatusDescription> condErrs = isConfigValidWithTranslator(cev, PACKAGE_COND, getConditionExpressions());
    List<StatusDescription> missingNames = new ArrayList<StatusDescription>();
    /*
		 * check group and area names for existence
		 */
    ModuleConfiguration mc = getModuleConfiguration();
    String areaNames = (String) mc.get(CONFIG_AREANAME);
    List<Long> areaKeys = mc.getList(ENCourseNode.CONFIG_AREA_IDS, Long.class);
    List<String> missingAreas = getMissingAreas(areaKeys, areaNames, cev);
    if (missingAreas.size() > 0) {
        missingNames.add(addStatusErrorMissing(missingAreas));
    }
    String groupNames = (String) mc.get(CONFIG_GROUPNAME);
    List<Long> groupKeys = mc.getList(ENCourseNode.CONFIG_GROUP_IDS, Long.class);
    List<String> missingGroups = getMissingBusinessGroups(groupKeys, groupNames, cev);
    if (missingGroups.size() > 0) {
        missingNames.add(addStatusErrorMissing(missingGroups));
    }
    missingNames.addAll(condErrs);
    /*
		 * sort -> Errors > Warnings > Infos and remove NOERRORS, if
		 * Error/Warning/Info around.
		 */
    oneClickStatusCache = StatusDescriptionHelper.sort(missingNames);
    return oneClickStatusCache;
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) StatusDescription(org.olat.course.editor.StatusDescription) ArrayList(java.util.ArrayList)

Aggregations

StatusDescription (org.olat.course.editor.StatusDescription)82 ArrayList (java.util.ArrayList)20 ModuleConfiguration (org.olat.modules.ModuleConfiguration)10 List (java.util.List)4 Condition (org.olat.course.condition.Condition)4 PublishProcess (org.olat.course.editor.PublishProcess)4 PublishSetInformations (org.olat.course.editor.PublishSetInformations)4 CourseNode (org.olat.course.nodes.CourseNode)4 CourseEditorTreeModel (org.olat.course.tree.CourseEditorTreeModel)4 BusinessGroupService (org.olat.group.BusinessGroupService)4 ChecklistEditController (de.bps.course.nodes.cl.ChecklistEditController)2 VCEditController (de.bps.course.nodes.vc.VCEditController)2 VCProvider (de.bps.course.nodes.vc.provider.VCProvider)2 Checklist (de.bps.olat.modules.cl.Checklist)2 Checkpoint (de.bps.olat.modules.cl.Checkpoint)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 IdentityRef (org.olat.basesecurity.IdentityRef)2 CollaborationTools (org.olat.collaboration.CollaborationTools)2