use of org.olat.course.assessment.model.AssessmentStatistics in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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 AssessmentToolManagerTest method assessmentTool_coach.
@Test
public void assessmentTool_coach() {
// course
Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-author-1");
ICourse course = CoursesWebService.createEmptyCourse(author, "course-assessment-tool", "course long name", null);
// members as participant and coach
Identity assessedIdentity1 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-1");
Identity assessedIdentity2 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-2");
Identity assessedIdentity3 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-3");
Identity assessedIdentity4 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-4");
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-coach-1");
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
RepositoryEntry refEntry = JunitTestHelper.createAndPersistRepositoryEntry();
String subIdent = UUID.randomUUID().toString();
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "assessment-tool-bg-1", "assessment-tool-bg-1-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRelationToResource(group1, entry);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "assessment-tool-bg-2", "assessment-tool-bg-2-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRelationToResource(group2, entry);
businessGroupRelationDao.addRole(assessedIdentity1, group1, GroupRoles.participant.name());
businessGroupRelationDao.addRole(assessedIdentity2, group1, GroupRoles.participant.name());
businessGroupRelationDao.addRole(assessedIdentity3, group2, GroupRoles.participant.name());
businessGroupRelationDao.addRole(coach, group1, GroupRoles.coach.name());
dbInstance.commitAndCloseSession();
// some datas
assessmentEntryDao.createAssessmentEntry(assessedIdentity1, null, entry, subIdent, refEntry, 3.0f, Boolean.FALSE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, entry, subIdent, refEntry, 5.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedIdentity3, null, entry, subIdent, refEntry, 8.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedIdentity4, null, entry, subIdent, refEntry, 9.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(null, UUID.randomUUID().toString(), entry, subIdent, refEntry);
dbInstance.commitAndCloseSession();
// coach of group 1 with id 1 and id2
List<BusinessGroup> coachedGroups = Collections.singletonList(group1);
AssessmentToolSecurityCallback assessmentCallback = new AssessmentToolSecurityCallback(false, false, false, true, coachedGroups);
SearchAssessedIdentityParams params = new SearchAssessedIdentityParams(entry, subIdent, refEntry, assessmentCallback);
// statistics
AssessmentStatistics statistics = assessmentToolManager.getStatistics(coach, params);
Assert.assertEquals(4.0d, statistics.getAverageScore().doubleValue(), 0.0001);
Assert.assertEquals(1, statistics.getCountFailed());
Assert.assertEquals(1, statistics.getCountPassed());
// check assessed identities list
List<Identity> assessedIdentities = assessmentToolManager.getAssessedIdentities(coach, params);
Assert.assertNotNull(assessedIdentities);
Assert.assertEquals(2, assessedIdentities.size());
// number of assessed identities
int numOfAssessedIdentities = assessmentToolManager.getNumberOfAssessedIdentities(coach, params);
Assert.assertEquals(2, numOfAssessedIdentities);
// check only the queries
AssessmentMembersStatistics participantStatistics = assessmentToolManager.getNumberOfParticipants(coach, params);
Assert.assertNotNull(participantStatistics);
int numOfInitialLanches = assessmentToolManager.getNumberOfInitialLaunches(coach, params);
// not launched, only simulated
Assert.assertEquals(0, numOfInitialLanches);
List<IdentityShort> assessedShortIdentities = assessmentToolManager.getShortAssessedIdentities(coach, params, 120);
Assert.assertNotNull(assessedShortIdentities);
Assert.assertEquals(2, assessedShortIdentities.size());
List<AssessmentEntry> assessmentEntries = assessmentToolManager.getAssessmentEntries(coach, params, AssessmentEntryStatus.notStarted);
Assert.assertNotNull(assessmentEntries);
Assert.assertEquals(0, assessmentEntries.size());
// separate check with more options in the search parameters
// add by group key
params.setBusinessGroupKeys(Collections.singletonList(group1.getKey()));
// assessed groups
List<AssessedBusinessGroup> assessedGroups = assessmentToolManager.getBusinessGroupStatistics(coach, params);
Assert.assertNotNull(assessedGroups);
Assert.assertEquals(1, assessedGroups.size());
// check assessed identities list
List<Identity> assessedIdentitiesAlt = assessmentToolManager.getAssessedIdentities(coach, params);
Assert.assertNotNull(assessedIdentitiesAlt);
Assert.assertEquals(2, assessedIdentitiesAlt.size());
// number of assessed identities
int numOfAssessedIdentitiesAlt = assessmentToolManager.getNumberOfAssessedIdentities(coach, params);
Assert.assertEquals(2, numOfAssessedIdentitiesAlt);
List<IdentityShort> assessedShortIdentitiesAlt = assessmentToolManager.getShortAssessedIdentities(coach, params, 120);
Assert.assertNotNull(assessedShortIdentitiesAlt);
Assert.assertEquals(2, assessedShortIdentitiesAlt.size());
List<AssessmentEntry> assessmentEntriesAlt = assessmentToolManager.getAssessmentEntries(coach, params, AssessmentEntryStatus.notStarted);
Assert.assertNotNull(assessmentEntriesAlt);
Assert.assertEquals(0, assessmentEntriesAlt.size());
}
use of org.olat.course.assessment.model.AssessmentStatistics in project OpenOLAT by OpenOLAT.
the class AssessmentToolManagerTest method assessmentTool_coach.
@Test
public void assessmentTool_coach() {
// course
Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-author-1");
ICourse course = CoursesWebService.createEmptyCourse(author, "course-assessment-tool", "course long name", null);
// members as participant and coach
Identity assessedIdentity1 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-1");
Identity assessedIdentity2 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-2");
Identity assessedIdentity3 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-3");
Identity assessedIdentity4 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-4");
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-coach-1");
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
RepositoryEntry refEntry = JunitTestHelper.createAndPersistRepositoryEntry();
String subIdent = UUID.randomUUID().toString();
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "assessment-tool-bg-1", "assessment-tool-bg-1-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRelationToResource(group1, entry);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "assessment-tool-bg-2", "assessment-tool-bg-2-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRelationToResource(group2, entry);
businessGroupRelationDao.addRole(assessedIdentity1, group1, GroupRoles.participant.name());
businessGroupRelationDao.addRole(assessedIdentity2, group1, GroupRoles.participant.name());
businessGroupRelationDao.addRole(assessedIdentity3, group2, GroupRoles.participant.name());
businessGroupRelationDao.addRole(coach, group1, GroupRoles.coach.name());
dbInstance.commitAndCloseSession();
// some datas
assessmentEntryDao.createAssessmentEntry(assessedIdentity1, null, entry, subIdent, refEntry, 3.0f, Boolean.FALSE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, entry, subIdent, refEntry, 5.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedIdentity3, null, entry, subIdent, refEntry, 8.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedIdentity4, null, entry, subIdent, refEntry, 9.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(null, UUID.randomUUID().toString(), entry, subIdent, refEntry);
dbInstance.commitAndCloseSession();
// coach of group 1 with id 1 and id2
List<BusinessGroup> coachedGroups = Collections.singletonList(group1);
AssessmentToolSecurityCallback assessmentCallback = new AssessmentToolSecurityCallback(false, false, false, true, coachedGroups);
SearchAssessedIdentityParams params = new SearchAssessedIdentityParams(entry, subIdent, refEntry, assessmentCallback);
// statistics
AssessmentStatistics statistics = assessmentToolManager.getStatistics(coach, params);
Assert.assertEquals(4.0d, statistics.getAverageScore().doubleValue(), 0.0001);
Assert.assertEquals(1, statistics.getCountFailed());
Assert.assertEquals(1, statistics.getCountPassed());
// check assessed identities list
List<Identity> assessedIdentities = assessmentToolManager.getAssessedIdentities(coach, params);
Assert.assertNotNull(assessedIdentities);
Assert.assertEquals(2, assessedIdentities.size());
// number of assessed identities
int numOfAssessedIdentities = assessmentToolManager.getNumberOfAssessedIdentities(coach, params);
Assert.assertEquals(2, numOfAssessedIdentities);
// check only the queries
AssessmentMembersStatistics participantStatistics = assessmentToolManager.getNumberOfParticipants(coach, params);
Assert.assertNotNull(participantStatistics);
int numOfInitialLanches = assessmentToolManager.getNumberOfInitialLaunches(coach, params);
// not launched, only simulated
Assert.assertEquals(0, numOfInitialLanches);
List<IdentityShort> assessedShortIdentities = assessmentToolManager.getShortAssessedIdentities(coach, params, 120);
Assert.assertNotNull(assessedShortIdentities);
Assert.assertEquals(2, assessedShortIdentities.size());
List<AssessmentEntry> assessmentEntries = assessmentToolManager.getAssessmentEntries(coach, params, AssessmentEntryStatus.notStarted);
Assert.assertNotNull(assessmentEntries);
Assert.assertEquals(0, assessmentEntries.size());
// separate check with more options in the search parameters
// add by group key
params.setBusinessGroupKeys(Collections.singletonList(group1.getKey()));
// assessed groups
List<AssessedBusinessGroup> assessedGroups = assessmentToolManager.getBusinessGroupStatistics(coach, params);
Assert.assertNotNull(assessedGroups);
Assert.assertEquals(1, assessedGroups.size());
// check assessed identities list
List<Identity> assessedIdentitiesAlt = assessmentToolManager.getAssessedIdentities(coach, params);
Assert.assertNotNull(assessedIdentitiesAlt);
Assert.assertEquals(2, assessedIdentitiesAlt.size());
// number of assessed identities
int numOfAssessedIdentitiesAlt = assessmentToolManager.getNumberOfAssessedIdentities(coach, params);
Assert.assertEquals(2, numOfAssessedIdentitiesAlt);
List<IdentityShort> assessedShortIdentitiesAlt = assessmentToolManager.getShortAssessedIdentities(coach, params, 120);
Assert.assertNotNull(assessedShortIdentitiesAlt);
Assert.assertEquals(2, assessedShortIdentitiesAlt.size());
List<AssessmentEntry> assessmentEntriesAlt = assessmentToolManager.getAssessmentEntries(coach, params, AssessmentEntryStatus.notStarted);
Assert.assertNotNull(assessmentEntriesAlt);
Assert.assertEquals(0, assessmentEntriesAlt.size());
}
use of org.olat.course.assessment.model.AssessmentStatistics in project OpenOLAT by OpenOLAT.
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