Search in sources :

Example 1 with SearchCoachedIdentityParams

use of org.olat.modules.coach.model.SearchCoachedIdentityParams in project OpenOLAT by OpenOLAT.

the class CoachingLargeTest method getUsersStatistics.

@Test
public void getUsersStatistics() {
    SearchCoachedIdentityParams params = new SearchCoachedIdentityParams();
    params.setLogin(aStudent.getName());
    List<StudentStatEntry> statEntries = coachingService.getUsersStatistics(params, userPropertyHandlers);
    Assert.assertNotNull(statEntries);
    Assert.assertEquals(1, statEntries.size());
    StudentStatEntry statEntry = statEntries.get(0);
    Assert.assertEquals(aStudent.getKey(), statEntry.getIdentityKey());
    Assert.assertEquals(studentToCourseMap.get(aStudent).size(), statEntry.getCountRepo());
}
Also used : SearchCoachedIdentityParams(org.olat.modules.coach.model.SearchCoachedIdentityParams) StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry) Test(org.junit.Test)

Example 2 with SearchCoachedIdentityParams

use of org.olat.modules.coach.model.SearchCoachedIdentityParams 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());
}
Also used : User(org.olat.core.id.User) BusinessGroup(org.olat.group.BusinessGroup) HashMap(java.util.HashMap) RepositoryEntry(org.olat.repository.RepositoryEntry) URL(java.net.URL) Date(java.util.Date) StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry) SearchCoachedIdentityParams(org.olat.modules.coach.model.SearchCoachedIdentityParams) Identity(org.olat.core.id.Identity) File(java.io.File) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) CoachingLargeTest(org.olat.modules.coach.CoachingLargeTest) Test(org.junit.Test)

Example 3 with SearchCoachedIdentityParams

use of org.olat.modules.coach.model.SearchCoachedIdentityParams 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());
}
Also used : User(org.olat.core.id.User) BusinessGroup(org.olat.group.BusinessGroup) HashMap(java.util.HashMap) RepositoryEntry(org.olat.repository.RepositoryEntry) URL(java.net.URL) Date(java.util.Date) StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry) SearchCoachedIdentityParams(org.olat.modules.coach.model.SearchCoachedIdentityParams) Identity(org.olat.core.id.Identity) File(java.io.File) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) CoachingLargeTest(org.olat.modules.coach.CoachingLargeTest) Test(org.junit.Test)

Example 4 with SearchCoachedIdentityParams

use of org.olat.modules.coach.model.SearchCoachedIdentityParams in project OpenOLAT by OpenOLAT.

the class UserSearchController method doSearchByIdentityKey.

private void doSearchByIdentityKey(UserRequest ureq, Long identityKey) {
    SearchCoachedIdentityParams params = new SearchCoachedIdentityParams();
    params.setIdentityKey(identityKey);
    userListCtrl = new UserListController(ureq, getWindowControl(), stackPanel);
    userListCtrl.search(params);
    if (userListCtrl.size() == 1) {
        userListCtrl.selectUniqueStudent(ureq);
        stackPanel.pushController("Result", userListCtrl);
    } else {
        stackPanel.pushController("Results", userListCtrl);
    }
}
Also used : SearchCoachedIdentityParams(org.olat.modules.coach.model.SearchCoachedIdentityParams)

Example 5 with SearchCoachedIdentityParams

use of org.olat.modules.coach.model.SearchCoachedIdentityParams in project OpenOLAT by OpenOLAT.

the class UserSearchController method doSearch.

private void doSearch(UserRequest ureq) {
    String login = searchForm.getLogin();
    boolean onlyActive = searchForm.isOnlyActive();
    Map<String, String> searchProps = searchForm.getSearchProperties();
    SearchCoachedIdentityParams params = new SearchCoachedIdentityParams();
    params.setLogin(login);
    params.setUserProperties(searchProps);
    if (onlyActive) {
        params.setStatus(Identity.STATUS_VISIBLE_LIMIT);
    }
    userListCtrl = new UserListController(ureq, getWindowControl(), stackPanel);
    userListCtrl.search(params);
    listenTo(userListCtrl);
    stackPanel.popUpToRootController(ureq);
    stackPanel.pushController(translate("results"), userListCtrl);
}
Also used : SearchCoachedIdentityParams(org.olat.modules.coach.model.SearchCoachedIdentityParams)

Aggregations

SearchCoachedIdentityParams (org.olat.modules.coach.model.SearchCoachedIdentityParams)8 Test (org.junit.Test)4 StudentStatEntry (org.olat.modules.coach.model.StudentStatEntry)4 File (java.io.File)2 URL (java.net.URL)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Identity (org.olat.core.id.Identity)2 User (org.olat.core.id.User)2 BusinessGroup (org.olat.group.BusinessGroup)2 CoachingLargeTest (org.olat.modules.coach.CoachingLargeTest)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)2