Search in sources :

Example 1 with QItemFactory

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());
}
Also used : QItemFactory(org.olat.modules.qpool.QItemFactory) QPoolSPI(org.olat.modules.qpool.QPoolSPI) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 2 with QItemFactory

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));
}
Also used : QItemFactory(org.olat.modules.qpool.QItemFactory) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) QItemCreationCmdEvent(org.olat.modules.qpool.ui.events.QItemCreationCmdEvent)

Example 3 with QItemFactory

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));
}
Also used : QItemFactory(org.olat.modules.qpool.QItemFactory) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) QItemCreationCmdEvent(org.olat.modules.qpool.ui.events.QItemCreationCmdEvent)

Example 4 with QItemFactory

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());
}
Also used : QItemFactory(org.olat.modules.qpool.QItemFactory) QPoolSPI(org.olat.modules.qpool.QPoolSPI) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Aggregations

QItemFactory (org.olat.modules.qpool.QItemFactory)4 ArrayList (java.util.ArrayList)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 QPoolSPI (org.olat.modules.qpool.QPoolSPI)2 QItemCreationCmdEvent (org.olat.modules.qpool.ui.events.QItemCreationCmdEvent)2 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)2