Search in sources :

Example 76 with AssessmentEntry

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

the class AssessmentEntryDAOTest method deleteEntryForRepositoryEntry.

@Test
public void deleteEntryForRepositoryEntry() {
    Identity assessedIdentity1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-20");
    Identity assessedIdentity2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-21");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntry refEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    String subIdent = UUID.randomUUID().toString();
    AssessmentEntry nodeAssessment1 = assessmentEntryDao.createAssessmentEntry(assessedIdentity1, null, entry, subIdent, refEntry);
    AssessmentEntry nodeAssessment2 = assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, entry, subIdent, refEntry, 3.0f, Boolean.FALSE, null, null);
    AssessmentEntry nodeAssessment3 = assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, entry, null, entry, 3.0f, Boolean.FALSE, null, null);
    AssessmentEntry nodeAssessment4 = assessmentEntryDao.createAssessmentEntry(assessedIdentity1, null, refEntry, subIdent, refEntry, 3.0f, Boolean.FALSE, null, null);
    dbInstance.commitAndCloseSession();
    // delete by reference
    assessmentEntryDao.deleteEntryForRepositoryEntry(entry);
    dbInstance.commitAndCloseSession();
    // check
    AssessmentEntry deletedAssessmentEntry1 = assessmentEntryDao.loadAssessmentEntryById(nodeAssessment1.getKey());
    Assert.assertNull(deletedAssessmentEntry1);
    AssessmentEntry deletedAssessmentEntry2 = assessmentEntryDao.loadAssessmentEntryById(nodeAssessment2.getKey());
    Assert.assertNull(deletedAssessmentEntry2);
    AssessmentEntry deletedAssessmentEntry3 = assessmentEntryDao.loadAssessmentEntryById(nodeAssessment3.getKey());
    Assert.assertNull(deletedAssessmentEntry3);
    AssessmentEntry deletedAssessmentEntry4 = assessmentEntryDao.loadAssessmentEntryById(nodeAssessment4.getKey());
    Assert.assertNotNull(deletedAssessmentEntry4);
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Example 77 with AssessmentEntry

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

the class AssessmentEntryDAOTest method resetAssessmentEntry.

@Test
public void resetAssessmentEntry() {
    Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-6");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntry refEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    String subIdent = UUID.randomUUID().toString();
    AssessmentEntry nodeAssessmentRef = assessmentEntryDao.createAssessmentEntry(assessedIdentity, null, entry, subIdent, refEntry, 2.0f, Boolean.TRUE, null, null);
    dbInstance.commitAndCloseSession();
    AssessmentEntry resetedAssessmentRef = assessmentEntryDao.resetAssessmentEntry(nodeAssessmentRef);
    dbInstance.commitAndCloseSession();
    Assert.assertEquals(nodeAssessmentRef, resetedAssessmentRef);
    Assert.assertEquals(assessedIdentity, resetedAssessmentRef.getIdentity());
    Assert.assertNull(resetedAssessmentRef.getScore());
    Assert.assertNull(resetedAssessmentRef.getPassed());
    Assert.assertEquals(new Integer(0), resetedAssessmentRef.getAttempts());
    Assert.assertNull(resetedAssessmentRef.getCompletion());
    // double check by reloading the entry
    AssessmentEntry reloadedAssessmentRef = assessmentEntryDao.loadAssessmentEntryById(resetedAssessmentRef.getKey());
    dbInstance.commitAndCloseSession();
    Assert.assertEquals(nodeAssessmentRef, reloadedAssessmentRef);
    Assert.assertNull(reloadedAssessmentRef.getScore());
    Assert.assertNull(reloadedAssessmentRef.getPassed());
    Assert.assertEquals(new Integer(0), reloadedAssessmentRef.getAttempts());
    Assert.assertNull(reloadedAssessmentRef.getCompletion());
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Example 78 with AssessmentEntry

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

the class AssessmentEntryDAOTest method loadAssessmentEntry_specificTest.

@Test
public void loadAssessmentEntry_specificTest() {
    Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-5");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntry refEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    String subIdent = UUID.randomUUID().toString();
    AssessmentEntry nodeAssessmentRef = assessmentEntryDao.createAssessmentEntry(assessedIdentity, null, entry, subIdent, refEntry);
    dbInstance.commitAndCloseSession();
    AssessmentEntry reloadedAssessmentRef = assessmentEntryDao.loadAssessmentEntry(assessedIdentity, entry, subIdent, refEntry);
    Assert.assertEquals(nodeAssessmentRef.getKey(), reloadedAssessmentRef.getKey());
    Assert.assertEquals(nodeAssessmentRef, reloadedAssessmentRef);
    Assert.assertEquals(assessedIdentity, reloadedAssessmentRef.getIdentity());
    Assert.assertEquals(entry, reloadedAssessmentRef.getRepositoryEntry());
    Assert.assertEquals(subIdent, reloadedAssessmentRef.getSubIdent());
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Example 79 with AssessmentEntry

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

the class AssessmentEntryDAOTest method loadAssessmentEntry_anonymous.

@Test
public void loadAssessmentEntry_anonymous() {
    String anonymousIdentifier = UUID.randomUUID().toString();
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    String subIdent = UUID.randomUUID().toString();
    AssessmentEntry nodeAssessment = assessmentEntryDao.createAssessmentEntry(null, anonymousIdentifier, entry, subIdent, entry);
    dbInstance.commitAndCloseSession();
    AssessmentEntry reloadedAssessment = assessmentEntryDao.loadAssessmentEntry(null, anonymousIdentifier, entry, subIdent);
    Assert.assertEquals(nodeAssessment.getKey(), reloadedAssessment.getKey());
    Assert.assertEquals(nodeAssessment, reloadedAssessment);
    Assert.assertEquals(anonymousIdentifier, reloadedAssessment.getAnonymousIdentifier());
    Assert.assertEquals(entry, reloadedAssessment.getRepositoryEntry());
    Assert.assertEquals(subIdent, reloadedAssessment.getSubIdent());
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Example 80 with AssessmentEntry

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

the class AssessmentTestSessionDAOTest method hasActiveTestSession.

@Test
public void hasActiveTestSession() {
    // prepare a test and a user
    RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("session-4");
    AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, testEntry, null, testEntry);
    dbInstance.commit();
    // create an assessment test session
    AssessmentTestSession testSession1 = testSessionDao.createAndPersistTestSession(testEntry, null, null, assessmentEntry, assessedIdentity, null, false);
    Assert.assertNotNull(testSession1);
    dbInstance.commitAndCloseSession();
    // check
    boolean hasTestSession = testSessionDao.hasActiveTestSession(testEntry);
    Assert.assertTrue(hasTestSession);
}
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