use of org.olat.core.gui.render.RenderResult in project OpenOLAT by OpenOLAT.
the class MailContextCellRenderer method render.
@Override
public void render(StringOutput sb, Renderer renderer, Object val, Locale locale, int alignment, String action) {
if (val instanceof ContextPair) {
ContextPair context = (ContextPair) val;
if (renderer == null) {
StringHelper.escapeHtml(sb, context.getName());
} else {
String contextName = StringHelper.escapeHtml(context.getName());
Link link = LinkFactory.createLink("bp_" + UUID.randomUUID().toString(), container, listeningController);
link.setCustomDisplayText(contextName);
link.setUserObject(context.getBusinessPath());
URLBuilder ubu = renderer.getUrlBuilder().createCopyFor(link);
RenderResult renderResult = new RenderResult();
link.getHTMLRendererSingleton().render(renderer, sb, link, ubu, translator, renderResult, null);
}
}
}
use of org.olat.core.gui.render.RenderResult in project OpenOLAT by OpenOLAT.
the class ExportBinderAsCPResource method renderVelocityContainer.
private String renderVelocityContainer(VelocityContainer mainVC) {
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 OpenOLAT.
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 OpenOLAT.
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 QTI21ResultsExportMediaResource method createResultHTML.
private String createResultHTML(Component results) {
String pagePath = Util.getPackageVelocityRoot(this.getClass()) + "/qti21results.html";
URLBuilder ubu = new URLBuilder("auth", "1", "0");
// generate VelocityContainer and put Component
VelocityContainer mainVC = new VelocityContainer("html", pagePath, translator, null);
mainVC.contextPut("rootTitle", translator.translate("table.grading"));
mainVC.put("results", results);
// render VelocityContainer to StringOutPut
Renderer renderer = Renderer.getInstance(mainVC, translator, ubu, new RenderResult(), new EmptyGlobalSettings());
try (StringOutput sb = new StringOutput(32000);
VelocityRenderDecorator vrdec = new VelocityRenderDecorator(renderer, mainVC, sb)) {
mainVC.contextPut("r", vrdec);
renderer.render(sb, mainVC, null);
vrdec.close();
return sb.toString();
} catch (Exception e) {
log.error("", e);
return "";
}
}
Aggregations