original_string: public static function save_definitions($areas) {
          $params = self::validate_parameters(self::save_definitions_parameters(),
                                              array('areas' => $areas));
  
          foreach ($params['areas'] as $area) {
  
              $context = context::instance_by_id($area['contextid']);
              require_capability('moodle/grade:managegradingforms', $context);
              $gradingmanager = get_grading_manager($context, $area['component'], $area['areaname']);
              $gradingmanager->set_active_method($area['activemethod']);
              $availablemethods = $gradingmanager->get_available_methods();
  
              foreach ($area['definitions'] as $definition) {
                  if (array_key_exists($definition['method'], $availablemethods)) {
                      $controller = $gradingmanager->get_controller($definition['method']);
                      $controller->update_definition(self::create_definition_object($definition));
                  } else {
                      throw new invalid_parameter_exception('Unknown Grading method: '. $definition['method']);
                  }
              }
          }
      }
code: public static function save_definitions($areas) {
          $params = self::validate_parameters(self::save_definitions_parameters(),
                                              array('areas' => $areas));
  
          foreach ($params['areas'] as $area) {
  
              $context = context::instance_by_id($area['contextid']);
              require_capability('moodle/grade:managegradingforms', $context);
              $gradingmanager = get_grading_manager($context, $area['component'], $area['areaname']);
              $gradingmanager->set_active_method($area['activemethod']);
              $availablemethods = $gradingmanager->get_available_methods();
  
              foreach ($area['definitions'] as $definition) {
                  if (array_key_exists($definition['method'], $availablemethods)) {
                      $controller = $gradingmanager->get_controller($definition['method']);
                      $controller->update_definition(self::create_definition_object($definition));
                  } else {
                      throw new invalid_parameter_exception('Unknown Grading method: '. $definition['method']);
                  }
              }
          }
      }
code_tokens: public static function save_definitions ( $ areas ) { $ params = self :: validate_parameters ( self :: save_definitions_parameters ( ) , array ( 'areas' => $ areas ) ) ; foreach ( $ params [ 'areas' ] as $ area ) { $ context = context :: instance_by_id ( $ area [ 'contextid' ] ) ; require_capability ( 'moodle/grade:managegradingforms' , $ context ) ; $ gradingmanager = get_grading_manager ( $ context , $ area [ 'component' ] , $ area [ 'areaname' ] ) ; $ gradingmanager -> set_active_method ( $ area [ 'activemethod' ] ) ; $ availablemethods = $ gradingmanager -> get_available_methods ( ) ; foreach ( $ area [ 'definitions' ] as $ definition ) { if ( array_key_exists ( $ definition [ 'method' ] , $ availablemethods ) ) { $ controller = $ gradingmanager -> get_controller ( $ definition [ 'method' ] ) ; $ controller -> update_definition ( self :: create_definition_object ( $ definition ) ) ; } else { throw new invalid_parameter_exception ( 'Unknown Grading method: ' . $ definition [ 'method' ] ) ; } } } }
docstring: Saves the areas and definitions
  @param array $areas array of areas containing definitions to be saved
  @return null
  @throws invalid_parameter_exception
  @since Moodle 2.8
docstring_tokens: Saves the areas and definitions