use of org.olat.course.assessment.model.UserEfficiencyStatementLight 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.model.UserEfficiencyStatementLight in project openolat by klemens.
the class CertificateAndEfficiencyStatementListController method doDelete.
private void doDelete(Long efficiencyStatementKey) {
UserEfficiencyStatementLight efficiencyStatement = esm.getUserEfficiencyStatementLightByKey(efficiencyStatementKey);
if (efficiencyStatement != null) {
esm.deleteEfficiencyStatement(efficiencyStatement);
}
loadModel();
tableEl.reset();
showInfo("info.efficiencyStatement.deleted");
}
use of org.olat.course.assessment.model.UserEfficiencyStatementLight in project OpenOLAT by OpenOLAT.
the class RepositoryEntryMyCourseQueries method searchViews.
public List<RepositoryEntryMyView> searchViews(SearchMyRepositoryEntryViewParams params, int firstResult, int maxResults) {
if (params.getIdentity() == null) {
log.error("No identity defined for query");
return Collections.emptyList();
}
TypedQuery<Object[]> query = creatMyViewQuery(params, Object[].class);
query.setFirstResult(firstResult);
if (maxResults > 0) {
query.setMaxResults(maxResults);
}
// we don't need statistics when rating and comments are disabled unless
// were searching for videos, there we want to see the launch counter
// from the statistics
boolean needStats = repositoryModule.isRatingEnabled() || repositoryModule.isCommentEnabled() || (params.getResourceTypes() != null && params.getResourceTypes().contains(VideoFileResource.TYPE_NAME));
List<Long> effKeys = new ArrayList<>();
List<Object[]> objects = query.getResultList();
List<RepositoryEntryMyView> views = new ArrayList<>(objects.size());
Map<OLATResource, RepositoryEntryMyCourseImpl> viewsMap = new HashMap<>();
for (Object[] object : objects) {
RepositoryEntry re = (RepositoryEntry) object[0];
Number numOfMarks = (Number) object[1];
boolean hasMarks = numOfMarks == null ? false : numOfMarks.longValue() > 0;
Number numOffers = (Number) object[2];
long offers = numOffers == null ? 0l : numOffers.longValue();
Integer myRating = (Integer) object[3];
RepositoryEntryStatistics stats;
if (needStats) {
stats = re.getStatistics();
} else {
stats = null;
}
RepositoryEntryMyCourseImpl view = new RepositoryEntryMyCourseImpl(re, stats, hasMarks, offers, myRating);
views.add(view);
viewsMap.put(re.getOlatResource(), view);
Long effKey = (Long) object[4];
if (effKey != null) {
effKeys.add(effKey);
}
}
if (effKeys.size() > 0) {
List<UserEfficiencyStatementLight> efficiencyStatements = efficiencyStatementManager.findEfficiencyStatementsLight(effKeys);
for (UserEfficiencyStatementLight efficiencyStatement : efficiencyStatements) {
if (viewsMap.containsKey(efficiencyStatement.getResource())) {
viewsMap.get(efficiencyStatement.getResource()).setEfficiencyStatement(efficiencyStatement);
}
}
}
return views;
}
use of org.olat.course.assessment.model.UserEfficiencyStatementLight 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);
}
use of org.olat.course.assessment.model.UserEfficiencyStatementLight in project OpenOLAT by OpenOLAT.
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());
}
Aggregations