use of org.olat.modules.coach.model.StudentStatEntry in project OpenOLAT by OpenOLAT.
the class CoachingDAOTest method getUsers.
@Test
public void getUsers() 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 participant = JunitTestHelper.createAndPersistIdentityAsRndUser("User-Part-1");
repositoryService.addRole(participant, re1, GroupRoles.participant.name());
repositoryService.addRole(participant, re2, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// groups
BusinessGroup group2 = businessGroupService.createBusinessGroup(null, "Coaching-grp-1", "tg", null, null, false, false, re2);
businessGroupRelationDao.addRole(participant, group2, GroupRoles.participant.name());
BusinessGroup group3 = businessGroupService.createBusinessGroup(null, "Coaching-grp-1", "tg", null, null, false, false, re3);
businessGroupRelationDao.addRole(participant, group3, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// make statements participant 1
effManager.createUserEfficiencyStatement(new Date(), 6.0f, true, participant, re1.getOlatResource());
effManager.createUserEfficiencyStatement(new Date(), 4.0f, false, participant, re2.getOlatResource());
effManager.createUserEfficiencyStatement(new Date(), 2.0f, false, participant, re3.getOlatResource());
dbInstance.commitAndCloseSession();
// make user infos
userCourseInformationsManager.updateUserCourseInformations(re1.getOlatResource(), participant);
userCourseInformationsManager.updateUserCourseInformations(re2.getOlatResource(), participant);
userCourseInformationsManager.updateUserCourseInformations(re3.getOlatResource(), participant);
dbInstance.commitAndCloseSession();
// update props
User partUser = participant.getUser();
partUser.setProperty(UserConstants.FIRSTNAME, "Rei");
partUser.setProperty(UserConstants.LASTNAME, "Ayanami");
partUser.setProperty(UserConstants.EMAIL, "rei.ayanami@openolat.com");
partUser = userManager.updateUser(partUser);
dbInstance.commitAndCloseSession();
List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(UserListController.usageIdentifyer, false);
// search by first name
SearchCoachedIdentityParams params = new SearchCoachedIdentityParams();
Map<String, String> props = new HashMap<>();
props.put(UserConstants.FIRSTNAME, "re");
params.setUserProperties(props);
List<StudentStatEntry> stats = coachingDAO.getUsersStatisticsNative(params, userPropertyHandlers);
Assert.assertNotNull(stats);
Assert.assertFalse(stats.isEmpty());
// check participant
StudentStatEntry entryStat = getStudentStatEntry(participant, stats);
Assert.assertNotNull(entryStat);
Assert.assertEquals(3, entryStat.getCountRepo());
Assert.assertEquals(3, entryStat.getInitialLaunch());
Assert.assertEquals(1, entryStat.getCountPassed());
Assert.assertEquals(2, entryStat.getCountFailed());
Assert.assertEquals(0, entryStat.getCountNotAttempted());
// search by user name
SearchCoachedIdentityParams loginParams = new SearchCoachedIdentityParams();
loginParams.setLogin(participant.getName());
List<StudentStatEntry> loginStats = coachingDAO.getUsersStatisticsNative(loginParams, userPropertyHandlers);
Assert.assertNotNull(loginStats);
Assert.assertEquals(1, loginStats.size());
// check participant
StudentStatEntry loginStat = loginStats.get(0);
Assert.assertNotNull(loginStat);
Assert.assertEquals(3, loginStat.getCountRepo());
Assert.assertEquals(3, loginStat.getInitialLaunch());
Assert.assertEquals(1, loginStat.getCountPassed());
Assert.assertEquals(2, loginStat.getCountFailed());
Assert.assertEquals(0, loginStat.getCountNotAttempted());
}
use of org.olat.modules.coach.model.StudentStatEntry in project OpenOLAT by OpenOLAT.
the class StudentListController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty())
return;
ContextEntry ce = entries.get(0);
OLATResourceable ores = ce.getOLATResourceable();
if ("Identity".equals(ores.getResourceableTypeName())) {
Long identityKey = ores.getResourceableId();
for (StudentStatEntry entry : model.getObjects()) {
if (identityKey.equals(entry.getIdentityKey())) {
selectStudent(ureq, entry).activate(ureq, entries.subList(1, entries.size()), ce.getTransientState());
break;
}
}
}
}
use of org.olat.modules.coach.model.StudentStatEntry in project OpenOLAT by OpenOLAT.
the class StudentListController method previousStudent.
protected void previousStudent(UserRequest ureq) {
StudentStatEntry currentEntry = studentCtrl.getEntry();
int previousIndex = model.getObjects().indexOf(currentEntry) - 1;
if (previousIndex < 0 || previousIndex >= model.getRowCount()) {
previousIndex = model.getRowCount() - 1;
}
StudentStatEntry previousEntry = model.getObject(previousIndex);
selectStudent(ureq, previousEntry);
}
use of org.olat.modules.coach.model.StudentStatEntry in project OpenOLAT by OpenOLAT.
the class StudentListController method nextStudent.
protected void nextStudent(UserRequest ureq) {
StudentStatEntry currentEntry = studentCtrl.getEntry();
int nextIndex = model.getObjects().indexOf(currentEntry) + 1;
if (nextIndex < 0 || nextIndex >= model.getRowCount()) {
nextIndex = 0;
}
StudentStatEntry nextEntry = model.getObject(nextIndex);
selectStudent(ureq, nextEntry);
}
use of org.olat.modules.coach.model.StudentStatEntry in project OpenOLAT by OpenOLAT.
the class UserListController method previousStudent.
protected void previousStudent(UserRequest ureq) {
StudentStatEntry currentEntry = studentCtrl.getEntry();
int previousIndex = model.getObjects().indexOf(currentEntry) - 1;
if (previousIndex < 0 || previousIndex >= model.getRowCount()) {
previousIndex = model.getRowCount() - 1;
}
StudentStatEntry previousEntry = model.getObject(previousIndex);
selectStudent(ureq, previousEntry);
}
Aggregations