Skip to content

Commit

Permalink
MDL-27625 rating - consider RATING_UNSET_RATING a valid rating value
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed May 25, 2011
1 parent a021f72 commit 93e980d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
9 changes: 7 additions & 2 deletions mod/data/lib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1420,9 +1420,14 @@ function data_rating_validate($params) {
} }


//check that the submitted rating is valid for the scale //check that the submitted rating is valid for the scale
if ($params['rating'] < 0) {
// lower limit
if ($params['rating'] < 0 && $params['rating'] != RATING_UNSET_RATING) {
throw new rating_exception('invalidnum'); throw new rating_exception('invalidnum');
} else if ($info->scale < 0) { }

// upper limit
if ($info->scale < 0) {
//its a custom scale //its a custom scale
$scalerecord = $DB->get_record('scale', array('id' => -$params['scaleid'])); $scalerecord = $DB->get_record('scale', array('id' => -$params['scaleid']));
if ($scalerecord) { if ($scalerecord) {
Expand Down
9 changes: 7 additions & 2 deletions mod/forum/lib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3513,9 +3513,14 @@ function forum_rating_validate($params) {
} }


//check that the submitted rating is valid for the scale //check that the submitted rating is valid for the scale
if ($params['rating'] < 0) {
// lower limit
if ($params['rating'] < 0 && $params['rating'] != RATING_UNSET_RATING) {
throw new rating_exception('invalidnum'); throw new rating_exception('invalidnum');
} else if ($info->scale < 0) { }

// upper limit
if ($info->scale < 0) {
//its a custom scale //its a custom scale
$scalerecord = $DB->get_record('scale', array('id' => -$params['scaleid'])); $scalerecord = $DB->get_record('scale', array('id' => -$params['scaleid']));
if ($scalerecord) { if ($scalerecord) {
Expand Down
9 changes: 7 additions & 2 deletions mod/glossary/lib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -526,9 +526,14 @@ function glossary_rating_validate($params) {
} }


//check that the submitted rating is valid for the scale //check that the submitted rating is valid for the scale
if ($params['rating'] < 0) {
// lower limit
if ($params['rating'] < 0 && $params['rating'] != RATING_UNSET_RATING) {
throw new rating_exception('invalidnum'); throw new rating_exception('invalidnum');
} else if ($info->scale < 0) { }

// upper limit
if ($info->scale < 0) {
//its a custom scale //its a custom scale
$scalerecord = $DB->get_record('scale', array('id' => -$params['scaleid'])); $scalerecord = $DB->get_record('scale', array('id' => -$params['scaleid']));
if ($scalerecord) { if ($scalerecord) {
Expand Down

0 comments on commit 93e980d

Please sign in to comment.