use of uk.ac.ed.ph.qtiworks.mathassess.XsltStylesheetCacheAdapter in project OpenOLAT by OpenOLAT.
the class MathWebDispatcher method execute.
@Override
public void execute(HttpServletRequest request, HttpServletResponse response) {
UserRequest ureq = null;
try {
// upon creation URL is checked for
ureq = new UserRequestImpl("math", request, response);
} catch (NumberFormatException nfe) {
DispatcherModule.sendBadRequest(request.getPathInfo(), response);
return;
}
String asciiMathInput = ureq.getParameter("input");
Map<String, String> upConvertedAsciiMathInput;
if (StringHelper.containsNonWhitespace(asciiMathInput)) {
XsltStylesheetCache stylesheetCache = CoreSpringFactory.getImpl(QTI21Service.class).getXsltStylesheetCache();
AsciiMathHelper asciiMathHelper = new AsciiMathHelper(new XsltStylesheetCacheAdapter(stylesheetCache));
upConvertedAsciiMathInput = asciiMathHelper.upConvertAsciiMathInput(asciiMathInput);
} else {
upConvertedAsciiMathInput = Collections.emptyMap();
}
try {
JSONObject object = new JSONObject();
for (Map.Entry<String, String> entry : upConvertedAsciiMathInput.entrySet()) {
object.append(entry.getKey(), entry.getValue());
}
object.write(response.getWriter());
} catch (JSONException | IOException e) {
log.error("", e);
}
}
use of uk.ac.ed.ph.qtiworks.mathassess.XsltStylesheetCacheAdapter in project openolat by klemens.
the class MathWebDispatcher method execute.
@Override
public void execute(HttpServletRequest request, HttpServletResponse response) {
UserRequest ureq = null;
try {
// upon creation URL is checked for
ureq = new UserRequestImpl("math", request, response);
} catch (NumberFormatException nfe) {
DispatcherModule.sendBadRequest(request.getPathInfo(), response);
return;
}
String asciiMathInput = ureq.getParameter("input");
Map<String, String> upConvertedAsciiMathInput;
if (StringHelper.containsNonWhitespace(asciiMathInput)) {
XsltStylesheetCache stylesheetCache = CoreSpringFactory.getImpl(QTI21Service.class).getXsltStylesheetCache();
AsciiMathHelper asciiMathHelper = new AsciiMathHelper(new XsltStylesheetCacheAdapter(stylesheetCache));
upConvertedAsciiMathInput = asciiMathHelper.upConvertAsciiMathInput(asciiMathInput);
} else {
upConvertedAsciiMathInput = Collections.emptyMap();
}
try {
JSONObject object = new JSONObject();
for (Map.Entry<String, String> entry : upConvertedAsciiMathInput.entrySet()) {
object.append(entry.getKey(), entry.getValue());
}
object.write(response.getWriter());
} catch (JSONException | IOException e) {
log.error("", e);
}
}
Aggregations