use of org.olat.course.nodes.cl.model.AssessmentData in project OpenOLAT by OpenOLAT.
the class CheckListAssessmentController method getAssessmentDataViews.
private List<CheckListAssessmentRow> getAssessmentDataViews(List<AssessmentData> datas, List<Checkbox> checkbox) {
List<CheckListAssessmentRow> dataViews = new ArrayList<>();
int numOfcheckbox = checkbox.size();
Map<String, Integer> indexed = new HashMap<>();
for (int i = numOfcheckbox; i-- > 0; ) {
indexed.put(checkbox.get(i).getCheckboxId(), new Integer(i));
}
for (AssessmentData data : datas) {
Float[] scores = new Float[numOfcheckbox];
Boolean[] checkBool = new Boolean[numOfcheckbox];
float totalPoints = 0.0f;
for (DBCheck check : data.getChecks()) {
Float score = check.getScore();
if (score != null) {
totalPoints += score.floatValue();
}
if (check.getChecked() == null)
continue;
check.getCheckbox();
Integer index = indexed.get(check.getCheckbox().getCheckboxId());
if (index != null) {
int i = index.intValue();
if (i >= 0 && i < numOfcheckbox) {
scores[i] = score;
checkBool[i] = check.getChecked();
}
}
}
if (maxScore != null && maxScore.floatValue() > 0f && totalPoints > maxScore.floatValue()) {
totalPoints = maxScore.floatValue();
}
CheckListAssessmentRow row = new CheckListAssessmentRow(data.getIdentity(), checkBool, scores, totalPoints, userPropertyHandlers, getLocale());
dataViews.add(row);
}
return dataViews;
}
use of org.olat.course.nodes.cl.model.AssessmentData in project openolat by klemens.
the class CheckListAssessmentController method loadDatas.
private List<CheckListAssessmentRow> loadDatas() {
if (!(coachCourseEnv instanceof UserCourseEnvironmentImpl)) {
return Collections.emptyList();
}
UserCourseEnvironmentImpl env = (UserCourseEnvironmentImpl) coachCourseEnv;
List<Checkbox> checkboxColl = checkboxList.getList();
int numOfCheckbox = checkboxList.getNumOfCheckbox();
boolean courseAdmin = env.isAdmin();
RepositoryEntry re = env.getCourseRepositoryEntry();
boolean courseTutor = repositoryService.hasRole(getIdentity(), re, GroupRoles.coach.name());
Set<Long> missingIdentityKeys = new HashSet<>();
if (courseTutor || courseAdmin) {
List<RepositoryEntryMembership> repoMemberships = repositoryManager.getRepositoryEntryMembership(re);
for (RepositoryEntryMembership repoMembership : repoMemberships) {
if (repoMembership.isParticipant()) {
missingIdentityKeys.add(repoMembership.getIdentityKey());
}
}
}
List<BusinessGroup> coachedGroups = courseAdmin ? coachCourseEnv.getCourseEnvironment().getCourseGroupManager().getAllBusinessGroups() : env.getCoachedGroups();
List<AssessmentData> dataList = checkboxManager.getAssessmentDatas(courseOres, courseNode.getIdent(), courseTutor || courseAdmin ? re : null, coachedGroups);
List<CheckListAssessmentRow> boxList = getAssessmentDataViews(dataList, checkboxColl);
Map<Long, CheckListAssessmentRow> identityToView = new HashMap<>();
for (CheckListAssessmentRow box : boxList) {
identityToView.put(box.getIdentityKey(), box);
missingIdentityKeys.remove(box.getIdentityKey());
}
List<BusinessGroupMembership> memberships = businessGroupService.getBusinessGroupsMembership(coachedGroups);
for (BusinessGroupMembership membership : memberships) {
if (!membership.isParticipant())
continue;
Long identityKey = membership.getIdentityKey();
if (!identityToView.containsKey(identityKey)) {
missingIdentityKeys.add(identityKey);
}
}
List<Identity> missingIdentities = securityManager.loadIdentityByKeys(missingIdentityKeys);
for (Identity missingIdentity : missingIdentities) {
Boolean[] checked = new Boolean[numOfCheckbox];
Float[] scores = new Float[numOfCheckbox];
CheckListAssessmentRow view = new CheckListAssessmentRow(missingIdentity, checked, scores, null, userPropertyHandlers, getLocale());
identityToView.put(missingIdentity.getKey(), view);
}
for (BusinessGroupMembership membership : memberships) {
if (!membership.isParticipant())
continue;
CheckListAssessmentRow view = identityToView.get(membership.getIdentityKey());
if (view != null) {
view.addGroupKey(membership.getGroupKey());
}
}
List<CheckListAssessmentRow> views = new ArrayList<>();
views.addAll(identityToView.values());
return views;
}
use of org.olat.course.nodes.cl.model.AssessmentData in project openolat by klemens.
the class CheckListAssessmentController method getAssessmentDataViews.
private List<CheckListAssessmentRow> getAssessmentDataViews(List<AssessmentData> datas, List<Checkbox> checkbox) {
List<CheckListAssessmentRow> dataViews = new ArrayList<>();
int numOfcheckbox = checkbox.size();
Map<String, Integer> indexed = new HashMap<>();
for (int i = numOfcheckbox; i-- > 0; ) {
indexed.put(checkbox.get(i).getCheckboxId(), new Integer(i));
}
for (AssessmentData data : datas) {
Float[] scores = new Float[numOfcheckbox];
Boolean[] checkBool = new Boolean[numOfcheckbox];
float totalPoints = 0.0f;
for (DBCheck check : data.getChecks()) {
Float score = check.getScore();
if (score != null) {
totalPoints += score.floatValue();
}
if (check.getChecked() == null)
continue;
check.getCheckbox();
Integer index = indexed.get(check.getCheckbox().getCheckboxId());
if (index != null) {
int i = index.intValue();
if (i >= 0 && i < numOfcheckbox) {
scores[i] = score;
checkBool[i] = check.getChecked();
}
}
}
if (maxScore != null && maxScore.floatValue() > 0f && totalPoints > maxScore.floatValue()) {
totalPoints = maxScore.floatValue();
}
CheckListAssessmentRow row = new CheckListAssessmentRow(data.getIdentity(), checkBool, scores, totalPoints, userPropertyHandlers, getLocale());
dataViews.add(row);
}
return dataViews;
}
use of org.olat.course.nodes.cl.model.AssessmentData in project openolat by klemens.
the class CheckListExcelExport method exportAll.
public void exportAll(String filename, ZipOutputStream exportStream) {
List<AssessmentData> dataList = checkboxManager.getAssessmentDatas(course, courseNode.getIdent(), null, null);
try (OutputStream out = new ShieldOutputStream(exportStream)) {
exportStream.putNextEntry(new ZipEntry(filename + ".xlsx"));
exportWorkbook(dataList, out);
exportStream.closeEntry();
} catch (IOException e) {
log.error("", e);
}
}
use of org.olat.course.nodes.cl.model.AssessmentData in project openolat by klemens.
the class CheckboxManagerImpl method getAssessmentDatas.
@Override
public List<AssessmentData> getAssessmentDatas(OLATResourceable ores, String resSubPath, RepositoryEntry re, List<BusinessGroup> businessGroups) {
StringBuilder sb = new StringBuilder();
sb.append("select check from clcheck check").append(" inner join fetch check.checkbox box").append(" inner join fetch check.identity ident").append(" inner join fetch ident.user identUser").append(" where box.resName=:resName and box.resId=:resId");
if (StringHelper.containsNonWhitespace(resSubPath)) {
sb.append(" and box.resSubPath=:resSubPath");
}
boolean hasBusinessGroups = businessGroups != null && businessGroups.size() > 0;
if (hasBusinessGroups) {
sb.append(" and ");
if (re != null) {
sb.append(" ( ");
}
sb.append(" check.identity.key in ( select membership.identity.key from bgroupmember membership ").append(" where membership.group in (:baseGroups) and membership.role='").append(GroupRole.participant).append("'").append(" )");
}
if (re != null) {
if (hasBusinessGroups) {
sb.append(" or ");
} else {
sb.append(" and ");
}
sb.append(" check.identity.key in ( select membership.identity.key from repoentrytogroup as rel, bgroup as reBaseGroup, bgroupmember membership ").append(" where rel.entry.key=:repoKey and rel.group=reBaseGroup and membership.group=reBaseGroup and membership.role='").append(GroupRole.participant).append("'").append(" )");
if (hasBusinessGroups) {
sb.append(" ) ");
}
}
TypedQuery<DBCheck> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), DBCheck.class).setParameter("resName", ores.getResourceableTypeName()).setParameter("resId", ores.getResourceableId());
if (StringHelper.containsNonWhitespace(resSubPath)) {
query.setParameter("resSubPath", resSubPath);
}
if (hasBusinessGroups) {
List<Group> groups = new ArrayList<>(businessGroups.size());
for (BusinessGroup businessGroup : businessGroups) {
groups.add(businessGroup.getBaseGroup());
}
query.setParameter("baseGroups", groups);
}
if (re != null) {
query.setParameter("repoKey", re.getKey());
}
List<DBCheck> checks = query.getResultList();
Map<Long, AssessmentData> identToBox = new HashMap<Long, AssessmentData>();
for (DBCheck check : checks) {
AssessmentData data = identToBox.get(check.getIdentity().getKey());
if (data == null) {
data = new AssessmentData(check.getIdentity());
identToBox.put(check.getIdentity().getKey(), data);
}
data.getChecks().add(check);
}
return new ArrayList<AssessmentData>(identToBox.values());
}
Aggregations