Search in sources :

Example 31 with SimpleAssociableChoice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project OpenOLAT by OpenOLAT.

the class KPrimEditorController method updateMatch.

private void updateMatch(UserRequest ureq) {
    for (KprimWrapper choiceWrapper : choiceWrappers) {
        SimpleAssociableChoice choice = choiceWrapper.getSimpleChoice();
        Identifier choiceIdentifier = choice.getIdentifier();
        String association = ureq.getHttpReq().getParameter(choiceIdentifier.toString());
        if (StringHelper.containsNonWhitespace(association)) {
            if ("correct".equals(association)) {
                itemBuilder.setAssociation(choiceIdentifier, QTI21Constants.CORRECT_IDENTIFIER);
            } else if ("wrong".equals(association)) {
                itemBuilder.setAssociation(choiceIdentifier, QTI21Constants.WRONG_IDENTIFIER);
            }
        }
    }
}
Also used : SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier)

Example 32 with SimpleAssociableChoice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project OpenOLAT by OpenOLAT.

the class KPrimEditorController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (readOnly)
        return;
    // title
    itemBuilder.setTitle(titleEl.getValue());
    // question
    String questionText = textEl.getRawValue();
    itemBuilder.setQuestion(questionText);
    // shuffle
    if (!restrictedEdit) {
        itemBuilder.setShuffle(shuffleEl.isOneSelected() && shuffleEl.isSelected(0));
        // alignment
        if (alignmentEl.isOneSelected() && alignmentEl.isSelected(1)) {
            itemBuilder.addClass(QTI21Constants.CHOICE_ALIGN_RIGHT);
        } else {
            itemBuilder.removeClass(QTI21Constants.CHOICE_ALIGN_RIGHT);
        }
    }
    // update kprims
    for (KprimWrapper choiceWrapper : choiceWrappers) {
        SimpleAssociableChoice choice = choiceWrapper.getSimpleChoice();
        String answer = choiceWrapper.getAnswer().getRawValue();
        itemBuilder.getHtmlHelper().appendHtml(choice, answer);
    }
    // set associations
    if (!restrictedEdit) {
        for (KprimWrapper choiceWrapper : choiceWrappers) {
            SimpleAssociableChoice choice = choiceWrapper.getSimpleChoice();
            Identifier choiceIdentifier = choice.getIdentifier();
            String association = ureq.getHttpReq().getParameter(choiceIdentifier.toString());
            if ("correct".equals(association)) {
                itemBuilder.setAssociation(choiceIdentifier, QTI21Constants.CORRECT_IDENTIFIER);
            } else if ("wrong".equals(association)) {
                itemBuilder.setAssociation(choiceIdentifier, QTI21Constants.WRONG_IDENTIFIER);
            }
        }
    }
    fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), QTI21QuestionType.kprim));
}
Also used : SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) AssessmentItemEvent(org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent)

Example 33 with SimpleAssociableChoice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project OpenOLAT by OpenOLAT.

the class MatchScoreController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    super.initForm(formLayout, listener, ureq);
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_score");
    ScoreBuilder minScore = itemBuilder.getMinScoreBuilder();
    String minValue = minScore == null ? "" : (minScore.getScore() == null ? "" : minScore.getScore().toString());
    minScoreEl = uifactory.addTextElement("min.score", "min.score", 8, minValue, formLayout);
    minScoreEl.setElementCssClass("o_sel_assessment_item_min_score");
    minScoreEl.setEnabled(!restrictedEdit && !readOnly);
    ScoreBuilder maxScore = itemBuilder.getMaxScoreBuilder();
    String maxValue = maxScore == null ? "" : (maxScore.getScore() == null ? "" : maxScore.getScore().toString());
    maxScoreEl = uifactory.addTextElement("max.score", "max.score", 8, maxValue, formLayout);
    maxScoreEl.setElementCssClass("o_sel_assessment_item_max_score");
    maxScoreEl.setEnabled(!restrictedEdit && !readOnly);
    String[] modeValues = new String[] { translate("form.score.assessment.all.correct"), translate("form.score.assessment.per.answer") };
    assessmentModeEl = uifactory.addRadiosHorizontal("assessment.mode", "form.score.assessment.mode", formLayout, modeKeys, modeValues);
    assessmentModeEl.addActionListener(FormEvent.ONCHANGE);
    assessmentModeEl.setEnabled(!restrictedEdit && !readOnly);
    if (itemBuilder.getScoreEvaluationMode() == ScoreEvaluation.perAnswer) {
        assessmentModeEl.select(ScoreEvaluation.perAnswer.name(), true);
    } else {
        assessmentModeEl.select(ScoreEvaluation.allCorrectAnswers.name(), true);
    }
    String scorePage = velocity_root + "/match_score.html";
    scoreCont = FormLayoutContainer.createCustomFormLayout("scores", getTranslator(), scorePage);
    formLayout.add(scoreCont);
    scoreCont.setLabel(null, null);
    scoreCont.setVisible(assessmentModeEl.isSelected(1));
    scoreCont.contextPut("sourceLeft", Boolean.valueOf(sourceLeft));
    for (SimpleAssociableChoice choice : itemBuilder.getSourceMatchSet().getSimpleAssociableChoices()) {
        sourceWrappers.add(createMatchWrapper(choice));
    }
    scoreCont.contextPut("sourceChoices", sourceWrappers);
    for (SimpleAssociableChoice choice : itemBuilder.getTargetMatchSet().getSimpleAssociableChoices()) {
        targetWrappers.add(createMatchWrapper(choice));
    }
    scoreCont.contextPut("targetChoices", targetWrappers);
    forgeScoreElements();
    // Submit Button
    FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsContainer.setRootForm(mainForm);
    buttonsContainer.setVisible(!readOnly);
    formLayout.add(buttonsContainer);
    uifactory.addFormSubmitButton("submit", buttonsContainer);
}
Also used : SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) ScoreBuilder(org.olat.ims.qti21.model.xml.ScoreBuilder) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 34 with SimpleAssociableChoice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project OpenOLAT by OpenOLAT.

the class KPrimStatisticsController method getKPrim.

public Series getKPrim() {
    List<KPrimStatistics> statisticResponses = qtiStatisticsManager.getKPrimStatistics(itemRef.getIdentifier().toString(), assessmentItem, interaction, resourceResult.getSearchParams());
    // TODO String mediaBaseURL = resourceResult.getMediaBaseURL();
    boolean survey = QTIType.survey.equals(resourceResult.getType());
    int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
    List<SimpleMatchSet> matchSets = interaction.getSimpleMatchSets();
    SimpleMatchSet fourMatchSet = matchSets.get(0);
    int i = 0;
    BarSeries d1 = new BarSeries("bar_green", "green", translate("answer.correct"));
    BarSeries d2 = new BarSeries("bar_red", "red", translate("answer.false"));
    BarSeries d3 = new BarSeries("bar_grey", "grey", translate("answer.noanswer"));
    List<ResponseInfos> responseInfos = new ArrayList<>();
    for (KPrimStatistics statisticResponse : statisticResponses) {
        Identifier choiceIdentifier = statisticResponse.getChoiceIdentifier();
        boolean correctRight = statisticResponse.isCorrectRight();
        double right = statisticResponse.getNumOfCorrect();
        double wrong = statisticResponse.getNumOfIncorrect();
        double notanswered = numOfParticipants - right - wrong;
        String label = Integer.toString(++i);
        d1.add(right, label);
        d2.add(wrong, label);
        d3.add(notanswered, label);
        String text = "";
        for (SimpleAssociableChoice choice : fourMatchSet.getSimpleAssociableChoices()) {
            if (choice.getIdentifier().equals(choiceIdentifier)) {
                String textFlow = assessmentHtmlBuilder.flowStaticString(choice.getFlowStatics());
                text = Formatter.formatLatexFormulas(textFlow);
            }
        }
        responseInfos.add(new ResponseInfos(label, text, null, correctRight, survey, true));
    }
    List<BarSeries> serieList = new ArrayList<>(3);
    serieList.add(d1);
    serieList.add(d2);
    serieList.add(d3);
    Series series = new Series(serieList, responseInfos, numOfParticipants, !survey);
    series.setChartType(survey ? SeriesFactory.BAR_ANSWERED : SeriesFactory.BAR_CORRECT_WRONG_NOT);
    series.setItemCss("o_mi_qtikprim");
    return series;
}
Also used : SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) ArrayList(java.util.ArrayList) BarSeries(org.olat.core.gui.components.chart.BarSeries) KPrimStatistics(org.olat.ims.qti21.model.statistics.KPrimStatistics) SimpleMatchSet(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet) Series(org.olat.ims.qti.statistics.ui.Series) BarSeries(org.olat.core.gui.components.chart.BarSeries) ResponseInfos(org.olat.ims.qti.statistics.ui.ResponseInfos) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier)

Example 35 with SimpleAssociableChoice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project OpenOLAT by OpenOLAT.

the class MatchEditorController method doAddSourceRow.

private void doAddSourceRow(UserRequest ureq) {
    SimpleAssociableChoice newChoice = createSimpleAssociableChoice("Text", itemBuilder.getSourceMatchSet());
    if (singleMultiEl.isOneSelected() && singleMultiEl.isSelected(0)) {
        newChoice.setMatchMax(1);
    } else {
        newChoice.setMatchMax(0);
    }
    itemBuilder.getSourceMatchSet().getSimpleAssociableChoices().add(newChoice);
    wrapAnswer(ureq, newChoice, sourceWrappers);
    answersCont.setDirty(true);
}
Also used : AssessmentItemFactory.createSimpleAssociableChoice(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createSimpleAssociableChoice) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)

Aggregations

SimpleAssociableChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)54 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)20 MatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction)18 ArrayList (java.util.ArrayList)17 SimpleMatchSet (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet)16 AssessmentItemFactory.createSimpleAssociableChoice (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createSimpleAssociableChoice)14 HashMap (java.util.HashMap)12 List (java.util.List)10 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)10 AssessmentItemEvent (org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent)10 P (uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P)10 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)10 FlowFormItem (org.olat.ims.qti21.ui.components.FlowFormItem)7 DirectedPairValue (uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)7 Map (java.util.Map)6 Collectors (java.util.stream.Collectors)6 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)6 File (java.io.File)4 UserRequest (org.olat.core.gui.UserRequest)4 FormItem (org.olat.core.gui.components.form.flexible.FormItem)4