use of org.olat.modules.qpool.QuestionItemAuditLogBuilder in project OpenOLAT by OpenOLAT.
the class QuestionPoolWebService method deleteQuestionItem.
/**
* Delete a question item by id.
*
* @response.representation.200.doc Nothing
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The question item not found
* @param itemKey The question item identifier
* @param request The HTTP request
* @return Nothing
*/
@DELETE
@Path("{itemKey}")
public Response deleteQuestionItem(@PathParam("itemKey") Long itemKey, @Context HttpServletRequest request) {
if (!isQuestionPoolManager(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
QPoolService poolService = CoreSpringFactory.getImpl(QPoolService.class);
QuestionItem item = poolService.loadItemById(itemKey);
if (item == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
List<QuestionItem> itemToDelete = Collections.singletonList(item);
poolService.deleteItems(itemToDelete);
Identity identity = RestSecurityHelper.getUserRequest(request).getIdentity();
QuestionItemAuditLogBuilder builder = poolService.createAuditLogBuilder(identity, Action.DELETE_QUESTION_ITEM);
builder.withBefore(item);
poolService.persist(builder.create());
return Response.ok().build();
}
use of org.olat.modules.qpool.QuestionItemAuditLogBuilder in project OpenOLAT by OpenOLAT.
the class QuestionPoolWebService method importQuestionItem.
private QuestionItemVOes importQuestionItem(Identity owner, String filename, File tmpFile, String language, Identity executor) {
Locale locale = CoreSpringFactory.getImpl(I18nManager.class).getLocaleOrDefault(language);
QPoolService qpoolService = CoreSpringFactory.getImpl(QPoolService.class);
List<QuestionItem> items = qpoolService.importItems(owner, locale, filename, tmpFile);
for (QuestionItem item : items) {
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(executor, Action.CREATE_QUESTION_ITEM_BY_IMPORT);
builder.withAfter(item);
qpoolService.persist(builder.create());
}
QuestionItemVOes voes = new QuestionItemVOes();
QuestionItemVO[] voArray = new QuestionItemVO[items.size()];
for (int i = items.size(); i-- > 0; ) {
voArray[i] = new QuestionItemVO(items.get(i));
}
voes.setQuestionItems(voArray);
voes.setTotalCount(items.size());
return voes;
}
use of org.olat.modules.qpool.QuestionItemAuditLogBuilder 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.QuestionItemAuditLogBuilder 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.QuestionItemAuditLogBuilder in project OpenOLAT by OpenOLAT.
the class ConversionConfirmationController method logAudit.
private void logAudit(List<QuestionItem> items) {
for (QuestionItem item : items) {
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_BY_CONVERSION);
builder.withAfter(item);
qpoolService.persist(builder.create());
}
}
Aggregations