define ("qtype_moopt/creation_via_drag_and_drop",["core/ajax","qtype_moopt/edit_editor_content"],function(a,b){return{init:functioninit(a){varb=this;document.querySelector("#loadproformataskfilebutton").addEventListener("click",function(){b.extractInformation(a)})},extractInformation:functionextractInformation(){varc=document.querySelector("#id_proformataskfileupload").parentNode,d=null;c.childNodes.forEach(function(a){if("proformataskfileupload"==a.name&&null===d){d=a.value}});a.call([{methodname:"qtype_moopt_extract_task_infos_from_draft_file",args:{itemid:d},done:functiondone(c){if("undefined"!=typeofc.error){document.querySelector("#id_error_ajaxerrorlabel").parentNode.children.item(0).innerHTML="<div>"+c.error+"</div>";document.querySelector("#id_error_ajaxwarnlabel").parentNode.children.item(0).innerHTML="";return}document.querySelector("#id_error_ajaxerrorlabel").parentNode.children.item(0).innerHTML="";document.querySelector("#id_name").value=c.title;b.setContents("id_questiontext",c.description);b.setContents("id_internaldescription",c.internaldescription);b.setContents("id_taskuuid",c.taskuuid);b.setContents("id_defaultmark",c.maxscoregradinghints);b.setContents("id_generalfeedback",c.filesdisplayedingeneralfeedback);a.call([{methodname:"qtype_moopt_get_grader_data",args:{},done:functiondone(a){if(0<a.length){for(varb=a[0],d=document.querySelector("#id_graderselect"),e=d.options[d.selectedIndex].value,f=0,g;f<a.length;f++){g=a[f].html_representation;if(g===e){b=a[f];break}}varh=[];a.forEach(function(a){if("proglangs"ina){for(varb=0;b<a.proglangs.length;b++){if(a.proglangs[b].toLowerCase()===c.proglang.toLowerCase()){h.push(a);break}}}});if(0<h.length){varj=[],l=h[0].name;h.forEach(function(a){if(a.name===l){j.push(a)}});if(0<j.length){b=j[0];for(varm=1;m<j.length;m++){for(varn=j[m].version.split("."),o=b.version.split("."),p=0;2>p;p++){if(parseInt(n[p])>parseInt(o[p])){b=j[m];break}elseif(parseInt(n[p])<parseInt(o[p])){break}}}}}varq=b.html_representation;setSelectionSafely("#id_graderselect option[value='"+q+"']");varr=document.querySelectorAll("[id^=form_autocomplete_input]")[0];console.log(r);r.value=c.proglang;console.log(r.value);enterKeyEvent(r);vars=document.querySelector("#id_graderselect option[value='"+q+"']").text;r.value=s;console.log(r.value);enterKeyEvent(r);r.value="MooPT";console.log(r.value);enterKeyEvent(r);if("result_spec"inb){if("format"inb.result_spec){q=b.result_spec.format;setSelectionSafely("#id_resultspecformat option[value='"+q+"']")}if("structure"inb.result_spec){q=b.result_spec.structure;setSelectionSafely("#id_resultspecstructure option[value='"+q+"']")}if("teacher_feedback_level"inb.result_spec){q=b.result_spec.teacher_feedback_level;setSelectionSafely("#id_teacherfeedbacklevel option[value='"+q+"']")}if("student_feedback_level"inb.result_spec){q=b.result_spec.student_feedback_level;setSelectionSafely("#id_studentfeedbacklevel option[value='"+q+"']")}}}}}]);vard=document.querySelector("#id_enablefilesubmissions");d.checked=!c.enablefileinput;d.click();vare=c.freetextfilesettings.length;d=document.querySelector("#id_enablefreetextsubmissions");d.checked=!(0<e);d.click();if(0<e){d=document.querySelector("#id_ftsnuminitialfields");d.value=e;d.click();d=document.querySelector("#id_ftsmaxnumfields");d.value=e;d.click();d.dispatchEvent(newEvent("change"));d=document.querySelector("#id_ftsstandardlang");for(varf=d.options,g=0;g<f.length;g++){if(f[g].text.toLowerCase()===c.proglang.toLowerCase()){d.selectedIndex=g}}d=document.querySelector("#id_enablecustomsettingsforfreetextinputfields");d.checked=!1;d.click();for(varh=0;h<c.freetextfilesettings.length;h++){d=document.querySelector("#id_enablecustomsettingsforfreetextinputfield"+h);d.checked=!c.freetextfilesettings[h].enablecustomsettings;d.click();if(!0==c.freetextfilesettings[h].usefixedfilename){d=document.querySelector("#id_namesettingsforfreetextinput"+h+"_0");d.checked=!1;d.click()}else{d=document.querySelector("#id_namesettingsforfreetextinput"+h+"_1");d.checked=!1;d.click()}document.querySelector("#id_freetextinputfieldname"+h).value=c.freetextfilesettings[h].defaultfilename;document.querySelector("#id_freetextinputfieldtemplate"+h).value=c.freetextfilesettings[h].filecontent;document.querySelector("#id_ftsoverwrittenlang"+h).value=c.freetextfilesettings[h].proglang;document.querySelector("#id_ftsinitialdisplayrows"+h).value=c.freetextfilesettings[h].initialdisplayrows}}varj="";if("undefined"!=typeofc.moodleValidationProformaNamespace){j+="<p>Detected ProFormA-version "+c.moodleValidationProformaNamespace+"</p>"}if("undefined"!=typeofc.moodleValidationWarningInvalidNamespace){j+="<p>"+c.moodleValidationWarningInvalidNamespace+"</p>"}if("undefined"!=typeofc.moodleValidationWarnings){j+="<p>Found the following problems during validation but still continued:</p><ul>";c.moodleValidationWarnings.forEach(function(a){j+="<li>"+a.msg+"</li>"});j+="</ul>"}document.querySelector("#id_error_ajaxwarninglabel").parentNode.children.item(0).innerHTML=j;document.querySelector("#loadproformataskfilebutton").focus()},fail:functionfail(a){console.log(a);document.querySelector("#id_error_ajaxerrorlabel").parentNode.children.item(0).innerHTML="<div>"+a.debuginfo+"</div><div> For more information see browser console.</div>";document.querySelector("#id_error_ajaxwarninglabel").parentNode.children.item(0).innerHTML=""}}])}}});functionsetSelectionSafely(a){select=document.querySelector(a);if(null!==select)select.selected=!0}functionenterKeyEvent(a){varb=newKeyboardEvent("keydown",{bubbles:!0,cancelBubble:!1,cancelable:!0,charCode:0,code:"Enter",isTrusted:!0,key:"Enter",keyCode:13,repeat:!1,type:"keydown",which:13});a.dispatchEvent(b)}
define ("qtype_moopt/creation_via_drag_and_drop",["core/ajax","qtype_moopt/edit_editor_content"],function(a,b){return{init:functioninit(a){varb=this;document.querySelector("#loadproformataskfilebutton").addEventListener("click",function(){b.extractInformation(a)})},extractInformation:functionextractInformation(){varc=document.querySelector("#id_proformataskfileupload").parentNode,d=null;c.childNodes.forEach(function(a){if("proformataskfileupload"==a.name&&null===d){d=a.value}});a.call([{methodname:"qtype_moopt_extract_task_infos_from_draft_file",args:{itemid:d},done:functiondone(c){if("undefined"!=typeofc.error){document.querySelector("#id_error_ajaxerrorlabel").parentNode.children.item(0).innerHTML="<div>"+c.error+"</div>";document.querySelector("#id_error_ajaxwarnlabel").parentNode.children.item(0).innerHTML="";return}document.querySelector("#id_error_ajaxerrorlabel").parentNode.children.item(0).innerHTML="";document.querySelector("#id_name").value=c.title;b.setContents("id_questiontext",c.description);b.setContents("id_internaldescription",c.internaldescription);b.setContents("id_taskuuid",c.taskuuid);b.setContents("id_defaultmark",c.maxscoregradinghints);b.setContents("id_generalfeedback",c.filesdisplayedingeneralfeedback);a.call([{methodname:"qtype_moopt_get_grader_data",args:{},done:functiondone(a){if(0<a.length){for(varb=a[0],d=document.querySelector("#id_graderselect"),e=d.options[d.selectedIndex].value,f=0,g;f<a.length;f++){g=a[f].html_representation;if(g===e){b=a[f];break}}varh=[];a.forEach(function(a){if("proglangs"ina){for(varb=0;b<a.proglangs.length;b++){if(a.proglangs[b].toLowerCase()===c.proglang.toLowerCase()){h.push(a);break}}}});if(0<h.length){varj=[],l=h[0].name;h.forEach(function(a){if(a.name===l){j.push(a)}});if(0<j.length){b=j[0];for(varm=1;m<j.length;m++){for(varn=j[m].version.split("."),o=b.version.split("."),p=0;2>p;p++){if(parseInt(n[p])>parseInt(o[p])){b=j[m];break}elseif(parseInt(n[p])<parseInt(o[p])){break}}}}}varq=b.html_representation;setSelectionSafely("#id_graderselect option[value='"+q+"']");varr=document.querySelectorAll("[id^=form_autocomplete_input]")[0];r.value=c.proglang;enterKeyEvent(r);vars=document.querySelector("#id_graderselect option[value='"+q+"']").text;r.value=s;enterKeyEvent(r);r.value="MooPT";enterKeyEvent(r);if("result_spec"inb){if("format"inb.result_spec){q=b.result_spec.format;setSelectionSafely("#id_resultspecformat option[value='"+q+"']")}if("structure"inb.result_spec){q=b.result_spec.structure;setSelectionSafely("#id_resultspecstructure option[value='"+q+"']")}if("teacher_feedback_level"inb.result_spec){q=b.result_spec.teacher_feedback_level;setSelectionSafely("#id_teacherfeedbacklevel option[value='"+q+"']")}if("student_feedback_level"inb.result_spec){q=b.result_spec.student_feedback_level;setSelectionSafely("#id_studentfeedbacklevel option[value='"+q+"']")}}}}}]);vard=document.querySelector("#id_enablefilesubmissions");d.checked=!c.enablefileinput;d.click();vare=c.freetextfilesettings.length;d=document.querySelector("#id_enablefreetextsubmissions");d.checked=!(0<e);d.click();if(0<e){d=document.querySelector("#id_ftsnuminitialfields");d.value=e;d.click();d=document.querySelector("#id_ftsmaxnumfields");d.value=e;d.click();d.dispatchEvent(newEvent("change"));d=document.querySelector("#id_ftsstandardlang");for(varf=d.options,g=0;g<f.length;g++){if(f[g].text.toLowerCase()===c.proglang.toLowerCase()){d.selectedIndex=g}}d=document.querySelector("#id_enablecustomsettingsforfreetextinputfields");d.checked=!1;d.click();for(varh=0;h<c.freetextfilesettings.length;h++){d=document.querySelector("#id_enablecustomsettingsforfreetextinputfield"+h);d.checked=!c.freetextfilesettings[h].enablecustomsettings;d.click();if(!0==c.freetextfilesettings[h].usefixedfilename){d=document.querySelector("#id_namesettingsforfreetextinput"+h+"_0");d.checked=!1;d.click()}else{d=document.querySelector("#id_namesettingsforfreetextinput"+h+"_1");d.checked=!1;d.click()}document.querySelector("#id_freetextinputfieldname"+h).value=c.freetextfilesettings[h].defaultfilename;document.querySelector("#id_freetextinputfieldtemplate"+h).value=c.freetextfilesettings[h].filecontent;document.querySelector("#id_ftsoverwrittenlang"+h).value=c.freetextfilesettings[h].proglang;document.querySelector("#id_ftsinitialdisplayrows"+h).value=c.freetextfilesettings[h].initialdisplayrows}}varj="";if("undefined"!=typeofc.moodleValidationProformaNamespace){j+="<p>Detected ProFormA-version "+c.moodleValidationProformaNamespace+"</p>"}if("undefined"!=typeofc.moodleValidationWarningInvalidNamespace){j+="<p>"+c.moodleValidationWarningInvalidNamespace+"</p>"}if("undefined"!=typeofc.moodleValidationWarnings){j+="<p>Found the following problems during validation but still continued:</p><ul>";c.moodleValidationWarnings.forEach(function(a){j+="<li>"+a.msg+"</li>"});j+="</ul>"}document.querySelector("#id_error_ajaxwarninglabel").parentNode.children.item(0).innerHTML=j;document.querySelector("#loadproformataskfilebutton").focus()},fail:functionfail(a){console.log(a);document.querySelector("#id_error_ajaxerrorlabel").parentNode.children.item(0).innerHTML="<div>"+a.debuginfo+"</div><div> For more information see browser console.</div>";document.querySelector("#id_error_ajaxwarninglabel").parentNode.children.item(0).innerHTML=""}}])}}});functionsetSelectionSafely(a){select=document.querySelector(a);if(null!==select)select.selected=!0}functionenterKeyEvent(a){varb=newKeyboardEvent("keydown",{bubbles:!0,cancelBubble:!1,cancelable:!0,charCode:0,code:"Enter",isTrusted:!0,key:"Enter",keyCode:13,repeat:!1,type:"keydown",which:13});a.dispatchEvent(b)}