Search in sources :

Example 11 with CourseStatEntry

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());
}
Also used : CourseStatEntry(org.olat.modules.coach.model.CourseStatEntry) EfficiencyStatementEntry(org.olat.modules.coach.model.EfficiencyStatementEntry) RepositoryEntry(org.olat.repository.RepositoryEntry) StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry) CourseStatEntry(org.olat.modules.coach.model.CourseStatEntry) GroupStatEntry(org.olat.modules.coach.model.GroupStatEntry) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Example 12 with CourseStatEntry

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

Example 13 with CourseStatEntry

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);
}
Also used : CourseStatEntry(org.olat.modules.coach.model.CourseStatEntry) TableEvent(org.olat.core.gui.components.table.TableEvent)

Example 14 with CourseStatEntry

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));
}
Also used : CourseStatEntry(org.olat.modules.coach.model.CourseStatEntry) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 15 with CourseStatEntry

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);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) URL(java.net.URL) Date(java.util.Date) StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry) GroupStatEntry(org.olat.modules.coach.model.GroupStatEntry) CourseStatEntry(org.olat.modules.coach.model.CourseStatEntry) 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)

Aggregations

CourseStatEntry (org.olat.modules.coach.model.CourseStatEntry)32 Test (org.junit.Test)14 GroupStatEntry (org.olat.modules.coach.model.GroupStatEntry)14 StudentStatEntry (org.olat.modules.coach.model.StudentStatEntry)14 RepositoryEntry (org.olat.repository.RepositoryEntry)14 File (java.io.File)12 URL (java.net.URL)12 Identity (org.olat.core.id.Identity)12 BusinessGroup (org.olat.group.BusinessGroup)12 CoachingLargeTest (org.olat.modules.coach.CoachingLargeTest)12 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)12 Date (java.util.Date)8 NativeQueryBuilder (org.olat.core.commons.persistence.NativeQueryBuilder)8 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 ContextEntry (org.olat.core.id.context.ContextEntry)2 ICourse (org.olat.course.ICourse)2 EfficiencyStatementEntry (org.olat.modules.coach.model.EfficiencyStatementEntry)2