From 55090ed293c14cf1cdfe218ac305436e8ec2fa75 Mon Sep 17 00:00:00 2001 From: Lyannic Date: Wed, 27 Dec 2023 20:13:58 +0100 Subject: [PATCH] Try to use relative URL for opening problem_selector.php --- amd/build/mod_form.min.js | 2 +- amd/build/mod_form.min.js.map | 2 +- amd/src/mod_form.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/amd/build/mod_form.min.js b/amd/build/mod_form.min.js index 31877f7..ee0ae87 100644 --- a/amd/build/mod_form.min.js +++ b/amd/build/mod_form.min.js @@ -1,3 +1,3 @@ -define("mod_mumie/mod_form",["jquery","core/templates","core/modal_factory","auth_mumie/mumie_server_config","core/ajax"],(function(){const addServerButton=document.getElementById("id_add_server_button"),missingConfig=document.getElementsByName("mumie_missing_config")[0];let lmsSelectorUrl,systemLanguage;const serverController=function(){let serverStructure;const serverDropDown=document.getElementById("id_server");return{init:function(structure){serverStructure=structure},getSelectedServer:function(){const selectedServerName=serverDropDown.options[serverDropDown.selectedIndex].text;return serverStructure.find((server=>server.name===selectedServerName))},disable:function(){serverDropDown.disabled=!0,function(elem){for(;elem.firstChild;)elem.removeChild(elem.firstChild)}(serverDropDown)}}}(),problemSelectorController=function(){const problemSelectorButton=document.getElementById("id_prb_selector_btn"),multiProblemSelectorButton=document.getElementById("id_multi_problem_selector_btn");let problemSelectorWindow;const mumieOrg=document.getElementsByName("mumie_org")[0].value;function sendResponse(response){problemSelectorWindow&&problemSelectorWindow.postMessage(JSON.stringify(response),lmsSelectorUrl)}function sendSuccess(){let message=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";sendResponse({success:!0,message:message})}function addMessageListener(){window.addEventListener("message",(event=>{var _importObj$worksheet;if(event.origin!==lmsSelectorUrl)return;const importObj=JSON.parse(event.data),isGraded=!1!==importObj.isGraded,worksheet=null!==(_importObj$worksheet=importObj.worksheet)&&void 0!==_importObj$worksheet?_importObj$worksheet:null;try{courseController.setCourse(importObj.path_to_coursefile),langController.setLanguage(importObj.language),taskController.setSelection(importObj.link,importObj.language,importObj.name),taskController.setIsGraded(isGraded),worksheetController.setWorksheet(worksheet),sendSuccess(),window.focus(),require(["core/str","core/notification"],(function(str,notification){str.get_strings([{key:"mumie_form_updated_selection",component:"mod_mumie"}]).done((function(s){notification.addNotification({message:s[0],type:"info"})})).fail(notification.exception)}))}catch(error){!function(){sendResponse({success:!1,message:arguments.length>0&&void 0!==arguments[0]?arguments[0]:""})}(error.message)}}),!1)}return{init:function(){problemSelectorButton.onclick=function(){problemSelectorWindow=window.open(function(){const gradingType=taskController.getGradingType(),selection=taskController.getDelocalizedTaskLink();return"http://moodledev.mumie.net:8050/auth/mumie/problem_selector.php?org="+mumieOrg+"&serverUrl="+encodeURIComponent(serverController.getSelectedServer().urlprefix)+"&problemLang="+langController.getSelectedLanguage()+"&origin="+encodeURIComponent(window.location.origin)+"&gradingType="+gradingType+(selection?"&selection="+selection:"")}(),"_blank")},window.onclose=function(){sendSuccess()},window.addEventListener("beforeunload",(function(){sendSuccess()}),!1),addMessageListener(),multiProblemSelectorButton.onclick=function(e){e.preventDefault(),problemSelectorWindow=window.open(lmsSelectorUrl+"/lms-problem-selector?serverUrl="+encodeURIComponent(serverController.getSelectedServer().urlprefix)+"&gradingType=all","_blank","toolbar=0,location=0,menubar=0")}},disable:function(){problemSelectorButton.disabled=!0}}}(),courseController=function(){const courseNameElem=document.getElementById("id_mumie_course"),coursefileElem=document.getElementsByName("mumie_coursefile")[0];function updateCourseName(){var _selectedCourse$name$;const selectedCourse=courseController.getSelectedCourse(),selectedLanguage=langController.getSelectedLanguage();selectedCourse&&selectedLanguage&&(courseNameElem.value=null===(_selectedCourse$name$=selectedCourse.name.find((translation=>translation.language===selectedLanguage)))||void 0===_selectedCourse$name$?void 0:_selectedCourse$name$.value)}return{init:function(){updateCourseName()},getSelectedCourse:function(){return serverController.getSelectedServer().courses.find((course=>course.coursefile===coursefileElem.value))},setCourse:function(courseFile){var coursefile;coursefile=courseFile,coursefileElem.value=coursefile,updateCourseName()}}}(),langController=function(){const languageElem=document.getElementById("id_language");return{getSelectedLanguage:function(){return languageElem.value},setLanguage:function(lang){languageElem.value=lang}}}(),taskController=function(){const taskSelectionInput=document.getElementsByName("taskurl")[0],nameElem=document.getElementById("id_name"),taskDisplayElement=document.getElementById("id_task_display_element"),isGradedElem=document.getElementById("id_mumie_isgraded");function updateTaskDisplayElemement(localizedLink){taskDisplayElement.value=localizedLink}function updateTaskUri(link,language){const localizedLink=function(link,language){return link+"?lang="+language}(link,language);taskSelectionInput.value=localizedLink,updateTaskDisplayElemement(localizedLink)}return{init:function(){updateTaskDisplayElemement(taskSelectionInput.value)},setSelection:function(link,language,name){updateTaskUri(link,language),function(name){nameElem.value=name}(name)},setIsGraded:function(isGraded){null===isGraded&&(isGradedElem.value=null),isGradedElem.value=isGraded?"1":"0",function(){const disabled="0"===isGradedElem.value;document.getElementById("id_points").disabled=disabled,document.getElementById("id_gradepass").disabled=disabled,document.getElementById("id_duedate_enabled").disabled=disabled,document.getElementById("id_gradecat").disabled=disabled}()},getGradingType:function(){const isGraded=isGradedElem.value;return"1"===isGraded?"graded":"0"===isGraded?"ungraded":"all"},getDelocalizedTaskLink:function(){return(link=taskSelectionInput.value).includes("?lang=")?link.split("?lang=")[0]:link;var link}}}(),multiTaskEditController=function(){const propertySelectionInputs=document.getElementsByName("mumie_multi_edit_property"),selectedTaskProperties=document.getElementsByName("mumie_selected_task_properties")[0];let selectedTaskProp=[];const taskSelectionInputs=document.getElementsByName("mumie_multi_edit_task"),selectedTasks=document.getElementsByName("mumie_selected_tasks")[0];let selectedTaskIds=[];const sectionInputs=document.getElementsByName("mumie_multi_edit_section");return{init:function(){taskSelectionInputs.forEach((function(checkbox){checkbox.onchange=function(){checkbox.checked?selectedTaskIds.push(checkbox.value):selectedTaskIds=selectedTaskIds.filter((elem=>elem!==checkbox.value)),selectedTasks.value=JSON.stringify(selectedTaskIds)}})),propertySelectionInputs.forEach((function(checkbox){checkbox.onchange=function(){checkbox.checked?selectedTaskProp.push(checkbox.value):selectedTaskProp=selectedTaskProp.filter((elem=>elem!==checkbox.value)),selectedTaskProperties.value=JSON.stringify(selectedTaskProp)}})),sectionInputs.forEach((function(sectionCheckbox){sectionCheckbox.onchange=function(){sectionCheckbox.checked?taskSelectionInputs.forEach((function(taskCheckbox){var array,element;taskCheckbox.getAttribute("section")===sectionCheckbox.value&&(taskCheckbox.checked=!0,array=selectedTaskIds,element=taskCheckbox.value,array.includes(element)||array.push(element))})):taskSelectionInputs.forEach((function(taskCheckbox){taskCheckbox.getAttribute("section")===sectionCheckbox.value&&(taskCheckbox.checked=!1,selectedTaskIds=selectedTaskIds.filter((elem=>taskCheckbox.value!==elem)))})),selectedTasks.value=JSON.stringify(selectedTaskIds)}}))}}}(),worksheetController=function(){const worksheetElement=document.getElementById("id_mumie_worksheet");return{setWorksheet:function(worksheet){worksheet?worksheetElement.setAttribute("value",JSON.stringify(worksheet)):worksheetElement.removeAttribute("value")}}}();function disableDropDownMenus(errorKey){require(["core/str","core/notification"],(function(str,notification){str.get_strings([{key:errorKey,component:"mod_mumie"}]).done((function(s){notification.addNotification({message:s[0]+""+missingConfig.getAttribute("value")+"",type:"problem"})})).fail(notification.exception)})),serverController.disable(),problemSelectorController.disable()}return{init:function(contextid,prbSelectorUrl,lang){lmsSelectorUrl=prbSelectorUrl,systemLanguage=lang;const isEdit=document.getElementById("id_name").getAttribute("value"),serverStructure=JSON.parse(document.getElementsByName("mumie_server_structure")[0].value);isEdit&&""!==document.getElementsByName("mumie_missing_config")[0].getAttribute("value")?disableDropDownMenus("mumie_form_missing_server"):serverStructure.length?(serverController.init(serverStructure),courseController.init(),taskController.init(),multiTaskEditController.init(),problemSelectorController.init()):disableDropDownMenus("mumie_form_no_server_conf"),multiTaskEditController.init(),addServerButton&&require(["auth_mumie/mumie_server_config"],(function(MumieServer){MumieServer.init(addServerButton,contextid)}))}}})); +define("mod_mumie/mod_form",["jquery","core/templates","core/modal_factory","auth_mumie/mumie_server_config","core/ajax"],(function(){const addServerButton=document.getElementById("id_add_server_button"),missingConfig=document.getElementsByName("mumie_missing_config")[0];let lmsSelectorUrl,systemLanguage;const serverController=function(){let serverStructure;const serverDropDown=document.getElementById("id_server");return{init:function(structure){serverStructure=structure},getSelectedServer:function(){const selectedServerName=serverDropDown.options[serverDropDown.selectedIndex].text;return serverStructure.find((server=>server.name===selectedServerName))},disable:function(){serverDropDown.disabled=!0,function(elem){for(;elem.firstChild;)elem.removeChild(elem.firstChild)}(serverDropDown)}}}(),problemSelectorController=function(){const problemSelectorButton=document.getElementById("id_prb_selector_btn"),multiProblemSelectorButton=document.getElementById("id_multi_problem_selector_btn");let problemSelectorWindow;const mumieOrg=document.getElementsByName("mumie_org")[0].value;function sendResponse(response){problemSelectorWindow&&problemSelectorWindow.postMessage(JSON.stringify(response),lmsSelectorUrl)}function sendSuccess(){let message=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";sendResponse({success:!0,message:message})}function addMessageListener(){window.addEventListener("message",(event=>{var _importObj$worksheet;if(event.origin!==lmsSelectorUrl)return;const importObj=JSON.parse(event.data),isGraded=!1!==importObj.isGraded,worksheet=null!==(_importObj$worksheet=importObj.worksheet)&&void 0!==_importObj$worksheet?_importObj$worksheet:null;try{courseController.setCourse(importObj.path_to_coursefile),langController.setLanguage(importObj.language),taskController.setSelection(importObj.link,importObj.language,importObj.name),taskController.setIsGraded(isGraded),worksheetController.setWorksheet(worksheet),sendSuccess(),window.focus(),require(["core/str","core/notification"],(function(str,notification){str.get_strings([{key:"mumie_form_updated_selection",component:"mod_mumie"}]).done((function(s){notification.addNotification({message:s[0],type:"info"})})).fail(notification.exception)}))}catch(error){!function(){sendResponse({success:!1,message:arguments.length>0&&void 0!==arguments[0]?arguments[0]:""})}(error.message)}}),!1)}function buildURL(){const gradingType=taskController.getGradingType(),selection=taskController.getDelocalizedTaskLink(),selectedServer=serverController.getSelectedServer().urlprefix;var selectedServerUrl;return(selectedServerUrl=selectedServer,new URL(lmsSelectorUrl).origin===new URL(selectedServerUrl).origin)?"/auth/mumie/problem_selector.php?org="+mumieOrg+"&serverUrl="+encodeURIComponent(selectedServer)+"&problemLang="+langController.getSelectedLanguage()+"&origin="+encodeURIComponent(window.location.origin)+"&gradingType="+gradingType+(selection?"&selection="+selection:""):lmsSelectorUrl+"/lms-problem-selector?org="+mumieOrg+"&serverUrl="+encodeURIComponent(selectedServer)+"&problemLang="+langController.getSelectedLanguage()+"&origin="+encodeURIComponent(window.location.origin)+"&uiLang="+systemLanguage+"&gradingType="+gradingType+"&multiCourse=true&worksheet=true"+(selection?"&selection="+selection:"")}return{init:function(){problemSelectorButton.onclick=function(){problemSelectorWindow=window.open(buildURL(),"_blank")},window.onclose=function(){sendSuccess()},window.addEventListener("beforeunload",(function(){sendSuccess()}),!1),addMessageListener(),multiProblemSelectorButton.onclick=function(e){e.preventDefault(),problemSelectorWindow=window.open(lmsSelectorUrl+"/lms-problem-selector?serverUrl="+encodeURIComponent(serverController.getSelectedServer().urlprefix)+"&gradingType=all","_blank","toolbar=0,location=0,menubar=0")}},disable:function(){problemSelectorButton.disabled=!0}}}(),courseController=function(){const courseNameElem=document.getElementById("id_mumie_course"),coursefileElem=document.getElementsByName("mumie_coursefile")[0];function updateCourseName(){var _selectedCourse$name$;const selectedCourse=courseController.getSelectedCourse(),selectedLanguage=langController.getSelectedLanguage();selectedCourse&&selectedLanguage&&(courseNameElem.value=null===(_selectedCourse$name$=selectedCourse.name.find((translation=>translation.language===selectedLanguage)))||void 0===_selectedCourse$name$?void 0:_selectedCourse$name$.value)}return{init:function(){updateCourseName()},getSelectedCourse:function(){return serverController.getSelectedServer().courses.find((course=>course.coursefile===coursefileElem.value))},setCourse:function(courseFile){var coursefile;coursefile=courseFile,coursefileElem.value=coursefile,updateCourseName()}}}(),langController=function(){const languageElem=document.getElementById("id_language");return{getSelectedLanguage:function(){return languageElem.value},setLanguage:function(lang){languageElem.value=lang}}}(),taskController=function(){const taskSelectionInput=document.getElementsByName("taskurl")[0],nameElem=document.getElementById("id_name"),taskDisplayElement=document.getElementById("id_task_display_element"),isGradedElem=document.getElementById("id_mumie_isgraded");function updateTaskDisplayElemement(localizedLink){taskDisplayElement.value=localizedLink}function updateTaskUri(link,language){const localizedLink=function(link,language){return link+"?lang="+language}(link,language);taskSelectionInput.value=localizedLink,updateTaskDisplayElemement(localizedLink)}return{init:function(){updateTaskDisplayElemement(taskSelectionInput.value)},setSelection:function(link,language,name){updateTaskUri(link,language),function(name){nameElem.value=name}(name)},setIsGraded:function(isGraded){null===isGraded&&(isGradedElem.value=null),isGradedElem.value=isGraded?"1":"0",function(){const disabled="0"===isGradedElem.value;document.getElementById("id_points").disabled=disabled,document.getElementById("id_gradepass").disabled=disabled,document.getElementById("id_duedate_enabled").disabled=disabled,document.getElementById("id_gradecat").disabled=disabled}()},getGradingType:function(){const isGraded=isGradedElem.value;return"1"===isGraded?"graded":"0"===isGraded?"ungraded":"all"},getDelocalizedTaskLink:function(){return(link=taskSelectionInput.value).includes("?lang=")?link.split("?lang=")[0]:link;var link}}}(),multiTaskEditController=function(){const propertySelectionInputs=document.getElementsByName("mumie_multi_edit_property"),selectedTaskProperties=document.getElementsByName("mumie_selected_task_properties")[0];let selectedTaskProp=[];const taskSelectionInputs=document.getElementsByName("mumie_multi_edit_task"),selectedTasks=document.getElementsByName("mumie_selected_tasks")[0];let selectedTaskIds=[];const sectionInputs=document.getElementsByName("mumie_multi_edit_section");return{init:function(){taskSelectionInputs.forEach((function(checkbox){checkbox.onchange=function(){checkbox.checked?selectedTaskIds.push(checkbox.value):selectedTaskIds=selectedTaskIds.filter((elem=>elem!==checkbox.value)),selectedTasks.value=JSON.stringify(selectedTaskIds)}})),propertySelectionInputs.forEach((function(checkbox){checkbox.onchange=function(){checkbox.checked?selectedTaskProp.push(checkbox.value):selectedTaskProp=selectedTaskProp.filter((elem=>elem!==checkbox.value)),selectedTaskProperties.value=JSON.stringify(selectedTaskProp)}})),sectionInputs.forEach((function(sectionCheckbox){sectionCheckbox.onchange=function(){sectionCheckbox.checked?taskSelectionInputs.forEach((function(taskCheckbox){var array,element;taskCheckbox.getAttribute("section")===sectionCheckbox.value&&(taskCheckbox.checked=!0,array=selectedTaskIds,element=taskCheckbox.value,array.includes(element)||array.push(element))})):taskSelectionInputs.forEach((function(taskCheckbox){taskCheckbox.getAttribute("section")===sectionCheckbox.value&&(taskCheckbox.checked=!1,selectedTaskIds=selectedTaskIds.filter((elem=>taskCheckbox.value!==elem)))})),selectedTasks.value=JSON.stringify(selectedTaskIds)}}))}}}(),worksheetController=function(){const worksheetElement=document.getElementById("id_mumie_worksheet");return{setWorksheet:function(worksheet){worksheet?worksheetElement.setAttribute("value",JSON.stringify(worksheet)):worksheetElement.removeAttribute("value")}}}();function disableDropDownMenus(errorKey){require(["core/str","core/notification"],(function(str,notification){str.get_strings([{key:errorKey,component:"mod_mumie"}]).done((function(s){notification.addNotification({message:s[0]+""+missingConfig.getAttribute("value")+"",type:"problem"})})).fail(notification.exception)})),serverController.disable(),problemSelectorController.disable()}return{init:function(contextid,prbSelectorUrl,lang){lmsSelectorUrl=prbSelectorUrl,systemLanguage=lang;const isEdit=document.getElementById("id_name").getAttribute("value"),serverStructure=JSON.parse(document.getElementsByName("mumie_server_structure")[0].value);isEdit&&""!==document.getElementsByName("mumie_missing_config")[0].getAttribute("value")?disableDropDownMenus("mumie_form_missing_server"):serverStructure.length?(serverController.init(serverStructure),courseController.init(),taskController.init(),multiTaskEditController.init(),problemSelectorController.init()):disableDropDownMenus("mumie_form_no_server_conf"),multiTaskEditController.init(),addServerButton&&require(["auth_mumie/mumie_server_config"],(function(MumieServer){MumieServer.init(addServerButton,contextid)}))}}})); //# sourceMappingURL=mod_form.min.js.map \ No newline at end of file diff --git a/amd/build/mod_form.min.js.map b/amd/build/mod_form.min.js.map index 9c7dfa7..6e940bf 100644 --- a/amd/build/mod_form.min.js.map +++ b/amd/build/mod_form.min.js.map @@ -1 +1 @@ -{"version":3,"file":"mod_form.min.js","sources":["../src/mod_form.js"],"sourcesContent":["define(['jquery', 'core/templates', 'core/modal_factory', 'auth_mumie/mumie_server_config', 'core/ajax'],\n function() {\n const addServerButton = document.getElementById(\"id_add_server_button\");\n const missingConfig = document.getElementsByName(\"mumie_missing_config\")[0];\n let lmsSelectorUrl;\n let systemLanguage;\n const serverController = (function() {\n let serverStructure;\n const serverDropDown = document.getElementById(\"id_server\");\n\n return {\n init: function(structure) {\n serverStructure = structure;\n },\n getSelectedServer: function() {\n const selectedServerName = serverDropDown.options[serverDropDown.selectedIndex].text;\n return serverStructure.find(server => server.name === selectedServerName);\n },\n disable: function() {\n serverDropDown.disabled = true;\n removeChildElems(serverDropDown);\n }\n };\n })();\n\n const problemSelectorController = (function() {\n const problemSelectorButton = document.getElementById('id_prb_selector_btn');\n const multiProblemSelectorButton = document.getElementById('id_multi_problem_selector_btn');\n let problemSelectorWindow;\n const mumieOrg = document.getElementsByName('mumie_org')[0].value;\n\n /**\n * Send a message to the problem selector window.\n *\n * Don't do anything if there is no problem selector window.\n * @param {Object} response\n */\n function sendResponse(response) {\n if (!problemSelectorWindow) {\n return;\n }\n problemSelectorWindow.postMessage(JSON.stringify(response), lmsSelectorUrl);\n }\n\n /**\n * Send a success message to problem selector window\n * @param {string} message\n */\n function sendSuccess(message = '') {\n sendResponse({\n success: true,\n message: message\n });\n }\n\n /**\n * Send a failure message to problem selector window\n * @param {string} message\n */\n function sendFailure(message = '') {\n sendResponse({\n success: false,\n message: message\n });\n }\n\n /**\n * Add an event listener that accepts messages from LMS-Browser and updates the selected problem.\n */\n function addMessageListener() {\n window.addEventListener('message', (event) => {\n if (event.origin !== lmsSelectorUrl) {\n return;\n }\n const importObj = JSON.parse(event.data);\n const isGraded = importObj.isGraded !== false;\n const worksheet = importObj.worksheet ?? null;\n try {\n courseController.setCourse(importObj.path_to_coursefile);\n langController.setLanguage(importObj.language);\n taskController.setSelection(importObj.link, importObj.language, importObj.name);\n taskController.setIsGraded(isGraded);\n worksheetController.setWorksheet(worksheet);\n sendSuccess();\n window.focus();\n displayProblemSelectedMessage();\n } catch (error) {\n sendFailure(error.message);\n }\n }, false);\n }\n\n /**\n * Display a success message in Moodle that a problem was successfully selected.\n */\n function displayProblemSelectedMessage() {\n require(['core/str', \"core/notification\"], function(str, notification) {\n str.get_strings([{\n 'key': 'mumie_form_updated_selection',\n component: 'mod_mumie'\n }]).done(function(s) {\n notification.addNotification({\n message: s[0],\n type: \"info\"\n });\n }).fail(notification.exception);\n });\n }\n\n /**\n * Builds the URL to the Problem Selector\n * @returns {string} URL to the Problem Selector\n */\n function buildURL() {\n const gradingType = taskController.getGradingType();\n const selection = taskController.getDelocalizedTaskLink();\n // TODO write function to determine whether SSO should be used\n const useSSO = true;\n if (useSSO) {\n return 'http://moodledev.mumie.net:8050/auth/mumie/problem_selector.php?'\n + 'org='\n + mumieOrg\n + '&serverUrl='\n + encodeURIComponent(serverController.getSelectedServer().urlprefix)\n + '&problemLang='\n + langController.getSelectedLanguage()\n + '&origin=' + encodeURIComponent(window.location.origin)\n + '&gradingType=' + gradingType\n + (selection ? '&selection=' + selection : '');\n }\n return lmsSelectorUrl\n + '/lms-problem-selector?'\n + 'org='\n + mumieOrg\n + '&serverUrl='\n + encodeURIComponent(serverController.getSelectedServer().urlprefix)\n + '&problemLang='\n + langController.getSelectedLanguage()\n + '&origin=' + encodeURIComponent(window.location.origin)\n + '&uiLang=' + systemLanguage\n + '&gradingType=' + gradingType\n + '&multiCourse=true'\n + '&worksheet=true'\n + (selection ? '&selection=' + selection : '');\n }\n\n return {\n init: function() {\n problemSelectorButton.onclick = function() {\n problemSelectorWindow = window.open(buildURL(), '_blank');\n };\n\n window.onclose = function() {\n sendSuccess();\n };\n\n window.addEventListener(\"beforeunload\", function() {\n sendSuccess();\n }, false);\n\n addMessageListener();\n\n multiProblemSelectorButton.onclick = function(e) {\n e.preventDefault();\n problemSelectorWindow = window.open(\n lmsSelectorUrl\n + '/lms-problem-selector?'\n + \"serverUrl=\"\n + encodeURIComponent(serverController.getSelectedServer().urlprefix)\n + '&gradingType=all',\n \"_blank\",\n 'toolbar=0,location=0,menubar=0'\n );\n };\n },\n disable: function() {\n problemSelectorButton.disabled = true;\n }\n };\n })();\n\n const courseController = (function() {\n const courseNameElem = document.getElementById(\"id_mumie_course\");\n const coursefileElem = document.getElementsByName(\"mumie_coursefile\")[0];\n\n\n /**\n * Update the hidden input field with the selected course's course file path\n *\n * @param {string} coursefile\n */\n function updateCoursefilePath(coursefile) {\n coursefileElem.value = coursefile;\n updateCourseName();\n }\n\n /**\n * Update displayed course name.\n */\n function updateCourseName() {\n const selectedCourse = courseController.getSelectedCourse();\n const selectedLanguage = langController.getSelectedLanguage();\n if (!selectedCourse || !selectedLanguage) {\n return;\n }\n courseNameElem.value = selectedCourse.name\n .find(translation => translation.language === selectedLanguage)?.value;\n }\n\n return {\n init: function() {\n updateCourseName();\n },\n getSelectedCourse: function() {\n const courses = serverController.getSelectedServer().courses;\n return courses.find(course => course.coursefile === coursefileElem.value);\n },\n setCourse: function(courseFile) {\n updateCoursefilePath(courseFile);\n }\n };\n })();\n\n const langController = (function() {\n const languageElem = document.getElementById(\"id_language\");\n return {\n getSelectedLanguage: function() {\n return languageElem.value;\n },\n setLanguage: function(lang) {\n languageElem.value = lang;\n }\n };\n })();\n\n const taskController = (function() {\n const taskSelectionInput = document.getElementsByName(\"taskurl\")[0];\n const nameElem = document.getElementById(\"id_name\");\n const taskDisplayElement = document.getElementById(\"id_task_display_element\");\n const isGradedElem = document.getElementById('id_mumie_isgraded');\n const LANG_REQUEST_PARAM_PREFIX = \"?lang=\";\n\n /**\n * Update the activity's name in the input field\n * @param {string} name\n */\n function updateName(name) {\n nameElem.value = name;\n }\n\n /**\n * @param {string} localizedLink\n */\n function updateTaskDisplayElemement(localizedLink) {\n taskDisplayElement.value = localizedLink;\n }\n\n /**\n * Update task uri\n * @param {string} link\n * @param {string} language\n */\n function updateTaskUri(link, language) {\n const localizedLink = localizeLink(link, language);\n taskSelectionInput.value = localizedLink;\n updateTaskDisplayElemement(localizedLink);\n }\n\n /**\n * Add lang request param to link\n * @param {string} link\n * @param {string} language\n * @returns {string} Link with lang request param\n */\n function localizeLink(link, language) {\n return link + LANG_REQUEST_PARAM_PREFIX + language;\n }\n\n /**\n * Remove lang request param from link\n * @param {string} link Link that may have lang request param\n * @returns {string} Link without lang request param\n */\n function delocalizeLink(link) {\n if (link.includes(LANG_REQUEST_PARAM_PREFIX)) {\n return link.split(LANG_REQUEST_PARAM_PREFIX)[0];\n }\n return link;\n }\n\n /**\n * Form inputs related to grades should be disabled, if the MUMIE Task is not graded.\n */\n function updateGradeEditability() {\n const disabled = isGradedElem.value === '0';\n document.getElementById('id_points').disabled = disabled;\n document.getElementById('id_gradepass').disabled = disabled;\n document.getElementById('id_duedate_enabled').disabled = disabled;\n document.getElementById('id_gradecat').disabled = disabled;\n }\n\n return {\n init: function() {\n updateTaskDisplayElemement(taskSelectionInput.value);\n },\n setSelection: function(link, language, name) {\n updateTaskUri(link, language);\n updateName(name);\n },\n setIsGraded: function(isGraded) {\n if (isGraded === null) {\n isGradedElem.value = null;\n }\n isGradedElem.value = isGraded ? '1' : '0';\n updateGradeEditability();\n },\n getGradingType: function() {\n const isGraded = isGradedElem.value;\n if (isGraded === '1') {\n return 'graded';\n } else if (isGraded === '0') {\n return 'ungraded';\n }\n return 'all';\n },\n getDelocalizedTaskLink: function() {\n return delocalizeLink(taskSelectionInput.value);\n }\n };\n })();\n\n\n const multiTaskEditController = (function() {\n const propertySelectionInputs = document.getElementsByName(\"mumie_multi_edit_property\");\n const selectedTaskProperties = document.getElementsByName(\"mumie_selected_task_properties\")[0];\n let selectedTaskProp = [];\n const taskSelectionInputs = document.getElementsByName(\"mumie_multi_edit_task\");\n const selectedTasks = document.getElementsByName(\"mumie_selected_tasks\")[0];\n let selectedTaskIds = [];\n const sectionInputs = document.getElementsByName(\"mumie_multi_edit_section\");\n\n /**\n * Push an element to an array, if it's not already included.\n *\n * @param {string[]} array\n * @param {string} element\n */\n function pushIfNotExists(array, element) {\n if (!array.includes(element)) {\n array.push(element);\n }\n }\n\n /**\n * Set selection listeners for other MUMIE Tasks in the course.\n */\n function setTaskSelectionListeners() {\n taskSelectionInputs.forEach(function(checkbox) {\n checkbox.onchange = function() {\n if (!checkbox.checked) {\n selectedTaskIds = selectedTaskIds.filter(elem => elem !== checkbox.value);\n } else {\n selectedTaskIds.push(checkbox.value);\n }\n selectedTasks.value = JSON.stringify(selectedTaskIds);\n };\n });\n }\n\n /**\n * Set selection listeners for properties to apply to MUMIE Tasks in the course.\n */\n function setPropertySelectionListeners() {\n propertySelectionInputs.forEach(function(checkbox) {\n checkbox.onchange = function() {\n if (!checkbox.checked) {\n selectedTaskProp = selectedTaskProp.filter(elem => elem !== checkbox.value);\n } else {\n selectedTaskProp.push(checkbox.value);\n }\n selectedTaskProperties.value = JSON.stringify(selectedTaskProp);\n };\n });\n }\n\n /**\n * Set selection listeners for entire section of MUMIE Tasks in the course\n */\n function setSectionSelectionListeners() {\n sectionInputs.forEach(function(sectionCheckbox) {\n sectionCheckbox.onchange = function() {\n if (!sectionCheckbox.checked) {\n taskSelectionInputs.forEach(function(taskCheckbox) {\n if (taskCheckbox.getAttribute('section') === sectionCheckbox.value) {\n taskCheckbox.checked = false;\n selectedTaskIds = selectedTaskIds.filter(elem => taskCheckbox.value !== elem);\n }\n });\n } else {\n taskSelectionInputs.forEach(function(taskCheckbox) {\n if (taskCheckbox.getAttribute('section') === sectionCheckbox.value) {\n taskCheckbox.checked = true;\n pushIfNotExists(selectedTaskIds, taskCheckbox.value);\n }\n });\n }\n selectedTasks.value = JSON.stringify(selectedTaskIds);\n };\n });\n }\n\n return {\n init: function() {\n setTaskSelectionListeners();\n setPropertySelectionListeners();\n setSectionSelectionListeners();\n },\n };\n })();\n\n const worksheetController = (function() {\n const worksheetElement = document.getElementById(\"id_mumie_worksheet\");\n return {\n setWorksheet: function(worksheet) {\n if (worksheet) {\n worksheetElement.setAttribute(\"value\", JSON.stringify(worksheet));\n } else {\n worksheetElement.removeAttribute(\"value\");\n }\n }\n };\n })();\n\n /**\n * Disable all dropdown menus and show notification\n * @param {string} errorKey\n */\n function disableDropDownMenus(errorKey) {\n require(['core/str', \"core/notification\"], function(str, notification) {\n str.get_strings([{\n 'key': errorKey,\n component: 'mod_mumie'\n }]).done(function(s) {\n notification.addNotification({\n message: s[0] + \"\" + missingConfig.getAttribute(\"value\") + \"\",\n type: \"problem\"\n });\n }).fail(notification.exception);\n });\n serverController.disable();\n problemSelectorController.disable();\n }\n\n return {\n init: function(contextid, prbSelectorUrl, lang) {\n lmsSelectorUrl = prbSelectorUrl;\n systemLanguage = lang;\n const isEdit = document.getElementById(\"id_name\").getAttribute('value');\n const serverStructure = JSON.parse(document.getElementsByName('mumie_server_structure')[0].value);\n if (isEdit && !serverConfigExists()) {\n disableDropDownMenus('mumie_form_missing_server');\n } else if (!serverStructure.length) {\n disableDropDownMenus('mumie_form_no_server_conf');\n } else {\n serverController.init(serverStructure);\n courseController.init();\n taskController.init();\n multiTaskEditController.init();\n problemSelectorController.init();\n }\n multiTaskEditController.init();\n if (addServerButton) {\n require(['auth_mumie/mumie_server_config'], function(MumieServer) {\n MumieServer.init(addServerButton, contextid);\n });\n }\n }\n };\n\n /**\n * Remove all child elements of a given html element\n * @param {Object} elem\n */\n function removeChildElems(elem) {\n while (elem.firstChild) {\n elem.removeChild(elem.firstChild);\n }\n }\n\n /**\n * Check, if the flag for an existing config is set\n * @returns {boolean}\n */\n function serverConfigExists() {\n return document.getElementsByName(\"mumie_missing_config\")[0].getAttribute(\"value\") === \"\";\n }\n });\n"],"names":["define","addServerButton","document","getElementById","missingConfig","getElementsByName","lmsSelectorUrl","systemLanguage","serverController","serverStructure","serverDropDown","init","structure","getSelectedServer","selectedServerName","options","selectedIndex","text","find","server","name","disable","disabled","elem","firstChild","removeChild","removeChildElems","problemSelectorController","problemSelectorButton","multiProblemSelectorButton","problemSelectorWindow","mumieOrg","value","sendResponse","response","postMessage","JSON","stringify","sendSuccess","message","success","addMessageListener","window","addEventListener","event","origin","importObj","parse","data","isGraded","worksheet","courseController","setCourse","path_to_coursefile","langController","setLanguage","language","taskController","setSelection","link","setIsGraded","worksheetController","setWorksheet","focus","require","str","notification","get_strings","component","done","s","addNotification","type","fail","exception","error","sendFailure","onclick","open","gradingType","getGradingType","selection","getDelocalizedTaskLink","encodeURIComponent","urlprefix","getSelectedLanguage","location","buildURL","onclose","e","preventDefault","courseNameElem","coursefileElem","updateCourseName","selectedCourse","getSelectedCourse","selectedLanguage","translation","_selectedCourse$name$","courses","course","coursefile","courseFile","languageElem","lang","taskSelectionInput","nameElem","taskDisplayElement","isGradedElem","updateTaskDisplayElemement","localizedLink","updateTaskUri","localizeLink","updateName","updateGradeEditability","includes","split","multiTaskEditController","propertySelectionInputs","selectedTaskProperties","selectedTaskProp","taskSelectionInputs","selectedTasks","selectedTaskIds","sectionInputs","forEach","checkbox","onchange","checked","push","filter","sectionCheckbox","taskCheckbox","array","element","getAttribute","worksheetElement","setAttribute","removeAttribute","disableDropDownMenus","errorKey","contextid","prbSelectorUrl","isEdit","length","MumieServer"],"mappings":"AAAAA,4BAAO,CAAC,SAAU,iBAAkB,qBAAsB,iCAAkC,cACxF,iBACUC,gBAAkBC,SAASC,eAAe,wBAC1CC,cAAgBF,SAASG,kBAAkB,wBAAwB,OACrEC,eACAC,qBACEC,iBAAoB,eAClBC,sBACEC,eAAiBR,SAASC,eAAe,mBAExC,CACHQ,KAAM,SAASC,WACXH,gBAAkBG,WAEtBC,kBAAmB,iBACTC,mBAAqBJ,eAAeK,QAAQL,eAAeM,eAAeC,YACzER,gBAAgBS,MAAKC,QAAUA,OAAOC,OAASN,sBAE1DO,QAAS,WACLX,eAAeY,UAAW,WAgdZC,WACfA,KAAKC,YACRD,KAAKE,YAAYF,KAAKC,YAjdlBE,CAAiBhB,kBAdH,GAmBpBiB,0BAA6B,iBACzBC,sBAAwB1B,SAASC,eAAe,uBAChD0B,2BAA6B3B,SAASC,eAAe,q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GxBxI,iBAAiBG,KAAKF,iBACtB0C,iBAAiBxC,OACjB8C,eAAe9C,OACf0G,wBAAwB1G,OACxBgB,0BAA0BhB,QAN1BgI,qBAAqB,6BAQzBtB,wBAAwB1G,OACpBV,iBACA+D,QAAQ,CAAC,mCAAmC,SAASiF,aACjDA,YAAYtI,KAAKV,gBAAiB4I"} \ No newline at end of file +{"version":3,"file":"mod_form.min.js","sources":["../src/mod_form.js"],"sourcesContent":["define(['jquery', 'core/templates', 'core/modal_factory', 'auth_mumie/mumie_server_config', 'core/ajax'],\n function() {\n const addServerButton = document.getElementById(\"id_add_server_button\");\n const missingConfig = document.getElementsByName(\"mumie_missing_config\")[0];\n let lmsSelectorUrl;\n let systemLanguage;\n const serverController = (function() {\n let serverStructure;\n const serverDropDown = document.getElementById(\"id_server\");\n\n return {\n init: function(structure) {\n serverStructure = structure;\n },\n getSelectedServer: function() {\n const selectedServerName = serverDropDown.options[serverDropDown.selectedIndex].text;\n return serverStructure.find(server => server.name === selectedServerName);\n },\n disable: function() {\n serverDropDown.disabled = true;\n removeChildElems(serverDropDown);\n }\n };\n })();\n\n const problemSelectorController = (function() {\n const problemSelectorButton = document.getElementById('id_prb_selector_btn');\n const multiProblemSelectorButton = document.getElementById('id_multi_problem_selector_btn');\n let problemSelectorWindow;\n const mumieOrg = document.getElementsByName('mumie_org')[0].value;\n\n /**\n * Send a message to the problem selector window.\n *\n * Don't do anything if there is no problem selector window.\n * @param {Object} response\n */\n function sendResponse(response) {\n if (!problemSelectorWindow) {\n return;\n }\n problemSelectorWindow.postMessage(JSON.stringify(response), lmsSelectorUrl);\n }\n\n /**\n * Send a success message to problem selector window\n * @param {string} message\n */\n function sendSuccess(message = '') {\n sendResponse({\n success: true,\n message: message\n });\n }\n\n /**\n * Send a failure message to problem selector window\n * @param {string} message\n */\n function sendFailure(message = '') {\n sendResponse({\n success: false,\n message: message\n });\n }\n\n /**\n * Add an event listener that accepts messages from LMS-Browser and updates the selected problem.\n */\n function addMessageListener() {\n window.addEventListener('message', (event) => {\n if (event.origin !== lmsSelectorUrl) {\n return;\n }\n const importObj = JSON.parse(event.data);\n const isGraded = importObj.isGraded !== false;\n const worksheet = importObj.worksheet ?? null;\n try {\n courseController.setCourse(importObj.path_to_coursefile);\n langController.setLanguage(importObj.language);\n taskController.setSelection(importObj.link, importObj.language, importObj.name);\n taskController.setIsGraded(isGraded);\n worksheetController.setWorksheet(worksheet);\n sendSuccess();\n window.focus();\n displayProblemSelectedMessage();\n } catch (error) {\n sendFailure(error.message);\n }\n }, false);\n }\n\n /**\n * Display a success message in Moodle that a problem was successfully selected.\n */\n function displayProblemSelectedMessage() {\n require(['core/str', \"core/notification\"], function(str, notification) {\n str.get_strings([{\n 'key': 'mumie_form_updated_selection',\n component: 'mod_mumie'\n }]).done(function(s) {\n notification.addNotification({\n message: s[0],\n type: \"info\"\n });\n }).fail(notification.exception);\n });\n }\n\n /**\n * Builds the URL to the Problem Selector\n * @returns {string} URL to the Problem Selector\n */\n function buildURL() {\n const gradingType = taskController.getGradingType();\n const selection = taskController.getDelocalizedTaskLink();\n const selectedServer = serverController.getSelectedServer().urlprefix;\n const useSSO = shouldUseSSO(lmsSelectorUrl, selectedServer);\n if (useSSO) {\n return '/auth/mumie/problem_selector.php?'\n + 'org='\n + mumieOrg\n + '&serverUrl='\n + encodeURIComponent(selectedServer)\n + '&problemLang='\n + langController.getSelectedLanguage()\n + '&origin=' + encodeURIComponent(window.location.origin)\n + '&gradingType=' + gradingType\n + (selection ? '&selection=' + selection : '');\n }\n return lmsSelectorUrl\n + '/lms-problem-selector?'\n + 'org='\n + mumieOrg\n + '&serverUrl='\n + encodeURIComponent(selectedServer)\n + '&problemLang='\n + langController.getSelectedLanguage()\n + '&origin=' + encodeURIComponent(window.location.origin)\n + '&uiLang=' + systemLanguage\n + '&gradingType=' + gradingType\n + '&multiCourse=true'\n + '&worksheet=true'\n + (selection ? '&selection=' + selection : '');\n }\n\n /**\n * Determines whether the Single Sign-On (SSO) should be used when opening the Problem Selector.\n * SSO is only supposed to be used when the Problem Selector URL has the same origin as the\n * URL of the selected MUMIE server.\n *\n * @param {string} problemSelectorUrl - The URL of the problem selector.\n * @param {string} selectedServerUrl - The URL of the selected MUMIE server\n * @returns {boolean} Whether SSO should be used for the Problem Selector or not\n */\n function shouldUseSSO(problemSelectorUrl, selectedServerUrl) {\n return new URL(problemSelectorUrl).origin === new URL(selectedServerUrl).origin;\n }\n\n return {\n init: function() {\n problemSelectorButton.onclick = function() {\n problemSelectorWindow = window.open(buildURL(), '_blank');\n };\n\n window.onclose = function() {\n sendSuccess();\n };\n\n window.addEventListener(\"beforeunload\", function() {\n sendSuccess();\n }, false);\n\n addMessageListener();\n\n multiProblemSelectorButton.onclick = function(e) {\n e.preventDefault();\n problemSelectorWindow = window.open(\n lmsSelectorUrl\n + '/lms-problem-selector?'\n + \"serverUrl=\"\n + encodeURIComponent(serverController.getSelectedServer().urlprefix)\n + '&gradingType=all',\n \"_blank\",\n 'toolbar=0,location=0,menubar=0'\n );\n };\n },\n disable: function() {\n problemSelectorButton.disabled = true;\n }\n };\n })();\n\n const courseController = (function() {\n const courseNameElem = document.getElementById(\"id_mumie_course\");\n const coursefileElem = document.getElementsByName(\"mumie_coursefile\")[0];\n\n\n /**\n * Update the hidden input field with the selected course's course file path\n *\n * @param {string} coursefile\n */\n function updateCoursefilePath(coursefile) {\n coursefileElem.value = coursefile;\n updateCourseName();\n }\n\n /**\n * Update displayed course name.\n */\n function updateCourseName() {\n const selectedCourse = courseController.getSelectedCourse();\n const selectedLanguage = langController.getSelectedLanguage();\n if (!selectedCourse || !selectedLanguage) {\n return;\n }\n courseNameElem.value = selectedCourse.name\n .find(translation => translation.language === selectedLanguage)?.value;\n }\n\n return {\n init: function() {\n updateCourseName();\n },\n getSelectedCourse: function() {\n const courses = serverController.getSelectedServer().courses;\n return courses.find(course => course.coursefile === coursefileElem.value);\n },\n setCourse: function(courseFile) {\n updateCoursefilePath(courseFile);\n }\n };\n })();\n\n const langController = (function() {\n const languageElem = document.getElementById(\"id_language\");\n return {\n getSelectedLanguage: function() {\n return languageElem.value;\n },\n setLanguage: function(lang) {\n languageElem.value = lang;\n }\n };\n })();\n\n const taskController = (function() {\n const taskSelectionInput = document.getElementsByName(\"taskurl\")[0];\n const nameElem = document.getElementById(\"id_name\");\n const taskDisplayElement = document.getElementById(\"id_task_display_element\");\n const isGradedElem = document.getElementById('id_mumie_isgraded');\n const LANG_REQUEST_PARAM_PREFIX = \"?lang=\";\n\n /**\n * Update the activity's name in the input field\n * @param {string} name\n */\n function updateName(name) {\n nameElem.value = name;\n }\n\n /**\n * @param {string} localizedLink\n */\n function updateTaskDisplayElemement(localizedLink) {\n taskDisplayElement.value = localizedLink;\n }\n\n /**\n * Update task uri\n * @param {string} link\n * @param {string} language\n */\n function updateTaskUri(link, language) {\n const localizedLink = localizeLink(link, language);\n taskSelectionInput.value = localizedLink;\n updateTaskDisplayElemement(localizedLink);\n }\n\n /**\n * Add lang request param to link\n * @param {string} link\n * @param {string} language\n * @returns {string} Link with lang request param\n */\n function localizeLink(link, language) {\n return link + LANG_REQUEST_PARAM_PREFIX + language;\n }\n\n /**\n * Remove lang request param from link\n * @param {string} link Link that may have lang request param\n * @returns {string} Link without lang request param\n */\n function delocalizeLink(link) {\n if (link.includes(LANG_REQUEST_PARAM_PREFIX)) {\n return link.split(LANG_REQUEST_PARAM_PREFIX)[0];\n }\n return link;\n }\n\n /**\n * Form inputs related to grades should be disabled, if the MUMIE Task is not graded.\n */\n function updateGradeEditability() {\n const disabled = isGradedElem.value === '0';\n document.getElementById('id_points').disabled = disabled;\n document.getElementById('id_gradepass').disabled = disabled;\n document.getElementById('id_duedate_enabled').disabled = disabled;\n document.getElementById('id_gradecat').disabled = disabled;\n }\n\n return {\n init: function() {\n updateTaskDisplayElemement(taskSelectionInput.value);\n },\n setSelection: function(link, language, name) {\n updateTaskUri(link, language);\n updateName(name);\n },\n setIsGraded: function(isGraded) {\n if (isGraded === null) {\n isGradedElem.value = null;\n }\n isGradedElem.value = isGraded ? '1' : '0';\n updateGradeEditability();\n },\n getGradingType: function() {\n const isGraded = isGradedElem.value;\n if (isGraded === '1') {\n return 'graded';\n } else if (isGraded === '0') {\n return 'ungraded';\n }\n return 'all';\n },\n getDelocalizedTaskLink: function() {\n return delocalizeLink(taskSelectionInput.value);\n }\n };\n })();\n\n\n const multiTaskEditController = (function() {\n const propertySelectionInputs = document.getElementsByName(\"mumie_multi_edit_property\");\n const selectedTaskProperties = document.getElementsByName(\"mumie_selected_task_properties\")[0];\n let selectedTaskProp = [];\n const taskSelectionInputs = document.getElementsByName(\"mumie_multi_edit_task\");\n const selectedTasks = document.getElementsByName(\"mumie_selected_tasks\")[0];\n let selectedTaskIds = [];\n const sectionInputs = document.getElementsByName(\"mumie_multi_edit_section\");\n\n /**\n * Push an element to an array, if it's not already included.\n *\n * @param {string[]} array\n * @param {string} element\n */\n function pushIfNotExists(array, element) {\n if (!array.includes(element)) {\n array.push(element);\n }\n }\n\n /**\n * Set selection listeners for other MUMIE Tasks in the course.\n */\n function setTaskSelectionListeners() {\n taskSelectionInputs.forEach(function(checkbox) {\n checkbox.onchange = function() {\n if (!checkbox.checked) {\n selectedTaskIds = selectedTaskIds.filter(elem => elem !== checkbox.value);\n } else {\n selectedTaskIds.push(checkbox.value);\n }\n selectedTasks.value = JSON.stringify(selectedTaskIds);\n };\n });\n }\n\n /**\n * Set selection listeners for properties to apply to MUMIE Tasks in the course.\n */\n function setPropertySelectionListeners() {\n propertySelectionInputs.forEach(function(checkbox) {\n checkbox.onchange = function() {\n if (!checkbox.checked) {\n selectedTaskProp = selectedTaskProp.filter(elem => elem !== checkbox.value);\n } else {\n selectedTaskProp.push(checkbox.value);\n }\n selectedTaskProperties.value = JSON.stringify(selectedTaskProp);\n };\n });\n }\n\n /**\n * Set selection listeners for entire section of MUMIE Tasks in the course\n */\n function setSectionSelectionListeners() {\n sectionInputs.forEach(function(sectionCheckbox) {\n sectionCheckbox.onchange = function() {\n if (!sectionCheckbox.checked) {\n taskSelectionInputs.forEach(function(taskCheckbox) {\n if (taskCheckbox.getAttribute('section') === sectionCheckbox.value) {\n taskCheckbox.checked = false;\n selectedTaskIds = selectedTaskIds.filter(elem => taskCheckbox.value !== elem);\n }\n });\n } else {\n taskSelectionInputs.forEach(function(taskCheckbox) {\n if (taskCheckbox.getAttribute('section') === sectionCheckbox.value) {\n taskCheckbox.checked = true;\n pushIfNotExists(selectedTaskIds, taskCheckbox.value);\n }\n });\n }\n selectedTasks.value = JSON.stringify(selectedTaskIds);\n };\n });\n }\n\n return {\n init: function() {\n setTaskSelectionListeners();\n setPropertySelectionListeners();\n setSectionSelectionListeners();\n },\n };\n })();\n\n const worksheetController = (function() {\n const worksheetElement = document.getElementById(\"id_mumie_worksheet\");\n return {\n setWorksheet: function(worksheet) {\n if (worksheet) {\n worksheetElement.setAttribute(\"value\", JSON.stringify(worksheet));\n } else {\n worksheetElement.removeAttribute(\"value\");\n }\n }\n };\n })();\n\n /**\n * Disable all dropdown menus and show notification\n * @param {string} errorKey\n */\n function disableDropDownMenus(errorKey) {\n require(['core/str', \"core/notification\"], function(str, notification) {\n str.get_strings([{\n 'key': errorKey,\n component: 'mod_mumie'\n }]).done(function(s) {\n notification.addNotification({\n message: s[0] + \"\" + missingConfig.getAttribute(\"value\") + \"\",\n type: \"problem\"\n });\n }).fail(notification.exception);\n });\n serverController.disable();\n problemSelectorController.disable();\n }\n\n return {\n init: function(contextid, prbSelectorUrl, lang) {\n lmsSelectorUrl = prbSelectorUrl;\n systemLanguage = lang;\n const isEdit = document.getElementById(\"id_name\").getAttribute('value');\n const serverStructure = JSON.parse(document.getElementsByName('mumie_server_structure')[0].value);\n if (isEdit && !serverConfigExists()) {\n disableDropDownMenus('mumie_form_missing_server');\n } else if (!serverStructure.length) {\n disableDropDownMenus('mumie_form_no_server_conf');\n } else {\n serverController.init(serverStructure);\n courseController.init();\n taskController.init();\n multiTaskEditController.init();\n problemSelectorController.init();\n }\n multiTaskEditController.init();\n if (addServerButton) {\n require(['auth_mumie/mumie_server_config'], function(MumieServer) {\n MumieServer.init(addServerButton, contextid);\n });\n }\n }\n };\n\n /**\n * Remove all child elements of a given html element\n * @param {Object} elem\n */\n function removeChildElems(elem) {\n while (elem.firstChild) {\n elem.removeChild(elem.firstChild);\n }\n }\n\n /**\n * Check, if the flag for an existing config is set\n * @returns {boolean}\n */\n function serverConfigExists() {\n return document.getElementsByName(\"mumie_missing_config\")[0].getAttribute(\"value\") === \"\";\n }\n });\n"],"names":["define","addServerButton","document","getElementById","missingConfig","getElementsByName","lmsSelectorUrl","systemLanguage","serverController","serverStructure","serverDropDown","init","structure","getSelectedServer","selectedServerName","options","selectedIndex","text","find","server","name","disable","disabled","elem","firstChild","removeChild","removeChildElems","problemSelectorController","problemSelectorButton","multiProblemSelectorButton","problemSelectorWindow","mumieOrg","value","sendResponse","response","postMessage","JSON","stringify","sendSuccess","message","success","addMessageListener","window","addEventListener","event","origin","importObj","parse","data","isGraded","worksheet","courseController","setCourse","path_to_coursefile","langController","setLanguage","language","taskController","setSelection","link","setIsGraded","worksheetController","setWorksheet","focus","require","str","notification","get_strings","component","done","s","addNotification","type","fail","exception","error","sendFailure","buildURL","gradingType","getGradingType","selection","getDelocalizedTaskLink","selectedServer","urlprefix","selectedServerUrl","URL","encodeURIComponent","getSelectedLanguage","location","onclick","open","onclose","e","preventDefault","courseNameElem","coursefileElem","updateCourseName","selectedCourse","getSelectedCourse","selectedLanguage","translation","_selectedCourse$name$","courses","course","coursefile","courseFile","languageElem","lang","taskSelectionInput","nameElem","taskDisplayElement","isGradedElem","updateTaskDisplayElemement","localizedLink","updateTaskUri","localizeLink","updateName","updateGradeEditability","includes","split","multiTaskEditController","propertySelectionInputs","selectedTaskProperties","selectedTaskProp","taskSelectionInputs","selectedTasks","selectedTaskIds","sectionInputs","forEach","checkbox","onchange","checked","push","filter","sectionCheckbox","taskCheckbox","array","element","getAttribute","worksheetElement","setAttribute","removeAttribute","disableDropDownMenus","err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BtG,QACzDuG,aAAaJ,SAAU,EACvBL,gBAAkBA,gBAAgBO,QAAO9G,MAAQgH,aAAavG,QAAUT,WAWpFsG,cAAc7F,MAAQI,KAAKC,UAAUyF,uBA1EpB,GAwF3BjE,oBAAuB,iBACnB8E,iBAAmBzI,SAASC,eAAe,4BAC1C,CACH2D,aAAc,SAASZ,WACfA,UACAyF,iBAAiBC,aAAa,QAASxG,KAAKC,UAAUa,YAEtDyF,iBAAiBE,gBAAgB,WAPpB,YAiBpBC,qBAAqBC,UAC1B/E,QAAQ,CAAC,WAAY,sBAAsB,SAASC,IAAKC,cACrDD,IAAIE,YAAY,CAAC,KACL4E,SACR3E,UAAW,eACXC,MAAK,SAASC,GACdJ,aAAaK,gBAAgB,CACzBhC,QAAS+B,EAAE,GAAK,MAAQlE,cAAcsI,aAAa,SAAW,OAC9DlE,KAAM,eAEXC,KAAKP,aAAaQ,cAEzBlE,iBAAiBa,UACjBM,0BAA0BN,gBAGvB,CACHV,KAAM,SAASqI,UAAWC,eAAgBtC,MACtCrG,eAAiB2I,eACjB1I,eAAiBoG,WACXuC,OAAShJ,SAASC,eAAe,WAAWuI,aAAa,SACzDjI,gBAAkB2B,KAAKW,MAAM7C,SAASG,kBAAkB,0BAA0B,GAAG2B,OACvFkH,QAmC+E,KAAhFhJ,SAASG,kBAAkB,wBAAwB,GAAGqI,aAAa,SAlClEI,qBAAqB,6BACbrI,gBAAgB0I,QAGxB3I,iBAAiBG,KAAKF,iBACtB0C,iBAAiBxC,OACjB8C,eAAe9C,OACf6G,wBAAwB7G,OACxBgB,0BAA0BhB,QAN1BmI,qBAAqB,6BAQzBtB,wBAAwB7G,OACpBV,iBACA+D,QAAQ,CAAC,mCAAmC,SAASoF,aACjDA,YAAYzI,KAAKV,gBAAiB+I"} \ No newline at end of file diff --git a/amd/src/mod_form.js b/amd/src/mod_form.js index e161c1f..39010c1 100644 --- a/amd/src/mod_form.js +++ b/amd/src/mod_form.js @@ -117,7 +117,7 @@ define(['jquery', 'core/templates', 'core/modal_factory', 'auth_mumie/mumie_serv const selectedServer = serverController.getSelectedServer().urlprefix; const useSSO = shouldUseSSO(lmsSelectorUrl, selectedServer); if (useSSO) { - return 'http://moodledev.mumie.net:8050/auth/mumie/problem_selector.php?' + return '/auth/mumie/problem_selector.php?' + 'org=' + mumieOrg + '&serverUrl='