use of org.olat.modules.qpool.model.QuestionItemImpl in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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 OpenOLAT.
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 OpenOLAT.
the class QuestionItemDAO method createAndPersist.
public QuestionItemImpl createAndPersist(Identity owner, String title, String format, String language, TaxonomyLevel taxonLevel, String dir, String rootFilename, QItemType type) {
QuestionItemImpl item = create(title, format, dir, rootFilename);
if (type != null) {
item.setType(type);
}
item.setLanguage(language);
item.setTaxonomyLevel(taxonLevel);
persist(owner, item);
return item;
}
use of org.olat.modules.qpool.model.QuestionItemImpl in project OpenOLAT by OpenOLAT.
the class QuestionItemDAO method copy.
/**
* The method make a copy of the original question. The copy is not persisted.
*
* @param original
* @return A copy of the question.
*/
public QuestionItemImpl copy(QuestionItemImpl original) {
String title = "(Copy) " + original.getTitle();
QuestionItemImpl copy = create(title, original.getFormat(), null, original.getRootFilename());
// general
copy.setMasterIdentifier(original.getIdentifier());
copy.setDescription(original.getDescription());
copy.setKeywords(original.getKeywords());
copy.setCoverage(original.getCoverage());
copy.setAdditionalInformations(original.getAdditionalInformations());
copy.setLanguage(original.getLanguage());
// classification
copy.setTaxonomyLevel(original.getTaxonomyLevel());
copy.setTopic(original.getTopic());
// educational
copy.setEducationalContext(original.getEducationalContext());
copy.setEducationalLearningTime(original.getEducationalLearningTime());
// item
copy.setType(original.getType());
copy.setDifficulty(original.getDifficulty());
copy.setStdevDifficulty(original.getStdevDifficulty());
copy.setDifferentiation(original.getDifferentiation());
copy.setNumOfAnswerAlternatives(original.getNumOfAnswerAlternatives());
copy.setUsage(0);
copy.setAssessmentType(original.getAssessmentType());
// lifecycle
copy.setItemVersion(original.getItemVersion());
copy.setStatus(QuestionStatus.draft.name());
// technical
copy.setEditor(original.getEditor());
copy.setEditorVersion(original.getEditorVersion());
return copy;
}
Aggregations