From 5693d56cd80ac4dbd0ceda548b3b6e0bc9c48cd2 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Wed, 25 May 2011 12:00:16 +0200 Subject: [PATCH] MDL-27625 rating - consider RATING_UNSET_RATING a valid rating value --- mod/data/lib.php | 9 +++++++-- mod/forum/lib.php | 9 +++++++-- mod/glossary/lib.php | 9 +++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/mod/data/lib.php b/mod/data/lib.php index 4ab2ee5ea10..3ddc1589f3e 100644 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -1420,9 +1420,14 @@ function data_rating_validate($params) { } //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'); - } else if ($info->scale < 0) { + } + + // upper limit + if ($info->scale < 0) { //its a custom scale $scalerecord = $DB->get_record('scale', array('id' => -$params['scaleid'])); if ($scalerecord) { diff --git a/mod/forum/lib.php b/mod/forum/lib.php index d850e57682c..db883889ec3 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -3513,9 +3513,14 @@ function forum_rating_validate($params) { } //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'); - } else if ($info->scale < 0) { + } + + // upper limit + if ($info->scale < 0) { //its a custom scale $scalerecord = $DB->get_record('scale', array('id' => -$params['scaleid'])); if ($scalerecord) { diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index edd9e421157..d954bdd0d32 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -526,9 +526,14 @@ function glossary_rating_validate($params) { } //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'); - } else if ($info->scale < 0) { + } + + // upper limit + if ($info->scale < 0) { //its a custom scale $scalerecord = $DB->get_record('scale', array('id' => -$params['scaleid'])); if ($scalerecord) {