use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.
the class IQComponentRenderer method addSectionLink.
// menu stuff
private StringOutput addSectionLink(Renderer r, URLBuilder ubu, Formatter formatter, SectionContext sc, int sectionPos, boolean clickable, boolean active, boolean pagewise) {
StringOutput sb = new StringOutput();
// section link
sb.append("<td>");
String title = StringHelper.escapeHtml(Formatter.truncate(sc.getTitle(), 30));
long maxdur = sc.getDurationLimit();
long start = sc.getTimeOfStart();
long due = start + maxdur;
boolean started = (start != -1);
boolean timelimit = (maxdur != -1);
String fdue = (started && timelimit ? formatter.formatTimeShort(new Date(due)) : null);
if (!sc.isOpen())
clickable = false;
if (active) {
if (pagewise) {
sb.append("<div class=\"o_qti_menu_section_active\">");
} else {
sb.append("<div class=\"o_qti_menu_section\">");
}
} else {
if (pagewise) {
sb.append("<div class=\"o_qti_menu_section_clickable\">");
} else {
sb.append("<div class=\"o_qti_menu_section\">");
}
}
if (clickable) {
sb.append("<a onclick=\"return o2cl()\" href=\"");
ubu.buildURI(sb, new String[] { VelocityContainer.COMMAND_ID }, new String[] { "gse" });
sb.append("?seid=" + sectionPos);
sb.append("\" title=\"" + StringEscapeUtils.escapeHtml(sc.getTitle()) + "\">");
}
sb.append("<b>" + (sectionPos + 1) + ".</b> ");
sb.append(title);
if (clickable) {
sb.append("</a>");
}
sb.append("</div>");
sb.append("</td>");
sb.append("<td>");
if (!sc.isOpen()) {
sb.append("<div class='o_qti_closed_icon' title=\"");
sb.append(StringEscapeUtils.escapeHtml(r.getTranslator().translate("itemclosed")));
sb.append("\"><i class='o_icon o_icon_locked'> </i></div>");
} else {
// max duration info
if (maxdur != -1) {
sb.append("<div class='o_qti_timelimit_icon' title=\"");
if (!sc.isStarted()) {
sb.append(StringEscapeUtils.escapeHtml(r.getTranslator().translate("timelimit.initial", new String[] { getFormattedLimit(maxdur) })));
} else {
sb.append(StringEscapeUtils.escapeHtml(r.getTranslator().translate("timelimit.running", new String[] { fdue })));
}
sb.append("\" ><i class='o_icon o_icon_timelimit'> </i></div>");
}
}
sb.append("</td>");
sb.append("<td colspan=\"2\"></td>");
return sb;
}
use of org.olat.core.gui.render.StringOutput 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.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.
the class HotspotAssessmentItemBuilder method extractHotspotInteraction.
private void extractHotspotInteraction() {
try (StringOutput sb = new StringOutput()) {
List<Block> blocks = assessmentItem.getItemBody().getBlocks();
for (Block block : blocks) {
if (block instanceof HotspotInteraction) {
hotspotInteraction = (HotspotInteraction) block;
responseIdentifier = hotspotInteraction.getResponseIdentifier();
break;
} else {
serializeJqtiObject(block, sb);
}
}
question = sb.toString();
} catch (IOException e) {
log.error("", e);
}
}
use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.
the class MatchAssessmentItemBuilder method extractMatchInteraction.
private void extractMatchInteraction() {
try (StringOutput sb = new StringOutput()) {
List<Block> blocks = assessmentItem.getItemBody().getBlocks();
for (Block block : blocks) {
if (block instanceof MatchInteraction) {
matchInteraction = (MatchInteraction) block;
responseIdentifier = matchInteraction.getResponseIdentifier();
shuffle = matchInteraction.getShuffle();
break;
} else {
serializeJqtiObject(block, sb);
}
}
question = sb.toString();
} catch (IOException e) {
log.error("", e);
}
}
use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.
the class EssayAssessmentItemBuilder method extractExtendedTextInteraction.
private void extractExtendedTextInteraction() {
try (StringOutput sb = new StringOutput()) {
List<Block> blocks = assessmentItem.getItemBody().getBlocks();
for (Block block : blocks) {
if (block instanceof ExtendedTextInteraction) {
extendedTextInteraction = (ExtendedTextInteraction) block;
responseIdentifier = extendedTextInteraction.getResponseIdentifier();
break;
} else {
serializeJqtiObject(block, sb);
}
}
question = sb.toString();
} catch (IOException e) {
log.error("", e);
}
}
Aggregations