use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeRule in project OpenOLAT by OpenOLAT.
the class AssessmentTestBuilder method extractRules.
private void extractRules() {
if (assessmentTest.getOutcomeProcessing() != null) {
List<OutcomeRule> outcomeRules = assessmentTest.getOutcomeProcessing().getOutcomeRules();
for (OutcomeRule outcomeRule : outcomeRules) {
// export test score
if (outcomeRule instanceof SetOutcomeValue) {
SetOutcomeValue setOutcomeValue = (SetOutcomeValue) outcomeRule;
if (QTI21Constants.SCORE_IDENTIFIER.equals(setOutcomeValue.getIdentifier())) {
testScoreRule = outcomeRule;
}
}
// pass rule
if (outcomeRule instanceof OutcomeCondition) {
OutcomeCondition outcomeCondition = (OutcomeCondition) outcomeRule;
boolean findIf = QtiNodesExtractor.findSetOutcomeValue(outcomeCondition.getOutcomeIf(), QTI21Constants.PASS_IDENTIFIER);
boolean findElse = QtiNodesExtractor.findSetOutcomeValue(outcomeCondition.getOutcomeElse(), QTI21Constants.PASS_IDENTIFIER);
if (findIf && findElse) {
cutValue = QtiNodesExtractor.extractCutValue(outcomeCondition.getOutcomeIf());
cutValueRule = outcomeCondition;
}
boolean findMinIf = QtiNodesExtractor.findLtValue(outcomeCondition.getOutcomeIf(), QTI21Constants.MINSCORE_IDENTIFIER) && QtiNodesExtractor.findLtValue(outcomeCondition.getOutcomeIf(), QTI21Constants.SCORE_IDENTIFIER);
if (findMinIf) {
minScoreRule = outcomeCondition;
}
}
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeRule in project OpenOLAT by OpenOLAT.
the class AssessmentTestBuilder method buildFeedback.
private void buildFeedback() {
// remove outcome rules
List<OutcomeRule> outcomeRules = assessmentTest.getOutcomeProcessing().getOutcomeRules();
for (Iterator<OutcomeRule> outcomeRuleIt = outcomeRules.iterator(); outcomeRuleIt.hasNext(); ) {
OutcomeRule outcomeRule = outcomeRuleIt.next();
if (outcomeRule instanceof OutcomeCondition) {
OutcomeCondition outcomeCondition = (OutcomeCondition) outcomeRule;
if (outcomeCondition.getOutcomeIf() != null && outcomeCondition.getOutcomeIf().getOutcomeRules().size() == 1) {
OutcomeRule outcomeValue = outcomeCondition.getOutcomeIf().getOutcomeRules().get(0);
if (outcomeValue instanceof SetOutcomeValue) {
SetOutcomeValue setOutcomeValue = (SetOutcomeValue) outcomeValue;
if (QTI21Constants.FEEDBACKMODAL_IDENTIFIER.equals(setOutcomeValue.getIdentifier())) {
outcomeRuleIt.remove();
}
}
}
}
}
// set the feedbackmodal outcome declaration if needed
if (passedFeedback != null || failedFeedback != null) {
OutcomeDeclaration outcomeDeclaration = assessmentTest.getOutcomeDeclaration(QTI21Constants.FEEDBACKMODAL_IDENTIFIER);
if (outcomeDeclaration == null) {
OutcomeDeclaration feedbackModalOutcomeDeclaration = AssessmentTestFactory.createTestFeedbackModalOutcomeDeclaration(assessmentTest);
assessmentTest.getOutcomeDeclarations().add(feedbackModalOutcomeDeclaration);
}
}
if (passedFeedback != null) {
buildFeedback(passedFeedback, true);
}
if (failedFeedback != null) {
buildFeedback(failedFeedback, false);
}
}
use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeRule in project OpenOLAT by OpenOLAT.
the class QtiNodesExtractor method extractCutValue.
public static Double extractCutValue(AssessmentTest assessmentTest) {
Double cutValue = null;
if (assessmentTest.getOutcomeProcessing() != null) {
List<OutcomeRule> outcomeRules = assessmentTest.getOutcomeProcessing().getOutcomeRules();
for (OutcomeRule outcomeRule : outcomeRules) {
if (outcomeRule instanceof OutcomeCondition) {
OutcomeCondition outcomeCondition = (OutcomeCondition) outcomeRule;
boolean findIf = findSetOutcomeValue(outcomeCondition.getOutcomeIf(), QTI21Constants.PASS_IDENTIFIER);
boolean findElse = findSetOutcomeValue(outcomeCondition.getOutcomeElse(), QTI21Constants.PASS_IDENTIFIER);
if (findIf && findElse) {
cutValue = extractCutValue(outcomeCondition.getOutcomeIf());
}
}
}
}
return cutValue;
}
use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeRule in project OpenOLAT by OpenOLAT.
the class QTI21WordExport method renderAssessmentTest.
public void renderAssessmentTest(AssessmentTest assessmentTest, OpenXMLDocument document, Translator translator) {
String title = assessmentTest.getTitle();
document.appendTitle(title);
if (assessmentTest.getOutcomeProcessing() != null) {
List<OutcomeRule> outcomeRules = assessmentTest.getOutcomeProcessing().getOutcomeRules();
for (OutcomeRule outcomeRule : outcomeRules) {
// pass rule
if (outcomeRule instanceof OutcomeCondition) {
OutcomeCondition outcomeCondition = (OutcomeCondition) outcomeRule;
boolean findIf = QtiNodesExtractor.findSetOutcomeValue(outcomeCondition.getOutcomeIf(), QTI21Constants.PASS_IDENTIFIER);
boolean findElse = QtiNodesExtractor.findSetOutcomeValue(outcomeCondition.getOutcomeElse(), QTI21Constants.PASS_IDENTIFIER);
if (findIf && findElse) {
Double cutValue = QtiNodesExtractor.extractCutValue(outcomeCondition.getOutcomeIf());
String cutValueLabel = translator.translate("cut.value");
document.appendText(cutValueLabel + ": " + AssessmentHelper.getRoundedScore(cutValue), true);
}
}
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeRule in project openolat by klemens.
the class AssessmentTestBuilder method buildFeedback.
private void buildFeedback() {
// remove outcome rules
List<OutcomeRule> outcomeRules = assessmentTest.getOutcomeProcessing().getOutcomeRules();
for (Iterator<OutcomeRule> outcomeRuleIt = outcomeRules.iterator(); outcomeRuleIt.hasNext(); ) {
OutcomeRule outcomeRule = outcomeRuleIt.next();
if (outcomeRule instanceof OutcomeCondition) {
OutcomeCondition outcomeCondition = (OutcomeCondition) outcomeRule;
if (outcomeCondition.getOutcomeIf() != null && outcomeCondition.getOutcomeIf().getOutcomeRules().size() == 1) {
OutcomeRule outcomeValue = outcomeCondition.getOutcomeIf().getOutcomeRules().get(0);
if (outcomeValue instanceof SetOutcomeValue) {
SetOutcomeValue setOutcomeValue = (SetOutcomeValue) outcomeValue;
if (QTI21Constants.FEEDBACKMODAL_IDENTIFIER.equals(setOutcomeValue.getIdentifier())) {
outcomeRuleIt.remove();
}
}
}
}
}
// set the feedbackmodal outcome declaration if needed
if (passedFeedback != null || failedFeedback != null) {
OutcomeDeclaration outcomeDeclaration = assessmentTest.getOutcomeDeclaration(QTI21Constants.FEEDBACKMODAL_IDENTIFIER);
if (outcomeDeclaration == null) {
OutcomeDeclaration feedbackModalOutcomeDeclaration = AssessmentTestFactory.createTestFeedbackModalOutcomeDeclaration(assessmentTest);
assessmentTest.getOutcomeDeclarations().add(feedbackModalOutcomeDeclaration);
}
}
if (passedFeedback != null) {
buildFeedback(passedFeedback, true);
}
if (failedFeedback != null) {
buildFeedback(failedFeedback, false);
}
}
Aggregations