Skip to content

Commit

Permalink
Merge branch 'MDL-71664-master-v04' of git://github.com/ferranrecio/m…
Browse files Browse the repository at this point in the history
…oodle
  • Loading branch information
junpataleta committed Sep 22, 2021
2 parents 0e979b8 + 23499e6 commit ed0d7ef
Show file tree
Hide file tree
Showing 19 changed files with 395 additions and 38 deletions.
2 changes: 1 addition & 1 deletion course/amd/build/actions.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion course/amd/build/actions.min.js.map

Large diffs are not rendered by default.

35 changes: 26 additions & 9 deletions course/amd/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,15 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
* @returns {Integer}
*/
var getModuleId = function(element) {
var id;
// Check if we have a data-id first.
const item = element.get(0);
if (item.dataset.id) {
return item.dataset.id;
}
// Use YUI way if data-id is not present.
let id;
Y.use('moodle-course-util', function(Y) {
id = Y.Moodle.core_course.util.cm.getId(Y.Node(element.get(0)));
id = Y.Moodle.core_course.util.cm.getId(Y.Node(item));
});
return id;
};
Expand All @@ -75,6 +81,12 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
Y.use('moodle-course-util', function(Y) {
name = Y.Moodle.core_course.util.cm.getName(Y.Node(element.get(0)));
});
// Check if we have the name in the course state.
const state = courseeditor.state;
const cmid = getModuleId(element);
if (!name && state && cmid) {
name = state.cm.get(cmid)?.name;
}
return name;
};

Expand Down Expand Up @@ -282,6 +294,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
* @param {JQuery|Element} element
* @param {Number} cmid
* @param {Number} sectionreturn
* @return {Promise} the refresh promise
*/
var refreshModule = function(element, cmid, sectionreturn) {
const activityElement = $(element);
Expand All @@ -291,13 +304,17 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
args: {id: cmid, sectionreturn: sectionreturn}
}], true);

$.when.apply($, promises)
.done(function(data) {
removeSpinner(activityElement, spinner, 400);
replaceActivityHtmlWith(data);
}).fail(function() {
removeSpinner(activityElement, spinner);
});
return new Promise((resolve, reject) => {
$.when.apply($, promises)
.done(function(data) {
removeSpinner(activityElement, spinner, 400);
replaceActivityHtmlWith(data);
resolve(data);
}).fail(function() {
removeSpinner(activityElement, spinner);
reject();
});
});
};

/**
Expand Down
2 changes: 1 addition & 1 deletion course/format/amd/build/local/content.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ed0d7ef

Please sign in to comment.