Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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 proxy in the Moodle server.
18
 *
19
 * @module     mod_lti/tool_proxy
20
 * @copyright  2015 Ryan Wyllie <ryan@moodle.com>
21
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22
 * @since      3.1
23
 */
24
define(['core/ajax', 'core/notification'], function(ajax, notification) {
25
    return {
26
        /**
27
         * Get a list of tool types from Moodle for the given
28
         * search args.
29
         *
30
         * See also:
31
         * mod/lti/classes/external.php get_tool_types_parameters()
32
         *
33
         * @method query
34
         * @public
35
         * @param {Object} args Search parameters
36
         * @return {Promise} jQuery Deferred object
37
         */
38
        query: function(args) {
39
            var request = {
40
                methodname: 'mod_lti_get_tool_proxies',
41
                args: args || {}
42
            };
43
 
44
            var promise = ajax.call([request])[0];
45
 
46
            promise.fail(notification.exception);
47
 
48
            return promise;
49
        },
50
        /**
51
         * Delete a tool proxy from Moodle.
52
         *
53
         * @method delete
54
         * @public
55
         * @param {Integer} id Tool proxy ID
56
         * @return {Promise} jQuery Deferred object
57
         */
58
        'delete': function(id) {
59
            var request = {
60
                methodname: 'mod_lti_delete_tool_proxy',
61
                args: {
62
                    id: id
63
                }
64
            };
65
 
66
            var promise = ajax.call([request])[0];
67
 
68
            promise.fail(notification.exception);
69
 
70
            return promise;
71
        },
72
 
73
        /**
74
         * Create a tool proxy in Moodle.
75
         *
76
         * The promise will fail if the proxy cannot be created, so you must handle the fail result.
77
         *
78
         * See mod/lti/classes/external.php create_tool_proxy_parameters
79
         *
80
         * @method create
81
         * @public
82
         * @param {Object} args Tool proxy properties
83
         * @return {Promise} jQuery Deferred object
84
         */
85
        create: function(args) {
86
            var request = {
87
                methodname: 'mod_lti_create_tool_proxy',
88
                args: args
89
            };
90
 
91
            var promise = ajax.call([request])[0];
92
 
93
            return promise;
94
        }
95
    };
96
});