use of uk.ac.ed.ph.jqtiplus.node.item.template.declaration.TemplateDeclaration in project openolat by klemens.
the class AssessmentItemChecker method checkSetCorrectResponse.
/**
* responseDeclaration -> float
*
* templateVraiable -> integer
*
* setCorrectResponse
* -> variable -> integer doesn't match float -> issue
* @param item
* @return
*/
private static boolean checkSetCorrectResponse(AssessmentItem item) {
boolean allOk = true;
List<SetCorrectResponse> setCorrectResponses = QueryUtils.search(SetCorrectResponse.class, item);
for (SetCorrectResponse setCorrectResponse : setCorrectResponses) {
Identifier responseIdentifier = setCorrectResponse.getIdentifier();
ResponseDeclaration responseDeclaration = item.getResponseDeclaration(responseIdentifier);
BaseType baseType = responseDeclaration.getBaseType();
Expression expression = setCorrectResponse.getExpression();
if (expression instanceof Variable) {
Variable variable = (Variable) expression;
ComplexReferenceIdentifier cpxVariableIdentifier = variable.getIdentifier();
Identifier variableIdentifier = Identifier.assumedLegal(cpxVariableIdentifier.toString());
TemplateDeclaration templateDeclaration = item.getTemplateDeclaration(variableIdentifier);
if (templateDeclaration != null && !templateDeclaration.hasBaseType(baseType)) {
templateDeclaration.setBaseType(baseType);
allOk &= false;
}
}
}
return allOk;
}
use of uk.ac.ed.ph.jqtiplus.node.item.template.declaration.TemplateDeclaration in project openolat by klemens.
the class AssessmentItemCheckerTest method checkAndCorrect_hottextOpenOLAT.
@Test
public void checkAndCorrect_hottextOpenOLAT() throws URISyntaxException {
URL itemUrl = OnyxToAssessmentItemBuilderTest.class.getResource("resources/openolat/hottext-score-all-11-4-0.xml");
AssessmentItem assessmentItem = loadAssessmentItem(itemUrl);
boolean ok = AssessmentItemChecker.checkAndCorrect(assessmentItem);
Assert.assertTrue(ok);
TemplateDeclaration templateDeclaration = assessmentItem.getTemplateDeclaration(Identifier.assumedLegal("SOLUTION1"));
Assert.assertNull(templateDeclaration);
}
use of uk.ac.ed.ph.jqtiplus.node.item.template.declaration.TemplateDeclaration in project openolat by klemens.
the class AssessmentItemCheckerTest method checkAndCorrect_wrongType.
@Test
public void checkAndCorrect_wrongType() throws URISyntaxException {
URL itemUrl = OnyxToAssessmentItemBuilderTest.class.getResource("resources/onyx/set-correct-response-wrong-type-5-11.xml");
AssessmentItem assessmentItem = loadAssessmentItem(itemUrl);
boolean ok = AssessmentItemChecker.checkAndCorrect(assessmentItem);
Assert.assertFalse(ok);
TemplateDeclaration solutionDeclaration = assessmentItem.getTemplateDeclaration(Identifier.assumedLegal("solution"));
Assert.assertEquals(BaseType.FLOAT, solutionDeclaration.getBaseType());
}
use of uk.ac.ed.ph.jqtiplus.node.item.template.declaration.TemplateDeclaration in project openolat by klemens.
the class AssessmentItemCheckerTest method checkAndCorrect_rightType.
@Test
public void checkAndCorrect_rightType() throws URISyntaxException {
URL itemUrl = OnyxToAssessmentItemBuilderTest.class.getResource("resources/umpc/addition.xml");
AssessmentItem assessmentItem = loadAssessmentItem(itemUrl);
boolean ok = AssessmentItemChecker.checkAndCorrect(assessmentItem);
Assert.assertTrue(ok);
TemplateDeclaration solutionDeclaration = assessmentItem.getTemplateDeclaration(Identifier.assumedLegal("SOLUTION1"));
Assert.assertEquals(BaseType.FLOAT, solutionDeclaration.getBaseType());
}
use of uk.ac.ed.ph.jqtiplus.node.item.template.declaration.TemplateDeclaration in project OpenOLAT by OpenOLAT.
the class AssessmentItemCheckerTest method checkAndCorrect_notTemplateDeclaration.
@Test
public void checkAndCorrect_notTemplateDeclaration() throws URISyntaxException {
URL itemUrl = OnyxToAssessmentItemBuilderTest.class.getResource("resources/ims/template_image.xml");
AssessmentItem assessmentItem = loadAssessmentItem(itemUrl);
boolean ok = AssessmentItemChecker.checkAndCorrect(assessmentItem);
Assert.assertTrue(ok);
TemplateDeclaration templateDeclaration = assessmentItem.getTemplateDeclaration(Identifier.assumedLegal("SOLUTION1"));
Assert.assertNull(templateDeclaration);
}
Aggregations