Search in sources :

Example 16 with UserEfficiencyStatement

use of org.olat.course.assessment.UserEfficiencyStatement in project openolat by klemens.

the class CoachingServiceImpl method getCourse.

@Override
public List<EfficiencyStatementEntry> getCourse(Identity coach, RepositoryEntry entry, List<UserPropertyHandler> userPropertyHandlers, Locale locale) {
    List<Identity> students = coachingDao.getStudents(coach, entry);
    List<UserEfficiencyStatement> statements = efficiencyStatementManager.getUserEfficiencyStatementLight(entry);
    Map<Identity, UserEfficiencyStatement> identityToStatements = new HashMap<>();
    for (UserEfficiencyStatement statement : statements) {
        identityToStatements.put(statement.getIdentity(), statement);
    }
    List<EfficiencyStatementEntry> entries = new ArrayList<>(students.size());
    for (Identity student : students) {
        UserEfficiencyStatement statement = identityToStatements.get(student);
        entries.add(new EfficiencyStatementEntry(student, entry, statement, userPropertyHandlers, locale));
    }
    return entries;
}
Also used : HashMap(java.util.HashMap) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) EfficiencyStatementEntry(org.olat.modules.coach.model.EfficiencyStatementEntry)

Example 17 with UserEfficiencyStatement

use of org.olat.course.assessment.UserEfficiencyStatement in project openolat by klemens.

the class CoachingServiceImpl method getGroup.

@Override
public List<EfficiencyStatementEntry> getGroup(BusinessGroup group, List<UserPropertyHandler> userPropertyHandlers, Locale locale) {
    List<Identity> students = businessGroupService.getMembers(group, GroupRoles.participant.name());
    List<RepositoryEntry> courses = businessGroupService.findRepositoryEntries(Collections.singletonList(group), 0, -1);
    List<UserEfficiencyStatement> statements = efficiencyStatementManager.getUserEfficiencyStatementLight(courses);
    Map<IdentityRepositoryEntryKey, UserEfficiencyStatement> identityToStatements = new HashMap<>();
    for (UserEfficiencyStatement statement : statements) {
        IdentityRepositoryEntryKey key = new IdentityRepositoryEntryKey(statement.getIdentity().getKey(), statement.getCourseRepoKey());
        identityToStatements.put(key, statement);
    }
    List<EfficiencyStatementEntry> entries = new ArrayList<>(students.size() * courses.size());
    for (RepositoryEntry course : courses) {
        for (Identity student : students) {
            IdentityRepositoryEntryKey key = new IdentityRepositoryEntryKey(student.getKey(), course.getKey());
            UserEfficiencyStatement statement = identityToStatements.get(key);
            entries.add(new EfficiencyStatementEntry(student, course, statement, userPropertyHandlers, locale));
        }
    }
    return entries;
}
Also used : HashMap(java.util.HashMap) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) EfficiencyStatementEntry(org.olat.modules.coach.model.EfficiencyStatementEntry)

Example 18 with UserEfficiencyStatement

use of org.olat.course.assessment.UserEfficiencyStatement in project openolat by klemens.

the class EfficiencyStatementManagerTest method hasUserEfficiencyStatement.

@Test
public void hasUserEfficiencyStatement() throws URISyntaxException {
    RepositoryEntry re = deployTestcourse();
    // add some members
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("Eff-Del-Part-3");
    Identity notParticipant = JunitTestHelper.createAndPersistIdentityAsRndUser("Eff-Del-Part-4");
    repositoryService.addRole(participant, re, GroupRoles.participant.name());
    dbInstance.commit();
    // make statements
    UserEfficiencyStatement statement = effManager.createUserEfficiencyStatement(new Date(), 6.0f, true, participant, re.getOlatResource());
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(statement);
    // has participant an efficiency statement
    boolean hasOne = effManager.hasUserEfficiencyStatement(re.getKey(), participant);
    Assert.assertTrue(hasOne);
    boolean hasNot = effManager.hasUserEfficiencyStatement(re.getKey(), notParticipant);
    Assert.assertFalse(hasNot);
}
Also used : UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test) CoachingLargeTest(org.olat.modules.coach.CoachingLargeTest)

Example 19 with UserEfficiencyStatement

use of org.olat.course.assessment.UserEfficiencyStatement in project openolat by klemens.

the class EfficiencyStatementManagerTest method deleteUserData.

@Test
public void deleteUserData() throws URISyntaxException {
    RepositoryEntry re1 = deployTestcourse();
    RepositoryEntry re2 = deployTestcourse();
    // add some members
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("Eff-Del-Part-1");
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("Eff-Del-Part-2");
    repositoryService.addRole(participant1, re1, GroupRoles.participant.name());
    repositoryService.addRole(participant2, re1, GroupRoles.participant.name());
    repositoryService.addRole(participant1, re2, GroupRoles.participant.name());
    repositoryService.addRole(participant2, re2, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    // make statements
    UserEfficiencyStatement statement1_1 = effManager.createUserEfficiencyStatement(new Date(), 6.0f, true, participant1, re1.getOlatResource());
    UserEfficiencyStatement statement1_2 = effManager.createUserEfficiencyStatement(new Date(), 6.0f, true, participant1, re2.getOlatResource());
    UserEfficiencyStatement statement2_1 = effManager.createUserEfficiencyStatement(new Date(), 6.0f, true, participant2, re1.getOlatResource());
    UserEfficiencyStatement statement2_2 = effManager.createUserEfficiencyStatement(new Date(), 6.0f, true, participant2, re2.getOlatResource());
    dbInstance.commitAndCloseSession();
    // load the efficiency statements
    List<UserEfficiencyStatementLight> statementsLight1 = effManager.findEfficiencyStatementsLight(participant1);
    Assert.assertEquals(2, statementsLight1.size());
    // delete user 1
    effManager.deleteEfficientyStatement(participant1);
    dbInstance.commitAndCloseSession();
    // check the efficiency statements
    List<UserEfficiencyStatementLight> deletedStatementsLight1 = effManager.findEfficiencyStatementsLight(participant1);
    Assert.assertTrue(deletedStatementsLight1.isEmpty());
    List<UserEfficiencyStatementLight> deletedStatementsLight2 = effManager.findEfficiencyStatementsLight(participant2);
    Assert.assertEquals(2, deletedStatementsLight2.size());
    // double check
    List<Identity> identitesRe1 = effManager.findIdentitiesWithEfficiencyStatements(re1.getKey());
    Assert.assertEquals(1, identitesRe1.size());
    Assert.assertTrue(identitesRe1.contains(participant2));
    List<Identity> identitesRe2 = effManager.findIdentitiesWithEfficiencyStatements(re2.getKey());
    Assert.assertEquals(1, identitesRe2.size());
    Assert.assertTrue(identitesRe2.contains(participant2));
    // triple check
    List<UserEfficiencyStatementLight> reloadStatemets_1_1 = effManager.findEfficiencyStatementsLight(Collections.<Long>singletonList(statement1_1.getKey()));
    Assert.assertTrue(reloadStatemets_1_1.isEmpty());
    List<UserEfficiencyStatementLight> reloadStatemets_1_2 = effManager.findEfficiencyStatementsLight(Collections.<Long>singletonList(statement1_2.getKey()));
    Assert.assertTrue(reloadStatemets_1_2.isEmpty());
    List<UserEfficiencyStatementLight> reloadStatemets_2_1 = effManager.findEfficiencyStatementsLight(Collections.<Long>singletonList(statement2_1.getKey()));
    Assert.assertEquals(1, reloadStatemets_2_1.size());
    List<UserEfficiencyStatementLight> reloadStatemets_2_2 = effManager.findEfficiencyStatementsLight(Collections.<Long>singletonList(statement2_2.getKey()));
    Assert.assertEquals(1, reloadStatemets_2_2.size());
}
Also used : UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) UserEfficiencyStatementLight(org.olat.course.assessment.model.UserEfficiencyStatementLight) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test) CoachingLargeTest(org.olat.modules.coach.CoachingLargeTest)

Example 20 with UserEfficiencyStatement

use of org.olat.course.assessment.UserEfficiencyStatement in project OpenOLAT by OpenOLAT.

the class EfficiencyStatementManagerTest method testEfficiencyStatement.

/**
 * Create and reload an efficiency statement.
 *
 * @throws URISyntaxException
 */
@Test
public void testEfficiencyStatement() throws URISyntaxException {
    RepositoryEntry re = deployTestcourse();
    ICourse course = CourseFactory.loadCourse(re);
    // add some members
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("Eff-Part-1");
    repositoryService.addRole(participant, re, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    // make statements
    UserEfficiencyStatement statement = effManager.createUserEfficiencyStatement(new Date(), 6.0f, true, participant, re.getOlatResource());
    dbInstance.commitAndCloseSession();
    // load the efficiency statements
    List<UserEfficiencyStatementLight> statementsLight = effManager.findEfficiencyStatementsLight(participant);
    Assert.assertNotNull(statementsLight);
    Assert.assertEquals(1, statementsLight.size());
    UserEfficiencyStatementLight statementLight = statementsLight.get(0);
    Assert.assertEquals(statement.getKey(), statementLight.getKey());
    Assert.assertEquals(participant, statementLight.getIdentity());
    Assert.assertEquals(statement.getCourseRepoKey(), statementLight.getCourseRepoKey());
    Assert.assertEquals(re.getKey(), statementLight.getCourseRepoKey());
    Assert.assertEquals(course.getCourseTitle(), statementLight.getShortTitle());
    Assert.assertEquals(re.getOlatResource(), statementLight.getResource());
    Assert.assertEquals(re.getOlatResource().getKey(), statementLight.getArchivedResourceKey());
    Assert.assertNotNull(statementLight.getCreationDate());
    Assert.assertNotNull(statementLight.getLastModified());
    Assert.assertTrue(statementLight.getPassed());
    Assert.assertEquals(6.0f, statementLight.getScore(), 0.00001);
}
Also used : UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) UserEfficiencyStatementLight(org.olat.course.assessment.model.UserEfficiencyStatementLight) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test) CoachingLargeTest(org.olat.modules.coach.CoachingLargeTest)

Aggregations

UserEfficiencyStatement (org.olat.course.assessment.UserEfficiencyStatement)34 Identity (org.olat.core.id.Identity)20 RepositoryEntry (org.olat.repository.RepositoryEntry)18 Date (java.util.Date)16 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)10 EfficiencyStatementVO (org.olat.course.assessment.model.EfficiencyStatementVO)10 URI (java.net.URI)8 HttpResponse (org.apache.http.HttpResponse)8 HashMap (java.util.HashMap)6 HttpPut (org.apache.http.client.methods.HttpPut)6 EfficiencyStatementManager (org.olat.course.assessment.manager.EfficiencyStatementManager)6 UserEfficiencyStatementLight (org.olat.course.assessment.model.UserEfficiencyStatementLight)6 CoachingLargeTest (org.olat.modules.coach.CoachingLargeTest)6 EfficiencyStatementEntry (org.olat.modules.coach.model.EfficiencyStatementEntry)6 RepositoryEntryRef (org.olat.repository.RepositoryEntryRef)6 RepositoryEntryRefImpl (org.olat.repository.model.RepositoryEntryRefImpl)6 ICourse (org.olat.course.ICourse)4 ArgumentParseException (org.olat.course.condition.interpreter.ArgumentParseException)4 CourseEditorEnv (org.olat.course.editor.CourseEditorEnv)4