diff --git a/src/main/java/org/olat/ims/qti21/model/xml/interactions/ChoiceAssessmentItemBuilder.java b/src/main/java/org/olat/ims/qti21/model/xml/interactions/ChoiceAssessmentItemBuilder.java index a2564bc9059b0bd727b5a0576d9f5d4894257ec1..696814c6647d2826038dcc115c350efd29bd136f 100644 --- a/src/main/java/org/olat/ims/qti21/model/xml/interactions/ChoiceAssessmentItemBuilder.java +++ b/src/main/java/org/olat/ims/qti21/model/xml/interactions/ChoiceAssessmentItemBuilder.java @@ -78,6 +78,8 @@ public abstract class ChoiceAssessmentItemBuilder extends AssessmentItemBuilder scoreMapping.put(identifier, score); } + public abstract boolean scoreOfCorrectAnswerWarning(); + public abstract int getMaxPossibleCorrectAnswers(); public abstract int getMaxChoices(); diff --git a/src/main/java/org/olat/ims/qti21/model/xml/interactions/HottextAssessmentItemBuilder.java b/src/main/java/org/olat/ims/qti21/model/xml/interactions/HottextAssessmentItemBuilder.java index a59bda4ba9596294c4038afe7f87c7034bd350c1..4b775feb7c858baf0e231a10e8e94c309d9b57f0 100644 --- a/src/main/java/org/olat/ims/qti21/model/xml/interactions/HottextAssessmentItemBuilder.java +++ b/src/main/java/org/olat/ims/qti21/model/xml/interactions/HottextAssessmentItemBuilder.java @@ -230,6 +230,11 @@ public class HottextAssessmentItemBuilder extends ChoiceAssessmentItemBuilder im return correctAnswers.contains(choice.getIdentifier()); } + @Override + public boolean scoreOfCorrectAnswerWarning() { + return false; + } + @Override public int getMaxPossibleCorrectAnswers() { return getChoices().size(); diff --git a/src/main/java/org/olat/ims/qti21/model/xml/interactions/MultipleChoiceAssessmentItemBuilder.java b/src/main/java/org/olat/ims/qti21/model/xml/interactions/MultipleChoiceAssessmentItemBuilder.java index 3a4b0a90aa722b5054a019ae6e9df77f5e73273c..459c7695e966b59e4223d30436b8c06bd00b5129 100644 --- a/src/main/java/org/olat/ims/qti21/model/xml/interactions/MultipleChoiceAssessmentItemBuilder.java +++ b/src/main/java/org/olat/ims/qti21/model/xml/interactions/MultipleChoiceAssessmentItemBuilder.java @@ -165,6 +165,27 @@ public class MultipleChoiceAssessmentItemBuilder extends SimpleChoiceAssessmentI return choices.size(); } + @Override + public boolean scoreOfCorrectAnswerWarning() { + boolean warning; + if(getScoreEvaluationMode() == ScoreEvaluation.perAnswer) { + boolean wrongAnswerHasPoint = false; + boolean correctAnswerHasNotPoint = true; + for(SimpleChoice choice:getChoices()) { + Double score = getMapping(choice.getIdentifier()); + if(isCorrect(choice)) { + correctAnswerHasNotPoint &= (score == null || score.doubleValue() < 0.000001); + } else { + wrongAnswerHasPoint |= (score != null && score.doubleValue() > 0.6); + } + } + warning = wrongAnswerHasPoint && correctAnswerHasNotPoint; + } else { + warning = false; + } + return warning; + } + @Override public void clearSimpleChoices() { if(correctAnswers != null) { diff --git a/src/main/java/org/olat/ims/qti21/model/xml/interactions/SingleChoiceAssessmentItemBuilder.java b/src/main/java/org/olat/ims/qti21/model/xml/interactions/SingleChoiceAssessmentItemBuilder.java index b7ef3eaeccf2e2f2d0b719b9253ee9638b2ddc23..fce63be87aa0cbb01bd39a3535f5fe1296a66ae7 100644 --- a/src/main/java/org/olat/ims/qti21/model/xml/interactions/SingleChoiceAssessmentItemBuilder.java +++ b/src/main/java/org/olat/ims/qti21/model/xml/interactions/SingleChoiceAssessmentItemBuilder.java @@ -149,6 +149,26 @@ public class SingleChoiceAssessmentItemBuilder extends SimpleChoiceAssessmentIte correctAnswer = null; super.clearSimpleChoices(); } + + @Override + public boolean scoreOfCorrectAnswerWarning() { + boolean warning = false; + if(getScoreEvaluationMode() == ScoreEvaluation.perAnswer) { + boolean wrongAnswerHasPoint = false; + boolean correctAnswerHasNotPoint = false; + + for(SimpleChoice choiceWrapper:getChoices()) { + Double score = getMapping(choiceWrapper.getIdentifier()); + if(isCorrect(choiceWrapper)) { + correctAnswerHasNotPoint = (score == null || score.doubleValue() < 0.000001); + } else { + wrongAnswerHasPoint |= (score != null && score.doubleValue() > 0.6); + } + } + warning |= wrongAnswerHasPoint && correctAnswerHasNotPoint; + } + return warning; + } @Override protected void buildResponseAndOutcomeDeclarations() { diff --git a/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_de.properties index 63b2de809c99972380cd4e3a380b9e476861d29b..77ac21517fe800ebfe56e41d46a054bbc21f7579 100644 --- a/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_de.properties @@ -273,8 +273,8 @@ warning.atleastone=Bitte w\u00E4hlen Sie mindestens ein Element. warning.atleastonesection=Diese Sektion kann nicht gel\u00F6scht werden. Ein Test oder ein Test-Part muss mindestens eine Sektion enthalten. warning.conversion.list=Es wurde Inkompatibilit\u00E4ten gefunden\: warning.conversion.standard=Es gibt ein Risiko, dass sie Daten verlieren, obwohl kein Inkompatibilit\u00E4ten entdeckt wurden. -warning.correct.answer.score=Die korrekte Antwort gibt kein Punkt zu, aber eine inkorrekte schon. -warning.correct.answers.score=Korrekte Antwort geben keine Punkte zu, aber inkorrekte schon. +warning.correct.answer.score=Es wurden keine Punkte f\u00FCr die korrekte Antwort definiert, aber f\u00FCr die inkorrekte Antwort. +warning.correct.answers.score=Es wurden keine Punkte f\u00FCr die korrekte(n) Antwort(en) definiert, aber f\u00FCr die inkorrekte(n) Antwort(en). warning.copy.from.pool=Die Frage wurde vom Fragenpool kopiert. Sie k\u00F6nnen die Originalfrage unter Master ID finden. warning.custom.operator=Es wurde eine her\u00ADstel\u00ADler\u00ADspe\u00ADzi\u00ADfische Erweiterung gefunden. Diese ist nicht von Editor unterst\u00FCtzt. warning.feedback.cutvalue=Feedback wird aktiviert, sobald bei "Notwendige Punktzahl f\u00FCr 'Bestanden'" eine Punktzahl eingegeben wurde. diff --git a/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_en.properties index 3e22af185a2c93b70a095098c7e7d4fe944f54d1..16b6798e6d025ac2be7def0ac67db07c0ff353f3 100644 --- a/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_en.properties @@ -274,8 +274,8 @@ warning.atleastonesection=The section cannot be deleted. A test or a test part m warning.conversion.list=Some incompatibilities was found\: warning.conversion.standard=There is a risk that some data got lost after conversion but no flagrant incompatibilities was found. warning.copy.from.pool=The question was copied from the question bank. You can find the original question under the master id. -warning.correct.answer.score=Correct answers don't give any points but wrong one(s) do. -warning.correct.answers.score=Correct answer doesn't give any point but wrong one do. +warning.correct.answer.score=No points have been defined for the correct answer, but for the incorrect answer. +warning.correct.answers.score=No points have been defined for the correct answer(s), but for the incorrect answer(s). warning.custom.operator=This question contains creator specific extension which are currently not supported by OpenOlat. warning.feedback.cutvalue=The feedback is based on the cut value. You need to define it first. warning.in.use=The resource is already used for assessment purpose. Editing is limited. diff --git a/src/main/java/org/olat/ims/qti21/ui/editor/interactions/ChoiceScoreController.java b/src/main/java/org/olat/ims/qti21/ui/editor/interactions/ChoiceScoreController.java index 7264dda4c14016e58fed8ea42b13da15f6ca27e0..635cfd7a9d9d8699bb92b86699f716a908caeb4f 100644 --- a/src/main/java/org/olat/ims/qti21/ui/editor/interactions/ChoiceScoreController.java +++ b/src/main/java/org/olat/ims/qti21/ui/editor/interactions/ChoiceScoreController.java @@ -71,7 +71,8 @@ public class ChoiceScoreController extends AssessmentItemRefEditorController imp private TextElement minScoreEl; private TextElement maxScoreEl; private SingleSelection assessmentModeEl; - private SingleSelection maxChoicesEl, minChoicesEl; + private SingleSelection minChoicesEl; + private SingleSelection maxChoicesEl; private FormLayoutContainer scoreCont; private final List<ChoiceWrapper> wrappers = new ArrayList<>(); @@ -97,6 +98,7 @@ public class ChoiceScoreController extends AssessmentItemRefEditorController imp new ResourcesMapper(assessmentObjectUri)); initForm(ureq); + validateScoreOfCorrectAnswer(); } @Override @@ -229,6 +231,7 @@ public class ChoiceScoreController extends AssessmentItemRefEditorController imp updateMinMaxChoices(); } + validateScoreOfCorrectAnswer(); } private ChoiceWrapper createChoiceWrapper(Choice choice) { @@ -264,9 +267,23 @@ public class ChoiceScoreController extends AssessmentItemRefEditorController imp allOk &= validateDouble(wrapper.getPointsEl()); } } - + + validateScoreOfCorrectAnswer();// only a warning return allOk; } + + private void validateScoreOfCorrectAnswer() { + try { + Boolean warning = (Boolean)scoreCont.contextGet("scoreWarning"); + Boolean newWarning = Boolean.valueOf(itemBuilder.scoreOfCorrectAnswerWarning()); + if(warning == null || !warning.equals(newWarning)) { + scoreCont.contextPut("scoreWarning", newWarning); + } + } catch (Exception e) { + // not a critical feature, don't produce red screen + logError("", e); + } + } @Override protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) { @@ -310,6 +327,7 @@ public class ChoiceScoreController extends AssessmentItemRefEditorController imp } fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), null)); + validateScoreOfCorrectAnswer(); } @Override diff --git a/src/main/java/org/olat/ims/qti21/ui/editor/interactions/MultipleChoiceEditorController.java b/src/main/java/org/olat/ims/qti21/ui/editor/interactions/MultipleChoiceEditorController.java index 3564403ca7d65a4093c3a9111dcb58aba4e4ed68..637a10887322dcbcae45b3d2d0db149dd12448fa 100644 --- a/src/main/java/org/olat/ims/qti21/ui/editor/interactions/MultipleChoiceEditorController.java +++ b/src/main/java/org/olat/ims/qti21/ui/editor/interactions/MultipleChoiceEditorController.java @@ -47,7 +47,6 @@ import org.olat.ims.qti21.model.QTI21QuestionType; import org.olat.ims.qti21.model.xml.AssessmentItemBuilder; import org.olat.ims.qti21.model.xml.AssessmentItemFactory; import org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder; -import org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder.ScoreEvaluation; import org.olat.ims.qti21.ui.ResourcesMapper; import org.olat.ims.qti21.ui.components.FlowFormItem; import org.olat.ims.qti21.ui.editor.AssessmentTestEditorController; @@ -244,7 +243,7 @@ public class MultipleChoiceEditorController extends FormBasicController implemen } @Override - public void sync(UserRequest ureq, AssessmentItemBuilder itemBuilder) { + public void sync(UserRequest ureq, AssessmentItemBuilder builder) { validateScoreOfCorrectAnswer(); } @@ -273,23 +272,7 @@ public class MultipleChoiceEditorController extends FormBasicController implemen private void validateScoreOfCorrectAnswer() { try { Boolean warning = (Boolean)answersCont.contextGet("scoreWarning"); - Boolean newWarning; - if(itemBuilder.getScoreEvaluationMode() == ScoreEvaluation.perAnswer) { - boolean wrongAnswerHasPoint = false; - boolean correctAnswerHasNotPoint = true; - for(SimpleChoiceWrapper choiceWrapper:choiceWrappers) { - Double score = itemBuilder.getMapping(choiceWrapper.getIdentifier()); - if(choiceWrapper.isCorrect()) { - correctAnswerHasNotPoint &= (score == null || score.doubleValue() < 0.000001); - } else { - wrongAnswerHasPoint |= (score != null && score.doubleValue() > 0.6); - } - } - newWarning = Boolean.valueOf(wrongAnswerHasPoint && correctAnswerHasNotPoint); - } else { - newWarning = Boolean.FALSE; - } - + Boolean newWarning = Boolean.valueOf(itemBuilder.scoreOfCorrectAnswerWarning()); if(warning == null || !warning.equals(newWarning)) { answersCont.contextPut("scoreWarning", newWarning); } diff --git a/src/main/java/org/olat/ims/qti21/ui/editor/interactions/SingleChoiceEditorController.java b/src/main/java/org/olat/ims/qti21/ui/editor/interactions/SingleChoiceEditorController.java index 4033edadd1bcbad456b115f003fc9fee0772a086..048eb7f200505d338c86b766d28d01ed8ab9aa62 100644 --- a/src/main/java/org/olat/ims/qti21/ui/editor/interactions/SingleChoiceEditorController.java +++ b/src/main/java/org/olat/ims/qti21/ui/editor/interactions/SingleChoiceEditorController.java @@ -45,7 +45,6 @@ import org.olat.ims.qti21.QTI21Constants; import org.olat.ims.qti21.model.QTI21QuestionType; import org.olat.ims.qti21.model.xml.AssessmentItemBuilder; import org.olat.ims.qti21.model.xml.AssessmentItemFactory; -import org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder.ScoreEvaluation; import org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder; import org.olat.ims.qti21.ui.ResourcesMapper; import org.olat.ims.qti21.ui.components.FlowFormItem; @@ -274,23 +273,7 @@ public class SingleChoiceEditorController extends FormBasicController implements private void validateScoreOfCorrectAnswer() { try { Boolean warning = (Boolean)answersCont.contextGet("scoreWarning"); - Boolean newWarning; - if(itemBuilder.getScoreEvaluationMode() == ScoreEvaluation.perAnswer) { - boolean wrongAnswerHasPoint = false; - boolean correctAnswerHasNotPoint = false; - for(SimpleChoiceWrapper choiceWrapper:choiceWrappers) { - Double score = itemBuilder.getMapping(choiceWrapper.getIdentifier()); - if(choiceWrapper.isCorrect()) { - correctAnswerHasNotPoint = (score == null || score.doubleValue() < 0.000001); - } else { - wrongAnswerHasPoint |= (score != null && score.doubleValue() > 0.6); - } - } - newWarning = Boolean.valueOf(wrongAnswerHasPoint && correctAnswerHasNotPoint); - } else { - newWarning = Boolean.FALSE; - } - + Boolean newWarning = Boolean.valueOf(itemBuilder.scoreOfCorrectAnswerWarning()); if(warning == null || !warning.equals(newWarning)) { answersCont.contextPut("scoreWarning", newWarning); } diff --git a/src/main/java/org/olat/ims/qti21/ui/editor/interactions/_content/choices_score.html b/src/main/java/org/olat/ims/qti21/ui/editor/interactions/_content/choices_score.html index 8adeebdc2356d23260ce685f528f93872e4a7579..3c2584896ba21323d071eb80815b0500df81a30a 100644 --- a/src/main/java/org/olat/ims/qti21/ui/editor/interactions/_content/choices_score.html +++ b/src/main/java/org/olat/ims/qti21/ui/editor/interactions/_content/choices_score.html @@ -1,3 +1,6 @@ +#if($r.isTrue($scoreWarning)) + <div class="o_warning" role="alert">$r.translate("warning.correct.answer.score")</div> +#end <table class="table o_sel_choices_scores"> <thead><tr> <th>$r.translate("form.score.answer.correct")</th>