original_string: protected function generate_rating_settings_object($options) {
  
          if (!isset($options->context)) {
              throw new coding_exception('The context option is a required option when generating a rating settings object.');
          }
          if (!isset($options->component)) {
              throw new coding_exception('The component option is now a required option when generating a rating settings object.');
          }
          if (!isset($options->ratingarea)) {
              throw new coding_exception('The ratingarea option is now a required option when generating a rating settings object.');
          }
          if (!isset($options->aggregate)) {
              throw new coding_exception('The aggregate option is now a required option when generating a rating settings object.');
          }
          if (!isset($options->scaleid)) {
              throw new coding_exception('The scaleid option is now a required option when generating a rating settings object.');
          }
  
          // Settings that are common to all ratings objects in this context.
          $settings = new stdClass;
          $settings->scale             = $this->generate_rating_scale_object($options->scaleid); // The scale to use now.
          $settings->aggregationmethod = $options->aggregate;
          $settings->assesstimestart   = null;
          $settings->assesstimefinish  = null;
  
          // Collect options into the settings object.
          if (!empty($options->assesstimestart)) {
              $settings->assesstimestart = $options->assesstimestart;
          }
          if (!empty($options->assesstimefinish)) {
              $settings->assesstimefinish = $options->assesstimefinish;
          }
          if (!empty($options->returnurl)) {
              $settings->returnurl = $options->returnurl;
          }
  
          // Check site capabilities.
          $settings->permissions = new stdClass;
          // Can view the aggregate of ratings of their own items.
          $settings->permissions->view    = has_capability('moodle/rating:view', $options->context);
          // Can view the aggregate of ratings of other people's items.
          $settings->permissions->viewany = has_capability('moodle/rating:viewany', $options->context);
          // Can view individual ratings.
          $settings->permissions->viewall = has_capability('moodle/rating:viewall', $options->context);
          // Can submit ratings.
          $settings->permissions->rate    = has_capability('moodle/rating:rate', $options->context);
  
          // Check module capabilities
          // This is mostly for backwards compatability with old modules that previously implemented their own ratings.
          $pluginpermissionsarray = $this->get_plugin_permissions_array($options->context->id,
                                                                        $options->component,
                                                                        $options->ratingarea);
          $settings->pluginpermissions = new stdClass;
          $settings->pluginpermissions->view    = $pluginpermissionsarray['view'];
          $settings->pluginpermissions->viewany = $pluginpermissionsarray['viewany'];
          $settings->pluginpermissions->viewall = $pluginpermissionsarray['viewall'];
          $settings->pluginpermissions->rate    = $pluginpermissionsarray['rate'];
  
          return $settings;
      }
code: protected function generate_rating_settings_object($options) {
  
          if (!isset($options->context)) {
              throw new coding_exception('The context option is a required option when generating a rating settings object.');
          }
          if (!isset($options->component)) {
              throw new coding_exception('The component option is now a required option when generating a rating settings object.');
          }
          if (!isset($options->ratingarea)) {
              throw new coding_exception('The ratingarea option is now a required option when generating a rating settings object.');
          }
          if (!isset($options->aggregate)) {
              throw new coding_exception('The aggregate option is now a required option when generating a rating settings object.');
          }
          if (!isset($options->scaleid)) {
              throw new coding_exception('The scaleid option is now a required option when generating a rating settings object.');
          }
  
          // Settings that are common to all ratings objects in this context.
          $settings = new stdClass;
          $settings->scale             = $this->generate_rating_scale_object($options->scaleid); // The scale to use now.
          $settings->aggregationmethod = $options->aggregate;
          $settings->assesstimestart   = null;
          $settings->assesstimefinish  = null;
  
          // Collect options into the settings object.
          if (!empty($options->assesstimestart)) {
              $settings->assesstimestart = $options->assesstimestart;
          }
          if (!empty($options->assesstimefinish)) {
              $settings->assesstimefinish = $options->assesstimefinish;
          }
          if (!empty($options->returnurl)) {
              $settings->returnurl = $options->returnurl;
          }
  
          // Check site capabilities.
          $settings->permissions = new stdClass;
          // Can view the aggregate of ratings of their own items.
          $settings->permissions->view    = has_capability('moodle/rating:view', $options->context);
          // Can view the aggregate of ratings of other people's items.
          $settings->permissions->viewany = has_capability('moodle/rating:viewany', $options->context);
          // Can view individual ratings.
          $settings->permissions->viewall = has_capability('moodle/rating:viewall', $options->context);
          // Can submit ratings.
          $settings->permissions->rate    = has_capability('moodle/rating:rate', $options->context);
  
          // Check module capabilities
          // This is mostly for backwards compatability with old modules that previously implemented their own ratings.
          $pluginpermissionsarray = $this->get_plugin_permissions_array($options->context->id,
                                                                        $options->component,
                                                                        $options->ratingarea);
          $settings->pluginpermissions = new stdClass;
          $settings->pluginpermissions->view    = $pluginpermissionsarray['view'];
          $settings->pluginpermissions->viewany = $pluginpermissionsarray['viewany'];
          $settings->pluginpermissions->viewall = $pluginpermissionsarray['viewall'];
          $settings->pluginpermissions->rate    = $pluginpermissionsarray['rate'];
  
          return $settings;
      }
code_tokens: protected function generate_rating_settings_object ( $ options ) { if ( ! isset ( $ options -> context ) ) { throw new coding_exception ( 'The context option is a required option when generating a rating settings object.' ) ; } if ( ! isset ( $ options -> component ) ) { throw new coding_exception ( 'The component option is now a required option when generating a rating settings object.' ) ; } if ( ! isset ( $ options -> ratingarea ) ) { throw new coding_exception ( 'The ratingarea option is now a required option when generating a rating settings object.' ) ; } if ( ! isset ( $ options -> aggregate ) ) { throw new coding_exception ( 'The aggregate option is now a required option when generating a rating settings object.' ) ; } if ( ! isset ( $ options -> scaleid ) ) { throw new coding_exception ( 'The scaleid option is now a required option when generating a rating settings object.' ) ; } // Settings that are common to all ratings objects in this context. $ settings = new stdClass ; $ settings -> scale = $ this -> generate_rating_scale_object ( $ options -> scaleid ) ; // The scale to use now. $ settings -> aggregationmethod = $ options -> aggregate ; $ settings -> assesstimestart = null ; $ settings -> assesstimefinish = null ; // Collect options into the settings object. if ( ! empty ( $ options -> assesstimestart ) ) { $ settings -> assesstimestart = $ options -> assesstimestart ; } if ( ! empty ( $ options -> assesstimefinish ) ) { $ settings -> assesstimefinish = $ options -> assesstimefinish ; } if ( ! empty ( $ options -> returnurl ) ) { $ settings -> returnurl = $ options -> returnurl ; } // Check site capabilities. $ settings -> permissions = new stdClass ; // Can view the aggregate of ratings of their own items. $ settings -> permissions -> view = has_capability ( 'moodle/rating:view' , $ options -> context ) ; // Can view the aggregate of ratings of other people's items. $ settings -> permissions -> viewany = has_capability ( 'moodle/rating:viewany' , $ options -> context ) ; // Can view individual ratings. $ settings -> permissions -> viewall = has_capability ( 'moodle/rating:viewall' , $ options -> context ) ; // Can submit ratings. $ settings -> permissions -> rate = has_capability ( 'moodle/rating:rate' , $ options -> context ) ; // Check module capabilities // This is mostly for backwards compatability with old modules that previously implemented their own ratings. $ pluginpermissionsarray = $ this -> get_plugin_permissions_array ( $ options -> context -> id , $ options -> component , $ options -> ratingarea ) ; $ settings -> pluginpermissions = new stdClass ; $ settings -> pluginpermissions -> view = $ pluginpermissionsarray [ 'view' ] ; $ settings -> pluginpermissions -> viewany = $ pluginpermissionsarray [ 'viewany' ] ; $ settings -> pluginpermissions -> viewall = $ pluginpermissionsarray [ 'viewall' ] ; $ settings -> pluginpermissions -> rate = $ pluginpermissionsarray [ 'rate' ] ; return $ settings ; }
docstring: Generates a rating settings object based upon the options it is provided.
  
  @param stdClass $options {
  context           => context the context in which the ratings exists [required]
  component         => string The component the items belong to [required]
  ratingarea        => string The ratingarea the items belong to [required]
  aggregate         => int Aggregation method to apply. RATING_AGGREGATE_AVERAGE, RATING_AGGREGATE_MAXIMUM etc [required]
  scaleid           => int the scale from which the user can select a rating [required]
  returnurl         => string the url to return the user to after submitting a rating. Null for ajax requests [optional]
  assesstimestart   => int only allow rating of items created after this timestamp [optional]
  assesstimefinish  => int only allow rating of items created before this timestamp [optional]
  plugintype        => string plugin type ie 'mod' Used to find the permissions callback [optional]
  pluginname        => string plugin name ie 'forum' Used to find the permissions callback [optional]
  }
  @return stdClass rating settings object
docstring_tokens: Generates a rating settings object based upon the options it is provided .