Search in sources :

Example 11 with Project

use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.

the class ProjectBrokerManagerImpl method setProjectState.

@Override
public void setProjectState(final Project project, final String state) {
    final Long projectBrokerId = project.getProjectBroker().getKey();
    OLATResourceable projectBrokerOres = OresHelper.createOLATResourceableInstance(this.getClass(), projectBrokerId);
    CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectBrokerOres, new SyncerExecutor() {

        @Override
        public void execute() {
            // For cluster-safe : reload project object here another node might have changed this in the meantime
            Project reloadedProject = (Project) dbInstance.loadObject(project, true);
            reloadedProject.setState(state);
            updateProjectAndInvalidateCache(reloadedProject);
        }
    });
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) OLATResourceable(org.olat.core.id.OLATResourceable) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor)

Example 12 with Project

use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.

the class ProjectBrokerManagerImpl method getCoachedProjectsOf.

@Override
public List<Project> getCoachedProjectsOf(Identity identity, Long projectBrokerId) {
    List<Project> myProjects = new ArrayList<Project>();
    List<Project> allProjects = getProjectListBy(projectBrokerId);
    // TODO: for better performance should be done with sql query instead of a loop
    for (Iterator<Project> iterator = allProjects.iterator(); iterator.hasNext(); ) {
        Project project = iterator.next();
        if (businessGroupService.hasRoles(identity, project.getProjectGroup(), GroupRoles.coach.name())) {
            myProjects.add(project);
        }
    }
    return myProjects;
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) ArrayList(java.util.ArrayList)

Example 13 with Project

use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.

the class ProjectGroupManagerImpl method acceptCandidates.

@Override
public BusinessGroupAddResponse acceptCandidates(final List<Identity> identities, final Project project, final Identity actionIdentity, final boolean autoSignOut, final boolean isAcceptSelectionManually) {
    final Project reloadedProject = projectDao.loadProject(project.getKey());
    final BusinessGroupAddResponse response = new BusinessGroupAddResponse();
    BusinessGroupAddResponse state = businessGroupService.addParticipants(actionIdentity, null, identities, reloadedProject.getProjectGroup(), null);
    response.getAddedIdentities().addAll(state.getAddedIdentities());
    response.getIdentitiesAlreadyInGroup().addAll(state.getIdentitiesAlreadyInGroup());
    Boolean result = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(project.getProjectGroup(), new SyncerCallback<Boolean>() {

        @Override
        public Boolean execute() {
            for (final Identity identity : identities) {
                if (businessGroupService.hasRoles(identity, reloadedProject.getProjectGroup(), GroupRoles.participant.name())) {
                    securityManager.removeIdentityFromSecurityGroup(identity, reloadedProject.getCandidateGroup());
                    log.audit("ProjectBroker: Accept candidate, identity=" + identity + " project=" + reloadedProject);
                }
            }
            return Boolean.TRUE;
        }
    });
    if (autoSignOut && result.booleanValue()) {
        projectBrokerManager.signOutFormAllCandidateList(response.getAddedIdentities(), reloadedProject.getProjectBroker().getKey());
    }
    if (isAcceptSelectionManually && (reloadedProject.getMaxMembers() != Project.MAX_MEMBERS_UNLIMITED) && reloadedProject.getSelectedPlaces() >= reloadedProject.getMaxMembers()) {
        projectBrokerManager.setProjectState(reloadedProject, Project.STATE_ASSIGNED);
        log.info("ProjectBroker: Accept candidate, change project-state=" + Project.STATE_ASSIGNED);
    }
    return response;
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) BusinessGroupAddResponse(org.olat.group.BusinessGroupAddResponse) Identity(org.olat.core.id.Identity)

Example 14 with Project

use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.

the class ProjectBrokerExportGenerator method createProjectDataLine.

private static String createProjectDataLine(Translator t, Project project, ProjectBrokerModuleConfiguration moduleConfig, Translator translator) {
    StringBuilder line = new StringBuilder();
    line.append(project.getTitle());
    line.append(TABLE_DELIMITER);
    // loop over project leaders
    StringBuilder projectLeader = new StringBuilder();
    boolean firstElement = true;
    for (Identity identity : project.getProjectLeaders()) {
        if (!firstElement) {
            projectLeader.append(" , ");
        }
        String last = identity.getUser().getProperty(UserConstants.LASTNAME, t.getLocale());
        String first = identity.getUser().getProperty(UserConstants.FIRSTNAME, t.getLocale());
        projectLeader.append(first);
        projectLeader.append(" ");
        projectLeader.append(last);
        firstElement = false;
    }
    line.append(projectLeader.toString());
    line.append(TABLE_DELIMITER);
    line.append(t.translate(project.getState()));
    line.append(TABLE_DELIMITER);
    // loop over customfileds
    for (int customFieldIndex = 0; customFieldIndex < moduleConfig.getCustomFields().size(); customFieldIndex++) {
        String value = project.getCustomFieldValue(customFieldIndex);
        line.append(value);
        line.append(TABLE_DELIMITER);
    }
    line.append(project.getSelectedPlaces());
    line.append(TABLE_DELIMITER);
    // loop over all events
    for (Project.EventType eventType : Project.EventType.values()) {
        if (moduleConfig.isProjectEventEnabled(eventType)) {
            ProjectEvent projectEvent = project.getProjectEvent(eventType);
            if (projectEvent.getStartDate() != null) {
                line.append(translator.translate("export.event.start.prefix"));
                line.append(" ");
                line.append(projectEvent.getFormattedStartDate());
                line.append(" ");
            }
            if (projectEvent.getEndDate() != null) {
                line.append(translator.translate("export.event.end.prefix"));
                line.append(" ");
                line.append(projectEvent.getFormattedEndDate());
            }
            line.append(TABLE_DELIMITER);
        }
    }
    // loop over all paricipants
    StringBuilder participants = new StringBuilder();
    boolean firstParticipants = true;
    List<Identity> participantList = CoreSpringFactory.getImpl(BusinessGroupService.class).getMembers(project.getProjectGroup(), GroupRoles.participant.name());
    for (Identity identity : participantList) {
        if (!firstParticipants) {
            participants.append(" , ");
        }
        String last = identity.getUser().getProperty(UserConstants.LASTNAME, t.getLocale());
        String first = identity.getUser().getProperty(UserConstants.FIRSTNAME, t.getLocale());
        participants.append(first);
        participants.append(" ");
        participants.append(last);
        firstParticipants = false;
    }
    line.append(participants.toString());
    line.append(TABLE_DELIMITER);
    line.append(project.getKey().toString());
    line.append(END_OF_LINE);
    return line.toString();
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) BusinessGroupService(org.olat.group.BusinessGroupService) Identity(org.olat.core.id.Identity) ProjectEvent(org.olat.course.nodes.projectbroker.datamodel.ProjectEvent)

Example 15 with Project

use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.

the class ProjectBrokerExportGenerator method createCourseResultsOverviewTable.

/**
 * The results from assessable nodes are written to one row per user into an excel-sheet. An
 * assessable node will only appear if it is producing at least one of the
 * following variables: score, passed, attempts, comments.
 *
 * @param identities
 * @param myNodes
 * @param course
 * @param locale
 * @return String
 */
public static String createCourseResultsOverviewTable(CourseNode courseNode, ICourse course, Locale locale) {
    Translator translator = Util.createPackageTranslator(ProjectBrokerControllerFactory.class, locale);
    StringBuilder table = new StringBuilder();
    ProjectBrokerModuleConfiguration moduleConfig = new ProjectBrokerModuleConfiguration(courseNode.getModuleConfiguration());
    ProjectBrokerManager projectBrokerManager = CoreSpringFactory.getImpl(ProjectBrokerManager.class);
    // load project-list
    CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    Long projectBrokerId = projectBrokerManager.getProjectBrokerId(cpm, courseNode);
    if (projectBrokerId != null) {
        List<Project> projects = projectBrokerManager.getProjectListBy(projectBrokerId);
        // build table-header
        table.append(createHeaderLine(translator, moduleConfig));
        // loop over all projects
        for (Project project : projects) {
            table.append(createProjectDataLine(translator, project, moduleConfig, translator));
        }
    } else {
        log.debug("projectBrokerId is null, courseNode=" + courseNode + " , course=" + course);
    }
    return table.toString();
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) Translator(org.olat.core.gui.translator.Translator) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Aggregations

Project (org.olat.course.nodes.projectbroker.datamodel.Project)70 ProjectBroker (org.olat.course.nodes.projectbroker.datamodel.ProjectBroker)30 Identity (org.olat.core.id.Identity)22 OLATResourceable (org.olat.core.id.OLATResourceable)16 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)12 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)12 ProjectEvent (org.olat.course.nodes.projectbroker.datamodel.ProjectEvent)10 ProjectBrokerManager (org.olat.course.nodes.projectbroker.service.ProjectBrokerManager)10 BusinessGroup (org.olat.group.BusinessGroup)10 BusinessGroupService (org.olat.group.BusinessGroupService)10 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)8 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)8 ProjectGroupManager (org.olat.course.nodes.projectbroker.service.ProjectGroupManager)8 PersistingCoursePropertyManager (org.olat.course.properties.PersistingCoursePropertyManager)8 File (java.io.File)6 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)6 VFSItem (org.olat.core.util.vfs.VFSItem)6 XStream (com.thoughtworks.xstream.XStream)4 IOException (java.io.IOException)4