Search in sources :

Example 6 with UserEfficiencyStatementLight

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

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");
}
Also used : UserEfficiencyStatementLight(org.olat.course.assessment.model.UserEfficiencyStatementLight)

Example 8 with UserEfficiencyStatementLight

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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RepositoryEntryMyView(org.olat.repository.RepositoryEntryMyView) OLATResource(org.olat.resource.OLATResource) UserEfficiencyStatementLight(org.olat.course.assessment.model.UserEfficiencyStatementLight) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryStatistics(org.olat.repository.model.RepositoryEntryStatistics) RepositoryEntryMyCourseImpl(org.olat.repository.model.RepositoryEntryMyCourseImpl)

Example 9 with UserEfficiencyStatementLight

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

Example 10 with UserEfficiencyStatementLight

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

Aggregations

UserEfficiencyStatementLight (org.olat.course.assessment.model.UserEfficiencyStatementLight)14 Identity (org.olat.core.id.Identity)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 ICourse (org.olat.course.ICourse)4 UserEfficiencyStatement (org.olat.course.assessment.UserEfficiencyStatement)4 CoachingLargeTest (org.olat.modules.coach.CoachingLargeTest)4 BigDecimal (java.math.BigDecimal)2 HashSet (java.util.HashSet)2 TransientIdentity (org.olat.admin.user.imp.TransientIdentity)2 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)2 UserRequest (org.olat.core.gui.UserRequest)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2 WindowControl (org.olat.core.gui.control.WindowControl)2 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)2 PopupBrowserWindow (org.olat.core.gui.control.generic.popup.PopupBrowserWindow)2 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)2