Search in sources :

Example 11 with ComplexReferenceIdentifier

use of uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier in project OpenOLAT by OpenOLAT.

the class HotspotAssessmentItemBuilder method buildMainScoreRuleAllCorrectAnswers.

private void buildMainScoreRuleAllCorrectAnswers(ResponseCondition rule) {
    /*
		<responseCondition>
			<responseIf>
				<isNull>
					<variable identifier="RESPONSE_1" />
				</isNull>
				<setOutcomeValue identifier="FEEDBACKBASIC">
					<baseValue baseType="identifier">empty</baseValue>
				</setOutcomeValue>
			</responseIf>
			<responseElseIf>
				<match>
					<variable identifier="RESPONSE_1" />
					<correct identifier="RESPONSE_1" />
				</match>
				<setOutcomeValue identifier="SCORE">
					<sum>
						<variable identifier="SCORE" />
						<variable identifier="MAXSCORE" />
					</sum>
				</setOutcomeValue>
				<setOutcomeValue identifier="FEEDBACKBASIC">
					<baseValue baseType="identifier">correct</baseValue>
				</setOutcomeValue>
			</responseElseIf>
			<responseElse>
				<setOutcomeValue identifier="FEEDBACKBASIC">
					<baseValue baseType="identifier">incorrect</baseValue>
				</setOutcomeValue>
			</responseElse>
		</responseCondition>
		 */
    // simple as build with / without feedback
    ensureFeedbackBasicOutcomeDeclaration();
    ResponseIf responseIf = new ResponseIf(rule);
    rule.setResponseIf(responseIf);
    {
        // if no response
        IsNull isNull = new IsNull(responseIf);
        responseIf.getExpressions().add(isNull);
        Variable variable = new Variable(isNull);
        variable.setIdentifier(ComplexReferenceIdentifier.parseString(responseIdentifier.toString()));
        isNull.getExpressions().add(variable);
        SetOutcomeValue incorrectOutcomeValue = new SetOutcomeValue(responseIf);
        incorrectOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
        responseIf.getResponseRules().add(incorrectOutcomeValue);
        BaseValue incorrectValue = new BaseValue(incorrectOutcomeValue);
        incorrectValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
        incorrectValue.setSingleValue(QTI21Constants.EMPTY_IDENTIFIER_VALUE);
        incorrectOutcomeValue.setExpression(incorrectValue);
    }
    ResponseElseIf responseElseIf = new ResponseElseIf(rule);
    rule.getResponseElseIfs().add(responseElseIf);
    {
        // match the correct answers
        Match match = new Match(responseElseIf);
        responseElseIf.getExpressions().add(match);
        Variable scoreVar = new Variable(match);
        ComplexReferenceIdentifier choiceResponseIdentifier = ComplexReferenceIdentifier.parseString(hotspotInteraction.getResponseIdentifier().toString());
        scoreVar.setIdentifier(choiceResponseIdentifier);
        match.getExpressions().add(scoreVar);
        Correct correct = new Correct(match);
        correct.setIdentifier(choiceResponseIdentifier);
        match.getExpressions().add(correct);
    }
    {
        // outcome score
        SetOutcomeValue scoreOutcomeValue = new SetOutcomeValue(responseElseIf);
        scoreOutcomeValue.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
        responseElseIf.getResponseRules().add(scoreOutcomeValue);
        Sum sum = new Sum(scoreOutcomeValue);
        scoreOutcomeValue.getExpressions().add(sum);
        Variable scoreVar = new Variable(sum);
        scoreVar.setIdentifier(QTI21Constants.SCORE_CLX_IDENTIFIER);
        sum.getExpressions().add(scoreVar);
        Variable maxScoreVar = new Variable(sum);
        maxScoreVar.setIdentifier(QTI21Constants.MAXSCORE_CLX_IDENTIFIER);
        sum.getExpressions().add(maxScoreVar);
    }
    {
        // outcome feedback
        SetOutcomeValue correctOutcomeValue = new SetOutcomeValue(responseElseIf);
        correctOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
        responseElseIf.getResponseRules().add(correctOutcomeValue);
        BaseValue correctValue = new BaseValue(correctOutcomeValue);
        correctValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
        correctValue.setSingleValue(QTI21Constants.CORRECT_IDENTIFIER_VALUE);
        correctOutcomeValue.setExpression(correctValue);
    }
    ResponseElse responseElse = new ResponseElse(rule);
    rule.setResponseElse(responseElse);
    {
        // outcome feedback
        SetOutcomeValue incorrectOutcomeValue = new SetOutcomeValue(responseElse);
        incorrectOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
        responseElse.getResponseRules().add(incorrectOutcomeValue);
        BaseValue incorrectValue = new BaseValue(incorrectOutcomeValue);
        incorrectValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
        incorrectValue.setSingleValue(QTI21Constants.INCORRECT_IDENTIFIER_VALUE);
        incorrectOutcomeValue.setExpression(incorrectValue);
    }
}
Also used : ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) Variable(uk.ac.ed.ph.jqtiplus.node.expression.general.Variable) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) ResponseElse(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseElse) ResponseIf(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf) IsNull(uk.ac.ed.ph.jqtiplus.node.expression.operator.IsNull) Sum(uk.ac.ed.ph.jqtiplus.node.expression.operator.Sum) ResponseElseIf(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseElseIf) Correct(uk.ac.ed.ph.jqtiplus.node.expression.general.Correct) Match(uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)

Example 12 with ComplexReferenceIdentifier

use of uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier in project OpenOLAT by OpenOLAT.

the class MatchAssessmentItemBuilder method buildMainScoreRuleAllCorrectAnswers.

private void buildMainScoreRuleAllCorrectAnswers(ResponseCondition rule) {
    /*
		<responseCondition>
			<responseIf>
				<isNull>
					<variable identifier="RESPONSE_1" />
				</isNull>
				<setOutcomeValue identifier="FEEDBACKBASIC">
					<baseValue baseType="identifier">
						empty
					</baseValue>
				</setOutcomeValue>
			</responseIf>
			<responseElseIf>
				<match>
					<variable identifier="RESPONSE_1" />
					<correct identifier="RESPONSE_1" />
				</match>
				<setOutcomeValue identifier="SCORE">
					<sum>
						<variable identifier="SCORE" /><
						variable identifier="MAXSCORE" />
					</sum>
				</setOutcomeValue>
				<setOutcomeValue identifier="FEEDBACKBASIC">
					<baseValue baseType="identifier">
						correct
					</baseValue>
				</setOutcomeValue>
			</responseElseIf>
			<responseElse>
				<setOutcomeValue identifier="FEEDBACKBASIC">
					<baseValue baseType="identifier">
						incorrect
					</baseValue>
				</setOutcomeValue>
			</responseElse>
		</responseCondition>
		*/
    // simple as build with / without feedback
    ensureFeedbackBasicOutcomeDeclaration();
    ResponseIf responseIf = new ResponseIf(rule);
    rule.setResponseIf(responseIf);
    // match the correct answers (or null if there are no associations)
    if (associations.isEmpty()) {
        IsNull isNull = new IsNull(responseIf);
        responseIf.getExpressions().add(isNull);
        Variable responseVar = new Variable(isNull);
        ComplexReferenceIdentifier choiceResponseIdentifier = ComplexReferenceIdentifier.parseString(responseIdentifier.toString());
        responseVar.setIdentifier(choiceResponseIdentifier);
        isNull.getExpressions().add(responseVar);
    } else {
        Match match = new Match(responseIf);
        responseIf.getExpressions().add(match);
        Variable responseVar = new Variable(match);
        ComplexReferenceIdentifier choiceResponseIdentifier = ComplexReferenceIdentifier.parseString(responseIdentifier.toString());
        responseVar.setIdentifier(choiceResponseIdentifier);
        match.getExpressions().add(responseVar);
        Correct correct = new Correct(match);
        correct.setIdentifier(choiceResponseIdentifier);
        match.getExpressions().add(correct);
    }
    // outcome score + max score
    appendSetOutcomeScoreMaxScore(responseIf);
    // outcome correct feedback
    appendSetOutcomeFeedbackCorrect(responseIf);
    ResponseElse responseElse = new ResponseElse(rule);
    rule.setResponseElse(responseElse);
    // outcome incorrect feedback
    appendSetOutcomeFeedbackIncorrect(responseElse);
}
Also used : ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) Variable(uk.ac.ed.ph.jqtiplus.node.expression.general.Variable) ResponseElse(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseElse) ResponseIf(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf) IsNull(uk.ac.ed.ph.jqtiplus.node.expression.operator.IsNull) Correct(uk.ac.ed.ph.jqtiplus.node.expression.general.Correct) AssessmentItemFactory.appendSetOutcomeFeedbackCorrect(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendSetOutcomeFeedbackCorrect) Match(uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)

Example 13 with ComplexReferenceIdentifier

use of uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier in project OpenOLAT by OpenOLAT.

the class HottextAssessmentItemBuilder method matchCorrectAnswers.

/**
 * Match the correct answer or, if there isn't not a single correct answer,
 * match null.
 *
 * @param responseIf
 */
private void matchCorrectAnswers(ResponseIf responseIf) {
    if (correctAnswers.isEmpty()) {
        IsNull isNull = new IsNull(responseIf);
        responseIf.getExpressions().add(isNull);
        Variable variable = new Variable(isNull);
        variable.setIdentifier(ComplexReferenceIdentifier.parseString(responseIdentifier.toString()));
        isNull.getExpressions().add(variable);
    } else {
        Match match = new Match(responseIf);
        responseIf.getExpressions().add(match);
        Variable scoreVar = new Variable(match);
        ComplexReferenceIdentifier choiceResponseIdentifier = ComplexReferenceIdentifier.parseString(hottextInteraction.getResponseIdentifier().toString());
        scoreVar.setIdentifier(choiceResponseIdentifier);
        match.getExpressions().add(scoreVar);
        Correct correct = new Correct(match);
        correct.setIdentifier(choiceResponseIdentifier);
        match.getExpressions().add(correct);
    }
}
Also used : ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) Variable(uk.ac.ed.ph.jqtiplus.node.expression.general.Variable) IsNull(uk.ac.ed.ph.jqtiplus.node.expression.operator.IsNull) Correct(uk.ac.ed.ph.jqtiplus.node.expression.general.Correct) Match(uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)

Example 14 with ComplexReferenceIdentifier

use of uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier in project OpenOLAT by OpenOLAT.

the class MultipleChoiceAssessmentItemBuilder method buildMainScoreRuleAllCorrectAnswers.

private void buildMainScoreRuleAllCorrectAnswers(ResponseCondition rule) {
    /*
		<responseCondition>
			<responseIf>
				<match>
					<variable identifier="RESPONSE_1" />
					<correct identifier="RESPONSE_1" />
				</match>
				<setOutcomeValue identifier="SCORE">
					<sum>
						<variable identifier="SCORE" />
						<variable identifier="MAXSCORE" />
					</sum>
				</setOutcomeValue>
				<setOutcomeValue identifier="FEEDBACKBASIC">
					<baseValue baseType="identifier">correct</baseValue>
				</setOutcomeValue>
			</responseIf>
			<responseElse>
				<setOutcomeValue identifier="FEEDBACKBASIC">
					<baseValue baseType="identifier">incorrect</baseValue>
				</setOutcomeValue>
			</responseElse>
		</responseCondition>
		 */
    // simple as build with / without feedback
    ensureFeedbackBasicOutcomeDeclaration();
    ResponseIf responseIf = new ResponseIf(rule);
    rule.setResponseIf(responseIf);
    {
        // match the correct answers
        Match match = new Match(responseIf);
        responseIf.getExpressions().add(match);
        Variable scoreVar = new Variable(match);
        ComplexReferenceIdentifier choiceResponseIdentifier = ComplexReferenceIdentifier.parseString(choiceInteraction.getResponseIdentifier().toString());
        scoreVar.setIdentifier(choiceResponseIdentifier);
        match.getExpressions().add(scoreVar);
        Correct correct = new Correct(match);
        correct.setIdentifier(choiceResponseIdentifier);
        match.getExpressions().add(correct);
    }
    {
        // outcome score
        SetOutcomeValue scoreOutcomeValue = new SetOutcomeValue(responseIf);
        scoreOutcomeValue.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
        responseIf.getResponseRules().add(scoreOutcomeValue);
        Sum sum = new Sum(scoreOutcomeValue);
        scoreOutcomeValue.getExpressions().add(sum);
        Variable scoreVar = new Variable(sum);
        scoreVar.setIdentifier(QTI21Constants.SCORE_CLX_IDENTIFIER);
        sum.getExpressions().add(scoreVar);
        Variable maxScoreVar = new Variable(sum);
        maxScoreVar.setIdentifier(QTI21Constants.MAXSCORE_CLX_IDENTIFIER);
        sum.getExpressions().add(maxScoreVar);
    }
    {
        // outcome feedback
        SetOutcomeValue correctOutcomeValue = new SetOutcomeValue(responseIf);
        correctOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
        responseIf.getResponseRules().add(correctOutcomeValue);
        BaseValue correctValue = new BaseValue(correctOutcomeValue);
        correctValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
        correctValue.setSingleValue(QTI21Constants.CORRECT_IDENTIFIER_VALUE);
        correctOutcomeValue.setExpression(correctValue);
    }
    ResponseElse responseElse = new ResponseElse(rule);
    rule.setResponseElse(responseElse);
    {
        // outcome feedback
        SetOutcomeValue incorrectOutcomeValue = new SetOutcomeValue(responseElse);
        incorrectOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
        responseElse.getResponseRules().add(incorrectOutcomeValue);
        BaseValue incorrectValue = new BaseValue(incorrectOutcomeValue);
        incorrectValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
        incorrectValue.setSingleValue(QTI21Constants.INCORRECT_IDENTIFIER_VALUE);
        incorrectOutcomeValue.setExpression(incorrectValue);
    }
}
Also used : ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) Variable(uk.ac.ed.ph.jqtiplus.node.expression.general.Variable) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) ResponseElse(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseElse) ResponseIf(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf) Sum(uk.ac.ed.ph.jqtiplus.node.expression.operator.Sum) Correct(uk.ac.ed.ph.jqtiplus.node.expression.general.Correct) Match(uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)

Example 15 with ComplexReferenceIdentifier

use of uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier in project OpenOLAT by OpenOLAT.

the class MultipleChoiceAssessmentItemBuilder method buildMainScoreRulePerAnswer.

private void buildMainScoreRulePerAnswer(ResponseCondition rule) {
    /*
		<responseCondition>
			<responseIf>
				<match>
					<variable identifier="RESPONSE_1" />
					<correct identifier="RESPONSE_1" />
				</match>
				<setOutcomeValue identifier="SCORE">
					<sum>
						<variable identifier="SCORE" />
						<mapResponse identifier="RESPONSE_1" />
					</sum>
				</setOutcomeValue>
				<setOutcomeValue identifier="FEEDBACKBASIC">
					<baseValue baseType="identifier">correct</baseValue>
				</setOutcomeValue>
			</responseIf>
			<responseElse>
				<setOutcomeValue identifier="FEEDBACKBASIC">
					<baseValue baseType="identifier">incorrect</baseValue>
				</setOutcomeValue>
			</responseElse>
		</responseCondition>
		*/
    ResponseIf responseIf = new ResponseIf(rule);
    rule.setResponseIf(responseIf);
    {
        // match the correct answers
        Match match = new Match(responseIf);
        responseIf.getExpressions().add(match);
        Variable scoreVar = new Variable(match);
        ComplexReferenceIdentifier choiceResponseIdentifier = ComplexReferenceIdentifier.parseString(choiceInteraction.getResponseIdentifier().toString());
        scoreVar.setIdentifier(choiceResponseIdentifier);
        match.getExpressions().add(scoreVar);
        Correct correct = new Correct(match);
        correct.setIdentifier(choiceResponseIdentifier);
        match.getExpressions().add(correct);
    }
    {
        // outcome score
        SetOutcomeValue scoreOutcome = new SetOutcomeValue(responseIf);
        scoreOutcome.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
        responseIf.getResponseRules().add(scoreOutcome);
        Sum sum = new Sum(scoreOutcome);
        scoreOutcome.getExpressions().add(sum);
        Variable scoreVar = new Variable(sum);
        scoreVar.setIdentifier(QTI21Constants.SCORE_CLX_IDENTIFIER);
        sum.getExpressions().add(scoreVar);
        MapResponse mapResponse = new MapResponse(sum);
        mapResponse.setIdentifier(choiceInteraction.getResponseIdentifier());
        sum.getExpressions().add(mapResponse);
    }
    {
        // outcome feedback
        SetOutcomeValue correctOutcomeValue = new SetOutcomeValue(responseIf);
        correctOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
        responseIf.getResponseRules().add(correctOutcomeValue);
        BaseValue correctValue = new BaseValue(correctOutcomeValue);
        correctValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
        correctValue.setSingleValue(QTI21Constants.CORRECT_IDENTIFIER_VALUE);
        correctOutcomeValue.setExpression(correctValue);
    }
    ResponseElse responseElse = new ResponseElse(rule);
    rule.setResponseElse(responseElse);
    {
        // outcome score
        SetOutcomeValue scoreOutcome = new SetOutcomeValue(responseElse);
        scoreOutcome.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
        responseElse.getResponseRules().add(scoreOutcome);
        Sum sum = new Sum(scoreOutcome);
        scoreOutcome.getExpressions().add(sum);
        Variable scoreVar = new Variable(sum);
        scoreVar.setIdentifier(QTI21Constants.SCORE_CLX_IDENTIFIER);
        sum.getExpressions().add(scoreVar);
        MapResponse mapResponse = new MapResponse(sum);
        mapResponse.setIdentifier(choiceInteraction.getResponseIdentifier());
        sum.getExpressions().add(mapResponse);
    }
    {
        // outcome feedback
        SetOutcomeValue incorrectOutcomeValue = new SetOutcomeValue(responseElse);
        incorrectOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
        responseElse.getResponseRules().add(incorrectOutcomeValue);
        BaseValue incorrectValue = new BaseValue(incorrectOutcomeValue);
        incorrectValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
        incorrectValue.setSingleValue(QTI21Constants.INCORRECT_IDENTIFIER_VALUE);
        incorrectOutcomeValue.setExpression(incorrectValue);
    }
}
Also used : ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) MapResponse(uk.ac.ed.ph.jqtiplus.node.expression.general.MapResponse) Variable(uk.ac.ed.ph.jqtiplus.node.expression.general.Variable) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) ResponseElse(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseElse) ResponseIf(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf) Sum(uk.ac.ed.ph.jqtiplus.node.expression.operator.Sum) Correct(uk.ac.ed.ph.jqtiplus.node.expression.general.Correct) Match(uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)

Aggregations

ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)26 Variable (uk.ac.ed.ph.jqtiplus.node.expression.general.Variable)24 Correct (uk.ac.ed.ph.jqtiplus.node.expression.general.Correct)22 ResponseIf (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf)20 Match (uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)18 ResponseElse (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseElse)16 SetOutcomeValue (uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue)16 BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)14 Sum (uk.ac.ed.ph.jqtiplus.node.expression.operator.Sum)14 MapResponse (uk.ac.ed.ph.jqtiplus.node.expression.general.MapResponse)10 IsNull (uk.ac.ed.ph.jqtiplus.node.expression.operator.IsNull)8 Expression (uk.ac.ed.ph.jqtiplus.node.expression.Expression)6 ResponseCondition (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition)6 FloatOrVariableRef (uk.ac.ed.ph.jqtiplus.types.FloatOrVariableRef)6 ArrayList (java.util.ArrayList)4 AssessmentItemFactory.appendSetOutcomeFeedbackCorrect (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendSetOutcomeFeedbackCorrect)4 And (uk.ac.ed.ph.jqtiplus.node.expression.operator.And)4 Equal (uk.ac.ed.ph.jqtiplus.node.expression.operator.Equal)4 MapEntry (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry)4 ResponseElseIf (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseElseIf)4