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
 * A javascript module to retrieve enrolled coruses from the server.
18
 *
19
 * @module block_myoverview/repository
20
 * @copyright  2018 Bas Brands <base@moodle.com>
21
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22
 */
23
 
24
import Ajax from 'core/ajax';
25
 
26
/**
27
 * Retrieve a list of enrolled courses.
28
 *
29
 * Valid args are:
30
 * string classification    future, inprogress, past
31
 * int limit                number of records to retreive
32
 * int Offset               offset for pagination
33
 * int sort                 sort by lastaccess or name
34
 *
35
 * @method getEnrolledCoursesByTimeline
36
 * @param {object} args The request arguments
37
 * @return {promise} Resolved with an array of courses
38
 */
39
export const getEnrolledCoursesByTimeline = args => {
40
    const request = {
41
        methodname: 'core_course_get_enrolled_courses_by_timeline_classification',
42
        args: args
43
    };
44
 
45
    return Ajax.call([request])[0];
46
};
47
 
48
/**
49
 * Set the favourite state on a list of courses.
50
 *
51
 * Valid args are:
52
 * Array courses  list of course id numbers.
53
 *
54
 * @param {Object} args Arguments send to the webservice.
55
 * @return {Promise} Resolve with warnings.
56
 */
57
export const setFavouriteCourses = args => {
58
    const request = {
59
        methodname: 'core_course_set_favourite_courses',
60
        args: args
61
    };
62
 
63
    return Ajax.call([request])[0];
64
};
65
 
66
/**
67
 * These course fields are the only ones needed to be included in the results for the card and list views.
68
 *
69
 * @type {string[]}
70
 */
71
export const CARDLIST_REQUIRED_FIELDS = [
72
    'id',
73
    'fullname',
74
    'shortname',
75
    'showcoursecategory',
76
    'showshortname',
77
    'visible',
78
    'enddate',
79
];
80
 
81
/**
82
 * These course fields are the only ones needed to be included in the results for the card and list views.
83
 *
84
 * @type {string[]}
85
 */
86
export const SUMMARY_REQUIRED_FIELDS = [
87
    'id',
88
    'fullname',
89
    'shortname',
90
    'showcoursecategory',
91
    'showshortname',
92
    'visible',
93
    'enddate',
94
    'summary',
95
    'summaryformat',
96
];