original_string: public static function create_tool_type($cartridgeurl, $key, $secret) {
          $params = self::validate_parameters(self::create_tool_type_parameters(),
                                              array(
                                                  'cartridgeurl' => $cartridgeurl,
                                                  'key' => $key,
                                                  'secret' => $secret
                                              ));
          $cartridgeurl = $params['cartridgeurl'];
          $key = $params['key'];
          $secret = $params['secret'];
  
          $context = context_system::instance();
          self::validate_context($context);
          require_capability('moodle/site:config', $context);
  
          $id = null;
  
          if (!empty($cartridgeurl)) {
              $type = new stdClass();
              $data = new stdClass();
              $type->state = LTI_TOOL_STATE_CONFIGURED;
              $data->lti_coursevisible = 1;
              $data->lti_sendname = LTI_SETTING_DELEGATE;
              $data->lti_sendemailaddr = LTI_SETTING_DELEGATE;
              $data->lti_acceptgrades = LTI_SETTING_DELEGATE;
              $data->lti_forcessl = 0;
  
              if (!empty($key)) {
                  $data->lti_resourcekey = $key;
              }
  
              if (!empty($secret)) {
                  $data->lti_password = $secret;
              }
  
              lti_load_type_from_cartridge($cartridgeurl, $data);
              if (empty($data->lti_toolurl)) {
                  throw new moodle_exception('unabletocreatetooltype', 'mod_lti');
              } else {
                  $id = lti_add_type($type, $data);
              }
          }
  
          if (!empty($id)) {
              $type = lti_get_type($id);
              return serialise_tool_type($type);
          } else {
              throw new moodle_exception('unabletocreatetooltype', 'mod_lti');
          }
      }
code: public static function create_tool_type($cartridgeurl, $key, $secret) {
          $params = self::validate_parameters(self::create_tool_type_parameters(),
                                              array(
                                                  'cartridgeurl' => $cartridgeurl,
                                                  'key' => $key,
                                                  'secret' => $secret
                                              ));
          $cartridgeurl = $params['cartridgeurl'];
          $key = $params['key'];
          $secret = $params['secret'];
  
          $context = context_system::instance();
          self::validate_context($context);
          require_capability('moodle/site:config', $context);
  
          $id = null;
  
          if (!empty($cartridgeurl)) {
              $type = new stdClass();
              $data = new stdClass();
              $type->state = LTI_TOOL_STATE_CONFIGURED;
              $data->lti_coursevisible = 1;
              $data->lti_sendname = LTI_SETTING_DELEGATE;
              $data->lti_sendemailaddr = LTI_SETTING_DELEGATE;
              $data->lti_acceptgrades = LTI_SETTING_DELEGATE;
              $data->lti_forcessl = 0;
  
              if (!empty($key)) {
                  $data->lti_resourcekey = $key;
              }
  
              if (!empty($secret)) {
                  $data->lti_password = $secret;
              }
  
              lti_load_type_from_cartridge($cartridgeurl, $data);
              if (empty($data->lti_toolurl)) {
                  throw new moodle_exception('unabletocreatetooltype', 'mod_lti');
              } else {
                  $id = lti_add_type($type, $data);
              }
          }
  
          if (!empty($id)) {
              $type = lti_get_type($id);
              return serialise_tool_type($type);
          } else {
              throw new moodle_exception('unabletocreatetooltype', 'mod_lti');
          }
      }
code_tokens: public static function create_tool_type ( $ cartridgeurl , $ key , $ secret ) { $ params = self :: validate_parameters ( self :: create_tool_type_parameters ( ) , array ( 'cartridgeurl' => $ cartridgeurl , 'key' => $ key , 'secret' => $ secret ) ) ; $ cartridgeurl = $ params [ 'cartridgeurl' ] ; $ key = $ params [ 'key' ] ; $ secret = $ params [ 'secret' ] ; $ context = context_system :: instance ( ) ; self :: validate_context ( $ context ) ; require_capability ( 'moodle/site:config' , $ context ) ; $ id = null ; if ( ! empty ( $ cartridgeurl ) ) { $ type = new stdClass ( ) ; $ data = new stdClass ( ) ; $ type -> state = LTI_TOOL_STATE_CONFIGURED ; $ data -> lti_coursevisible = 1 ; $ data -> lti_sendname = LTI_SETTING_DELEGATE ; $ data -> lti_sendemailaddr = LTI_SETTING_DELEGATE ; $ data -> lti_acceptgrades = LTI_SETTING_DELEGATE ; $ data -> lti_forcessl = 0 ; if ( ! empty ( $ key ) ) { $ data -> lti_resourcekey = $ key ; } if ( ! empty ( $ secret ) ) { $ data -> lti_password = $ secret ; } lti_load_type_from_cartridge ( $ cartridgeurl , $ data ) ; if ( empty ( $ data -> lti_toolurl ) ) { throw new moodle_exception ( 'unabletocreatetooltype' , 'mod_lti' ) ; } else { $ id = lti_add_type ( $ type , $ data ) ; } } if ( ! empty ( $ id ) ) { $ type = lti_get_type ( $ id ) ; return serialise_tool_type ( $ type ) ; } else { throw new moodle_exception ( 'unabletocreatetooltype' , 'mod_lti' ) ; } }
docstring: Creates a tool type.
  
  @param string $cartridgeurl Url of the xml cartridge representing the LTI tool
  @param string $key The consumer key to identify this consumer
  @param string $secret The secret
  @return array created tool type
  @since Moodle 3.1
  @throws moodle_exception If the tool type could not be created
docstring_tokens: Creates a tool type .