Merge branch 'MDL-79548-master' of https://github.com/mickhawkins/moodle

This commit is contained in:
Huong Nguyen
2023-10-04 10:21:41 +07:00
9 changed files with 18 additions and 25 deletions
+1
View File
@@ -103,3 +103,4 @@ completionview_desc,mod_bigbluebuttonbn
activitygradenotrequired,core_completion
completionpassgrade_help,core_completion
completionusegrade_help,core_completion
moodlenet:sharetyperesource,core
+4 -3
View File
@@ -1394,8 +1394,9 @@ $string['moodlenet:issuerisnotenabled'] = 'MoodleNet issuer is not enabled';
$string['moodlenet:issuerisnotset'] = 'MoodleNet issuer is not set at site administration';
$string['moodlenet:nosharedresources'] = 'There are no shared resources to display at this time.';
$string['moodlenet:outboundsettings'] = 'MoodleNet outbound settings';
$string['moodlenet:sharenotice'] = 'This {$a->type} is being shared with MoodleNet as a {$a->sharetype}.';
$string['moodlenet:sharenoticepartial'] = 'The selected activities are being shared with MoodleNet as a {$a}.';
$string['moodlenet:sharenoticeactivity'] = 'This activity is being shared with MoodleNet as a resource.';
$string['moodlenet:sharenoticecourse'] = 'This course is being shared with MoodleNet as a resource.';
$string['moodlenet:sharenoticepartial'] = 'The selected activities are being shared with MoodleNet as a resource.';
$string['moodlenet:sharenoticepartialactivitynumber'] = '{$a} activities will be included in the course.';
$string['moodlenet:sharefailtitle'] = 'Something went wrong';
$string['moodlenet:sharefailtext'] = 'There was an error sharing your content to MoodleNet.<br>Please try again later.';
@@ -1406,7 +1407,6 @@ $string['moodlenet:shareprogressinfo'] = 'The list shows courses and activities
$string['moodlenet:sharesuccesstitle'] = 'Saved to MoodleNet drafts';
$string['moodlenet:sharesuccesstext'] = "Almost done! Visit your drafts in MoodleNet to finish sharing your content.";
$string['moodlenet:sharetomoodlenet'] = 'Share to MoodleNet';
$string['moodlenet:sharetyperesource'] = 'resource';
$string['moodlenet:sharingstatus'] = 'Sharing to MoodleNet';
$string['moodlenet:sharinglargefile'] = "Large files can take some time.";
$string['moodlenet:sharingto'] = 'Sharing to: ';
@@ -2482,3 +2482,4 @@ $string['supplyinfo'] = 'More details';
$string['clicktochangeinbrackets'] = '{$a} (Click to change)';
$string['modshowcmtitle'] = 'Show activity';
$string['makeavailablecmtitle'] = 'Make activity available';
$string['moodlenet:sharetyperesource'] = 'resource';
+1 -1
View File
@@ -1,3 +1,3 @@
define("core/moodlenet/mutations",["exports","core_courseformat/local/courseeditor/mutations","core_courseformat/courseeditor","core_courseformat/local/content/actions","core/pubsub","core/moodlenet/send_resource","core/moodlenet/events"],(function(_exports,_mutations,_courseeditor,_actions,_pubsub,_send_resource,_events){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_mutations=_interopRequireDefault(_mutations),_actions=_interopRequireDefault(_actions),_events=_interopRequireDefault(_events);class MoodleNetMutations extends _mutations.default{constructor(){var obj,key,value;super(...arguments),value=async function(stateManager,cmIds){this.cmLock(stateManager,cmIds,!0),(0,_send_resource.handleModal)("partial","resource",cmIds),this.cmLock(stateManager,cmIds,!1),(0,_pubsub.subscribe)(_events.default.MOODLENET_SHARE_STARTED,(()=>{this.bulkReset(stateManager)}))},(key="shareToMoodleNet")in(obj=this)?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value}}_exports.init=()=>{(0,_courseeditor.getCurrentCourseEditor)().addMutations(new MoodleNetMutations),_actions.default.addActions({cmShareToMoodleNet:"shareToMoodleNet"})}}));
define("core/moodlenet/mutations",["exports","core_courseformat/local/courseeditor/mutations","core_courseformat/courseeditor","core_courseformat/local/content/actions","core/pubsub","core/moodlenet/send_resource","core/moodlenet/events"],(function(_exports,_mutations,_courseeditor,_actions,_pubsub,_send_resource,_events){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_mutations=_interopRequireDefault(_mutations),_actions=_interopRequireDefault(_actions),_events=_interopRequireDefault(_events);class MoodleNetMutations extends _mutations.default{constructor(){var obj,key,value;super(...arguments),value=async function(stateManager,cmIds){this.cmLock(stateManager,cmIds,!0),(0,_send_resource.handleModal)("partial",cmIds),this.cmLock(stateManager,cmIds,!1),(0,_pubsub.subscribe)(_events.default.MOODLENET_SHARE_STARTED,(()=>{this.bulkReset(stateManager)}))},(key="shareToMoodleNet")in(obj=this)?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value}}_exports.init=()=>{(0,_courseeditor.getCurrentCourseEditor)().addMutations(new MoodleNetMutations),_actions.default.addActions({cmShareToMoodleNet:"shareToMoodleNet"})}}));
//# sourceMappingURL=mutations.min.js.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"mutations.min.js","sources":["../../src/moodlenet/mutations.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * MoodleNet mutations.\n * An instance of this class will be used to add custom mutations to the course editor.\n *\n * @module core/moodlenet/mutations\n * @copyright 2023 Huong Nguyen <[email protected]>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 4.3\n */\n\nimport DefaultMutations from 'core_courseformat/local/courseeditor/mutations';\nimport {getCurrentCourseEditor} from 'core_courseformat/courseeditor';\nimport CourseActions from 'core_courseformat/local/content/actions';\nimport {subscribe} from 'core/pubsub';\nimport {handleModal} from 'core/moodlenet/send_resource';\nimport MoodleNetEvents from 'core/moodlenet/events';\n\nclass MoodleNetMutations extends DefaultMutations {\n\n /**\n * Share to MoodleNet.\n *\n * @param {StateManager} stateManager the current state manager\n * @param {array} cmIds Course module ids.\n */\n shareToMoodleNet = async function(stateManager, cmIds) {\n this.cmLock(stateManager, cmIds, true);\n handleModal('partial', 'resource', cmIds);\n this.cmLock(stateManager, cmIds, false);\n subscribe(MoodleNetEvents.MOODLENET_SHARE_STARTED, () => {\n // Only clear the selection if the user starts the sharing.\n this.bulkReset(stateManager);\n });\n };\n}\n\n/**\n * Initialize.\n */\nexport const init = () => {\n const courseEditor = getCurrentCourseEditor();\n courseEditor.addMutations(new MoodleNetMutations());\n // Add direct mutation content actions.\n CourseActions.addActions({\n cmShareToMoodleNet: 'shareToMoodleNet'\n });\n};\n"],"names":["MoodleNetMutations","DefaultMutations","async","stateManager","cmIds","cmLock","MoodleNetEvents","MOODLENET_SHARE_STARTED","bulkReset","addMutations","addActions","cmShareToMoodleNet"],"mappings":"ymBAgCMA,2BAA2BC,6EAQVC,eAAeC,aAAcC,YACvCC,OAAOF,aAAcC,OAAO,kCACrB,UAAW,WAAYA,YAC9BC,OAAOF,aAAcC,OAAO,yBACvBE,gBAAgBC,yBAAyB,UAE1CC,UAAUL,4KAQP,MACK,0CACRM,aAAa,IAAIT,qCAEhBU,WAAW,CACrBC,mBAAoB"}
{"version":3,"file":"mutations.min.js","sources":["../../src/moodlenet/mutations.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * MoodleNet mutations.\n * An instance of this class will be used to add custom mutations to the course editor.\n *\n * @module core/moodlenet/mutations\n * @copyright 2023 Huong Nguyen <[email protected]>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 4.3\n */\n\nimport DefaultMutations from 'core_courseformat/local/courseeditor/mutations';\nimport {getCurrentCourseEditor} from 'core_courseformat/courseeditor';\nimport CourseActions from 'core_courseformat/local/content/actions';\nimport {subscribe} from 'core/pubsub';\nimport {handleModal} from 'core/moodlenet/send_resource';\nimport MoodleNetEvents from 'core/moodlenet/events';\n\nclass MoodleNetMutations extends DefaultMutations {\n\n /**\n * Share to MoodleNet.\n *\n * @param {StateManager} stateManager the current state manager\n * @param {array} cmIds Course module ids.\n */\n shareToMoodleNet = async function(stateManager, cmIds) {\n this.cmLock(stateManager, cmIds, true);\n handleModal('partial', cmIds);\n this.cmLock(stateManager, cmIds, false);\n subscribe(MoodleNetEvents.MOODLENET_SHARE_STARTED, () => {\n // Only clear the selection if the user starts the sharing.\n this.bulkReset(stateManager);\n });\n };\n}\n\n/**\n * Initialize.\n */\nexport const init = () => {\n const courseEditor = getCurrentCourseEditor();\n courseEditor.addMutations(new MoodleNetMutations());\n // Add direct mutation content actions.\n CourseActions.addActions({\n cmShareToMoodleNet: 'shareToMoodleNet'\n });\n};\n"],"names":["MoodleNetMutations","DefaultMutations","async","stateManager","cmIds","cmLock","MoodleNetEvents","MOODLENET_SHARE_STARTED","bulkReset","addMutations","addActions","cmShareToMoodleNet"],"mappings":"ymBAgCMA,2BAA2BC,6EAQVC,eAAeC,aAAcC,YACvCC,OAAOF,aAAcC,OAAO,kCACrB,UAAWA,YAClBC,OAAOF,aAAcC,OAAO,yBACvBE,gBAAgBC,yBAAyB,UAE1CC,UAAUL,4KAQP,MACK,0CACRM,aAAa,IAAIT,qCAEhBU,WAAW,CACrBC,mBAAoB"}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -40,7 +40,7 @@ class MoodleNetMutations extends DefaultMutations {
*/
shareToMoodleNet = async function(stateManager, cmIds) {
this.cmLock(stateManager, cmIds, true);
handleModal('partial', 'resource', cmIds);
handleModal('partial', cmIds);
this.cmLock(stateManager, cmIds, false);
subscribe(MoodleNetEvents.MOODLENET_SHARE_STARTED, () => {
// Only clear the selection if the user starts the sharing.
+8 -15
View File
@@ -109,10 +109,9 @@ const responseFromMoodleNet = (status, resourceUrl = '') => {
* Render the modal to send resource to MoodleNet.
*
* @param {object} data The data of the resource to be shared.
* @param {string} shareType The type of the resource to be shared.
* @param {array} selectedActivities Selected activities.
*/
const renderModal = async(data, shareType, selectedActivities) => {
const renderModal = async(data, selectedActivities) => {
if (data.status) {
siteSupportUrl = data.supportpageurl;
issuerId = data.issuerid;
@@ -123,7 +122,6 @@ const renderModal = async(data, shareType, selectedActivities) => {
'server': data.server,
}
};
const sharetype = await getString('moodlenet:sharetype' + shareType, 'moodle');
if (selectedActivities.length > 0) {
selectedCmIds = selectedActivities;
}
@@ -131,16 +129,13 @@ const renderModal = async(data, shareType, selectedActivities) => {
modalConfig.templateContext.fullsharing = false;
modalConfig.templateContext.selectedactivitiesnotice = await getString('moodlenet:sharenoticepartialactivitynumber',
'moodle', selectedActivities.length);
modalConfig.templateContext.sharenotice = await getString('moodlenet:sharenoticepartial',
'moodle', sharetype);
modalConfig.templateContext.sharenotice = await getString('moodlenet:sharenoticepartial', 'moodle');
} else {
modalConfig.templateContext.fullsharing = true;
if (type === TYPE_PARTIAL_COURSE && selectedActivities.length == 1) {
modalConfig.templateContext.sharenotice = await getString('moodlenet:sharenotice',
'moodle', {'type': TYPE_ACTIVITY, 'sharetype': sharetype});
if (type === TYPE_ACTIVITY || (type === TYPE_PARTIAL_COURSE && selectedActivities.length == 1)) {
modalConfig.templateContext.sharenotice = await getString('moodlenet:sharenoticeactivity', 'moodle');
} else {
modalConfig.templateContext.sharenotice = await getString('moodlenet:sharenotice',
'moodle', {'type': type, 'sharetype': sharetype});
modalConfig.templateContext.sharenotice = await getString('moodlenet:sharenoticecourse', 'moodle');
}
}
@@ -156,10 +151,9 @@ const renderModal = async(data, shareType, selectedActivities) => {
/**
* Handle modal.
* @param {string} shareActionType Share action type.
* @param {string} shareType Share type.
* @param {array} selectedActivities Selected activities.
*/
export const handleModal = (shareActionType, shareType, selectedActivities = []) => {
export const handleModal = (shareActionType, selectedActivities = []) => {
const resourceId = Config.contextInstanceId;
type = shareActionType;
@@ -181,7 +175,7 @@ export const handleModal = (shareActionType, shareType, selectedActivities = [])
throw new Error(`Unknown type ${type}`);
})
.then((data) => {
return renderModal(data, shareType, selectedActivities);
return renderModal(data, selectedActivities);
})
.then((modal) => {
currentModal = modal;
@@ -200,8 +194,7 @@ const registerEventListeners = () => {
if (shareAction) {
e.preventDefault();
type = shareAction.getAttribute('data-type');
const shareType = shareAction.getAttribute('data-sharetype');
handleModal(shareAction.getAttribute('data-type'), shareType);
handleModal(shareAction.getAttribute('data-type'));
}
if (sendAction) {
-2
View File
@@ -4650,7 +4650,6 @@ class settings_navigation extends navigation_node {
$action = new action_link(new moodle_url(''), '', null, [
'data-action' => 'sendtomoodlenet',
'data-type' => 'course',
'data-sharetype' => 'resource',
]);
// Share course to MoodleNet link.
$coursenode->add(get_string('moodlenet:sharetomoodlenet', 'moodle'),
@@ -4942,7 +4941,6 @@ class settings_navigation extends navigation_node {
$action = new action_link(new moodle_url(''), '', null, [
'data-action' => 'sendtomoodlenet',
'data-type' => 'activity',
'data-sharetype' => 'resource',
]);
$modulenode->add(get_string('moodlenet:sharetomoodlenet', 'moodle'),
$action, self::TYPE_SETTING, null, 'exportmoodlenet')->set_force_into_more_menu(true);