Search in sources :

Example 1 with ModalFeedbackBuilder

use of org.olat.ims.qti21.model.xml.ModalFeedbackBuilder in project OpenOLAT by OpenOLAT.

the class HottextAssessmentItemBuilderTest method readHottextAssessmentItem_allCorrectAnswers.

@Test
public void readHottextAssessmentItem_allCorrectAnswers() throws URISyntaxException {
    QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
    URL itemUrl = AssessmentItemBuilderTest.class.getResource("resources/openolat/hottext-score-all-11-4-0.xml");
    AssessmentItem assessmentItem = loadAssessmentItem(itemUrl);
    HottextAssessmentItemBuilder itemBuilder = new HottextAssessmentItemBuilder(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 HottextInteraction);
    Assert.assertTrue(interactions.get(1) instanceof EndAttemptInteraction);
    // hot texts
    Choice correct1 = itemBuilder.getChoice(Identifier.assumedLegal("htebdb40344641dba115e3c8c6ce3926"));
    Assert.assertTrue(itemBuilder.isCorrect(correct1));
    Choice correct2 = itemBuilder.getChoice(Identifier.assumedLegal("ht103ce53892dea97613005a5ce76be31e"));
    Assert.assertTrue(itemBuilder.isCorrect(correct2));
    Choice wrong1 = itemBuilder.getChoice(Identifier.assumedLegal("hte11a51c3e3d86a5f7293da19a1a8700e"));
    Assert.assertFalse(itemBuilder.isCorrect(wrong1));
    // 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);
    // per answer
    Assert.assertEquals(ScoreEvaluation.allCorrectAnswers, itemBuilder.getScoreEvaluationMode());
    // correct feedback
    ModalFeedbackBuilder correctFeedback = itemBuilder.getCorrectFeedback();
    Assert.assertNotNull(correctFeedback);
    Assert.assertNotNull(correctFeedback.getText());
    Assert.assertTrue(correctFeedback.getText().contains("You check the right answers"));
    // incorrect
    ModalFeedbackBuilder incorrectFeedback = itemBuilder.getIncorrectFeedback();
    Assert.assertNotNull(incorrectFeedback);
    Assert.assertNotNull(incorrectFeedback.getText());
    Assert.assertTrue(incorrectFeedback.getText().contains("Some of your anwsers are not the correct one."));
    // correct solution feedback
    ModalFeedbackBuilder correctSolutionFeedback = itemBuilder.getCorrectSolutionFeedback();
    Assert.assertNotNull(correctSolutionFeedback);
    Assert.assertNotNull(correctSolutionFeedback.getText());
    Assert.assertTrue(correctSolutionFeedback.getText().contains("A little hint towards the correct solution"));
    // hint
    ModalFeedbackBuilder hint = itemBuilder.getHint();
    Assert.assertNotNull(hint);
    Assert.assertNotNull(hint.getText());
    Assert.assertTrue(hint.getText().contains("This is an endAttemptInteraction"));
}
Also used : HottextAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder) Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) 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) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) EndAttemptInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) URL(java.net.URL) Test(org.junit.Test)

Example 2 with ModalFeedbackBuilder

use of org.olat.ims.qti21.model.xml.ModalFeedbackBuilder in project OpenOLAT by OpenOLAT.

the class MultipleChoiceAssessmentItemBuilderTest method readMultipleChoice_perAnswer_1123.

@Test
public void readMultipleChoice_perAnswer_1123() throws IOException, URISyntaxException {
    QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
    URL itemUrl = AssessmentItemBuilderTest.class.getResource("resources/openolat/multiple-choice-per-answer-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(1, interactions.size());
    Assert.assertTrue(interactions.get(0) instanceof ChoiceInteraction);
    // choices
    SimpleChoice correct1 = itemBuilder.getChoice(Identifier.assumedLegal("mc80677ac3f4449ebc689cf60c230a3d"));
    Assert.assertTrue(itemBuilder.isCorrect(correct1));
    SimpleChoice correct2 = itemBuilder.getChoice(Identifier.assumedLegal("mc7e5667abeb415fa05a8c7d8fd3d6bb"));
    Assert.assertTrue(itemBuilder.isCorrect(correct2));
    SimpleChoice wrong1 = itemBuilder.getChoice(Identifier.assumedLegal("mcaacc51e0ca4027b3adb3107cda4e30"));
    Assert.assertFalse(itemBuilder.isCorrect(wrong1));
    SimpleChoice wrong2 = itemBuilder.getChoice(Identifier.assumedLegal("mc1b7b8257e2419b880936ea11bff1f1"));
    Assert.assertFalse(itemBuilder.isCorrect(wrong2));
    // score
    Double maxScore = itemBuilder.getMaxScoreBuilder().getScore();
    Assert.assertEquals(1.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 correct"));
    // incorrect
    ModalFeedbackBuilder incorrectFeedback = itemBuilder.getIncorrectFeedback();
    Assert.assertNotNull(incorrectFeedback);
    Assert.assertNotNull(incorrectFeedback.getText());
    Assert.assertTrue(incorrectFeedback.getText().contains("Some choices are wrong"));
    // per answer
    Assert.assertEquals(ScoreEvaluation.perAnswer, itemBuilder.getScoreEvaluationMode());
}
Also used : SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) JqtiExtensionManager(uk.ac.ed.ph.jqtiplus.JqtiExtensionManager) 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)

Example 3 with ModalFeedbackBuilder

use of org.olat.ims.qti21.model.xml.ModalFeedbackBuilder in project OpenOLAT by OpenOLAT.

the class MultipleChoiceAssessmentItemBuilderTest method readMultipleChoice_perAnswer_1110.

/**
 * Check if a bare bone multiple choice created with our builder make a valid assessmentItem.
 * It has 2 correct choices, two wrong, correct and wrong feedbacks. The max score is 1.0
 * but the 2 choices has each a score of 1.0.
 *
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
public void readMultipleChoice_perAnswer_1110() throws IOException, URISyntaxException {
    QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
    URL itemUrl = AssessmentItemBuilderTest.class.getResource("resources/openolat/multiple-choice-per-answer-11-1-0.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(1, interactions.size());
    Assert.assertTrue(interactions.get(0) instanceof ChoiceInteraction);
    // choices
    SimpleChoice correct1 = itemBuilder.getChoice(Identifier.assumedLegal("mc80677ac3f4449ebc689cf60c230a3d"));
    Assert.assertTrue(itemBuilder.isCorrect(correct1));
    SimpleChoice correct2 = itemBuilder.getChoice(Identifier.assumedLegal("mc7e5667abeb415fa05a8c7d8fd3d6bb"));
    Assert.assertTrue(itemBuilder.isCorrect(correct2));
    SimpleChoice wrong1 = itemBuilder.getChoice(Identifier.assumedLegal("mcaacc51e0ca4027b3adb3107cda4e30"));
    Assert.assertFalse(itemBuilder.isCorrect(wrong1));
    SimpleChoice wrong2 = itemBuilder.getChoice(Identifier.assumedLegal("mc1b7b8257e2419b880936ea11bff1f1"));
    Assert.assertFalse(itemBuilder.isCorrect(wrong2));
    // score
    Double maxScore = itemBuilder.getMaxScoreBuilder().getScore();
    Assert.assertEquals(1.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 correct"));
    // incorrect
    ModalFeedbackBuilder incorrectFeedback = itemBuilder.getIncorrectFeedback();
    Assert.assertNotNull(incorrectFeedback);
    Assert.assertNotNull(incorrectFeedback.getText());
    Assert.assertTrue(incorrectFeedback.getText().contains("Some choices are wrong"));
    // per answer
    Assert.assertEquals(ScoreEvaluation.perAnswer, itemBuilder.getScoreEvaluationMode());
}
Also used : SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) JqtiExtensionManager(uk.ac.ed.ph.jqtiplus.JqtiExtensionManager) 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)

Example 4 with ModalFeedbackBuilder

use of org.olat.ims.qti21.model.xml.ModalFeedbackBuilder in project OpenOLAT by OpenOLAT.

the class OnyxToAssessmentItemBuilderTest method extractSingleChoiceWithExpertConditionFeedbacks.

@Test
public void extractSingleChoiceWithExpertConditionFeedbacks() throws URISyntaxException {
    URL itemUrl = OnyxToAssessmentItemBuilderTest.class.getResource("resources/onyx/sc-expert-conditions-feedback.xml");
    AssessmentItem assessmentItem = loadAssessmentItem(itemUrl);
    QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
    SingleChoiceAssessmentItemBuilder itemBuilder = new SingleChoiceAssessmentItemBuilder(assessmentItem, qtiSerializer);
    List<ModalFeedbackBuilder> feedbackBuilders = itemBuilder.getAdditionalFeedbackBuilders();
    System.out.println(feedbackBuilders);
}
Also used : JqtiExtensionManager(uk.ac.ed.ph.jqtiplus.JqtiExtensionManager) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) QtiSerializer(uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) URL(java.net.URL) Test(org.junit.Test)

Example 5 with ModalFeedbackBuilder

use of org.olat.ims.qti21.model.xml.ModalFeedbackBuilder in project OpenOLAT by OpenOLAT.

the class SingleChoiceAssessmentItemBuilderTest method readSingleChoice.

/**
 * Check if a bare bone multiple choice created with our builder make a valid assessmentItem.
 *
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
public void readSingleChoice() throws IOException, URISyntaxException {
    QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
    URL itemUrl = AssessmentItemBuilderTest.class.getResource("resources/openolat/single-choice-feedbacks.xml");
    AssessmentItem assessmentItem = loadAssessmentItem(itemUrl);
    SingleChoiceAssessmentItemBuilder itemBuilder = new SingleChoiceAssessmentItemBuilder(assessmentItem, qtiSerializer);
    // basic check ChoiceInteraction
    AssessmentItem loadedItem = itemBuilder.getAssessmentItem();
    List<Interaction> interactions = loadedItem.getItemBody().findInteractions();
    Assert.assertNotNull(interactions);
    Assert.assertEquals(1, interactions.size());
    Assert.assertTrue(interactions.get(0) instanceof ChoiceInteraction);
    // correct feedback
    ModalFeedbackBuilder correctFeedback = itemBuilder.getCorrectFeedback();
    Assert.assertNotNull(correctFeedback);
    Assert.assertNotNull(correctFeedback.getText());
    Assert.assertTrue(correctFeedback.getText().contains("This is the correct answer"));
    // incorrect
    ModalFeedbackBuilder incorrectFeedback = itemBuilder.getIncorrectFeedback();
    Assert.assertNotNull(incorrectFeedback);
    Assert.assertNotNull(incorrectFeedback.getText());
    Assert.assertTrue(incorrectFeedback.getText().contains("This is the wrong answer"));
    // correct answer
    SimpleChoice correctChoice = itemBuilder.getChoice(Identifier.assumedLegal("id87d42b76-93d7-42fc-bdec-3e2419fa901d"));
    Assert.assertTrue(itemBuilder.isCorrect(correctChoice));
    // score per
    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) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) 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) 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) URL(java.net.URL) Test(org.junit.Test)

Aggregations

AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)20 URL (java.net.URL)18 Test (org.junit.Test)18 JqtiExtensionManager (uk.ac.ed.ph.jqtiplus.JqtiExtensionManager)18 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)18 QtiSerializer (uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer)18 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)12 SimpleChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice)12 ModalFeedbackBuilder (org.olat.ims.qti21.model.xml.ModalFeedbackBuilder)10 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)10 EndAttemptInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction)10 MultipleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder)8 SingleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder)8 ArrayList (java.util.ArrayList)4 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)4 EssayQuestion (org.olat.ims.qti.editor.beecom.objects.EssayQuestion)4 Question (org.olat.ims.qti.editor.beecom.objects.Question)4 DropdownItem (org.olat.core.gui.components.dropdown.DropdownItem)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 Translator (org.olat.core.gui.translator.Translator)2