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);
}
});
}
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;
}
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;
}
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();
}
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();
}
Aggregations