Search in sources :

Example 11 with KPrimAssessmentItemBuilder

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

the class QTI12To21Converter method convertKPrim.

private AssessmentItemBuilder convertKPrim(Item item) {
    KPrimAssessmentItemBuilder itemBuilder = new KPrimAssessmentItemBuilder("Kprim", "New answer", qtiSerializer);
    convertItemBasics(item, itemBuilder);
    Question question = item.getQuestion();
    itemBuilder.setShuffle(question.isShuffle());
    List<Response> responses = question.getResponses();
    List<SimpleAssociableChoice> choices = itemBuilder.getKprimChoices();
    for (int i = 0; i < 4; i++) {
        Response response = responses.get(i);
        SimpleAssociableChoice choice = choices.get(i);
        String answer = response.getContent().renderAsHtmlForEditor();
        answer = blockedHtml(answer);
        if (StringHelper.isHtml(answer)) {
            htmlBuilder.appendHtml(choice, answer);
        } else {
            P firstChoiceText = AssessmentItemFactory.getParagraph(choice, answer);
            choice.getFlowStatics().clear();
            choice.getFlowStatics().add(firstChoiceText);
        }
        if (response.isCorrect()) {
            itemBuilder.setAssociation(choice.getIdentifier(), QTI21Constants.CORRECT_IDENTIFIER);
        } else {
            itemBuilder.setAssociation(choice.getIdentifier(), QTI21Constants.WRONG_IDENTIFIER);
        }
    }
    double score = question.getMaxValue();
    itemBuilder.setMinScore(0.0d);
    itemBuilder.setMaxScore(score);
    return itemBuilder;
}
Also used : FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) ChoiceResponse(org.olat.ims.qti.editor.beecom.objects.ChoiceResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) EssayResponse(org.olat.ims.qti.editor.beecom.objects.EssayResponse) P(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P) KPrimAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) Question(org.olat.ims.qti.editor.beecom.objects.Question)

Example 12 with KPrimAssessmentItemBuilder

use of org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder in project openolat by klemens.

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 13 with KPrimAssessmentItemBuilder

use of org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder in project openolat by klemens.

the class CSVToAssessmentItemConverter method processPoints.

private void processPoints(String[] parts) {
    if (currentItem == null)
        return;
    double points = parseFloat(parts[1], 1.0f);
    AssessmentItemBuilder itemBuilder = currentItem.getItemBuilder();
    if (itemBuilder instanceof SimpleChoiceAssessmentItemBuilder) {
        itemBuilder.setMinScore(0.0d);
        itemBuilder.setMaxScore(points);
    } else if (itemBuilder instanceof FIBAssessmentItemBuilder) {
        itemBuilder.setMinScore(0.0d);
        itemBuilder.setMaxScore(points);
    } else if (itemBuilder instanceof KPrimAssessmentItemBuilder) {
        itemBuilder.setMinScore(0.0d);
        itemBuilder.setMaxScore(points);
    } else if (itemBuilder instanceof MatchAssessmentItemBuilder) {
        itemBuilder.setMinScore(0.0d);
        itemBuilder.setMaxScore(points);
    }
}
Also used : SimpleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) KPrimAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder) SimpleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) 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) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder)

Example 14 with KPrimAssessmentItemBuilder

use of org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder in project openolat by klemens.

the class AssessmentTestComposerController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (menuTree == source) {
        if (event instanceof TreeEvent) {
            TreeEvent te = (TreeEvent) event;
            String cmd = te.getCommand();
            if (MenuTree.COMMAND_TREENODE_CLICKED.equals(cmd)) {
                TreeNode selectedNode = menuTree.getTreeModel().getNodeById(te.getNodeId());
                partEditorFactory(ureq, selectedNode);
            }
        } else if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_DROP)) {
            TreeDropEvent tde = (TreeDropEvent) event;
            doDrop(ureq, tde.getDroppedNodeId(), tde.getTargetNodeId(), tde.isAsChild());
        }
    } else if (newSectionLink == source) {
        doNewSection(ureq, menuTree.getSelectedNode());
    } else if (newTestPartLink == source) {
        doNewTestPart(ureq);
    } else if (newSingleChoiceLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new SingleChoiceAssessmentItemBuilder(translate("new.sc"), translate("new.answer"), qtiService.qtiSerializer()));
    } else if (newMultipleChoiceLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new MultipleChoiceAssessmentItemBuilder(translate("new.mc"), translate("new.answer"), qtiService.qtiSerializer()));
    } else if (newKPrimLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new KPrimAssessmentItemBuilder(translate("new.kprim"), translate("new.answer"), qtiService.qtiSerializer()));
    } else if (newMatchLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new MatchAssessmentItemBuilder(translate("new.match"), QTI21Constants.CSS_MATCH_MATRIX, qtiService.qtiSerializer()));
    } else if (newMatchDragAndDropLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new MatchAssessmentItemBuilder(translate("new.matchdraganddrop"), QTI21Constants.CSS_MATCH_DRAG_AND_DROP, qtiService.qtiSerializer()));
    } else if (newMatchTrueFalseLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new MatchAssessmentItemBuilder(translate("new.matchtruefalse"), QTI21Constants.CSS_MATCH_TRUE_FALSE, translate("match.unanswered"), translate("match.true"), translate("match.false"), qtiService.qtiSerializer()));
    } else if (newFIBLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new FIBAssessmentItemBuilder(translate("new.fib"), EntryType.text, qtiService.qtiSerializer()));
    } else if (newNumericalLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new FIBAssessmentItemBuilder(translate("new.fib.numerical"), EntryType.numerical, qtiService.qtiSerializer()));
    } else if (newHotspotLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new HotspotAssessmentItemBuilder(translate("new.hotspot"), qtiService.qtiSerializer()));
    } else if (newHottextLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new HottextAssessmentItemBuilder(translate("new.hottext"), translate("new.hottext.start"), translate("new.hottext.text"), qtiService.qtiSerializer()));
    } else if (newEssayLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new EssayAssessmentItemBuilder(translate("new.essay"), qtiService.qtiSerializer()));
    } else if (newUploadLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new UploadAssessmentItemBuilder(translate("new.upload"), qtiService.qtiSerializer()));
    } else if (newDrawingLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new DrawingAssessmentItemBuilder(translate("new.drawing"), qtiService.qtiSerializer()));
    } else if (importFromPoolLink == source) {
        doSelectQItem(ureq);
    } else if (importFromTableLink == source) {
        doImportTable(ureq);
    } else if (exportToPoolLink == source) {
        doExportPool();
    } else if (exportToDocxLink == source) {
        doExportDocx(ureq);
    } else if (deleteLink == source) {
        doConfirmDelete(ureq);
    } else if (copyLink == source) {
        doCopy(ureq);
    } else if (reloadInCacheLink == source) {
        doForceReloadFiles(ureq);
    }
}
Also used : HottextAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) MultipleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) TreeEvent(org.olat.core.gui.components.tree.TreeEvent) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) KPrimAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) HotspotAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder) TreeDropEvent(org.olat.core.gui.components.tree.TreeDropEvent) UploadAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.UploadAssessmentItemBuilder) DrawingAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.DrawingAssessmentItemBuilder)

Aggregations

KPrimAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder)14 EssayAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder)8 FIBAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder)8 MatchAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder)8 MultipleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder)8 SingleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder)8 AssessmentItemBuilder (org.olat.ims.qti21.model.xml.AssessmentItemBuilder)6 Translator (org.olat.core.gui.translator.Translator)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 SimpleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder)4 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)4 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)4 UploadAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.UploadAssessmentItemBuilder)3 File (java.io.File)2 Test (org.junit.Test)2 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)2 TreeDropEvent (org.olat.core.gui.components.tree.TreeDropEvent)2 TreeEvent (org.olat.core.gui.components.tree.TreeEvent)2