Search in sources :

Example 16 with AssessmentItemSession

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);
    }
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) HashMap(java.util.HashMap) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse)

Example 17 with AssessmentItemSession

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;
}
Also used : AssessmentItemSessionImpl(org.olat.ims.qti21.model.jpa.AssessmentItemSessionImpl) Date(java.util.Date)

Example 18 with AssessmentItemSession

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;
}
Also used : AssessmentResponseImpl(org.olat.ims.qti21.model.jpa.AssessmentResponseImpl) Date(java.util.Date)

Example 19 with AssessmentItemSession

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());
}
Also used : ParentPartItemRefs(org.olat.ims.qti21.model.ParentPartItemRefs) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Example 20 with AssessmentItemSession

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();
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse) Test(org.junit.Test)

Aggregations

AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)40 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)24 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)18 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)18 HashMap (java.util.HashMap)16 Identity (org.olat.core.id.Identity)16 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)16 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)16 AssessmentResponse (org.olat.ims.qti21.AssessmentResponse)12 ParentPartItemRefs (org.olat.ims.qti21.model.ParentPartItemRefs)12 BigDecimal (java.math.BigDecimal)10 ArrayList (java.util.ArrayList)10 Date (java.util.Date)8 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)8 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)8 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)8 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)8 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)8 Test (org.junit.Test)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6