Search in sources :

Example 81 with BGArea

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

the class PreviewSettingsForm method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    sdate = uifactory.addDateChooser("sdate", "form.sdate", null, formLayout);
    sdate.setExampleKey("form.easy.example.bdate", null);
    sdate.setDateChooserTimeEnabled(true);
    sdate.setMandatory(true);
    sdate.setValidDateCheck("form.sdate.invalid");
    // setDate must be called after the DataChooser was configured
    sdate.setDate(new Date());
    List<BusinessGroup> groups = courseGroupManager.getAllBusinessGroups();
    String[] groupNames = new String[groups.size()];
    String[] groupKeys = new String[groups.size()];
    for (int i = groups.size(); i-- > 0; ) {
        groupNames[i] = groups.get(i).getName();
        groupKeys[i] = groups.get(i).getKey().toString();
    }
    groupSelector = uifactory.addCheckboxesVertical("details.groups", formLayout, groupKeys, groupNames, 1);
    groupSelector.setVisible(groups.size() > 0);
    List<BGArea> areas = courseGroupManager.getAllAreas();
    String[] areaNames = new String[areas.size()];
    String[] areaKeys = new String[areas.size()];
    for (int i = areas.size(); i-- > 0; ) {
        areaNames[i] = areas.get(i).getName();
        areaKeys[i] = areas.get(i).getKey().toString();
    }
    areaSelector = uifactory.addCheckboxesVertical("details.areas", formLayout, areaKeys, areaNames, 1);
    areaSelector.setVisible(areas.size() > 0);
    String[] keys = { ROLE_STUDENT, ROLE_GUEST, ROLE_COURSECOACH, ROLE_COURSEADMIN, ROLE_GLOBALAUTHOR };
    String[] values = new String[keys.length];
    for (int i = 0; i < keys.length; i++) {
        values[i] = translate(keys[i]);
    }
    roles = uifactory.addRadiosVertical("roles", "form.roles", formLayout, keys, values);
    roles.select(ROLE_STUDENT, true);
    String page = velocity_root + "/attributes.html";
    FormLayoutContainer attrlayout = FormLayoutContainer.createCustomFormLayout("attributes", getTranslator(), page);
    formLayout.add(attrlayout);
    attrlayout.setLabel("form.attributes", null);
    for (int i = 0; i < NUMATTR; i++) {
        TextElement name = uifactory.addTextElement("attrname" + i, null, 255, "", attrlayout);
        ((AbstractComponent) name.getComponent()).setDomReplacementWrapperRequired(false);
        name.setDisplaySize(12);
        TextElement value = uifactory.addTextElement("attrvalue" + i, "form.equals", 255, "", attrlayout);
        ((AbstractComponent) value.getComponent()).setDomReplacementWrapperRequired(false);
        value.setDisplaySize(12);
        attrNames.add(name);
        attrValues.add(value);
    }
    uifactory.addFormSubmitButton("submit", "command.preview", formLayout);
}
Also used : AbstractComponent(org.olat.core.gui.components.AbstractComponent) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) BusinessGroup(org.olat.group.BusinessGroup) BGArea(org.olat.group.area.BGArea) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Date(java.util.Date)

Example 82 with BGArea

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

the class GTAWorkflowEditController method getAreaNames.

private String getAreaNames(List<Long> areaKeyList) {
    StringBuilder sb = new StringBuilder(64);
    List<BGArea> areas = areaManager.loadAreas(areaKeyList);
    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> ").append(StringHelper.escapeHtml(area.getName()));
    }
    return sb.toString();
}
Also used : BGArea(org.olat.group.area.BGArea)

Example 83 with BGArea

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

the class BGAreaEditController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == areaController) {
        if (event == Event.DONE_EVENT) {
            BGArea updatedArea = doAreaUpdate();
            if (updatedArea == null) {
                areaController.resetAreaName();
                getWindowControl().setWarning(translate("error.area.name.exists"));
            } else {
                area = updatedArea;
                mainVC.contextPut("title", translate("area.edit.title", new String[] { StringEscapeUtils.escapeHtml(area.getName()).toString() }));
            }
        } else if (event == Event.CANCELLED_EVENT) {
            // area might have been changed, reload from db
            area = areaManager.reloadArea(area);
            removeAsListenerAndDispose(areaController);
            areaController = new BGAreaFormController(ureq, getWindowControl(), area, false);
            listenTo(areaController);
            detailsTabVC.put("areaForm", areaController.getInitialComponent());
            fireEvent(ureq, event);
        }
    }
}
Also used : BGArea(org.olat.group.area.BGArea)

Example 84 with BGArea

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

the class BusinessGroupServiceImpl method copyBusinessGroup.

@Override
public BusinessGroup copyBusinessGroup(Identity identity, BusinessGroup sourceBusinessGroup, String targetName, String targetDescription, Integer targetMin, Integer targetMax, boolean copyAreas, boolean copyCollabToolConfig, boolean copyRights, boolean copyOwners, boolean copyParticipants, boolean copyMemberVisibility, boolean copyWaitingList, boolean copyRelations) {
    // 1. create group, set waitingListEnabled, enableAutoCloseRanks like source business-group
    BusinessGroup newGroup = createBusinessGroup(null, targetName, targetDescription, targetMin, targetMax, sourceBusinessGroup.getWaitingListEnabled(), sourceBusinessGroup.getAutoCloseRanksEnabled(), null);
    // return immediately with null value to indicate an already take groupname
    if (newGroup == null) {
        return null;
    }
    // 2. copy tools
    if (copyCollabToolConfig) {
        CollaborationToolsFactory toolsF = CollaborationToolsFactory.getInstance();
        // get collab tools from original group and the new group
        CollaborationTools oldTools = toolsF.getOrCreateCollaborationTools(sourceBusinessGroup);
        CollaborationTools newTools = toolsF.getOrCreateCollaborationTools(newGroup);
        // copy the collab tools settings
        String[] availableTools = CollaborationToolsFactory.getInstance().getAvailableTools().clone();
        for (int i = 0; i < availableTools.length; i++) {
            String tool = availableTools[i];
            newTools.setToolEnabled(tool, oldTools.isToolEnabled(tool));
        }
        String oldNews = oldTools.lookupNews();
        newTools.saveNews(oldNews);
    }
    // 3. copy member visibility
    if (copyMemberVisibility) {
        newGroup.setOwnersVisibleIntern(sourceBusinessGroup.isOwnersVisibleIntern());
        newGroup.setOwnersVisiblePublic(sourceBusinessGroup.isOwnersVisiblePublic());
        newGroup.setParticipantsVisibleIntern(sourceBusinessGroup.isParticipantsVisibleIntern());
        newGroup.setParticipantsVisiblePublic(sourceBusinessGroup.isParticipantsVisiblePublic());
        newGroup.setWaitingListVisibleIntern(sourceBusinessGroup.isWaitingListVisibleIntern());
        newGroup.setWaitingListVisiblePublic(sourceBusinessGroup.isWaitingListVisiblePublic());
        newGroup.setDownloadMembersLists(sourceBusinessGroup.isDownloadMembersLists());
    }
    // 4. copy areas
    if (copyAreas) {
        List<BGArea> areas = areaManager.findBGAreasOfBusinessGroup(sourceBusinessGroup);
        for (BGArea area : areas) {
            // reference target group to source groups areas
            areaManager.addBGToBGArea(newGroup, area);
        }
    }
    // 5. copy owners
    if (copyOwners) {
        List<Identity> owners = businessGroupRelationDAO.getMembers(sourceBusinessGroup, GroupRoles.coach.name());
        if (owners.isEmpty()) {
            businessGroupRelationDAO.addRole(identity, newGroup, GroupRoles.coach.name());
        } else {
            for (Identity owner : owners) {
                businessGroupRelationDAO.addRole(owner, newGroup, GroupRoles.coach.name());
            }
        }
    } else {
        businessGroupRelationDAO.addRole(identity, newGroup, GroupRoles.coach.name());
    }
    // 6. copy participants
    if (copyParticipants) {
        List<Identity> participants = businessGroupRelationDAO.getMembers(sourceBusinessGroup, GroupRoles.participant.name());
        for (Identity participant : participants) {
            businessGroupRelationDAO.addRole(participant, newGroup, GroupRoles.participant.name());
        }
    }
    // 7. copy rights
    if (copyRights) {
        List<String> participantRights = rightManager.findBGRights(sourceBusinessGroup, BGRightsRole.participant);
        for (String sourceRight : participantRights) {
            rightManager.addBGRight(sourceRight, newGroup, BGRightsRole.participant);
        }
        List<String> tutorRights = rightManager.findBGRights(sourceBusinessGroup, BGRightsRole.tutor);
        for (String sourceRight : tutorRights) {
            rightManager.addBGRight(sourceRight, newGroup, BGRightsRole.tutor);
        }
    }
    // 8. copy waiting-lisz
    if (copyWaitingList) {
        List<Identity> waitingList = getMembers(sourceBusinessGroup, GroupRoles.waiting.name());
        for (Identity waiting : waitingList) {
            businessGroupRelationDAO.addRole(waiting, newGroup, GroupRoles.waiting.name());
        }
    }
    // 9. copy relations
    if (copyRelations) {
        List<RepositoryEntry> resources = businessGroupRelationDAO.findRepositoryEntries(Collections.singletonList(sourceBusinessGroup), 0, -1);
        addResourcesTo(Collections.singletonList(newGroup), resources);
    }
    return newGroup;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) BGArea(org.olat.group.area.BGArea) CollaborationTools(org.olat.collaboration.CollaborationTools) Identity(org.olat.core.id.Identity) CollaborationToolsFactory(org.olat.collaboration.CollaborationToolsFactory)

Example 85 with BGArea

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

the class BusinessGroupImportExport method exportGroups.

public void exportGroups(List<BusinessGroup> groups, List<BGArea> areas, File fExportFile, BusinessGroupEnvironment env, boolean runtimeDatas, boolean backwardsCompatible) {
    if (groups == null || groups.isEmpty()) {
        // nothing to do... says Florian.
        return;
    }
    OLATGroupExport root = new OLATGroupExport();
    // export areas
    root.setAreas(new AreaCollection());
    root.getAreas().setGroups(new ArrayList<Area>());
    for (BGArea area : areas) {
        Area newArea = new Area();
        newArea.key = backwardsCompatible ? null : area.getKey();
        newArea.name = area.getName();
        if (backwardsCompatible && env != null) {
            String newName = env.getAreaName(area.getKey());
            if (StringHelper.containsNonWhitespace(newName)) {
                newArea.name = newName;
            }
        }
        newArea.description = Collections.singletonList(area.getDescription());
        root.getAreas().getGroups().add(newArea);
    }
    // export groups
    root.setGroups(new GroupCollection());
    root.getGroups().setGroups(new ArrayList<Group>());
    for (BusinessGroup group : groups) {
        String groupName = null;
        if (backwardsCompatible && env != null) {
            groupName = env.getGroupName(group.getKey());
        }
        Group newGroup = exportGroup(fExportFile, group, groupName, runtimeDatas, backwardsCompatible);
        root.getGroups().getGroups().add(newGroup);
    }
    saveGroupConfiguration(fExportFile, root);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) BGArea(org.olat.group.area.BGArea) BGArea(org.olat.group.area.BGArea) BusinessGroup(org.olat.group.BusinessGroup)

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