use of org.olat.modules.qpool.model.QuestionItemImpl in project openolat by klemens.
the class QuestionPoolServiceImpl method updateItem.
@Override
public QuestionItem updateItem(QuestionItem item) {
QuestionItem previousItem = loadItemById(item.getKey());
QuestionStatus previousStatus = previousItem != null ? previousItem.getQuestionStatus() : null;
QuestionStatus newStatus = item.getQuestionStatus();
if (statusChanged(previousStatus, newStatus)) {
if (item instanceof QuestionItemImpl) {
QuestionItemImpl itemImpl = (QuestionItemImpl) item;
itemImpl.setQuestionStatusLastModified(new Date());
}
if (reviewService.isReviewStarting(previousStatus, newStatus)) {
reviewService.startReview(item);
}
}
QuestionItem mergedItem = questionItemDao.merge(item);
dbInstance.commit();
lifeIndexer.indexDocument(QItemDocument.TYPE, mergedItem.getKey());
return mergedItem;
}
use of org.olat.modules.qpool.model.QuestionItemImpl in project openolat by klemens.
the class QuestionPoolServiceImpl method getRootLeaf.
@Override
public VFSLeaf getRootLeaf(QuestionItemShort item) {
QuestionItemImpl reloadedItem = questionItemDao.loadById(item.getKey());
if (reloadedItem == null) {
return null;
}
VFSContainer root = qpoolModule.getRootContainer();
VFSItem dir = root.resolve(reloadedItem.getDirectory());
if (dir instanceof VFSContainer) {
VFSContainer itemContainer = (VFSContainer) dir;
VFSItem rootLeaf = itemContainer.resolve(reloadedItem.getRootFilename());
if (rootLeaf instanceof VFSLeaf) {
return (VFSLeaf) rootLeaf;
}
}
return null;
}
use of org.olat.modules.qpool.model.QuestionItemImpl in project openolat by klemens.
the class QuestionPoolServiceImpl method deleteItems.
@Override
public void deleteItems(List<? extends QuestionItemShort> items) {
if (items == null || items.isEmpty()) {
// nothing to do
return;
}
List<SecurityGroup> secGroups = new ArrayList<>();
for (QuestionItemShort item : items) {
markManager.deleteMarks(item);
commentAndRatingService.deleteAllIgnoringSubPath(item);
licenseService.delete(item);
QuestionItem loadedItem = loadItemById(item.getKey());
if (loadedItem instanceof QuestionItemImpl) {
QuestionItemImpl itemImpl = (QuestionItemImpl) loadedItem;
qpoolFileStorage.deleteDir(itemImpl.getDirectory());
secGroups.add(itemImpl.getOwnerGroup());
}
dbInstance.intermediateCommit();
}
poolDao.removeFromPools(items);
questionItemDao.removeFromShares(items);
collectionDao.deleteItemFromCollections(items);
questionItemDao.delete(items);
// Delete SecurityGroup after the item to avoid foreign key constraint violation.
for (SecurityGroup secGroup : secGroups) {
securityManager.deleteSecurityGroup(secGroup);
}
for (QuestionItemShort item : items) {
lifeIndexer.deleteDocument(QItemDocument.TYPE, item.getKey());
}
// allow reload of data
dbInstance.getCurrentEntityManager().flush();
}
use of org.olat.modules.qpool.model.QuestionItemImpl in project openolat by klemens.
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 klemens.
the class QTIQPoolServiceProvider method createItem.
public QuestionItem createItem(Identity owner, QTI12ItemFactory.Type type, String title, Locale defaultLocale) {
Translator trans = Util.createPackageTranslator(QTIEditorMainController.class, defaultLocale);
Item item;
switch(type) {
case sc:
item = QTIEditHelper.createSCItem(trans);
break;
case mc:
item = QTIEditHelper.createMCItem(trans);
break;
case kprim:
item = QTIEditHelper.createKPRIMItem(trans);
break;
case fib:
item = QTIEditHelper.createFIBItem(trans);
break;
case essay:
item = QTIEditHelper.createEssayItem(trans);
break;
default:
return null;
}
item.setLabel(title);
item.setTitle(title);
QTIImportProcessor processor = new QTIImportProcessor(owner, defaultLocale);
Document doc = QTIEditHelper.itemToXml(item);
Element itemEl = (Element) doc.selectSingleNode("questestinterop/item");
QuestionItemImpl qitem = processor.processItem(itemEl, "", null, "OpenOLAT", Settings.getVersion(), null, null);
// save to file System
VFSContainer baseDir = qpoolFileStorage.getContainer(qitem.getDirectory());
VFSLeaf leaf = baseDir.createChildLeaf(qitem.getRootFilename());
QTIEditHelper.serialiazeDoc(doc, leaf);
return qitem;
}
Aggregations