use of org.olat.modules.qpool.model.QuestionItemImpl in project OpenOLAT by OpenOLAT.
the class GeneralMetadataEditController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (item instanceof QuestionItemImpl) {
QuestionItemImpl itemImpl = (QuestionItemImpl) item;
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.UPDATE_QUESTION_ITEM_METADATA);
builder.withBefore(itemImpl);
itemImpl.setTopic(topicEl.getValue());
if (taxonomyLevelEl.isOneSelected()) {
String selectedKey = taxonomyLevelEl.getSelectedKey();
TaxonomyLevel taxonomyLevel = qpoolTaxonomyTreeBuilder.getTaxonomyLevel(selectedKey);
itemImpl.setTaxonomyLevel(taxonomyLevel);
} else {
itemImpl.setTaxonomyLevel(null);
}
QEducationalContext context = contextEl.isOneSelected() ? qpoolService.getEducationlContextByLevel(contextEl.getSelectedKey()) : null;
itemImpl.setEducationalContext(context);
if (StringHelper.containsNonWhitespace(keywordsEl.getValue())) {
itemImpl.setKeywords(keywordsEl.getValue());
} else {
itemImpl.setKeywords("");
}
if (StringHelper.containsNonWhitespace(coverageEl.getValue())) {
itemImpl.setCoverage(coverageEl.getValue());
} else {
itemImpl.setCoverage("");
}
if (StringHelper.containsNonWhitespace(addInfosEl.getValue())) {
itemImpl.setAdditionalInformations(addInfosEl.getValue());
} else {
itemImpl.setAdditionalInformations(null);
}
itemImpl.setLanguage(languageEl.getValue());
String assessmentType = assessmentTypeEl.isOneSelected() ? assessmentTypeEl.getSelectedKey() : null;
itemImpl.setAssessmentType(assessmentType);
item = qpoolService.updateItem(item);
builder.withAfter(itemImpl);
qpoolService.persist(builder.create());
fireEvent(ureq, new QItemEdited(item));
}
}
use of org.olat.modules.qpool.model.QuestionItemImpl in project OpenOLAT by OpenOLAT.
the class MetadataBulkChangeController method formOK.
@Override
protected void formOK(UserRequest ureq) {
updatedItems = new ArrayList<>();
for (QuestionItemShort item : items) {
QuestionItem fullItem = qpoolService.loadItemById(item.getKey());
if (fullItem instanceof QuestionItemImpl) {
QuestionItemImpl itemImpl = (QuestionItemImpl) fullItem;
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.UPDATE_QUESTION_ITEM_METADATA);
builder.withBefore(itemImpl);
formOKGeneral(itemImpl);
formOKQuestion(itemImpl);
formOKTechnical(itemImpl);
formOKRights(itemImpl);
QuestionItem merged = qpoolService.updateItem(itemImpl);
builder.withAfter(itemImpl);
qpoolService.persist(builder.create());
updatedItems.add(merged);
}
}
fireEvent(ureq, Event.DONE_EVENT);
}
use of org.olat.modules.qpool.model.QuestionItemImpl in project openolat by klemens.
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.model.QuestionItemImpl in project openolat by klemens.
the class QuestionItemDetailsController method doStartReview.
private void doStartReview(UserRequest ureq, TaxonomyLevel taxonomyLevel) {
QuestionItem item = metadatasCtrl.getItem();
if (item instanceof QuestionItemImpl) {
QuestionItemImpl itemImpl = (QuestionItemImpl) item;
if (itemImpl.getTaxonomyLevel() == null || !itemImpl.getTaxonomyLevel().equals(taxonomyLevel)) {
itemImpl.setTaxonomyLevel(taxonomyLevel);
}
}
doChangeQuestionStatus(ureq, item, QuestionStatus.review);
}
use of org.olat.modules.qpool.model.QuestionItemImpl in project openolat by klemens.
the class QuestionItemDetailsController method doChangeQuestionStatus.
private void doChangeQuestionStatus(UserRequest ureq, QuestionItem item, QuestionStatus newStatus) {
if (!newStatus.equals(item.getQuestionStatus()) && item instanceof QuestionItemImpl) {
QuestionItemImpl itemImpl = (QuestionItemImpl) item;
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.STATUS_CHANGED);
builder.withBefore(itemImpl);
builder.withMessage("New status: " + newStatus);
itemImpl.setQuestionStatus(newStatus);
qpoolService.updateItem(itemImpl);
builder.withAfter(item);
qpoolService.persist(builder.create());
fireEvent(ureq, new QPoolEvent(QPoolEvent.ITEM_STATUS_CHANGED, item.getKey()));
}
reloadData(ureq);
}
Aggregations