Search in sources :

Example 26 with Correct

use of uk.ac.ed.ph.jqtiplus.node.expression.general.Correct in project openolat by klemens.

the class AssessmentItemFactory method createResponseProcessing.

public static ResponseProcessing createResponseProcessing(AssessmentItem assessmentItem, Identifier responseId) {
    ResponseProcessing responseProcessing = new ResponseProcessing(assessmentItem);
    ResponseCondition rule = new ResponseCondition(responseProcessing);
    // if no response
    ResponseIf responseIf = new ResponseIf(rule);
    rule.setResponseIf(responseIf);
    IsNull isNull = new IsNull(responseIf);
    responseIf.getExpressions().add(isNull);
    Variable variable = new Variable(isNull);
    variable.setIdentifier(ComplexReferenceIdentifier.parseString(responseId.toString()));
    isNull.getExpressions().add(variable);
    {
        SetOutcomeValue feedbackVar = new SetOutcomeValue(responseIf);
        feedbackVar.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
        BaseValue feedbackVal = new BaseValue(feedbackVar);
        feedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
        feedbackVal.setSingleValue(new IdentifierValue("empty"));
        feedbackVar.setExpression(feedbackVal);
        responseIf.getResponseRules().add(feedbackVar);
    }
    // else if correct response
    ResponseElseIf responseElseIf = new ResponseElseIf(rule);
    rule.getResponseElseIfs().add(responseElseIf);
    // match
    {
        Match match = new Match(responseElseIf);
        responseElseIf.getExpressions().add(match);
        Variable responseVar = new Variable(match);
        responseVar.setIdentifier(ComplexReferenceIdentifier.parseString(responseId.toString()));
        match.getExpressions().add(responseVar);
        Correct correct = new Correct(match);
        correct.setIdentifier(ComplexReferenceIdentifier.parseString(responseId.toString()));
        match.getExpressions().add(correct);
    }
    // outcome score
    {
        SetOutcomeValue scoreOutcomeVar = new SetOutcomeValue(responseIf);
        scoreOutcomeVar.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
        responseElseIf.getResponseRules().add(scoreOutcomeVar);
        Sum sum = new Sum(scoreOutcomeVar);
        scoreOutcomeVar.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 correctFeedbackVar = new SetOutcomeValue(responseIf);
        correctFeedbackVar.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
        BaseValue correctFeedbackVal = new BaseValue(correctFeedbackVar);
        correctFeedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
        correctFeedbackVal.setSingleValue(QTI21Constants.CORRECT_IDENTIFIER_VALUE);
        correctFeedbackVar.setExpression(correctFeedbackVal);
        responseElseIf.getResponseRules().add(correctFeedbackVar);
    }
    // else failed
    ResponseElse responseElse = new ResponseElse(rule);
    rule.setResponseElse(responseElse);
    {
        // feedback incorrect
        SetOutcomeValue incorrectFeedbackVar = new SetOutcomeValue(responseIf);
        incorrectFeedbackVar.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
        BaseValue incorrectFeedbackVal = new BaseValue(incorrectFeedbackVar);
        incorrectFeedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
        incorrectFeedbackVal.setSingleValue(QTI21Constants.INCORRECT_IDENTIFIER_VALUE);
        incorrectFeedbackVar.setExpression(incorrectFeedbackVal);
        responseElse.getResponseRules().add(incorrectFeedbackVar);
    }
    responseProcessing.getResponseRules().add(rule);
    return responseProcessing;
}
Also used : 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) ResponseIf(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) Sum(uk.ac.ed.ph.jqtiplus.node.expression.operator.Sum) ResponseProcessing(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing) 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) ResponseElse(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseElse) IsNull(uk.ac.ed.ph.jqtiplus.node.expression.operator.IsNull) ResponseCondition(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition)

Aggregations

Correct (uk.ac.ed.ph.jqtiplus.node.expression.general.Correct)26 Variable (uk.ac.ed.ph.jqtiplus.node.expression.general.Variable)24 Match (uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)22 ResponseIf (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf)22 ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)22 ResponseElse (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseElse)20 BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)18 Sum (uk.ac.ed.ph.jqtiplus.node.expression.operator.Sum)18 SetOutcomeValue (uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue)18 IsNull (uk.ac.ed.ph.jqtiplus.node.expression.operator.IsNull)12 MapResponse (uk.ac.ed.ph.jqtiplus.node.expression.general.MapResponse)10 ResponseElseIf (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseElseIf)8 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 Equal (uk.ac.ed.ph.jqtiplus.node.expression.operator.Equal)4 MapEntry (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry)4 FloatValue (uk.ac.ed.ph.jqtiplus.value.FloatValue)4 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)4