Search in sources :

Example 11 with AssessmentItemRef

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project OpenOLAT by OpenOLAT.

the class QTI21PrintController method appendNodes.

private void appendNodes(UserRequest ureq, TreeNode node, QTI21StatisticResourceResult resourceResult, List<String> pageNames) {
    if (node.getUserObject() instanceof AssessmentItemRef) {
        Controller itemCtrl = resourceResult.getController(ureq, getWindowControl(), null, node, true);
        if (itemCtrl != null) {
            String itemPageName = "page" + count++;
            mainVC.put(itemPageName, itemCtrl.getInitialComponent());
            pageNames.add(itemPageName);
        }
    }
    for (int i = 0; i < node.getChildCount(); i++) {
        appendNodes(ureq, (TreeNode) node.getChildAt(i), resourceResult, pageNames);
    }
}
Also used : AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController)

Example 12 with AssessmentItemRef

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project OpenOLAT by OpenOLAT.

the class QTI12To21Converter method convert.

private void convert(Section section, TestPart testPart) throws URISyntaxException {
    AssessmentSection assessmentSection = AssessmentTestFactory.appendAssessmentSection("Section", testPart);
    assessmentSection.setTitle(section.getTitle());
    convertDuration(section.getDuration(), assessmentSection);
    RubricBlock rubricBlock = assessmentSection.getRubricBlocks().get(0);
    rubricBlock.getBlocks().clear();
    String objectives = section.getObjectives();
    htmlBuilder.appendHtml(rubricBlock, blockedHtml(objectives));
    boolean shuffle = SelectionOrdering.RANDOM.equals(section.getSelection_ordering().getOrderType());
    assessmentSection.getOrdering().setShuffle(shuffle);
    int selectionNum = section.getSelection_ordering().getSelectionNumber();
    if (selectionNum > 0) {
        Selection selection = new Selection(assessmentSection);
        selection.setSelect(selectionNum);
        assessmentSection.setSelection(selection);
    }
    List<Item> items = section.getItems();
    for (Item item : items) {
        AssessmentItemBuilder itemBuilder = null;
        if (item != null && item.getQuestion() != null) {
            int questionType = item.getQuestion().getType();
            switch(questionType) {
                case Question.TYPE_SC:
                    itemBuilder = convertSingleChoice(item);
                    break;
                case Question.TYPE_MC:
                    itemBuilder = convertMultipleChoice(item);
                    break;
                case Question.TYPE_KPRIM:
                    itemBuilder = convertKPrim(item);
                    break;
                case Question.TYPE_FIB:
                    itemBuilder = convertFIB(item);
                    break;
                case Question.TYPE_ESSAY:
                    itemBuilder = convertEssay(item);
                    break;
            }
        } else {
            errors.add(item.getTitle());
            log.error("Item without question: " + item);
        }
        if (itemBuilder != null) {
            itemBuilder.build();
            AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
            AssessmentItemRef itemRef = new AssessmentItemRef(assessmentSection);
            String itemId = IdentifierGenerator.newAsString(itemBuilder.getQuestionType().getPrefix());
            itemRef.setIdentifier(Identifier.parseString(itemId));
            convertItemBasics(item, itemRef);
            File itemFile = new File(unzippedDirRoot, itemId + ".xml");
            itemRef.setHref(new URI(itemFile.getName()));
            assessmentSection.getSectionParts().add(itemRef);
            persistAssessmentObject(itemFile, assessmentItem);
            appendResourceAndMetadata(item, itemBuilder, itemFile);
            // collect max score
            Double maxScore = QtiNodesExtractor.extractMaxScore(assessmentItem);
            if (maxScore != null && maxScore.doubleValue() > 0.0d) {
                atomicMaxScore.add(maxScore.doubleValue());
            }
        }
    }
}
Also used : Selection(uk.ac.ed.ph.jqtiplus.node.test.Selection) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) 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) SimpleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) URI(java.net.URI) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) Item(org.olat.ims.qti.editor.beecom.objects.Item) VFSItem(org.olat.core.util.vfs.VFSItem) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock) File(java.io.File)

Example 13 with AssessmentItemRef

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project OpenOLAT by OpenOLAT.

the class QTI21QPoolServiceProvider method importRepositoryEntry.

public List<QuestionItem> importRepositoryEntry(Identity owner, RepositoryEntry repositoryEntry, Locale defaultLocale) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedDirRoot = frm.unzipFileResource(repositoryEntry.getOlatResource());
    ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, true);
    ManifestBuilder clonedManifestBuilder = ManifestBuilder.read(new File(unzippedDirRoot, "imsmanifest.xml"));
    List<AssessmentItemRef> itemRefs = resolvedAssessmentTest.getAssessmentItemRefs();
    List<QuestionItem> importedItems = new ArrayList<>(itemRefs.size());
    for (AssessmentItemRef itemRef : itemRefs) {
        ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
        RootNodeLookup<AssessmentItem> rootNode = resolvedAssessmentItem.getItemLookup();
        URI itemUri = rootNode.getSystemId();
        File itemFile = new File(itemUri);
        String relativePathToManifest = unzippedDirRoot.toPath().relativize(itemFile.toPath()).toString();
        AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
        ResourceType resource = clonedManifestBuilder.getResourceTypeByHref(relativePathToManifest);
        ManifestMetadataBuilder metadata = clonedManifestBuilder.getMetadataBuilder(resource, true);
        QuestionItem qitem = importAssessmentItemRef(owner, assessmentItem, itemFile, metadata, defaultLocale);
        importedItems.add(qitem);
    }
    return importedItems;
}
Also used : ManifestBuilder(org.olat.ims.qti21.model.xml.ManifestBuilder) ArrayList(java.util.ArrayList) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ResourceType(org.olat.imscp.xml.manifest.ResourceType) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) URI(java.net.URI) ManifestMetadataBuilder(org.olat.ims.qti21.model.xml.ManifestMetadataBuilder) FileResourceManager(org.olat.fileresource.FileResourceManager) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) File(java.io.File) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 14 with AssessmentItemRef

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project OpenOLAT by OpenOLAT.

the class AssessmentResultController method initFormSections.

private void initFormSections(FormLayoutContainer layoutCont, Results testResults) {
    List<Results> itemResults = new ArrayList<>();
    layoutCont.contextPut("itemResults", itemResults);
    Map<Identifier, AssessmentItemRef> identifierToRefs = new HashMap<>();
    for (AssessmentItemRef itemRef : resolvedAssessmentTest.getAssessmentItemRefs()) {
        identifierToRefs.put(itemRef.getIdentifier(), itemRef);
    }
    Map<TestPlanNode, Results> resultsMap = new HashMap<>();
    TestPlan testPlan = testSessionState.getTestPlan();
    List<TestPlanNode> nodes = testPlan.getTestPlanNodeList();
    for (TestPlanNode node : nodes) {
        TestPlanNodeKey testPlanNodeKey = node.getKey();
        TestNodeType testNodeType = node.getTestNodeType();
        if (testNodeType == TestNodeType.ASSESSMENT_SECTION) {
            Results r = new Results(true, node.getSectionPartTitle(), "o_mi_qtisection", options.isSectionSummary());
            AssessmentSectionSessionState sectionState = testSessionState.getAssessmentSectionSessionStates().get(testPlanNodeKey);
            if (sectionState != null) {
                r.setSessionState(sectionState);
            }
            resultsMap.put(node, r);
            itemResults.add(r);
            testResults.setNumberOfSections(testResults.getNumberOfSections() + 1);
        } else if (testNodeType == TestNodeType.ASSESSMENT_ITEM_REF) {
            Results results = initFormItemResult(layoutCont, node, identifierToRefs, resultsMap);
            if (results != null) {
                itemResults.add(results);
            }
            testResults.setNumberOfQuestions(testResults.getNumberOfQuestions() + 1);
            if (results.sessionStatus == SessionStatus.FINAL) {
                testResults.setNumberOfAnsweredQuestions(testResults.getNumberOfAnsweredQuestions() + 1);
            }
            if (results.hasMaxScore()) {
                testResults.addMaxScore(results);
            }
        }
    }
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) HashMap(java.util.HashMap) TestPlan(uk.ac.ed.ph.jqtiplus.state.TestPlan) ArrayList(java.util.ArrayList) AssessmentSectionSessionState(uk.ac.ed.ph.jqtiplus.state.AssessmentSectionSessionState) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) TestNodeType(uk.ac.ed.ph.jqtiplus.state.TestPlanNode.TestNodeType) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 15 with AssessmentItemRef

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef 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)

Aggregations

AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)70 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)34 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)32 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)28 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)22 TreeNode (org.olat.core.gui.components.tree.TreeNode)20 File (java.io.File)18 URI (java.net.URI)18 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)18 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)18 ArrayList (java.util.ArrayList)16 HashMap (java.util.HashMap)16 ManifestMetadataBuilder (org.olat.ims.qti21.model.xml.ManifestMetadataBuilder)12 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)12 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)12 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)12 Identity (org.olat.core.id.Identity)10 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)10 SectionPart (uk.ac.ed.ph.jqtiplus.node.test.SectionPart)10 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)10