Search in sources :

Example 16 with AssessmentItemRef

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

the class CorrectionAssessmentItemListController method doSelect.

private void doSelect(UserRequest ureq, AssessmentItemListEntry listEntry, List<? extends AssessmentItemListEntry> selectedItemSessions) {
    removeAsListenerAndDispose(identityItemCtrl);
    doUnlock();
    AssessmentItemRef itemRef = listEntry.getItemRef();
    AssessmentItemSession reloadItemSession = null;
    if (listEntry.getItemSession() != null) {
        reloadItemSession = qtiService.getAssessmentItemSession(listEntry.getItemSession());
    }
    // lock on item, need to check the lock on identity / test
    String lockSubKey = "item-" + listEntry.getAssessedIdentity().getKey() + "-" + listEntry.getItemRef().getIdentifier().toString();
    OLATResourceable testOres = OresHelper.clone(model.getTestEntry().getOlatResource());
    lockResult = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(testOres, getIdentity(), lockSubKey);
    if (lockResult.isSuccess()) {
        Identity assessedIdentity = listEntry.getAssessedIdentity();
        AssessmentTestSession candidateSession = listEntry.getTestSession();
        TestSessionState testSessionState = qtiService.loadTestSessionState(listEntry.getTestSession());
        List<TestPlanNode> nodes = testSessionState.getTestPlan().getNodes(itemRef.getIdentifier());
        if (nodes.size() == 1) {
            TestPlanNode itemNode = nodes.get(0);
            ItemSessionState itemSessionState = testSessionState.getItemSessionStates().get(itemNode.getKey());
            AssessmentItemCorrection itemCorrection = new AssessmentItemCorrection(assessedIdentity, candidateSession, testSessionState, reloadItemSession, itemSessionState, itemRef, itemNode);
            itemCorrection.setItemSession(reloadItemSession);
            identityItemCtrl = new CorrectionIdentityAssessmentItemNavigationController(ureq, getWindowControl(), model.getTestEntry(), model.getResolvedAssessmentTest(), itemCorrection, listEntry, selectedItemSessions, model);
            listenTo(identityItemCtrl);
            updatePreviousNext();
            stackPanel.pushController(listEntry.getLabel(), identityItemCtrl);
        }
    } else {
        String lockOwnerName = userManager.getUserDisplayName(lockResult.getOwner());
        showWarning("warning.assessment.item.locked", new String[] { lockOwnerName });
    }
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) OLATResourceable(org.olat.core.id.OLATResourceable) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) AssessmentItemCorrection(org.olat.ims.qti21.ui.assessment.model.AssessmentItemCorrection) Identity(org.olat.core.id.Identity)

Example 17 with AssessmentItemRef

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

the class CorrectionIdentityAssessmentItemListController method doSelect.

private void doSelect(UserRequest ureq, CorrectionIdentityAssessmentItemRow row) {
    removeAsListenerAndDispose(identityItemCtrl);
    doUnlock();
    AssessmentItemRef itemRef = row.getItemRef();
    TestSessionState testSessionState = qtiService.loadTestSessionState(candidateSession);
    List<TestPlanNode> nodes = testSessionState.getTestPlan().getNodes(itemRef.getIdentifier());
    AssessmentItemSession reloadItemSession = null;
    if (nodes.size() == 1) {
        TestPlanNode itemNode = nodes.get(0);
        String stringuifiedIdentifier = itemNode.getKey().getIdentifier().toString();
        ParentPartItemRefs parentParts = AssessmentTestHelper.getParentSection(itemNode.getKey(), testSessionState, model.getResolvedAssessmentTest());
        reloadItemSession = qtiService.getOrCreateAssessmentItemSession(candidateSession, parentParts, stringuifiedIdentifier);
    }
    // lock on item, need to check the lock on identity / test
    String lockSubKey = "item-" + reloadItemSession.getKey();
    OLATResourceable testOres = OresHelper.clone(model.getTestEntry().getOlatResource());
    lockResult = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(testOres, getIdentity(), lockSubKey);
    if (lockResult.isSuccess()) {
        if (nodes.size() == 1) {
            TestPlanNode itemNode = nodes.get(0);
            ItemSessionState itemSessionState = testSessionState.getItemSessionStates().get(itemNode.getKey());
            AssessmentItemCorrection itemCorrection = new AssessmentItemCorrection(assessedIdentity, candidateSession, testSessionState, reloadItemSession, itemSessionState, itemRef, itemNode);
            itemCorrection.setItemSession(reloadItemSession);
            ResolvedAssessmentItem resolvedAssessmentItem = model.getResolvedAssessmentTest().getResolvedAssessmentItem(itemRef);
            AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
            identityItemCtrl = new CorrectionIdentityAssessmentItemNavigationController(ureq, getWindowControl(), model.getTestEntry(), model.getResolvedAssessmentTest(), itemCorrection, row, tableModel.getObjects(), model);
            listenTo(identityItemCtrl);
            stackPanel.pushController(assessmentItem.getTitle(), identityItemCtrl);
            updatePreviousNext();
        }
    } else {
        String lockOwnerName = userManager.getUserDisplayName(lockResult.getOwner());
        showWarning("warning.assessment.item.locked", new String[] { lockOwnerName });
    }
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) ParentPartItemRefs(org.olat.ims.qti21.model.ParentPartItemRefs) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) OLATResourceable(org.olat.core.id.OLATResourceable) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) AssessmentItemCorrection(org.olat.ims.qti21.ui.assessment.model.AssessmentItemCorrection) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)

Example 18 with AssessmentItemRef

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

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

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 20 with AssessmentItemRef

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

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)

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