Package org.olat.core.commons.services.commentAndRating.model

Examples of org.olat.core.commons.services.commentAndRating.model.UserRating


  /**
   * @see org.olat.core.commons.services.commentAndRating.UserRatingsManager#createRating(org.olat.core.id.Identity, int)
   */
  @Override
  public UserRating createRating(Identity creator, int ratingValue) {
    UserRating rating = new UserRatingImpl(getOLATResourceable(),
        getOLATResourceableSubPath(), creator, Integer.valueOf(ratingValue));
    DBFactory.getInstance().saveObject(rating);
    return rating;
  }
View Full Code Here


    assertEquals(Float.valueOf(0), urm.calculateRatingAverage());
    assertEquals(Float.valueOf(0), urm2.calculateRatingAverage());
    assertEquals(Long.valueOf(0), urm.countRatings());
    assertEquals(Long.valueOf(0), urm2.countRatings());
   
    UserRating r1 = urm.createRating(ident1, 2);
    UserRating r2 = urm2.createRating(ident1, 2);
    assertEquals(Float.valueOf(2), urm.calculateRatingAverage());
    assertEquals(Float.valueOf(2), urm2.calculateRatingAverage());
    assertEquals(Long.valueOf(1), urm.countRatings());
    assertEquals(Long.valueOf(1), urm2.countRatings());
    //
    UserRating r3 = urm.createRating(ident2, 4);
    UserRating r4 = urm2.createRating(ident2, 4);
    assertEquals(Float.valueOf(3), urm.calculateRatingAverage());
    assertEquals(Float.valueOf(3), urm2.calculateRatingAverage());
    assertEquals(Long.valueOf(2), urm.countRatings());
    assertEquals(Long.valueOf(2), urm2.countRatings());
    //
    UserRating r5 = urm.createRating(ident3, 1);
    UserRating r6 = urm2.createRating(ident3, 1);
    assertEquals(Float.valueOf(2.5f), urm.calculateRatingAverage());
    assertEquals(Float.valueOf(2.5f), urm2.calculateRatingAverage());
    assertEquals(Long.valueOf(3), urm.countRatings());
    assertEquals(Long.valueOf(3), urm2.countRatings());
    //
View Full Code Here

TOP

Related Classes of org.olat.core.commons.services.commentAndRating.model.UserRating

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.