Search in sources :

Example 1 with ScoreBuilder

use of org.olat.ims.qti21.model.xml.ScoreBuilder in project OpenOLAT by OpenOLAT.

the class ChoiceScoreController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormContextHelp(contextHelpUrl);
    super.initForm(formLayout, listener, ureq);
    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[] choiceKeys = new String[0];
    String[] choiceValues = new String[0];
    maxChoicesEl = uifactory.addDropdownSingleselect("max.choices", formLayout, choiceKeys, choiceValues, null);
    maxChoicesEl.setEnabled(!restrictedEdit && !readOnly);
    minChoicesEl = uifactory.addDropdownSingleselect("min.choices", formLayout, choiceKeys, choiceValues, null);
    minChoicesEl.setEnabled(!restrictedEdit && !readOnly);
    updateMinMaxChoices();
    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.setEnabled(!restrictedEdit && !readOnly);
    assessmentModeEl.addActionListener(FormEvent.ONCHANGE);
    if (itemBuilder.getScoreEvaluationMode() == ScoreEvaluation.perAnswer) {
        assessmentModeEl.select(ScoreEvaluation.perAnswer.name(), true);
    } else {
        assessmentModeEl.select(ScoreEvaluation.allCorrectAnswers.name(), true);
    }
    String scorePage = velocity_root + "/choices_score.html";
    scoreCont = FormLayoutContainer.createCustomFormLayout("scores", getTranslator(), scorePage);
    formLayout.add(scoreCont);
    scoreCont.setLabel(null, null);
    for (Choice choice : itemBuilder.getChoices()) {
        ChoiceWrapper wrapper = createChoiceWrapper(choice);
        wrappers.add(wrapper);
    }
    scoreCont.contextPut("choices", wrappers);
    scoreCont.contextPut("restrictedEdit", restrictedEdit || readOnly);
    scoreCont.setVisible(assessmentModeEl.isSelected(1));
    // Submit Button
    FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsContainer.setRootForm(mainForm);
    buttonsContainer.setVisible(!readOnly);
    formLayout.add(buttonsContainer);
    uifactory.addFormSubmitButton("submit", buttonsContainer);
}
Also used : Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) ScoreBuilder(org.olat.ims.qti21.model.xml.ScoreBuilder) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 2 with ScoreBuilder

use of org.olat.ims.qti21.model.xml.ScoreBuilder in project openolat by klemens.

the class OnyxToAssessmentItemBuilderTest method extractsingleChoiceWithFeedbacks.

@Test
public void extractsingleChoiceWithFeedbacks() throws URISyntaxException {
    URL itemUrl = OnyxToAssessmentItemBuilderTest.class.getResource("resources/onyx/single-choice-1-with-feedbacks_5-11.xml");
    AssessmentItem assessmentItem = loadAssessmentItem(itemUrl);
    QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
    SingleChoiceAssessmentItemBuilder itemBuilder = new SingleChoiceAssessmentItemBuilder(assessmentItem, qtiSerializer);
    // correct answer
    List<SimpleChoice> choices = itemBuilder.getChoices();
    Assert.assertNotNull(choices);
    SimpleChoice choice = choices.get(3);
    Assert.assertTrue(itemBuilder.isCorrect(choice));
    // scoring
    Assert.assertEquals(ScoreEvaluation.allCorrectAnswers, itemBuilder.getScoreEvaluationMode());
    ScoreBuilder maxScoreBuilder = itemBuilder.getMaxScoreBuilder();
    Assert.assertEquals(4.0d, maxScoreBuilder.getScore(), 0.00001d);
    // check standard feedback
    ModalFeedbackBuilder correctFeedback = itemBuilder.getCorrectFeedback();
    Assert.assertNotNull(correctFeedback);
    Assert.assertTrue(correctFeedback.isCorrectRule());
    Assert.assertEquals("<p>Richtig Text</p>", correctFeedback.getText());
    ModalFeedbackBuilder incorrectFeedback = itemBuilder.getIncorrectFeedback();
    Assert.assertNotNull(incorrectFeedback);
    Assert.assertTrue(incorrectFeedback.isIncorrectRule());
    Assert.assertEquals("<p>Falsch Text</p>", incorrectFeedback.getText());
}
Also used : SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) JqtiExtensionManager(uk.ac.ed.ph.jqtiplus.JqtiExtensionManager) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) QtiSerializer(uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) URL(java.net.URL) Test(org.junit.Test)

Example 3 with ScoreBuilder

use of org.olat.ims.qti21.model.xml.ScoreBuilder in project openolat by klemens.

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 4 with ScoreBuilder

use of org.olat.ims.qti21.model.xml.ScoreBuilder in project openolat by klemens.

the class FIBScoreController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_score");
    super.initForm(formLayout, listener, ureq);
    minScoreEl = uifactory.addTextElement("min.score", "min.score", 8, "0.0", formLayout);
    minScoreEl.setElementCssClass("o_sel_assessment_item_min_score");
    minScoreEl.setEnabled(false);
    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 + "/fib_score.html";
    scoreCont = FormLayoutContainer.createCustomFormLayout("scores", getTranslator(), scorePage);
    formLayout.add(scoreCont);
    scoreCont.setLabel(null, null);
    for (AbstractEntry entry : itemBuilder.getOrderedTextEntries()) {
        wrappers.add(createTextEntryWrapper(entry));
    }
    scoreCont.contextPut("choices", wrappers);
    scoreCont.setVisible(assessmentModeEl.isSelected(1));
    // Submit Button
    FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsContainer.setRootForm(mainForm);
    buttonsContainer.setVisible(!readOnly);
    formLayout.add(buttonsContainer);
    uifactory.addFormSubmitButton("submit", buttonsContainer);
}
Also used : AbstractEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry) ScoreBuilder(org.olat.ims.qti21.model.xml.ScoreBuilder) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 5 with ScoreBuilder

use of org.olat.ims.qti21.model.xml.ScoreBuilder in project openolat by klemens.

the class ChoiceScoreController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormContextHelp(contextHelpUrl);
    super.initForm(formLayout, listener, ureq);
    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[] choiceKeys = new String[0];
    String[] choiceValues = new String[0];
    maxChoicesEl = uifactory.addDropdownSingleselect("max.choices", formLayout, choiceKeys, choiceValues, null);
    maxChoicesEl.setEnabled(!restrictedEdit && !readOnly);
    minChoicesEl = uifactory.addDropdownSingleselect("min.choices", formLayout, choiceKeys, choiceValues, null);
    minChoicesEl.setEnabled(!restrictedEdit && !readOnly);
    updateMinMaxChoices();
    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.setEnabled(!restrictedEdit && !readOnly);
    assessmentModeEl.addActionListener(FormEvent.ONCHANGE);
    if (itemBuilder.getScoreEvaluationMode() == ScoreEvaluation.perAnswer) {
        assessmentModeEl.select(ScoreEvaluation.perAnswer.name(), true);
    } else {
        assessmentModeEl.select(ScoreEvaluation.allCorrectAnswers.name(), true);
    }
    String scorePage = velocity_root + "/choices_score.html";
    scoreCont = FormLayoutContainer.createCustomFormLayout("scores", getTranslator(), scorePage);
    formLayout.add(scoreCont);
    scoreCont.setLabel(null, null);
    for (Choice choice : itemBuilder.getChoices()) {
        ChoiceWrapper wrapper = createChoiceWrapper(choice);
        wrappers.add(wrapper);
    }
    scoreCont.contextPut("choices", wrappers);
    scoreCont.contextPut("restrictedEdit", restrictedEdit || readOnly);
    scoreCont.setVisible(assessmentModeEl.isSelected(1));
    // Submit Button
    FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsContainer.setRootForm(mainForm);
    buttonsContainer.setVisible(!readOnly);
    formLayout.add(buttonsContainer);
    uifactory.addFormSubmitButton("submit", buttonsContainer);
}
Also used : Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) ScoreBuilder(org.olat.ims.qti21.model.xml.ScoreBuilder) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Aggregations

FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)10 ScoreBuilder (org.olat.ims.qti21.model.xml.ScoreBuilder)10 SimpleChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice)4 URL (java.net.URL)2 Test (org.junit.Test)2 AbstractEntry (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry)2 SingleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder)2 JqtiExtensionManager (uk.ac.ed.ph.jqtiplus.JqtiExtensionManager)2 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)2 Choice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice)2 SimpleAssociableChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)2 HotspotChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice)2 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)2 QtiSerializer (uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer)2