use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class AssessmentObjectComponentRenderer method renderEndAttemptInteraction.
private void renderEndAttemptInteraction(AssessmentRenderer renderer, StringOutput sb, EndAttemptInteraction interaction, ItemSessionState itemSessionState, AssessmentObjectComponent component, URLBuilder ubu, Translator translator) {
if (QTI21Constants.HINT_REQUEST_IDENTIFIER.equals(interaction.getResponseIdentifier()) && component.isHideFeedbacks()) {
// don't show our hint's, they trigger feedbacks
return;
}
boolean ended = component.isItemSessionEnded(itemSessionState, renderer.isSolutionMode());
AssessmentObjectFormItem item = component.getQtiItem();
String responseUniqueId = component.getResponseUniqueIdentifier(itemSessionState, interaction);
String id = "qtiworks_response_".concat(responseUniqueId);
if (!ended) {
sb.append("<input name=\"qtiworks_presented_").append(responseUniqueId).append("\" type=\"hidden\" value=\"1\"/>");
}
FormItem endAttemptButton = item.getFormComponent(id);
if (endAttemptButton == null) {
String title = StringHelper.escapeHtml(interaction.getTitle());
FormLink button = FormUIFactory.getInstance().addFormLink(id, id, title, null, null, Link.BUTTON | Link.NONTRANSLATED);
// use specific icon for known types
if (interaction.getResponseIdentifier().equals(QTI21Constants.HINT_REQUEST_IDENTIFIER)) {
button.setIconLeftCSS("o_icon o_icon-fw o_icon_qti_hint");
button.setElementCssClass("o_sel_assessment_item_hint");
}
endAttemptButton = button;
endAttemptButton.setTranslator(translator);
endAttemptButton.setUserObject(interaction);
if (item.getRootForm() != endAttemptButton.getRootForm()) {
endAttemptButton.setRootForm(item.getRootForm());
}
item.addFormItem(endAttemptButton);
}
endAttemptButton.setEnabled(!ended);
endAttemptButton.getComponent().getHTMLRendererSingleton().render(renderer.getRenderer(), sb, endAttemptButton.getComponent(), ubu, translator, new RenderResult(), null);
}
use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class StepsMainRunController method initForm.
/*
* (non-Javadoc)
*
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
* org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
*/
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
formLayout.add("stepLinks", stepTitleLinks);
// steps/wizard navigation .. as start most of buttons are disabled
// they must be enabled by the first step according to its rules
// cancel button is not possible to disable
prevButton = new FormLinkImpl("back");
prevButton.setCustomEnabledLinkCSS("btn btn-default o_wizard_button_prev");
prevButton.setCustomDisabledLinkCSS("btn btn-default o_wizard_button_prev");
prevButton.setIconLeftCSS("o_icon o_icon_previous_step o_icon-fw");
nextButton = new FormLinkImpl("next");
nextButton.setCustomEnabledLinkCSS("btn btn-default o_wizard_button_next");
nextButton.setCustomDisabledLinkCSS("btn btn-default o_wizard_button_next");
nextButton.setIconRightCSS("o_icon o_icon_next_step o_icon-fw");
finishButton = new FormLinkImpl("finish");
finishButton.setCustomEnabledLinkCSS("btn btn-default o_wizard_button_finish");
finishButton.setCustomDisabledLinkCSS("btn btn-default o_wizard_button_finish");
cancelButton = new FormLinkImpl("cancel");
cancelButton.setCustomEnabledLinkCSS("btn btn-default o_wizard_button_cancel");
cancelButton.setCustomDisabledLinkCSS("btn btn-default o_wizard_button_cancel");
closeLink = new FormLinkImpl("closeIcon", "close", "", Link.NONTRANSLATED);
closeLink.setIconLeftCSS("o_icon o_icon_close");
formLayout.add(prevButton);
formLayout.add(nextButton);
formLayout.add(finishButton);
formLayout.add(cancelButton);
formLayout.add(closeLink);
// add all step titles, but disabled.
Step tmp = startStep;
do {
FormItem title = tmp.getStepTitle();
title.setEnabled(false);
stepTitleLinks.add(title);
tmp = tmp.nextStep();
} while (tmp != Step.NOSTEP);
// init buttons and the like
// start with -1 to be on zero after calling
currentStepIndex = -1;
// update current step index to velocity
flc.contextPut("currentStep", currentStepIndex + 1);
// next step the first time
addNextStep(startStep.getStepController(ureq, getWindowControl(), this.stepsContext, this.mainForm), startStep);
}
use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class SubmitDocumentsController method updateModel.
private void updateModel() {
File[] documents = documentsDir.listFiles(new SystemFileFilter(true, false));
List<SubmittedSolution> docList = new ArrayList<>(documents.length);
for (File document : documents) {
String filename = document.getName();
String uploadedBy = null;
VFSItem item = documentsContainer.resolve(filename);
if (item instanceof MetaTagged) {
MetaInfo metaInfo = ((MetaTagged) item).getMetaInfo();
if (metaInfo != null && metaInfo.getAuthorIdentityKey() != null) {
uploadedBy = userManager.getUserDisplayName(metaInfo.getAuthorIdentityKey());
}
}
FormItem download;
if (filename.endsWith(".html")) {
download = uifactory.addFormLink("view-" + CodeHelper.getRAMUniqueID(), "view", filename, null, flc, Link.LINK | Link.NONTRANSLATED);
download.setUserObject(filename);
} else {
download = uifactory.addDownloadLink("view-" + CodeHelper.getRAMUniqueID(), filename, null, document, tableEl);
}
docList.add(new SubmittedSolution(document, uploadedBy, download));
}
model.setObjects(docList);
tableEl.reset();
if (maxDocs > 0 && docList.size() >= maxDocs) {
if (uploadDocButton != null) {
uploadDocButton.setEnabled(false);
}
if (createDocButton != null) {
createDocButton.setEnabled(false);
}
String msg = translate("error.max.documents", new String[] { Integer.toString(maxDocs) });
flc.contextPut("maxDocsWarning", msg);
} else {
if (uploadDocButton != null) {
uploadDocButton.setEnabled(true);
}
if (createDocButton != null) {
createDocButton.setEnabled(true);
}
flc.contextPut("maxDocsWarning", Boolean.FALSE);
}
flc.contextPut("hasDocuments", Boolean.valueOf(hasUploadDocuments()));
}
use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class FlexiTableClassicRenderer method renderCell.
private void renderCell(Renderer renderer, StringOutput target, FlexiTableComponent ftC, FlexiColumnModel fcm, int row, URLBuilder ubu, Translator translator, RenderResult renderResult) {
FlexiTableElementImpl ftE = ftC.getFlexiTableElement();
FlexiTableDataModel<?> dataModel = ftE.getTableDataModel();
int alignment = fcm.getAlignment();
String cssClass = (alignment == FlexiColumnModel.ALIGNMENT_LEFT ? "text-left" : (alignment == FlexiColumnModel.ALIGNMENT_RIGHT ? "text-right" : "text-center"));
target.append("<td class=\"").append(cssClass).append(" ").append("o_dnd_label", ftE.getColumnIndexForDragAndDropLabel() == fcm.getColumnIndex()).append("\">");
int columnIndex = fcm.getColumnIndex();
Object cellValue = columnIndex >= 0 ? dataModel.getValueAt(row, columnIndex) : null;
if (cellValue instanceof FormItem) {
FormItem formItem = (FormItem) cellValue;
formItem.setTranslator(translator);
if (ftE.getRootForm() != formItem.getRootForm()) {
formItem.setRootForm(ftE.getRootForm());
}
ftE.addFormItem(formItem);
if (formItem.isVisible()) {
formItem.getComponent().getHTMLRendererSingleton().render(renderer, target, formItem.getComponent(), ubu, translator, renderResult, null);
}
} else if (cellValue instanceof Component) {
Component cmp = (Component) cellValue;
cmp.setTranslator(translator);
if (cmp.isVisible()) {
cmp.getHTMLRendererSingleton().render(renderer, target, cmp, ubu, translator, renderResult, null);
}
} else {
fcm.getCellRenderer().render(renderer, target, cellValue, row, ftC, ubu, translator);
}
target.append("</td>");
}
use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class FlexiTableComponent method getComponents.
@Override
public Iterable<Component> getComponents() {
List<Component> cmp = new ArrayList<Component>();
for (FormItem item : element.getFormItems()) {
cmp.add(item.getComponent());
}
cmp.addAll(components.values());
return cmp;
}
Aggregations