Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | 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
 * A javascript module to handle user AJAX actions.
18
 *
19
 * @module     core_course/local/activitychooser/repository
20
 * @copyright  2019 Mathew May <mathew.solutions>
21
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22
 */
23
import ajax from 'core/ajax';
24
 
25
/**
26
 * Fetch all the information on modules we'll need in the activity chooser.
27
 *
28
 * @method activityModules
29
 * @param {Number} courseid What course to fetch the modules for
1441 ariadna 30
 * @param {Number} sectionnum What course section to fetch the modules for
1 efrain 31
 * @return {object} jQuery promise
32
 */
1441 ariadna 33
export const activityModules = (courseid, sectionnum) => {
1 efrain 34
    const request = {
35
        methodname: 'core_course_get_course_content_items',
36
        args: {
37
            courseid: courseid,
1441 ariadna 38
            sectionnum: sectionnum,
1 efrain 39
        },
40
    };
41
    return ajax.call([request])[0];
42
};
43
 
44
/**
45
 * Given a module name, module ID & the current course we want to specify that the module
46
 * is a users' favourite.
47
 *
48
 * @method favouriteModule
49
 * @param {String} modName Frankenstyle name of the component to add favourite
50
 * @param {int} modID ID of the module. Mainly for LTI cases where they have same / similar names
51
 * @return {object} jQuery promise
52
 */
53
export const favouriteModule = (modName, modID) => {
54
    const request = {
55
        methodname: 'core_course_add_content_item_to_user_favourites',
56
        args: {
57
            componentname: modName,
58
            contentitemid: modID,
59
        },
60
    };
61
    return ajax.call([request])[0];
62
};
63
 
64
/**
65
 * Given a module name, module ID & the current course we want to specify that the module
66
 * is no longer a users' favourite.
67
 *
68
 * @method unfavouriteModule
69
 * @param {String} modName Frankenstyle name of the component to add favourite
70
 * @param {int} modID ID of the module. Mainly for LTI cases where they have same / similar names
71
 * @return {object} jQuery promise
72
 */
73
export const unfavouriteModule = (modName, modID) => {
74
    const request = {
75
        methodname: 'core_course_remove_content_item_from_user_favourites',
76
        args: {
77
            componentname: modName,
78
            contentitemid: modID,
79
        },
80
    };
81
    return ajax.call([request])[0];
82
};
83
 
84
/**
85
 * Fetch all the information on modules we'll need in the activity chooser.
86
 *
87
 * @method fetchFooterData
88
 * @param {Number} courseid What course to fetch the data for
89
 * @param {Number} sectionid What section to fetch the data for
90
 * @return {object} jQuery promise
91
 */
92
export const fetchFooterData = (courseid, sectionid) => {
93
    const request = {
94
        methodname: 'core_course_get_activity_chooser_footer',
95
        args: {
96
            courseid: courseid,
97
            sectionid: sectionid,
98
        },
99
    };
100
    return ajax.call([request])[0];
101
};