Proyectos de Subversion Moodle

Rev

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

Rev 5 Rev 6
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.
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.
55
     */
56
     */
56
    function setUpDifficultyTracks(difficultyLevels, trackColors) {
57
    function setUpDifficultyTracks(difficultyLevels, trackColors, cmid) {
57
        difficultyLevels.forEach(function(module) {
58
        difficultyLevels.forEach(function(module) {
58
            var difficultyLevel = parseInt(module.difficultyLevel);
59
            var difficultyLevel = parseInt(module.difficultyLevel);
59
            var title = '';
60
            var title = '';
60
            if (difficultyLevel > 0) {
61
            if (difficultyLevel > 0) {
Línea 65... Línea 66...
65
                'class': 'block_point_view track',
66
                'class': 'block_point_view track',
66
                'title': title,
67
                'title': title,
67
                'style': 'background-color: ' + trackColors[difficultyLevel] + ';'
68
                'style': 'background-color: ' + trackColors[difficultyLevel] + ';'
68
            });
69
            });
69
            // Decide where to put the track.
70
            // Decide where to put the track.
70
            var $container = $('#module-' + module.id + ' .mod-indent-outer');
71
            var $container = $('#module-' + module.id + ' .activitytitle');
-
 
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 71... Línea 81...
71
 
81
 
72
            // Add the track.
82
            // Add the track.
73
            if ($container.find('.block_point_view.track').length === 0) {
83
            if ($container.find('.block_point_view.track').length === 0) {
74
                $container.prepend($track);
84
                $container.prepend($track);
75
            }
85
            }
76
            // If there is indentation, move the track after it.
86
            // If there is indentation, move the track after it.
Línea -... Línea 87...
-
 
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.
77
            $container.find('.mod-indent').after($track);
91
                $('.page-context-header').prepend($track);
78
 
92
            }
Línea 79... Línea -...
79
        });
-
 
80
    }
93
        });
81
 
94
    }
82
 
95
 
83
    /**
96
    /**
84
     * Get a jQuery object in reaction zone for given module ID.
97
     * Get a jQuery object in reaction zone for given module ID.
Línea 111... Línea 124...
111
     * Set up difficulty tracks on course modules.
124
     * Set up difficulty tracks on course modules.
112
     * @param {Number} courseId Course ID.
125
     * @param {Number} courseId Course ID.
113
     * @param {Array} modulesWithReactions Array of reactions state, one entry for each course module with reactions enabled.
126
     * @param {Array} modulesWithReactions Array of reactions state, one entry for each course module with reactions enabled.
114
     * @param {String} reactionsHtml HTML fragment for reactions.
127
     * @param {String} reactionsHtml HTML fragment for reactions.
115
     * @param {Array} pixSrc Array of pictures sources for group images.
128
     * @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.
116
     */
130
     */
117
    function setUpReactions(courseId, modulesWithReactions, reactionsHtml, pixSrc) {
131
    function setUpReactions(courseId, modulesWithReactions, reactionsHtml, pixSrc, cmid) {
118
        // For each selected module, create a reaction zone.
132
        // For each selected module, create a reaction zone.
119
        modulesWithReactions.forEach(function(module) {
133
        modulesWithReactions.forEach(function(module) {
120
            var moduleId = parseInt(module.cmid);
134
            var moduleId = parseInt(module.cmid);
121
            var uservote = parseInt(module.uservote);
135
            var uservote = parseInt(module.uservote);
Línea 122... Línea 136...
122
 
136
 
123
            // Initialise reactionVotedArray.
137
            // Initialise reactionVotedArray.
Línea -... Línea 138...
-
 
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">');
124
            reactionVotedArray[moduleId] = uservote;
145
            }
Línea 125... Línea 146...
125
 
146
 
-
 
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) {
126
            if ($('#module-' + moduleId).length === 1 && $get(moduleId).length === 0) {
155
                    // Tiles format.
-
 
156
                    $module.find('.tiles-activity-container').after(reactionsHtml);
Línea 127... Línea 157...
127
 
157
                } else {
128
                // Add the reaction zone to the module.
158
                    $module.find('.activity-instance').after(reactionsHtml);
129
                $('#module-' + moduleId).prepend(reactionsHtml);
159
                }
130
 
160
 
Línea 286... Línea 316...
286
            .animate(groupImageSizeForRatio(0), 300)
316
            .animate(groupImageSizeForRatio(0), 300)
287
            .hide(0);
317
            .hide(0);
Línea 288... Línea 318...
288
 
318
 
Línea 289... Línea 319...
289
            $get(moduleId, '.group_nb').delay(200).hide(300);
319
            $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 290... Línea 334...
290
 
334
                next();
291
            $('#module-' + moduleId + ' .actions').delay(200).hide(300);
335
            });
Línea 292... Línea 336...
292
 
336
 
Línea 333... Línea 377...
333
            })
377
            })
334
            .css({'pointer-events': 'auto'});
378
            .css({'pointer-events': 'auto'});
Línea 335... Línea 379...
335
 
379
 
Línea 336... Línea 380...
336
            $get(moduleId, '.group_nb').delay(600).show(0);
380
            $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
                });
337
 
392
                next();
Línea 338... Línea 393...
338
            $('#module-' + moduleId + ' .actions').delay(600).show(300);
393
            });
339
        };
394
        };
340
 
395
 
Línea 398... Línea 453...
398
            // Wait that the DOM is fully loaded.
453
            // Wait that the DOM is fully loaded.
399
            $(function() {
454
            $(function() {
Línea 400... Línea 455...
400
 
455
 
Línea -... Línea 456...
-
 
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;
401
                var blockData = $('.block_point_view[data-blockdata]').data('blockdata');
462
                });
402
 
463
 
403
                callOnModulesListLoad(function() {
464
                callOnModulesListLoad(function() {
404
                    setUpDifficultyTracks(blockData.difficultylevels, blockData.trackcolors);
465
                    setUpDifficultyTracks(blockData.difficultylevels, blockData.trackcolors, cmid);
Línea 405... Línea 466...
405
                    setUpReactions(courseId, blockData.moduleswithreactions, blockData.reactionstemplate, blockData.pix);
466
                    setUpReactions(courseId, blockData.moduleswithreactions, blockData.reactionstemplate, blockData.pix, cmid);
406
                });
467
                });
407
 
468