Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
Fixed a bug that was causing it to lose the half star if the average …
Browse files Browse the repository at this point in the history
…was exactly 0.5
  • Loading branch information
paustian committed May 7, 2020
1 parent 2326527 commit 68673de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion modules/Paustian/RatingsModule/Api/RatingsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static function CalculateAverage($ratings, $ratingScale){
$retArray['average'] = $totalRating/$count;
$averageRemainder = fmod($retArray['average'], 1);
$retArray['avgInt'] = floor($retArray['average']);
$retArray['doHalfStar'] = ($averageRemainder > 0.5);
$retArray['doHalfStar'] = ($averageRemainder >= 0.5);
$max = $ratingScale;
$retArray['emptyStars'] = $max - Round($retArray['average']);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ application "Ratings" {
fields {
string "moduleName" {
documentation "The name of the module that the rating is linked to"
length 64
length 64
},
integer "objectId" {
documentation "The id of the object that identifies the module instance this rating is linked to"
Expand All @@ -45,7 +45,8 @@ application "Ratings" {
documentation "The rating, based upon a scale for the item"
defaultValue "0"
length 3
},
}
,
user "userId" {
documentation "The Id of the user who rated the item. "
}
Expand All @@ -69,29 +70,26 @@ application "Ratings" {
},
string "iconFa" {
documentation "A font-awesome css string that is used to display ratings. Either this or iconUrls must be specified."
defaultValue "fa-star"
mandatory false
role ICON
role ICON
},
string "halfIconFa" {
documentation "A font-awesome css string that is used to display ratings. Either this or iconUrls must be specified."
defaultValue "fa-star-half"
mandatory false
role ICON
role ICON
},
string "emptyIconFa" {
documentation "A font-awesome css string that is used to display ratings. Either this or iconUrls must be specified."
defaultValue "fa-star-o"
mandatory false
role ICON
role ICON
},
string "iconUrl" {
documentation "A url to a rating icon to be used for a rating. Either this or IconFas must be designated."
mandatory false
},
string "halfIconUrl" {
documentation "A url to a rating icon to be used for a rating. Either this or IconFas must be designated."
mandatory false
mandatory false
},
string "emptyIconUrl" {
documentation "A url to a rating icon to be used for a rating. Either this or IconFas must be designated."
Expand Down

0 comments on commit 68673de

Please sign in to comment.