Search in sources :

Example 46 with SimpleAssociableChoice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.

the class AssessmentItemFactory method appendSimpleAssociableChoice.

public static void appendSimpleAssociableChoice(SimpleMatchSet matchSet, String value, int matchMax, int matchMin) {
    SimpleAssociableChoice choice = new SimpleAssociableChoice(matchSet);
    choice.setMatchMax(matchMax);
    choice.setMatchMin(matchMin);
    choice.setIdentifier(IdentifierGenerator.newNumberAsIdentifier(value));
    P question = getParagraph(choice, value);
    choice.getFlowStatics().add(question);
    matchSet.getSimpleAssociableChoices().add(choice);
}
Also used : P(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)

Example 47 with SimpleAssociableChoice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.

the class CSVToAssessmentItemConverter method processChoice_kprim.

private void processChoice_kprim(String[] parts, KPrimAssessmentItemBuilder kprimBuilder) {
    String firstPart = parts[0].toLowerCase();
    String answer = parts[1];
    Identifier correctIncorrectIdentifier;
    if ("+".equals(firstPart)) {
        correctIncorrectIdentifier = QTI21Constants.CORRECT_IDENTIFIER;
    } else {
        correctIncorrectIdentifier = QTI21Constants.WRONG_IDENTIFIER;
    }
    List<SimpleAssociableChoice> choices = kprimBuilder.getKprimChoices();
    SimpleAssociableChoice choice = choices.get(kprimPosition);
    P choiceText = AssessmentItemFactory.getParagraph(choice, answer);
    choice.getFlowStatics().clear();
    choice.getFlowStatics().add(choiceText);
    kprimBuilder.setAssociation(choice.getIdentifier(), correctIncorrectIdentifier);
    kprimPosition++;
}
Also used : P(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier)

Example 48 with SimpleAssociableChoice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.

the class CSVToAssessmentItemConverter method processChoice_match.

private void processChoice_match(String[] parts, MatchAssessmentItemBuilder matchBuilder) {
    List<SimpleAssociableChoice> targetChoices = matchBuilder.getTargetChoices();
    if (targetChoices == null || targetChoices.isEmpty()) {
        for (int i = 1; i < parts.length; i++) {
            String answer = parts[i];
            SimpleAssociableChoice choice = AssessmentItemFactory.createSimpleAssociableChoice(answer, matchBuilder.getTargetMatchSet());
            targetChoices.add(choice);
        }
    } else {
        String answer = parts[0];
        if (StringHelper.containsNonWhitespace(answer)) {
            SimpleAssociableChoice sourceChoice = AssessmentItemFactory.createSimpleAssociableChoice(answer, matchBuilder.getSourceMatchSet());
            matchBuilder.getSourceChoices().add(sourceChoice);
            // correct answer and points
            for (int i = 1; i < parts.length && i < (targetChoices.size() + 1); i++) {
                double point = parseFloat(parts[i], 0.0f);
                SimpleAssociableChoice targetChoice = targetChoices.get(i - 1);
                DirectedPairValue directedPair = new DirectedPairValue(sourceChoice.getIdentifier(), targetChoice.getIdentifier());
                matchBuilder.addScore(directedPair, Double.valueOf(point));
                if (point > 0.0) {
                    matchBuilder.addAssociation(sourceChoice.getIdentifier(), targetChoice.getIdentifier());
                }
            }
        }
    }
}
Also used : SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)

Example 49 with SimpleAssociableChoice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.

the class MatchEditorController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (readOnly)
        return;
    // title
    itemBuilder.setTitle(titleEl.getValue());
    // question
    String questionText = textEl.getRawValue();
    itemBuilder.setQuestion(questionText);
    if (!restrictedEdit) {
        boolean singleChoice = singleMultiEl.isOneSelected() && singleMultiEl.isSelected(0);
        itemBuilder.setMultipleChoice(!singleChoice);
    }
    // shuffle
    if (!restrictedEdit) {
        itemBuilder.setShuffle(shuffleEl.isOneSelected() && shuffleEl.isSelected(0));
    }
    // layout
    if (!restrictedEdit && layoutEl != null) {
        itemBuilder.removeMatchInteractionClass(layoutKeys);
        String cssClass = layoutEl.getSelectedKey();
        itemBuilder.addMatchInteractionClass(cssClass);
    }
    // update
    for (MatchWrapper sourceWrapper : sourceWrappers) {
        SimpleAssociableChoice choice = sourceWrapper.getSimpleChoice();
        String answer = sourceWrapper.getText().getRawValue();
        itemBuilder.getHtmlHelper().appendHtml(choice, answer);
    }
    for (MatchWrapper sourceWrapper : targetWrappers) {
        SimpleAssociableChoice choice = sourceWrapper.getSimpleChoice();
        String answer = sourceWrapper.getText().getRawValue();
        itemBuilder.getHtmlHelper().appendHtml(choice, answer);
    }
    // correct answers
    commitAssociations(ureq);
    fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), QTI21QuestionType.match));
}
Also used : AssessmentItemFactory.createSimpleAssociableChoice(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createSimpleAssociableChoice) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) AssessmentItemEvent(org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent)

Example 50 with SimpleAssociableChoice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.

the class MatchEditorController method doAddSourceRow.

private void doAddSourceRow(UserRequest ureq) {
    SimpleAssociableChoice newChoice = createSimpleAssociableChoice("Text", itemBuilder.getSourceMatchSet());
    if (singleMultiEl.isOneSelected() && singleMultiEl.isSelected(0)) {
        newChoice.setMatchMax(1);
    } else {
        newChoice.setMatchMax(0);
    }
    itemBuilder.getSourceMatchSet().getSimpleAssociableChoices().add(newChoice);
    wrapAnswer(ureq, newChoice, sourceWrappers);
    answersCont.setDirty(true);
}
Also used : AssessmentItemFactory.createSimpleAssociableChoice(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createSimpleAssociableChoice) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)

Aggregations

SimpleAssociableChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)54 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)20 MatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction)18 ArrayList (java.util.ArrayList)17 SimpleMatchSet (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet)16 AssessmentItemFactory.createSimpleAssociableChoice (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createSimpleAssociableChoice)14 HashMap (java.util.HashMap)12 List (java.util.List)10 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)10 AssessmentItemEvent (org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent)10 P (uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P)10 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)10 FlowFormItem (org.olat.ims.qti21.ui.components.FlowFormItem)7 DirectedPairValue (uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)7 Map (java.util.Map)6 Collectors (java.util.stream.Collectors)6 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)6 File (java.io.File)4 UserRequest (org.olat.core.gui.UserRequest)4 FormItem (org.olat.core.gui.components.form.flexible.FormItem)4