Search in sources :

Example 71 with Identifier

use of uk.ac.ed.ph.jqtiplus.types.Identifier in project openolat by klemens.

the class EssayAssessmentItemBuilder method createAssessmentItem.

private static AssessmentItem createAssessmentItem(String title) {
    AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.essay, title);
    // define the response
    Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
    ResponseDeclaration responseDeclaration = createExtendedTextResponseDeclaration(assessmentItem, responseDeclarationId);
    assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
    // outcomes
    appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
    ItemBody itemBody = appendDefaultItemBody(assessmentItem);
    appendExtendedTextInteraction(itemBody, responseDeclarationId);
    // response processing
    ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
    assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
    return assessmentItem;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ItemBody(uk.ac.ed.ph.jqtiplus.node.content.ItemBody) AssessmentItemFactory.appendDefaultItemBody(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendDefaultItemBody) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ResponseProcessing(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing) AssessmentItemFactory.createResponseProcessing(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createResponseProcessing) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) AssessmentItemFactory.createExtendedTextResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createExtendedTextResponseDeclaration)

Example 72 with Identifier

use of uk.ac.ed.ph.jqtiplus.types.Identifier in project openolat by klemens.

the class AlienItemAnalyzer method checkFeedback.

private void checkFeedback(Report report) {
    if (item.getModalFeedbacks() != null && item.getModalFeedbacks().size() > 0) {
        Set<Identifier> outcomeIdentifiers = new HashSet<>();
        List<ModalFeedback> feedbacks = item.getModalFeedbacks();
        for (ModalFeedback feedback : feedbacks) {
            if (feedback.getOutcomeIdentifier() != null) {
                outcomeIdentifiers.add(feedback.getOutcomeIdentifier());
            }
        }
        if (outcomeIdentifiers.size() == 1) {
            if (outcomeIdentifiers.iterator().next().equals(QTI21Constants.FEEDBACKMODAL_IDENTIFIER)) {
                checkFeedbackModalResponseProcessing(report);
            } else {
                report.addWarning(ReportWarningEnum.alienFeedbacks);
            }
        } else {
            // Onyx and OpenOLAT only use one outcome identifier for the feedbacks
            // Taotesting use several different identifiers. And we don't
            // understand feedbacks without outcome identifiers
            report.addWarning(ReportWarningEnum.alienFeedbacks);
        }
    }
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback) HashSet(java.util.HashSet)

Example 73 with Identifier

use of uk.ac.ed.ph.jqtiplus.types.Identifier in project openolat by klemens.

the class SingleChoiceAssessmentItemBuilderTest method createSingleAssessmentItem_allCorrectAnswers.

@Test
public void createSingleAssessmentItem_allCorrectAnswers() throws IOException {
    QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
    SingleChoiceAssessmentItemBuilder itemBuilder = new SingleChoiceAssessmentItemBuilder("Single choice", "Single choice", qtiSerializer);
    itemBuilder.setQuestion("<p>Hello</p>");
    ChoiceInteraction interaction = itemBuilder.getChoiceInteraction();
    SimpleChoice choice1 = AssessmentItemFactory.createSimpleChoice(interaction, "One", "sc");
    SimpleChoice choice2 = AssessmentItemFactory.createSimpleChoice(interaction, "Two", "sc");
    SimpleChoice choice3 = AssessmentItemFactory.createSimpleChoice(interaction, "Three", "sc");
    List<SimpleChoice> choiceList = new ArrayList<>();
    choiceList.add(choice1);
    choiceList.add(choice2);
    choiceList.add(choice3);
    itemBuilder.setSimpleChoices(choiceList);
    itemBuilder.setCorrectAnswer(choice2.getIdentifier());
    itemBuilder.setMaxScore(3.0d);
    itemBuilder.setScoreEvaluationMode(ScoreEvaluation.allCorrectAnswers);
    itemBuilder.build();
    File itemFile = new File(WebappHelper.getTmpDir(), "scAssessmentItem" + UUID.randomUUID() + ".xml");
    try (FileOutputStream out = new FileOutputStream(itemFile)) {
        qtiSerializer.serializeJqtiObject(itemBuilder.getAssessmentItem(), out);
    } catch (Exception e) {
        log.error("", e);
    }
    {
        // correct answers
        Map<Identifier, ResponseData> responseMap = new HashMap<>();
        Identifier responseIdentifier = itemBuilder.getInteraction().getResponseIdentifier();
        responseMap.put(responseIdentifier, new StringResponseData(choice2.getIdentifier().toString()));
        ItemSessionController itemSessionController = RunningItemHelper.run(itemFile, responseMap);
        Value score = itemSessionController.getItemSessionState().getOutcomeValue(QTI21Constants.SCORE_IDENTIFIER);
        Assert.assertEquals(new FloatValue(3.0d), score);
    }
    {
        // wrong answer
        Map<Identifier, ResponseData> responseMap = new HashMap<>();
        Identifier responseIdentifier = itemBuilder.getInteraction().getResponseIdentifier();
        responseMap.put(responseIdentifier, new StringResponseData(choice3.getIdentifier().toString()));
        ItemSessionController itemSessionController = RunningItemHelper.run(itemFile, responseMap);
        Value score = itemSessionController.getItemSessionState().getOutcomeValue(QTI21Constants.SCORE_IDENTIFIER);
        Assert.assertEquals(new FloatValue(0.0d), score);
    }
    FileUtils.deleteDirsAndFiles(itemFile.toPath());
}
Also used : SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) ArrayList(java.util.ArrayList) ItemSessionController(uk.ac.ed.ph.jqtiplus.running.ItemSessionController) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) JqtiExtensionManager(uk.ac.ed.ph.jqtiplus.JqtiExtensionManager) StringResponseData(uk.ac.ed.ph.jqtiplus.types.StringResponseData) QtiSerializer(uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer) FileOutputStream(java.io.FileOutputStream) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) Value(uk.ac.ed.ph.jqtiplus.value.Value) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 74 with Identifier

use of uk.ac.ed.ph.jqtiplus.types.Identifier in project openolat by klemens.

the class QTI21ServiceImpl method getAssessmentResponses.

@Override
public Map<Identifier, AssessmentResponse> getAssessmentResponses(AssessmentItemSession assessmentItemSession) {
    List<AssessmentResponse> responses = testResponseDao.getResponses(assessmentItemSession);
    Map<Identifier, AssessmentResponse> responseMap = new HashMap<>();
    for (AssessmentResponse response : responses) {
        responseMap.put(Identifier.assumedLegal(response.getResponseIdentifier()), response);
    }
    return responseMap;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) LinkedHashMap(java.util.LinkedHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse)

Example 75 with Identifier

use of uk.ac.ed.ph.jqtiplus.types.Identifier in project openolat by klemens.

the class QTI21ServiceImpl method recordOutcomeVariable.

private void recordOutcomeVariable(AssessmentTestSession candidateSession, OutcomeVariable outcomeVariable, Map<Identifier, String> outcomes) {
    Identifier identifier = outcomeVariable.getIdentifier();
    Value computedValue = outcomeVariable.getComputedValue();
    if (QtiConstants.VARIABLE_DURATION_IDENTIFIER.equals(identifier)) {
        log.audit(candidateSession.getKey() + " :: " + outcomeVariable.getIdentifier() + " - " + stringifyQtiValue(computedValue));
    } else if (QTI21Constants.SCORE_IDENTIFIER.equals(identifier)) {
        if (computedValue instanceof NumberValue) {
            double score = ((NumberValue) computedValue).doubleValue();
            candidateSession.setScore(new BigDecimal(score));
        }
    } else if (QTI21Constants.PASS_IDENTIFIER.equals(identifier)) {
        if (computedValue instanceof BooleanValue) {
            boolean pass = ((BooleanValue) computedValue).booleanValue();
            candidateSession.setPassed(pass);
        }
    }
    try {
        outcomes.put(identifier, stringifyQtiValue(computedValue));
    } catch (Exception e) {
        log.error("", e);
    }
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) NumberValue(uk.ac.ed.ph.jqtiplus.value.NumberValue) BooleanValue(uk.ac.ed.ph.jqtiplus.value.BooleanValue) Value(uk.ac.ed.ph.jqtiplus.value.Value) NumberValue(uk.ac.ed.ph.jqtiplus.value.NumberValue) RecordValue(uk.ac.ed.ph.jqtiplus.value.RecordValue) BooleanValue(uk.ac.ed.ph.jqtiplus.value.BooleanValue) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) BigDecimal(java.math.BigDecimal) QtiXmlInterpretationException(uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) XmlResourceNotFoundException(uk.ac.ed.ph.jqtiplus.xmlutils.XmlResourceNotFoundException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException)

Aggregations

Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)208 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)62 ArrayList (java.util.ArrayList)53 HashMap (java.util.HashMap)52 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)46 ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)42 Value (uk.ac.ed.ph.jqtiplus.value.Value)42 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)40 Map (java.util.Map)32 SimpleAssociableChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)24 DirectedPairValue (uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)24 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)24 ItemBody (uk.ac.ed.ph.jqtiplus.node.content.ItemBody)22 CorrectResponse (uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse)22 ResponseProcessing (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing)22 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)22 List (java.util.List)20 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)20 SimpleChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice)20 RecordValue (uk.ac.ed.ph.jqtiplus.value.RecordValue)20