Search in sources :

Example 6 with AbstractEntry

use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry 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 7 with AbstractEntry

use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry in project openolat by klemens.

the class FIBEditorController method createEntry.

private AbstractEntry createEntry(String responseIdentifier, String selectedText, String type, boolean newEntry) {
    AbstractEntry interaction = null;
    if ("string".equalsIgnoreCase(type)) {
        TextEntry textInteraction = itemBuilder.createTextEntry(responseIdentifier);
        if (StringHelper.containsNonWhitespace(selectedText)) {
            String[] alternatives = selectedText.split(",");
            for (String alternative : alternatives) {
                if (StringHelper.containsNonWhitespace(alternative)) {
                    alternative = alternative.trim();
                    if (textInteraction.getSolution() == null) {
                        textInteraction.setSolution(alternative);
                    } else {
                        textInteraction.addAlternative(alternative, textInteraction.getScore());
                    }
                }
            }
            if (alternatives.length > 0) {
                String solution = alternatives[0];
                if (newEntry && "gap".equals(solution)) {
                    solution = "";
                }
                textInteraction.setSolution(solution);
            }
        }
        interaction = textInteraction;
    } else if ("float".equalsIgnoreCase(type)) {
        NumericalEntry numericalInteraction = itemBuilder.createNumericalEntry(responseIdentifier);
        if (newEntry && "gap".equals(selectedText)) {
        // skip it, it's a placeholder
        } else if (StringHelper.containsNonWhitespace(selectedText)) {
            try {
                Double val = Double.parseDouble(selectedText.trim());
                numericalInteraction.setSolution(val);
            } catch (NumberFormatException e) {
            // 
            }
        }
        interaction = numericalInteraction;
    }
    return interaction;
}
Also used : AbstractEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry) TextEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.TextEntry) NumericalEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.NumericalEntry)

Example 8 with AbstractEntry

use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry in project openolat by klemens.

the class FIBEditorController method doGapEntry.

private void doGapEntry(UserRequest ureq, String responseIdentifier, String selectedText, String emptySolution, String type, boolean newEntry) {
    if (textEntrySettingsCtrl != null || numericalEntrySettingsCtrl != null)
        return;
    AbstractEntry interaction = itemBuilder.getEntry(responseIdentifier);
    if (interaction == null) {
        interaction = createEntry(responseIdentifier, selectedText, type, newEntry);
    } else if (StringHelper.containsNonWhitespace(selectedText)) {
        updateSolution(interaction, selectedText, emptySolution);
    }
    if (interaction instanceof TextEntry) {
        textEntrySettingsCtrl = new FIBTextEntrySettingsController(ureq, getWindowControl(), (TextEntry) interaction, restrictedEdit, readOnly);
        listenTo(textEntrySettingsCtrl);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), textEntrySettingsCtrl.getInitialComponent(), true, translate("title.add"));
        cmc.activate();
        listenTo(cmc);
    } else if (interaction instanceof NumericalEntry) {
        numericalEntrySettingsCtrl = new FIBNumericalEntrySettingsController(ureq, getWindowControl(), (NumericalEntry) interaction, restrictedEdit, readOnly);
        listenTo(numericalEntrySettingsCtrl);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), numericalEntrySettingsCtrl.getInitialComponent(), true, translate("title.add"));
        cmc.activate();
        listenTo(cmc);
    }
}
Also used : AbstractEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TextEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.TextEntry) NumericalEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.NumericalEntry)

Example 9 with AbstractEntry

use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry in project openolat by klemens.

the class FIBScoreController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_score");
    super.initForm(formLayout, listener, ureq);
    minScoreEl = uifactory.addTextElement("min.score", "min.score", 8, "0.0", formLayout);
    minScoreEl.setElementCssClass("o_sel_assessment_item_min_score");
    minScoreEl.setEnabled(false);
    ScoreBuilder maxScore = itemBuilder.getMaxScoreBuilder();
    String maxValue = maxScore == null ? "" : (maxScore.getScore() == null ? "" : maxScore.getScore().toString());
    maxScoreEl = uifactory.addTextElement("max.score", "max.score", 8, maxValue, formLayout);
    maxScoreEl.setElementCssClass("o_sel_assessment_item_max_score");
    maxScoreEl.setEnabled(!restrictedEdit && !readOnly);
    String[] modeValues = new String[] { translate("form.score.assessment.all.correct"), translate("form.score.assessment.per.answer") };
    assessmentModeEl = uifactory.addRadiosHorizontal("assessment.mode", "form.score.assessment.mode", formLayout, modeKeys, modeValues);
    assessmentModeEl.addActionListener(FormEvent.ONCHANGE);
    assessmentModeEl.setEnabled(!restrictedEdit && !readOnly);
    if (itemBuilder.getScoreEvaluationMode() == ScoreEvaluation.perAnswer) {
        assessmentModeEl.select(ScoreEvaluation.perAnswer.name(), true);
    } else {
        assessmentModeEl.select(ScoreEvaluation.allCorrectAnswers.name(), true);
    }
    String scorePage = velocity_root + "/fib_score.html";
    scoreCont = FormLayoutContainer.createCustomFormLayout("scores", getTranslator(), scorePage);
    formLayout.add(scoreCont);
    scoreCont.setLabel(null, null);
    for (AbstractEntry entry : itemBuilder.getOrderedTextEntries()) {
        wrappers.add(createTextEntryWrapper(entry));
    }
    scoreCont.contextPut("choices", wrappers);
    scoreCont.setVisible(assessmentModeEl.isSelected(1));
    // Submit Button
    FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsContainer.setRootForm(mainForm);
    buttonsContainer.setVisible(!readOnly);
    formLayout.add(buttonsContainer);
    uifactory.addFormSubmitButton("submit", buttonsContainer);
}
Also used : AbstractEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry) ScoreBuilder(org.olat.ims.qti21.model.xml.ScoreBuilder) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 10 with AbstractEntry

use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry in project OpenOLAT by OpenOLAT.

the class FIBEditorController method createEntry.

private AbstractEntry createEntry(String responseIdentifier, String selectedText, String type, boolean newEntry) {
    AbstractEntry interaction = null;
    if ("string".equalsIgnoreCase(type)) {
        TextEntry textInteraction = itemBuilder.createTextEntry(responseIdentifier);
        if (StringHelper.containsNonWhitespace(selectedText)) {
            String[] alternatives = selectedText.split(",");
            for (String alternative : alternatives) {
                if (StringHelper.containsNonWhitespace(alternative)) {
                    alternative = alternative.trim();
                    if (textInteraction.getSolution() == null) {
                        textInteraction.setSolution(alternative);
                    } else {
                        textInteraction.addAlternative(alternative, textInteraction.getScore());
                    }
                }
            }
            if (alternatives.length > 0) {
                String solution = alternatives[0];
                if (newEntry && "gap".equals(solution)) {
                    solution = "";
                }
                textInteraction.setSolution(solution);
            }
        }
        interaction = textInteraction;
    } else if ("float".equalsIgnoreCase(type)) {
        NumericalEntry numericalInteraction = itemBuilder.createNumericalEntry(responseIdentifier);
        if (newEntry && "gap".equals(selectedText)) {
        // skip it, it's a placeholder
        } else if (StringHelper.containsNonWhitespace(selectedText)) {
            try {
                Double val = Double.parseDouble(selectedText.trim());
                numericalInteraction.setSolution(val);
            } catch (NumberFormatException e) {
            // 
            }
        }
        interaction = numericalInteraction;
    }
    return interaction;
}
Also used : AbstractEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry) TextEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.TextEntry) NumericalEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.NumericalEntry)

Aggregations

AbstractEntry (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry)10 TextEntryInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction)8 ArrayList (java.util.ArrayList)6 AssessmentItemFactory.appendTextEntryInteraction (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendTextEntryInteraction)6 NumericalEntry (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.NumericalEntry)6 TextEntry (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.TextEntry)6 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)6 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)6 HashMap (java.util.HashMap)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 DoubleAdder (java.util.concurrent.atomic.DoubleAdder)4 AssessmentItemFactory.createNumericalEntryResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createNumericalEntryResponseDeclaration)4 AssessmentItemFactory.createTextEntryResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createTextEntryResponseDeclaration)4 Map (java.util.Map)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 ScoreBuilder (org.olat.ims.qti21.model.xml.ScoreBuilder)2 Block (uk.ac.ed.ph.jqtiplus.node.content.basic.Block)2 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)2