Search in sources :

Example 36 with QuestionItemAuditLogBuilder

use of org.olat.modules.qpool.QuestionItemAuditLogBuilder in project openolat by klemens.

the class ImportController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    String filename = fileEl.getUploadFileName();
    File file = fileEl.getUploadFile();
    List<QuestionItem> importItems = qpoolService.importItems(getIdentity(), getLocale(), filename, file);
    if (importItems == null || importItems.isEmpty()) {
        fireEvent(ureq, Event.DONE_EVENT);
        showWarning("import.failed");
    } else {
        boolean editable = editableEl == null ? true : editableEl.isSelected(0);
        source.postImport(importItems, editable);
        for (QuestionItem item : importItems) {
            QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_BY_IMPORT);
            builder.withAfter(item);
            qpoolService.persist(builder.create());
        }
        fireEvent(ureq, Event.DONE_EVENT);
        showInfo("import.success", Integer.toString(importItems.size()));
    }
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) File(java.io.File) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 37 with QuestionItemAuditLogBuilder

use of org.olat.modules.qpool.QuestionItemAuditLogBuilder 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);
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) QPoolEvent(org.olat.modules.qpool.ui.events.QPoolEvent)

Example 38 with QuestionItemAuditLogBuilder

use of org.olat.modules.qpool.QuestionItemAuditLogBuilder in project openolat by klemens.

the class QuestionPoolServiceImpl method rateItemInReview.

@Override
public void rateItemInReview(QuestionItem item, Identity identity, Float rating, String comment) {
    if (item == null || identity == null)
        return;
    if (rating != null && rating > 0f) {
        // Review is only in status review possible
        QuestionItem previousItem = loadItemById(item.getKey());
        if (QuestionStatus.review.equals(previousItem.getQuestionStatus())) {
            QuestionItemAuditLogBuilder builder = createAuditLogBuilder(identity, Action.REVIEW_QUESTION_ITEM);
            builder.withBefore(item);
            Integer newRating = Float.valueOf(rating).intValue();
            builder.withMessage("Rating: " + newRating);
            commentAndRatingService.createRating(identity, item, null, newRating);
            ReviewDecision decision = reviewService.decideStatus(item, rating);
            if (item instanceof QuestionItemImpl && decision.isStatusChanged()) {
                QuestionItemImpl itemImpl = (QuestionItemImpl) item;
                itemImpl.setQuestionStatus(decision.getStatus());
                updateItem(itemImpl);
            }
            builder.withAfter(item);
            persist(builder.create());
        }
    }
    if (StringHelper.containsNonWhitespace(comment)) {
        commentAndRatingService.createComment(identity, item, null, comment);
    }
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) ReviewDecision(org.olat.modules.qpool.model.ReviewDecision) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 39 with QuestionItemAuditLogBuilder

use of org.olat.modules.qpool.QuestionItemAuditLogBuilder in project openolat by klemens.

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 40 with QuestionItemAuditLogBuilder

use of org.olat.modules.qpool.QuestionItemAuditLogBuilder in project openolat by klemens.

the class QuestionPoolUserDataDeletable method deleteUserData.

@Override
public void deleteUserData(Identity identity, String newDeletedUserName, File archivePath) {
    if (!qpoolModule.isDeleteQuestionsWithoutAuthor())
        return;
    List<QuestionItem> itemsWithOneAuthor = questionItemDao.getItemsWithOneAuthor(identity);
    qpoolService.deleteItems(itemsWithOneAuthor);
    for (QuestionItem item : itemsWithOneAuthor) {
        QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(null, Action.DELETE_QUESTION_ITEM);
        builder.withBefore(item);
        builder.withMessage("Author deleted");
        qpoolService.persist(builder.create());
    }
    String logMessage = getLogMessage(identity, itemsWithOneAuthor);
    log.info(logMessage);
}
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