use of org.olat.ims.qti.container.qtielements.RenderInstructions in project OpenOLAT by OpenOLAT.
the class QTIWordExport method renderItem.
public static void renderItem(Item item, OpenXMLDocument document, boolean withResponses, Translator translator) {
Element el = DocumentFactory.getInstance().createElement("dummy");
item.addToElement(el);
Element itemEl = (Element) el.elements().get(0);
org.olat.ims.qti.container.qtielements.Item foo = new org.olat.ims.qti.container.qtielements.Item(itemEl);
RenderInstructions renderInstructions = new RenderInstructions();
renderInstructions.put(RenderInstructions.KEY_STATICS_PATH, "/");
renderInstructions.put(RenderInstructions.KEY_LOCALE, translator.getLocale());
renderInstructions.put(RenderInstructions.KEY_RENDER_TITLE, Boolean.TRUE);
if (item.getQuestion() != null) {
Map<String, String> iinput = new HashMap<String, String>();
String questionType = null;
String questionScore = null;
Question question = item.getQuestion();
if (question instanceof ChoiceQuestion) {
ChoiceQuestion choice = (ChoiceQuestion) question;
if (question.getType() == Question.TYPE_SC) {
questionType = translator.translate("item.type.sc");
fetchPointsOfMultipleChoices(itemEl, choice, iinput);
} else if (question.getType() == Question.TYPE_MC) {
questionType = translator.translate("item.type.mc");
fetchPointsOfMultipleChoices(itemEl, choice, iinput);
} else if (question.getType() == Question.TYPE_KPRIM) {
questionType = translator.translate("item.type.kprim");
fetchPointsOfKPrim(itemEl, choice, iinput);
}
} else if (question instanceof FIBQuestion) {
questionType = translator.translate("item.type.sc");
for (Response response : question.getResponses()) {
FIBResponse fibResponse = (FIBResponse) response;
if ("BLANK".equals(fibResponse.getType())) {
iinput.put(fibResponse.getIdent(), fibResponse.getCorrectBlank());
}
}
} else if (question instanceof EssayQuestion) {
questionType = translator.translate("item.type.essay");
}
if (question != null && question.getMaxValue() > 0.0f) {
questionScore = AssessmentHelper.getRoundedScore(question.getMaxValue());
questionScore = translator.translate("item.score.long", new String[] { questionScore });
}
renderInstructions.put(RenderInstructions.KEY_RENDER_CORRECT_RESPONSES, new Boolean(withResponses));
renderInstructions.put(RenderInstructions.KEY_CORRECT_RESPONSES_MAP, iinput);
renderInstructions.put(RenderInstructions.KEY_QUESTION_TYPE, questionType);
renderInstructions.put(RenderInstructions.KEY_QUESTION_SCORE, questionScore);
renderInstructions.put(RenderInstructions.KEY_QUESTION_OO_TYPE, new Integer(question.getType()));
}
foo.renderOpenXML(document, renderInstructions);
}
use of org.olat.ims.qti.container.qtielements.RenderInstructions in project OpenOLAT by OpenOLAT.
the class IQComponentRenderer method displayItem.
private void displayItem(StringOutput sb, Renderer renderer, URLBuilder ubu, ItemContext itc, AssessmentInstance ai) {
StringBuilder buffer = new StringBuilder(1000);
Resolver resolver = ai.getResolver();
RenderInstructions ri = new RenderInstructions();
ri.put(RenderInstructions.KEY_STATICS_PATH, resolver.getStaticsBaseURI() + "/");
ri.put(RenderInstructions.KEY_LOCALE, renderer.getTranslator().getLocale());
StringOutput soCommandURI = new StringOutput(50);
ubu.buildURI(soCommandURI, new String[] { VelocityContainer.COMMAND_ID }, new String[] { "sflash" });
ri.put(RenderInstructions.KEY_APPLET_SUBMIT_URI, soCommandURI.toString());
if (itc.getItemInput() != null)
ri.put(RenderInstructions.KEY_ITEM_INPUT, itc.getItemInput());
ri.put(RenderInstructions.KEY_RENDER_TITLE, Boolean.valueOf(ai.isDisplayTitles()));
if (ai.isAutoEnum()) {
String k = renderer.getTranslator().translate("choices.autoenum.keys");
if (k != null) {
ri.put(RenderInstructions.KEY_RENDER_AUTOENUM_LIST, k);
}
}
itc.getQtiItem().render(buffer, ri);
sb.append(buffer);
}
use of org.olat.ims.qti.container.qtielements.RenderInstructions in project openolat by klemens.
the class IQComponentRenderer method displayFeedback.
private void displayFeedback(StringOutput sb, GenericQTIElement feedback, AssessmentInstance ai, Locale locale) {
StringBuilder sbTmp = new StringBuilder();
Resolver resolver = ai.getResolver();
RenderInstructions ri = new RenderInstructions();
ri.put(RenderInstructions.KEY_STATICS_PATH, resolver.getStaticsBaseURI() + "/");
ri.put(RenderInstructions.KEY_LOCALE, locale);
feedback.render(sbTmp, ri);
sb.append(sbTmp);
}
use of org.olat.ims.qti.container.qtielements.RenderInstructions in project openolat by klemens.
the class IQComponentRenderer method displayItem.
private void displayItem(StringOutput sb, Renderer renderer, URLBuilder ubu, ItemContext itc, AssessmentInstance ai) {
StringBuilder buffer = new StringBuilder(1000);
Resolver resolver = ai.getResolver();
RenderInstructions ri = new RenderInstructions();
ri.put(RenderInstructions.KEY_STATICS_PATH, resolver.getStaticsBaseURI() + "/");
ri.put(RenderInstructions.KEY_LOCALE, renderer.getTranslator().getLocale());
StringOutput soCommandURI = new StringOutput(50);
ubu.buildURI(soCommandURI, new String[] { VelocityContainer.COMMAND_ID }, new String[] { "sflash" });
ri.put(RenderInstructions.KEY_APPLET_SUBMIT_URI, soCommandURI.toString());
if (itc.getItemInput() != null)
ri.put(RenderInstructions.KEY_ITEM_INPUT, itc.getItemInput());
ri.put(RenderInstructions.KEY_RENDER_TITLE, Boolean.valueOf(ai.isDisplayTitles()));
if (ai.isAutoEnum()) {
String k = renderer.getTranslator().translate("choices.autoenum.keys");
if (k != null) {
ri.put(RenderInstructions.KEY_RENDER_AUTOENUM_LIST, k);
}
}
itc.getQtiItem().render(buffer, ri);
sb.append(buffer);
}
use of org.olat.ims.qti.container.qtielements.RenderInstructions in project OpenOLAT by OpenOLAT.
the class IQComponentRenderer method displayAssessmentInfo.
private void displayAssessmentInfo(StringOutput sb, AssessmentContext ac, AssessmentInstance ai, IQComponent comp, URLBuilder ubu, Translator translator) {
Objectives objectives = ac.getObjectives();
if (objectives != null) {
StringBuilder sbTmp = new StringBuilder();
Resolver resolver = ai.getResolver();
RenderInstructions ri = new RenderInstructions();
ri.put(RenderInstructions.KEY_STATICS_PATH, resolver.getStaticsBaseURI() + "/");
objectives.render(sbTmp, ri);
sb.append(sbTmp);
}
// if Menu not visible, or if visible but not selectable show button to navigate to the first section panel
IQMenuDisplayConf menuDisplayConfig = comp.getMenuDisplayConf();
if (!menuDisplayConfig.isEnabledMenu()) {
sb.append("<a class=\"btn btn-default\" onclick=\"return o2cl()\" href=\"");
ubu.buildURI(sb, new String[] { VelocityContainer.COMMAND_ID }, new String[] { "gse" });
sb.append("?seid=" + 0);
String title = translator.translate("next");
sb.append("\" title=\"" + StringEscapeUtils.escapeHtml(title) + "\">");
sb.append("<span>").append(title).append("</span>");
sb.append("</a>");
}
}
Aggregations