use of org.olat.modules.qpool.QuestionItem in project OpenOLAT by OpenOLAT.
the class QuestionListController method doCreateNewItem.
private void doCreateNewItem(UserRequest ureq, String title, TaxonomyLevel taxonomyLevel, QItemFactory factory) {
QuestionItem item = factory.createItem(getIdentity(), title, getLocale());
List<QuestionItem> newItems = Collections.singletonList(item);
getSource().postImport(newItems, false);
if (taxonomyLevel != null && item instanceof QuestionItemImpl) {
QuestionItemImpl itemImpl = (QuestionItemImpl) item;
itemImpl.setTaxonomyLevel(taxonomyLevel);
qpoolService.updateItem(itemImpl);
}
if (licenseModule.isEnabled(licenseHandler)) {
// The QItemFactory may create a no license as part of the import process.
// But for new question items the default license should be created.
// So delete the no license first, so that the default license can be created.
licenseService.delete(item);
licenseService.createDefaultLicense(item, licenseHandler, getIdentity());
}
getItemsTable().reset();
dbInstance.commit();
qpoolService.index(newItems);
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_NEW);
builder.withAfter(item);
qpoolService.persist(builder.create());
QPoolEvent qce = new QPoolEvent(QPoolEvent.ITEM_CREATED);
fireEvent(ureq, qce);
doOpenDetails(ureq, item);
}
use of org.olat.modules.qpool.QuestionItem in project OpenOLAT by OpenOLAT.
the class AbstractItemListController method getIndex.
public List<Integer> getIndex(Collection<QuestionItem> items) {
Set<Long> itemKeys = new HashSet<>();
for (QuestionItem item : items) {
itemKeys.add(item.getKey());
}
List<Integer> index = new ArrayList<>(items.size());
for (int i = model.getObjects().size(); i-- > 0; ) {
ItemRow row = model.getObject(i);
if (row != null && itemKeys.contains(row.getKey())) {
index.add(i);
}
}
return index;
}
use of org.olat.modules.qpool.QuestionItem in project OpenOLAT by OpenOLAT.
the class AbstractItemListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == itemsTable) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
if ("rSelect".equals(se.getCommand())) {
ItemRow row = model.getObject(se.getIndex());
if (row != null) {
doClick(ureq, row);
}
} else if ("select-item".equals(se.getCommand())) {
ItemRow row = getModel().getObject(se.getIndex());
if (row != null) {
doSelect(ureq, row);
}
} else if ("quick-view".equals(se.getCommand())) {
int rowIndex = se.getIndex();
if (rowIndex >= 0) {
if (itemsTable.isDetailsExpended(rowIndex)) {
itemsTable.collapseDetails(rowIndex);
} else {
itemsTable.collapseAllDetails();
ItemRow row = getModel().getObject(rowIndex);
if (row != null) {
itemsTable.expandDetails(rowIndex);
QuestionItem item = qpoolService.loadItemById(row.getKey());
previewCtrl.updateItem(ureq, item);
quickViewMetadataCtrl.setItem(ureq, item);
}
}
}
}
}
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
if ("select".equals(link.getCmd())) {
ItemRow row = (ItemRow) link.getUserObject();
doSelect(ureq, row);
} else if ("mark".equals(link.getCmd())) {
ItemRow row = (ItemRow) link.getUserObject();
if (doMark(row)) {
link.setIconLeftCSS(Mark.MARK_CSS_LARGE);
} else {
link.setIconLeftCSS(Mark.MARK_ADD_CSS_LARGE);
}
link.getComponent().setDirty(true);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.modules.qpool.QuestionItem in project OpenOLAT by OpenOLAT.
the class CopyConfirmationController method logAudit.
private void logAudit(List<QuestionItem> items) {
for (QuestionItem item : items) {
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_BY_COPY);
builder.withAfter(item);
qpoolService.persist(builder.create());
}
}
use of org.olat.modules.qpool.QuestionItem in project OpenOLAT by OpenOLAT.
the class QuestionPoolMainEditorController method activateQuestionItem.
private void activateQuestionItem(UserRequest ureq, Long itemKey, List<ContextEntry> entries) {
QuestionItem item = qpoolService.loadItemById(itemKey);
if (item == null)
return;
List<Identity> authors = qpoolService.getAuthors(item);
if (authors.contains(getIdentity())) {
activateNode(ureq, treeModel.getMyQuestionsNode(), entries);
return;
}
if (item.getTaxonomyLevel() != null && item.getQuestionStatus() != null && QuestionStatus.finalVersion.equals(item.getQuestionStatus()) && treeModel.getFinalNode() != null) {
TreeNode levelNode = treeModel.getFinalTanonomyLevelNode(item.getTaxonomyLevel());
if (levelNode != null) {
activateNode(ureq, levelNode, entries);
return;
}
}
if (treeModel.getSharesNode() != null) {
List<QuestionItem2Resource> shares = qpoolService.getSharedResourceInfosByItem(item);
for (QuestionItem2Resource share : shares) {
TreeNode levelNode = treeModel.getShareNode(share);
if (levelNode != null) {
activateNode(ureq, levelNode, entries);
return;
}
}
List<QuestionItem2Pool> pools = qpoolService.getPoolInfosByItem(item);
for (QuestionItem2Pool pool : pools) {
TreeNode levelNode = treeModel.getShareNode(pool);
if (levelNode != null) {
activateNode(ureq, levelNode, entries);
return;
}
}
}
}
Aggregations