use of org.olat.ims.qti21.AssessmentTestSession in project openolat by klemens.
the class AssessmentTestSessionDAO method createAndPersistTestSession.
public AssessmentTestSession createAndPersistTestSession(RepositoryEntry testEntry, RepositoryEntry repositoryEntry, String subIdent, AssessmentEntry assessmentEntry, Identity identity, String anonymousIdentifier, boolean authorMode) {
AssessmentTestSessionImpl testSession = new AssessmentTestSessionImpl();
Date now = new Date();
testSession.setCreationDate(now);
testSession.setLastModified(now);
testSession.setTestEntry(testEntry);
testSession.setRepositoryEntry(repositoryEntry);
testSession.setSubIdent(subIdent);
testSession.setAssessmentEntry(assessmentEntry);
testSession.setAuthorMode(authorMode);
testSession.setExploded(false);
testSession.setIdentity(identity);
testSession.setAnonymousIdentifier(anonymousIdentifier);
testSession.setStorage(createSessionStorage(testSession));
dbInstance.getCurrentEntityManager().persist(testSession);
return testSession;
}
use of org.olat.ims.qti21.AssessmentTestSession in project openolat by klemens.
the class AssessmentItemSessionDAOTest method createAndGetItemSession.
@Test
public void createAndGetItemSession() {
// prepare a test and a user
RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("response-session-1");
AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, testEntry, "-", testEntry);
dbInstance.commit();
String itemIdentifier = UUID.randomUUID().toString();
ParentPartItemRefs parentParts = new ParentPartItemRefs();
String sectionIdentifier = UUID.randomUUID().toString();
parentParts.setSectionIdentifier(sectionIdentifier);
String testPartIdentifier = UUID.randomUUID().toString();
parentParts.setTestPartIdentifier(testPartIdentifier);
// make test, item and response
AssessmentTestSession testSession = testSessionDao.createAndPersistTestSession(testEntry, testEntry, "_", assessmentEntry, assessedIdentity, null, true);
Assert.assertNotNull(testSession);
AssessmentItemSession itemSession = itemSessionDao.createAndPersistAssessmentItemSession(testSession, parentParts, itemIdentifier);
Assert.assertNotNull(itemSession);
dbInstance.commitAndCloseSession();
AssessmentItemSession reloadedItemSession = itemSessionDao.getAssessmentItemSession(testSession, itemIdentifier);
Assert.assertNotNull(reloadedItemSession);
Assert.assertNotNull(reloadedItemSession.getCreationDate());
Assert.assertNotNull(reloadedItemSession.getLastModified());
Assert.assertEquals(itemIdentifier, reloadedItemSession.getAssessmentItemIdentifier());
Assert.assertEquals(sectionIdentifier, reloadedItemSession.getSectionIdentifier());
Assert.assertEquals(testPartIdentifier, reloadedItemSession.getTestPartIdentifier());
}
use of org.olat.ims.qti21.AssessmentTestSession in project openolat by klemens.
the class AssessmentResponseDAOTest method createResponse.
@Test
public void createResponse() {
// prepare a test and a user
RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("response-session-1");
AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, testEntry, "-", testEntry);
dbInstance.commit();
String itemIdentifier = UUID.randomUUID().toString();
String responseIdentifier = UUID.randomUUID().toString();
// make test, item and response
AssessmentTestSession testSession = testSessionDao.createAndPersistTestSession(testEntry, testEntry, "_", assessmentEntry, assessedIdentity, null, true);
Assert.assertNotNull(testSession);
AssessmentItemSession itemSession = itemSessionDao.createAndPersistAssessmentItemSession(testSession, null, itemIdentifier);
Assert.assertNotNull(itemSession);
AssessmentResponse response = responseDao.createAssessmentResponse(testSession, itemSession, responseIdentifier, ResponseLegality.VALID, ResponseDataType.FILE);
Assert.assertNotNull(response);
dbInstance.commit();
}
use of org.olat.ims.qti21.AssessmentTestSession in project openolat by klemens.
the class AssessmentTestSessionDAOTest method getUserTestSessionsStatistics.
@Test
public void getUserTestSessionsStatistics() {
// 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, false);
Assert.assertNotNull(testSession);
dbInstance.commit();
for (int i = 0; i < 4; i++) {
ParentPartItemRefs parentParts = new ParentPartItemRefs();
String sectionIdentifier = UUID.randomUUID().toString();
parentParts.setSectionIdentifier(sectionIdentifier);
String testPartIdentifier = UUID.randomUUID().toString();
parentParts.setTestPartIdentifier(testPartIdentifier);
AssessmentItemSession itemSession = itemSessionDao.createAndPersistAssessmentItemSession(testSession, parentParts, UUID.randomUUID().toString());
Assert.assertNotNull(itemSession);
dbInstance.commit();
if (i % 2 == 0) {
itemSession.setManualScore(new BigDecimal(3));
itemSessionDao.merge(itemSession);
}
}
dbInstance.commitAndCloseSession();
List<AssessmentTestSessionStatistics> sessionsStatistics = testSessionDao.getUserTestSessionsStatistics(courseEntry, subIdent, assessedIdentity);
Assert.assertNotNull(sessionsStatistics);
Assert.assertEquals(1, sessionsStatistics.size());
AssessmentTestSessionStatistics sessionStatistics = sessionsStatistics.get(0);
Assert.assertNotNull(sessionStatistics.getTestSession());
Assert.assertEquals(testSession, sessionStatistics.getTestSession());
Assert.assertEquals(2, sessionStatistics.getNumOfCorrectedItems());
}
use of org.olat.ims.qti21.AssessmentTestSession in project openolat by klemens.
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));
}
Aggregations