Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
/**
2
 * Javascript module to handle tool_usertour AJAX requests.
3
 *
4
 * @module     tool_usertours/repository
5
 * @copyright  2016 Andrew Nicols <andrew@nicols.co.uk>
6
 */
7
import {call as fetchMany} from 'core/ajax';
8
import moodleConfig from 'core/config';
9
 
10
/**
11
 * Reset the tour state of the specified tour.
12
 *
13
 * @param {number} tourid
14
 * @return {Promise}
15
 */
16
export const resetTourState = tourid => fetchMany([{
17
    methodname: 'tool_usertours_reset_tour',
18
    args: {
19
        tourid,
20
        context: moodleConfig.contextid,
21
        pageurl: window.location.href,
22
    }
23
}])[0];
24
 
25
/**
26
 * Mark the specified tour as complete.
27
 *
28
 * @param {number} stepid
29
 * @param {number} tourid
30
 * @param {number} stepindex
31
 * @return {Promise}
32
 */
33
export const markTourComplete = (stepid, tourid, stepindex) => fetchMany([{
34
    methodname: 'tool_usertours_complete_tour',
35
    args: {
36
        stepid,
37
        stepindex: stepindex,
38
        tourid,
39
        context: moodleConfig.contextid,
40
        pageurl: window.location.href,
41
    }
42
}])[0];
43
 
44
/**
45
 * Fetch the specified tour.
46
 *
47
 * @param {number} tourid
48
 * @return {Promise}
49
 */
50
export const fetchTour = tourid => fetchMany([{
51
    methodname: 'tool_usertours_fetch_and_start_tour',
52
    args: {
53
        tourid,
54
        context: moodleConfig.contextid,
55
        pageurl: window.location.href,
56
    }
57
}])[0];
58
 
59
/**
60
 * Mark the specified step as having been shown.
61
 *
62
 * @param {number} stepid
63
 * @param {number} tourid
64
 * @param {number} stepindex
65
 * @return {Promise}
66
 */
67
export const markStepShown = (stepid, tourid, stepindex) => fetchMany([{
68
    methodname: 'tool_usertours_step_shown',
69
    args: {
70
        tourid,
71
        stepid,
72
        stepindex,
73
        context: moodleConfig.contextid,
74
        pageurl: window.location.href,
75
    }
76
}])[0];