Search in sources :

Example 11 with AssessmentResponse

use of org.olat.ims.qti21.AssessmentResponse in project openolat by klemens.

the class QTI21ArchiveFormat method exportCourseElement.

public MediaResource exportCourseElement() {
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedDirRoot = frm.unzipFileResource(searchParams.getTestEntry().getOlatResource());
    resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
    ICourse course = CourseFactory.loadCourse(searchParams.getCourseEntry());
    courseNode = course.getRunStructure().getNode(searchParams.getNodeIdent());
    String label = courseNode.getType() + "_" + StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())) + ".xlsx";
    if ("iqself".equals(courseNode.getType())) {
        anonymizerCallback = course.getCourseEnvironment().getCoursePropertyManager();
    }
    // content
    final List<AssessmentTestSession> sessions = testSessionDao.getTestSessionsOfResponse(searchParams);
    final List<AssessmentResponse> responses = responseDao.getResponse(searchParams);
    return new OpenXMLWorkbookResource(label) {

        @Override
        protected void generate(OutputStream out) {
            try (OpenXMLWorkbook workbook = new OpenXMLWorkbook(out, 1)) {
                // headers
                OpenXMLWorksheet exportSheet = workbook.nextWorksheet();
                exportSheet.setHeaderRows(2);
                writeHeaders_1(exportSheet, workbook);
                writeHeaders_2(exportSheet, workbook);
                writeData(sessions, responses, exportSheet, workbook);
            } catch (Exception e) {
                log.error("", e);
            }
        }
    };
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) OpenXMLWorkbookResource(org.olat.core.util.openxml.OpenXMLWorkbookResource) ShieldOutputStream(org.olat.core.util.io.ShieldOutputStream) ZipOutputStream(java.util.zip.ZipOutputStream) OutputStream(java.io.OutputStream) ICourse(org.olat.course.ICourse) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse) Date(java.util.Date) IOException(java.io.IOException) FileResourceManager(org.olat.fileresource.FileResourceManager) OpenXMLWorkbook(org.olat.core.util.openxml.OpenXMLWorkbook) OpenXMLWorksheet(org.olat.core.util.openxml.OpenXMLWorksheet) File(java.io.File)

Example 12 with AssessmentResponse

use of org.olat.ims.qti21.AssessmentResponse 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 13 with AssessmentResponse

use of org.olat.ims.qti21.AssessmentResponse 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 14 with AssessmentResponse

use of org.olat.ims.qti21.AssessmentResponse in project openolat by klemens.

the class TextEntryInteractionArchive method writeInteractionData.

@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
    String stringuifiedResponses = response == null ? null : response.getStringuifiedResponse();
    if (StringHelper.containsNonWhitespace(stringuifiedResponses)) {
        TextEntryInteraction textEntryInteraction = (TextEntryInteraction) interaction;
        AbstractEntry correctAnswers = CorrectResponsesUtil.getCorrectTextResponses(item, textEntryInteraction);
        stringuifiedResponses = CorrectResponsesUtil.stripResponse(stringuifiedResponses);
        boolean correct = correctAnswers.match(stringuifiedResponses);
        if (correct) {
            dataRow.addCell(col++, stringuifiedResponses, workbook.getStyles().getCorrectStyle());
        } else {
            dataRow.addCell(col++, stringuifiedResponses, null);
        }
    } else {
        col++;
    }
    return col;
}
Also used : AbstractEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction)

Example 15 with AssessmentResponse

use of org.olat.ims.qti21.AssessmentResponse 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

AssessmentResponse (org.olat.ims.qti21.AssessmentResponse)22 Date (java.util.Date)12 HashMap (java.util.HashMap)12 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)12 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)12 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)10 File (java.io.File)8 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)8 StringInput (org.olat.ims.qti21.ui.ResponseInput.StringInput)8 NotificationRecorder (uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder)8 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)8 FileResponseData (uk.ac.ed.ph.jqtiplus.types.FileResponseData)8 ResponseData (uk.ac.ed.ph.jqtiplus.types.ResponseData)8 StringResponseData (uk.ac.ed.ph.jqtiplus.types.StringResponseData)8 CandidateItemEventType (org.olat.ims.qti21.model.audit.CandidateItemEventType)6 IOException (java.io.IOException)4 AssessmentResponseData (org.olat.ims.qti21.model.audit.AssessmentResponseData)4 QtiCandidateStateException (uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException)4 List (java.util.List)3 Identity (org.olat.core.id.Identity)3