Search in sources :

Example 6 with QTI21QuestionType

use of org.olat.ims.qti21.model.QTI21QuestionType 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 7 with QTI21QuestionType

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

the class AssessmentResultController method initFormItemResult.

private Results initFormItemResult(FormLayoutContainer layoutCont, TestPlanNode node, Map<Identifier, AssessmentItemRef> identifierToRefs, Map<TestPlanNode, Results> resultsMap) {
    TestPlanNodeKey testPlanNodeKey = node.getKey();
    Identifier identifier = testPlanNodeKey.getIdentifier();
    AssessmentItemRef itemRef = identifierToRefs.get(identifier);
    ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
    AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
    QTI21QuestionType type = QTI21QuestionType.getType(assessmentItem);
    AssessmentItemSession itemSession = identifierToItemSession.get(identifier.toString());
    Results r = new Results(false, node.getSectionPartTitle(), type.getCssClass(), options.isQuestionSummary());
    // init
    r.setSessionStatus(null);
    r.setItemIdentifier(node.getIdentifier().toString());
    ItemSessionState sessionState = testSessionState.getItemSessionStates().get(testPlanNodeKey);
    if (sessionState != null) {
        r.setSessionState(sessionState);
        SessionStatus sessionStatus = sessionState.getSessionStatus();
        if (sessionState != null) {
            r.setSessionStatus(sessionStatus);
        }
    }
    ItemResult itemResult = assessmentResult.getItemResult(identifier.toString());
    if (itemResult != null) {
        extractOutcomeVariable(itemResult.getItemVariables(), r);
    }
    if (itemSession != null) {
        if (itemSession.getManualScore() != null) {
            r.setScore(itemSession.getManualScore());
            r.setManualScore(itemSession.getManualScore());
        }
        r.setComment(itemSession.getCoachComment());
    }
    // update max score of section
    if (options.isUserSolutions() || options.isCorrectSolutions()) {
        InteractionResults interactionResults = initFormItemInteractions(layoutCont, sessionState, resolvedAssessmentItem);
        r.setInteractionResults(interactionResults);
        if (options.isCorrectSolutions()) {
            String correctSolutionId = "correctSolutionItem" + count++;
            FeedbackResultFormItem correctSolutionItem = new FeedbackResultFormItem(correctSolutionId, resolvedAssessmentItem);
            initInteractionResultFormItem(correctSolutionItem, sessionState);
            layoutCont.add(correctSolutionId, correctSolutionItem);
            r.setCorrectSolutionItem(correctSolutionItem);
        }
    }
    updateSectionScoreInformations(node, r, resultsMap);
    return r;
}
Also used : ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ItemResult(uk.ac.ed.ph.jqtiplus.node.result.ItemResult) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) SessionStatus(uk.ac.ed.ph.jqtiplus.node.result.SessionStatus) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) QTI21QuestionType(org.olat.ims.qti21.model.QTI21QuestionType) FeedbackResultFormItem(org.olat.ims.qti21.ui.components.FeedbackResultFormItem) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 8 with QTI21QuestionType

use of org.olat.ims.qti21.model.QTI21QuestionType in project openolat by klemens.

the class AssessmentResultController method initFormItemResult.

private Results initFormItemResult(FormLayoutContainer layoutCont, TestPlanNode node, Map<Identifier, AssessmentItemRef> identifierToRefs, Map<TestPlanNode, Results> resultsMap) {
    TestPlanNodeKey testPlanNodeKey = node.getKey();
    Identifier identifier = testPlanNodeKey.getIdentifier();
    AssessmentItemRef itemRef = identifierToRefs.get(identifier);
    ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
    AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
    QTI21QuestionType type = QTI21QuestionType.getType(assessmentItem);
    AssessmentItemSession itemSession = identifierToItemSession.get(identifier.toString());
    Results r = new Results(false, node.getSectionPartTitle(), type.getCssClass(), options.isQuestionSummary());
    // init
    r.setSessionStatus(null);
    r.setItemIdentifier(node.getIdentifier().toString());
    ItemSessionState sessionState = testSessionState.getItemSessionStates().get(testPlanNodeKey);
    if (sessionState != null) {
        r.setSessionState(sessionState);
        SessionStatus sessionStatus = sessionState.getSessionStatus();
        if (sessionState != null) {
            r.setSessionStatus(sessionStatus);
        }
    }
    ItemResult itemResult = assessmentResult.getItemResult(identifier.toString());
    if (itemResult != null) {
        extractOutcomeVariable(itemResult.getItemVariables(), r);
    }
    if (itemSession != null) {
        if (itemSession.getManualScore() != null) {
            r.setScore(itemSession.getManualScore());
            r.setManualScore(itemSession.getManualScore());
        }
        r.setComment(itemSession.getCoachComment());
    }
    // update max score of section
    if (options.isUserSolutions() || options.isCorrectSolutions()) {
        InteractionResults interactionResults = initFormItemInteractions(layoutCont, sessionState, resolvedAssessmentItem);
        r.setInteractionResults(interactionResults);
        if (options.isCorrectSolutions()) {
            String correctSolutionId = "correctSolutionItem" + count++;
            FeedbackResultFormItem correctSolutionItem = new FeedbackResultFormItem(correctSolutionId, resolvedAssessmentItem);
            initInteractionResultFormItem(correctSolutionItem, sessionState);
            layoutCont.add(correctSolutionId, correctSolutionItem);
            r.setCorrectSolutionItem(correctSolutionItem);
        }
    }
    updateSectionScoreInformations(node, r, resultsMap);
    return r;
}
Also used : ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ItemResult(uk.ac.ed.ph.jqtiplus.node.result.ItemResult) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) SessionStatus(uk.ac.ed.ph.jqtiplus.node.result.SessionStatus) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) QTI21QuestionType(org.olat.ims.qti21.model.QTI21QuestionType) FeedbackResultFormItem(org.olat.ims.qti21.ui.components.FeedbackResultFormItem) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 9 with QTI21QuestionType

use of org.olat.ims.qti21.model.QTI21QuestionType in project openolat by klemens.

the class AssessmentItemEditorController method initFIBEditors.

private AssessmentItemBuilder initFIBEditors(UserRequest ureq, QTI21QuestionType preferedType, AssessmentItem item) {
    FIBAssessmentItemBuilder fibItemBuilder = new FIBAssessmentItemBuilder(item, qtiService.qtiSerializer());
    itemEditor = new FIBEditorController(ureq, getWindowControl(), preferedType, fibItemBuilder, rootDirectory, rootContainer, itemFile, restrictedEdit, readOnly);
    listenTo(itemEditor);
    scoreEditor = new FIBScoreController(ureq, getWindowControl(), fibItemBuilder, itemRef, restrictedEdit, readOnly);
    listenTo(scoreEditor);
    feedbackEditor = new FeedbacksEditorController(ureq, getWindowControl(), fibItemBuilder, rootDirectory, rootContainer, itemFile, FeedbacksEnabler.standardFeedbacks(), restrictedEdit, readOnly);
    listenTo(feedbackEditor);
    tabbedPane.addTab(translate("form.fib"), itemEditor);
    tabbedPane.addTab(translate("form.score"), scoreEditor);
    tabbedPane.addTab(translate("form.feedback"), feedbackEditor);
    return fibItemBuilder;
}
Also used : FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) FIBScoreController(org.olat.ims.qti21.ui.editor.interactions.FIBScoreController) FIBEditorController(org.olat.ims.qti21.ui.editor.interactions.FIBEditorController)

Example 10 with QTI21QuestionType

use of org.olat.ims.qti21.model.QTI21QuestionType in project openolat by klemens.

the class UnkownItemEditorController method doConvertItem.

private void doConvertItem(UserRequest ureq, QTI21QuestionType alternativeType) {
    item.setToolName(QTI21Constants.TOOLNAME);
    item.setToolVersion(Settings.getVersion());
    if (alternativeType == QTI21QuestionType.matchdraganddrop) {
        addClassToInteraction(QTI21Constants.CSS_MATCH_DRAG_AND_DROP);
    }
    qtiService.updateAssesmentObject(itemFileRef, resolvedAssessmentItem);
    fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_NEED_RELOAD, item));
}
Also used : AssessmentItemEvent(org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent)

Aggregations

QTI21QuestionType (org.olat.ims.qti21.model.QTI21QuestionType)20 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)12 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)12 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)6 File (java.io.File)4 FIBAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder)4 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)4 BadResourceException (uk.ac.ed.ph.jqtiplus.provision.BadResourceException)4 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 TreeNode (org.olat.core.gui.components.tree.TreeNode)2 Translator (org.olat.core.gui.translator.Translator)2 AssertException (org.olat.core.logging.AssertException)2 LocalImpl (org.olat.core.util.vfs.LocalImpl)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2