Search in sources :

Example 11 with StudentStatEntry

use of org.olat.modules.coach.model.StudentStatEntry 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);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) ICourse(org.olat.course.ICourse) 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)

Example 12 with StudentStatEntry

use of org.olat.modules.coach.model.StudentStatEntry in project openolat by klemens.

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 13 with StudentStatEntry

use of org.olat.modules.coach.model.StudentStatEntry in project openolat by klemens.

the class StudentListProvider method getResult.

@Override
public void getResult(String searchValue, ListReceiver receiver) {
    int maxEntries = 10;
    boolean hasMore = false;
    searchValue = searchValue.toLowerCase();
    for (Iterator<StudentStatEntry> it_res = model.getObjects().iterator(); (hasMore = it_res.hasNext()) && maxEntries > 0; ) {
        StudentStatEntry entry = it_res.next();
        if (contains(searchValue, entry)) {
            maxEntries--;
            String key = entry.getIdentityKey().toString();
            String displayKey = entry.getIdentityName();
            String displayText = userManager.getUserDisplayName(entry.getIdentityKey());
            receiver.addEntry(key, displayKey, displayText, CSSHelper.CSS_CLASS_USER);
        }
    }
    if (hasMore) {
        receiver.addEntry(".....", ".....");
    }
}
Also used : StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry)

Example 14 with StudentStatEntry

use of org.olat.modules.coach.model.StudentStatEntry in project openolat by klemens.

the class UserListController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (tableEl == source) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            String cmd = se.getCommand();
            StudentStatEntry selectedRow = model.getObject(se.getIndex());
            if ("select".equals(cmd)) {
                selectStudent(ureq, selectedRow);
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry)

Example 15 with StudentStatEntry

use of org.olat.modules.coach.model.StudentStatEntry in project openolat by klemens.

the class CoachingDAO method getUsersStatisticsStatements.

private boolean getUsersStatisticsStatements(SearchCoachedIdentityParams params, Map<Long, StudentStatEntry> map) {
    NativeQueryBuilder sb = new NativeQueryBuilder(1024, dbInstance);
    Map<String, Object> queryParams = new HashMap<>();
    sb.append("select ").append(" fin_statement.fk_identity, ").append(" sum(case when fin_statement.passed=").appendTrue().append(" then 1 else 0 end) as num_of_passed, ").append(" sum(case when fin_statement.passed=").appendFalse().append(" then 1 else 0 end) as num_of_failed ").append("from o_as_eff_statement fin_statement ").append("where fin_statement.id in ( select ").append("  distinct sg_statement.id as st_id ").append(" from o_repositoryentry sg_re ").append(" inner join o_re_to_group togroup on (togroup.fk_entry_id = sg_re.repositoryentry_id) ").append(" inner join o_bs_group_member sg_participant on (sg_participant.fk_group_id=togroup.fk_group_id and sg_participant.g_role='participant') ").append(" inner join o_as_eff_statement sg_statement on (sg_statement.fk_identity = sg_participant.fk_identity_id and sg_statement.fk_resource_id = sg_re.fk_olatresource) ").append(" inner join o_bs_identity id_participant on (sg_participant.fk_identity_id = id_participant.id) ");
    appendUsersStatisticsJoins(params, sb).append(" where  sg_re.accesscode>0 ");
    appendUsersStatisticsSearchParams(params, queryParams, sb).append(") ").append("group by fin_statement.fk_identity ");
    Query query = dbInstance.getCurrentEntityManager().createNativeQuery(sb.toString());
    for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
        query.setParameter(entry.getKey(), entry.getValue());
    }
    List<?> rawList = query.getResultList();
    for (Object rawObject : rawList) {
        Object[] rawStat = (Object[]) rawObject;
        Long userKey = ((Number) rawStat[0]).longValue();
        StudentStatEntry entry = map.get(userKey);
        if (entry != null) {
            int passed = ((Number) rawStat[1]).intValue();
            int failed = ((Number) rawStat[2]).intValue();
            entry.setCountPassed(passed);
            entry.setCountFailed(failed);
            int notAttempted = entry.getCountRepo() - passed - failed;
            entry.setCountNotAttempted(notAttempted);
        }
    }
    return rawList.size() > 0;
}
Also used : Query(javax.persistence.Query) HashMap(java.util.HashMap) NativeQueryBuilder(org.olat.core.commons.persistence.NativeQueryBuilder) StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry) HashMap(java.util.HashMap) Map(java.util.Map)

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