Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 12... Línea 12...
12
//
12
//
13
// You should have received a copy of the GNU General Public License
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/>.
14
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 15... Línea 15...
15
 
15
 
-
 
16
/**
-
 
17
 * A configuration to provide to the modal.
-
 
18
 *
-
 
19
 * @typedef {Object} courseItem
-
 
20
 *
-
 
21
 * @property {String} type The type of element (section, cm).
-
 
22
 * @property {Number} id Element ID.
-
 
23
 * @property {String} url Element URL.
-
 
24
 */
-
 
25
 
16
/**
26
/**
17
 * Module to export parts of the state and transform them to be used in templates
27
 * Module to export parts of the state and transform them to be used in templates
18
 * and as draggable data.
28
 * and as draggable data.
19
 *
29
 *
20
 * @module     core_courseformat/local/courseeditor/exporter
30
 * @module     core_courseformat/local/courseeditor/exporter
Línea 109... Línea 119...
109
     */
119
     */
110
    cm(state, cminfo) {
120
    cm(state, cminfo) {
111
        const cm = {
121
        const cm = {
112
            ...cminfo,
122
            ...cminfo,
113
            isactive: false,
123
            isactive: false,
-
 
124
            sectioninfo: false, // Init to false to prevent mustache recursion loops.
114
        };
125
        };
-
 
126
        if (cminfo.hasdelegatedsection) {
-
 
127
            const sectioninfo = state.section.get(cminfo.delegatesectionid);
-
 
128
            cm.sectioninfo = this.section(state, sectioninfo);
-
 
129
        }
115
        return cm;
130
        return cm;
116
    }
131
    }
Línea 117... Línea 132...
117
 
132
 
118
    /**
133
    /**
Línea 142... Línea 157...
142
        return {
157
        return {
143
            type: 'cm',
158
            type: 'cm',
144
            id: cminfo.id,
159
            id: cminfo.id,
145
            name: cminfo.name,
160
            name: cminfo.name,
146
            sectionid: cminfo.sectionid,
161
            sectionid: cminfo.sectionid,
147
            delegatesection: cminfo.delegatesection,
162
            hasdelegatedsection: cminfo.hasdelegatedsection,
148
            nextcmid,
163
            nextcmid,
149
        };
164
        };
150
    }
165
    }
Línea 151... Línea 166...
151
 
166
 
Línea 221... Línea 236...
221
 
236
 
222
    /**
237
    /**
223
     * Return a sorted list of all sections and cms items in the state.
238
     * Return a sorted list of all sections and cms items in the state.
224
     *
239
     *
225
     * @param {Object} state the current state.
240
     * @param {Object} state the current state.
226
     * @returns {Array} all sections and cms items in the state.
241
     * @returns {courseItem[]} all sections and cms items in the state.
227
     */
242
     */
228
    allItemsArray(state) {
243
    allItemsArray(state) {
229
        const items = [];
244
        const items = [];
230
        const sectionlist = state.course.sectionlist ?? [];
245
        const sectionlist = state.course.sectionlist ?? [];
231
        // Add sections.
246
        // Add sections.
232
        sectionlist.forEach(sectionid => {
247
        sectionlist.forEach(sectionid => {
233
            const sectioninfo = state.section.get(sectionid);
248
            const sectioninfo = state.section.get(sectionid);
-
 
249
            // Skip delegated sections because components are responsible for them.
-
 
250
            if (sectioninfo.component !== null) {
-
 
251
                return;
-
 
252
            }
-
 
253
 
-
 
254
            items.push({
-
 
255
                type: 'section',
-
 
256
                id: sectioninfo.id,
-
 
257
                url: sectioninfo.sectionurl
234
            items.push({type: 'section', id: sectioninfo.id, url: sectioninfo.sectionurl});
258
            });
235
            // Add cms.
259
            // Add cms.
236
            const cmlist = sectioninfo.cmlist ?? [];
260
            const cmlist = sectioninfo.cmlist ?? [];
237
            cmlist.forEach(cmid => {
261
            cmlist.forEach(cmid => {
238
                const cminfo = state.cm.get(cmid);
262
                const cmInfo = state.cm.get(cmid);
239
                items.push({type: 'cm', id: cminfo.id, url: cminfo.url});
263
                items.push(...this.cmItemsArray(state, cmInfo));
240
            });
264
            });
241
        });
265
        });
242
        return items;
266
        return items;
Línea 243... Línea 267...
243
    }
267
    }
-
 
268
 
-
 
269
    /**
-
 
270
     * Return a list of all items associated with an activity.
-
 
271
     *
-
 
272
     * @private
-
 
273
     * @param {Object} state the full current state.
-
 
274
     * @param {Object} cmInfo the course module state data.
-
 
275
     * @return {courseItem[]} the items array associated with that cm.
-
 
276
     */
-
 
277
    cmItemsArray(state, cmInfo) {
-
 
278
        // Activities with delegated sections are exported as sections.
-
 
279
        if (cmInfo.hasdelegatedsection) {
-
 
280
            const items = [];
-
 
281
            const delegatedsection = state.section.get(cmInfo.delegatesectionid);
-
 
282
            items.push({
-
 
283
                type: 'section',
-
 
284
                id: delegatedsection.id,
-
 
285
                url: delegatedsection.sectionurl
-
 
286
            });
-
 
287
            const delegatedCmlist = delegatedsection.cmlist ?? [];
-
 
288
            delegatedCmlist.forEach(cmid => {
-
 
289
                const cmInfo = state.cm.get(cmid);
-
 
290
                items.push({
-
 
291
                    type: 'cm',
-
 
292
                    id: cmInfo.id,
-
 
293
                    url: cmInfo.url
-
 
294
                });
-
 
295
            });
-
 
296
            return items;
-
 
297
        }
-
 
298
 
-
 
299
        return [
-
 
300
            {type: 'cm', id: cmInfo.id, url: cmInfo.url},
-
 
301
        ];
-
 
302
    }
244
 
303
 
245
    /**
304
    /**
246
     * Check is some activities of a list can be stealth.
305
     * Check is some activities of a list can be stealth.
247
     *
306
     *
248
     * @param {Object} state the current state.
307
     * @param {Object} state the current state.