use of org.olat.core.gui.components.rating.RatingWithAverageFormItem in project openolat by klemens.
the class RepositoryEntryListController method forgeRatings.
@Override
public void forgeRatings(RepositoryEntryRow row) {
if (repositoryModule.isRatingEnabled()) {
if (guestOnly) {
Double averageRating = row.getAverageRating();
float averageRatingValue = averageRating == null ? 0f : averageRating.floatValue();
RatingFormItem ratingCmp = uifactory.addRatingItem("rat_" + row.getKey(), null, averageRatingValue, 5, false, null);
row.setRatingFormItem(ratingCmp);
ratingCmp.setUserObject(row);
} else {
Integer myRating = row.getMyRating();
Double averageRating = row.getAverageRating();
long numOfRatings = row.getNumOfRatings();
float ratingValue = myRating == null ? 0f : myRating.floatValue();
float averageRatingValue = averageRating == null ? 0f : averageRating.floatValue();
RatingWithAverageFormItem ratingCmp = new RatingWithAverageFormItem("rat_" + row.getKey(), ratingValue, averageRatingValue, 5, numOfRatings);
row.setRatingFormItem(ratingCmp);
ratingCmp.setUserObject(row);
}
}
}
Aggregations