use of org.olat.course.assessment.AssessmentModeToGroup in project openolat by klemens.
the class AssessmentModeManagerImpl method getAssessedIdentityKeys.
@Override
public Set<Long> getAssessedIdentityKeys(AssessmentMode assessmentMode) {
Target targetAudience = assessmentMode.getTargetAudience();
RepositoryEntry re = assessmentMode.getRepositoryEntry();
Set<Long> assessedKeys = new HashSet<>();
if (targetAudience == Target.course || targetAudience == Target.courseAndGroups) {
List<Long> courseMemberKeys = assessmentMode.isApplySettingsForCoach() ? repositoryEntryRelationDao.getMemberKeys(re, RepositoryEntryRelationType.defaultGroup, GroupRoles.coach.name(), GroupRoles.participant.name()) : repositoryEntryRelationDao.getMemberKeys(re, RepositoryEntryRelationType.defaultGroup, GroupRoles.participant.name());
assessedKeys.addAll(courseMemberKeys);
}
if (targetAudience == Target.groups || targetAudience == Target.courseAndGroups) {
List<BusinessGroup> groups = new ArrayList<>();
Set<AssessmentModeToArea> modeToAreas = assessmentMode.getAreas();
if (modeToAreas.size() > 0) {
List<BGArea> areas = new ArrayList<>(modeToAreas.size());
for (AssessmentModeToArea modeToArea : modeToAreas) {
areas.add(modeToArea.getArea());
}
List<BusinessGroup> groupsInAreas = areaMgr.findBusinessGroupsOfAreas(areas);
groups.addAll(groupsInAreas);
}
Set<AssessmentModeToGroup> modeToGroups = assessmentMode.getGroups();
if (modeToGroups.size() > 0) {
for (AssessmentModeToGroup modeToGroup : modeToGroups) {
groups.add(modeToGroup.getBusinessGroup());
}
}
List<Long> groupMemberKeys = assessmentMode.isApplySettingsForCoach() ? businessGroupRelationDao.getMemberKeys(groups, GroupRoles.coach.name(), GroupRoles.participant.name()) : businessGroupRelationDao.getMemberKeys(groups, GroupRoles.participant.name());
assessedKeys.addAll(groupMemberKeys);
}
return assessedKeys;
}
use of org.olat.course.assessment.AssessmentModeToGroup in project openolat by klemens.
the class AssessmentModeEditController method save.
private void save(UserRequest ureq, boolean forceStatus) {
if (assessmentMode.getKey() != null) {
assessmentMode = assessmentModeMgr.getAssessmentModeById(assessmentMode.getKey());
}
assessmentMode.setName(nameEl.getValue());
assessmentMode.setDescription(descriptionEl.getValue());
assessmentMode.setBegin(beginEl.getDate());
if (leadTimeEl.getIntValue() > 0) {
assessmentMode.setLeadTime(leadTimeEl.getIntValue());
} else {
assessmentMode.setLeadTime(0);
}
assessmentMode.setEnd(endEl.getDate());
if (followupTimeEl.getIntValue() > 0) {
assessmentMode.setFollowupTime(followupTimeEl.getIntValue());
} else {
assessmentMode.setFollowupTime(0);
}
if (startModeEl.isOneSelected() && startModeEl.isSelected(1)) {
assessmentMode.setManualBeginEnd(true);
} else {
assessmentMode.setManualBeginEnd(false);
}
String targetKey = targetEl.getSelectedKey();
assessmentMode.setTargetAudience(AssessmentMode.Target.valueOf(targetKey));
boolean elementRestrictions = courseElementsRestrictionEl.isAtLeastSelected(1);
assessmentMode.setRestrictAccessElements(elementRestrictions);
if (elementRestrictions) {
StringBuilder sb = new StringBuilder();
for (String elementKey : elementKeys) {
if (sb.length() > 0)
sb.append(",");
sb.append(elementKey);
}
assessmentMode.setElementList(sb.toString());
} else {
assessmentMode.setElementList(null);
}
if (StringHelper.containsNonWhitespace(startElementKey)) {
assessmentMode.setStartElement(startElementKey);
} else {
assessmentMode.setStartElement(null);
}
boolean ipRestriction = ipsEl.isAtLeastSelected(1);
assessmentMode.setRestrictAccessIps(ipRestriction);
if (ipRestriction) {
assessmentMode.setIpList(ipListEl.getValue());
} else {
assessmentMode.setIpList(null);
}
boolean safeExamEnabled = safeExamBrowserEl.isAtLeastSelected(1);
assessmentMode.setSafeExamBrowser(safeExamEnabled);
if (safeExamEnabled) {
assessmentMode.setSafeExamBrowserKey(safeExamBrowserKeyEl.getValue());
assessmentMode.setSafeExamBrowserHint(safeExamBrowserHintEl.getValue());
} else {
assessmentMode.setSafeExamBrowserKey(null);
assessmentMode.setSafeExamBrowserHint(null);
}
assessmentMode.setApplySettingsForCoach(forCoachEl.isAtLeastSelected(1));
// mode need to be persisted for the following relations
if (assessmentMode.getKey() == null) {
assessmentMode = assessmentModeMgr.persist(assessmentMode);
}
// update groups
if (groupKeys.isEmpty()) {
if (!assessmentMode.getGroups().isEmpty()) {
assessmentMode.getGroups().clear();
}
} else {
Set<Long> currentKeys = new HashSet<>();
for (Iterator<AssessmentModeToGroup> modeToGroupIt = assessmentMode.getGroups().iterator(); modeToGroupIt.hasNext(); ) {
Long currentKey = modeToGroupIt.next().getBusinessGroup().getKey();
if (!groupKeys.contains(currentKey)) {
modeToGroupIt.remove();
} else {
currentKeys.add(currentKey);
}
}
for (Long groupKey : groupKeys) {
if (!currentKeys.contains(groupKey)) {
BusinessGroup group = businessGroupService.loadBusinessGroup(groupKey);
AssessmentModeToGroup modeToGroup = assessmentModeMgr.createAssessmentModeToGroup(assessmentMode, group);
assessmentMode.getGroups().add(modeToGroup);
}
}
}
// update areas
if (areaKeys.isEmpty()) {
if (!assessmentMode.getAreas().isEmpty()) {
assessmentMode.getAreas().clear();
}
} else {
Set<Long> currentKeys = new HashSet<>();
for (Iterator<AssessmentModeToArea> modeToAreaIt = assessmentMode.getAreas().iterator(); modeToAreaIt.hasNext(); ) {
Long currentKey = modeToAreaIt.next().getArea().getKey();
if (!areaKeys.contains(currentKey)) {
modeToAreaIt.remove();
} else {
currentKeys.add(currentKey);
}
}
for (Long areaKey : areaKeys) {
if (!currentKeys.contains(areaKey)) {
BGArea area = areaMgr.loadArea(areaKey);
AssessmentModeToArea modeToArea = assessmentModeMgr.createAssessmentModeToArea(assessmentMode, area);
assessmentMode.getAreas().add(modeToArea);
}
}
}
assessmentMode = assessmentModeMgr.merge(assessmentMode, forceStatus);
fireEvent(ureq, Event.CHANGED_EVENT);
}
Aggregations