/** * The parsing {@link ResponseData} for this interaction is slightly artificial in order to * make it easy to implement in a web form: * * - We accept {@link StringResponseData} only. * - An empty list is treated as false, anything else is treated as true. */ @Override protected Value parseResponse(final ResponseDeclaration responseDeclaration, final ResponseData responseData) throws ResponseBindingException { if (responseData.getType()!=ResponseDataType.STRING) { throw new ResponseBindingException(responseDeclaration, responseData, "ResponseData for endAttemptInteraction must be of string type"); } final List<String> stringResponseData = ((StringResponseData) responseData).getResponseData(); return BooleanValue.valueOf(!stringResponseData.isEmpty()); }
private static void appendResponseData(final Element element, final ResponseData responseData) { switch (responseData.getType()) { case STRING: final StringResponseData stringResponseData = (StringResponseData) responseData; for (final String responseDatum : stringResponseData.getResponseData()) { XmlMarshallerCore.maybeAppendTextElement(element, "string", responseDatum); } break; case FILE: final FileResponseData fileResponseData = (FileResponseData) responseData; final Element fileElement = XmlMarshallerCore.appendElement(element, "file"); fileElement.setAttribute("contentType", fileResponseData.getContentType()); fileElement.setAttribute("fileName", fileResponseData.getFileName()); fileElement.setAttribute("absoluteFilePath", fileResponseData.getFile().getAbsolutePath()); break; default: throw new QtiLogicException("Unexpected switch case " + responseData.getType()); } }
@Override protected Value parseResponse(final MathAssessExtensionPackage mathAssessExtensionPackage, final ResponseDeclaration responseDeclaration, final ResponseData responseData) throws ResponseBindingException { if (responseData.getType()!=ResponseDataType.STRING) { throw new ResponseBindingException(responseDeclaration, responseData, "mathEntryInteraction must be bound to string response data");
if (responseData.getType()!=ResponseDataType.FILE) { throw new ResponseBindingException(responseDeclaration, responseData, "Attempted to bind non-file response data to a file response"); if (responseData.getType()!=ResponseDataType.STRING) { throw new ResponseBindingException(responseDeclaration, responseData, "Attempted to bind non-string response data to response with baseType " + responseBaseType);
@Override protected Value parseResponse(final ResponseDeclaration responseDeclaration, final ResponseData responseData) throws ResponseBindingException { if (responseData.getType()!=ResponseDataType.STRING) { throw new ResponseBindingException(responseDeclaration, responseData, "textInteraction must be bound to string response data");
@Override protected Value parseResponse(final ResponseDeclaration responseDeclaration, final ResponseData responseData) throws ResponseBindingException { if (responseData.getType()!=ResponseDataType.STRING) { throw new ResponseBindingException(responseDeclaration, responseData, "extendedTextInteraction must be bound to string response data");
candidateItemResponse.setResponseDataType(responseData.getType()); switch (responseData.getType()) { case STRING: candidateItemResponse.setStringResponseData(((StringResponseData) responseData).getResponseData()); throw new QtiWorksLogicException("Unexpected switch case: " + responseData.getType());