Search in sources :

Example 56 with StatusDescription

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

the class TACourseNode method isConfigValid.

/**
 * @see org.olat.course.nodes.CourseNode#isConfigValid()
 */
@Override
public StatusDescription isConfigValid() {
    /*
		 * first check the one click cache
		 */
    if (oneClickStatusCache != null) {
        return oneClickStatusCache[0];
    }
    boolean isValid = true;
    Boolean hasScoring = (Boolean) getModuleConfiguration().get(CONF_SCORING_ENABLED);
    if (hasScoring.booleanValue()) {
        if (!MSEditFormController.isConfigValid(getModuleConfiguration()))
            isValid = false;
    }
    StatusDescription sd = StatusDescription.NOERROR;
    if (!isValid) {
        // FIXME: refine statusdescriptions by moving the statusdescription
        String shortKey = NLS_ERROR_MISSINGSCORECONFIG_SHORT;
        String longKey = NLS_ERROR_MISSINGSCORECONFIG_SHORT;
        String[] params = new String[] { this.getShortTitle() };
        String translPackage = Util.getPackageName(MSEditFormController.class);
        sd = new StatusDescription(StatusDescription.ERROR, shortKey, longKey, params, translPackage);
        sd.setDescriptionForUnit(getIdent());
        // set which pane is affected by error
        sd.setActivateableViewIdentifier(TACourseNodeEditController.PANE_TAB_CONF_SCORING);
    }
    // Check if any group exist make sense only with dropbox, scoring or solution
    Boolean hasDropbox = (Boolean) getModuleConfiguration().get(CONF_DROPBOX_ENABLED);
    if (hasDropbox == null) {
        hasDropbox = new Boolean(false);
    }
    Boolean hasReturnbox = (Boolean) getModuleConfiguration().get(CONF_RETURNBOX_ENABLED);
    if (hasReturnbox == null) {
        hasReturnbox = hasDropbox;
    }
    Boolean hasSolution = (Boolean) getModuleConfiguration().get(CONF_SOLUTION_ENABLED);
    if (hasSolution == null) {
        hasSolution = new Boolean(false);
    }
    // remove the error handling for missing groups as you can use the course members
    return sd;
}
Also used : StatusDescription(org.olat.course.editor.StatusDescription)

Example 57 with StatusDescription

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

the class BasicLTICourseNode method isConfigValid.

/**
 * @see org.olat.course.nodes.CourseNode#isConfigValid()
 */
@Override
public StatusDescription isConfigValid() {
    /*
		 * first check the one click cache
		 */
    if (oneClickStatusCache != null) {
        return oneClickStatusCache[0];
    }
    String host = (String) getModuleConfiguration().get(LTIConfigForm.CONFIGKEY_HOST);
    boolean isValid = host != null;
    StatusDescription sd = StatusDescription.NOERROR;
    if (!isValid) {
        // FIXME: refine statusdescriptions
        String[] params = new String[] { this.getShortTitle() };
        sd = new StatusDescription(StatusDescription.ERROR, NLS_ERROR_HOSTMISSING_SHORT, NLS_ERROR_HOSTMISSING_LONG, params, translatorPackage);
        sd.setDescriptionForUnit(getIdent());
        // set which pane is affected by error
        sd.setActivateableViewIdentifier(LTIEditController.PANE_TAB_LTCONFIG);
    }
    return sd;
}
Also used : StatusDescription(org.olat.course.editor.StatusDescription)

Example 58 with StatusDescription

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

the class COCourseNode method isConfigValid.

/**
 * @see org.olat.course.nodes.CourseNode#isConfigValid(org.olat.course.run.userview.UserCourseEnvironment)
 */
public StatusDescription[] isConfigValid(CourseEditorEnv cev) {
    oneClickStatusCache = null;
    // only here we know which translator to take for translating condition
    // error messages
    String translatorStr = Util.getPackageName(ConditionEditController.class);
    List<StatusDescription> condErrs = isConfigValidWithTranslator(cev, translatorStr, getConditionExpressions());
    List<StatusDescription> missingNames = new ArrayList<StatusDescription>();
    /*
         * check group and area names for existence
         */
    String nodeId = getIdent();
    ModuleConfiguration mc = getModuleConfiguration();
    @SuppressWarnings("unchecked") List<Long> areaKeys = (List<Long>) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_AREA_IDS);
    if (areaKeys != null) {
        BGAreaManager areaManager = CoreSpringFactory.getImpl(BGAreaManager.class);
        List<BGArea> areas = areaManager.loadAreas(areaKeys);
        a_a: for (Long areaKey : areaKeys) {
            for (BGArea area : areas) {
                if (area.getKey().equals(areaKey)) {
                    continue a_a;
                }
            }
            StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", areaKey.toString() }, translatorStr);
            sd.setDescriptionForUnit(nodeId);
            missingNames.add(sd);
        }
    } else {
        String areaStr = (String) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_AREA);
        if (areaStr != null) {
            String[] areas = areaStr.split(",");
            for (int i = 0; i < areas.length; i++) {
                String trimmed = areas[i] != null ? areas[i].trim() : areas[i];
                if (!trimmed.equals("") && !cev.existsArea(trimmed)) {
                    StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", trimmed }, translatorStr);
                    sd.setDescriptionForUnit(nodeId);
                    missingNames.add(sd);
                }
            }
        }
    }
    @SuppressWarnings("unchecked") List<Long> groupKeys = (List<Long>) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_GROUP_ID);
    if (groupKeys != null) {
        BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
        List<BusinessGroupShort> groups = bgs.loadShortBusinessGroups(groupKeys);
        a_a: for (Long activeGroupKey : groupKeys) {
            for (BusinessGroupShort group : groups) {
                if (group.getKey().equals(activeGroupKey)) {
                    continue a_a;
                }
            }
            StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", activeGroupKey.toString() }, translatorStr);
            sd.setDescriptionForUnit(nodeId);
            missingNames.add(sd);
        }
    } else {
        String groupStr = (String) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_GROUP);
        if (groupStr != null) {
            String[] groups = groupStr.split(",");
            for (int i = 0; i < groups.length; i++) {
                String trimmed = groups[i] != null ? groups[i].trim() : groups[i];
                if (!trimmed.equals("") && !cev.existsGroup(trimmed)) {
                    StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", trimmed }, translatorStr);
                    sd.setDescriptionForUnit(nodeId);
                    missingNames.add(sd);
                }
            }
        }
    }
    missingNames.addAll(condErrs);
    oneClickStatusCache = StatusDescriptionHelper.sort(missingNames);
    return oneClickStatusCache;
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) ArrayList(java.util.ArrayList) BGArea(org.olat.group.area.BGArea) BusinessGroupService(org.olat.group.BusinessGroupService) StatusDescription(org.olat.course.editor.StatusDescription) ArrayList(java.util.ArrayList) List(java.util.List) BusinessGroupShort(org.olat.group.BusinessGroupShort) BGAreaManager(org.olat.group.area.BGAreaManager)

Example 59 with StatusDescription

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

the class COCourseNode method isConfigValid.

/**
 * @see org.olat.course.nodes.CourseNode#isConfigValid()
 */
@Override
public StatusDescription isConfigValid() {
    updateModuleConfigDefaults(false);
    /*
         * first check the one click cache
         */
    if (oneClickStatusCache != null) {
        return oneClickStatusCache[0];
    }
    /**
     * configuration is valid if the provided e-mail container result in at list
     * one recipient e-mail adress. Hence we have always to perform the very
     * expensive operation to fetch the e-mail adresses for tutors,
     * participants, group and area members. simple config here!
     */
    @SuppressWarnings("unchecked") List<String> emailList = (List<String>) getModuleConfiguration().get(COEditController.CONFIG_KEY_EMAILTOADRESSES);
    boolean isValid = (emailList != null && emailList.size() > 0);
    Boolean email2owners = getModuleConfiguration().getBooleanEntry(COEditController.CONFIG_KEY_EMAILTOOWNERS);
    isValid = isValid || (email2owners != null && email2owners.booleanValue());
    String email2AreaCoaches = (String) getModuleConfiguration().get(COEditController.CONFIG_KEY_EMAILTOCOACHES_AREA);
    isValid = isValid || (StringHelper.containsNonWhitespace(email2AreaCoaches));
    String email2GroupCoaches = (String) getModuleConfiguration().get(COEditController.CONFIG_KEY_EMAILTOCOACHES_GROUP);
    isValid = isValid || (StringHelper.containsNonWhitespace(email2GroupCoaches));
    isValid = isValid || getModuleConfiguration().getBooleanSafe(COEditController.CONFIG_KEY_EMAILTOCOACHES_ALL, false);
    isValid = isValid || getModuleConfiguration().getBooleanSafe(COEditController.CONFIG_KEY_EMAILTOCOACHES_COURSE, false);
    String email2AreaParticipants = (String) getModuleConfiguration().get(COEditController.CONFIG_KEY_EMAILTOPARTICIPANTS_AREA);
    isValid = isValid || (StringHelper.containsNonWhitespace(email2AreaParticipants));
    String email2GroupParticipants = (String) getModuleConfiguration().get(COEditController.CONFIG_KEY_EMAILTOPARTICIPANTS_GROUP);
    isValid = isValid || (StringHelper.containsNonWhitespace(email2GroupParticipants));
    isValid = isValid || getModuleConfiguration().getBooleanSafe(COEditController.CONFIG_KEY_EMAILTOPARTICIPANTS_ALL, false);
    isValid = isValid || getModuleConfiguration().getBooleanSafe(COEditController.CONFIG_KEY_EMAILTOPARTICIPANTS_COURSE, false);
    StatusDescription sd = StatusDescription.NOERROR;
    if (!isValid) {
        String shortKey = "error.norecipients.short";
        String longKey = "error.norecipients.long";
        String[] params = new String[] { this.getShortTitle() };
        String translPackage = Util.getPackageName(COEditController.class);
        sd = new StatusDescription(StatusDescription.ERROR, shortKey, longKey, params, translPackage);
        sd.setDescriptionForUnit(getIdent());
        // set which pane is affected by error
        sd.setActivateableViewIdentifier(COEditController.PANE_TAB_COCONFIG);
    }
    return sd;
}
Also used : StatusDescription(org.olat.course.editor.StatusDescription) ArrayList(java.util.ArrayList) List(java.util.List)

Example 60 with StatusDescription

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

the class CourseEditorTreeNode method getIconDecorator1CssClass.

@Override
public String getIconDecorator1CssClass() {
    StatusDescription sd = cn.isConfigValid();
    String cssClass = null;
    if (deleted) {
        cssClass = "o_middel";
    } else if (sd.isError()) {
        cssClass = "o_miderr";
    } else if (!sd.isError() && dirty) {
        cssClass = "o_midpub";
    }
    return cssClass;
}
Also used : StatusDescription(org.olat.course.editor.StatusDescription)

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