Search in sources :

Example 76 with BGArea

use of org.olat.group.area.BGArea in project OpenOLAT by OpenOLAT.

the class ConditionConfigEasyController method validateGroupFields.

/**
 * @param retVal
 * @return
 */
private boolean validateGroupFields() {
    boolean retVal = true;
    if (groupSwitch.getSelectedKeys().size() == 1) {
        List<Long> activeGroupSelection = null;
        List<Long> activeAreaSelection = null;
        groupChooseSubContainer.clearError();
        if (!isEmpty(easyGroupList)) {
            // check whether groups exist
            activeGroupSelection = getKeys(easyGroupList);
            Set<Long> missingGroups = new HashSet<Long>();
            List<BusinessGroupShort> existingGroups = businessGroupService.loadShortBusinessGroups(activeGroupSelection);
            a_a: for (Long activeGroupKey : activeGroupSelection) {
                for (BusinessGroupShort group : existingGroups) {
                    if (group.getKey().equals(activeGroupKey)) {
                        continue a_a;
                    }
                }
                missingGroups.add(activeGroupKey);
            }
            if (missingGroups.size() > 0) {
                retVal = false;
                String labelKey = missingGroups.size() == 1 ? "error.notfound.name" : "error.notfound.names";
                String csvMissGrps = toString(missingGroups);
                String[] params = new String[] { "-", csvMissGrps };
                // create error with link to fix it
                String vc_errorPage = velocity_root + "/erroritem.html";
                FormLayoutContainer errorGroupItemLayout = FormLayoutContainer.createCustomFormLayout("errorgroupitem", getTranslator(), vc_errorPage);
                groupChooseSubContainer.setErrorComponent(errorGroupItemLayout, this.flc);
                // FIXING LINK ONLY IF A DEFAULTCONTEXT EXISTS
                fixGroupError = new FormLinkImpl("error.fix", "create");
                // link
                fixGroupError.setCustomEnabledLinkCSS("btn btn-default");
                errorGroupItemLayout.add(fixGroupError);
                fixGroupError.setErrorKey(labelKey, params);
                fixGroupError.showError(true);
                fixGroupError.showLabel(false);
                // String[].lenght > 1 -> show bulkmode creation group
                if (missingGroups.size() > 1) {
                    fixGroupError.setUserObject(new String[] { csvMissGrps, "dummy" });
                } else {
                    fixGroupError.setUserObject(new String[] { csvMissGrps });
                }
                groupChooseSubContainer.showError(true);
            } else {
                // no more errors
                groupChooseSubContainer.clearError();
            }
        }
        areaChooseSubContainer.clearError();
        if (!isEmpty(easyAreaList)) {
            // check whether areas exist
            activeAreaSelection = getKeys(easyAreaList);
            List<Long> missingAreas = new ArrayList<Long>();
            List<BGArea> cnt = areaManager.loadAreas(activeAreaSelection);
            a_a: for (Long activeAreaKey : activeAreaSelection) {
                for (BGArea element : cnt) {
                    if (element.getKey().equals(activeAreaKey)) {
                        continue a_a;
                    }
                }
                missingAreas.add(activeAreaKey);
            }
            if (missingAreas.size() > 0) {
                retVal = false;
                String labelKey = missingAreas.size() == 1 ? "error.notfound.name" : "error.notfound.names";
                String csvMissAreas = toString(missingAreas);
                String[] params = new String[] { "-", csvMissAreas };
                // create error with link to fix it
                String vc_errorPage = velocity_root + "/erroritem.html";
                FormLayoutContainer errorAreaItemLayout = FormLayoutContainer.createCustomFormLayout("errorareaitem", getTranslator(), vc_errorPage);
                areaChooseSubContainer.setErrorComponent(errorAreaItemLayout, this.flc);
                // FXINGIN LINK ONLY IF DEFAULT CONTEXT EXISTS
                // erstellen
                fixAreaError = new FormLinkImpl("error.fix", "create");
                // link
                fixAreaError.setCustomEnabledLinkCSS("btn btn-default");
                errorAreaItemLayout.add(fixAreaError);
                fixAreaError.setErrorKey(labelKey, params);
                fixAreaError.showError(true);
                fixAreaError.showLabel(false);
                // String[].lenght > 1 -> show bulkmode creation group
                if (missingAreas.size() > 1) {
                    fixAreaError.setUserObject(new String[] { csvMissAreas, "dummy" });
                } else {
                    fixAreaError.setUserObject(new String[] { csvMissAreas });
                }
                areaChooseSubContainer.showError(true);
            } else {
                areaChooseSubContainer.clearError();
            }
        }
        boolean easyGroupOK = (!isEmpty(easyGroupList) && activeGroupSelection != null && !activeGroupSelection.isEmpty());
        boolean easyAreaOK = (!isEmpty(easyAreaList) && activeAreaSelection != null && !activeAreaSelection.isEmpty());
        if (easyGroupOK || easyAreaOK) {
            // clear general error
            groupSubContainer.clearError();
        } else {
            // error concerns both fields -> set it as switch error
            groupSubContainer.setErrorKey("form.easy.error.group", null);
            retVal = false;
        }
    }
    return retVal;
}
Also used : ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FormLinkImpl(org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl) BGArea(org.olat.group.area.BGArea) BusinessGroupShort(org.olat.group.BusinessGroupShort) HashSet(java.util.HashSet)

Example 77 with BGArea

use of org.olat.group.area.BGArea in project OpenOLAT by OpenOLAT.

the class PreviewConfigController method generateEnvironment.

private void generateEnvironment() {
    List<BGArea> tmpAreas = areaManager.loadAreas(psf.getAreaKeys());
    List<BusinessGroup> groups = businessGroupService.loadBusinessGroups(psf.getGroupKeys());
    // get learning areas for groups
    Set<BGArea> areas = new HashSet<BGArea>();
    areas.addAll(tmpAreas);
    List<BGArea> areaByGroups = areaManager.findBGAreasOfBusinessGroups(groups);
    areas.addAll(areaByGroups);
    role = psf.getRole();
    ICourse course = CourseFactory.loadCourse(ores);
    // default is student
    isGlobalAuthor = false;
    isGuestOnly = false;
    isCoach = false;
    isCourseAdmin = false;
    /*
		 * if (role.equals(PreviewSettingsForm.ROLE_STUDENT)) { } else
		 */
    if (role.equals(PreviewSettingsForm.ROLE_GUEST)) {
        isGuestOnly = true;
    } else if (role.equals(PreviewSettingsForm.ROLE_COURSECOACH)) {
        isCoach = true;
    } else if (role.equals(PreviewSettingsForm.ROLE_COURSEADMIN)) {
        isCourseAdmin = true;
    } else if (role.equals(PreviewSettingsForm.ROLE_GLOBALAUTHOR)) {
        isGlobalAuthor = true;
    }
    final RepositoryEntry courseResource = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    final CourseGroupManager cgm = new PreviewCourseGroupManager(courseResource, new ArrayList<BusinessGroup>(groups), new ArrayList<BGArea>(areas), isCoach, isCourseAdmin);
    final UserNodeAuditManager auditman = new PreviewAuditManager();
    final AssessmentManager am = new PreviewAssessmentManager();
    final CoursePropertyManager cpm = new PreviewCoursePropertyManager();
    final Structure runStructure = course.getEditorTreeModel().createStructureForPreview();
    final String title = course.getCourseTitle();
    final CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig();
    simCourseEnv = new PreviewCourseEnvironment(title, runStructure, psf.getDate(), course.getCourseFolderContainer(), course.getCourseBaseContainer(), course.getResourceableId(), cpm, cgm, auditman, am, courseConfig);
    simIdentEnv = new IdentityEnvironment();
    simIdentEnv.setRoles(new Roles(false, false, false, isGlobalAuthor, isGuestOnly, false, false));
    final Identity ident = new PreviewIdentity();
    simIdentEnv.setIdentity(ident);
    // identity must be set before attributes OLAT-4811
    simIdentEnv.setAttributes(psf.getAttributesMap());
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) AssessmentManager(org.olat.course.assessment.AssessmentManager) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CourseConfig(org.olat.course.config.CourseConfig) BGArea(org.olat.group.area.BGArea) Structure(org.olat.course.Structure) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) HashSet(java.util.HashSet) BusinessGroup(org.olat.group.BusinessGroup) Roles(org.olat.core.id.Roles) UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 78 with BGArea

use of org.olat.group.area.BGArea in project OpenOLAT by OpenOLAT.

the class PersistingCourseGroupManager method exportCourseBusinessGroups.

/**
 * @see org.olat.course.groupsandrights.CourseGroupManager#exportCourseBusinessGroups(java.io.File)
 */
@Override
public void exportCourseBusinessGroups(File fExportDirectory, CourseEnvironmentMapper courseEnv, boolean runtimeDatas, boolean backwardsCompatible) {
    File fExportFile = new File(fExportDirectory, LEARNINGGROUPEXPORT_XML);
    List<BGArea> areas = getAllAreas();
    List<BusinessGroup> groups = getAllBusinessGroups();
    BusinessGroupEnvironment bgEnv = new BusinessGroupEnvironment();
    bgEnv.getGroups().addAll(courseEnv.getGroups());
    bgEnv.getAreas().addAll(courseEnv.getAreas());
    businessGroupService.exportGroups(groups, areas, fExportFile, bgEnv, runtimeDatas, backwardsCompatible);
}
Also used : BusinessGroupEnvironment(org.olat.group.model.BusinessGroupEnvironment) BGArea(org.olat.group.area.BGArea) BusinessGroup(org.olat.group.BusinessGroup) File(java.io.File)

Example 79 with BGArea

use of org.olat.group.area.BGArea in project OpenOLAT by OpenOLAT.

the class MembersSelectorFormFragment method getAreaNames.

private String getAreaNames(List<Long> keys) {
    StringBuilder sb = new StringBuilder();
    List<BGArea> areas = areaManager.loadAreas(keys);
    for (BGArea area : areas) {
        if (sb.length() > 0)
            sb.append("&nbsp;&nbsp;");
        sb.append("<i class='o_icon o_icon-fw o_icon_courseareas'>&nbsp;</i> ");
        sb.append(StringHelper.escapeHtml(area.getName()));
    }
    return sb.toString();
}
Also used : BGArea(org.olat.group.area.BGArea)

Example 80 with BGArea

use of org.olat.group.area.BGArea in project OpenOLAT by OpenOLAT.

the class PreviewConfigHelper method getPreviewCourseEnvironment.

public static CourseEnvironment getPreviewCourseEnvironment(boolean isCoach, boolean isCourseAdmin, ICourse course) {
    // generateEnvironment();
    final RepositoryEntry courseResource = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    final CourseGroupManager cgm = new PreviewCourseGroupManager(courseResource, new ArrayList<BusinessGroup>(), new ArrayList<BGArea>(), isCoach, isCourseAdmin);
    final UserNodeAuditManager auditman = new PreviewAuditManager();
    final AssessmentManager am = new PreviewAssessmentManager();
    final CoursePropertyManager cpm = new PreviewCoursePropertyManager();
    final Structure runStructure = course.getEditorTreeModel().createStructureForPreview();
    final String title = course.getCourseTitle();
    final CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig();
    CourseEnvironment previewCourseEnvironment = new PreviewCourseEnvironment(title, runStructure, new Date(), course.getCourseFolderContainer(), course.getCourseBaseContainer(), course.getResourceableId(), cpm, cgm, auditman, am, courseConfig);
    return previewCourseEnvironment;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) BusinessGroup(org.olat.group.BusinessGroup) AssessmentManager(org.olat.course.assessment.AssessmentManager) RepositoryEntry(org.olat.repository.RepositoryEntry) Date(java.util.Date) CourseConfig(org.olat.course.config.CourseConfig) UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) BGArea(org.olat.group.area.BGArea) Structure(org.olat.course.Structure) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Aggregations

BGArea (org.olat.group.area.BGArea)124 BusinessGroup (org.olat.group.BusinessGroup)70 Test (org.junit.Test)68 RepositoryEntry (org.olat.repository.RepositoryEntry)52 ArrayList (java.util.ArrayList)22 Identity (org.olat.core.id.Identity)22 BGAreaReference (org.olat.group.model.BGAreaReference)18 AssessmentModeToArea (org.olat.course.assessment.AssessmentModeToArea)16 CourseEnvironmentMapper (org.olat.course.export.CourseEnvironmentMapper)16 HashSet (java.util.HashSet)14 AssessmentMode (org.olat.course.assessment.AssessmentMode)12 BusinessGroupReference (org.olat.group.model.BusinessGroupReference)12 OLATResource (org.olat.resource.OLATResource)12 AssessmentModeToGroup (org.olat.course.assessment.AssessmentModeToGroup)10 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)8 CollaborationTools (org.olat.collaboration.CollaborationTools)6 BusinessGroupShort (org.olat.group.BusinessGroupShort)6 File (java.io.File)4 IOException (java.io.IOException)4 Field (java.lang.reflect.Field)4