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