Proyectos de Subversion Moodle

Rev

Rev 4 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 4 Rev 5
Línea 50... Línea 50...
50
 
50
 
51
    /**
51
    /**
52
     * Set up difficulty tracks on course modules.
52
     * Set up difficulty tracks on course modules.
53
     * @param {Array} difficultyLevels Array of difficulty tracks, one entry for each course module.
53
     * @param {Array} difficultyLevels Array of difficulty tracks, one entry for each course module.
54
     * @param {Array} trackColors Tracks colors, from block plugin configuration.
-
 
55
     * @param {Number|null} cmid The course module ID, if this page is a module view.
54
     * @param {Array} trackColors Tracks colors, from block plugin configuration.
56
     */
55
     */
57
    function setUpDifficultyTracks(difficultyLevels, trackColors, cmid) {
56
    function setUpDifficultyTracks(difficultyLevels, trackColors) {
58
        difficultyLevels.forEach(function(module) {
57
        difficultyLevels.forEach(function(module) {
59
            var difficultyLevel = parseInt(module.difficultyLevel);
58
            var difficultyLevel = parseInt(module.difficultyLevel);
60
            var title = '';
59
            var title = '';
61
            if (difficultyLevel > 0) {
60
            if (difficultyLevel > 0) {
Línea 66... Línea 65...
66
                'class': 'block_point_view track',
65
                'class': 'block_point_view track',
67
                'title': title,
66
                'title': title,
68
                'style': 'background-color: ' + trackColors[difficultyLevel] + ';'
67
                'style': 'background-color: ' + trackColors[difficultyLevel] + ';'
69
            });
68
            });
70
            // Decide where to put the track.
69
            // Decide where to put the track.
71
            var $container = $('#module-' + module.id + ' .activitytitle');
70
            var $container = $('#module-' + module.id + ' .mod-indent-outer');
72
            if ($container.closest('.activity-grid').length) {
-
 
73
                // Moodle 4.3+.
-
 
74
                $container = $container.closest('.activity-grid');
-
 
75
            }
-
 
76
            if ($container.length === 0) {
-
 
77
                // This seems to be a label.
-
 
78
                $container = $('#module-' + module.id + ' .activity-item .description,' +
-
 
79
                                '#module-' + module.id + ' .activity-item .activity-altcontent').first();
-
 
80
            }
-
 
Línea 81... Línea 71...
81
 
71
 
82
            // Add the track.
72
            // Add the track.
83
            if ($container.find('.block_point_view.track').length === 0) {
73
            if ($container.find('.block_point_view.track').length === 0) {
84
                $container.prepend($track);
74
                $container.prepend($track);
85
            }
75
            }
86
            // If there is indentation, move the track after it.
76
            // If there is indentation, move the track after it.
Línea 87... Línea -...
87
            $container.find('.mod-indent').after($track);
-
 
88
 
-
 
89
            if (cmid === module.id) {
-
 
90
                // This is a module page, add the track to the title.
-
 
91
                $('.page-context-header').prepend($track);
77
            $container.find('.mod-indent').after($track);
92
            }
78
 
Línea -... Línea 79...
-
 
79
        });
93
        });
80
    }
94
    }
81
 
95
 
82
 
96
    /**
83
    /**
97
     * Get a jQuery object in reaction zone for given module ID.
84
     * Get a jQuery object in reaction zone for given module ID.
Línea 124... Línea 111...
124
     * Set up difficulty tracks on course modules.
111
     * Set up difficulty tracks on course modules.
125
     * @param {Number} courseId Course ID.
112
     * @param {Number} courseId Course ID.
126
     * @param {Array} modulesWithReactions Array of reactions state, one entry for each course module with reactions enabled.
113
     * @param {Array} modulesWithReactions Array of reactions state, one entry for each course module with reactions enabled.
127
     * @param {String} reactionsHtml HTML fragment for reactions.
114
     * @param {String} reactionsHtml HTML fragment for reactions.
128
     * @param {Array} pixSrc Array of pictures sources for group images.
115
     * @param {Array} pixSrc Array of pictures sources for group images.
129
     * @param {Number|null} cmid The course module ID, if this page is a module view.
-
 
130
     */
116
     */
131
    function setUpReactions(courseId, modulesWithReactions, reactionsHtml, pixSrc, cmid) {
117
    function setUpReactions(courseId, modulesWithReactions, reactionsHtml, pixSrc) {
132
        // For each selected module, create a reaction zone.
118
        // For each selected module, create a reaction zone.
133
        modulesWithReactions.forEach(function(module) {
119
        modulesWithReactions.forEach(function(module) {
134
            var moduleId = parseInt(module.cmid);
120
            var moduleId = parseInt(module.cmid);
135
            var uservote = parseInt(module.uservote);
121
            var uservote = parseInt(module.uservote);
Línea 136... Línea 122...
136
 
122
 
137
            // Initialise reactionVotedArray.
123
            // Initialise reactionVotedArray.
Línea 138... Línea -...
138
            reactionVotedArray[moduleId] = uservote;
-
 
139
 
-
 
140
            if (module.cmid === cmid) {
-
 
141
                // Simulate an activity row on course page (so we treat it the same for what's next).
-
 
142
                $('<div id="module-' + moduleId + '" class="activity-wrapper mr-5" style="width: 165px;">')
-
 
143
                .insertAfter($('.header-actions-container'))
-
 
144
                .prepend('<div class="activity-instance">');
-
 
145
            }
124
            reactionVotedArray[moduleId] = uservote;
Línea 146... Línea 125...
146
 
125
 
147
            if ($('#module-' + moduleId).length === 1 && $get(moduleId).length === 0) {
-
 
148
 
-
 
149
                // Add the reaction zone to the module.
-
 
150
                var $module = $('#module-' + moduleId);
-
 
151
                if ($module.is('.modtype_label')) {
-
 
152
                    // Label.
-
 
153
                    $module.find('.description, .activity-grid').first().before(reactionsHtml);
-
 
154
                } else if ($module.find('.tiles-activity-container').length) {
-
 
155
                    // Tiles format.
126
            if ($('#module-' + moduleId).length === 1 && $get(moduleId).length === 0) {
156
                    $module.find('.tiles-activity-container').after(reactionsHtml);
-
 
Línea 157... Línea 127...
157
                } else {
127
 
158
                    $module.find('.activity-instance').after(reactionsHtml);
128
                // Add the reaction zone to the module.
159
                }
129
                $('#module-' + moduleId).prepend(reactionsHtml);
160
 
130
 
Línea 316... Línea 286...
316
            .animate(groupImageSizeForRatio(0), 300)
286
            .animate(groupImageSizeForRatio(0), 300)
317
            .hide(0);
287
            .hide(0);
Línea 318... Línea 288...
318
 
288
 
Línea 319... Línea 289...
319
            $get(moduleId, '.group_nb').delay(200).hide(300);
289
            $get(moduleId, '.group_nb').delay(200).hide(300);
320
 
-
 
321
            $('#module-' + moduleId + ' button[data-action="toggle-manual-completion"],' +
-
 
322
              '#module-' + moduleId + ' .activity-info .automatic-completion-conditions > span.badge:first-of-type,' +
-
 
323
              '#module-' + moduleId + ' .activity-information [data-region="completionrequirements"]')
-
 
324
            .delay(200).queue(function(next) {
-
 
325
                // Use opacity transition for a smooth hiding.
-
 
326
                $(this).css({
-
 
327
                    opacity: 0,
-
 
328
                    transition: 'opacity 0.3s ease-in-out'
-
 
329
                });
-
 
330
                next();
-
 
331
            }).delay(300).queue(function(next) {
-
 
332
                // Actually make the element invisible to avoid accidental clicking on transparent element.
-
 
333
                $(this).addClass('invisible');
-
 
Línea 334... Línea 290...
334
                next();
290
 
335
            });
291
            $('#module-' + moduleId + ' .actions').delay(200).hide(300);
Línea 336... Línea 292...
336
 
292
 
Línea 377... Línea 333...
377
            })
333
            })
378
            .css({'pointer-events': 'auto'});
334
            .css({'pointer-events': 'auto'});
Línea 379... Línea 335...
379
 
335
 
Línea 380... Línea 336...
380
            $get(moduleId, '.group_nb').delay(600).show(0);
336
            $get(moduleId, '.group_nb').delay(600).show(0);
381
 
-
 
382
            $('#module-' + moduleId + ' button[data-action="toggle-manual-completion"],' +
-
 
383
              '#module-' + moduleId + ' .activity-info .automatic-completion-conditions > span.badge:first-of-type,' +
-
 
384
              '#module-' + moduleId + ' .activity-information [data-region="completionrequirements"]')
-
 
385
            .delay(600).queue(function(next) {
-
 
386
                $(this).removeClass('invisible');
-
 
387
                // Use opacity transition for a smooth showing back.
-
 
388
                $(this).css({
-
 
389
                    opacity: 1,
-
 
390
                    transition: 'opacity 0.3s ease-in-out'
-
 
391
                });
-
 
392
                next();
337
 
Línea 393... Línea 338...
393
            });
338
            $('#module-' + moduleId + ' .actions').delay(600).show(300);
394
        };
339
        };
395
 
340
 
Línea 453... Línea 398...
453
            // Wait that the DOM is fully loaded.
398
            // Wait that the DOM is fully loaded.
454
            $(function() {
399
            $(function() {
Línea 455... Línea 400...
455
 
400
 
Línea 456... Línea -...
456
                var blockData = $('.block_point_view[data-blockdata]').data('blockdata');
-
 
457
 
-
 
458
                var cmid = null; // If this page is a course module view, retrieve the module ID.
-
 
459
                document.body.classList.forEach(function(bodyClass) {
-
 
460
                    var matches = bodyClass.match(/cmid-(\d+)/);
-
 
461
                    cmid = matches ? matches[1] : cmid;
-
 
462
                });
401
                var blockData = $('.block_point_view[data-blockdata]').data('blockdata');
463
 
402
 
464
                callOnModulesListLoad(function() {
403
                callOnModulesListLoad(function() {
465
                    setUpDifficultyTracks(blockData.difficultylevels, blockData.trackcolors, cmid);
404
                    setUpDifficultyTracks(blockData.difficultylevels, blockData.trackcolors);
Línea 466... Línea 405...
466
                    setUpReactions(courseId, blockData.moduleswithreactions, blockData.reactionstemplate, blockData.pix, cmid);
405
                    setUpReactions(courseId, blockData.moduleswithreactions, blockData.reactionstemplate, blockData.pix);
467
                });
406
                });
468
 
407