Search in sources :

Example 6 with Choice

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

the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedChoices.

public List<SimpleAssociableChoice> getVisibleOrderedChoices(MatchInteraction interaction, int pos) {
    try {
        List<SimpleAssociableChoice> choices;
        if (interaction.getShuffle()) {
            List<Identifier> choiceOrders = itemSessionState.getShuffledInteractionChoiceOrder(interaction.getResponseIdentifier());
            Map<Identifier, SimpleAssociableChoice> idTochoice = new HashMap<>();
            List<SimpleAssociableChoice> allChoices = interaction.getSimpleMatchSets().get(pos).getSimpleAssociableChoices();
            for (SimpleAssociableChoice allChoice : allChoices) {
                idTochoice.put(allChoice.getIdentifier(), allChoice);
            }
            choices = new ArrayList<>();
            for (Identifier choiceOrder : choiceOrders) {
                SimpleAssociableChoice choice = idTochoice.get(choiceOrder);
                if (choice != null) {
                    choices.add(choice);
                }
            }
        } else {
            choices = interaction.getSimpleMatchSets().get(pos).getSimpleAssociableChoices();
        }
        return choices.stream().filter((choice) -> isVisible(choice, itemSessionState)).collect(Collectors.toList());
    } catch (Exception e) {
        log.error("", e);
        return null;
    }
}
Also used : URLBuilder(org.olat.core.gui.render.URLBuilder) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) GraphicAssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) Map(java.util.Map) Flow(uk.ac.ed.ph.jqtiplus.node.content.basic.Flow) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) StringOutput(org.olat.core.gui.render.StringOutput) OLog(org.olat.core.logging.OLog) ListValue(uk.ac.ed.ph.jqtiplus.value.ListValue) FlowStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.FlowStatic) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) Translator(org.olat.core.gui.translator.Translator) InlineChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.InlineChoice) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) FormJSHelper(org.olat.core.gui.components.form.flexible.impl.FormJSHelper) AssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction) StringInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.StringInteraction) Value(uk.ac.ed.ph.jqtiplus.value.Value) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) AssociableHotspot(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.AssociableHotspot) Collectors(java.util.stream.Collectors) GapImg(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapImg) List(java.util.List) BlockStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.BlockStatic) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) AssessmentRenderFunctions.renderValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderValue) TextOrVariable(uk.ac.ed.ph.jqtiplus.node.content.variable.TextOrVariable) BaseType(uk.ac.ed.ph.jqtiplus.value.BaseType) VelocityRenderDecorator(org.olat.core.gui.render.velocity.VelocityRenderDecorator) RecordValue(uk.ac.ed.ph.jqtiplus.value.RecordValue) GraphicOrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) Settings(org.olat.core.helpers.Settings) Orientation(uk.ac.ed.ph.jqtiplus.value.Orientation) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode) GapChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice) QueryUtils(uk.ac.ed.ph.jqtiplus.utils.QueryUtils) CandidateSessionContext(org.olat.ims.qti21.ui.CandidateSessionContext) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) HashMap(java.util.HashMap) StringMultipleAttribute(uk.ac.ed.ph.jqtiplus.attribute.value.StringMultipleAttribute) Prompt(uk.ac.ed.ph.jqtiplus.node.item.interaction.Prompt) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ResponseData(uk.ac.ed.ph.jqtiplus.types.ResponseData) ArrayList(java.util.ArrayList) Gap(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap) SliderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SliderInteraction) Cardinality(uk.ac.ed.ph.jqtiplus.value.Cardinality) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) OrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.OrderInteraction) StringHelper(org.olat.core.util.StringHelper) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) Iterator(java.util.Iterator) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) IOException(java.io.IOException) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Shape(uk.ac.ed.ph.jqtiplus.node.expression.operator.Shape) GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) NullValue(uk.ac.ed.ph.jqtiplus.value.NullValue) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) Tracing(org.olat.core.logging.Tracing) FileValue(uk.ac.ed.ph.jqtiplus.value.FileValue) BodyElement(uk.ac.ed.ph.jqtiplus.node.content.BodyElement) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) HashMap(java.util.HashMap) IOException(java.io.IOException)

Example 7 with Choice

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

the class ChoiceScoreController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormContextHelp(contextHelpUrl);
    super.initForm(formLayout, listener, ureq);
    ScoreBuilder minScore = itemBuilder.getMinScoreBuilder();
    String minValue = minScore == null ? "" : (minScore.getScore() == null ? "" : minScore.getScore().toString());
    minScoreEl = uifactory.addTextElement("min.score", "min.score", 8, minValue, formLayout);
    minScoreEl.setElementCssClass("o_sel_assessment_item_min_score");
    minScoreEl.setEnabled(!restrictedEdit && !readOnly);
    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[] choiceKeys = new String[0];
    String[] choiceValues = new String[0];
    maxChoicesEl = uifactory.addDropdownSingleselect("max.choices", formLayout, choiceKeys, choiceValues, null);
    maxChoicesEl.setEnabled(!restrictedEdit && !readOnly);
    minChoicesEl = uifactory.addDropdownSingleselect("min.choices", formLayout, choiceKeys, choiceValues, null);
    minChoicesEl.setEnabled(!restrictedEdit && !readOnly);
    updateMinMaxChoices();
    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.setEnabled(!restrictedEdit && !readOnly);
    assessmentModeEl.addActionListener(FormEvent.ONCHANGE);
    if (itemBuilder.getScoreEvaluationMode() == ScoreEvaluation.perAnswer) {
        assessmentModeEl.select(ScoreEvaluation.perAnswer.name(), true);
    } else {
        assessmentModeEl.select(ScoreEvaluation.allCorrectAnswers.name(), true);
    }
    String scorePage = velocity_root + "/choices_score.html";
    scoreCont = FormLayoutContainer.createCustomFormLayout("scores", getTranslator(), scorePage);
    formLayout.add(scoreCont);
    scoreCont.setLabel(null, null);
    for (Choice choice : itemBuilder.getChoices()) {
        ChoiceWrapper wrapper = createChoiceWrapper(choice);
        wrappers.add(wrapper);
    }
    scoreCont.contextPut("choices", wrappers);
    scoreCont.contextPut("restrictedEdit", restrictedEdit || readOnly);
    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 : Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) ScoreBuilder(org.olat.ims.qti21.model.xml.ScoreBuilder) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 8 with Choice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice in project OpenOLAT by OpenOLAT.

the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedSimpleChoices.

public List<SimpleChoice> getVisibleOrderedSimpleChoices(OrderInteraction interaction) {
    List<SimpleChoice> choices;
    if (interaction.getShuffle()) {
        // <xsl:variable name="shuffledChoiceOrders" select="$itemSessionState/qw:shuffledInteractionChoiceOrder"
        // as="element(qw:shuffledInteractionChoiceOrder)*"/>
        // <xsl:variable name="choiceSequence" as="xs:string?"
        // select="$shuffledChoiceOrders[@responseIdentifier=$interaction/@responseIdentifier]/@choiceSequence"/>
        List<Identifier> choiceOrders = itemSessionState.getShuffledInteractionChoiceOrder(interaction.getResponseIdentifier());
        choices = new ArrayList<>();
        for (Identifier choiceOrder : choiceOrders) {
            choices.add(interaction.getSimpleChoice(choiceOrder));
        }
    } else {
        choices = interaction.getSimpleChoices();
    }
    return choices.stream().filter((choice) -> isVisible(choice, itemSessionState)).collect(Collectors.toList());
}
Also used : URLBuilder(org.olat.core.gui.render.URLBuilder) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) GraphicAssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) Map(java.util.Map) Flow(uk.ac.ed.ph.jqtiplus.node.content.basic.Flow) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) StringOutput(org.olat.core.gui.render.StringOutput) OLog(org.olat.core.logging.OLog) ListValue(uk.ac.ed.ph.jqtiplus.value.ListValue) FlowStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.FlowStatic) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) Translator(org.olat.core.gui.translator.Translator) InlineChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.InlineChoice) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) FormJSHelper(org.olat.core.gui.components.form.flexible.impl.FormJSHelper) AssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction) StringInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.StringInteraction) Value(uk.ac.ed.ph.jqtiplus.value.Value) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) AssociableHotspot(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.AssociableHotspot) Collectors(java.util.stream.Collectors) GapImg(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapImg) List(java.util.List) BlockStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.BlockStatic) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) AssessmentRenderFunctions.renderValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderValue) TextOrVariable(uk.ac.ed.ph.jqtiplus.node.content.variable.TextOrVariable) BaseType(uk.ac.ed.ph.jqtiplus.value.BaseType) VelocityRenderDecorator(org.olat.core.gui.render.velocity.VelocityRenderDecorator) RecordValue(uk.ac.ed.ph.jqtiplus.value.RecordValue) GraphicOrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) Settings(org.olat.core.helpers.Settings) Orientation(uk.ac.ed.ph.jqtiplus.value.Orientation) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode) GapChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice) QueryUtils(uk.ac.ed.ph.jqtiplus.utils.QueryUtils) CandidateSessionContext(org.olat.ims.qti21.ui.CandidateSessionContext) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) HashMap(java.util.HashMap) StringMultipleAttribute(uk.ac.ed.ph.jqtiplus.attribute.value.StringMultipleAttribute) Prompt(uk.ac.ed.ph.jqtiplus.node.item.interaction.Prompt) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ResponseData(uk.ac.ed.ph.jqtiplus.types.ResponseData) ArrayList(java.util.ArrayList) Gap(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap) SliderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SliderInteraction) Cardinality(uk.ac.ed.ph.jqtiplus.value.Cardinality) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) OrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.OrderInteraction) StringHelper(org.olat.core.util.StringHelper) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) Iterator(java.util.Iterator) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) IOException(java.io.IOException) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Shape(uk.ac.ed.ph.jqtiplus.node.expression.operator.Shape) GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) NullValue(uk.ac.ed.ph.jqtiplus.value.NullValue) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) Tracing(org.olat.core.logging.Tracing) FileValue(uk.ac.ed.ph.jqtiplus.value.FileValue) BodyElement(uk.ac.ed.ph.jqtiplus.node.content.BodyElement) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier)

Example 9 with Choice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice in project OpenOLAT by OpenOLAT.

the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedChoices.

public List<GapChoice> getVisibleOrderedChoices(GapMatchInteraction interaction) {
    List<GapChoice> choices;
    if (interaction.getShuffle()) {
        // <xsl:variable name="shuffledChoiceOrders" select="$itemSessionState/qw:shuffledInteractionChoiceOrder"
        // as="element(qw:shuffledInteractionChoiceOrder)*"/>
        // <xsl:variable name="choiceSequence" as="xs:string?"
        // select="$shuffledChoiceOrders[@responseIdentifier=$interaction/@responseIdentifier]/@choiceSequence"/>
        List<Identifier> choiceOrders = itemSessionState.getShuffledInteractionChoiceOrder(interaction.getResponseIdentifier());
        choices = new ArrayList<>();
        for (Identifier choiceOrder : choiceOrders) {
            choices.add(interaction.getGapChoice(choiceOrder));
        }
    } else {
        choices = new ArrayList<>(interaction.getGapChoices());
    }
    return choices.stream().filter((choice) -> isVisible(choice, itemSessionState)).collect(Collectors.toList());
}
Also used : URLBuilder(org.olat.core.gui.render.URLBuilder) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) GraphicAssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) Map(java.util.Map) Flow(uk.ac.ed.ph.jqtiplus.node.content.basic.Flow) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) StringOutput(org.olat.core.gui.render.StringOutput) OLog(org.olat.core.logging.OLog) ListValue(uk.ac.ed.ph.jqtiplus.value.ListValue) FlowStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.FlowStatic) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) Translator(org.olat.core.gui.translator.Translator) InlineChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.InlineChoice) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) FormJSHelper(org.olat.core.gui.components.form.flexible.impl.FormJSHelper) AssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction) StringInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.StringInteraction) Value(uk.ac.ed.ph.jqtiplus.value.Value) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) AssociableHotspot(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.AssociableHotspot) Collectors(java.util.stream.Collectors) GapImg(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapImg) List(java.util.List) BlockStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.BlockStatic) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) AssessmentRenderFunctions.renderValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderValue) TextOrVariable(uk.ac.ed.ph.jqtiplus.node.content.variable.TextOrVariable) BaseType(uk.ac.ed.ph.jqtiplus.value.BaseType) VelocityRenderDecorator(org.olat.core.gui.render.velocity.VelocityRenderDecorator) RecordValue(uk.ac.ed.ph.jqtiplus.value.RecordValue) GraphicOrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) Settings(org.olat.core.helpers.Settings) Orientation(uk.ac.ed.ph.jqtiplus.value.Orientation) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode) GapChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice) QueryUtils(uk.ac.ed.ph.jqtiplus.utils.QueryUtils) CandidateSessionContext(org.olat.ims.qti21.ui.CandidateSessionContext) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) HashMap(java.util.HashMap) StringMultipleAttribute(uk.ac.ed.ph.jqtiplus.attribute.value.StringMultipleAttribute) Prompt(uk.ac.ed.ph.jqtiplus.node.item.interaction.Prompt) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ResponseData(uk.ac.ed.ph.jqtiplus.types.ResponseData) ArrayList(java.util.ArrayList) Gap(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap) SliderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SliderInteraction) Cardinality(uk.ac.ed.ph.jqtiplus.value.Cardinality) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) OrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.OrderInteraction) StringHelper(org.olat.core.util.StringHelper) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) Iterator(java.util.Iterator) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) IOException(java.io.IOException) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Shape(uk.ac.ed.ph.jqtiplus.node.expression.operator.Shape) GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) NullValue(uk.ac.ed.ph.jqtiplus.value.NullValue) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) Tracing(org.olat.core.logging.Tracing) FileValue(uk.ac.ed.ph.jqtiplus.value.FileValue) BodyElement(uk.ac.ed.ph.jqtiplus.node.content.BodyElement) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) GapChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice)

Example 10 with Choice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice in project OpenOLAT by OpenOLAT.

the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedChoices.

public List<SimpleAssociableChoice> getVisibleOrderedChoices(MatchInteraction interaction, int pos) {
    try {
        List<SimpleAssociableChoice> choices;
        if (interaction.getShuffle()) {
            List<Identifier> choiceOrders = itemSessionState.getShuffledInteractionChoiceOrder(interaction.getResponseIdentifier());
            Map<Identifier, SimpleAssociableChoice> idTochoice = new HashMap<>();
            List<SimpleAssociableChoice> allChoices = interaction.getSimpleMatchSets().get(pos).getSimpleAssociableChoices();
            for (SimpleAssociableChoice allChoice : allChoices) {
                idTochoice.put(allChoice.getIdentifier(), allChoice);
            }
            choices = new ArrayList<>();
            for (Identifier choiceOrder : choiceOrders) {
                SimpleAssociableChoice choice = idTochoice.get(choiceOrder);
                if (choice != null) {
                    choices.add(choice);
                }
            }
        } else {
            choices = interaction.getSimpleMatchSets().get(pos).getSimpleAssociableChoices();
        }
        return choices.stream().filter((choice) -> isVisible(choice, itemSessionState)).collect(Collectors.toList());
    } catch (Exception e) {
        log.error("", e);
        return null;
    }
}
Also used : URLBuilder(org.olat.core.gui.render.URLBuilder) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) GraphicAssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) Map(java.util.Map) Flow(uk.ac.ed.ph.jqtiplus.node.content.basic.Flow) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) StringOutput(org.olat.core.gui.render.StringOutput) OLog(org.olat.core.logging.OLog) ListValue(uk.ac.ed.ph.jqtiplus.value.ListValue) FlowStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.FlowStatic) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) Translator(org.olat.core.gui.translator.Translator) InlineChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.InlineChoice) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) FormJSHelper(org.olat.core.gui.components.form.flexible.impl.FormJSHelper) AssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction) StringInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.StringInteraction) Value(uk.ac.ed.ph.jqtiplus.value.Value) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) AssociableHotspot(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.AssociableHotspot) Collectors(java.util.stream.Collectors) GapImg(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapImg) List(java.util.List) BlockStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.BlockStatic) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) AssessmentRenderFunctions.renderValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderValue) TextOrVariable(uk.ac.ed.ph.jqtiplus.node.content.variable.TextOrVariable) BaseType(uk.ac.ed.ph.jqtiplus.value.BaseType) VelocityRenderDecorator(org.olat.core.gui.render.velocity.VelocityRenderDecorator) RecordValue(uk.ac.ed.ph.jqtiplus.value.RecordValue) GraphicOrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) Settings(org.olat.core.helpers.Settings) Orientation(uk.ac.ed.ph.jqtiplus.value.Orientation) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode) GapChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice) QueryUtils(uk.ac.ed.ph.jqtiplus.utils.QueryUtils) CandidateSessionContext(org.olat.ims.qti21.ui.CandidateSessionContext) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) HashMap(java.util.HashMap) StringMultipleAttribute(uk.ac.ed.ph.jqtiplus.attribute.value.StringMultipleAttribute) Prompt(uk.ac.ed.ph.jqtiplus.node.item.interaction.Prompt) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ResponseData(uk.ac.ed.ph.jqtiplus.types.ResponseData) ArrayList(java.util.ArrayList) Gap(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap) SliderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SliderInteraction) Cardinality(uk.ac.ed.ph.jqtiplus.value.Cardinality) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) OrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.OrderInteraction) StringHelper(org.olat.core.util.StringHelper) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) Iterator(java.util.Iterator) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) IOException(java.io.IOException) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Shape(uk.ac.ed.ph.jqtiplus.node.expression.operator.Shape) GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) NullValue(uk.ac.ed.ph.jqtiplus.value.NullValue) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) Tracing(org.olat.core.logging.Tracing) FileValue(uk.ac.ed.ph.jqtiplus.value.FileValue) BodyElement(uk.ac.ed.ph.jqtiplus.node.content.BodyElement) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) HashMap(java.util.HashMap) IOException(java.io.IOException)

Aggregations

Choice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice)18 ArrayList (java.util.ArrayList)12 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)12 HottextInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction)12 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)12 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)12 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)10 IOException (java.io.IOException)8 HashMap (java.util.HashMap)8 Iterator (java.util.Iterator)8 List (java.util.List)8 Map (java.util.Map)8 Collectors (java.util.stream.Collectors)8 FormJSHelper (org.olat.core.gui.components.form.flexible.impl.FormJSHelper)8 StringOutput (org.olat.core.gui.render.StringOutput)8 URLBuilder (org.olat.core.gui.render.URLBuilder)8 VelocityRenderDecorator (org.olat.core.gui.render.velocity.VelocityRenderDecorator)8 Translator (org.olat.core.gui.translator.Translator)8 Settings (org.olat.core.helpers.Settings)8 OLog (org.olat.core.logging.OLog)8