Search in sources :

Example 1 with SingleChoiceAssessmentItemBuilder

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

use of org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder 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)

Example 3 with SingleChoiceAssessmentItemBuilder

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

the class AssessmentItemEditorController method initSingleChoiceEditors.

private AssessmentItemBuilder initSingleChoiceEditors(UserRequest ureq, AssessmentItem item) {
    SingleChoiceAssessmentItemBuilder scItemBuilder = new SingleChoiceAssessmentItemBuilder(item, qtiService.qtiSerializer());
    itemEditor = new SingleChoiceEditorController(ureq, getWindowControl(), scItemBuilder, rootDirectory, rootContainer, itemFile, restrictedEdit, readOnly);
    listenTo(itemEditor);
    scoreEditor = new ChoiceScoreController(ureq, getWindowControl(), scItemBuilder, itemRef, itemFile, restrictedEdit, readOnly, "Test editor QTI 2.1 in detail#details_testeditor_score");
    listenTo(scoreEditor);
    feedbackEditor = new FeedbacksEditorController(ureq, getWindowControl(), scItemBuilder, rootDirectory, rootContainer, itemFile, FeedbacksEnabler.standardFeedbacks(), restrictedEdit, readOnly);
    listenTo(feedbackEditor);
    tabbedPane.addTab(translate("form.choice"), itemEditor);
    tabbedPane.addTab(translate("form.score"), scoreEditor);
    tabbedPane.addTab(translate("form.feedback"), feedbackEditor);
    return scItemBuilder;
}
Also used : ChoiceScoreController(org.olat.ims.qti21.ui.editor.interactions.ChoiceScoreController) HotspotChoiceScoreController(org.olat.ims.qti21.ui.editor.interactions.HotspotChoiceScoreController) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) SingleChoiceEditorController(org.olat.ims.qti21.ui.editor.interactions.SingleChoiceEditorController)

Example 4 with SingleChoiceAssessmentItemBuilder

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

the class QTI21QPoolServiceProvider method createItem.

public QuestionItem createItem(Identity identity, QTI21QuestionType type, String title, Locale locale) {
    AssessmentItemBuilder itemBuilder = null;
    Translator translator = Util.createPackageTranslator(AssessmentTestComposerController.class, locale);
    switch(type) {
        case sc:
            itemBuilder = new SingleChoiceAssessmentItemBuilder(translator.translate("new.sc"), translator.translate("new.answer"), qtiService.qtiSerializer());
            break;
        case mc:
            itemBuilder = new MultipleChoiceAssessmentItemBuilder(translator.translate("new.mc"), translator.translate("new.answer"), qtiService.qtiSerializer());
            break;
        case kprim:
            itemBuilder = new KPrimAssessmentItemBuilder(translator.translate("new.kprim"), translator.translate("new.answer"), qtiService.qtiSerializer());
            break;
        case match:
            itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_MATRIX, qtiService.qtiSerializer());
            break;
        case matchdraganddrop:
            itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_DRAG_AND_DROP, qtiService.qtiSerializer());
            break;
        case matchtruefalse:
            itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_TRUE_FALSE, translator.translate("match.unanswered"), translator.translate("match.true"), translator.translate("match.false"), qtiService.qtiSerializer());
            break;
        case fib:
            itemBuilder = new FIBAssessmentItemBuilder(translator.translate("new.fib"), EntryType.text, qtiService.qtiSerializer());
            break;
        case numerical:
            itemBuilder = new FIBAssessmentItemBuilder(translator.translate("new.fib.numerical"), EntryType.numerical, qtiService.qtiSerializer());
            break;
        case essay:
            itemBuilder = new EssayAssessmentItemBuilder(translator.translate("new.essay"), qtiService.qtiSerializer());
            break;
        case upload:
            itemBuilder = new UploadAssessmentItemBuilder(translator.translate("new.upload"), qtiService.qtiSerializer());
            break;
        case drawing:
            itemBuilder = new DrawingAssessmentItemBuilder(translator.translate("new.drawing"), qtiService.qtiSerializer());
            break;
        case hotspot:
            itemBuilder = new HotspotAssessmentItemBuilder(translator.translate("new.hotspot"), qtiService.qtiSerializer());
            break;
        case hottext:
            itemBuilder = new HottextAssessmentItemBuilder(translator.translate("new.hottext"), translator.translate("new.hottext.start"), translator.translate("new.hottext.text"), qtiService.qtiSerializer());
            break;
        default:
            return null;
    }
    AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
    assessmentItem.setLabel(title);
    assessmentItem.setTitle(title);
    AssessmentItemMetadata itemMetadata = new AssessmentItemMetadata();
    itemMetadata.setQuestionType(type);
    QTI21ImportProcessor processor = new QTI21ImportProcessor(identity, locale);
    QuestionItemImpl qitem = processor.processItem(assessmentItem, "", null, "OpenOLAT", Settings.getVersion(), itemMetadata);
    VFSContainer baseDir = qpoolFileStorage.getContainer(qitem.getDirectory());
    VFSLeaf leaf = baseDir.createChildLeaf(qitem.getRootFilename());
    File itemFile = ((LocalImpl) leaf).getBasefile();
    qtiService.persistAssessmentObject(itemFile, assessmentItem);
    // create imsmanifest
    ManifestBuilder manifest = ManifestBuilder.createAssessmentItemBuilder();
    manifest.appendAssessmentItem(itemFile.getName());
    manifest.write(new File(itemFile.getParentFile(), "imsmanifest.xml"));
    return qitem;
}
Also used : HottextAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ManifestBuilder(org.olat.ims.qti21.model.xml.ManifestBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) HotspotAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder) UploadAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.UploadAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) HottextAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder) DrawingAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.DrawingAssessmentItemBuilder) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) AssessmentItemBuilder(org.olat.ims.qti21.model.xml.AssessmentItemBuilder) KPrimAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder) MultipleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder) MultipleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) KPrimAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder) Translator(org.olat.core.gui.translator.Translator) AssessmentItemMetadata(org.olat.ims.qti21.model.xml.AssessmentItemMetadata) HotspotAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder) UploadAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.UploadAssessmentItemBuilder) LocalImpl(org.olat.core.util.vfs.LocalImpl) File(java.io.File) DrawingAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.DrawingAssessmentItemBuilder)

Example 5 with SingleChoiceAssessmentItemBuilder

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

the class CSVToAssessmentItemConverter method processChoice_smc.

private void processChoice_smc(String[] parts, SimpleChoiceAssessmentItemBuilder choiceBuilder) {
    double point = parseFloat(parts[0], 1.0f);
    String content = parts[1];
    ChoiceInteraction interaction = choiceBuilder.getChoiceInteraction();
    SimpleChoice newChoice = AssessmentItemFactory.createSimpleChoice(interaction, content, choiceBuilder.getQuestionType().getPrefix());
    choiceBuilder.addSimpleChoice(newChoice);
    choiceBuilder.setMapping(newChoice.getIdentifier(), point);
    if (point > 0.0) {
        if (choiceBuilder instanceof MultipleChoiceAssessmentItemBuilder) {
            ((MultipleChoiceAssessmentItemBuilder) choiceBuilder).addCorrectAnswer(newChoice.getIdentifier());
        } else {
            ((SingleChoiceAssessmentItemBuilder) choiceBuilder).setCorrectAnswer(newChoice.getIdentifier());
        }
    }
}
Also used : SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) MultipleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder)

Aggregations

SingleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder)24 Test (org.junit.Test)12 JqtiExtensionManager (uk.ac.ed.ph.jqtiplus.JqtiExtensionManager)12 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)12 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)12 QtiSerializer (uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer)12 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)10 SimpleChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice)10 URL (java.net.URL)8 MultipleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder)8 EssayAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder)6 FIBAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder)6 KPrimAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder)6 MatchAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder)6 File (java.io.File)4 HashMap (java.util.HashMap)4 DrawingAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.DrawingAssessmentItemBuilder)4 HotspotAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder)4 HottextAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder)4 UploadAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.UploadAssessmentItemBuilder)4