use of org.olat.modules.qpool.QItemFactory in project OpenOLAT by OpenOLAT.
the class NewItemOptionsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// title
titleEl = uifactory.addTextElement("general.title", "general.title", 128, "", formLayout);
// type
List<QItemFactory> factories = new ArrayList<>();
for (QPoolSPI spi : qpoolModule.getQuestionPoolProviders()) {
for (QItemFactory factory : spi.getItemfactories()) {
factories.add(factory);
}
}
int count = 0;
String[] typeKeys = new String[factories.size()];
String[] valueKeys = new String[factories.size()];
for (QItemFactory factory : factories) {
String typeKey = "item.type." + count;
typeKeys[count] = typeKey;
keyToFactoryMap.put(typeKey, factory);
valueKeys[count] = factory.getLabel(getLocale());
count++;
}
typeEl = uifactory.addDropdownSingleselect("question.type", "menu.admin.types", formLayout, typeKeys, valueKeys, null);
// subject
taxonomyLevelEl = uifactory.addDropdownSingleselect("process.start.review.taxonomy.level", formLayout, qpoolTaxonomyTreeBuilder.getSelectableKeys(), qpoolTaxonomyTreeBuilder.getSelectableValues(), null);
if (selectedTaxonomyLevel != null) {
String selectedTaxonomyLevelKey = String.valueOf(selectedTaxonomyLevel.getKey());
for (String taxonomyKey : qpoolTaxonomyTreeBuilder.getSelectableKeys()) {
if (taxonomyKey.equals(selectedTaxonomyLevelKey)) {
taxonomyLevelEl.select(taxonomyKey, true);
}
}
}
taxonomyLevelEl.setVisible(qPoolSecurityCallback.canUseTaxonomy());
FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonLayout.setRootForm(mainForm);
formLayout.add(buttonLayout);
uifactory.addFormSubmitButton("new.item", buttonLayout);
uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
}
use of org.olat.modules.qpool.QItemFactory in project OpenOLAT by OpenOLAT.
the class NewItemOptionsController method formOK.
@Override
protected void formOK(UserRequest ureq) {
String typeKey = typeEl.getSelectedKey();
QItemFactory factory = keyToFactoryMap.get(typeKey);
String title = titleEl.getValue();
TaxonomyLevel taxonomyLevel = null;
if (taxonomyLevelEl.isOneSelected()) {
String selectedKey = taxonomyLevelEl.getSelectedKey();
taxonomyLevel = qpoolTaxonomyTreeBuilder.getTaxonomyLevel(selectedKey);
}
fireEvent(ureq, new QItemCreationCmdEvent(title, taxonomyLevel, factory));
}
use of org.olat.modules.qpool.QItemFactory in project openolat by klemens.
the class NewItemOptionsController method formOK.
@Override
protected void formOK(UserRequest ureq) {
String typeKey = typeEl.getSelectedKey();
QItemFactory factory = keyToFactoryMap.get(typeKey);
String title = titleEl.getValue();
TaxonomyLevel taxonomyLevel = null;
if (taxonomyLevelEl.isOneSelected()) {
String selectedKey = taxonomyLevelEl.getSelectedKey();
taxonomyLevel = qpoolTaxonomyTreeBuilder.getTaxonomyLevel(selectedKey);
}
fireEvent(ureq, new QItemCreationCmdEvent(title, taxonomyLevel, factory));
}
use of org.olat.modules.qpool.QItemFactory in project openolat by klemens.
the class NewItemOptionsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// title
titleEl = uifactory.addTextElement("general.title", "general.title", 128, "", formLayout);
// type
List<QItemFactory> factories = new ArrayList<>();
for (QPoolSPI spi : qpoolModule.getQuestionPoolProviders()) {
for (QItemFactory factory : spi.getItemfactories()) {
factories.add(factory);
}
}
int count = 0;
String[] typeKeys = new String[factories.size()];
String[] valueKeys = new String[factories.size()];
for (QItemFactory factory : factories) {
String typeKey = "item.type." + count;
typeKeys[count] = typeKey;
keyToFactoryMap.put(typeKey, factory);
valueKeys[count] = factory.getLabel(getLocale());
count++;
}
typeEl = uifactory.addDropdownSingleselect("question.type", "menu.admin.types", formLayout, typeKeys, valueKeys, null);
// subject
taxonomyLevelEl = uifactory.addDropdownSingleselect("process.start.review.taxonomy.level", formLayout, qpoolTaxonomyTreeBuilder.getSelectableKeys(), qpoolTaxonomyTreeBuilder.getSelectableValues(), null);
if (selectedTaxonomyLevel != null) {
String selectedTaxonomyLevelKey = String.valueOf(selectedTaxonomyLevel.getKey());
for (String taxonomyKey : qpoolTaxonomyTreeBuilder.getSelectableKeys()) {
if (taxonomyKey.equals(selectedTaxonomyLevelKey)) {
taxonomyLevelEl.select(taxonomyKey, true);
}
}
}
taxonomyLevelEl.setVisible(qPoolSecurityCallback.canUseTaxonomy());
FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonLayout.setRootForm(mainForm);
formLayout.add(buttonLayout);
uifactory.addFormSubmitButton("new.item", buttonLayout);
uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
}
Aggregations