public function check_rating_is_valid($params) {

        if (!isset($params['context'])) {
            throw new coding_exception('The context option is a required option when checking rating validity.');
        }
        if (!isset($params['component'])) {
            throw new coding_exception('The component option is now a required option when checking rating validity');
        }
        if (!isset($params['ratingarea'])) {
            throw new coding_exception('The ratingarea option is now a required option when checking rating validity');
        }
        if (!isset($params['itemid'])) {
            throw new coding_exception('The itemid option is now a required option when checking rating validity');
        }
        if (!isset($params['scaleid'])) {
            throw new coding_exception('The scaleid option is now a required option when checking rating validity');
        }
        if (!isset($params['rateduserid'])) {
            throw new coding_exception('The rateduserid option is now a required option when checking rating validity');
        }

        list($plugintype, $pluginname) = core_component::normalize_component($params['component']);

        // This looks for a function like forum_rating_validate() in mod_forum lib.php
        // wrapping the params array in another array as call_user_func_array() expands arrays into multiple arguments.
        $isvalid = plugin_callback($plugintype, $pluginname, 'rating', 'validate', array($params), null);

        // If null then the callback does not exist.
        if ($isvalid === null) {
            $isvalid = false;
            debugging('rating validation callback not found for component '.  clean_param($component, PARAM_ALPHANUMEXT));
        }
        return $isvalid;
    }
public function check_rating_is_valid($params) {

        if (!isset($params['context'])) {
            throw new coding_exception('The context option is a required option when checking rating validity.');
        }
        if (!isset($params['component'])) {
            throw new coding_exception('The component option is now a required option when checking rating validity');
        }
        if (!isset($params['ratingarea'])) {
            throw new coding_exception('The ratingarea option is now a required option when checking rating validity');
        }
        if (!isset($params['itemid'])) {
            throw new coding_exception('The itemid option is now a required option when checking rating validity');
        }
        if (!isset($params['scaleid'])) {
            throw new coding_exception('The scaleid option is now a required option when checking rating validity');
        }
        if (!isset($params['rateduserid'])) {
            throw new coding_exception('The rateduserid option is now a required option when checking rating validity');
        }

        list($plugintype, $pluginname) = core_component::normalize_component($params['component']);

        // This looks for a function like forum_rating_validate() in mod_forum lib.php
        // wrapping the params array in another array as call_user_func_array() expands arrays into multiple arguments.
        $isvalid = plugin_callback($plugintype, $pluginname, 'rating', 'validate', array($params), null);

        // If null then the callback does not exist.
        if ($isvalid === null) {
            $isvalid = false;
            debugging('rating validation callback not found for component '.  clean_param($component, PARAM_ALPHANUMEXT));
        }
        return $isvalid;
    }
public function check_rating_is_valid ( $ params ) { if ( ! isset ( $ params [ 'context' ] ) ) { throw new coding_exception ( 'The context option is a required option when checking rating validity.' ) ; } if ( ! isset ( $ params [ 'component' ] ) ) { throw new coding_exception ( 'The component option is now a required option when checking rating validity' ) ; } if ( ! isset ( $ params [ 'ratingarea' ] ) ) { throw new coding_exception ( 'The ratingarea option is now a required option when checking rating validity' ) ; } if ( ! isset ( $ params [ 'itemid' ] ) ) { throw new coding_exception ( 'The itemid option is now a required option when checking rating validity' ) ; } if ( ! isset ( $ params [ 'scaleid' ] ) ) { throw new coding_exception ( 'The scaleid option is now a required option when checking rating validity' ) ; } if ( ! isset ( $ params [ 'rateduserid' ] ) ) { throw new coding_exception ( 'The rateduserid option is now a required option when checking rating validity' ) ; } list ( $ plugintype , $ pluginname ) = core_component :: normalize_component ( $ params [ 'component' ] ) ; // This looks for a function like forum_rating_validate() in mod_forum lib.php // wrapping the params array in another array as call_user_func_array() expands arrays into multiple arguments. $ isvalid = plugin_callback ( $ plugintype , $ pluginname , 'rating' , 'validate' , array ( $ params ) , null ) ; // If null then the callback does not exist. if ( $ isvalid === null ) { $ isvalid = false ; debugging ( 'rating validation callback not found for component ' . clean_param ( $ component , PARAM_ALPHANUMEXT ) ) ; } return $ isvalid ; }
Validates a submitted rating

@param array $params submitted data
context => object the context in which the rated items exists [required]
component => The component the rating belongs to [required]
ratingarea => The ratingarea the rating is associated with [required]
itemid => int the ID of the object being rated [required]
scaleid => int the scale from which the user can select a rating. Used for bounds checking. [required]
rating => int the submitted rating
rateduserid => int the id of the user whose items have been rated. 0 to update all. [required]
aggregation => int the aggregation method to apply when calculating grades ie RATING_AGGREGATE_AVERAGE [optional]
@return boolean true if the rating is valid, false if callback not found, throws rating_exception if rating is invalid
Validates a submitted rating