Search in sources :

Example 11 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class PortfolioServiceImpl method updateAssessmentEntryLastModification.

private void updateAssessmentEntryLastModification(Binder binder, Identity doer, Role by) {
    if (binder.getEntry() == null)
        return;
    RepositoryEntry entry = binder.getEntry();
    List<Identity> assessedIdentities = getMembers(binder, PortfolioRoles.owner.name());
    // order status from the entry / section
    if ("CourseModule".equals(entry.getOlatResource().getResourceableTypeName())) {
        ICourse course = CourseFactory.loadCourse(entry);
        CourseNode courseNode = course.getRunStructure().getNode(binder.getSubIdent());
        if (courseNode instanceof PortfolioCourseNode) {
            PortfolioCourseNode pfNode = (PortfolioCourseNode) courseNode;
            for (Identity assessedIdentity : assessedIdentities) {
                UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
                pfNode.updateLastModifications(userCourseEnv, doer, by);
            }
        }
    } else {
        OLATResource resource = ((BinderImpl) binder.getTemplate()).getOlatResource();
        RepositoryEntry referenceEntry = repositoryService.loadByResourceKey(resource.getKey());
        for (Identity assessedIdentity : assessedIdentities) {
            AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, binder.getEntry(), binder.getSubIdent(), referenceEntry);
            if (by == Role.coach) {
                assessmentEntry.setLastCoachModified(new Date());
            } else if (by == Role.user) {
                assessmentEntry.setLastUserModified(new Date());
            }
            assessmentService.updateAssessmentEntry(assessmentEntry);
        }
    }
}
Also used : PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) OLATResource(org.olat.resource.OLATResource) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CourseNode(org.olat.course.nodes.CourseNode) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Date(java.util.Date)

Example 12 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class AssessmentTestSessionDAOTest method getUserTestSessions.

@Test
public void getUserTestSessions() {
    // prepare a test and a user
    RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntry courseEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    String subIdent = UUID.randomUUID().toString();
    Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("session-3");
    AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, courseEntry, subIdent, testEntry);
    dbInstance.commit();
    AssessmentTestSession testSession = testSessionDao.createAndPersistTestSession(testEntry, courseEntry, subIdent, assessmentEntry, assessedIdentity, null, true);
    Assert.assertNotNull(testSession);
    dbInstance.commitAndCloseSession();
    List<AssessmentTestSession> sessions = testSessionDao.getUserTestSessions(courseEntry, subIdent, assessedIdentity);
    Assert.assertNotNull(sessions);
    Assert.assertEquals(1, sessions.size());
    Assert.assertEquals(testSession, sessions.get(0));
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Example 13 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class AssessmentTestSessionDAOTest method createTestSession_repo.

@Test
public void createTestSession_repo() {
    // prepare a test and a user
    RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("session-1");
    AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, testEntry, "-", testEntry);
    dbInstance.commit();
    AssessmentTestSession testSession = testSessionDao.createAndPersistTestSession(testEntry, testEntry, "-", assessmentEntry, assessedIdentity, null, true);
    Assert.assertNotNull(testSession);
    dbInstance.commit();
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Example 14 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class AssessmentTestSessionDAOTest method getLastTestSession.

@Test
public void getLastTestSession() {
    // prepare a test and a user
    RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntry courseEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    String subIdent = UUID.randomUUID().toString();
    Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("session-3");
    AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, courseEntry, subIdent, testEntry);
    dbInstance.commit();
    AssessmentTestSession testSession1 = testSessionDao.createAndPersistTestSession(testEntry, courseEntry, subIdent, assessmentEntry, assessedIdentity, null, false);
    Assert.assertNotNull(testSession1);
    dbInstance.commitAndCloseSession();
    // to have a time difference
    sleep(1500);
    AssessmentTestSession testSession2 = testSessionDao.createAndPersistTestSession(testEntry, courseEntry, subIdent, assessmentEntry, assessedIdentity, null, false);
    Assert.assertNotNull(testSession2);
    dbInstance.commitAndCloseSession();
    // load the last session
    AssessmentTestSession lastTestSession = testSessionDao.getLastTestSession(testEntry, courseEntry, subIdent, assessedIdentity, null, false);
    Assert.assertNotNull(lastTestSession);
    Assert.assertEquals(testSession2, lastTestSession);
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Example 15 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class AssessmentTestSessionDAOTest method getAuthorAssessmentTestSession.

@Test
public void getAuthorAssessmentTestSession() {
    // prepare a test and 2 users
    RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity author1 = JunitTestHelper.createAndPersistIdentityAsRndUser("session-6");
    Identity author2 = JunitTestHelper.createAndPersistIdentityAsRndUser("session-7");
    Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("session-8");
    AssessmentEntry assessmentEntry1 = assessmentService.getOrCreateAssessmentEntry(author1, null, testEntry, null, testEntry);
    AssessmentEntry assessmentEntry2 = assessmentService.getOrCreateAssessmentEntry(author2, null, testEntry, null, testEntry);
    AssessmentEntry assessmentEntry3 = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, testEntry, null, testEntry);
    dbInstance.commit();
    // create an assessment test session
    AssessmentTestSession testSession1 = testSessionDao.createAndPersistTestSession(testEntry, null, null, assessmentEntry1, author1, null, true);
    AssessmentTestSession testSession2 = testSessionDao.createAndPersistTestSession(testEntry, null, null, assessmentEntry2, author2, null, true);
    AssessmentTestSession testSession3 = testSessionDao.createAndPersistTestSession(testEntry, null, null, assessmentEntry3, assessedIdentity, null, false);
    dbInstance.commitAndCloseSession();
    // check that there isn't any active test session (only author mode)
    List<AssessmentTestSession> authorSessions = testSessionDao.getAuthorAssessmentTestSession(testEntry);
    Assert.assertNotNull(authorSessions);
    Assert.assertEquals(2, authorSessions.size());
    Assert.assertTrue(authorSessions.contains(testSession1));
    Assert.assertTrue(authorSessions.contains(testSession2));
    Assert.assertFalse(authorSessions.contains(testSession3));
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Aggregations

AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)150 Identity (org.olat.core.id.Identity)88 RepositoryEntry (org.olat.repository.RepositoryEntry)70 Test (org.junit.Test)50 ICourse (org.olat.course.ICourse)38 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)32 File (java.io.File)26 Date (java.util.Date)26 HashMap (java.util.HashMap)22 BigDecimal (java.math.BigDecimal)20 ArrayList (java.util.ArrayList)20 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)20 UserNodeAuditManager (org.olat.course.auditing.UserNodeAuditManager)16 CourseNode (org.olat.course.nodes.CourseNode)16 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)16 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)14 AssessmentChangedEvent (org.olat.course.assessment.AssessmentChangedEvent)12 AssessmentManager (org.olat.course.assessment.AssessmentManager)12 BusinessGroup (org.olat.group.BusinessGroup)12 List (java.util.List)10