Search in sources :

Example 41 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.

the class CoachingDAOTest method getStatistics_owner.

@Test
public void getStatistics_owner() 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, re2, GroupRoles.owner.name());
    repositoryService.addRole(coach, re3, GroupRoles.coach.name());
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("Coaching-Part-1");
    repositoryService.addRole(participant1, re1, GroupRoles.participant.name());
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("Coaching-Part-2");
    repositoryService.addRole(participant2, re1, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    // members of group of re 2
    BusinessGroup group2 = businessGroupService.createBusinessGroup(null, "Coaching-grp-1", "tg", null, null, false, false, re2);
    Identity participant3 = JunitTestHelper.createAndPersistIdentityAsRndUser("Coaching-Part-3");
    businessGroupRelationDao.addRole(participant3, group2, GroupRoles.participant.name());
    Identity participant4 = JunitTestHelper.createAndPersistIdentityAsRndUser("Coaching-Part-4");
    businessGroupRelationDao.addRole(participant4, group2, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    // members of group of re 3
    BusinessGroup group3 = businessGroupService.createBusinessGroup(null, "Coaching-grp-1", "tg", null, null, false, false, re3);
    Identity participant5 = JunitTestHelper.createAndPersistIdentityAsRndUser("Coaching-Part-5");
    businessGroupRelationDao.addRole(participant5, group3, GroupRoles.participant.name());
    Identity participant6 = JunitTestHelper.createAndPersistIdentityAsRndUser("Coaching-Part-6");
    businessGroupRelationDao.addRole(participant6, group3, 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, participant2, re1.getOlatResource());
    effManager.createUserEfficiencyStatement(new Date(), 5.5f, true, participant3, re2.getOlatResource());
    effManager.createUserEfficiencyStatement(new Date(), null, null, participant4, re2.getOlatResource());
    effManager.createUserEfficiencyStatement(new Date(), 4.0f, true, participant5, re3.getOlatResource());
    effManager.createUserEfficiencyStatement(new Date(), 3.0f, false, participant6, re3.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);
    userCourseInformationsManager.updateUserCourseInformations(re2.getOlatResource(), participant3);
    userCourseInformationsManager.updateUserCourseInformations(re2.getOlatResource(), participant4);
    userCourseInformationsManager.updateUserCourseInformations(re3.getOlatResource(), participant5);
    userCourseInformationsManager.updateUserCourseInformations(re3.getOlatResource(), participant6);
    dbInstance.commitAndCloseSession();
    // owner can see participant 1,2,3 and 4
    // p1 has 1 assessment in re1
    // p2 has 1 assessment in re1
    // p3 has 2 assessments in re1 and re2
    // p4 has 1 assessment in re2
    // 5 and p6 has 1 assessment in re3
    List<GroupStatEntry> nativeGroupStats = coachingDAO.getGroupsStatisticsNative(coach);
    Assert.assertNotNull(nativeGroupStats);
    Assert.assertEquals(1, nativeGroupStats.size());
    GroupStatEntry entryGroup2 = getGroupStatEntry(group2, nativeGroupStats);
    Assert.assertNotNull(entryGroup2);
    Assert.assertEquals(2, entryGroup2.getCountDistinctStudents());
    Assert.assertEquals(2, entryGroup2.getInitialLaunch());
    Assert.assertEquals(1, entryGroup2.getCountPassed());
    Assert.assertEquals(0, entryGroup2.getCountFailed());
    Assert.assertEquals(1, entryGroup2.getCountNotAttempted());
    Assert.assertEquals(5.5f, entryGroup2.getAverageScore(), 0.0001f);
    // re 3 is removed because coach has no visible participants within
    List<CourseStatEntry> nativeCourseStats = coachingDAO.getCoursesStatisticsNative(coach);
    Assert.assertNotNull(nativeCourseStats);
    Assert.assertEquals(2, nativeCourseStats.size());
    // re 1
    CourseStatEntry entryCourse1 = getCourseStatEntry(re1, nativeCourseStats);
    Assert.assertNotNull(entryCourse1);
    Assert.assertEquals(2, entryCourse1.getCountStudents());
    Assert.assertEquals(2, entryCourse1.getInitialLaunch());
    Assert.assertEquals(1, entryCourse1.getCountPassed());
    Assert.assertEquals(1, entryCourse1.getCountFailed());
    Assert.assertEquals(0, entryCourse1.getCountNotAttempted());
    Assert.assertEquals(5.0f, entryCourse1.getAverageScore(), 0.0001f);
    // re 2
    CourseStatEntry entryCourse2 = getCourseStatEntry(re2, nativeCourseStats);
    Assert.assertNotNull(entryCourse2);
    Assert.assertEquals(2, entryCourse2.getCountStudents());
    Assert.assertEquals(2, entryCourse2.getInitialLaunch());
    Assert.assertEquals(1, entryCourse2.getCountPassed());
    Assert.assertEquals(0, entryCourse2.getCountFailed());
    Assert.assertEquals(1, entryCourse2.getCountNotAttempted());
    Assert.assertEquals(5.5f, entryCourse2.getAverageScore(), 0.0001f);
    List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(UserListController.usageIdentifyer, false);
    // user native
    List<StudentStatEntry> nativeUserStats = coachingDAO.getStudentsStatisticsNative(coach, userPropertyHandlers);
    Assert.assertNotNull(nativeUserStats);
    Assert.assertEquals(4, nativeUserStats.size());
    // participant1 is only in re 1
    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());
    Assert.assertEquals(1, entryParticipant1.getCountRepo());
    // participant2 is only in re 1
    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(1, entryParticipant2.getInitialLaunch());
    Assert.assertEquals(1, entryParticipant2.getCountRepo());
    // participant3 is in re 2 ( via group 2)
    StudentStatEntry entryParticipant3 = getStudentStatEntry(participant3, nativeUserStats);
    Assert.assertNotNull(entryParticipant3);
    Assert.assertEquals(1, entryParticipant3.getCountPassed());
    Assert.assertEquals(0, entryParticipant3.getCountFailed());
    Assert.assertEquals(0, entryParticipant3.getCountNotAttempted());
    Assert.assertEquals(1, entryParticipant3.getInitialLaunch());
    Assert.assertEquals(1, entryParticipant3.getCountRepo());
    // participant4 is in re 2 ( via group 2)
    StudentStatEntry entryParticipant4 = getStudentStatEntry(participant4, nativeUserStats);
    Assert.assertNotNull(entryParticipant4);
    Assert.assertEquals(0, entryParticipant4.getCountPassed());
    Assert.assertEquals(0, entryParticipant4.getCountFailed());
    Assert.assertEquals(1, entryParticipant4.getCountNotAttempted());
    Assert.assertEquals(1, entryParticipant4.getInitialLaunch());
    Assert.assertEquals(1, entryParticipant4.getCountRepo());
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) URL(java.net.URL) Date(java.util.Date) GroupStatEntry(org.olat.modules.coach.model.GroupStatEntry) StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry) 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 42 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.

the class CoachingDAOTest method getStatistics_emptyStatements_emptyCourseInfos.

/**
 * 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_emptyStatements_emptyCourseInfos() 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());
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("Coaching-Part-1");
    repositoryService.addRole(participant1, re1, GroupRoles.participant.name());
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("Coaching-Part-2");
    repositoryService.addRole(participant2, re1, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    // groups
    BusinessGroup group1 = businessGroupService.createBusinessGroup(null, "Coaching-grp-1", "tg", null, null, false, false, re1);
    Identity participant3 = JunitTestHelper.createAndPersistIdentityAsRndUser("Coaching-Part-3");
    businessGroupRelationDao.addRole(participant3, group1, GroupRoles.participant.name());
    Identity participant4 = JunitTestHelper.createAndPersistIdentityAsRndUser("Coaching-Part-4");
    businessGroupRelationDao.addRole(participant4, group1, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    // check groups statistics
    List<GroupStatEntry> nativeGroupStats = coachingDAO.getGroupsStatisticsNative(coach);
    Assert.assertNotNull(nativeGroupStats);
    Assert.assertEquals(1, nativeGroupStats.size());
    GroupStatEntry entryGroup1 = getGroupStatEntry(group1, nativeGroupStats);
    Assert.assertNotNull(entryGroup1);
    Assert.assertEquals(2, entryGroup1.getCountDistinctStudents());
    Assert.assertEquals(0, entryGroup1.getInitialLaunch());
    Assert.assertEquals(0, entryGroup1.getCountPassed());
    Assert.assertEquals(0, entryGroup1.getCountFailed());
    Assert.assertEquals(2, entryGroup1.getCountNotAttempted());
    Assert.assertNull(entryGroup1.getAverageScore());
    // courses
    List<CourseStatEntry> nativeCourseStats = coachingDAO.getCoursesStatisticsNative(coach);
    Assert.assertNotNull(nativeCourseStats);
    Assert.assertEquals(1, nativeCourseStats.size());
    // re 1
    CourseStatEntry entryCourse1 = getCourseStatEntry(re1, nativeCourseStats);
    Assert.assertNotNull(entryCourse1);
    Assert.assertEquals(4, entryCourse1.getCountStudents());
    Assert.assertEquals(0, entryCourse1.getInitialLaunch());
    Assert.assertEquals(0, entryCourse1.getCountPassed());
    Assert.assertEquals(0, entryCourse1.getCountFailed());
    Assert.assertEquals(4, entryCourse1.getCountNotAttempted());
    Assert.assertNull(entryCourse1.getAverageScore());
    List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(UserListController.usageIdentifyer, false);
    // user native
    List<StudentStatEntry> nativeUserStats = coachingDAO.getStudentsStatisticsNative(coach, userPropertyHandlers);
    Assert.assertNotNull(nativeUserStats);
    Assert.assertEquals(4, nativeUserStats.size());
    // participants have all the same statistics
    Identity[] participants = new Identity[] { participant1, participant2, participant3, participant4 };
    for (Identity participant : participants) {
        StudentStatEntry entryParticipant = getStudentStatEntry(participant, nativeUserStats);
        Assert.assertNotNull(entryParticipant);
        Assert.assertEquals(0, entryParticipant.getCountPassed());
        Assert.assertEquals(0, entryParticipant.getCountFailed());
        Assert.assertEquals(1, entryParticipant.getCountNotAttempted());
        Assert.assertEquals(0, entryParticipant.getInitialLaunch());
        Assert.assertEquals(1, entryParticipant.getCountRepo());
    }
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) URL(java.net.URL) GroupStatEntry(org.olat.modules.coach.model.GroupStatEntry) StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry) 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 43 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.

the class CourseReminderLogsController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(SendCols.status.i18nKey(), SendCols.status.ordinal(), true, SendCols.status.name(), new StatusCellRenderer()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(SendCols.reminder.i18nKey(), SendCols.reminder.ordinal(), "reminder", true, SendCols.reminder.name(), new StaticFlexiCellRenderer("reminder", new TextFlexiCellRenderer())));
    if (isAdministrativeUser) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(SendCols.username.i18nKey(), SendCols.username.ordinal(), true, SendCols.username.name()));
    }
    int i = 0;
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        int colIndex = USER_PROPS_OFFSET + i++;
        if (userPropertyHandler == null)
            continue;
        String propName = userPropertyHandler.getName();
        boolean visible = userManager.isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
        FlexiColumnModel col;
        if (UserConstants.FIRSTNAME.equals(propName) || UserConstants.LASTNAME.equals(propName)) {
            col = new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, userPropertyHandler.getName(), true, propName, new StaticFlexiCellRenderer(userPropertyHandler.getName(), new TextFlexiCellRenderer()));
        } else {
            col = new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, true, propName);
        }
        columnsModel.addFlexiColumnModel(col);
    }
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(SendCols.sendTime.i18nKey(), SendCols.sendTime.ordinal(), true, SendCols.sendTime.name()));
    // user properties
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("resend", translate("resend"), "resend"));
    tableModel = new CourseSendReminderTableModel(columnsModel);
    tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 20, false, getTranslator(), formLayout);
    tableEl.setElementCssClass("o_sel_course_sent_reminder_log_list");
    updateModel();
}
Also used : StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) FlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 44 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.

the class UserImpl method getProperty.

/**
 * @see org.olat.core.id.User#getProperty(java.lang.String, java.util.Locale)
 */
@Override
public String getProperty(String propertyName, Locale locale) {
    UserManager um = UserManager.getInstance();
    UserPropertyHandler propertyHandler = um.getUserPropertiesConfig().getPropertyHandler(propertyName);
    if (propertyHandler == null)
        return null;
    return propertyHandler.getUserProperty(this, locale);
}
Also used : UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 45 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.

the class UserImpl method setProperty.

/**
 * @see org.olat.core.id.User#setProperty(java.lang.String, java.lang.String)
 */
@Override
public void setProperty(String propertyName, String propertyValue) {
    UserManager um = UserManager.getInstance();
    UserPropertyHandler propertyHandler = um.getUserPropertiesConfig().getPropertyHandler(propertyName);
    if (propertyHandler == null) {
        log.error("Try to set unkown property: " + propertyName + " for user: " + getKey());
    } else {
        propertyHandler.setUserProperty(this, propertyValue);
    }
}
Also used : UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Aggregations

UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)319 Identity (org.olat.core.id.Identity)84 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)74 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)70 ArrayList (java.util.ArrayList)62 FormItem (org.olat.core.gui.components.form.flexible.FormItem)62 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)56 User (org.olat.core.id.User)52 HashMap (java.util.HashMap)40 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)36 FlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel)34 Translator (org.olat.core.gui.translator.Translator)32 Date (java.util.Date)30 UserManager (org.olat.user.UserManager)28 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)24 Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)24 File (java.io.File)22 BusinessGroup (org.olat.group.BusinessGroup)22 SortKey (org.olat.core.commons.persistence.SortKey)18 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)18