Search in sources :

Example 26 with QuestionItemAuditLogBuilder

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();
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QPoolService(org.olat.modules.qpool.QPoolService) Identity(org.olat.core.id.Identity) QuestionItem(org.olat.modules.qpool.QuestionItem) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 27 with QuestionItemAuditLogBuilder

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;
}
Also used : Locale(java.util.Locale) QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QPoolService(org.olat.modules.qpool.QPoolService) QuestionItem(org.olat.modules.qpool.QuestionItem) I18nManager(org.olat.core.util.i18n.I18nManager)

Example 28 with QuestionItemAuditLogBuilder

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));
    }
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QItemEdited(org.olat.modules.qpool.ui.events.QItemEdited) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) QEducationalContext(org.olat.modules.qpool.model.QEducationalContext)

Example 29 with QuestionItemAuditLogBuilder

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);
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 30 with QuestionItemAuditLogBuilder

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());
    }
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QuestionItem(org.olat.modules.qpool.QuestionItem)

Aggregations

QuestionItemAuditLogBuilder (org.olat.modules.qpool.QuestionItemAuditLogBuilder)42 QuestionItem (org.olat.modules.qpool.QuestionItem)32 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)16 QItemEdited (org.olat.modules.qpool.ui.events.QItemEdited)8 QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)6 QPoolEvent (org.olat.modules.qpool.ui.events.QPoolEvent)6 UserRequest (org.olat.core.gui.UserRequest)4 WindowControl (org.olat.core.gui.control.WindowControl)4 Step (org.olat.core.gui.control.generic.wizard.Step)4 StepRunnerCallback (org.olat.core.gui.control.generic.wizard.StepRunnerCallback)4 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)4 StepsRunContext (org.olat.core.gui.control.generic.wizard.StepsRunContext)4 QTIQPoolServiceProvider (org.olat.ims.qti.qpool.QTIQPoolServiceProvider)4 QTI21QPoolServiceProvider (org.olat.ims.qti21.pool.QTI21QPoolServiceProvider)4 AssessmentItemAndMetadata (org.olat.ims.qti21.questionimport.AssessmentItemAndMetadata)4 AssessmentItemsPackage (org.olat.ims.qti21.questionimport.AssessmentItemsPackage)4 ImportOptions (org.olat.ims.qti21.questionimport.ImportOptions)4 QImport_1_InputStep (org.olat.ims.qti21.questionimport.QImport_1_InputStep)4 QPoolService (org.olat.modules.qpool.QPoolService)4 Export_1_TypeStep (org.olat.modules.qpool.ui.wizard.Export_1_TypeStep)4