use of org.olat.modules.qpool.model.ReviewDecision in project OpenOLAT by OpenOLAT.
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);
}
}
use of org.olat.modules.qpool.model.ReviewDecision 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);
}
}
use of org.olat.modules.qpool.model.ReviewDecision in project openolat by klemens.
the class LowerLimitProviderTest method shouldNotChangeStatusIfNotEnoughRatings.
@Test
public void shouldNotChangeStatusIfNotEnoughRatings() {
when(commentAndRatingServiceMock.countRatings(any(), any())).thenReturn(RATINGS_TOO_LITTLE);
ReviewDecision decision = sut.decideStatus(item, RATING_OK);
assertThat(decision.isStatusChanged()).isFalse();
assertThat(decision.getStatus()).isEqualTo(item.getQuestionStatus());
}
use of org.olat.modules.qpool.model.ReviewDecision in project openolat by klemens.
the class LowerLimitProviderTest method shouldSetRevisedIfRatingToLow.
@Test
public void shouldSetRevisedIfRatingToLow() {
ReviewDecision decision = sut.decideStatus(item, RATING_TO_LOW);
assertThat(decision.isStatusChanged()).isTrue();
assertThat(decision.getStatus()).isEqualTo(QuestionStatus.revised);
}
Aggregations