use of org.olat.modules.qpool.model.QuestionItemImpl in project OpenOLAT by OpenOLAT.
the class ReviewStartController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormDescription("process.start.review.description", new String[] { item.getTitle() });
qpoolTaxonomyTreeBuilder.loadTaxonomyLevelsSelection(getIdentity(), false, ignoreCompetences);
taxonomyLevelEl = uifactory.addDropdownSingleselect("process.start.review.taxonomy.level", formLayout, qpoolTaxonomyTreeBuilder.getSelectableKeys(), qpoolTaxonomyTreeBuilder.getSelectableValues(), null);
taxonomyLevelEl.setMandatory(true);
if (item instanceof QuestionItemImpl) {
QuestionItemImpl itemImpl = (QuestionItemImpl) item;
TaxonomyLevel selectedTaxonomyLevel = itemImpl.getTaxonomyLevel();
if (selectedTaxonomyLevel != null) {
String selectedTaxonomyLevelKey = String.valueOf(selectedTaxonomyLevel.getKey());
for (String taxonomyKey : qpoolTaxonomyTreeBuilder.getSelectableKeys()) {
if (taxonomyKey.equals(selectedTaxonomyLevelKey)) {
taxonomyLevelEl.select(taxonomyKey, true);
}
}
}
}
FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add("buttons", buttonLayout);
uifactory.addFormSubmitButton("process.start.review.button", buttonLayout);
uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
}
use of org.olat.modules.qpool.model.QuestionItemImpl in project OpenOLAT by OpenOLAT.
the class TaxonomyLevelItemsSource method postImport.
@Override
public int postImport(List<QuestionItem> items, boolean editable) {
if (items == null || items.isEmpty())
return 0;
for (QuestionItemShort item : items) {
if (item instanceof QuestionItemImpl) {
QuestionItemImpl itemImpl = (QuestionItemImpl) item;
itemImpl.setTaxonomyLevel(taxonomyLevel);
}
}
qpoolService.index(items);
return items.size();
}
use of org.olat.modules.qpool.model.QuestionItemImpl in project OpenOLAT by OpenOLAT.
the class QItemQueriesDAOTest method shouldGetItemsIsManager.
@Test
public void shouldGetItemsIsManager() {
Taxonomy taxonomy = taxonomyDao.createTaxonomy("QPool", "QPool", "", null);
TaxonomyLevel taxonomyLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, null, null, taxonomy);
TaxonomyLevel taxonomySubLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, taxonomyLevel, null, taxonomy);
Identity ownerAndManager = createRandomIdentity();
taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.manage, taxonomyLevel, ownerAndManager, null);
Identity manager = createRandomIdentity();
taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.manage, taxonomyLevel, manager, null);
Identity noManager = createRandomIdentity();
QuestionItemImpl item11 = createRandomItem(ownerAndManager);
item11.setTaxonomyLevel(taxonomyLevel);
QuestionItemImpl item12 = createRandomItem(ownerAndManager);
item12.setTaxonomyLevel(taxonomySubLevel);
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(ownerAndManager, null);
List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(filterByKey(loadedItems, item11).isManager()).isTrue();
assertThat(filterByKey(loadedItems, item12).isManager()).isTrue();
params = new SearchQuestionItemParams(ownerAndManager, null);
loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(filterByKey(loadedItems, item11).isManager()).isTrue();
assertThat(filterByKey(loadedItems, item12).isManager()).isTrue();
params = new SearchQuestionItemParams(noManager, null);
loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(filterByKey(loadedItems, item11).isManager()).isFalse();
assertThat(filterByKey(loadedItems, item12).isManager()).isFalse();
}
use of org.olat.modules.qpool.model.QuestionItemImpl in project OpenOLAT by OpenOLAT.
the class QItemQueriesDAOTest method shouldGetItemsFilteredByWithoutTaxonomyLevel.
@Test
public void shouldGetItemsFilteredByWithoutTaxonomyLevel() {
Taxonomy taxonomy = taxonomyDao.createTaxonomy("QPool", "QPool", "", null);
TaxonomyLevel taxonomyLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, null, null, taxonomy);
TaxonomyLevel taxonomySubLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, taxonomyLevel, null, taxonomy);
TaxonomyLevel otherTaxonomyLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, null, null, taxonomy);
QuestionItemImpl item11 = createRandomItem(createRandomIdentity());
item11.setTaxonomyLevel(taxonomyLevel);
QuestionItemImpl item12 = createRandomItem(createRandomIdentity());
item12.setTaxonomyLevel(taxonomySubLevel);
QuestionItemImpl item21 = createRandomItem(createRandomIdentity());
item21.setTaxonomyLevel(otherTaxonomyLevel);
QuestionItem item22 = createRandomItem(createRandomIdentity());
QuestionItem item23 = createRandomItem(createRandomIdentity());
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(createRandomIdentity(), null);
params.setWithoutTaxonomyLevelOnly(true);
List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(loadedItems).hasSize(2);
assertThat(keysOf(loadedItems)).containsOnlyElementsOf(keysOf(item22, item23)).doesNotContainAnyElementsOf(keysOf(item11, item12, item21));
int countItems = qItemQueriesDao.countItems(params);
assertThat(countItems).isEqualTo(2);
}
use of org.olat.modules.qpool.model.QuestionItemImpl in project OpenOLAT by OpenOLAT.
the class QItemQueriesDAOTest method shouldGetItemsFilteredByLikeTaxonomyLevel.
@Test
public void shouldGetItemsFilteredByLikeTaxonomyLevel() {
Taxonomy taxonomy = taxonomyDao.createTaxonomy("QPool", "QPool", "", null);
TaxonomyLevel taxonomyLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, null, null, taxonomy);
TaxonomyLevel taxonomySubLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, taxonomyLevel, null, taxonomy);
TaxonomyLevel otherTaxonomyLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, null, null, taxonomy);
QuestionItemImpl item11 = createRandomItem(createRandomIdentity());
item11.setTaxonomyLevel(taxonomyLevel);
QuestionItemImpl item12 = createRandomItem(createRandomIdentity());
item12.setTaxonomyLevel(taxonomySubLevel);
QuestionItemImpl item21 = createRandomItem(createRandomIdentity());
item21.setTaxonomyLevel(otherTaxonomyLevel);
QuestionItem item22 = createRandomItem(createRandomIdentity());
QuestionItem item23 = createRandomItem(createRandomIdentity());
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(createRandomIdentity(), null);
params.setLikeTaxonomyLevel(taxonomyLevel);
List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(loadedItems).hasSize(2);
assertThat(keysOf(loadedItems)).containsOnlyElementsOf(keysOf(item11, item12)).doesNotContainAnyElementsOf(keysOf(item21, item22, item23));
int countItems = qItemQueriesDao.countItems(params);
assertThat(countItems).isEqualTo(2);
}
Aggregations