Search in sources :

Example 11 with TestSessionState

use of uk.ac.ed.ph.jqtiplus.state.TestSessionState in project OpenOLAT by OpenOLAT.

the class AssessmentTestDisplayController method createNewTestSessionStateAndController.

private TestSessionController createNewTestSessionStateAndController(NotificationRecorder notificationRecorder) {
    TestProcessingMap testProcessingMap = getTestProcessingMap();
    /* Generate a test plan for this session */
    final TestPlanner testPlanner = new TestPlanner(testProcessingMap);
    if (notificationRecorder != null) {
        testPlanner.addNotificationListener(notificationRecorder);
    }
    final TestPlan testPlan = testPlanner.generateTestPlan();
    final TestSessionState testSessionState = new TestSessionState(testPlan);
    final TestSessionControllerSettings testSessionControllerSettings = new TestSessionControllerSettings();
    testSessionControllerSettings.setTemplateProcessingLimit(computeTemplateProcessingLimit());
    testProcessingMap.reduceItemProcessingMapMap(testPlan.getTestPlanNodeList());
    /* Create controller and wire up notification recorder */
    final TestSessionController result = new TestSessionController(qtiService.jqtiExtensionManager(), testSessionControllerSettings, testProcessingMap, testSessionState);
    if (notificationRecorder != null) {
        result.addNotificationListener(notificationRecorder);
    }
    return result;
}
Also used : TestSessionControllerSettings(uk.ac.ed.ph.jqtiplus.running.TestSessionControllerSettings) TestProcessingMap(uk.ac.ed.ph.jqtiplus.state.TestProcessingMap) TestPlanner(uk.ac.ed.ph.jqtiplus.running.TestPlanner) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) TestPlan(uk.ac.ed.ph.jqtiplus.state.TestPlan) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController)

Example 12 with TestSessionState

use of uk.ac.ed.ph.jqtiplus.state.TestSessionState in project OpenOLAT by OpenOLAT.

the class QTI21AssessmentDetailsController method doCorrection.

private void doCorrection(UserRequest ureq, AssessmentTestSession session) {
    File unzippedDirRoot = FileResourceManager.getInstance().unzipFileResource(testEntry.getOlatResource());
    ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
    ManifestBuilder manifestBuilder = ManifestBuilder.read(new File(unzippedDirRoot, "imsmanifest.xml"));
    TestSessionState testSessionState = qtiService.loadTestSessionState(session);
    CorrectionOverviewModel model = new CorrectionOverviewModel(entry, subIdent, testEntry, resolvedAssessmentTest, manifestBuilder, Collections.singletonMap(assessedIdentity, session), Collections.singletonMap(assessedIdentity, testSessionState));
    correctionCtrl = new CorrectionIdentityAssessmentItemListController(ureq, getWindowControl(), stackPanel, model, session, assessedIdentity);
    listenTo(correctionCtrl);
    stackPanel.pushController(translate("correction"), correctionCtrl);
}
Also used : CorrectionOverviewModel(org.olat.ims.qti21.ui.assessment.CorrectionOverviewModel) ManifestBuilder(org.olat.ims.qti21.model.xml.ManifestBuilder) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) CorrectionIdentityAssessmentItemListController(org.olat.ims.qti21.ui.assessment.CorrectionIdentityAssessmentItemListController) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) File(java.io.File)

Example 13 with TestSessionState

use of uk.ac.ed.ph.jqtiplus.state.TestSessionState in project OpenOLAT by OpenOLAT.

the class AssessmentTestComponentRenderer method renderTestItem.

private void renderTestItem(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, TestPlanNodeKey itemRefKey, URLBuilder ubu, Translator translator, RenderingRequest options) {
    final TestSessionController testSessionController = component.getTestSessionController();
    final TestSessionState testSessionState = testSessionController.getTestSessionState();
    String key = itemRefKey.toString();
    /* We finally do the transform on the _item_ (NB!) */
    sb.append("<div class='qtiworks o_assessmentitem o_assessmenttest'>");
    // test part feedback 'during'
    // test feedback 'during'
    TestPlanNode itemRefNode = testSessionState.getTestPlan().getNode(itemRefKey);
    final EffectiveItemSessionControl effectiveItemSessionControl = itemRefNode.getEffectiveItemSessionControl();
    final boolean allowComments = effectiveItemSessionControl.isAllowComment() && component.isPersonalNotes();
    renderer.setCandidateCommentAllowed(allowComments);
    // write section rubric
    renderSectionRubrics(renderer, sb, component, itemRefNode, ubu, translator);
    // test part -> section -> item
    renderTestItemBody(renderer, sb, component, itemRefNode, ubu, translator, options);
    // controls
    sb.append("<div class='o_button_group o_assessmentitem_controls'>");
    // submit button
    final ItemSessionState itemSessionState = component.getItemSessionState(itemRefNode.getKey());
    if (component.isItemSessionOpen(itemSessionState, options.isSolutionMode())) {
        Component submit = component.getQtiItem().getSubmitButton().getComponent();
        submit.getHTMLRendererSingleton().render(renderer.getRenderer(), sb, submit, ubu, translator, new RenderResult(), null);
    }
    // advanceTestItemAllowed /* && testSessionState.getCurrentItemKey() != null && testSessionController.mayAdvanceItemLinear() */
    if (options.isAdvanceTestItemAllowed()) {
        // TODO need to find if there is a next question
        String title = translator.translate("assessment.test.nextQuestion");
        renderControl(sb, component, title, false, "o_sel_next_question", new NameValuePair("cid", Event.finishItem.name()));
    }
    // nextItem
    if (options.isNextItemAllowed() && testSessionController.hasFollowingNonLinearItem()) {
        String title = translator.translate("assessment.test.nextQuestion");
        renderControl(sb, component, title, false, "o_sel_next_question", new NameValuePair("cid", Event.nextItem.name()));
    }
    // testPartNavigationAllowed"
    if (options.isTestPartNavigationAllowed() && component.isRenderNavigation()) {
        String title = translator.translate("assessment.test.questionMenu");
        renderControl(sb, component, title, false, "o_sel_question_menu", new NameValuePair("cid", Event.testPartNavigation.name()));
    }
    // endTestPartAllowed
    if (options.isEndTestPartAllowed()) {
        String title = component.hasMultipleTestParts() ? translator.translate("assessment.test.end.testPart") : translator.translate("assessment.test.end.test");
        renderControl(sb, component, title, false, "o_sel_end_testpart", new NameValuePair("cid", Event.endTestPart.name()));
    }
    // reviewMode
    if (options.isReviewMode()) {
        String title = translator.translate("assessment.test.backToTestFeedback");
        renderControl(sb, component, title, false, "o_sel_back_test_feedback", new NameValuePair("cid", Event.reviewTestPart.name()));
    }
    // <xsl:variable name="provideItemSolutionButton" as="xs:boolean" select="$reviewMode and $showSolution and not($solutionMode)"/>
    if (options.isReviewMode() && effectiveItemSessionControl.isShowSolution() && !options.isSolutionMode()) {
        String title = translator.translate("assessment.solution.show");
        renderControl(sb, component, title, false, "o_sel_show_solution", new NameValuePair("cid", Event.itemSolution.name()), new NameValuePair("item", key));
    }
    if (options.isReviewMode() && options.isSolutionMode()) {
        String title = translator.translate("assessment.solution.hide");
        renderControl(sb, component, title, false, "o_sel_solution_hide", new NameValuePair("cid", Event.reviewItem.name()), new NameValuePair("item", key));
    }
    // end controls
    sb.append("</div>");
    // end assessmentItem
    sb.append("</div>");
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) RenderResult(org.olat.core.gui.render.RenderResult) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) Component(org.olat.core.gui.components.Component) EffectiveItemSessionControl(uk.ac.ed.ph.jqtiplus.state.EffectiveItemSessionControl)

Example 14 with TestSessionState

use of uk.ac.ed.ph.jqtiplus.state.TestSessionState in project OpenOLAT by OpenOLAT.

the class CorrectionIdentityInteractionsController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    TestPlanNode node = correction.getItemNode();
    TestPlanNodeKey testPlanNodeKey = node.getKey();
    AssessmentItemSession itemSession = correction.getItemSession();
    AssessmentTestSession testSession = correction.getTestSession();
    TestSessionState testSessionState = correction.getTestSessionState();
    answerItem = initFormExtendedTextInteraction(testPlanNodeKey, testSessionState, testSession, formLayout);
    formLayout.add("answer", answerItem);
    viewSolutionButton = uifactory.addFormLink("view.solution", formLayout);
    viewSolutionButton.setIconLeftCSS("o_icon o_icon_open_togglebox");
    solutionItem = initFormExtendedTextInteraction(testPlanNodeKey, testSessionState, testSession, formLayout);
    solutionItem.setVisible(false);
    solutionItem.setShowSolution(true);
    formLayout.add("solution", solutionItem);
    List<InteractionResultFormItem> responseItems = new ArrayList<>(interactions.size());
    for (Interaction interaction : interactions) {
        if (interaction instanceof UploadInteraction || interaction instanceof DrawingInteraction || interaction instanceof ExtendedTextInteraction) {
            manualScore = true;
            File submissionDir = qtiService.getSubmissionDirectory(testSession);
            if (submissionDir != null) {
                submissionDirectoryMaps.put(testSession.getKey(), submissionDir);
            }
        }
    }
    String mScore = "";
    String coachComment = "";
    if (itemSession != null) {
        if (itemSession.getManualScore() != null) {
            mScore = AssessmentHelper.getRoundedScore(itemSession.getManualScore());
        }
        coachComment = itemSession.getCoachComment();
    }
    FormLayoutContainer scoreCont = FormLayoutContainer.createDefaultFormLayout("score.container", getTranslator());
    formLayout.add("score.container", scoreCont);
    statusEl = uifactory.addStaticTextElement("status", "status", "", scoreCont);
    statusEl.setValue(getStatus());
    String fullname = userManager.getUserDisplayName(correction.getAssessedIdentity());
    if (manualScore) {
        scoreEl = uifactory.addTextElement("scoreItem", "score", 6, mScore, scoreCont);
    } else {
        overrideAutoScore = itemSession == null ? null : itemSession.getManualScore();
        String page = velocity_root + "/override_score.html";
        overrideScoreCont = FormLayoutContainer.createCustomFormLayout("extra.score", getTranslator(), page);
        overrideScoreCont.setRootForm(mainForm);
        scoreCont.add(overrideScoreCont);
        overrideScoreCont.setLabel("score", null);
        BigDecimal score = null;
        if (itemSession != null) {
            score = itemSession.getManualScore();
            if (score == null) {
                score = itemSession.getScore();
            }
        }
        overrideScoreCont.contextPut("score", AssessmentHelper.getRoundedScore(score));
        overrideScoreButton = uifactory.addFormLink("override.score", overrideScoreCont, Link.BUTTON_SMALL);
        overrideScoreButton.setDomReplacementWrapperRequired(false);
    }
    commentEl = uifactory.addTextAreaElement("commentItem", "comment", 2500, 4, 60, false, coachComment, scoreCont);
    commentEl.setHelpText(translate("comment.help"));
    IdentityAssessmentItemWrapper wrapper = new IdentityAssessmentItemWrapper(fullname, assessmentItem, correction, responseItems, scoreEl, commentEl, statusEl);
    toReviewEl = uifactory.addCheckboxesHorizontal("to.review", "to.review", scoreCont, onKeys, new String[] { "" });
    if (itemSession != null && itemSession.isToReview()) {
        toReviewEl.select(onKeys[0], true);
    }
    Double minScore = QtiNodesExtractor.extractMinScore(assessmentItem);
    Double maxScore = QtiNodesExtractor.extractMaxScore(assessmentItem);
    if (maxScore != null) {
        if (minScore == null) {
            minScore = 0.0d;
        }
        wrapper.setMinScore(AssessmentHelper.getRoundedScore(minScore));
        wrapper.setMaxScore(AssessmentHelper.getRoundedScore(maxScore));
        wrapper.setMinScoreVal(minScore);
        wrapper.setMaxScoreVal(maxScore);
        if (scoreEl != null) {
            scoreEl.setExampleKey("correction.min.max.score", new String[] { wrapper.getMinScore(), wrapper.getMaxScore() });
        }
        if (overrideScoreCont != null) {
            overrideScoreCont.setExampleKey("correction.min.max.score", new String[] { wrapper.getMinScore(), wrapper.getMaxScore() });
        }
    }
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("interactionWrapper", wrapper);
    }
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) UploadInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) DrawingInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction) UploadInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) InteractionResultFormItem(org.olat.ims.qti21.ui.components.InteractionResultFormItem) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) DrawingInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction) BigDecimal(java.math.BigDecimal) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) File(java.io.File) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 15 with TestSessionState

use of uk.ac.ed.ph.jqtiplus.state.TestSessionState 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)

Aggregations

TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)78 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)42 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)34 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)32 NotificationRecorder (uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder)30 Date (java.util.Date)24 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)24 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)19 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)18 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)18 HashMap (java.util.HashMap)15 QtiCandidateStateException (uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException)13 AssessmentResult (uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult)12 TestSessionController (uk.ac.ed.ph.jqtiplus.running.TestSessionController)12 ArrayList (java.util.ArrayList)10 CandidateTestEventType (org.olat.ims.qti21.model.audit.CandidateTestEventType)10 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)10 Identity (org.olat.core.id.Identity)9 File (java.io.File)8 ParentPartItemRefs (org.olat.ims.qti21.model.ParentPartItemRefs)8