[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/mod/lti/amd/src/ -> tool_type.js (source)

   1  // This file is part of Moodle - http://moodle.org/
   2  //
   3  // Moodle is free software: you can redistribute it and/or modify
   4  // it under the terms of the GNU General Public License as published by
   5  // the Free Software Foundation, either version 3 of the License, or
   6  // (at your option) any later version.
   7  //
   8  // Moodle is distributed in the hope that it will be useful,
   9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11  // GNU General Public License for more details.
  12  //
  13  // You should have received a copy of the GNU General Public License
  14  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  15  
  16  /**
  17   * Provides an interface for a tool type in the Moodle server.
  18   *
  19   * @module     mod_lti/tool_type
  20   * @class      tool_type
  21   * @package    mod_lti
  22   * @copyright  2015 Ryan Wyllie <ryan@moodle.com>
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   * @since      3.1
  25   */
  26  define(['core/ajax', 'core/notification'], function(ajax, notification) {
  27      return /** @alias module:mod_lti/tool_type */ {
  28          /**
  29           * Get a list of tool types from Moodle for the given
  30           * search args.
  31           *
  32           * See also:
  33           * mod/lti/classes/external.php get_tool_types_parameters()
  34           *
  35           * @method query
  36           * @public
  37           * @param {Object} args Search parameters
  38           * @return {Promise} jQuery Deferred object
  39           */
  40          query: function(args) {
  41              var request = {
  42                  methodname: 'mod_lti_get_tool_types',
  43                  args: args || {}
  44              };
  45  
  46              var promise = ajax.call([request])[0];
  47  
  48              promise.fail(notification.exception);
  49  
  50              return promise;
  51          },
  52  
  53          /**
  54           * Create a tool type in Moodle.
  55           *
  56           * The promise will fail if the URL is not a cartridge, so you must handle the fail result.
  57           *
  58           * See also:
  59           * mod/lti/classes/external.php create_tool_type_parameters()
  60           *
  61           * @method create
  62           * @public
  63           * @param {Object} args Tool type properties
  64           * @return {Promise} jQuery Deferred object
  65           */
  66          create: function(args) {
  67              var request = {
  68                  methodname: 'mod_lti_create_tool_type',
  69                  args: args
  70              };
  71  
  72              var promise = ajax.call([request])[0];
  73  
  74              return promise;
  75          },
  76  
  77          /**
  78           * Update a tool type in Moodle.
  79           *
  80           * See also:
  81           * mod/lti/classes/external.php update_tool_type_parameters()
  82           *
  83           * @method update
  84           * @public
  85           * @param {Object} args Tool type properties
  86           * @return {Promise} jQuery Deferred object
  87           */
  88          update: function(args) {
  89              var request = {
  90                  methodname: 'mod_lti_update_tool_type',
  91                  args: args
  92              };
  93  
  94              var promise = ajax.call([request])[0];
  95  
  96              promise.fail(notification.exception);
  97  
  98              return promise;
  99          },
 100  
 101          /**
 102           * Delete a tool type from Moodle.
 103           *
 104           * @method delete
 105           * @public
 106           * @param {Integer} id Tool type ID
 107           * @return {Promise} jQuery Deferred object
 108           */
 109          'delete': function(id) {
 110              var request = {
 111                  methodname: 'mod_lti_delete_tool_type',
 112                  args: {
 113                      id: id
 114                  }
 115              };
 116  
 117              var promise = ajax.call([request])[0];
 118  
 119              promise.fail(notification.exception);
 120  
 121              return promise;
 122          },
 123  
 124          /**
 125           * Get a list of tool types from Moodle for the given
 126           * tool proxy id.
 127           *
 128           * @method query
 129           * @public
 130           * @param {Integer} id Tool type ID
 131           * @return {Promise} jQuery Deferred object
 132           */
 133          getFromToolProxyId: function(id) {
 134              return this.query({toolproxyid: id});
 135          },
 136  
 137          /**
 138           * Check if the given URL is a cartridge URL.
 139           *
 140           * The promise will fail if the URL is unreachable, so you must handle the fail result.
 141           *
 142           * @method isCartridge
 143           * @public
 144           * @param {String} url
 145           * @return {Promise} jQuery Deferred object
 146           */
 147          isCartridge: function(url) {
 148              var request = {
 149                  methodname: 'mod_lti_is_cartridge',
 150                  args: {
 151                      url: url
 152                  }
 153              };
 154  
 155              var promise = ajax.call([request])[0];
 156  
 157              return promise;
 158          },
 159  
 160          /**
 161           * Tool type constants.
 162           */
 163          constants: {
 164              state: {
 165                  configured: 1,
 166                  pending: 2,
 167                  rejected: 3
 168              },
 169          }
 170      };
 171  });


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1