use of org.olat.core.gui.render.RenderResult in project openolat by klemens.
the class AssessmentObjectComponentRenderer method renderVelocity.
private void renderVelocity(AssessmentRenderer renderer, StringOutput sb, QtiNode interaction, Context ctx, String page, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, AssessmentObjectComponent component, URLBuilder ubu, Translator translator) {
ctx.put("localName", interaction.getQtiClassName());
ctx.put("assessmentItem", resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful());
ctx.put("itemSessionState", itemSessionState);
ctx.put("isItemSessionOpen", component.isItemSessionOpen(itemSessionState, renderer.isSolutionMode()));
ctx.put("isItemSessionEnded", component.isItemSessionEnded(itemSessionState, renderer.isSolutionMode()));
Renderer fr = Renderer.getInstance(component, translator, ubu, new RenderResult(), renderer.getGlobalSettings());
AssessmentRenderer fHints = renderer.newHints(fr);
try (AssessmentObjectVelocityRenderDecorator vrdec = new AssessmentObjectVelocityRenderDecorator(fHints, sb, component, resolvedAssessmentItem, itemSessionState, ubu, translator)) {
ctx.put("r", vrdec);
VelocityHelper vh = VelocityHelper.getInstance();
vh.mergeContent(page, ctx, sb, null);
ctx.remove("r");
} catch (IOException e) {
log.error("", e);
}
}
use of org.olat.core.gui.render.RenderResult in project openolat by klemens.
the class AssessmentTestComponentRenderer method renderTestItem.
private void renderTestItem(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, TestPlanNodeKey itemRefKey, URLBuilder ubu, Translator translator, RenderingRequest options) {
final TestSessionController testSessionController = component.getTestSessionController();
final TestSessionState testSessionState = testSessionController.getTestSessionState();
String key = itemRefKey.toString();
/* We finally do the transform on the _item_ (NB!) */
sb.append("<div class='qtiworks o_assessmentitem o_assessmenttest'>");
// test part feedback 'during'
// test feedback 'during'
TestPlanNode itemRefNode = testSessionState.getTestPlan().getNode(itemRefKey);
final EffectiveItemSessionControl effectiveItemSessionControl = itemRefNode.getEffectiveItemSessionControl();
final boolean allowComments = effectiveItemSessionControl.isAllowComment() && component.isPersonalNotes();
renderer.setCandidateCommentAllowed(allowComments);
// write section rubric
renderSectionRubrics(renderer, sb, component, itemRefNode, ubu, translator);
// test part -> section -> item
renderTestItemBody(renderer, sb, component, itemRefNode, ubu, translator, options);
// controls
sb.append("<div class='o_button_group o_assessmentitem_controls'>");
// submit button
final ItemSessionState itemSessionState = component.getItemSessionState(itemRefNode.getKey());
if (component.isItemSessionOpen(itemSessionState, options.isSolutionMode())) {
Component submit = component.getQtiItem().getSubmitButton().getComponent();
submit.getHTMLRendererSingleton().render(renderer.getRenderer(), sb, submit, ubu, translator, new RenderResult(), null);
}
// advanceTestItemAllowed /* && testSessionState.getCurrentItemKey() != null && testSessionController.mayAdvanceItemLinear() */
if (options.isAdvanceTestItemAllowed()) {
// TODO need to find if there is a next question
String title = translator.translate("assessment.test.nextQuestion");
renderControl(sb, component, title, false, "o_sel_next_question", new NameValuePair("cid", Event.finishItem.name()));
}
// nextItem
if (options.isNextItemAllowed() && testSessionController.hasFollowingNonLinearItem()) {
String title = translator.translate("assessment.test.nextQuestion");
renderControl(sb, component, title, false, "o_sel_next_question", new NameValuePair("cid", Event.nextItem.name()));
}
// testPartNavigationAllowed"
if (options.isTestPartNavigationAllowed() && component.isRenderNavigation()) {
String title = translator.translate("assessment.test.questionMenu");
renderControl(sb, component, title, false, "o_sel_question_menu", new NameValuePair("cid", Event.testPartNavigation.name()));
}
// endTestPartAllowed
if (options.isEndTestPartAllowed()) {
String title = component.hasMultipleTestParts() ? translator.translate("assessment.test.end.testPart") : translator.translate("assessment.test.end.test");
renderControl(sb, component, title, false, "o_sel_end_testpart", new NameValuePair("cid", Event.endTestPart.name()));
}
// reviewMode
if (options.isReviewMode()) {
String title = translator.translate("assessment.test.backToTestFeedback");
renderControl(sb, component, title, false, "o_sel_back_test_feedback", new NameValuePair("cid", Event.reviewTestPart.name()));
}
// <xsl:variable name="provideItemSolutionButton" as="xs:boolean" select="$reviewMode and $showSolution and not($solutionMode)"/>
if (options.isReviewMode() && effectiveItemSessionControl.isShowSolution() && !options.isSolutionMode()) {
String title = translator.translate("assessment.solution.show");
renderControl(sb, component, title, false, "o_sel_show_solution", new NameValuePair("cid", Event.itemSolution.name()), new NameValuePair("item", key));
}
if (options.isReviewMode() && options.isSolutionMode()) {
String title = translator.translate("assessment.solution.hide");
renderControl(sb, component, title, false, "o_sel_solution_hide", new NameValuePair("cid", Event.reviewItem.name()), new NameValuePair("item", key));
}
// end controls
sb.append("</div>");
// end assessmentItem
sb.append("</div>");
}
use of org.olat.core.gui.render.RenderResult in project openolat by klemens.
the class ExportBinderAsPDFResource method createResultHTML.
private String createResultHTML(Component content) {
String pagePath = Util.getPackageVelocityRoot(this.getClass()) + "/export.html";
VelocityContainer mainVC = new VelocityContainer("html", pagePath, translator, null);
mainVC.put("cmp", content);
mainVC.contextPut("bodyCssClass", "o_portfolio_export");
StringOutput sb = new StringOutput(32000);
URLBuilder ubu = new URLBuilder("auth", "1", "0");
Renderer renderer = Renderer.getInstance(mainVC, translator, ubu, new RenderResult(), new EmptyGlobalSettings());
VelocityRenderDecorator vrdec = new VelocityRenderDecorator(renderer, mainVC, sb);
mainVC.contextPut("r", vrdec);
renderer.render(sb, mainVC, null);
return sb.toString();
}
use of org.olat.core.gui.render.RenderResult in project openolat by klemens.
the class MailFromCellRenderer method render.
@Override
public void render(StringOutput sb, Renderer renderer, Object val, Locale locale, int alignment, String action) {
if (val instanceof Identity) {
Identity identity = (Identity) val;
String fullName = userManager.getUserDisplayName(identity);
if (renderer == null) {
sb.appendHtmlEscaped(fullName);
} else {
Link link = LinkFactory.createLink("bp_" + counter.incrementAndGet(), container, listeningController);
link.setCustomDisplayText(StringHelper.escapeHtml(fullName));
link.setUserObject("[Identity:" + identity.getKey() + "]");
URLBuilder ubu = renderer.getUrlBuilder().createCopyFor(link);
RenderResult renderResult = new RenderResult();
link.getHTMLRendererSingleton().render(renderer, sb, link, ubu, translator, renderResult, null);
}
} else if (val instanceof String) {
sb.append("<span>").appendHtmlEscaped((String) val).append("</span>");
}
}
use of org.olat.core.gui.render.RenderResult in project OpenOLAT by OpenOLAT.
the class CourseCreationConfiguration method getSinglePageText.
/**
* @param translator
* @return single page content
*/
public String getSinglePageText(Translator translator) {
VelocityContainer vc = new VelocityContainer("singlePageTemplate", CourseCreationHelper.class, "singlePageTemplate", translator, null);
vc.contextPut("coursetitle", courseTitle);
// prepare rendering of velocity page for the content of the single page node
GlobalSettings globalSettings = new GlobalSettings() {
public int getFontSize() {
return 100;
}
public AJAXFlags getAjaxFlags() {
return new EmptyAJAXFlags();
}
public boolean isIdDivsForced() {
return false;
}
};
Context context = vc.getContext();
Renderer fr = Renderer.getInstance(vc, translator, null, new RenderResult(), globalSettings);
StringOutput wOut = new StringOutput(10000);
VelocityRenderDecorator vrdec = new VelocityRenderDecorator(fr, vc, wOut);
context.put("r", vrdec);
VelocityHelper.getInstance().mergeContent(vc.getPage(), context, wOut, null);
// free the decorator
context.remove("r");
IOUtils.closeQuietly(vrdec);
return WysiwygFactory.createXHtmlFileContent(wOut.toString(), courseTitle);
}
Aggregations