Search in sources :

Example 36 with Interaction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction 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 37 with Interaction

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

the class CorrectionIdentityInteractionsController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    TestPlanNode node = correction.getItemNode();
    TestPlanNodeKey testPlanNodeKey = node.getKey();
    AssessmentItemSession itemSession = correction.getItemSession();
    AssessmentTestSession testSession = correction.getTestSession();
    TestSessionState testSessionState = correction.getTestSessionState();
    answerItem = initFormExtendedTextInteraction(testPlanNodeKey, testSessionState, testSession, formLayout);
    formLayout.add("answer", answerItem);
    viewSolutionButton = uifactory.addFormLink("view.solution", formLayout);
    viewSolutionButton.setIconLeftCSS("o_icon o_icon_open_togglebox");
    solutionItem = initFormExtendedTextInteraction(testPlanNodeKey, testSessionState, testSession, formLayout);
    solutionItem.setVisible(false);
    solutionItem.setShowSolution(true);
    formLayout.add("solution", solutionItem);
    List<InteractionResultFormItem> responseItems = new ArrayList<>(interactions.size());
    for (Interaction interaction : interactions) {
        if (interaction instanceof UploadInteraction || interaction instanceof DrawingInteraction || interaction instanceof ExtendedTextInteraction) {
            manualScore = true;
            File submissionDir = qtiService.getSubmissionDirectory(testSession);
            if (submissionDir != null) {
                submissionDirectoryMaps.put(testSession.getKey(), submissionDir);
            }
        }
    }
    String mScore = "";
    String coachComment = "";
    if (itemSession != null) {
        if (itemSession.getManualScore() != null) {
            mScore = AssessmentHelper.getRoundedScore(itemSession.getManualScore());
        }
        coachComment = itemSession.getCoachComment();
    }
    FormLayoutContainer scoreCont = FormLayoutContainer.createDefaultFormLayout("score.container", getTranslator());
    formLayout.add("score.container", scoreCont);
    statusEl = uifactory.addStaticTextElement("status", "status", "", scoreCont);
    statusEl.setValue(getStatus());
    String fullname = userManager.getUserDisplayName(correction.getAssessedIdentity());
    if (manualScore) {
        scoreEl = uifactory.addTextElement("scoreItem", "score", 6, mScore, scoreCont);
    } else {
        overrideAutoScore = itemSession == null ? null : itemSession.getManualScore();
        String page = velocity_root + "/override_score.html";
        overrideScoreCont = FormLayoutContainer.createCustomFormLayout("extra.score", getTranslator(), page);
        overrideScoreCont.setRootForm(mainForm);
        scoreCont.add(overrideScoreCont);
        overrideScoreCont.setLabel("score", null);
        BigDecimal score = null;
        if (itemSession != null) {
            score = itemSession.getManualScore();
            if (score == null) {
                score = itemSession.getScore();
            }
        }
        overrideScoreCont.contextPut("score", AssessmentHelper.getRoundedScore(score));
        overrideScoreButton = uifactory.addFormLink("override.score", overrideScoreCont, Link.BUTTON_SMALL);
        overrideScoreButton.setDomReplacementWrapperRequired(false);
    }
    commentEl = uifactory.addTextAreaElement("commentItem", "comment", 2500, 4, 60, false, coachComment, scoreCont);
    commentEl.setHelpText(translate("comment.help"));
    IdentityAssessmentItemWrapper wrapper = new IdentityAssessmentItemWrapper(fullname, assessmentItem, correction, responseItems, scoreEl, commentEl, statusEl);
    toReviewEl = uifactory.addCheckboxesHorizontal("to.review", "to.review", scoreCont, onKeys, new String[] { "" });
    if (itemSession != null && itemSession.isToReview()) {
        toReviewEl.select(onKeys[0], true);
    }
    Double minScore = QtiNodesExtractor.extractMinScore(assessmentItem);
    Double maxScore = QtiNodesExtractor.extractMaxScore(assessmentItem);
    if (maxScore != null) {
        if (minScore == null) {
            minScore = 0.0d;
        }
        wrapper.setMinScore(AssessmentHelper.getRoundedScore(minScore));
        wrapper.setMaxScore(AssessmentHelper.getRoundedScore(maxScore));
        wrapper.setMinScoreVal(minScore);
        wrapper.setMaxScoreVal(maxScore);
        if (scoreEl != null) {
            scoreEl.setExampleKey("correction.min.max.score", new String[] { wrapper.getMinScore(), wrapper.getMaxScore() });
        }
        if (overrideScoreCont != null) {
            overrideScoreCont.setExampleKey("correction.min.max.score", new String[] { wrapper.getMinScore(), wrapper.getMaxScore() });
        }
    }
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("interactionWrapper", wrapper);
    }
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) UploadInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) DrawingInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction) UploadInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) InteractionResultFormItem(org.olat.ims.qti21.ui.components.InteractionResultFormItem) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) DrawingInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction) BigDecimal(java.math.BigDecimal) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) File(java.io.File) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 38 with Interaction

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

the class CorrectionOverviewModel method isManualCorrection.

public boolean isManualCorrection(AssessmentItemRef itemRef) {
    String identifier = itemRef.getIdentifier().toString();
    return manualCorrections.computeIfAbsent(identifier, id -> {
        ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
        AssessmentItem item = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
        List<Interaction> interactions = item.getItemBody().findInteractions();
        for (Interaction interaction : interactions) {
            if (interaction instanceof UploadInteraction || interaction instanceof DrawingInteraction || interaction instanceof ExtendedTextInteraction) {
                return true;
            }
        }
        return false;
    });
}
Also used : UploadInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) UploadInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) DrawingInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) DrawingInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction)

Example 39 with Interaction

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

the class UnkownItemEditorController method addClassToInteraction.

private void addClassToInteraction(String cssClass) {
    List<Interaction> interactions = item.getItemBody().findInteractions();
    for (Interaction interaction : interactions) {
        List<String> cssClasses = interaction.getClassAttr();
        if (cssClasses == null) {
            cssClasses = new ArrayList<>();
        } else {
            cssClasses = new ArrayList<>(cssClasses);
        }
        if (!cssClasses.contains(cssClass)) {
            cssClasses.add(cssClass);
        }
        interaction.setClassAttr(cssClasses);
    }
}
Also used : Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)

Example 40 with Interaction

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

the class MultipleChoiceAssessmentItemBuilderTest method readMultipleChoice_allAnswers_1123.

@Test
public void readMultipleChoice_allAnswers_1123() throws IOException, URISyntaxException {
    QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
    URL itemUrl = AssessmentItemBuilderTest.class.getResource("resources/openolat/multiple-choice-score-all-11-2-3.xml");
    AssessmentItem assessmentItem = loadAssessmentItem(itemUrl);
    MultipleChoiceAssessmentItemBuilder itemBuilder = new MultipleChoiceAssessmentItemBuilder(assessmentItem, qtiSerializer);
    // basic check ChoiceInteraction
    AssessmentItem loadedItem = itemBuilder.getAssessmentItem();
    List<Interaction> interactions = loadedItem.getItemBody().findInteractions();
    Assert.assertNotNull(interactions);
    Assert.assertEquals(2, interactions.size());
    Assert.assertTrue(interactions.get(0) instanceof ChoiceInteraction);
    Assert.assertTrue(interactions.get(1) instanceof EndAttemptInteraction);
    // choices
    SimpleChoice correct1 = itemBuilder.getChoice(Identifier.assumedLegal("mc1959a495d449f9af65b38695d3aff1"));
    Assert.assertTrue(itemBuilder.isCorrect(correct1));
    SimpleChoice correct2 = itemBuilder.getChoice(Identifier.assumedLegal("mca856e7adb54d3f9af06ecf9c00da69"));
    Assert.assertTrue(itemBuilder.isCorrect(correct2));
    SimpleChoice wrong1 = itemBuilder.getChoice(Identifier.assumedLegal("mcd39be64a6b4f20a2372cba44340e59"));
    Assert.assertFalse(itemBuilder.isCorrect(wrong1));
    SimpleChoice wrong2 = itemBuilder.getChoice(Identifier.assumedLegal("mc18648f96a84d479817cb5e81165c80"));
    Assert.assertFalse(itemBuilder.isCorrect(wrong2));
    // score
    Double maxScore = itemBuilder.getMaxScoreBuilder().getScore();
    Assert.assertEquals(2.0, maxScore.doubleValue(), 0.0001);
    Double minScore = itemBuilder.getMinScoreBuilder().getScore();
    Assert.assertEquals(0.0, minScore.doubleValue(), 0.0001);
    // correct feedback
    ModalFeedbackBuilder correctFeedback = itemBuilder.getCorrectFeedback();
    Assert.assertNotNull(correctFeedback);
    Assert.assertNotNull(correctFeedback.getText());
    Assert.assertTrue(correctFeedback.getText().contains("All answers are correct"));
    // incorrect
    ModalFeedbackBuilder incorrectFeedback = itemBuilder.getIncorrectFeedback();
    Assert.assertNotNull(incorrectFeedback);
    Assert.assertNotNull(incorrectFeedback.getText());
    Assert.assertTrue(incorrectFeedback.getText().contains("You missed something"));
    // hint
    ModalFeedbackBuilder hint = itemBuilder.getHint();
    Assert.assertNotNull(hint);
    Assert.assertNotNull(hint.getText());
    Assert.assertTrue(hint.getText().contains("This is the correct solution"));
    // per answer
    Assert.assertEquals(ScoreEvaluation.allCorrectAnswers, itemBuilder.getScoreEvaluationMode());
}
Also used : SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) JqtiExtensionManager(uk.ac.ed.ph.jqtiplus.JqtiExtensionManager) EndAttemptInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction) QtiSerializer(uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) EndAttemptInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) MultipleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder) URL(java.net.URL) Test(org.junit.Test)

Aggregations

Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)72 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)42 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)42 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)38 ExtendedTextInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction)32 MatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction)32 Test (org.junit.Test)28 HotspotInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction)28 TextEntryInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction)28 JqtiExtensionManager (uk.ac.ed.ph.jqtiplus.JqtiExtensionManager)26 QtiSerializer (uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer)26 EndAttemptInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction)22 ArrayList (java.util.ArrayList)20 HottextInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction)20 SimpleChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice)18 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)16 Block (uk.ac.ed.ph.jqtiplus.node.content.basic.Block)14 AssociateInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction)14 GapMatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction)14 GraphicAssociateInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction)14