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;
}
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;
}
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);
}
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());
}
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);
}
Aggregations