Search in sources :

Example 1 with InteractionResultFormItem

use of org.olat.ims.qti21.ui.components.InteractionResultFormItem 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 2 with InteractionResultFormItem

use of org.olat.ims.qti21.ui.components.InteractionResultFormItem in project openolat by klemens.

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)

Aggregations

File (java.io.File)2 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)2 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)2 InteractionResultFormItem (org.olat.ims.qti21.ui.components.InteractionResultFormItem)2 DrawingInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction)2 ExtendedTextInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction)2 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)2 UploadInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction)2 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)2 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)2 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)2