use of org.olat.ims.qti21.AssessmentItemSession in project openolat by klemens.
the class QTI21ArchiveFormat method writeData.
/**
* The 2 lists, sessions and responses are order by the user name and the test session key.
* @param sessions A list of test sessions ordered by test session key
* @param responses A list of responses ordered by test session key
* @param exportSheet
* @param workbook
*/
private void writeData(List<AssessmentTestSession> sessions, List<AssessmentResponse> responses, OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
int numOfSessions = sessions.size();
Map<AssessmentTestSession, SessionResponses> sessionToResponses = new HashMap<>();
for (int i = 0; i < numOfSessions; i++) {
AssessmentTestSession testSession = sessions.get(i);
sessionToResponses.put(testSession, new SessionResponses(testSession));
}
int numOfResponses = responses.size();
for (int j = 0; j < numOfResponses; j++) {
AssessmentResponse response = responses.get(j);
AssessmentItemSession itemSession = response.getAssessmentItemSession();
AssessmentTestSession responseTestSession = itemSession.getAssessmentTestSession();
SessionResponses sessionResponses = sessionToResponses.get(responseTestSession);
if (sessionResponses != null) {
sessionResponses.addResponse(itemSession, response);
}
}
for (int i = 0; i < numOfSessions; i++) {
AssessmentTestSession testSession = sessions.get(i);
SessionResponses sessionResponses = sessionToResponses.get(testSession);
writeDataRow(i + 2, sessionResponses, exportSheet, workbook);
}
}
use of org.olat.ims.qti21.AssessmentItemSession in project openolat by klemens.
the class AssessmentItemSessionDAO method createAndPersistAssessmentItemSession.
public AssessmentItemSession createAndPersistAssessmentItemSession(AssessmentTestSession assessmentTestSession, ParentPartItemRefs parentParts, String assessmentItemIdentifier) {
AssessmentItemSessionImpl itemSession = new AssessmentItemSessionImpl();
Date now = new Date();
itemSession.setCreationDate(now);
itemSession.setLastModified(now);
itemSession.setAssessmentItemIdentifier(assessmentItemIdentifier);
itemSession.setAssessmentTestSession(assessmentTestSession);
if (parentParts != null) {
itemSession.setSectionIdentifier(parentParts.getSectionIdentifier());
itemSession.setTestPartIdentifier(parentParts.getTestPartIdentifier());
}
dbInstance.getCurrentEntityManager().persist(itemSession);
return itemSession;
}
use of org.olat.ims.qti21.AssessmentItemSession in project openolat by klemens.
the class AssessmentResponseDAO method createAssessmentResponse.
public AssessmentResponse createAssessmentResponse(AssessmentTestSession assessmentTestSession, AssessmentItemSession assessmentItemSession, String responseIdentifier, ResponseLegality legality, ResponseDataType type) {
AssessmentResponseImpl response = new AssessmentResponseImpl();
Date now = new Date();
response.setCreationDate(now);
response.setLastModified(now);
response.setResponseDataType(type.name());
response.setResponseLegality(legality.name());
response.setAssessmentItemSession(assessmentItemSession);
response.setAssessmentTestSession(assessmentTestSession);
response.setResponseIdentifier(responseIdentifier);
return response;
}
use of org.olat.ims.qti21.AssessmentItemSession 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.AssessmentItemSession 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();
}
Aggregations