Search in sources :

Example 6 with RatingWithAverageFormItem

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);
        }
    }
}
Also used : RatingFormItem(org.olat.core.gui.components.rating.RatingFormItem) RatingWithAverageFormItem(org.olat.core.gui.components.rating.RatingWithAverageFormItem)

Aggregations

RatingWithAverageFormItem (org.olat.core.gui.components.rating.RatingWithAverageFormItem)6 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)4 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Map (java.util.Map)2 GroupRoles (org.olat.basesecurity.GroupRoles)2 License (org.olat.core.commons.services.license.License)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 FlexiTableSearchEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)2 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)2 ImageComponent (org.olat.core.gui.components.image.ImageComponent)2 RatingFormEvent (org.olat.core.gui.components.rating.RatingFormEvent)2 RatingFormItem (org.olat.core.gui.components.rating.RatingFormItem)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 Roles (org.olat.core.id.Roles)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 VFSContainerMapper (org.olat.core.util.vfs.VFSContainerMapper)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 UserEfficiencyStatement (org.olat.course.assessment.UserEfficiencyStatement)2 BusinessGroup (org.olat.group.BusinessGroup)2