use of org.olat.user.propertyhandlers.UserPropertyHandler in project openolat by klemens.
the class CoachingDAOTest method testExtern.
/**
* To test performance against an external database ( of a customer ).
*/
@Test
@Ignore
public void testExtern() {
Identity coach = securityManager.loadIdentityByKey(46268418l);
List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(UserListController.usageIdentifyer, false);
if (coach != null) {
long start = System.nanoTime();
coachingDAO.getCoursesStatisticsNative(coach);
CodeHelper.printNanoTime(start, "Courses");
start = System.nanoTime();
coachingDAO.getGroupsStatisticsNative(coach);
CodeHelper.printNanoTime(start, "Groups");
start = System.nanoTime();
coachingDAO.getStudentsStatisticsNative(coach, userPropertyHandlers);
CodeHelper.printNanoTime(start, "Students");
}
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project openolat by klemens.
the class CoachingDAOTest method getStatistics_empty.
/**
* This is an important test to check if the return values of the statistics
* are correctly handled because some of them can be null or 0.
*
* @throws URISyntaxException
*/
@Test
public void getStatistics_empty() 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);
dbInstance.commitAndCloseSession();
// members of courses
Identity coach = JunitTestHelper.createAndPersistIdentityAsAuthor("Coach-1-" + UUID.randomUUID());
repositoryService.addRole(coach, re1, GroupRoles.owner.name());
repositoryService.addRole(coach, re2, GroupRoles.coach.name());
// groups
BusinessGroup group = businessGroupService.createBusinessGroup(null, "Coaching-grp-1", "tg", null, null, false, false, re1);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(group);
// groups (method doesn't return courses without participant)
List<GroupStatEntry> nativeGroupStats = coachingDAO.getGroupsStatisticsNative(coach);
Assert.assertNotNull(nativeGroupStats);
Assert.assertEquals(0, nativeGroupStats.size());
// courses (method doesn't return courses without participant)
List<CourseStatEntry> nativeCourseStats = coachingDAO.getCoursesStatisticsNative(coach);
Assert.assertNotNull(nativeCourseStats);
Assert.assertEquals(0, nativeCourseStats.size());
List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(UserListController.usageIdentifyer, false);
// user native
List<StudentStatEntry> nativeUserStats = coachingDAO.getStudentsStatisticsNative(coach, userPropertyHandlers);
Assert.assertNotNull(nativeUserStats);
Assert.assertEquals(0, nativeUserStats.size());
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project openolat by klemens.
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.user.propertyhandlers.UserPropertyHandler in project openolat by klemens.
the class CoachingDAOTest method getStatistics_duplicateInGroups.
/**
* 1 course with 2 groups.
*
* @throws URISyntaxException
*/
@Test
public void getStatistics_duplicateInGroups() throws URISyntaxException {
List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(UserListController.usageIdentifyer, false);
URL courseWithForumsUrl = CoachingLargeTest.class.getResource("CoachingCourse.zip");
File courseWithForums = new File(courseWithForumsUrl.toURI());
String softKey = UUID.randomUUID().toString();
RepositoryEntry re = CourseFactory.deployCourseFromZIP(courseWithForums, softKey, 4);
Assert.assertNotNull(re);
dbInstance.commitAndCloseSession();
ICourse course = CourseFactory.loadCourse(re);
boolean enabled = course.getCourseEnvironment().getCourseConfig().isEfficencyStatementEnabled();
Assert.assertTrue(enabled);
// re -> owner,coach, p1, p2
// -> group 1 p1
// -> group 2 p2
// members of courses
Identity coach = JunitTestHelper.createAndPersistIdentityAsAuthor("Coach-1-" + UUID.randomUUID());
repositoryService.addRole(coach, re, GroupRoles.owner.name());
repositoryService.addRole(coach, re, GroupRoles.coach.name());
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("Coaching-Part-1");
repositoryService.addRole(participant1, re, GroupRoles.participant.name());
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("Coaching-Part-2");
repositoryService.addRole(participant2, re, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// members of 2 groups
BusinessGroup group1 = businessGroupService.createBusinessGroup(coach, "Coaching-grp-1", "tg", null, null, false, false, re);
businessGroupRelationDao.addRole(participant1, group1, GroupRoles.participant.name());
BusinessGroup group2 = businessGroupService.createBusinessGroup(coach, "Coaching-grp-2", "tg", null, null, false, false, re);
businessGroupRelationDao.addRole(participant1, group2, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// make statements
effManager.createUserEfficiencyStatement(new Date(), 6.0f, true, participant1, re.getOlatResource());
effManager.createUserEfficiencyStatement(new Date(), 2.0f, false, participant2, re.getOlatResource());
dbInstance.commitAndCloseSession();
// make user infos
userCourseInformationsManager.updateUserCourseInformations(course.getCourseEnvironment().getCourseGroupManager().getCourseResource(), participant1);
dbInstance.commitAndCloseSession();
// native
List<CourseStatEntry> nativeStats = coachingDAO.getCoursesStatisticsNative(coach);
Assert.assertNotNull(nativeStats);
Assert.assertEquals(1, nativeStats.size());
CourseStatEntry nativeStat = nativeStats.get(0);
Assert.assertEquals(2, nativeStat.getCountStudents());
Assert.assertEquals(1, nativeStat.getCountPassed());
Assert.assertEquals(1, nativeStat.getCountFailed());
Assert.assertEquals(1, nativeStat.getInitialLaunch());
Assert.assertEquals(4.0f, nativeStat.getAverageScore(), 0.0001);
// 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(0, entryParticipant1.getCountFailed());
Assert.assertEquals(0, entryParticipant1.getCountNotAttempted());
Assert.assertEquals(1, entryParticipant1.getInitialLaunch());
// participant2
StudentStatEntry entryParticipant2 = getStudentStatEntry(participant2, nativeUserStats);
Assert.assertNotNull(entryParticipant2);
Assert.assertEquals(0, entryParticipant2.getCountPassed());
Assert.assertEquals(1, entryParticipant2.getCountFailed());
Assert.assertEquals(0, entryParticipant2.getCountNotAttempted());
Assert.assertEquals(0, entryParticipant2.getInitialLaunch());
// group native
List<GroupStatEntry> nativeGroupStats = coachingDAO.getGroupsStatisticsNative(coach);
Assert.assertNotNull(nativeGroupStats);
Assert.assertEquals(2, nativeGroupStats.size());
// group 1
GroupStatEntry entryGroup1 = getGroupStatEntry(group1, nativeGroupStats);
Assert.assertNotNull(entryGroup1);
Assert.assertEquals(1, entryGroup1.getCountCourses());
Assert.assertEquals(1, entryGroup1.getCountPassed());
Assert.assertEquals(0, entryGroup1.getCountFailed());
Assert.assertEquals(0, entryGroup1.getCountNotAttempted());
Assert.assertEquals(1, entryGroup1.getInitialLaunch());
Assert.assertEquals(6.0f, entryGroup1.getAverageScore(), 0.0001f);
// group 2
GroupStatEntry entryGroup2 = getGroupStatEntry(group1, nativeGroupStats);
Assert.assertNotNull(entryGroup2);
Assert.assertEquals(1, entryGroup2.getCountCourses());
Assert.assertEquals(1, entryGroup2.getCountPassed());
Assert.assertEquals(0, entryGroup2.getCountFailed());
Assert.assertEquals(0, entryGroup2.getCountNotAttempted());
Assert.assertEquals(1, entryGroup2.getInitialLaunch());
Assert.assertEquals(6.0f, entryGroup2.getAverageScore(), 0.0001f);
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project openolat by klemens.
the class ImportAuthorOverviewDataModel method getValueAt.
@Override
public Object getValueAt(int row, int col) {
Identity identity = getObject(row);
if (col == 0 && isAdministrativeUser) {
return identity.getName();
}
int pos = isAdministrativeUser ? col - 1 : col;
if (pos >= 0 && pos < userPropertyHandlers.size()) {
UserPropertyHandler handler = userPropertyHandlers.get(pos);
return handler.getUserProperty(identity.getUser(), locale);
}
return "";
}
Aggregations