use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.
the class LTIRunController method doAskDataExchange.
/**
* Helper to initialize the ask-for-data-exchange screen
*/
private void doAskDataExchange() {
VelocityContainer acceptPage = createVelocityContainer("accept");
acceptPage.contextPut("userData", userData);
acceptPage.contextPut("customUserData", customUserData);
acceptLink = LinkFactory.createButton("accept", acceptPage, this);
acceptLink.setPrimary(true);
mainPanel.setContent(acceptPage);
}
use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.
the class Card2BrainRunController method runCard2Brain.
private void runCard2Brain(UserRequest ureq) {
VelocityContainer container = createVelocityContainer("run");
String url = String.format(card2BrainModule.getBaseUrl(), config.getStringValue(Card2BrainCourseNode.CONFIG_FLASHCARD_ALIAS));
String oauth_consumer_key;
String oauth_secret;
if (config.getBooleanSafe(Card2BrainCourseNode.CONFIG_ENABLE_PRIVATE_LOGIN)) {
oauth_consumer_key = (String) config.get(Card2BrainCourseNode.CONFIG_PRIVATE_KEY);
oauth_secret = (String) config.get(Card2BrainCourseNode.CONFIG_PRIVATE_SECRET);
} else {
oauth_consumer_key = card2BrainModule.getEnterpriseKey();
oauth_secret = card2BrainModule.getEnterpriseSecret();
}
LTIContext context = new Card2BrainContext();
Map<String, String> unsignedProps = ltiManager.forgeLTIProperties(getIdentity(), getLocale(), context, true, true, false);
Mapper contentMapper = new PostDataMapper(unsignedProps, url, oauth_consumer_key, oauth_secret, false);
String mapperUri = registerMapper(ureq, contentMapper);
container.contextPut("mapperUri", mapperUri + "/");
JSAndCSSComponent js = new JSAndCSSComponent("js", new String[] { "js/iframeResizer/iframeResizer.min.js" }, null);
container.put("js", js);
main.setContent(container);
}
use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.
the class AbstractItemListController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// add the table
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("quickview", "<i class='o_icon o_icon_quickview'> </i>", "quick-view"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.mark.i18nKey(), Cols.mark.ordinal(), true, OrderBy.marks.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.editable.i18nKey(), Cols.editable.ordinal(), false, null, FlexiColumnModel.ALIGNMENT_LEFT, new BooleanCellRenderer(new CSSIconFlexiCellRenderer(CSS_ICON_READWRITE), new CSSIconFlexiCellRenderer(CSS_ICON_READONLY))));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.key.i18nKey(), Cols.key.ordinal(), true, OrderBy.key.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.identifier.i18nKey(), Cols.identifier.ordinal(), true, OrderBy.identifier.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.title.i18nKey(), Cols.title.ordinal(), true, OrderBy.title.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.topic.i18nKey(), Cols.topic.ordinal(), true, OrderBy.topic.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.creationDate.i18nKey(), Cols.creationDate.ordinal(), true, OrderBy.creationDate.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.lastModified.i18nKey(), Cols.lastModified.ordinal(), true, OrderBy.lastModified.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.keywords.i18nKey(), Cols.keywords.ordinal(), true, OrderBy.keywords.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.coverage.i18nKey(), Cols.coverage.ordinal(), true, OrderBy.coverage.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.additionalInfos.i18nKey(), Cols.additionalInfos.ordinal(), true, OrderBy.additionalInformations.name()));
if (getSecurityCallback().canUseTaxonomy()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.taxnonomyLevel.i18nKey(), Cols.taxnonomyLevel.ordinal(), true, OrderBy.taxonomyLevel.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.taxnonomyPath.i18nKey(), Cols.taxnonomyPath.ordinal(), true, OrderBy.taxonomyPath.name()));
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.difficulty.i18nKey(), Cols.difficulty.ordinal(), true, OrderBy.difficulty.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.stdevDifficulty.i18nKey(), Cols.stdevDifficulty.ordinal(), true, OrderBy.stdevDifficulty.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.differentiation.i18nKey(), Cols.differentiation.ordinal(), true, OrderBy.differentiation.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.numOfAnswerAlternatives.i18nKey(), Cols.numOfAnswerAlternatives.ordinal(), true, OrderBy.numOfAnswerAlternatives.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.usage.i18nKey(), Cols.usage.ordinal(), true, OrderBy.usage.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.type.i18nKey(), Cols.type.ordinal(), true, OrderBy.itemType.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.format.i18nKey(), Cols.format.ordinal(), true, OrderBy.format.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.rating.i18nKey(), Cols.rating.ordinal(), true, OrderBy.rating.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.numberOfRatings.i18nKey(), Cols.numberOfRatings.ordinal(), true, OrderBy.numberOfRatings.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.itemVersion.i18nKey(), Cols.itemVersion.ordinal(), true, OrderBy.itemVersion.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.status.i18nKey(), Cols.status.ordinal(), true, OrderBy.status.name(), new QuestionStatusCellRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.statusLastModified.i18nKey(), Cols.statusLastModified.ordinal(), true, OrderBy.statusLastModified.name()));
if (licenseModule.isEnabled(licenseHandler)) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, false, Cols.license.i18nKey(), Cols.license.ordinal(), "license", false, null, FlexiColumnModel.ALIGNMENT_LEFT, new StaticFlexiCellRenderer("license", new LicenseRenderer(getLocale()))));
}
initActionColumns(columnsModel);
model = new QuestionItemDataModel(columnsModel, this, getTranslator());
itemsTable = uifactory.addTableElement(getWindowControl(), "items", model, 50, false, getTranslator(), formLayout);
itemsTable.setWrapperSelector("qitems");
itemsTable.setSelectAllEnable(true);
itemsTable.setMultiSelect(true);
itemsTable.setSearchEnabled(true);
itemsTable.setSortSettings(new FlexiTableSortOptions(true));
itemsTable.setExtendedSearch(extendedSearchCtrl);
itemsTable.setColumnIndexForDragAndDropLabel(Cols.title.ordinal());
itemsTable.setAndLoadPersistedPreferences(ureq, "qpool-list-" + prefsKey);
listenTo(extendedSearchCtrl);
VelocityContainer detailsVC = createVelocityContainer("item_list_details");
itemsTable.setDetailsRenderer(detailsVC, this);
FlexiTableSortOptions sortOptions = new FlexiTableSortOptions();
sortOptions.setDefaultOrderBy(new SortKey(OrderBy.title.name(), true));
itemsTable.setSortSettings(sortOptions);
initButtons(ureq, formLayout);
itemsTable.reloadData();
}
use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.
the class RepositoryEntryListController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (withSearch) {
setFormDescription("table.search.mycourses.desc");
searchCtrl = new RepositoryEntrySearchController(ureq, getWindowControl(), true, mainForm);
searchCtrl.setEnabled(false);
listenTo(searchCtrl);
}
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.key.i18nKey(), Cols.key.ordinal(), true, OrderBy.key.name()));
if (!guestOnly) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.mark.i18nKey(), Cols.mark.ordinal(), true, OrderBy.favorit.name()));
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.displayName.i18nKey(), Cols.select.ordinal(), true, OrderBy.displayname.name()));
if (repositoryModule.isManagedRepositoryEntries()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.externalId.i18nKey(), Cols.externalId.ordinal(), true, OrderBy.externalId.name()));
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.externalRef.i18nKey(), Cols.externalRef.ordinal(), true, OrderBy.externalRef.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.lifecycleLabel.i18nKey(), Cols.lifecycleLabel.ordinal(), true, OrderBy.lifecycleLabel.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.lifecycleSoftkey.i18nKey(), Cols.lifecycleSoftkey.ordinal(), true, OrderBy.lifecycleSoftkey.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.lifecycleStart.i18nKey(), Cols.lifecycleStart.ordinal(), true, OrderBy.lifecycleStart.name(), FlexiColumnModel.ALIGNMENT_LEFT, new DateFlexiCellRenderer(getLocale())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.lifecycleEnd.i18nKey(), Cols.lifecycleEnd.ordinal(), true, OrderBy.lifecycleEnd.name(), FlexiColumnModel.ALIGNMENT_LEFT, new DateFlexiCellRenderer(getLocale())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.location.i18nKey(), Cols.location.ordinal(), true, OrderBy.location.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.details.i18nKey(), Cols.details.ordinal(), false, null));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.start.i18nKey(), Cols.start.ordinal()));
if (repositoryModule.isRatingEnabled()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.ratings.i18nKey(), Cols.ratings.ordinal(), true, OrderBy.rating.name()));
}
if (repositoryModule.isCommentEnabled()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.comments.i18nKey(), Cols.comments.ordinal()));
}
model = new RepositoryEntryDataModel(dataSource, columnsModel);
tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout);
tableEl.setAvailableRendererTypes(FlexiTableRendererType.custom, FlexiTableRendererType.classic);
tableEl.setRendererType(FlexiTableRendererType.custom);
tableEl.setSearchEnabled(withSearch);
tableEl.setExtendedSearch(searchCtrl);
tableEl.setCustomizeColumns(true);
tableEl.setElementCssClass("o_coursetable");
tableEl.setEmtpyTableMessageKey("table.sEmptyTable");
VelocityContainer row = createVelocityContainer("row_1");
// sets its own DOM id in velocity container
row.setDomReplacementWrapperRequired(false);
tableEl.setRowRenderer(row, this);
initFilters(tableEl);
initSorters(tableEl);
tableEl.setAndLoadPersistedPreferences(ureq, "re-list-" + name);
}
use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.
the class QTIEditorMainController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component,
* org.olat.core.gui.control.Event)
*/
public void event(UserRequest ureq, Component source, Event event) {
//
if (source == menuTree) {
// catch menu tree clicks
if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
GenericQtiNode clickedNode;
clickedNode = menuTreeModel.getQtiNode(menuTree.getSelectedNodeId());
Component tabbedPane = clickedNode.createEditTabbedPane(ureq, getWindowControl(), getTranslator(), this);
if (tabbedPane != null) {
main.put("tabbedPane", tabbedPane);
} else {
VelocityContainer itemNotEditable = createVelocityContainer("tab_itemAlien");
main.put("tabbedPane", itemNotEditable);
return;
}
// only available in full edit mode
if (clickedNode instanceof AssessmentNode) {
deleteLink.setEnabled(false);
moveLink.setEnabled(false);
copyLink.setEnabled(false);
stackedPanel.setDirty(true);
} else {
deleteLink.setEnabled(true && !restrictedEdit);
moveLink.setEnabled(true && !restrictedEdit);
if (clickedNode instanceof ItemNode) {
copyLink.setEnabled(true && !restrictedEdit);
} else {
copyLink.setEnabled(false);
}
stackedPanel.setDirty(true);
}
}
} else if (source == exitVC) {
if (CMD_EXIT_SAVE.equals(event.getCommand())) {
if (isRestrictedEdit() && history.size() > 0) {
// changes were recorded
// start work flow:
// -sending an e-mail to everybody being a stake holder of this qti
// resource
// -email with change message
// -after sending email successfully -> saveNexit is called.
chngMsgFormVC = createVelocityContainer("changeMsgForm");
// FIXME:pb:a Bitte diesen Velocity container entfernen und statt
// dessen den
// ContentOnlyController verwenden. Es ist äusserst wichtig dass das
// Layout nie selber gemacht
// wird sondern immer die Layout controller verwendet werden, d.h. den
// ContentOnlyController oder
// den MenuAndToolController. Dort kann das Tool übrigens auch null
// sein wenn man nur ein Menü braucht.
// TODO:pb:a extend ContentOnlyController to work also if menu and
// tool are null, hence only content is desired
String userN = UserManager.getInstance().getUserDisplayEmail(ureq.getIdentity(), ureq.getLocale());
String lastN = ureq.getIdentity().getUser().getProperty(UserConstants.LASTNAME, ureq.getLocale());
String firstN = ureq.getIdentity().getUser().getProperty(UserConstants.FIRSTNAME, ureq.getLocale());
String changeMsg = "Changed by: " + firstN + " " + lastN + " [" + userN + "]\n";
changeMsg += createChangeMessage();
changeEmail.setBodyText(changeMsg);
chngMsgFormVC.contextPut("chngMsg", changeEmail.getBodyText());
removeAsListenerAndDispose(chngMsgFrom);
chngMsgFrom = new ChangeMessageForm(ureq, getWindowControl());
listenTo(chngMsgFrom);
chngMsgFormVC.put("chngMsgForm", chngMsgFrom.getInitialComponent());
exitPanel.setContent(chngMsgFormVC);
return;
} else {
// remove modal dialog and proceed with exit process
cmcExit.deactivate();
removeAsListenerAndDispose(cmcExit);
cmcExit = null;
// remove lock, clean tmp dir, fire done event to close editor
saveAndExit(ureq);
}
} else if (CMD_EXIT_DISCARD.equals(event.getCommand())) {
// remove modal dialog and proceed with exit process
cmcExit.deactivate();
removeAsListenerAndDispose(cmcExit);
cmcExit = null;
// cleanup, so package does not get resumed
qtiPackage.cleanupTmpPackageDir();
// remove lock
removeLocksAndExit(ureq);
} else if (CMD_EXIT_CANCEL.equals(event.getCommand())) {
// remove modal dialog and go back to edit mode
cmcExit.deactivate();
removeAsListenerAndDispose(cmcExit);
cmcExit = null;
}
} else if (source == notEditableButton) {
// close editor
fireEvent(ureq, Event.DONE_EVENT);
} else if (closeLink == source) {
// exitVC hook:
// save package back to repository
exitVC = createVelocityContainer("exitDialog");
exitPanel = new Panel("exitPanel");
exitPanel.setContent(exitVC);
cmcExit = new CloseableModalController(getWindowControl(), translate("editor.preview.close"), exitPanel, true, translate("exit.header"));
cmcExit.activate();
listenTo(cmcExit);
return;
} else if (previewLink == source) {
// preview
previewController = CoreSpringFactory.getImpl(IQManager.class).createIQDisplayController(new QTIEditorResolver(qtiPackage), qtiPackage.getQTIDocument().isSurvey() ? AssessmentInstance.QMD_ENTRY_TYPE_SURVEY : AssessmentInstance.QMD_ENTRY_TYPE_SELF, new IQPreviewSecurityCallback(), ureq, getWindowControl());
if (previewController.isReady()) {
// in case previewController was unable to initialize, a message was
// set by displayController
// this is the case if no more attempts or security check was
// unsuccessfull
previewController.addControllerListener(this);
cmcPrieview = new CloseableModalController(getWindowControl(), translate("editor.preview.close"), previewController.getInitialComponent());
cmcPrieview.activate();
listenTo(cmcPrieview);
} else {
getWindowControl().setWarning(translate("error.preview"));
}
} else if (deleteLink == source) {
// multi return in Firefox
if (deleteDialog != null)
return;
GenericQtiNode clickedNode = menuTreeModel.getQtiNode(menuTree.getSelectedNodeId());
String msg = "";
if (clickedNode instanceof SectionNode) {
if (QTIEditHelper.countSections(qtiPackage.getQTIDocument().getAssessment()) == 1) {
// At least one section
getWindowControl().setError(translate("error.atleastonesection"));
return;
}
msg = translate("delete.section", clickedNode.getTitle());
} else if (clickedNode instanceof ItemNode) {
if (((SectionNode) clickedNode.getParent()).getChildCount() == 1) {
// At least one item
getWindowControl().setError(translate("error.atleastoneitem"));
return;
}
msg = translate("delete.item", clickedNode.getTitle());
}
deleteDialog = activateYesNoDialog(ureq, null, msg, deleteDialog);
deleteDialog.setUserObject(clickedNode);
return;
} else if (moveLink == source) {
// cannot move the last item
GenericQtiNode clickedNode = menuTreeModel.getQtiNode(menuTree.getSelectedNodeId());
if (clickedNode instanceof ItemNode && ((SectionNode) clickedNode.getParent()).getChildCount() == 1) {
getWindowControl().setError(translate("error.move.atleastoneitem"));
} else {
TreeNode selectedNode = menuTree.getSelectedNode();
int type = (selectedNode instanceof SectionNode) ? InsertItemTreeModel.INSTANCE_ASSESSMENT : InsertItemTreeModel.INSTANCE_SECTION;
InsertItemTreeModel treeModel = new InsertItemTreeModel(menuTreeModel, selectedNode, type);
moveCtrl = new InsertNodeController(ureq, getWindowControl(), treeModel);
listenTo(moveCtrl);
cmc = new CloseableModalController(getWindowControl(), "close", moveCtrl.getInitialComponent(), true, translate("title.move"));
cmc.activate();
listenTo(cmc);
}
} else if (copyLink == source) {
InsertItemTreeModel treeModel = new InsertItemTreeModel(menuTreeModel, menuTree.getSelectedNode(), InsertItemTreeModel.INSTANCE_SECTION);
copyCtrl = new InsertNodeController(ureq, getWindowControl(), treeModel);
listenTo(copyCtrl);
cmc = new CloseableModalController(getWindowControl(), "close", copyCtrl.getInitialComponent(), true, translate("title.copy"));
cmc.activate();
listenTo(cmc);
} else if (addPoolLink == source) {
doSelectQItem(ureq);
} else if (exportPoolLink == source) {
doExportQItem();
} else if (exportDocLink == source) {
doExportDocx(ureq);
} else if (convertQTI21Link == source) {
doConvertToQTI21(ureq);
} else if (importTableLink == source) {
doImportTable(ureq);
} else if (addSectionLink == source) {
Section newSection = QTIEditHelper.createSection(getTranslator());
Item newItem = QTIEditHelper.createSCItem(getTranslator());
newSection.getItems().add(newItem);
SectionNode scNode = new SectionNode(newSection, qtiPackage);
ItemNode itemNode = new ItemNode(newItem, qtiPackage);
scNode.addChild(itemNode);
doSelectInsertionPoint(ureq, CMD_TOOLS_ADD_SECTION, scNode);
} else if (addSCLink == source) {
ItemNode insertObject = new ItemNode(QTIEditHelper.createSCItem(getTranslator()), qtiPackage);
doSelectInsertionPoint(ureq, CMD_TOOLS_ADD_SINGLECHOICE, insertObject);
} else if (addMCLink == source) {
ItemNode insertObject = new ItemNode(QTIEditHelper.createMCItem(getTranslator()), qtiPackage);
doSelectInsertionPoint(ureq, CMD_TOOLS_ADD_MULTIPLECHOICE, insertObject);
} else if (addKPrimLink == source) {
ItemNode insertObject = new ItemNode(QTIEditHelper.createKPRIMItem(getTranslator()), qtiPackage);
doSelectInsertionPoint(ureq, CMD_TOOLS_ADD_KPRIM, insertObject);
} else if (addFIBLink == source) {
ItemNode insertObject = new ItemNode(QTIEditHelper.createFIBItem(getTranslator()), qtiPackage);
doSelectInsertionPoint(ureq, CMD_TOOLS_ADD_FIB, insertObject);
} else if (addEssayLink == source) {
ItemNode insertObject = new ItemNode(QTIEditHelper.createEssayItem(getTranslator()), qtiPackage);
doSelectInsertionPoint(ureq, CMD_TOOLS_ADD_FREETEXT, insertObject);
}
}
Aggregations