use of org.olat.course.assessment.model.AssessmentStatistics in project openolat by klemens.
the class AssessmentToolManagerImpl method getStatistics.
@Override
public AssessmentStatistics getStatistics(Identity coach, SearchAssessedIdentityParams params) {
RepositoryEntry courseEntry = params.getEntry();
StringBuilder sf = new StringBuilder();
sf.append("select 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(" v.key as repoKey").append(" from assessmententry aentry ").append(" inner join aentry.repositoryEntry v ").append(" where v.key=:repoEntryKey");
if (params.getReferenceEntry() != null) {
sf.append(" and aentry.referenceEntry.key=:referenceKey");
}
if (params.getSubIdent() != null) {
sf.append(" and aentry.subIdent=:subIdent");
}
sf.append(" and (aentry.identity in");
if (params.isAdmin()) {
sf.append(" (select participant.identity from repoentrytogroup as rel, bgroupmember as participant").append(" where rel.entry.key=:repoEntryKey and rel.group=participant.group").append(" and participant.role='").append(GroupRoles.participant.name()).append("'").append(" )");
if (params.isNonMembers()) {
sf.append(" or aentry.identity not in (select membership.identity from repoentrytogroup as rel, bgroupmember as membership").append(" where rel.entry.key=:repoEntryKey and rel.group=membership.group and membership.identity=aentry.identity").append(" )");
}
} else if (params.isBusinessGroupCoach() || params.isRepositoryEntryCoach()) {
sf.append(" (select participant.identity from repoentrytogroup as rel, bgroupmember as participant, bgroupmember as coach").append(" where rel.entry.key=:repoEntryKey").append(" and rel.group=coach.group and coach.role='").append(GroupRoles.coach.name()).append("' and coach.identity.key=:identityKey").append(" and rel.group=participant.group and participant.role='").append(GroupRoles.participant.name()).append("'").append(" )");
}
sf.append(" ) group by v.key");
TypedQuery<Object[]> stats = dbInstance.getCurrentEntityManager().createQuery(sf.toString(), Object[].class).setParameter("repoEntryKey", courseEntry.getKey());
if (!params.isAdmin()) {
stats.setParameter("identityKey", coach.getKey());
}
if (params.getReferenceEntry() != null) {
stats.setParameter("referenceKey", params.getReferenceEntry().getKey());
}
if (params.getSubIdent() != null) {
stats.setParameter("subIdent", params.getSubIdent());
}
AssessmentStatistics entry = new AssessmentStatistics();
List<Object[]> results = stats.getResultList();
if (results != null && results.size() > 0) {
Object[] result = results.get(0);
Double averageScore = (Double) result[0];
Long numOfPassed = (Long) result[1];
Long numOfFailed = (Long) result[2];
entry.setAverageScore(averageScore);
entry.setCountPassed(numOfPassed == null ? 0 : numOfPassed.intValue());
entry.setCountFailed(numOfFailed == null ? 0 : numOfFailed.intValue());
}
return entry;
}
use of org.olat.course.assessment.model.AssessmentStatistics in project openolat by klemens.
the class AssessmentCourseStatisticsSmallController method updateStatistics.
public void updateStatistics() {
ICourse course = CourseFactory.loadCourse(courseEntry);
String rootNodeIdent = course.getRunStructure().getRootNode().getIdent();
SearchAssessedIdentityParams params = new SearchAssessedIdentityParams(courseEntry, rootNodeIdent, null, assessmentCallback);
numOfAssessedIdentities = assessmentToolManager.getNumberOfAssessedIdentities(getIdentity(), params);
mainVC.contextPut("numOfAssessedIdentities", numOfAssessedIdentities);
memberStatistics = assessmentToolManager.getNumberOfParticipants(getIdentity(), params);
mainVC.contextPut("numOfParticipants", memberStatistics.getNumOfParticipants());
if (assessmentCallback.canAssessNonMembers()) {
mainVC.contextPut("numOfOtherUsers", memberStatistics.getNumOfOtherUsers());
}
AssessmentStatistics stats = assessmentToolManager.getStatistics(getIdentity(), params);
mainVC.contextPut("scoreAverage", AssessmentHelper.getRoundedScore(stats.getAverageScore()));
numOfPassed = stats.getCountPassed();
mainVC.contextPut("numOfPassed", numOfPassed);
int total = memberStatistics.getTotal();
int percentPassed = total == 0 ? 0 : Math.round(100.0f * (stats.getCountPassed() / total));
mainVC.contextPut("percentPassed", percentPassed);
numOfFailed = stats.getCountFailed();
mainVC.contextPut("numOfFailed", numOfFailed);
int percentFailed = total == 0 ? 0 : Math.round(100.0f * (stats.getCountFailed() / total));
mainVC.contextPut("percentFailed", percentFailed);
int numOfParticipantLaunches = memberStatistics.getNumOfParticipantsLoggedIn();
mainVC.contextPut("numOfParticipantLaunches", numOfParticipantLaunches);
if (assessmentCallback.canAssessNonMembers()) {
int numOfOtherUserLaunches = memberStatistics.getLoggedIn();
mainVC.contextPut("numOfOtherUserLaunches", numOfOtherUserLaunches);
}
}
use of org.olat.course.assessment.model.AssessmentStatistics in project openolat by klemens.
the class AssessmentStatisticsSmallController method updateStatistics.
public void updateStatistics() {
SearchAssessedIdentityParams params = new SearchAssessedIdentityParams(testEntry, null, testEntry, assessmentCallback);
numOfAssessedIdentities = assessmentToolManager.getNumberOfAssessedIdentities(getIdentity(), params);
mainVC.contextPut("numOfAssessedIdentities", numOfAssessedIdentities);
membersStatistics = assessmentToolManager.getNumberOfParticipants(getIdentity(), params);
mainVC.contextPut("numOfParticipants", membersStatistics.getNumOfParticipants());
if (assessmentCallback.canAssessNonMembers()) {
mainVC.contextPut("numOfOtherUsers", membersStatistics.getNumOfOtherUsers());
}
AssessmentStatistics stats = assessmentToolManager.getStatistics(getIdentity(), params);
mainVC.contextPut("scoreAverage", AssessmentHelper.getRoundedScore(stats.getAverageScore()));
numOfPassed = stats.getCountPassed();
mainVC.contextPut("numOfPassed", numOfPassed);
int total = membersStatistics.getTotal();
int percentPassed = total <= 0 ? 0 : Math.round(100.0f * (stats.getCountPassed() / total));
mainVC.contextPut("percentPassed", percentPassed);
numOfFailed = stats.getCountFailed();
mainVC.contextPut("numOfFailed", numOfFailed);
int percentFailed = total <= 0 ? 0 : Math.round(100.0f * (stats.getCountFailed() / total));
mainVC.contextPut("percentFailed", percentFailed);
int numOfParticipantLaunches = membersStatistics.getNumOfParticipantsLoggedIn();
mainVC.contextPut("numOfParticipantLaunches", numOfParticipantLaunches);
if (assessmentCallback.canAssessNonMembers()) {
mainVC.contextPut("numOfOtherUserLaunches", membersStatistics.getLoggedIn());
}
}
Aggregations