Search in sources :

Example 21 with StudentStatEntry

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());
}
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 22 with StudentStatEntry

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;
            }
        }
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) ContextEntry(org.olat.core.id.context.ContextEntry) StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry)

Example 23 with StudentStatEntry

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);
}
Also used : StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry)

Example 24 with StudentStatEntry

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);
}
Also used : StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry)

Example 25 with StudentStatEntry

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);
}
Also used : StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry)

Aggregations

StudentStatEntry (org.olat.modules.coach.model.StudentStatEntry)46 Test (org.junit.Test)16 File (java.io.File)14 URL (java.net.URL)14 Identity (org.olat.core.id.Identity)14 BusinessGroup (org.olat.group.BusinessGroup)14 CoachingLargeTest (org.olat.modules.coach.CoachingLargeTest)14 RepositoryEntry (org.olat.repository.RepositoryEntry)14 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)14 CourseStatEntry (org.olat.modules.coach.model.CourseStatEntry)12 GroupStatEntry (org.olat.modules.coach.model.GroupStatEntry)12 Date (java.util.Date)10 HashMap (java.util.HashMap)10 NativeQueryBuilder (org.olat.core.commons.persistence.NativeQueryBuilder)10 Map (java.util.Map)4 Query (javax.persistence.Query)4 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)4 SearchCoachedIdentityParams (org.olat.modules.coach.model.SearchCoachedIdentityParams)4 ArrayList (java.util.ArrayList)2 FlexiTableSearchEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)2