use of org.olat.course.assessment.model.AssessedBusinessGroup in project OpenOLAT by OpenOLAT.
the class AssessmentToolManagerImpl method getBusinessGroupStatistics.
@Override
public List<AssessedBusinessGroup> getBusinessGroupStatistics(Identity coach, SearchAssessedIdentityParams params) {
RepositoryEntry courseEntry = params.getEntry();
StringBuilder sf = new StringBuilder();
sf.append("select bgi.key, bgi.name, baseGroup.key,").append(" avg(aentry.score) as scoreAverage,").append(" sum(case when aentry.passed=true then 1 else 0 end) as numOfPassed,").append(" sum(case when aentry.passed=false then 1 else 0 end) as numOfFailed,").append(" sum(case when (aentry.status is null or not(aentry.status='").append(AssessmentEntryStatus.notStarted.name()).append("') or aentry.passed is null) then 1 else 0 end) as numOfNotAttempted,").append(" (select count(gmember.key) from bgroupmember as gmember").append(" where gmember.group.key=baseGroup.key and gmember.role='").append(GroupRoles.participant.name()).append("'").append(" ) as numOfParticipants").append(" from businessgroup as bgi").append(" inner join bgi.baseGroup as baseGroup").append(" inner join repoentrytogroup as rel on (rel.group.key=bgi.baseGroup.key and rel.entry.key=:repoEntryKey)").append(" left join baseGroup.members as bmember on (bmember.role='").append(GroupRoles.participant.name()).append("')").append(" left join assessmententry as aentry on (bmember.identity.key=aentry.identity.key and rel.entry.key = aentry.repositoryEntry.key)");
boolean where = false;
if (!params.isAdmin()) {
where = PersistenceHelper.appendAnd(sf, where);
sf.append(" bgi.key in (:groupKeys)");
}
if (params.getSubIdent() != null) {
where = PersistenceHelper.appendAnd(sf, where);
sf.append(" aentry.subIdent=:subIdent");
}
if (params.getReferenceEntry() != null) {
where = PersistenceHelper.appendAnd(sf, where);
sf.append(" aentry.referenceEntry.key=:referenceKey");
}
sf.append(" group by bgi.key, bgi.name, baseGroup.key");
TypedQuery<Object[]> stats = dbInstance.getCurrentEntityManager().createQuery(sf.toString(), Object[].class).setParameter("repoEntryKey", courseEntry.getKey());
if (!params.isAdmin()) {
stats.setParameter("groupKeys", params.getBusinessGroupKeys());
}
if (params.getSubIdent() != null) {
stats.setParameter("subIdent", params.getSubIdent());
}
if (params.getReferenceEntry() != null) {
stats.setParameter("referenceKey", params.getReferenceEntry().getKey());
}
List<Object[]> results = stats.getResultList();
List<AssessedBusinessGroup> rows = new ArrayList<>(results.size());
for (Object[] result : results) {
Long key = (Long) result[0];
String name = (String) result[1];
double averageScore = result[3] == null ? 0.0d : ((Number) result[3]).doubleValue();
int numOfPassed = result[4] == null ? 0 : ((Number) result[4]).intValue();
int numOfFailed = result[5] == null ? 0 : ((Number) result[5]).intValue();
int numOfNotAttempted = result[6] == null ? 0 : ((Number) result[6]).intValue();
int numOfParticipants = result[7] == null ? 0 : ((Number) result[7]).intValue();
rows.add(new AssessedBusinessGroup(key, name, averageScore, numOfPassed, numOfFailed, numOfNotAttempted, numOfParticipants));
}
return rows;
}
use of org.olat.course.assessment.model.AssessedBusinessGroup in project OpenOLAT by OpenOLAT.
the class AssessedBusinessGroupCourseNodeListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (tableEl == source) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
String cmd = se.getCommand();
AssessedBusinessGroup row = tableModel.getObject(se.getIndex());
if ("select".equals(cmd)) {
doSelect(ureq, row);
}
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.course.assessment.model.AssessedBusinessGroup in project openolat by klemens.
the class AssessmentToolManagerImpl method getBusinessGroupStatistics.
@Override
public List<AssessedBusinessGroup> getBusinessGroupStatistics(Identity coach, SearchAssessedIdentityParams params) {
RepositoryEntry courseEntry = params.getEntry();
StringBuilder sf = new StringBuilder();
sf.append("select bgi.key, bgi.name, baseGroup.key,").append(" avg(aentry.score) as scoreAverage,").append(" sum(case when aentry.passed=true then 1 else 0 end) as numOfPassed,").append(" sum(case when aentry.passed=false then 1 else 0 end) as numOfFailed,").append(" sum(case when (aentry.status is null or not(aentry.status='").append(AssessmentEntryStatus.notStarted.name()).append("') or aentry.passed is null) then 1 else 0 end) as numOfNotAttempted,").append(" (select count(gmember.key) from bgroupmember as gmember").append(" where gmember.group.key=baseGroup.key and gmember.role='").append(GroupRoles.participant.name()).append("'").append(" ) as numOfParticipants").append(" from businessgroup as bgi").append(" inner join bgi.baseGroup as baseGroup").append(" inner join repoentrytogroup as rel on (rel.group.key=bgi.baseGroup.key and rel.entry.key=:repoEntryKey)").append(" left join baseGroup.members as bmember on (bmember.role='").append(GroupRoles.participant.name()).append("')").append(" left join assessmententry as aentry on (bmember.identity.key=aentry.identity.key and rel.entry.key = aentry.repositoryEntry.key)");
boolean where = false;
if (!params.isAdmin()) {
where = PersistenceHelper.appendAnd(sf, where);
sf.append(" bgi.key in (:groupKeys)");
}
if (params.getSubIdent() != null) {
where = PersistenceHelper.appendAnd(sf, where);
sf.append(" aentry.subIdent=:subIdent");
}
if (params.getReferenceEntry() != null) {
where = PersistenceHelper.appendAnd(sf, where);
sf.append(" aentry.referenceEntry.key=:referenceKey");
}
sf.append(" group by bgi.key, bgi.name, baseGroup.key");
TypedQuery<Object[]> stats = dbInstance.getCurrentEntityManager().createQuery(sf.toString(), Object[].class).setParameter("repoEntryKey", courseEntry.getKey());
if (!params.isAdmin()) {
stats.setParameter("groupKeys", params.getBusinessGroupKeys());
}
if (params.getSubIdent() != null) {
stats.setParameter("subIdent", params.getSubIdent());
}
if (params.getReferenceEntry() != null) {
stats.setParameter("referenceKey", params.getReferenceEntry().getKey());
}
List<Object[]> results = stats.getResultList();
List<AssessedBusinessGroup> rows = new ArrayList<>(results.size());
for (Object[] result : results) {
Long key = (Long) result[0];
String name = (String) result[1];
double averageScore = result[3] == null ? 0.0d : ((Number) result[3]).doubleValue();
int numOfPassed = result[4] == null ? 0 : ((Number) result[4]).intValue();
int numOfFailed = result[5] == null ? 0 : ((Number) result[5]).intValue();
int numOfNotAttempted = result[6] == null ? 0 : ((Number) result[6]).intValue();
int numOfParticipants = result[7] == null ? 0 : ((Number) result[7]).intValue();
rows.add(new AssessedBusinessGroup(key, name, averageScore, numOfPassed, numOfFailed, numOfNotAttempted, numOfParticipants));
}
return rows;
}
use of org.olat.course.assessment.model.AssessedBusinessGroup in project openolat by klemens.
the class AssessedBusinessGroupCourseNodeListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (tableEl == source) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
String cmd = se.getCommand();
AssessedBusinessGroup row = tableModel.getObject(se.getIndex());
if ("select".equals(cmd)) {
doSelect(ureq, row);
}
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.course.assessment.model.AssessedBusinessGroup in project openolat by klemens.
the class AssessedBusinessGroupCourseNodeListController method loadModel.
protected void loadModel() {
if (assessmentCallback.canAssessBusinessGoupMembers()) {
RepositoryEntry testEntry = null;
if (courseNode.needsReferenceToARepositoryEntry()) {
testEntry = courseNode.getReferencedRepositoryEntry();
}
SearchAssessedIdentityParams params = new SearchAssessedIdentityParams(courseEntry, courseNode.getIdent(), testEntry, assessmentCallback);
if (assessmentCallback.getCoachedGroups() != null) {
List<Long> groupKeys = assessmentCallback.getCoachedGroups().stream().map(c -> c.getKey()).collect(Collectors.toList());
params.setBusinessGroupKeys(groupKeys);
}
List<AssessedBusinessGroup> rows = assessmentToolManager.getBusinessGroupStatistics(getIdentity(), params);
Set<Long> keys = rows.stream().map(c -> c.getKey()).collect(Collectors.toSet());
List<BusinessGroup> groups;
if (assessmentCallback.isAdmin()) {
CourseEnvironment courseEnv = CourseFactory.loadCourse(courseEntry).getCourseEnvironment();
groups = courseEnv.getCourseGroupManager().getAllBusinessGroups();
} else if (assessmentCallback.getCoachedGroups() != null) {
groups = assessmentCallback.getCoachedGroups();
} else {
groups = Collections.emptyList();
}
for (BusinessGroup group : groups) {
if (!keys.contains(group.getKey())) {
rows.add(new AssessedBusinessGroup(group.getKey(), group.getName(), 0.0d, 0, 0, 0, 0));
}
}
tableModel.setObjects(rows);
tableEl.reset();
tableEl.reloadData();
}
}
Aggregations