diff --git a/lang/en/deprecated.txt b/lang/en/deprecated.txt index c4c60e30b82..012032d1f34 100644 --- a/lang/en/deprecated.txt +++ b/lang/en/deprecated.txt @@ -103,3 +103,4 @@ completionview_desc,mod_bigbluebuttonbn activitygradenotrequired,core_completion completionpassgrade_help,core_completion completionusegrade_help,core_completion +moodlenet:sharetyperesource,core diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 944dd0d93b8..f6393b22928 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -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.
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'; diff --git a/lib/amd/build/moodlenet/mutations.min.js b/lib/amd/build/moodlenet/mutations.min.js index b4170c68d64..bcc097e333a 100644 --- a/lib/amd/build/moodlenet/mutations.min.js +++ b/lib/amd/build/moodlenet/mutations.min.js @@ -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 \ No newline at end of file diff --git a/lib/amd/build/moodlenet/mutations.min.js.map b/lib/amd/build/moodlenet/mutations.min.js.map index d558041af21..76dcde6de55 100644 --- a/lib/amd/build/moodlenet/mutations.min.js.map +++ b/lib/amd/build/moodlenet/mutations.min.js.map @@ -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 .\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 \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"} \ No newline at end of file +{"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 .\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 \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"} \ No newline at end of file diff --git a/lib/amd/build/moodlenet/send_resource.min.js b/lib/amd/build/moodlenet/send_resource.min.js index 4f1e51ed113..f1db101faed 100644 --- a/lib/amd/build/moodlenet/send_resource.min.js +++ b/lib/amd/build/moodlenet/send_resource.min.js @@ -6,6 +6,6 @@ define("core/moodlenet/send_resource",["exports","core/config","core/notificatio * @copyright 2023 Huong Nguyen * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @since 4.2 - */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.sendToMoodleNet=_exports.init=_exports.handleModal=void 0,_config=_interopRequireDefault(_config),_prefetch=_interopRequireDefault(_prefetch),Templates=_interopRequireWildcard(Templates),MoodleNetService=_interopRequireWildcard(MoodleNetService),_send_activity_modal=_interopRequireDefault(_send_activity_modal),MoodleNetAuthorize=_interopRequireWildcard(MoodleNetAuthorize),_events=_interopRequireDefault(_events);let currentModal,siteSupportUrl,issuerId,courseId,resourceId,shareFormat,type,selectedCmIds,listenersRegistered=!1;_exports.sendToMoodleNet=(issuerId,resourceId,shareFormat)=>{const modal=currentModal.getModal()[0];let infoPromise;modal.querySelector(".modal-header").classList.remove("no-border"),modal.querySelector(".modal-header").classList.add("no-header-text"),currentModal.setBody(Templates.render("core/moodlenet/send_activity_modal_packaging",{})),currentModal.hideFooter(),"activity"===type?infoPromise=MoodleNetService.sendActivity(issuerId,resourceId,shareFormat):"course"===type?infoPromise=MoodleNetService.sendCourse(issuerId,resourceId,shareFormat):"partial"===type&&(infoPromise=selectedCmIds.length>1?MoodleNetService.sendPartialCourse(issuerId,resourceId,selectedCmIds,shareFormat):MoodleNetService.sendActivity(issuerId,selectedCmIds[0],shareFormat)),infoPromise.then((async data=>{const status=data.status,resourceUrl=data.resourceurl;return responseFromMoodleNet(status,resourceUrl)})).catch(_notification.exception)};const responseFromMoodleNet=function(status){let resourceUrl=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const $modal=currentModal.getModal(),modal=$modal[0];modal.querySelector(".modal-header").classList.add("no-border"),currentModal.setBody(Templates.render("core/moodlenet/send_activity_modal_done",{success:status,sitesupporturl:siteSupportUrl})),status&&(currentModal.setFooter(Templates.render("core/moodlenet/send_activity_modal_footer_view",{resourceurl:resourceUrl})),currentModal.showFooter())},renderModal=async(data,shareType,selectedActivities)=>{if(data.status){siteSupportUrl=data.supportpageurl,issuerId=data.issuerid;let modalConfig={templateContext:{activitytype:data.type,activityname:data.name,server:data.server}};const sharetype=await(0,_str.getString)("moodlenet:sharetype"+shareType,"moodle");return selectedActivities.length>0&&(selectedCmIds=selectedActivities),selectedActivities.length>1?(modalConfig.templateContext.fullsharing=!1,modalConfig.templateContext.selectedactivitiesnotice=await(0,_str.getString)("moodlenet:sharenoticepartialactivitynumber","moodle",selectedActivities.length),modalConfig.templateContext.sharenotice=await(0,_str.getString)("moodlenet:sharenoticepartial","moodle",sharetype)):(modalConfig.templateContext.fullsharing=!0,"partial"===type&&1==selectedActivities.length?modalConfig.templateContext.sharenotice=await(0,_str.getString)("moodlenet:sharenotice","moodle",{type:"activity",sharetype:sharetype}):modalConfig.templateContext.sharenotice=await(0,_str.getString)("moodlenet:sharenotice","moodle",{type:type,sharetype:sharetype})),_send_activity_modal.default.create(modalConfig)}return(0,_notification.addNotification)({message:data.warnings[0].message,type:"error"})},handleModal=function(shareActionType,shareType){let selectedActivities=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];const resourceId=_config.default.contextInstanceId;type=shareActionType,Promise.resolve(type).then((type=>{if("activity"===type)return MoodleNetService.getActivityInformation(resourceId);if("course"===type)return MoodleNetService.getCourseInformation(resourceId);if("partial"===type)return selectedActivities.length>1?MoodleNetService.getCourseInformation(resourceId):MoodleNetService.getActivityInformation(selectedActivities[0]);throw new Error("Unknown type ".concat(type))})).then((data=>renderModal(data,shareType,selectedActivities))).then((modal=>(currentModal=modal,currentModal))).catch(_notification.exception)};_exports.handleModal=handleModal;_exports.init=()=>{listenersRegistered||(_prefetch.default.prefetchTemplates(["core/moodlenet/send_activity_modal_base","core/moodlenet/send_activity_modal_packaging","core/moodlenet/send_activity_modal_done","core/moodlenet/send_activity_modal_footer_view","core/moodlenet/send_activity_modal_footer_share"]),document.addEventListener("click",(e=>{const shareAction=e.target.closest('[data-action="sendtomoodlenet"]'),sendAction=e.target.closest('.moodlenet-action-buttons [data-action="share"]');if(shareAction){e.preventDefault(),type=shareAction.getAttribute("data-type");const shareType=shareAction.getAttribute("data-sharetype");handleModal(shareAction.getAttribute("data-type"),shareType)}sendAction&&(e.preventDefault(),(0,_pubsub.publish)(_events.default.MOODLENET_SHARE_STARTED,{}),courseId=_config.default.courseId,resourceId=_config.default.contextInstanceId,shareFormat=0,MoodleNetAuthorize.handleAuthorization(issuerId,courseId,resourceId,0))})),listenersRegistered=!0)}})); + */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.sendToMoodleNet=_exports.init=_exports.handleModal=void 0,_config=_interopRequireDefault(_config),_prefetch=_interopRequireDefault(_prefetch),Templates=_interopRequireWildcard(Templates),MoodleNetService=_interopRequireWildcard(MoodleNetService),_send_activity_modal=_interopRequireDefault(_send_activity_modal),MoodleNetAuthorize=_interopRequireWildcard(MoodleNetAuthorize),_events=_interopRequireDefault(_events);let currentModal,siteSupportUrl,issuerId,courseId,resourceId,shareFormat,type,selectedCmIds,listenersRegistered=!1;_exports.sendToMoodleNet=(issuerId,resourceId,shareFormat)=>{const modal=currentModal.getModal()[0];let infoPromise;modal.querySelector(".modal-header").classList.remove("no-border"),modal.querySelector(".modal-header").classList.add("no-header-text"),currentModal.setBody(Templates.render("core/moodlenet/send_activity_modal_packaging",{})),currentModal.hideFooter(),"activity"===type?infoPromise=MoodleNetService.sendActivity(issuerId,resourceId,shareFormat):"course"===type?infoPromise=MoodleNetService.sendCourse(issuerId,resourceId,shareFormat):"partial"===type&&(infoPromise=selectedCmIds.length>1?MoodleNetService.sendPartialCourse(issuerId,resourceId,selectedCmIds,shareFormat):MoodleNetService.sendActivity(issuerId,selectedCmIds[0],shareFormat)),infoPromise.then((async data=>{const status=data.status,resourceUrl=data.resourceurl;return responseFromMoodleNet(status,resourceUrl)})).catch(_notification.exception)};const responseFromMoodleNet=function(status){let resourceUrl=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const $modal=currentModal.getModal(),modal=$modal[0];modal.querySelector(".modal-header").classList.add("no-border"),currentModal.setBody(Templates.render("core/moodlenet/send_activity_modal_done",{success:status,sitesupporturl:siteSupportUrl})),status&&(currentModal.setFooter(Templates.render("core/moodlenet/send_activity_modal_footer_view",{resourceurl:resourceUrl})),currentModal.showFooter())},renderModal=async(data,selectedActivities)=>{if(data.status){siteSupportUrl=data.supportpageurl,issuerId=data.issuerid;let modalConfig={templateContext:{activitytype:data.type,activityname:data.name,server:data.server}};return selectedActivities.length>0&&(selectedCmIds=selectedActivities),selectedActivities.length>1?(modalConfig.templateContext.fullsharing=!1,modalConfig.templateContext.selectedactivitiesnotice=await(0,_str.getString)("moodlenet:sharenoticepartialactivitynumber","moodle",selectedActivities.length),modalConfig.templateContext.sharenotice=await(0,_str.getString)("moodlenet:sharenoticepartial","moodle")):(modalConfig.templateContext.fullsharing=!0,"activity"===type||"partial"===type&&1==selectedActivities.length?modalConfig.templateContext.sharenotice=await(0,_str.getString)("moodlenet:sharenoticeactivity","moodle"):modalConfig.templateContext.sharenotice=await(0,_str.getString)("moodlenet:sharenoticecourse","moodle")),_send_activity_modal.default.create(modalConfig)}return(0,_notification.addNotification)({message:data.warnings[0].message,type:"error"})},handleModal=function(shareActionType){let selectedActivities=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const resourceId=_config.default.contextInstanceId;type=shareActionType,Promise.resolve(type).then((type=>{if("activity"===type)return MoodleNetService.getActivityInformation(resourceId);if("course"===type)return MoodleNetService.getCourseInformation(resourceId);if("partial"===type)return selectedActivities.length>1?MoodleNetService.getCourseInformation(resourceId):MoodleNetService.getActivityInformation(selectedActivities[0]);throw new Error("Unknown type ".concat(type))})).then((data=>renderModal(data,selectedActivities))).then((modal=>(currentModal=modal,currentModal))).catch(_notification.exception)};_exports.handleModal=handleModal;_exports.init=()=>{listenersRegistered||(_prefetch.default.prefetchTemplates(["core/moodlenet/send_activity_modal_base","core/moodlenet/send_activity_modal_packaging","core/moodlenet/send_activity_modal_done","core/moodlenet/send_activity_modal_footer_view","core/moodlenet/send_activity_modal_footer_share"]),document.addEventListener("click",(e=>{const shareAction=e.target.closest('[data-action="sendtomoodlenet"]'),sendAction=e.target.closest('.moodlenet-action-buttons [data-action="share"]');shareAction&&(e.preventDefault(),type=shareAction.getAttribute("data-type"),handleModal(shareAction.getAttribute("data-type"))),sendAction&&(e.preventDefault(),(0,_pubsub.publish)(_events.default.MOODLENET_SHARE_STARTED,{}),courseId=_config.default.courseId,resourceId=_config.default.contextInstanceId,shareFormat=0,MoodleNetAuthorize.handleAuthorization(issuerId,courseId,resourceId,0))})),listenersRegistered=!0)}})); //# sourceMappingURL=send_resource.min.js.map \ No newline at end of file diff --git a/lib/amd/build/moodlenet/send_resource.min.js.map b/lib/amd/build/moodlenet/send_resource.min.js.map index 783cdac3538..24fc26dd1c8 100644 --- a/lib/amd/build/moodlenet/send_resource.min.js.map +++ b/lib/amd/build/moodlenet/send_resource.min.js.map @@ -1 +1 @@ -{"version":3,"file":"send_resource.min.js","sources":["../../src/moodlenet/send_resource.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 .\n\n/**\n * A module to handle Share operations of the MoodleNet.\n *\n * @module core/moodlenet/send_resource\n * @copyright 2023 Huong Nguyen \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 4.2\n */\n\nimport Config from 'core/config';\nimport {addNotification, exception as displayException} from 'core/notification';\nimport {getString} from 'core/str';\nimport Prefetch from \"core/prefetch\";\nimport * as Templates from 'core/templates';\nimport {publish} from 'core/pubsub';\nimport * as MoodleNetService from 'core/moodlenet/service';\nimport SendActivityModal from 'core/moodlenet/send_activity_modal';\nimport * as MoodleNetAuthorize from 'core/moodlenet/authorize';\nimport MoodleNetEvents from 'core/moodlenet/events';\n\nconst TYPE_ACTIVITY = \"activity\";\nconst TYPE_COURSE = \"course\";\nconst TYPE_PARTIAL_COURSE = \"partial\";\n\nlet listenersRegistered = false;\nlet currentModal;\nlet siteSupportUrl;\nlet issuerId;\nlet courseId;\nlet resourceId;\nlet shareFormat;\nlet type;\nlet selectedCmIds;\n\n/**\n * Handle send to MoodleNet.\n *\n * @param {int} issuerId The OAuth 2 issuer ID.\n * @param {int} resourceId The resource ID, it can be a course or an activity.\n * @param {int} shareFormat The share format.\n */\nexport const sendToMoodleNet = (issuerId, resourceId, shareFormat) => {\n const $modal = currentModal.getModal();\n const modal = $modal[0];\n modal.querySelector('.modal-header').classList.remove('no-border');\n modal.querySelector('.modal-header').classList.add('no-header-text');\n\n currentModal.setBody(Templates.render('core/moodlenet/send_activity_modal_packaging', {}));\n currentModal.hideFooter();\n\n let infoPromise;\n if (type === TYPE_ACTIVITY) {\n infoPromise = MoodleNetService.sendActivity(issuerId, resourceId, shareFormat);\n } else if (type === TYPE_COURSE) {\n infoPromise = MoodleNetService.sendCourse(issuerId, resourceId, shareFormat);\n } else if (type === TYPE_PARTIAL_COURSE) {\n if (selectedCmIds.length > 1) {\n infoPromise = MoodleNetService.sendPartialCourse(issuerId, resourceId, selectedCmIds, shareFormat);\n } else {\n infoPromise = MoodleNetService.sendActivity(issuerId, selectedCmIds[0], shareFormat);\n }\n }\n infoPromise.then(async(data) => {\n const status = data.status;\n const resourceUrl = data.resourceurl;\n return responseFromMoodleNet(status, resourceUrl);\n }).catch(displayException);\n};\n\n/**\n * Handle response from MoodleNet.\n *\n * @param {boolean} status Response status. True if successful.\n * @param {String} resourceUrl Resource URL.\n */\nconst responseFromMoodleNet = (status, resourceUrl = '') => {\n const $modal = currentModal.getModal();\n const modal = $modal[0];\n modal.querySelector('.modal-header').classList.add('no-border');\n currentModal.setBody(Templates.render('core/moodlenet/send_activity_modal_done', {\n success: status,\n sitesupporturl: siteSupportUrl,\n }));\n\n if (status) {\n currentModal.setFooter(Templates.render('core/moodlenet/send_activity_modal_footer_view', {\n resourceurl: resourceUrl,\n }));\n currentModal.showFooter();\n }\n};\n\n/**\n * Render the modal to send resource to MoodleNet.\n *\n * @param {object} data The data of the resource to be shared.\n * @param {string} shareType The type of the resource to be shared.\n * @param {array} selectedActivities Selected activities.\n */\nconst renderModal = async(data, shareType, selectedActivities) => {\n if (data.status) {\n siteSupportUrl = data.supportpageurl;\n issuerId = data.issuerid;\n let modalConfig = {\n templateContext: {\n 'activitytype': data.type,\n 'activityname': data.name,\n 'server': data.server,\n }\n };\n const sharetype = await getString('moodlenet:sharetype' + shareType, 'moodle');\n if (selectedActivities.length > 0) {\n selectedCmIds = selectedActivities;\n }\n if (selectedActivities.length > 1) {\n modalConfig.templateContext.fullsharing = false;\n modalConfig.templateContext.selectedactivitiesnotice = await getString('moodlenet:sharenoticepartialactivitynumber',\n 'moodle', selectedActivities.length);\n modalConfig.templateContext.sharenotice = await getString('moodlenet:sharenoticepartial',\n 'moodle', sharetype);\n } else {\n modalConfig.templateContext.fullsharing = true;\n if (type === TYPE_PARTIAL_COURSE && selectedActivities.length == 1) {\n modalConfig.templateContext.sharenotice = await getString('moodlenet:sharenotice',\n 'moodle', {'type': TYPE_ACTIVITY, 'sharetype': sharetype});\n } else {\n modalConfig.templateContext.sharenotice = await getString('moodlenet:sharenotice',\n 'moodle', {'type': type, 'sharetype': sharetype});\n }\n }\n\n return SendActivityModal.create(modalConfig);\n } else {\n return addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n};\n\n/**\n * Handle modal.\n * @param {string} shareActionType Share action type.\n * @param {string} shareType Share type.\n * @param {array} selectedActivities Selected activities.\n */\nexport const handleModal = (shareActionType, shareType, selectedActivities = []) => {\n const resourceId = Config.contextInstanceId;\n type = shareActionType;\n\n Promise.resolve(type)\n .then((type) => {\n if (type === TYPE_ACTIVITY) {\n return MoodleNetService.getActivityInformation(resourceId);\n } else if (type === TYPE_COURSE) {\n return MoodleNetService.getCourseInformation(resourceId);\n } else if (type === TYPE_PARTIAL_COURSE) {\n if (selectedActivities.length > 1) {\n // Selected more than one activity.\n return MoodleNetService.getCourseInformation(resourceId);\n } else {\n // Select only one activity. Switch to activity mode.\n return MoodleNetService.getActivityInformation(selectedActivities[0]);\n }\n }\n throw new Error(`Unknown type ${type}`);\n })\n .then((data) => {\n return renderModal(data, shareType, selectedActivities);\n })\n .then((modal) => {\n currentModal = modal;\n return currentModal;\n })\n .catch(displayException);\n};\n\n/**\n * Register events.\n */\nconst registerEventListeners = () => {\n document.addEventListener('click', (e) => {\n const shareAction = e.target.closest('[data-action=\"sendtomoodlenet\"]');\n const sendAction = e.target.closest('.moodlenet-action-buttons [data-action=\"share\"]');\n if (shareAction) {\n e.preventDefault();\n type = shareAction.getAttribute('data-type');\n const shareType = shareAction.getAttribute('data-sharetype');\n handleModal(shareAction.getAttribute('data-type'), shareType);\n }\n\n if (sendAction) {\n e.preventDefault();\n publish(MoodleNetEvents.MOODLENET_SHARE_STARTED, {});\n courseId = Config.courseId;\n resourceId = Config.contextInstanceId;\n shareFormat = 0;\n MoodleNetAuthorize.handleAuthorization(issuerId, courseId, resourceId, shareFormat);\n }\n });\n};\n\n\n/**\n * Initialize.\n */\nexport const init = () => {\n if (!listenersRegistered) {\n Prefetch.prefetchTemplates([\n 'core/moodlenet/send_activity_modal_base',\n 'core/moodlenet/send_activity_modal_packaging',\n 'core/moodlenet/send_activity_modal_done',\n 'core/moodlenet/send_activity_modal_footer_view',\n 'core/moodlenet/send_activity_modal_footer_share',\n ]);\n registerEventListeners();\n listenersRegistered = true;\n }\n};\n"],"names":["currentModal","siteSupportUrl","issuerId","courseId","resourceId","shareFormat","type","selectedCmIds","listenersRegistered","modal","getModal","infoPromise","querySelector","classList","remove","add","setBody","Templates","render","hideFooter","MoodleNetService","sendActivity","sendCourse","length","sendPartialCourse","then","async","status","data","resourceUrl","resourceurl","responseFromMoodleNet","catch","displayException","$modal","success","sitesupporturl","setFooter","showFooter","renderModal","shareType","selectedActivities","supportpageurl","issuerid","modalConfig","templateContext","name","server","sharetype","fullsharing","selectedactivitiesnotice","sharenotice","SendActivityModal","create","message","warnings","handleModal","shareActionType","Config","contextInstanceId","Promise","resolve","getActivityInformation","getCourseInformation","Error","prefetchTemplates","document","addEventListener","e","shareAction","target","closest","sendAction","preventDefault","getAttribute","MoodleNetEvents","MOODLENET_SHARE_STARTED","MoodleNetAuthorize","handleAuthorization"],"mappings":"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"} \ No newline at end of file +{"version":3,"file":"send_resource.min.js","sources":["../../src/moodlenet/send_resource.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 .\n\n/**\n * A module to handle Share operations of the MoodleNet.\n *\n * @module core/moodlenet/send_resource\n * @copyright 2023 Huong Nguyen \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 4.2\n */\n\nimport Config from 'core/config';\nimport {addNotification, exception as displayException} from 'core/notification';\nimport {getString} from 'core/str';\nimport Prefetch from \"core/prefetch\";\nimport * as Templates from 'core/templates';\nimport {publish} from 'core/pubsub';\nimport * as MoodleNetService from 'core/moodlenet/service';\nimport SendActivityModal from 'core/moodlenet/send_activity_modal';\nimport * as MoodleNetAuthorize from 'core/moodlenet/authorize';\nimport MoodleNetEvents from 'core/moodlenet/events';\n\nconst TYPE_ACTIVITY = \"activity\";\nconst TYPE_COURSE = \"course\";\nconst TYPE_PARTIAL_COURSE = \"partial\";\n\nlet listenersRegistered = false;\nlet currentModal;\nlet siteSupportUrl;\nlet issuerId;\nlet courseId;\nlet resourceId;\nlet shareFormat;\nlet type;\nlet selectedCmIds;\n\n/**\n * Handle send to MoodleNet.\n *\n * @param {int} issuerId The OAuth 2 issuer ID.\n * @param {int} resourceId The resource ID, it can be a course or an activity.\n * @param {int} shareFormat The share format.\n */\nexport const sendToMoodleNet = (issuerId, resourceId, shareFormat) => {\n const $modal = currentModal.getModal();\n const modal = $modal[0];\n modal.querySelector('.modal-header').classList.remove('no-border');\n modal.querySelector('.modal-header').classList.add('no-header-text');\n\n currentModal.setBody(Templates.render('core/moodlenet/send_activity_modal_packaging', {}));\n currentModal.hideFooter();\n\n let infoPromise;\n if (type === TYPE_ACTIVITY) {\n infoPromise = MoodleNetService.sendActivity(issuerId, resourceId, shareFormat);\n } else if (type === TYPE_COURSE) {\n infoPromise = MoodleNetService.sendCourse(issuerId, resourceId, shareFormat);\n } else if (type === TYPE_PARTIAL_COURSE) {\n if (selectedCmIds.length > 1) {\n infoPromise = MoodleNetService.sendPartialCourse(issuerId, resourceId, selectedCmIds, shareFormat);\n } else {\n infoPromise = MoodleNetService.sendActivity(issuerId, selectedCmIds[0], shareFormat);\n }\n }\n infoPromise.then(async(data) => {\n const status = data.status;\n const resourceUrl = data.resourceurl;\n return responseFromMoodleNet(status, resourceUrl);\n }).catch(displayException);\n};\n\n/**\n * Handle response from MoodleNet.\n *\n * @param {boolean} status Response status. True if successful.\n * @param {String} resourceUrl Resource URL.\n */\nconst responseFromMoodleNet = (status, resourceUrl = '') => {\n const $modal = currentModal.getModal();\n const modal = $modal[0];\n modal.querySelector('.modal-header').classList.add('no-border');\n currentModal.setBody(Templates.render('core/moodlenet/send_activity_modal_done', {\n success: status,\n sitesupporturl: siteSupportUrl,\n }));\n\n if (status) {\n currentModal.setFooter(Templates.render('core/moodlenet/send_activity_modal_footer_view', {\n resourceurl: resourceUrl,\n }));\n currentModal.showFooter();\n }\n};\n\n/**\n * Render the modal to send resource to MoodleNet.\n *\n * @param {object} data The data of the resource to be shared.\n * @param {array} selectedActivities Selected activities.\n */\nconst renderModal = async(data, selectedActivities) => {\n if (data.status) {\n siteSupportUrl = data.supportpageurl;\n issuerId = data.issuerid;\n let modalConfig = {\n templateContext: {\n 'activitytype': data.type,\n 'activityname': data.name,\n 'server': data.server,\n }\n };\n if (selectedActivities.length > 0) {\n selectedCmIds = selectedActivities;\n }\n if (selectedActivities.length > 1) {\n modalConfig.templateContext.fullsharing = false;\n modalConfig.templateContext.selectedactivitiesnotice = await getString('moodlenet:sharenoticepartialactivitynumber',\n 'moodle', selectedActivities.length);\n modalConfig.templateContext.sharenotice = await getString('moodlenet:sharenoticepartial', 'moodle');\n } else {\n modalConfig.templateContext.fullsharing = true;\n if (type === TYPE_ACTIVITY || (type === TYPE_PARTIAL_COURSE && selectedActivities.length == 1)) {\n modalConfig.templateContext.sharenotice = await getString('moodlenet:sharenoticeactivity', 'moodle');\n } else {\n modalConfig.templateContext.sharenotice = await getString('moodlenet:sharenoticecourse', 'moodle');\n }\n }\n\n return SendActivityModal.create(modalConfig);\n } else {\n return addNotification({\n message: data.warnings[0].message,\n type: 'error'\n });\n }\n};\n\n/**\n * Handle modal.\n * @param {string} shareActionType Share action type.\n * @param {array} selectedActivities Selected activities.\n */\nexport const handleModal = (shareActionType, selectedActivities = []) => {\n const resourceId = Config.contextInstanceId;\n type = shareActionType;\n\n Promise.resolve(type)\n .then((type) => {\n if (type === TYPE_ACTIVITY) {\n return MoodleNetService.getActivityInformation(resourceId);\n } else if (type === TYPE_COURSE) {\n return MoodleNetService.getCourseInformation(resourceId);\n } else if (type === TYPE_PARTIAL_COURSE) {\n if (selectedActivities.length > 1) {\n // Selected more than one activity.\n return MoodleNetService.getCourseInformation(resourceId);\n } else {\n // Select only one activity. Switch to activity mode.\n return MoodleNetService.getActivityInformation(selectedActivities[0]);\n }\n }\n throw new Error(`Unknown type ${type}`);\n })\n .then((data) => {\n return renderModal(data, selectedActivities);\n })\n .then((modal) => {\n currentModal = modal;\n return currentModal;\n })\n .catch(displayException);\n};\n\n/**\n * Register events.\n */\nconst registerEventListeners = () => {\n document.addEventListener('click', (e) => {\n const shareAction = e.target.closest('[data-action=\"sendtomoodlenet\"]');\n const sendAction = e.target.closest('.moodlenet-action-buttons [data-action=\"share\"]');\n if (shareAction) {\n e.preventDefault();\n type = shareAction.getAttribute('data-type');\n handleModal(shareAction.getAttribute('data-type'));\n }\n\n if (sendAction) {\n e.preventDefault();\n publish(MoodleNetEvents.MOODLENET_SHARE_STARTED, {});\n courseId = Config.courseId;\n resourceId = Config.contextInstanceId;\n shareFormat = 0;\n MoodleNetAuthorize.handleAuthorization(issuerId, courseId, resourceId, shareFormat);\n }\n });\n};\n\n\n/**\n * Initialize.\n */\nexport const init = () => {\n if (!listenersRegistered) {\n Prefetch.prefetchTemplates([\n 'core/moodlenet/send_activity_modal_base',\n 'core/moodlenet/send_activity_modal_packaging',\n 'core/moodlenet/send_activity_modal_done',\n 'core/moodlenet/send_activity_modal_footer_view',\n 'core/moodlenet/send_activity_modal_footer_share',\n ]);\n registerEventListeners();\n listenersRegistered = true;\n }\n};\n"],"names":["currentModal","siteSupportUrl","issuerId","courseId","resourceId","shareFormat","type","selectedCmIds","listenersRegistered","modal","getModal","infoPromise","querySelector","classList","remove","add","setBody","Templates","render","hideFooter","MoodleNetService","sendActivity","sendCourse","length","sendPartialCourse","then","async","status","data","resourceUrl","resourceurl","responseFromMoodleNet","catch","displayException","$modal","success","sitesupporturl","setFooter","showFooter","renderModal","selectedActivities","supportpageurl","issuerid","modalConfig","templateContext","name","server","fullsharing","selectedactivitiesnotice","sharenotice","SendActivityModal","create","message","warnings","handleModal","shareActionType","Config","contextInstanceId","Promise","resolve","getActivityInformation","getCourseInformation","Error","prefetchTemplates","document","addEventListener","e","shareAction","target","closest","sendAction","preventDefault","getAttribute","MoodleNetEvents","MOODLENET_SHARE_STARTED","MoodleNetAuthorize","handleAuthorization"],"mappings":"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"} \ No newline at end of file diff --git a/lib/amd/src/moodlenet/mutations.js b/lib/amd/src/moodlenet/mutations.js index 90e29f5ed5b..ac9fe358786 100644 --- a/lib/amd/src/moodlenet/mutations.js +++ b/lib/amd/src/moodlenet/mutations.js @@ -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. diff --git a/lib/amd/src/moodlenet/send_resource.js b/lib/amd/src/moodlenet/send_resource.js index c7a732d24d5..c3834c9435e 100644 --- a/lib/amd/src/moodlenet/send_resource.js +++ b/lib/amd/src/moodlenet/send_resource.js @@ -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) { diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 60d1ff24d0b..8d23e8c2be2 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -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);