use of org.olat.modules.coach.model.CourseStatEntry in project openolat by klemens.
the class CoachingDAO method getCoursesStatisticsNative.
protected List<CourseStatEntry> getCoursesStatisticsNative(Identity coach) {
Map<Long, CourseStatEntry> map = new HashMap<>();
boolean hasCourses = getCourses(coach, map);
if (hasCourses) {
getCoursesStatisticsUserInfosForCoach(coach, map);
getCoursesStatisticsUserInfosForOwner(coach, map);
getCoursesStatisticsStatements(coach, map);
for (Iterator<Map.Entry<Long, CourseStatEntry>> it = map.entrySet().iterator(); it.hasNext(); ) {
CourseStatEntry entry = it.next().getValue();
if (entry.getCountStudents() == 0) {
it.remove();
} else {
int notAttempted = entry.getCountStudents() - entry.getCountPassed() - entry.getCountFailed();
entry.setCountNotAttempted(notAttempted);
}
}
}
return new ArrayList<>(map.values());
}
use of org.olat.modules.coach.model.CourseStatEntry in project openolat by klemens.
the class CourseListController method previousCourse.
private void previousCourse(UserRequest ureq) {
CourseStatEntry currentEntry = courseCtrl.getEntry();
int previousIndex = tableCtr.getIndexOfSortedObject(currentEntry) - 1;
if (previousIndex < 0 || previousIndex >= tableCtr.getRowCount()) {
previousIndex = tableCtr.getRowCount() - 1;
}
CourseStatEntry previousEntry = (CourseStatEntry) tableCtr.getSortedObjectAt(previousIndex);
selectCourse(ureq, previousEntry);
}
use of org.olat.modules.coach.model.CourseStatEntry in project openolat by klemens.
the class CourseListController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == tableCtr) {
if (event instanceof TableEvent) {
TableEvent e = (TableEvent) event;
if ("select".equals(e.getActionId())) {
CourseStatEntry courseStat = (CourseStatEntry) tableCtr.getTableDataModel().getObject(e.getRowId());
selectCourse(ureq, courseStat);
}
}
} else if (source == courseCtrl) {
if (event == Event.CHANGED_EVENT) {
hasChanged = true;
} else if ("next.course".equals(event.getCommand())) {
nextCourse(ureq);
} else if ("previous.course".equals(event.getCommand())) {
previousCourse(ureq);
}
}
super.event(ureq, source, event);
}
use of org.olat.modules.coach.model.CourseStatEntry in project OpenOLAT by OpenOLAT.
the class CoachingLargeTest method getCoursesStatistics.
@Test
public void getCoursesStatistics() {
List<CourseStatEntry> courseStatEntries = coachingService.getCoursesStatistics(coach10);
Assert.assertNotNull(courseStatEntries);
List<Long> coachedCourses = coachToCourseMap.get(coach10.getKey());
Assert.assertNotNull(coachedCourses);
Assert.assertEquals(coachedCourses.size(), courseStatEntries.size());
List<Long> courseStatsKeys = new ArrayList<>();
for (CourseStatEntry statEntry : courseStatEntries) {
courseStatsKeys.add(statEntry.getRepoKey());
}
Assert.assertTrue(courseStatsKeys.containsAll(coachedCourses));
Assert.assertTrue(coachedCourses.containsAll(courseStatsKeys));
}
use of org.olat.modules.coach.model.CourseStatEntry in project OpenOLAT by OpenOLAT.
the class CoachingDAOTest method getStatistics_notAttempted.
/**
* 3 courses in the same business group
*
* @throws URISyntaxException
*/
@Test
public void getStatistics_notAttempted() throws URISyntaxException {
URL coachingCourseUrl = CoachingLargeTest.class.getResource("CoachingCourse.zip");
File coachingCourseFile = new File(coachingCourseUrl.toURI());
RepositoryEntry re1 = CourseFactory.deployCourseFromZIP(coachingCourseFile, UUID.randomUUID().toString(), 4);
RepositoryEntry re2 = CourseFactory.deployCourseFromZIP(coachingCourseFile, UUID.randomUUID().toString(), 4);
RepositoryEntry re3 = CourseFactory.deployCourseFromZIP(coachingCourseFile, UUID.randomUUID().toString(), 4);
dbInstance.commitAndCloseSession();
// members of courses
Identity coach = JunitTestHelper.createAndPersistIdentityAsAuthor("Coach-1-" + UUID.randomUUID());
repositoryService.addRole(coach, re1, GroupRoles.owner.name());
repositoryService.addRole(coach, re1, GroupRoles.coach.name());
repositoryService.addRole(coach, re2, GroupRoles.coach.name());
repositoryService.addRole(coach, re3, GroupRoles.coach.name());
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("Coaching-Part-1");
repositoryService.addRole(participant1, re2, GroupRoles.participant.name());
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("Coaching-Part-2");
repositoryService.addRole(participant2, re1, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// members of 2 groups
BusinessGroup group = businessGroupService.createBusinessGroup(coach, "Coaching-grp-1", "tg", null, null, false, false, re1);
businessGroupService.addResourceTo(group, re2);
businessGroupService.addResourceTo(group, re3);
businessGroupRelationDao.addRole(participant1, group, GroupRoles.participant.name());
businessGroupRelationDao.addRole(participant2, group, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// make statements participant 1
effManager.createUserEfficiencyStatement(new Date(), 6.0f, true, participant1, re1.getOlatResource());
effManager.createUserEfficiencyStatement(new Date(), 4.0f, false, participant1, re2.getOlatResource());
effManager.createUserEfficiencyStatement(new Date(), 2.0f, false, participant1, re3.getOlatResource());
// make statements participant 2
effManager.createUserEfficiencyStatement(new Date(), 6.0f, true, participant2, re1.getOlatResource());
effManager.createUserEfficiencyStatement(new Date(), null, null, participant2, re2.getOlatResource());
dbInstance.commitAndCloseSession();
// make user infos
userCourseInformationsManager.updateUserCourseInformations(re1.getOlatResource(), participant1);
userCourseInformationsManager.updateUserCourseInformations(re2.getOlatResource(), participant1);
userCourseInformationsManager.updateUserCourseInformations(re3.getOlatResource(), participant1);
userCourseInformationsManager.updateUserCourseInformations(re1.getOlatResource(), participant2);
userCourseInformationsManager.updateUserCourseInformations(re2.getOlatResource(), participant2);
dbInstance.commitAndCloseSession();
// check course
List<CourseStatEntry> nativeStats = coachingDAO.getCoursesStatisticsNative(coach);
Assert.assertNotNull(nativeStats);
Assert.assertEquals(3, nativeStats.size());
CourseStatEntry entryRe1 = getCourseStatEntry(re1, nativeStats);
Assert.assertEquals(2, entryRe1.getCountStudents());
Assert.assertEquals(2, entryRe1.getCountPassed());
Assert.assertEquals(0, entryRe1.getCountFailed());
Assert.assertEquals(0, entryRe1.getCountNotAttempted());
Assert.assertEquals(2, entryRe1.getInitialLaunch());
Assert.assertEquals(6.0f, entryRe1.getAverageScore(), 0.0001);
CourseStatEntry entryRe2 = getCourseStatEntry(re2, nativeStats);
Assert.assertEquals(2, entryRe2.getCountStudents());
Assert.assertEquals(0, entryRe2.getCountPassed());
Assert.assertEquals(1, entryRe2.getCountFailed());
Assert.assertEquals(1, entryRe2.getCountNotAttempted());
Assert.assertEquals(2, entryRe2.getInitialLaunch());
Assert.assertEquals(4.0f, entryRe2.getAverageScore(), 0.0001);
CourseStatEntry entryRe3 = getCourseStatEntry(re3, nativeStats);
Assert.assertEquals(2, entryRe3.getCountStudents());
Assert.assertEquals(0, entryRe3.getCountPassed());
Assert.assertEquals(1, entryRe3.getCountFailed());
Assert.assertEquals(1, entryRe3.getCountNotAttempted());
Assert.assertEquals(1, entryRe3.getInitialLaunch());
Assert.assertEquals(2.0f, entryRe3.getAverageScore(), 0.0001);
List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(UserListController.usageIdentifyer, false);
// user native
List<StudentStatEntry> nativeUserStats = coachingDAO.getStudentsStatisticsNative(coach, userPropertyHandlers);
Assert.assertNotNull(nativeUserStats);
Assert.assertEquals(2, nativeUserStats.size());
// participant1
StudentStatEntry entryParticipant1 = getStudentStatEntry(participant1, nativeUserStats);
Assert.assertNotNull(entryParticipant1);
Assert.assertEquals(1, entryParticipant1.getCountPassed());
Assert.assertEquals(2, entryParticipant1.getCountFailed());
Assert.assertEquals(0, entryParticipant1.getCountNotAttempted());
Assert.assertEquals(3, entryParticipant1.getInitialLaunch());
Assert.assertEquals(3, entryParticipant1.getCountRepo());
// participant2
StudentStatEntry entryParticipant2 = getStudentStatEntry(participant2, nativeUserStats);
Assert.assertNotNull(entryParticipant2);
Assert.assertEquals(1, entryParticipant2.getCountPassed());
Assert.assertEquals(0, entryParticipant2.getCountFailed());
Assert.assertEquals(2, entryParticipant2.getCountNotAttempted());
Assert.assertEquals(2, entryParticipant2.getInitialLaunch());
Assert.assertEquals(3, entryParticipant1.getCountRepo());
// group native
List<GroupStatEntry> nativeGroupStats = coachingDAO.getGroupsStatisticsNative(coach);
Assert.assertNotNull(nativeGroupStats);
Assert.assertEquals(1, nativeGroupStats.size());
// group 1
GroupStatEntry entryGroup1 = getGroupStatEntry(group, nativeGroupStats);
Assert.assertNotNull(entryGroup1);
Assert.assertEquals(6, entryGroup1.getCountStudents());
Assert.assertEquals(2, entryGroup1.getCountDistinctStudents());
Assert.assertEquals(3, entryGroup1.getCountCourses());
Assert.assertEquals(2, entryGroup1.getCountPassed());
Assert.assertEquals(2, entryGroup1.getCountFailed());
Assert.assertEquals(2, entryGroup1.getCountNotAttempted());
Assert.assertEquals(5, entryGroup1.getInitialLaunch());
Assert.assertEquals(4.5f, entryGroup1.getAverageScore(), 0.0001f);
}
Aggregations