diff --git a/.travis.yml b/.travis.yml index 796f2c4..0369f12 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,13 +7,30 @@ cache: - $HOME/.composer/cache php: - - 5.6 - - 7.0 + - 7.2 + - 7.4 + +services: + - mysql + - postgresql env: matrix: - - DB=pgsql MOODLE_BRANCH=MOODLE_33_STABLE - - DB=mysqli MOODLE_BRANCH=MOODLE_33_STABLE + - DB=pgsql MOODLE_BRANCH=MOODLE_35_STABLE + - DB=mysqli MOODLE_BRANCH=MOODLE_35_STABLE + - DB=pgsql MOODLE_BRANCH=MOODLE_38_STABLE + - DB=mysqli MOODLE_BRANCH=MOODLE_38_STABLE + +matrix: + exclude: + - env: DB=pgsql MOODLE_BRANCH=MOODLE_35_STABLE + php: 7.4 + - env: DB=mysqli MOODLE_BRANCH=MOODLE_35_STABLE + php: 7.4 + - env: DB=pgsql MOODLE_BRANCH=MOODLE_38_STABLE + php: 7.2 + - env: DB=mysqli MOODLE_BRANCH=MOODLE_38_STABLE + php: 7.2 before_install: - phpenv config-rm xdebug.ini diff --git a/README.md b/README.md index d6938be..89f79ae 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Features: Useful Links - -[Creating the your Turnitin API key](https://help.turnitin.com/simcheck/integrations/moodle/administrator/account-basics/creating-an-API-key.htm) +[Creating your Turnitin API key](https://help.turnitin.com/simcheck/integrations/moodle/administrator/account-basics/creating-an-API-key.htm) Installation - diff --git a/amd/build/connection_test.min.js b/amd/build/connection_test.min.js index 6df38ee..62eda43 100644 --- a/amd/build/connection_test.min.js +++ b/amd/build/connection_test.min.js @@ -1,2 +1,2 @@ -define ("plagiarism_turnitinsim/connection_test",["jquery"],function(a){return{connectionTest:function connectionTest(){var c=a("#id_connection_test");if(0.\n\n/**\n * Javascript controller for the Turnitin Connection Test.\n *\n * @package plagiarism_turnitinsim\n * @copyright 2018 Turnitin\n * @author David Winn \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * @module plagiarism_turnitinsim/connection_test\n */\n\ndefine(['jquery', 'core/str'], function($, str) {\n return {\n connectionTest: function() {\n // Store connection test selector.\n var ct = $('#id_connection_test');\n\n if (ct.length > 0) {\n ct.click(function() {\n $.ajax({\n type: \"POST\",\n url: M.cfg.wwwroot + \"/plagiarism/turnitinsim/ajax/connection_test.php\",\n dataType: \"json\",\n data: {\n action: \"connection_test\",\n sesskey: M.cfg.sesskey,\n apiurl: $('#id_turnitinapiurl').val(),\n apikey: $('#id_turnitinapikey').val()\n },\n success: function(data) {\n if (data.connection_status === 200) {\n ct.removeClass(\"connection-test-failed\");\n ct.addClass(\"connection-test-success\");\n\n str.get_string('connecttestsuccess', 'plagiarism_turnitinsim').done(function(text) {\n changeString(ct, text);\n });\n } else {\n ct.removeClass(\"connection-test-success\");\n ct.addClass(\"connection-test-failed\");\n\n str.get_string('connecttestfailed', 'plagiarism_turnitinsim').done(function(text) {\n changeString(ct, text);\n });\n }\n\n // Fade out classes and swap back values.\n ct.delay(1000).fadeOut(\"slow\", function() {\n $(this).removeClass(\"turnitinsim_connection-test-failed\");\n $(this).removeClass(\"turnitinsim_connection-test-success\");\n\n str.get_string('connecttest', 'plagiarism_turnitinsim').done(function(text) {\n changeString(ct, text);\n });\n }).fadeIn(\"slow\");\n }\n });\n });\n }\n\n /**\n * Helper function to change the button text depending on which type of element we're handling.\n * @param {jQuery} ct - The button element - may be input or button depending on the Moodle theme.\n * @param {String} langString - The language string we're setting.\n */\n function changeString(ct, langString) {\n if (ct.get(0).tagName === \"BUTTON\") {\n ct.text(langString);\n } else {\n ct.attr('value', langString);\n }\n }\n }\n };\n});"],"file":"connection_test.min.js"} \ No newline at end of file diff --git a/amd/build/cv_launch.min.js b/amd/build/cv_launch.min.js index 440bee4..b3fcf8f 100644 --- a/amd/build/cv_launch.min.js +++ b/amd/build/cv_launch.min.js @@ -1,2 +1,2 @@ -define ("plagiarism_turnitinsim/cv_launch",["jquery"],function(a){return{open_cv:function open_cv(){a(document).on("click",".or_score",function(){var b=a(this).parent().attr("class").split(/\s+/),c=0;a(b).each(function(a){if(b[a].match("^submission_")){c=b[a].split("_")[1]}});var d=window.open("","cvWindow"),e="
",f=M.cfg.wwwroot+"/plagiarism/turnitinsim/pix/tiiIcon.svg";e+="";var g=M.str.plagiarism_turnitinsim.loadingcv;e+="

"+g+"

";e+="
";a(d.document.body).html(e);a.ajax({type:"GET",url:M.cfg.wwwroot+"/plagiarism/turnitinsim/ajax/cv.php",dataType:"json",data:{action:"request_cv_launch",submissionid:c,sesskey:M.cfg.sesskey},success:function success(a){d.location=a.viewer_url;this.checkDVClosed(d)},checkDVClosed:function checkDVClosed(a){var b=this;if(a.closed){window.location=window.location}else{setTimeout(function(){b.checkDVClosed(a)},500)}}})})}}}); +define ("plagiarism_turnitinsim/cv_launch",["jquery","core/str"],function(a,b){return{openCv:function openCv(){a(document).on("click",".or_score",function(){var c=a(this).parent().attr("class").split(/\s+/),d=0;a(c).each(function(a){if(c[a].match("^submission_")){d=c[a].split("_")[1]}});var e=window.open("","cvWindow"),f="
",g=M.cfg.wwwroot+"/plagiarism/turnitinsim/pix/tiiIcon.svg";f+="";b.get_string("loadingcv","plagiarism_turnitinsim").done(function(b){f+="

"+b+"

";a(".eulacontainer").hide().html(b).fadeIn()});f+="
";a(e.document.body).html(f);a.ajax({type:"GET",url:M.cfg.wwwroot+"/plagiarism/turnitinsim/ajax/cv.php",dataType:"json",data:{action:"request_cv_launch",submissionid:d,sesskey:M.cfg.sesskey},success:function success(a){e.location=a.viewer_url;this.checkDVClosed(e)},checkDVClosed:function checkDVClosed(a){var b=this;if(a.closed){window.location=window.location}else{setTimeout(function(){b.checkDVClosed(a)},500)}}})})}}}); //# sourceMappingURL=cv_launch.min.js.map diff --git a/amd/build/cv_launch.min.js.map b/amd/build/cv_launch.min.js.map index 0bd8df4..902cbab 100644 --- a/amd/build/cv_launch.min.js.map +++ b/amd/build/cv_launch.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/cv_launch.js"],"names":["define","$","open_cv","document","on","classList","parent","attr","split","submissionid","each","index","match","dvWindow","window","open","loading","icon","M","cfg","wwwroot","loadingCvStr","str","plagiarism_turnitinsim","loadingcv","body","html","ajax","type","url","dataType","data","action","sesskey","success","location","viewer_url","checkDVClosed","that","closed","setTimeout"],"mappings":"AA4BAA,OAAM,oCAAC,CAAC,QAAD,CAAD,CAAa,SAASC,CAAT,CAAY,CAC3B,MAAO,CACHC,OAAO,CAAE,kBAAW,CAChBD,CAAC,CAACE,QAAD,CAAD,CAAYC,EAAZ,CAAe,OAAf,CAAwB,WAAxB,CAAqC,UAAW,IAGxCC,CAAAA,CAAS,CAAGJ,CAAC,CAAC,IAAD,CAAD,CAAQK,MAAR,GAAiBC,IAAjB,CAAsB,OAAtB,EAA+BC,KAA/B,CAAqC,KAArC,CAH4B,CAIxCC,CAAY,CAAG,CAJyB,CAK5CR,CAAC,CAACI,CAAD,CAAD,CAAaK,IAAb,CAAkB,SAASC,CAAT,CAAe,CAC7B,GAAIN,CAAS,CAACM,CAAD,CAAT,CAAiBC,KAAjB,CAAuB,cAAvB,CAAJ,CAA4C,CACxCH,CAAY,CAAGJ,CAAS,CAACM,CAAD,CAAT,CAAiBH,KAAjB,CAAuB,GAAvB,EAA4B,CAA5B,CAClB,CACJ,CAJD,EAL4C,GAaxCK,CAAAA,CAAQ,CAAGC,MAAM,CAACC,IAAP,CAAY,EAAZ,CAAgB,UAAhB,CAb6B,CAcxCC,CAAO,CAAG,6DAd8B,CAexCC,CAAI,CAAGC,CAAC,CAACC,GAAF,CAAMC,OAAN,CAAgB,yCAfiB,CAgB5CJ,CAAO,EAAI,cAAeC,CAAf,CAAsB,0CAAjC,CACA,GAAII,CAAAA,CAAY,CAAGH,CAAC,CAACI,GAAF,CAAMC,sBAAN,CAA6BC,SAAhD,CACAR,CAAO,EAAI,2DAA2DK,CAA3D,CAA0E,MAArF,CACAL,CAAO,EAAI,QAAX,CACAf,CAAC,CAACY,CAAQ,CAACV,QAAT,CAAkBsB,IAAnB,CAAD,CAA0BC,IAA1B,CAA+BV,CAA/B,EAEAf,CAAC,CAAC0B,IAAF,CAAO,CACHC,IAAI,CAAE,KADH,CAEHC,GAAG,CAAEX,CAAC,CAACC,GAAF,CAAMC,OAAN,CAAgB,qCAFlB,CAGHU,QAAQ,CAAE,MAHP,CAIHC,IAAI,CAAE,CACFC,MAAM,CAAE,mBADN,CAEFvB,YAAY,CAAEA,CAFZ,CAGFwB,OAAO,CAAEf,CAAC,CAACC,GAAF,CAAMc,OAHb,CAJH,CASHC,OAAO,CAAE,iBAASH,CAAT,CAAe,CAEpBlB,CAAQ,CAACsB,QAAT,CAAoBJ,CAAI,CAACK,UAAzB,CACA,KAAKC,aAAL,CAAmBxB,CAAnB,CACH,CAbE,CAcHwB,aAAa,CAAE,uBAASxB,CAAT,CAAmB,CAC9B,GAAIyB,CAAAA,CAAI,CAAG,IAAX,CACA,GAAIzB,CAAQ,CAAC0B,MAAb,CAAqB,CACjBzB,MAAM,CAACqB,QAAP,CAAkBrB,MAAM,CAACqB,QAC5B,CAFD,IAEO,CACHK,UAAU,CAAC,UAAW,CAClBF,CAAI,CAACD,aAAL,CAAmBxB,CAAnB,CACH,CAFS,CAEP,GAFO,CAGb,CACJ,CAvBE,CAAP,CAyBH,CA/CD,CAgDH,CAlDE,CAoDV,CArDK,CAAN","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 * Javascript controller for the Turnitin Cloud Viewer launch.\n *\n * @package plagiarism_turnitinsim\n * @copyright 2017 Turnitin\n * @author John McGettrick \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * @module plagiarism_turnitinsim/cv_launch\n */\n\ndefine(['jquery'], function($) {\n return {\n open_cv: function() {\n $(document).on('click', '.or_score', function() {\n\n // Moodle forums strip ids from elements so we have to use classes.\n var classList = $(this).parent().attr('class').split(/\\s+/);\n var submissionid = 0;\n $(classList).each(function(index){\n if (classList[index].match(\"^submission_\")) {\n submissionid = classList[index].split(\"_\")[1];\n }\n });\n\n // Launch the Cloud Viewer in a new window.\n // It is being done this way as in the future we may have to listen for it closing and act on it.\n var dvWindow = window.open('', 'cvWindow');\n var loading = '
';\n var icon = M.cfg.wwwroot + '/plagiarism/turnitinsim/pix/tiiIcon.svg';\n loading += '';\n var loadingCvStr = M.str.plagiarism_turnitinsim.loadingcv;\n loading += '

' + loadingCvStr + '

';\n loading += '
';\n $(dvWindow.document.body).html(loading);\n\n $.ajax({\n type: \"GET\",\n url: M.cfg.wwwroot + \"/plagiarism/turnitinsim/ajax/cv.php\",\n dataType: \"json\",\n data: {\n action: 'request_cv_launch',\n submissionid: submissionid,\n sesskey: M.cfg.sesskey\n },\n success: function(data) {\n // Redirect opened window to returned URL.\n dvWindow.location = data.viewer_url;\n this.checkDVClosed(dvWindow);\n },\n checkDVClosed: function(dvWindow) {\n var that = this;\n if (dvWindow.closed) {\n window.location = window.location;\n } else {\n setTimeout(function() {\n that.checkDVClosed(dvWindow);\n }, 500);\n }\n }\n });\n });\n }\n };\n});"],"file":"cv_launch.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/cv_launch.js"],"names":["define","$","str","openCv","document","on","classList","parent","attr","split","submissionid","each","index","match","dvWindow","window","open","loading","icon","M","cfg","wwwroot","get_string","done","text","hide","html","fadeIn","body","ajax","type","url","dataType","data","action","sesskey","success","location","viewer_url","checkDVClosed","that","closed","setTimeout"],"mappings":"AA4BAA,OAAM,oCAAC,CAAC,QAAD,CAAW,UAAX,CAAD,CAAyB,SAASC,CAAT,CAAYC,CAAZ,CAAiB,CAC5C,MAAO,CACHC,MAAM,CAAE,iBAAW,CACfF,CAAC,CAACG,QAAD,CAAD,CAAYC,EAAZ,CAAe,OAAf,CAAwB,WAAxB,CAAqC,UAAW,IAGxCC,CAAAA,CAAS,CAAGL,CAAC,CAAC,IAAD,CAAD,CAAQM,MAAR,GAAiBC,IAAjB,CAAsB,OAAtB,EAA+BC,KAA/B,CAAqC,KAArC,CAH4B,CAIxCC,CAAY,CAAG,CAJyB,CAK5CT,CAAC,CAACK,CAAD,CAAD,CAAaK,IAAb,CAAkB,SAASC,CAAT,CAAgB,CAC9B,GAAIN,CAAS,CAACM,CAAD,CAAT,CAAiBC,KAAjB,CAAuB,cAAvB,CAAJ,CAA4C,CACxCH,CAAY,CAAGJ,CAAS,CAACM,CAAD,CAAT,CAAiBH,KAAjB,CAAuB,GAAvB,EAA4B,CAA5B,CAClB,CACJ,CAJD,EAL4C,GAaxCK,CAAAA,CAAQ,CAAGC,MAAM,CAACC,IAAP,CAAY,EAAZ,CAAgB,UAAhB,CAb6B,CAcxCC,CAAO,CAAG,6DAd8B,CAexCC,CAAI,CAAGC,CAAC,CAACC,GAAF,CAAMC,OAAN,CAAgB,yCAfiB,CAgB5CJ,CAAO,EAAI,cAAeC,CAAf,CAAsB,0CAAjC,CAEAhB,CAAG,CAACoB,UAAJ,CAAe,WAAf,CAA4B,wBAA5B,EAAsDC,IAAtD,CAA2D,SAASC,CAAT,CAAe,CACtEP,CAAO,EAAI,2DAA2DO,CAA3D,CAAkE,MAA7E,CACAvB,CAAC,CAAC,gBAAD,CAAD,CAAoBwB,IAApB,GAA2BC,IAA3B,CAAgCF,CAAhC,EAAsCG,MAAtC,EACH,CAHD,EAKAV,CAAO,EAAI,QAAX,CACAhB,CAAC,CAACa,CAAQ,CAACV,QAAT,CAAkBwB,IAAnB,CAAD,CAA0BF,IAA1B,CAA+BT,CAA/B,EAEAhB,CAAC,CAAC4B,IAAF,CAAO,CACHC,IAAI,CAAE,KADH,CAEHC,GAAG,CAAEZ,CAAC,CAACC,GAAF,CAAMC,OAAN,CAAgB,qCAFlB,CAGHW,QAAQ,CAAE,MAHP,CAIHC,IAAI,CAAE,CACFC,MAAM,CAAE,mBADN,CAEFxB,YAAY,CAAEA,CAFZ,CAGFyB,OAAO,CAAEhB,CAAC,CAACC,GAAF,CAAMe,OAHb,CAJH,CASHC,OAAO,CAAE,iBAASH,CAAT,CAAe,CAEpBnB,CAAQ,CAACuB,QAAT,CAAoBJ,CAAI,CAACK,UAAzB,CACA,KAAKC,aAAL,CAAmBzB,CAAnB,CACH,CAbE,CAcHyB,aAAa,CAAE,uBAASzB,CAAT,CAAmB,CAC9B,GAAI0B,CAAAA,CAAI,CAAG,IAAX,CACA,GAAI1B,CAAQ,CAAC2B,MAAb,CAAqB,CACjB1B,MAAM,CAACsB,QAAP,CAAkBtB,MAAM,CAACsB,QAC5B,CAFD,IAEO,CACHK,UAAU,CAAC,UAAW,CAClBF,CAAI,CAACD,aAAL,CAAmBzB,CAAnB,CACH,CAFS,CAEP,GAFO,CAGb,CACJ,CAvBE,CAAP,CAyBH,CAnDD,CAoDH,CAtDE,CAwDV,CAzDK,CAAN","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 * Javascript controller for the Turnitin Cloud Viewer launch.\n *\n * @package plagiarism_turnitinsim\n * @copyright 2017 Turnitin\n * @author John McGettrick \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * @module plagiarism_turnitinsim/cv_launch\n */\n\ndefine(['jquery', 'core/str'], function($, str) {\n return {\n openCv: function() {\n $(document).on('click', '.or_score', function() {\n\n // Moodle forums strip ids from elements so we have to use classes.\n var classList = $(this).parent().attr('class').split(/\\s+/);\n var submissionid = 0;\n $(classList).each(function(index) {\n if (classList[index].match(\"^submission_\")) {\n submissionid = classList[index].split(\"_\")[1];\n }\n });\n\n // Launch the Cloud Viewer in a new window.\n // It is being done this way as in the future we may have to listen for it closing and act on it.\n var dvWindow = window.open('', 'cvWindow');\n var loading = '
';\n var icon = M.cfg.wwwroot + '/plagiarism/turnitinsim/pix/tiiIcon.svg';\n loading += '';\n\n str.get_string('loadingcv', 'plagiarism_turnitinsim').done(function(text) {\n loading += '

' + text + '

';\n $('.eulacontainer').hide().html(text).fadeIn();\n });\n\n loading += '
';\n $(dvWindow.document.body).html(loading);\n\n $.ajax({\n type: \"GET\",\n url: M.cfg.wwwroot + \"/plagiarism/turnitinsim/ajax/cv.php\",\n dataType: \"json\",\n data: {\n action: 'request_cv_launch',\n submissionid: submissionid,\n sesskey: M.cfg.sesskey\n },\n success: function(data) {\n // Redirect opened window to returned URL.\n dvWindow.location = data.viewer_url;\n this.checkDVClosed(dvWindow);\n },\n checkDVClosed: function(dvWindow) {\n var that = this;\n if (dvWindow.closed) {\n window.location = window.location;\n } else {\n setTimeout(function() {\n that.checkDVClosed(dvWindow);\n }, 500);\n }\n }\n });\n });\n }\n };\n});"],"file":"cv_launch.min.js"} \ No newline at end of file diff --git a/amd/build/eula_response.min.js b/amd/build/eula_response.min.js index 7eb8602..da8e566 100644 --- a/amd/build/eula_response.min.js +++ b/amd/build/eula_response.min.js @@ -1,2 +1,2 @@ -define ("plagiarism_turnitinsim/eula_response",["jquery"],function(a){return{eula_response:function eula_response(){a(document).ready(function(){a("input[name=submitbutton]").prop("disabled","disabled")});a(document).on("click","#pp-eula-accept",function(){a("input[name=submitbutton]").prop("disabled","");a.ajax({type:"POST",url:M.cfg.wwwroot+"/plagiarism/turnitinsim/ajax/eula_response.php",dataType:"text",data:{action:"accept_eula",sesskey:M.cfg.sesskey},success:function success(){a(".eulacontainer").hide().html(M.str.plagiarism_turnitinsim.eulaaccepted).fadeIn()}})});a(document).on("click","#pp-eula-decline",function(){a(".eulacontainer").hide().html(M.str.plagiarism_turnitinsim.euladeclined).fadeIn();a("input[name=submitbutton]").prop("disabled","")})}}}); +define ("plagiarism_turnitinsim/eula_response",["jquery","core/str"],function(a,b){return{eulaResponse:function eulaResponse(){a(document).ready(function(){a("input[name=submitbutton]").prop("disabled","disabled")});a(document).on("click","#pp-eula-accept",function(){a("input[name=submitbutton]").prop("disabled","");a.ajax({type:"POST",url:M.cfg.wwwroot+"/plagiarism/turnitinsim/ajax/eula_response.php",dataType:"text",data:{action:"accept_eula",sesskey:M.cfg.sesskey},success:function success(){b.get_string("eulaaccepted","plagiarism_turnitinsim").done(function(b){a(".eulacontainer").hide().html(b).fadeIn()})}})});a(document).on("click","#pp-eula-decline",function(){b.get_string("euladeclined","plagiarism_turnitinsim").done(function(b){a(".eulacontainer").hide().html(b).fadeIn()});a("input[name=submitbutton]").prop("disabled","")})}}}); //# sourceMappingURL=eula_response.min.js.map diff --git a/amd/build/eula_response.min.js.map b/amd/build/eula_response.min.js.map index 106de6e..6c00fdf 100644 --- a/amd/build/eula_response.min.js.map +++ b/amd/build/eula_response.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/eula_response.js"],"names":["define","$","eula_response","document","ready","prop","on","ajax","type","url","M","cfg","wwwroot","dataType","data","action","sesskey","success","hide","html","str","plagiarism_turnitinsim","eulaaccepted","fadeIn","euladeclined"],"mappings":"AA4BAA,OAAM,wCAAC,CAAC,QAAD,CAAD,CAAa,SAASC,CAAT,CAAY,CAC3B,MAAO,CACHC,aAAa,CAAE,wBAAW,CACtBD,CAAC,CAACE,QAAD,CAAD,CAAYC,KAAZ,CAAkB,UAAW,CACzBH,CAAC,CAAC,0BAAD,CAAD,CAA8BI,IAA9B,CAAmC,UAAnC,CAA+C,UAA/C,CACH,CAFD,EAIAJ,CAAC,CAACE,QAAD,CAAD,CAAYG,EAAZ,CAAe,OAAf,CAAwB,iBAAxB,CAA2C,UAAW,CAClDL,CAAC,CAAC,0BAAD,CAAD,CAA8BI,IAA9B,CAAmC,UAAnC,CAA+C,EAA/C,EAGAJ,CAAC,CAACM,IAAF,CAAO,CACHC,IAAI,CAAE,MADH,CAEHC,GAAG,CAAEC,CAAC,CAACC,GAAF,CAAMC,OAAN,CAAgB,gDAFlB,CAGHC,QAAQ,CAAE,MAHP,CAIHC,IAAI,CAAE,CAACC,MAAM,CAAE,aAAT,CAAwBC,OAAO,CAAEN,CAAC,CAACC,GAAF,CAAMK,OAAvC,CAJH,CAKHC,OAAO,CAAE,kBAAW,CAChBhB,CAAC,CAAC,gBAAD,CAAD,CAAoBiB,IAApB,GAA2BC,IAA3B,CAAgCT,CAAC,CAACU,GAAF,CAAMC,sBAAN,CAA6BC,YAA7D,EAA2EC,MAA3E,EACH,CAPE,CAAP,CASH,CAbD,EAeAtB,CAAC,CAACE,QAAD,CAAD,CAAYG,EAAZ,CAAe,OAAf,CAAwB,kBAAxB,CAA4C,UAAW,CACnDL,CAAC,CAAC,gBAAD,CAAD,CAAoBiB,IAApB,GAA2BC,IAA3B,CAAgCT,CAAC,CAACU,GAAF,CAAMC,sBAAN,CAA6BG,YAA7D,EAA2ED,MAA3E,GACAtB,CAAC,CAAC,0BAAD,CAAD,CAA8BI,IAA9B,CAAmC,UAAnC,CAA+C,EAA/C,CACH,CAHD,CAIH,CAzBE,CA2BV,CA5BK,CAAN","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 * Javascript controller for handling the EULA response.\n *\n * @package plagiarism_turnitinsim\n * @copyright 2018 Turnitin\n * @author John McGettrick \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * @module plagiarism_turnitinsim/handleEulaResponse\n */\n\ndefine(['jquery'], function($) {\n return {\n eula_response: function() {\n $(document).ready(function() {\n $('input[name=submitbutton]').prop('disabled', 'disabled');\n });\n\n $(document).on('click', '#pp-eula-accept', function() {\n $('input[name=submitbutton]').prop('disabled', '');\n\n // Hide the EULA link.\n $.ajax({\n type: \"POST\",\n url: M.cfg.wwwroot + \"/plagiarism/turnitinsim/ajax/eula_response.php\",\n dataType: \"text\",\n data: {action: \"accept_eula\", sesskey: M.cfg.sesskey},\n success: function() {\n $('.eulacontainer').hide().html(M.str.plagiarism_turnitinsim.eulaaccepted).fadeIn();\n }\n });\n });\n\n $(document).on('click', '#pp-eula-decline', function() {\n $('.eulacontainer').hide().html(M.str.plagiarism_turnitinsim.euladeclined).fadeIn();\n $('input[name=submitbutton]').prop('disabled', '');\n });\n }\n };\n});"],"file":"eula_response.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/eula_response.js"],"names":["define","$","str","eulaResponse","document","ready","prop","on","ajax","type","url","M","cfg","wwwroot","dataType","data","action","sesskey","success","get_string","done","text","hide","html","fadeIn"],"mappings":"AA4BAA,OAAM,wCAAC,CAAC,QAAD,CAAW,UAAX,CAAD,CAAyB,SAASC,CAAT,CAAYC,CAAZ,CAAiB,CAC5C,MAAO,CACHC,YAAY,CAAE,uBAAW,CACrBF,CAAC,CAACG,QAAD,CAAD,CAAYC,KAAZ,CAAkB,UAAW,CACzBJ,CAAC,CAAC,0BAAD,CAAD,CAA8BK,IAA9B,CAAmC,UAAnC,CAA+C,UAA/C,CACH,CAFD,EAIAL,CAAC,CAACG,QAAD,CAAD,CAAYG,EAAZ,CAAe,OAAf,CAAwB,iBAAxB,CAA2C,UAAW,CAClDN,CAAC,CAAC,0BAAD,CAAD,CAA8BK,IAA9B,CAAmC,UAAnC,CAA+C,EAA/C,EAGAL,CAAC,CAACO,IAAF,CAAO,CACHC,IAAI,CAAE,MADH,CAEHC,GAAG,CAAEC,CAAC,CAACC,GAAF,CAAMC,OAAN,CAAgB,gDAFlB,CAGHC,QAAQ,CAAE,MAHP,CAIHC,IAAI,CAAE,CAACC,MAAM,CAAE,aAAT,CAAwBC,OAAO,CAAEN,CAAC,CAACC,GAAF,CAAMK,OAAvC,CAJH,CAKHC,OAAO,CAAE,kBAAW,CAChBhB,CAAG,CAACiB,UAAJ,CAAe,cAAf,CAA+B,wBAA/B,EAAyDC,IAAzD,CAA8D,SAASC,CAAT,CAAe,CACzEpB,CAAC,CAAC,gBAAD,CAAD,CAAoBqB,IAApB,GAA2BC,IAA3B,CAAgCF,CAAhC,EAAsCG,MAAtC,EACH,CAFD,CAGH,CATE,CAAP,CAWH,CAfD,EAiBAvB,CAAC,CAACG,QAAD,CAAD,CAAYG,EAAZ,CAAe,OAAf,CAAwB,kBAAxB,CAA4C,UAAW,CACnDL,CAAG,CAACiB,UAAJ,CAAe,cAAf,CAA+B,wBAA/B,EAAyDC,IAAzD,CAA8D,SAASC,CAAT,CAAe,CACzEpB,CAAC,CAAC,gBAAD,CAAD,CAAoBqB,IAApB,GAA2BC,IAA3B,CAAgCF,CAAhC,EAAsCG,MAAtC,EACH,CAFD,EAIAvB,CAAC,CAAC,0BAAD,CAAD,CAA8BK,IAA9B,CAAmC,UAAnC,CAA+C,EAA/C,CACH,CAND,CAOH,CA9BE,CAgCV,CAjCK,CAAN","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 * Javascript controller for handling the EULA response.\n *\n * @package plagiarism_turnitinsim\n * @copyright 2018 Turnitin\n * @author John McGettrick \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * @module plagiarism_turnitinsim/handleEulaResponse\n */\n\ndefine(['jquery', 'core/str'], function($, str) {\n return {\n eulaResponse: function() {\n $(document).ready(function() {\n $('input[name=submitbutton]').prop('disabled', 'disabled');\n });\n\n $(document).on('click', '#pp-eula-accept', function() {\n $('input[name=submitbutton]').prop('disabled', '');\n\n // Hide the EULA link.\n $.ajax({\n type: \"POST\",\n url: M.cfg.wwwroot + \"/plagiarism/turnitinsim/ajax/eula_response.php\",\n dataType: \"text\",\n data: {action: \"accept_eula\", sesskey: M.cfg.sesskey},\n success: function() {\n str.get_string('eulaaccepted', 'plagiarism_turnitinsim').done(function(text) {\n $('.eulacontainer').hide().html(text).fadeIn();\n });\n }\n });\n });\n\n $(document).on('click', '#pp-eula-decline', function() {\n str.get_string('euladeclined', 'plagiarism_turnitinsim').done(function(text) {\n $('.eulacontainer').hide().html(text).fadeIn();\n });\n\n $('input[name=submitbutton]').prop('disabled', '');\n });\n }\n };\n});"],"file":"eula_response.min.js"} \ No newline at end of file diff --git a/amd/build/inbox_eula_launch.min.js b/amd/build/inbox_eula_launch.min.js index 40bf1f5..82b4464 100644 --- a/amd/build/inbox_eula_launch.min.js +++ b/amd/build/inbox_eula_launch.min.js @@ -1,2 +1,2 @@ -define ("plagiarism_turnitinsim/inbox_eula_launch",["jquery","core/templates","core/modal_factory","plagiarism_turnitinsim/modal_eula"],function(a,b,c,d){return{inbox_eula_launch:function inbox_eula_launch(){var b=a(".eula-row-launch");c.create({type:d.TYPE},b)}}}); +define ("plagiarism_turnitinsim/inbox_eula_launch",["jquery","core/templates","core/modal_factory","plagiarism_turnitinsim/modal_eula"],function(a,b,c,d){return{inboxEulaLaunch:function inboxEulaLaunch(){var b=a(".eula-row-launch");c.create({type:d.TYPE},b)}}}); //# sourceMappingURL=inbox_eula_launch.min.js.map diff --git a/amd/build/inbox_eula_launch.min.js.map b/amd/build/inbox_eula_launch.min.js.map index 69336a3..f846138 100644 --- a/amd/build/inbox_eula_launch.min.js.map +++ b/amd/build/inbox_eula_launch.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/inbox_eula_launch.js"],"names":["define","$","Templates","ModalFactory","ModalTcEula","inbox_eula_launch","trigger","create","type","TYPE"],"mappings":"AAmBAA,OAAM,4CAAC,CAAC,QAAD,CACC,gBADD,CAEC,oBAFD,CAGC,mCAHD,CAAD,CAKF,SAASC,CAAT,CAAYC,CAAZ,CAAuBC,CAAvB,CAAqCC,CAArC,CAAkD,CAC9C,MAAO,CACHC,iBAAiB,CAAE,4BAAW,CAC1B,GAAIC,CAAAA,CAAO,CAAGL,CAAC,CAAC,kBAAD,CAAf,CAEAE,CAAY,CAACI,MAAb,CACI,CACIC,IAAI,CAAEJ,CAAW,CAACK,IADtB,CADJ,CAIIH,CAJJ,CAMH,CAVE,CAYV,CAlBC,CAAN","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 * @module plagiarism_turnitinsim/inbox_eula_launch\n */\n\ndefine(['jquery',\n 'core/templates',\n 'core/modal_factory',\n 'plagiarism_turnitinsim/modal_eula'\n ],\n function($, Templates, ModalFactory, ModalTcEula) {\n return {\n inbox_eula_launch: function() {\n var trigger = $('.eula-row-launch');\n\n ModalFactory.create(\n {\n type: ModalTcEula.TYPE\n },\n trigger\n );\n }\n };\n }\n);"],"file":"inbox_eula_launch.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/inbox_eula_launch.js"],"names":["define","$","Templates","ModalFactory","ModalTcEula","inboxEulaLaunch","trigger","create","type","TYPE"],"mappings":"AAmBAA,OAAM,4CAAC,CAAC,QAAD,CACC,gBADD,CAEC,oBAFD,CAGC,mCAHD,CAAD,CAKF,SAASC,CAAT,CAAYC,CAAZ,CAAuBC,CAAvB,CAAqCC,CAArC,CAAkD,CAC9C,MAAO,CACHC,eAAe,CAAE,0BAAW,CACxB,GAAIC,CAAAA,CAAO,CAAGL,CAAC,CAAC,kBAAD,CAAf,CAEAE,CAAY,CAACI,MAAb,CACI,CACIC,IAAI,CAAEJ,CAAW,CAACK,IADtB,CADJ,CAIIH,CAJJ,CAMH,CAVE,CAYV,CAlBC,CAAN","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 * @module plagiarism_turnitinsim/inbox_eula_launch\n */\n\ndefine(['jquery',\n 'core/templates',\n 'core/modal_factory',\n 'plagiarism_turnitinsim/modal_eula'\n ],\n function($, Templates, ModalFactory, ModalTcEula) {\n return {\n inboxEulaLaunch: function() {\n var trigger = $('.eula-row-launch');\n\n ModalFactory.create(\n {\n type: ModalTcEula.TYPE\n },\n trigger\n );\n }\n };\n }\n);"],"file":"inbox_eula_launch.min.js"} \ No newline at end of file diff --git a/amd/build/modal_eula.min.js b/amd/build/modal_eula.min.js index 5be1a29..cb800f9 100644 --- a/amd/build/modal_eula.min.js +++ b/amd/build/modal_eula.min.js @@ -1,2 +1,2 @@ -define ("plagiarism_turnitinsim/modal_eula",["jquery","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/modal_events","core/config"],function(a,b,c,d,e,f,g){var h=!1,i={EULA_LINK:"[class=\"eula_link\"]",ACCEPT_BUTTON:"[data-action=\"accept-eula\"]",CANCEL_BUTTON:"[data-action=\"cancel\"]"},j=function(a){d.call(this,a)};j.TYPE="plagiarism_turnitinsim-modal_eula";j.prototype=Object.create(d.prototype);j.prototype.constructor=j;j.prototype.registerEventListeners=function(){d.prototype.registerEventListeners.call(this);this.getModal().on(c.events.activate,i.EULA_LINK,function(a){a.preventDefault();window.open(g.wwwroot+"/plagiarism/turnitinsim/eula.php?cmd=eularedirect&sesskey="+g.sesskey,"_blank")}.bind(this));this.getModal().on(c.events.activate,i.ACCEPT_BUTTON,function(){var b=this;a.ajax({type:"POST",url:g.wwwroot+"/plagiarism/turnitinsim/ajax/eula_response.php",dataType:"json",data:{action:"accept_eula",contextid:g.contextid,sesskey:g.sesskey},success:function success(){b.hide();var a=window.location.origin+window.location.pathname+window.location.search+"&eula=1";window.location.href=a}})}.bind(this));this.getModal().on(c.events.activate,i.CANCEL_BUTTON,function(b,c){var d=a.Event(f.cancel);this.getRoot().trigger(d,this);if(!d.isDefaultPrevented()){this.hide();c.originalEvent.preventDefault()}}.bind(this))};if(!h){e.register(j.TYPE,j,"plagiarism_turnitinsim/modal_eula");h=!0}return j}); +define ("plagiarism_turnitinsim/modal_eula",["jquery","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/modal_events","core/config"],function(a,b,c,d,e,f,g){var h=!1,i={EULA_LINK:"[class=\"eula_link\"]",ACCEPT_BUTTON:"[data-action=\"accept-eula\"]",CANCEL_BUTTON:"[data-action=\"cancel\"]"},j=function(a){d.call(this,a)};j.TYPE="plagiarism_turnitinsim-modal_eula";j.prototype=Object.create(d.prototype);j.prototype.constructor=j;j.prototype.registerEventListeners=function(){d.prototype.registerEventListeners.call(this);this.getModal().on(c.events.activate,i.EULA_LINK,function(a){a.preventDefault();window.open(g.wwwroot+"/plagiarism/turnitinsim/eula.php?cmd=eularedirect&sesskey="+g.sesskey,"_blank")});this.getModal().on(c.events.activate,i.ACCEPT_BUTTON,function(){var b=this;a.ajax({type:"POST",url:g.wwwroot+"/plagiarism/turnitinsim/ajax/eula_response.php",dataType:"json",data:{action:"accept_eula",contextid:g.contextid,sesskey:g.sesskey},success:function success(){b.hide();var a=window.location.origin+window.location.pathname+window.location.search+"&eula=1";window.location.href=a}})}.bind(this));this.getModal().on(c.events.activate,i.CANCEL_BUTTON,function(b,c){var d=a.Event(f.cancel);this.getRoot().trigger(d,this);if(!d.isDefaultPrevented()){this.hide();c.originalEvent.preventDefault()}}.bind(this))};if(!h){e.register(j.TYPE,j,"plagiarism_turnitinsim/modal_eula");h=!0}return j}); //# sourceMappingURL=modal_eula.min.js.map diff --git a/amd/build/modal_eula.min.js.map b/amd/build/modal_eula.min.js.map index a0cd84b..e3108b8 100644 --- a/amd/build/modal_eula.min.js.map +++ b/amd/build/modal_eula.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/modal_eula.js"],"names":["define","$","Notification","CustomEvents","Modal","ModalRegistry","ModalEvents","Config","registered","SELECTORS","EULA_LINK","ACCEPT_BUTTON","CANCEL_BUTTON","ModalTcEula","root","call","TYPE","prototype","Object","create","constructor","registerEventListeners","getModal","on","events","activate","e","preventDefault","window","open","wwwroot","sesskey","bind","modal","ajax","type","url","dataType","data","action","contextid","success","hide","link","location","origin","pathname","search","href","cancelEvent","Event","cancel","getRoot","trigger","isDefaultPrevented","originalEvent","register"],"mappings":"AA4BAA,OAAM,qCACF,CACI,QADJ,CAEI,mBAFJ,CAGI,gCAHJ,CAII,YAJJ,CAKI,qBALJ,CAMI,mBANJ,CAOI,aAPJ,CADE,CAUF,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAwCC,CAAxC,CAA+CC,CAA/C,CAA8DC,CAA9D,CAA2EC,CAA3E,CAAmF,IAE3EC,CAAAA,CAAU,GAFiE,CAG3EC,CAAS,CAAG,CACZC,SAAS,CAAE,uBADC,CAEZC,aAAa,CAAE,+BAFH,CAGZC,aAAa,CAAE,0BAHH,CAH+D,CAc3EC,CAAW,CAAG,SAASC,CAAT,CAAe,CAC7BV,CAAK,CAACW,IAAN,CAAW,IAAX,CAAiBD,CAAjB,CACH,CAhB8E,CAkB/ED,CAAW,CAACG,IAAZ,CAAmB,mCAAnB,CACAH,CAAW,CAACI,SAAZ,CAAwBC,MAAM,CAACC,MAAP,CAAcf,CAAK,CAACa,SAApB,CAAxB,CACAJ,CAAW,CAACI,SAAZ,CAAsBG,WAAtB,CAAoCP,CAApC,CAOAA,CAAW,CAACI,SAAZ,CAAsBI,sBAAtB,CAA+C,UAAW,CAEtDjB,CAAK,CAACa,SAAN,CAAgBI,sBAAhB,CAAuCN,IAAvC,CAA4C,IAA5C,EAGA,KAAKO,QAAL,GAAgBC,EAAhB,CAAmBpB,CAAY,CAACqB,MAAb,CAAoBC,QAAvC,CAAiDhB,CAAS,CAACC,SAA3D,CAAsE,SAASgB,CAAT,CAAY,CAC9EA,CAAC,CAACC,cAAF,GACAC,MAAM,CAACC,IAAP,CACItB,CAAM,CAACuB,OAAP,CAAiB,4DAAjB,CAAgFvB,CAAM,CAACwB,OAD3F,CAEI,QAFJ,CAIH,CANqE,CAMpEC,IANoE,CAM/D,IAN+D,CAAtE,EASA,KAAKV,QAAL,GAAgBC,EAAhB,CAAmBpB,CAAY,CAACqB,MAAb,CAAoBC,QAAvC,CAAiDhB,CAAS,CAACE,aAA3D,CAA0E,UAAW,CACjF,GAAIsB,CAAAA,CAAK,CAAG,IAAZ,CAEAhC,CAAC,CAACiC,IAAF,CAAO,CACHC,IAAI,CAAE,MADH,CAEHC,GAAG,CAAE7B,CAAM,CAACuB,OAAP,CAAiB,gDAFnB,CAGHO,QAAQ,CAAE,MAHP,CAIHC,IAAI,CAAE,CACFC,MAAM,CAAE,aADN,CAEFC,SAAS,CAAEjC,CAAM,CAACiC,SAFhB,CAGFT,OAAO,CAAExB,CAAM,CAACwB,OAHd,CAJH,CASHU,OAAO,CAAE,kBAAY,CACjBR,CAAK,CAACS,IAAN,GACA,GAAIC,CAAAA,CAAI,CAAGf,MAAM,CAACgB,QAAP,CAAgBC,MAAhB,CAAyBjB,MAAM,CAACgB,QAAP,CAAgBE,QAAzC,CAAoDlB,MAAM,CAACgB,QAAP,CAAgBG,MAApE,CAA6E,SAAxF,CACAnB,MAAM,CAACgB,QAAP,CAAgBI,IAAhB,CAAuBL,CAC1B,CAbE,CAAP,CAgBH,CAnByE,CAmBxEX,IAnBwE,CAmBnE,IAnBmE,CAA1E,EAsBA,KAAKV,QAAL,GAAgBC,EAAhB,CAAmBpB,CAAY,CAACqB,MAAb,CAAoBC,QAAvC,CAAiDhB,CAAS,CAACG,aAA3D,CAA0E,SAASc,CAAT,CAAYY,CAAZ,CAAkB,CAExF,GAAIW,CAAAA,CAAW,CAAGhD,CAAC,CAACiD,KAAF,CAAQ5C,CAAW,CAAC6C,MAApB,CAAlB,CACA,KAAKC,OAAL,GAAeC,OAAf,CAAuBJ,CAAvB,CAAoC,IAApC,EAEA,GAAI,CAACA,CAAW,CAACK,kBAAZ,EAAL,CAAuC,CACnC,KAAKZ,IAAL,GACAJ,CAAI,CAACiB,aAAL,CAAmB5B,cAAnB,EACH,CACJ,CATyE,CASxEK,IATwE,CASnE,IATmE,CAA1E,CAUH,CA9CD,CAkDA,GAAI,CAACxB,CAAL,CAAiB,CACbH,CAAa,CAACmD,QAAd,CAAuB3C,CAAW,CAACG,IAAnC,CAAyCH,CAAzC,CAAsD,mCAAtD,EACAL,CAAU,GACb,CAED,MAAOK,CAAAA,CACV,CA7FC,CAAN","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 * Javascript controller for the Delete assignment part modal.\n *\n * @package plagiarism_turnitinsim\n * @copyright 2018 Turnitin\n * @author John McGettrick \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * @module plagiarism_turnitinsim/modal_eula\n */\n\ndefine(\n [\n 'jquery',\n 'core/notification',\n 'core/custom_interaction_events',\n 'core/modal',\n 'core/modal_registry',\n 'core/modal_events',\n 'core/config'\n ],\n function($, Notification, CustomEvents, Modal, ModalRegistry, ModalEvents, Config) {\n\n var registered = false;\n var SELECTORS = {\n EULA_LINK: '[class=\"eula_link\"]',\n ACCEPT_BUTTON: '[data-action=\"accept-eula\"]',\n CANCEL_BUTTON: '[data-action=\"cancel\"]'\n };\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n var ModalTcEula = function(root) {\n Modal.call(this, root);\n };\n\n ModalTcEula.TYPE = 'plagiarism_turnitinsim-modal_eula';\n ModalTcEula.prototype = Object.create(Modal.prototype);\n ModalTcEula.prototype.constructor = ModalTcEula;\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n ModalTcEula.prototype.registerEventListeners = function() {\n // Apply parent event listeners.\n Modal.prototype.registerEventListeners.call(this);\n\n // On clicking the EULA link, open in a new window.\n this.getModal().on(CustomEvents.events.activate, SELECTORS.EULA_LINK, function(e) {\n e.preventDefault();\n window.open(\n Config.wwwroot + '/plagiarism/turnitinsim/eula.php?cmd=eularedirect&sesskey=' + Config.sesskey,\n '_blank'\n );\n }.bind(this));\n\n // On accepting the EULA, update the db and queue submissions for this module.\n this.getModal().on(CustomEvents.events.activate, SELECTORS.ACCEPT_BUTTON, function() {\n var modal = this;\n\n $.ajax({\n type: \"POST\",\n url: Config.wwwroot + \"/plagiarism/turnitinsim/ajax/eula_response.php\",\n dataType: \"json\",\n data: {\n action: 'accept_eula',\n contextid: Config.contextid,\n sesskey: Config.sesskey\n },\n success: function () {\n modal.hide();\n var link = window.location.origin + window.location.pathname + window.location.search + '&eula=1';\n window.location.href = link;\n }\n });\n\n }.bind(this));\n\n // On cancel, then hide the modal.\n this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, function(e, data) {\n\n var cancelEvent = $.Event(ModalEvents.cancel);\n this.getRoot().trigger(cancelEvent, this);\n\n if (!cancelEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n };\n\n // Automatically register with the modal registry the first time this module is imported so that\n // you can create modals of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(ModalTcEula.TYPE, ModalTcEula, 'plagiarism_turnitinsim/modal_eula');\n registered = true;\n }\n\n return ModalTcEula;\n }\n);"],"file":"modal_eula.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/modal_eula.js"],"names":["define","$","Notification","CustomEvents","Modal","ModalRegistry","ModalEvents","Config","registered","SELECTORS","EULA_LINK","ACCEPT_BUTTON","CANCEL_BUTTON","ModalTcEula","root","call","TYPE","prototype","Object","create","constructor","registerEventListeners","getModal","on","events","activate","e","preventDefault","window","open","wwwroot","sesskey","modal","ajax","type","url","dataType","data","action","contextid","success","hide","link","location","origin","pathname","search","href","bind","cancelEvent","Event","cancel","getRoot","trigger","isDefaultPrevented","originalEvent","register"],"mappings":"AA4BAA,OAAM,qCACF,CACI,QADJ,CAEI,mBAFJ,CAGI,gCAHJ,CAII,YAJJ,CAKI,qBALJ,CAMI,mBANJ,CAOI,aAPJ,CADE,CAUF,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAwCC,CAAxC,CAA+CC,CAA/C,CAA8DC,CAA9D,CAA2EC,CAA3E,CAAmF,IAE3EC,CAAAA,CAAU,GAFiE,CAG3EC,CAAS,CAAG,CACZC,SAAS,CAAE,uBADC,CAEZC,aAAa,CAAE,+BAFH,CAGZC,aAAa,CAAE,0BAHH,CAH+D,CAc3EC,CAAW,CAAG,SAASC,CAAT,CAAe,CAC7BV,CAAK,CAACW,IAAN,CAAW,IAAX,CAAiBD,CAAjB,CACH,CAhB8E,CAkB/ED,CAAW,CAACG,IAAZ,CAAmB,mCAAnB,CACAH,CAAW,CAACI,SAAZ,CAAwBC,MAAM,CAACC,MAAP,CAAcf,CAAK,CAACa,SAApB,CAAxB,CACAJ,CAAW,CAACI,SAAZ,CAAsBG,WAAtB,CAAoCP,CAApC,CAOAA,CAAW,CAACI,SAAZ,CAAsBI,sBAAtB,CAA+C,UAAW,CAEtDjB,CAAK,CAACa,SAAN,CAAgBI,sBAAhB,CAAuCN,IAAvC,CAA4C,IAA5C,EAGA,KAAKO,QAAL,GAAgBC,EAAhB,CAAmBpB,CAAY,CAACqB,MAAb,CAAoBC,QAAvC,CAAiDhB,CAAS,CAACC,SAA3D,CAAsE,SAASgB,CAAT,CAAY,CAC9EA,CAAC,CAACC,cAAF,GACAC,MAAM,CAACC,IAAP,CACItB,CAAM,CAACuB,OAAP,CAAiB,4DAAjB,CAAgFvB,CAAM,CAACwB,OAD3F,CAEI,QAFJ,CAIH,CAND,EASA,KAAKT,QAAL,GAAgBC,EAAhB,CAAmBpB,CAAY,CAACqB,MAAb,CAAoBC,QAAvC,CAAiDhB,CAAS,CAACE,aAA3D,CAA0E,UAAW,CACjF,GAAIqB,CAAAA,CAAK,CAAG,IAAZ,CAEA/B,CAAC,CAACgC,IAAF,CAAO,CACHC,IAAI,CAAE,MADH,CAEHC,GAAG,CAAE5B,CAAM,CAACuB,OAAP,CAAiB,gDAFnB,CAGHM,QAAQ,CAAE,MAHP,CAIHC,IAAI,CAAE,CACFC,MAAM,CAAE,aADN,CAEFC,SAAS,CAAEhC,CAAM,CAACgC,SAFhB,CAGFR,OAAO,CAAExB,CAAM,CAACwB,OAHd,CAJH,CASHS,OAAO,CAAE,kBAAW,CAChBR,CAAK,CAACS,IAAN,GACA,GAAIC,CAAAA,CAAI,CAAGd,MAAM,CAACe,QAAP,CAAgBC,MAAhB,CAAyBhB,MAAM,CAACe,QAAP,CAAgBE,QAAzC,CAAoDjB,MAAM,CAACe,QAAP,CAAgBG,MAApE,CAA6E,SAAxF,CACAlB,MAAM,CAACe,QAAP,CAAgBI,IAAhB,CAAuBL,CAC1B,CAbE,CAAP,CAgBH,CAnByE,CAmBxEM,IAnBwE,CAmBnE,IAnBmE,CAA1E,EAsBA,KAAK1B,QAAL,GAAgBC,EAAhB,CAAmBpB,CAAY,CAACqB,MAAb,CAAoBC,QAAvC,CAAiDhB,CAAS,CAACG,aAA3D,CAA0E,SAASc,CAAT,CAAYW,CAAZ,CAAkB,CAExF,GAAIY,CAAAA,CAAW,CAAGhD,CAAC,CAACiD,KAAF,CAAQ5C,CAAW,CAAC6C,MAApB,CAAlB,CACA,KAAKC,OAAL,GAAeC,OAAf,CAAuBJ,CAAvB,CAAoC,IAApC,EAEA,GAAI,CAACA,CAAW,CAACK,kBAAZ,EAAL,CAAuC,CACnC,KAAKb,IAAL,GACAJ,CAAI,CAACkB,aAAL,CAAmB5B,cAAnB,EACH,CACJ,CATyE,CASxEqB,IATwE,CASnE,IATmE,CAA1E,CAUH,CA9CD,CAkDA,GAAI,CAACxC,CAAL,CAAiB,CACbH,CAAa,CAACmD,QAAd,CAAuB3C,CAAW,CAACG,IAAnC,CAAyCH,CAAzC,CAAsD,mCAAtD,EACAL,CAAU,GACb,CAED,MAAOK,CAAAA,CACV,CA7FC,CAAN","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 * Javascript controller for the Delete assignment part modal.\n *\n * @package plagiarism_turnitinsim\n * @copyright 2018 Turnitin\n * @author John McGettrick \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * @module plagiarism_turnitinsim/modal_eula\n */\n\ndefine(\n [\n 'jquery',\n 'core/notification',\n 'core/custom_interaction_events',\n 'core/modal',\n 'core/modal_registry',\n 'core/modal_events',\n 'core/config'\n ],\n function($, Notification, CustomEvents, Modal, ModalRegistry, ModalEvents, Config) {\n\n var registered = false;\n var SELECTORS = {\n EULA_LINK: '[class=\"eula_link\"]',\n ACCEPT_BUTTON: '[data-action=\"accept-eula\"]',\n CANCEL_BUTTON: '[data-action=\"cancel\"]'\n };\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n var ModalTcEula = function(root) {\n Modal.call(this, root);\n };\n\n ModalTcEula.TYPE = 'plagiarism_turnitinsim-modal_eula';\n ModalTcEula.prototype = Object.create(Modal.prototype);\n ModalTcEula.prototype.constructor = ModalTcEula;\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n ModalTcEula.prototype.registerEventListeners = function() {\n // Apply parent event listeners.\n Modal.prototype.registerEventListeners.call(this);\n\n // On clicking the EULA link, open in a new window.\n this.getModal().on(CustomEvents.events.activate, SELECTORS.EULA_LINK, function(e) {\n e.preventDefault();\n window.open(\n Config.wwwroot + '/plagiarism/turnitinsim/eula.php?cmd=eularedirect&sesskey=' + Config.sesskey,\n '_blank'\n );\n });\n\n // On accepting the EULA, update the db and queue submissions for this module.\n this.getModal().on(CustomEvents.events.activate, SELECTORS.ACCEPT_BUTTON, function() {\n var modal = this;\n\n $.ajax({\n type: \"POST\",\n url: Config.wwwroot + \"/plagiarism/turnitinsim/ajax/eula_response.php\",\n dataType: \"json\",\n data: {\n action: 'accept_eula',\n contextid: Config.contextid,\n sesskey: Config.sesskey\n },\n success: function() {\n modal.hide();\n var link = window.location.origin + window.location.pathname + window.location.search + '&eula=1';\n window.location.href = link;\n }\n });\n\n }.bind(this));\n\n // On cancel, then hide the modal.\n this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, function(e, data) {\n\n var cancelEvent = $.Event(ModalEvents.cancel);\n this.getRoot().trigger(cancelEvent, this);\n\n if (!cancelEvent.isDefaultPrevented()) {\n this.hide();\n data.originalEvent.preventDefault();\n }\n }.bind(this));\n };\n\n // Automatically register with the modal registry the first time this module is imported so that\n // you can create modals of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(ModalTcEula.TYPE, ModalTcEula, 'plagiarism_turnitinsim/modal_eula');\n registered = true;\n }\n\n return ModalTcEula;\n }\n);"],"file":"modal_eula.min.js"} \ No newline at end of file diff --git a/amd/build/resend_submission.min.js b/amd/build/resend_submission.min.js index 07ae5e3..49704fa 100644 --- a/amd/build/resend_submission.min.js +++ b/amd/build/resend_submission.min.js @@ -1,2 +1,2 @@ -define ("plagiarism_turnitinsim/resend_submission",["jquery"],function(a){return{resendSubmission:function resendSubmission(){a(document).on("click",".pp_resubmit_link",function(){a(this).hide();a(this).siblings(".pp_resubmitting").removeClass("hidden");var b=a(this),c=a(this).attr("class").split(/\s+/),d=0;a(c).each(function(a){if(c[a].match("^pp_resubmit_id_")){d=c[a].split("_")[3]}});a.ajax({type:"POST",url:M.cfg.wwwroot+"/plagiarism/turnitinsim/ajax/resend_submission.php",dataType:"text",data:{action:"resubmit_event",submissionid:d,sesskey:M.cfg.sesskey},success:function success(){b.siblings(".turnitinsim_status").removeClass("hidden");b.siblings(".tii_status_text").html(M.str.plagiarism_turnitinsim.submissiondisplaystatusqueued);b.siblings(".pp_resubmitting").addClass("hidden")},error:function error(){b.show();b.siblings(".pp_resubmitting").addClass("hidden")}})})}}}); +define ("plagiarism_turnitinsim/resend_submission",["jquery","core/str"],function(a,b){return{resendSubmission:function resendSubmission(){a(document).on("click",".pp_resubmit_link",function(){a(this).hide();a(this).siblings(".pp_resubmitting").removeClass("hidden");var c=a(this),d=a(this).attr("class").split(/\s+/),e=0;a(d).each(function(a){if(d[a].match("^pp_resubmit_id_")){e=d[a].split("_")[3]}});a.ajax({type:"POST",url:M.cfg.wwwroot+"/plagiarism/turnitinsim/ajax/resend_submission.php",dataType:"text",data:{action:"resubmit_event",submissionid:e,sesskey:M.cfg.sesskey},success:function success(){c.siblings(".turnitinsim_status").removeClass("hidden");b.get_string("euladeclined","plagiarism_turnitinsim").done(function(a){c.siblings(".tii_status_text").html(a)});c.siblings(".pp_resubmitting").addClass("hidden")},error:function error(){c.show();c.siblings(".pp_resubmitting").addClass("hidden")}})})}}}); //# sourceMappingURL=resend_submission.min.js.map diff --git a/amd/build/resend_submission.min.js.map b/amd/build/resend_submission.min.js.map index 6c146eb..939db0b 100644 --- a/amd/build/resend_submission.min.js.map +++ b/amd/build/resend_submission.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/resend_submission.js"],"names":["define","$","resendSubmission","document","on","hide","siblings","removeClass","that","classList","attr","split","submissionid","each","index","match","ajax","type","url","M","cfg","wwwroot","dataType","data","action","sesskey","success","html","str","plagiarism_turnitinsim","submissiondisplaystatusqueued","addClass","error","show"],"mappings":"AA4BAA,OAAM,4CAAC,CAAC,QAAD,CAAD,CAAa,SAASC,CAAT,CAAY,CAC3B,MAAO,CACHC,gBAAgB,CAAE,2BAAW,CACzBD,CAAC,CAACE,QAAD,CAAD,CAAYC,EAAZ,CAAe,OAAf,CAAwB,mBAAxB,CAA6C,UAAW,CACpDH,CAAC,CAAC,IAAD,CAAD,CAAQI,IAAR,GACAJ,CAAC,CAAC,IAAD,CAAD,CAAQK,QAAR,CAAiB,kBAAjB,EAAqCC,WAArC,CAAiD,QAAjD,EAFoD,GAGhDC,CAAAA,CAAI,CAAGP,CAAC,CAAC,IAAD,CAHwC,CAMhDQ,CAAS,CAAGR,CAAC,CAAC,IAAD,CAAD,CAAQS,IAAR,CAAa,OAAb,EAAsBC,KAAtB,CAA4B,KAA5B,CANoC,CAOhDC,CAAY,CAAG,CAPiC,CAQpDX,CAAC,CAACQ,CAAD,CAAD,CAAaI,IAAb,CAAkB,SAASC,CAAT,CAAe,CAC7B,GAAIL,CAAS,CAACK,CAAD,CAAT,CAAiBC,KAAjB,CAAuB,kBAAvB,CAAJ,CAAgD,CAC5CH,CAAY,CAAGH,CAAS,CAACK,CAAD,CAAT,CAAiBH,KAAjB,CAAuB,GAAvB,EAA4B,CAA5B,CAClB,CACJ,CAJD,EAMAV,CAAC,CAACe,IAAF,CAAO,CACHC,IAAI,CAAE,MADH,CAEHC,GAAG,CAAEC,CAAC,CAACC,GAAF,CAAMC,OAAN,CAAgB,oDAFlB,CAGHC,QAAQ,CAAE,MAHP,CAIHC,IAAI,CAAE,CAACC,MAAM,CAAE,gBAAT,CAA2BZ,YAAY,CAAEA,CAAzC,CAAuDa,OAAO,CAAEN,CAAC,CAACC,GAAF,CAAMK,OAAtE,CAJH,CAKHC,OAAO,CAAE,kBAAW,CAChBlB,CAAI,CAACF,QAAL,CAAc,qBAAd,EAAqCC,WAArC,CAAiD,QAAjD,EACAC,CAAI,CAACF,QAAL,CAAc,kBAAd,EAAkCqB,IAAlC,CAAuCR,CAAC,CAACS,GAAF,CAAMC,sBAAN,CAA6BC,6BAApE,EACAtB,CAAI,CAACF,QAAL,CAAc,kBAAd,EAAkCyB,QAAlC,CAA2C,QAA3C,CACH,CATE,CAUHC,KAAK,CAAE,gBAAW,CACdxB,CAAI,CAACyB,IAAL,GACAzB,CAAI,CAACF,QAAL,CAAc,kBAAd,EAAkCyB,QAAlC,CAA2C,QAA3C,CACH,CAbE,CAAP,CAeH,CA7BD,CA8BH,CAhCE,CAkCV,CAnCK,CAAN","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 * Javascript controller for Requeueing submissions.\n *\n * @package plagiarism_turnitinsim\n * @copyright 2018 Turnitin\n * @author David Winn \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * @module plagiarism_turnitinsim/resendSubmission\n */\n\ndefine(['jquery'], function($) {\n return {\n resendSubmission: function() {\n $(document).on('click', '.pp_resubmit_link', function() {\n $(this).hide();\n $(this).siblings('.pp_resubmitting').removeClass('hidden');\n var that = $(this);\n\n // Moodle forums strip ids from elements so we have to use classes.\n var classList = $(this).attr('class').split(/\\s+/);\n var submissionid = 0;\n $(classList).each(function(index){\n if (classList[index].match(\"^pp_resubmit_id_\")) {\n submissionid = classList[index].split(\"_\")[3];\n }\n });\n\n $.ajax({\n type: \"POST\",\n url: M.cfg.wwwroot + \"/plagiarism/turnitinsim/ajax/resend_submission.php\",\n dataType: \"text\",\n data: {action: \"resubmit_event\", submissionid: submissionid, sesskey: M.cfg.sesskey},\n success: function() {\n that.siblings('.turnitinsim_status').removeClass('hidden');\n that.siblings('.tii_status_text').html(M.str.plagiarism_turnitinsim.submissiondisplaystatusqueued);\n that.siblings('.pp_resubmitting').addClass('hidden');\n },\n error: function() {\n that.show();\n that.siblings('.pp_resubmitting').addClass('hidden');\n }\n });\n });\n }\n };\n});"],"file":"resend_submission.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/resend_submission.js"],"names":["define","$","str","resendSubmission","document","on","hide","siblings","removeClass","that","classList","attr","split","submissionid","each","index","match","ajax","type","url","M","cfg","wwwroot","dataType","data","action","sesskey","success","get_string","done","text","html","addClass","error","show"],"mappings":"AA4BAA,OAAM,4CAAC,CAAC,QAAD,CAAW,UAAX,CAAD,CAAyB,SAASC,CAAT,CAAYC,CAAZ,CAAiB,CAC5C,MAAO,CACHC,gBAAgB,CAAE,2BAAW,CACzBF,CAAC,CAACG,QAAD,CAAD,CAAYC,EAAZ,CAAe,OAAf,CAAwB,mBAAxB,CAA6C,UAAW,CACpDJ,CAAC,CAAC,IAAD,CAAD,CAAQK,IAAR,GACAL,CAAC,CAAC,IAAD,CAAD,CAAQM,QAAR,CAAiB,kBAAjB,EAAqCC,WAArC,CAAiD,QAAjD,EAFoD,GAGhDC,CAAAA,CAAI,CAAGR,CAAC,CAAC,IAAD,CAHwC,CAMhDS,CAAS,CAAGT,CAAC,CAAC,IAAD,CAAD,CAAQU,IAAR,CAAa,OAAb,EAAsBC,KAAtB,CAA4B,KAA5B,CANoC,CAOhDC,CAAY,CAAG,CAPiC,CAQpDZ,CAAC,CAACS,CAAD,CAAD,CAAaI,IAAb,CAAkB,SAASC,CAAT,CAAgB,CAC9B,GAAIL,CAAS,CAACK,CAAD,CAAT,CAAiBC,KAAjB,CAAuB,kBAAvB,CAAJ,CAAgD,CAC5CH,CAAY,CAAGH,CAAS,CAACK,CAAD,CAAT,CAAiBH,KAAjB,CAAuB,GAAvB,EAA4B,CAA5B,CAClB,CACJ,CAJD,EAMAX,CAAC,CAACgB,IAAF,CAAO,CACHC,IAAI,CAAE,MADH,CAEHC,GAAG,CAAEC,CAAC,CAACC,GAAF,CAAMC,OAAN,CAAgB,oDAFlB,CAGHC,QAAQ,CAAE,MAHP,CAIHC,IAAI,CAAE,CAACC,MAAM,CAAE,gBAAT,CAA2BZ,YAAY,CAAEA,CAAzC,CAAuDa,OAAO,CAAEN,CAAC,CAACC,GAAF,CAAMK,OAAtE,CAJH,CAKHC,OAAO,CAAE,kBAAW,CAChBlB,CAAI,CAACF,QAAL,CAAc,qBAAd,EAAqCC,WAArC,CAAiD,QAAjD,EAEAN,CAAG,CAAC0B,UAAJ,CAAe,cAAf,CAA+B,wBAA/B,EAAyDC,IAAzD,CAA8D,SAASC,CAAT,CAAe,CACzErB,CAAI,CAACF,QAAL,CAAc,kBAAd,EAAkCwB,IAAlC,CAAuCD,CAAvC,CACH,CAFD,EAIArB,CAAI,CAACF,QAAL,CAAc,kBAAd,EAAkCyB,QAAlC,CAA2C,QAA3C,CACH,CAbE,CAcHC,KAAK,CAAE,gBAAW,CACdxB,CAAI,CAACyB,IAAL,GACAzB,CAAI,CAACF,QAAL,CAAc,kBAAd,EAAkCyB,QAAlC,CAA2C,QAA3C,CACH,CAjBE,CAAP,CAmBH,CAjCD,CAkCH,CApCE,CAsCV,CAvCK,CAAN","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 * Javascript controller for Requeueing submissions.\n *\n * @package plagiarism_turnitinsim\n * @copyright 2018 Turnitin\n * @author David Winn \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * @module plagiarism_turnitinsim/resendSubmission\n */\n\ndefine(['jquery', 'core/str'], function($, str) {\n return {\n resendSubmission: function() {\n $(document).on('click', '.pp_resubmit_link', function() {\n $(this).hide();\n $(this).siblings('.pp_resubmitting').removeClass('hidden');\n var that = $(this);\n\n // Moodle forums strip ids from elements so we have to use classes.\n var classList = $(this).attr('class').split(/\\s+/);\n var submissionid = 0;\n $(classList).each(function(index) {\n if (classList[index].match(\"^pp_resubmit_id_\")) {\n submissionid = classList[index].split(\"_\")[3];\n }\n });\n\n $.ajax({\n type: \"POST\",\n url: M.cfg.wwwroot + \"/plagiarism/turnitinsim/ajax/resend_submission.php\",\n dataType: \"text\",\n data: {action: \"resubmit_event\", submissionid: submissionid, sesskey: M.cfg.sesskey},\n success: function() {\n that.siblings('.turnitinsim_status').removeClass('hidden');\n\n str.get_string('euladeclined', 'plagiarism_turnitinsim').done(function(text) {\n that.siblings('.tii_status_text').html(text);\n });\n\n that.siblings('.pp_resubmitting').addClass('hidden');\n },\n error: function() {\n that.show();\n that.siblings('.pp_resubmitting').addClass('hidden');\n }\n });\n });\n }\n };\n});"],"file":"resend_submission.min.js"} \ No newline at end of file diff --git a/amd/build/set_report_generation.min.js b/amd/build/set_report_generation.min.js index 606edc8..c77b24c 100644 --- a/amd/build/set_report_generation.min.js +++ b/amd/build/set_report_generation.min.js @@ -1,2 +1,2 @@ -define ("plagiarism_turnitinsim/set_report_generation",["jquery"],function(a){return{set_report_generation:function set_report_generation(){a(document).on("click","input[name=\"duedate[enabled]\"]",function(){if(!a(this).is(":checked")){a("select[name=reportgeneration]")[0].selectedIndex=0}})}}}); +define ("plagiarism_turnitinsim/set_report_generation",["jquery"],function(a){return{setReportGeneration:function setReportGeneration(){a(document).on("click","input[name=\"duedate[enabled]\"]",function(){if(!a(this).is(":checked")){a("select[name=reportgeneration]")[0].selectedIndex=0}})}}}); //# sourceMappingURL=set_report_generation.min.js.map diff --git a/amd/build/set_report_generation.min.js.map b/amd/build/set_report_generation.min.js.map index 7a2c20b..9cfa214 100644 --- a/amd/build/set_report_generation.min.js.map +++ b/amd/build/set_report_generation.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/set_report_generation.js"],"names":["define","$","set_report_generation","document","on","is","selectedIndex"],"mappings":"AA4BAA,OAAM,gDAAC,CAAC,QAAD,CAAD,CAAa,SAASC,CAAT,CAAY,CAC3B,MAAO,CACHC,qBAAqB,CAAE,gCAAW,CAC9BD,CAAC,CAACE,QAAD,CAAD,CAAYC,EAAZ,CAAe,OAAf,CAAwB,kCAAxB,CAA0D,UAAW,CACjE,GAAI,CAACH,CAAC,CAAC,IAAD,CAAD,CAAQI,EAAR,CAAW,UAAX,CAAL,CAA6B,CACzBJ,CAAC,CAAC,+BAAD,CAAD,CAAmC,CAAnC,EAAsCK,aAAtC,CAAsD,CACzD,CACJ,CAJD,CAKH,CAPE,CASV,CAVK,CAAN","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 * Javascript controller for the defaulting report generation to immediate if due date is disabled in settings.\n *\n * @package plagiarism_turnitinsim\n * @copyright 2018 Turnitin\n * @author John McGettrick \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * @module plagiarism_turnitinsim/set_report_generation\n */\n\ndefine(['jquery'], function($) {\n return {\n set_report_generation: function() {\n $(document).on('click', 'input[name=\"duedate[enabled]\"]', function() {\n if (!$(this).is(\":checked\")) {\n $('select[name=reportgeneration]')[0].selectedIndex = 0;\n }\n });\n }\n };\n});"],"file":"set_report_generation.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/set_report_generation.js"],"names":["define","$","setReportGeneration","document","on","is","selectedIndex"],"mappings":"AA4BAA,OAAM,gDAAC,CAAC,QAAD,CAAD,CAAa,SAASC,CAAT,CAAY,CAC3B,MAAO,CACHC,mBAAmB,CAAE,8BAAW,CAC5BD,CAAC,CAACE,QAAD,CAAD,CAAYC,EAAZ,CAAe,OAAf,CAAwB,kCAAxB,CAA0D,UAAW,CACjE,GAAI,CAACH,CAAC,CAAC,IAAD,CAAD,CAAQI,EAAR,CAAW,UAAX,CAAL,CAA6B,CACzBJ,CAAC,CAAC,+BAAD,CAAD,CAAmC,CAAnC,EAAsCK,aAAtC,CAAsD,CACzD,CACJ,CAJD,CAKH,CAPE,CASV,CAVK,CAAN","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 * Javascript controller for the defaulting report generation to immediate if due date is disabled in settings.\n *\n * @package plagiarism_turnitinsim\n * @copyright 2018 Turnitin\n * @author John McGettrick \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * @module plagiarism_turnitinsim/set_report_generation\n */\n\ndefine(['jquery'], function($) {\n return {\n setReportGeneration: function() {\n $(document).on('click', 'input[name=\"duedate[enabled]\"]', function() {\n if (!$(this).is(\":checked\")) {\n $('select[name=reportgeneration]')[0].selectedIndex = 0;\n }\n });\n }\n };\n});"],"file":"set_report_generation.min.js"} \ No newline at end of file diff --git a/amd/src/connection_test.js b/amd/src/connection_test.js index 217b7a5..a07e27c 100644 --- a/amd/src/connection_test.js +++ b/amd/src/connection_test.js @@ -26,7 +26,7 @@ * @module plagiarism_turnitinsim/connection_test */ -define(['jquery'], function($) { +define(['jquery', 'core/str'], function($, str) { return { connectionTest: function() { // Store connection test selector. @@ -49,12 +49,16 @@ define(['jquery'], function($) { ct.removeClass("connection-test-failed"); ct.addClass("connection-test-success"); - changeString(ct, M.str.plagiarism_turnitinsim.connecttestsuccess); + str.get_string('connecttestsuccess', 'plagiarism_turnitinsim').done(function(text) { + changeString(ct, text); + }); } else { ct.removeClass("connection-test-success"); ct.addClass("connection-test-failed"); - changeString(ct, M.str.plagiarism_turnitinsim.connecttestfailed); + str.get_string('connecttestfailed', 'plagiarism_turnitinsim').done(function(text) { + changeString(ct, text); + }); } // Fade out classes and swap back values. @@ -62,7 +66,9 @@ define(['jquery'], function($) { $(this).removeClass("turnitinsim_connection-test-failed"); $(this).removeClass("turnitinsim_connection-test-success"); - changeString(ct, M.str.plagiarism_turnitinsim.connecttest); + str.get_string('connecttest', 'plagiarism_turnitinsim').done(function(text) { + changeString(ct, text); + }); }).fadeIn("slow"); } }); diff --git a/amd/src/cv_launch.js b/amd/src/cv_launch.js index 9722883..587d930 100644 --- a/amd/src/cv_launch.js +++ b/amd/src/cv_launch.js @@ -26,15 +26,15 @@ * @module plagiarism_turnitinsim/cv_launch */ -define(['jquery'], function($) { +define(['jquery', 'core/str'], function($, str) { return { - open_cv: function() { + openCv: function() { $(document).on('click', '.or_score', function() { // Moodle forums strip ids from elements so we have to use classes. var classList = $(this).parent().attr('class').split(/\s+/); var submissionid = 0; - $(classList).each(function(index){ + $(classList).each(function(index) { if (classList[index].match("^submission_")) { submissionid = classList[index].split("_")[1]; } @@ -46,8 +46,12 @@ define(['jquery'], function($) { var loading = '
'; var icon = M.cfg.wwwroot + '/plagiarism/turnitinsim/pix/tiiIcon.svg'; loading += ''; - var loadingCvStr = M.str.plagiarism_turnitinsim.loadingcv; - loading += '

' + loadingCvStr + '

'; + + str.get_string('loadingcv', 'plagiarism_turnitinsim').done(function(text) { + loading += '

' + text + '

'; + $('.eulacontainer').hide().html(text).fadeIn(); + }); + loading += '
'; $(dvWindow.document.body).html(loading); diff --git a/amd/src/eula_response.js b/amd/src/eula_response.js index ff45f92..87b2ecc 100644 --- a/amd/src/eula_response.js +++ b/amd/src/eula_response.js @@ -26,9 +26,9 @@ * @module plagiarism_turnitinsim/handleEulaResponse */ -define(['jquery'], function($) { +define(['jquery', 'core/str'], function($, str) { return { - eula_response: function() { + eulaResponse: function() { $(document).ready(function() { $('input[name=submitbutton]').prop('disabled', 'disabled'); }); @@ -43,13 +43,18 @@ define(['jquery'], function($) { dataType: "text", data: {action: "accept_eula", sesskey: M.cfg.sesskey}, success: function() { - $('.eulacontainer').hide().html(M.str.plagiarism_turnitinsim.eulaaccepted).fadeIn(); + str.get_string('eulaaccepted', 'plagiarism_turnitinsim').done(function(text) { + $('.eulacontainer').hide().html(text).fadeIn(); + }); } }); }); $(document).on('click', '#pp-eula-decline', function() { - $('.eulacontainer').hide().html(M.str.plagiarism_turnitinsim.euladeclined).fadeIn(); + str.get_string('euladeclined', 'plagiarism_turnitinsim').done(function(text) { + $('.eulacontainer').hide().html(text).fadeIn(); + }); + $('input[name=submitbutton]').prop('disabled', ''); }); } diff --git a/amd/src/inbox_eula_launch.js b/amd/src/inbox_eula_launch.js index d8e2dbe..1fd49de 100644 --- a/amd/src/inbox_eula_launch.js +++ b/amd/src/inbox_eula_launch.js @@ -24,7 +24,7 @@ define(['jquery', ], function($, Templates, ModalFactory, ModalTcEula) { return { - inbox_eula_launch: function() { + inboxEulaLaunch: function() { var trigger = $('.eula-row-launch'); ModalFactory.create( diff --git a/amd/src/modal_eula.js b/amd/src/modal_eula.js index c62a65f..034464f 100644 --- a/amd/src/modal_eula.js +++ b/amd/src/modal_eula.js @@ -74,7 +74,7 @@ define( Config.wwwroot + '/plagiarism/turnitinsim/eula.php?cmd=eularedirect&sesskey=' + Config.sesskey, '_blank' ); - }.bind(this)); + }); // On accepting the EULA, update the db and queue submissions for this module. this.getModal().on(CustomEvents.events.activate, SELECTORS.ACCEPT_BUTTON, function() { @@ -89,7 +89,7 @@ define( contextid: Config.contextid, sesskey: Config.sesskey }, - success: function () { + success: function() { modal.hide(); var link = window.location.origin + window.location.pathname + window.location.search + '&eula=1'; window.location.href = link; diff --git a/amd/src/resend_submission.js b/amd/src/resend_submission.js index c87b5b8..5cbb00f 100644 --- a/amd/src/resend_submission.js +++ b/amd/src/resend_submission.js @@ -26,7 +26,7 @@ * @module plagiarism_turnitinsim/resendSubmission */ -define(['jquery'], function($) { +define(['jquery', 'core/str'], function($, str) { return { resendSubmission: function() { $(document).on('click', '.pp_resubmit_link', function() { @@ -37,7 +37,7 @@ define(['jquery'], function($) { // Moodle forums strip ids from elements so we have to use classes. var classList = $(this).attr('class').split(/\s+/); var submissionid = 0; - $(classList).each(function(index){ + $(classList).each(function(index) { if (classList[index].match("^pp_resubmit_id_")) { submissionid = classList[index].split("_")[3]; } @@ -50,7 +50,11 @@ define(['jquery'], function($) { data: {action: "resubmit_event", submissionid: submissionid, sesskey: M.cfg.sesskey}, success: function() { that.siblings('.turnitinsim_status').removeClass('hidden'); - that.siblings('.tii_status_text').html(M.str.plagiarism_turnitinsim.submissiondisplaystatusqueued); + + str.get_string('euladeclined', 'plagiarism_turnitinsim').done(function(text) { + that.siblings('.tii_status_text').html(text); + }); + that.siblings('.pp_resubmitting').addClass('hidden'); }, error: function() { diff --git a/amd/src/set_report_generation.js b/amd/src/set_report_generation.js index a6ca6a4..bee955e 100644 --- a/amd/src/set_report_generation.js +++ b/amd/src/set_report_generation.js @@ -28,7 +28,7 @@ define(['jquery'], function($) { return { - set_report_generation: function() { + setReportGeneration: function() { $(document).on('click', 'input[name="duedate[enabled]"]', function() { if (!$(this).is(":checked")) { $('select[name=reportgeneration]')[0].selectedIndex = 0; diff --git a/backup/moodle2/backup_plagiarism_turnitinsim_plugin.class.php b/backup/moodle2/backup_plagiarism_turnitinsim_plugin.class.php index ba71953..76f3431 100644 --- a/backup/moodle2/backup_plagiarism_turnitinsim_plugin.class.php +++ b/backup/moodle2/backup_plagiarism_turnitinsim_plugin.class.php @@ -25,8 +25,18 @@ defined('MOODLE_INTERNAL') || die(); +/** + * Used when backing up data created by the plugin. + */ class backup_plagiarism_turnitinsim_plugin extends backup_plagiarism_plugin { + /** + * Required by Moodle's backup tool to define the plugin structure. + * + * @return backup_plugin_element + * @throws backup_step_exception + * @throws base_element_struct_exception + */ protected function define_module_plugin_structure() { $plugin = $this->get_plugin_element(); diff --git a/backup/moodle2/restore_plagiarism_turnitinsim_plugin.class.php b/backup/moodle2/restore_plagiarism_turnitinsim_plugin.class.php index 1bc2aa9..80a2bd8 100644 --- a/backup/moodle2/restore_plagiarism_turnitinsim_plugin.class.php +++ b/backup/moodle2/restore_plagiarism_turnitinsim_plugin.class.php @@ -25,6 +25,9 @@ defined('MOODLE_INTERNAL') || die(); +/** + * Used when restoring data created by the plugin. + */ class restore_plagiarism_turnitinsim_plugin extends restore_plagiarism_plugin { /** @@ -42,6 +45,9 @@ protected function define_module_plugin_structure() { /** * Restore the Turnitin settings for this module. * This will only be done if the module is from the same site from where it was backed up. + * + * @param $data object The data we are restoring. + * @throws dml_exception */ public function process_turnitinsim_mods($data) { global $DB; @@ -59,6 +65,9 @@ public function process_turnitinsim_mods($data) { * Restore the links to Turnitin submissions. * This will only be done if the module is from the same site from where it was backed up * and if the Turnitin submission does not currently exist in the database. + * + * @param $data object The data we are restoring. + * @throws dml_exception */ public function process_turnitinsim_subs($data) { global $DB, $SESSION; @@ -83,6 +92,9 @@ public function process_turnitinsim_subs($data) { * Restore the Turnitin users. * This will only be done if the module is from the same site from where it was backed up * and if the Turnitin user id does not currently exist in the database. + * + * @param $data object The data we are restoring. + * @throws dml_exception */ public function process_turnitinsim_usrs($data) { global $DB; diff --git a/callbacks.php b/callbacks.php index ef3523d..56a4803 100644 --- a/callbacks.php +++ b/callbacks.php @@ -86,7 +86,8 @@ } // Handle Similarity complete callback. -if ($reqheaders['X-Turnitin-EventType'] == TURNITINSIM_SIMILARITY_COMPLETE || $reqheaders['X-Turnitin-EventType'] == TURNITINSIM_SIMILARITY_UPDATED) { +if ($reqheaders['X-Turnitin-EventType'] == TURNITINSIM_SIMILARITY_COMPLETE || + $reqheaders['X-Turnitin-EventType'] == TURNITINSIM_SIMILARITY_UPDATED) { // Get Moodle submission id from Turnitin id. $submission = $DB->get_record_select('plagiarism_turnitinsim_sub', 'turnitinid = ?', array($params->submission_id)); $tssubmission = new plagiarism_turnitinsim_submission( new plagiarism_turnitinsim_request(), $submission->id ); diff --git a/classes/assign.class.php b/classes/assign.class.php index d8bc4a0..29d68a7 100644 --- a/classes/assign.class.php +++ b/classes/assign.class.php @@ -25,13 +25,17 @@ defined('MOODLE_INTERNAL') || die(); +/** + * Helper class for plagiarism_turnitinsim component in assignments + */ class plagiarism_turnitinsim_assign { /** * Get the text from the database for the submission. * - * @param $itemid - * @return mixed + * @param $itemid String The itemid for this submission. + * @return mixed The text of the submission. + * @throws dml_exception */ public function get_onlinetext($itemid) { global $DB; @@ -44,8 +48,9 @@ public function get_onlinetext($itemid) { /** * Get the item id from the database for this submission. * - * @param $params - * @return mixed + * @param $params object The params to call the DB with. + * @return int The itemid. + * @throws dml_exception */ public function get_itemid($params) { global $DB; @@ -65,10 +70,13 @@ public function get_itemid($params) { /** * Get the actual author of the submission. * - * @param $userid - * @param $relateduserid - * @param $cm - * @param $itemid + * @param $userid int The userid as given by Moodle. + * @param $relateduserid int The relateduserid as given by Moodle. + * @param $cm object The course module. + * @param $itemid string the itemid for this submission. + * @return int The authorid. + * @throws coding_exception + * @throws dml_exception */ public function get_author($userid, $relateduserid, $cm, $itemid) { $author = (!empty($relateduserid)) ? $relateduserid : $userid; @@ -94,8 +102,9 @@ public function get_author($userid, $relateduserid, $cm, $itemid) { /** * Get the group id that a submission belongs to. * - * @param $itemid - * @return int + * @param $itemid string The itemid for the submission. + * @return int The group id. + * @throws dml_exception */ public function get_groupid($itemid) { global $DB; @@ -105,13 +114,14 @@ public function get_groupid($itemid) { return (!empty($moodlesubmission->groupid)) ? $moodlesubmission->groupid : null; } - /* + /** * Related user ID will be NULL if an instructor submits on behalf of a student who is in a group. * To get around this, we get the group ID, get the group members and set the author as the first student in the group. * @param int $courseid - The course ID. * @param int $groupid - The ID of the Moodle group that we're getting from. * @return int $author The Moodle user ID that we'll be using for the author. + * @throws coding_exception */ public function get_first_group_author($courseid, $groupid) { static $context; @@ -132,8 +142,9 @@ public function get_first_group_author($courseid, $groupid) { /** * Return whether the submission is a draft. * - * @param $itemid - * @return bool + * @param $itemid string The itemid for the submission. + * @return bool If the submission is a draft. + * @throws dml_exception */ public function is_submission_draft($itemid) { global $DB; @@ -143,9 +154,12 @@ public function is_submission_draft($itemid) { return ($moodlesubmission->status == 'draft') ? true : false; } - /* + /** * Get the assignment due date. - * @param $id + * + * @param $id int The assignment ID we want the due date for. + * @return mixed The due date for the assignment. + * @throws dml_exception */ public function get_due_date($id) { global $DB; @@ -155,12 +169,12 @@ public function get_due_date($id) { return $module->duedate; } - /* + /** * Determines whether the OR links in other posts should be seen. This is not applicable for assignments. * - * @param $courseid - * @param $userid - * @return bool + * @param $courseid int The ID for this course. + * @param $userid int The userid. + * @return bool if showing other posts links. */ public function show_other_posts_links($courseid, $userid) { return true; diff --git a/classes/callback.class.php b/classes/callback.class.php index e8acf8e..f3654af 100644 --- a/classes/callback.class.php +++ b/classes/callback.class.php @@ -27,10 +27,18 @@ defined('MOODLE_INTERNAL') || die(); +/** + * Class for handling callbacks from Turnitin. + */ class plagiarism_turnitinsim_callback { public $tsrequest; + /** + * plagiarism_turnitinsim_callback constructor. + * + * @param plagiarism_turnitinsim_request|null $tsrequest The request we're handling. + */ public function __construct(plagiarism_turnitinsim_request $tsrequest = null ) { $this->tsrequest = $tsrequest; } @@ -38,10 +46,10 @@ public function __construct(plagiarism_turnitinsim_request $tsrequest = null ) { /** * Attempt to retrieve the webhook. * - * @param $webhookid - * @return bool + * @param $webhookid string The webhookid to check. + * @return bool true if has webhook. */ - public function get_webhook($webhookid) { + public function has_webhook($webhookid) { // Make request to get webhook. try { $endpoint = TURNITINSIM_ENDPOINT_GET_WEBHOOK; @@ -78,8 +86,8 @@ public function get_webhook($webhookid) { /** * Attempt to delete the webhook (not currently used). * - * @param $webhookid - * @return bool + * @param $webhookid string The webhookid to be deleted. + * @return bool true if webhook has been deleted. */ public function delete_webhook($webhookid) { // Make request to get webhook. @@ -115,7 +123,11 @@ public function create_webhook() { $request['signing_secret'] = $secret; $request['description'] = get_string('webhook_description', 'plagiarism_turnitinsim', TURNITINSIM_CALLBACK_URL); $request['url'] = TURNITINSIM_CALLBACK_URL; - $request['event_types'] = array(TURNITINSIM_SUBMISSION_COMPLETE, TURNITINSIM_SIMILARITY_COMPLETE, TURNITINSIM_SIMILARITY_UPDATED); + $request['event_types'] = array( + TURNITINSIM_SUBMISSION_COMPLETE, + TURNITINSIM_SIMILARITY_COMPLETE, + TURNITINSIM_SIMILARITY_UPDATED + ); $request['allow_insecure'] = preg_match("@^https?://@", $CFG->wwwroot) ? true : false; // Make request to add webhook. @@ -141,11 +153,15 @@ public function create_webhook() { } /** - * Handle callbacks from Turnitin. + * Generate a 64 character length hash of the request string. + * + * @param $requeststring string The request in string format. + * @return string A 64 character length hash. + * @throws dml_exception */ - public function expected_callback_signature($requeststr) { + public function expected_callback_signature($requeststring) { $secret = get_config('plagiarism_turnitinsim', 'turnitin_webhook_secret'); - $sig = hash_hmac('sha256', $requeststr, base64_decode($secret)); + $sig = hash_hmac('sha256', $requeststring, base64_decode($secret)); return $sig; } @@ -153,7 +169,8 @@ public function expected_callback_signature($requeststr) { /** * Generate random webhook secret. * - * @return string + * @return string Random webhook secret. + * @throws Exception */ public function generate_secret() { $randomstring = random_bytes(20); diff --git a/classes/defaults_form.class.php b/classes/defaults_form.class.php index e0260be..34cbcb2 100644 --- a/classes/defaults_form.class.php +++ b/classes/defaults_form.class.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Default setting form for plagiarism_turnitinsim component + * Default setting form for plagiarism_turnitinsim component. * * @package plagiarism_turnitinsim * @copyright 2018 Turnitin @@ -28,9 +28,17 @@ require_once($CFG->libdir."/formslib.php"); require_once($CFG->dirroot.'/plagiarism/turnitinsim/classes/settings.class.php'); +/** + * Default setting form for plagiarism_turnitinsim component. + */ class plagiarism_turnitinsim_defaults_form extends moodleform { - // Define the form. + /** + * Form definition required when building a Moodle form. + * + * @throws dml_exception + * @throws coding_exception + */ public function definition () { $mform =& $this->_form; @@ -44,7 +52,7 @@ public function definition () { * Display the form, saving the contents of the output buffer overriding Moodle's * display function that prints to screen when called * - * @return the form as an object to print to screen at our convenience + * @return string The form as an object to print to screen at our convenience */ public function display() { ob_start(); @@ -58,6 +66,13 @@ public function display() { /** * Save the default settings */ + + /** + * Save the default settings + * + * @param $data object The form data we were passed and need to save. + * @throws dml_exception + */ public function save($data) { $settings = new plagiarism_turnitinsim_settings(); $data->coursemodule = 0; diff --git a/classes/eula.class.php b/classes/eula.class.php index a089afa..091dd54 100644 --- a/classes/eula.class.php +++ b/classes/eula.class.php @@ -25,10 +25,18 @@ defined('MOODLE_INTERNAL') || die(); +/** + * Class for handling Turnitin's EULA. + */ class plagiarism_turnitinsim_eula { public $tsrequest; + /** + * plagiarism_turnitinsim_eula constructor. + * + * @param plagiarism_turnitinsim_request|null $tsrequest The request we're handling. + */ public function __construct(plagiarism_turnitinsim_request $tsrequest = null ) { $this->tsrequest = ($tsrequest) ? $tsrequest : new plagiarism_turnitinsim_request(); } diff --git a/classes/forum.class.php b/classes/forum.class.php index c93c5e4..3003a51 100644 --- a/classes/forum.class.php +++ b/classes/forum.class.php @@ -25,13 +25,17 @@ defined('MOODLE_INTERNAL') || die(); +/** + * Helper class for plagiarism_turnitinsim component in forums + */ class plagiarism_turnitinsim_forum { /** - * Get the text from the database for the forum post. + * Get the text from the database for the submission. * - * @param $itemid - * @return mixed + * @param $itemid String The itemid for this submission. + * @return mixed The text of the submission. + * @throws dml_exception */ public function get_onlinetext($itemid) { global $DB; @@ -43,8 +47,9 @@ public function get_onlinetext($itemid) { /** * Get the item id from the database for this submission. * - * @param $params - * @return $postid + * @param $params object The params to call the DB with. + * @return int The itemid. + * @throws dml_exception */ public function get_itemid($params) { global $DB; @@ -64,19 +69,19 @@ public function get_itemid($params) { /** * Get the actual author of the submission. * - * @param $userid - * @param $relateduserid - * @param $cmid + * @param $userid int The userid as given by Moodle. + * @param $relateduserid int The relateduserid as given by Moodle. + * @return int The authorid. */ - public function get_author($userid, $relateduserid, $cmid, $itemid) { + public function get_author($userid, $relateduserid) { return (!empty($relateduserid)) ? $relateduserid : $userid; } /** - * Get the group id that a submission belongs to - (N/A in forums). + * Get the group id that a submission belongs to. - (N/A in forums). * - * @param $itemid - * @return null + * @param $itemid string The itemid for the submission. + * @return int The group id. */ public function get_groupid($itemid) { return null; @@ -85,8 +90,8 @@ public function get_groupid($itemid) { /** * Return whether the submission is a draft. Never the case with a forum submission. * - * @param $itemid - * @return bool + * @param $itemid string The itemid for the submission. + * @return bool If the submission is a draft. */ public function is_submission_draft($itemid) { return false; @@ -98,16 +103,24 @@ public function is_submission_draft($itemid) { * @param $id * @return int */ + + /** + * Return the due date so we can work out report generation time. Not applicable to forums. + * + * @param $id int The forum ID we want the due date for. + * @return int The due date for the assignment. + */ public function get_due_date($id) { return 0; } - /* + /** * Determines whether the OR links in other posts should be seen. * - * @param $courseid - * @param $userid - * @return bool + * @param $courseid int The ID for this course. + * @param $userid int The userid. + * @return bool if showing other posts links. + * @throws coding_exception */ public function show_other_posts_links($courseid, $userid) { global $USER; diff --git a/classes/group.class.php b/classes/group.class.php index c869f50..cab1ae7 100644 --- a/classes/group.class.php +++ b/classes/group.class.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Group class for plagiarism_turnitinsim component + * Group class for plagiarism_turnitinsim component. * * @package plagiarism_turnitinsim * @copyright 2017 Turnitin @@ -27,11 +27,26 @@ require_once($CFG->dirroot . '/plagiarism/turnitinsim/utilities/handle_deprecation.php'); +/** + * Group class for plagiarism_turnitinsim component. + */ class plagiarism_turnitinsim_group { + /** + * @var int The ID of the grup. + */ public $groupid; + + /** + * @var string The Turnitin group ID for the group. + */ public $turnitinid; + /** + * plagiarism_turnitinsim_group constructor. + * @param $groupid int The ID of the group. + * @throws dml_exception + */ public function __construct($groupid) { global $DB; @@ -67,6 +82,8 @@ public function create_turnitinid() { } /** + * Get the group ID. + * * @return mixed */ public function get_groupid() { @@ -74,6 +91,8 @@ public function get_groupid() { } /** + * Set the group ID. + * * @param mixed $groupid */ public function set_groupid($groupid) { @@ -81,6 +100,8 @@ public function set_groupid($groupid) { } /** + * Get the Turnitin group ID. + * * @return mixed */ public function get_turnitinid() { @@ -88,6 +109,8 @@ public function get_turnitinid() { } /** + * Set the Turnitin group ID. + * * @param mixed $turnitinid */ public function set_turnitinid($turnitinid) { diff --git a/classes/logger.class.php b/classes/logger.class.php index 9d83c1b..76673ff 100644 --- a/classes/logger.class.php +++ b/classes/logger.class.php @@ -17,9 +17,10 @@ /** * Log API requests and responses from Turnitin. * - * @package plagiarism_turnitinsim - * @author John McGettrick http://www.turnitin.com - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package plagiarism_turnitinsim + * @copyright 2018 Turnitin + * @author John McGettrick + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); @@ -30,12 +31,29 @@ use Katzgrau\KLogger; +/** + * Log API requests and responses from Turnitin. + */ class plagiarism_turnitinsim_logger extends Katzgrau\KLogger\Logger { + /** + * The location of the log directory. + */ const LOG_DIR = '/turnitinsim/logs/'; + + /** + * The number of logs to keep. + */ const KEEPLOGS = 10; + + /** + * The prefix for the API log file name. + */ const APILOG_PREFIX = 'apilog_'; + /** + * plagiarism_turnitinsim_logger constructor. + */ public function __construct() { global $CFG; @@ -49,7 +67,7 @@ public function __construct() { /** * Rotate logs, only keep the last KEEPLOGS number of logs. * - * @param $filepath + * @param $filepath string The file path for the logs. */ private function rotate_logs( $filepath ) { diff --git a/classes/message/get_webhook_failure.php b/classes/message/get_webhook_failure.php index 36b506c..bb34e6b 100644 --- a/classes/message/get_webhook_failure.php +++ b/classes/message/get_webhook_failure.php @@ -27,6 +27,9 @@ defined('MOODLE_INTERNAL') || die(); +/** + * Notification for admin that testing webhook check has failed. + */ class get_webhook_failure { /** * Send notification to site admins. diff --git a/classes/message/new_eula.php b/classes/message/new_eula.php index f47078b..ac4647e 100644 --- a/classes/message/new_eula.php +++ b/classes/message/new_eula.php @@ -27,6 +27,9 @@ defined('MOODLE_INTERNAL') || die(); +/** + * Notification for users that a new user is available that testing webhook check has failed. + */ class new_eula { /** * Send notification to site admins. diff --git a/classes/message/receipt_instructor.php b/classes/message/receipt_instructor.php index e9503d3..5561402 100644 --- a/classes/message/receipt_instructor.php +++ b/classes/message/receipt_instructor.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Instructor Digital Receipt for plagiarism_turnitinsim component + * Instructor Digital Receipt for plagiarism_turnitinsim component. * * @package plagiarism_turnitinsim * @copyright 2018 Turnitin @@ -27,13 +27,17 @@ defined('MOODLE_INTERNAL') || die(); +/** + * Instructor Digital Receipt for plagiarism_turnitinsim component + */ class receipt_instructor { /** * Send digital receipt to instructor. This message must preserve the anonymity of a submission. * - * @param array $input + * @param $input - used to build message * @return string + * @throws \coding_exception */ public function build_message($input) { $message = new \stdClass(); @@ -49,10 +53,10 @@ public function build_message($input) { /** * Send digital receipt to instructors. * - * @param array $instructors - * @param string $message - * @param int $courseid - * @return void + * @param $instructors array The instructors to send the receipt message to. + * @param $message string The message to send. + * @param $courseid int The ID for the course the submission is on. + * @throws \coding_exception */ public function send_message($instructors, $message, $courseid) { $eventdata = new \core\message\message(); diff --git a/classes/message/receipt_student.php b/classes/message/receipt_student.php index 96038aa..1ab76b8 100644 --- a/classes/message/receipt_student.php +++ b/classes/message/receipt_student.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Student Digital Receipt for plagiarism_turnitinsim component + * Student Digital Receipt for plagiarism_turnitinsim component. * * @package plagiarism_turnitinsim * @copyright 2018 Turnitin @@ -27,13 +27,17 @@ defined('MOODLE_INTERNAL') || die(); +/** + * Student Digital Receipt for plagiarism_turnitinsim component. + */ class receipt_student { /** * Build digital receipt to send to student * - * @param array $input - used to build message + * @param $input - used to build message * @return string + * @throws \coding_exception */ public function build_message($input) { $message = new \stdClass(); @@ -49,11 +53,12 @@ public function build_message($input) { } /** - * Send digital receipt to student + * Send digital receipt to student. * - * @param int $userid - * @param string $message - * @param int $courseid + * @param $userid int The userid to send the message to. + * @param $message string The message to send. + * @param $courseid int The ID for the course the submission is on. + * @throws \coding_exception */ public function send_message($userid, $message, $courseid) { $eventdata = new \core\message\message(); diff --git a/classes/observer.php b/classes/observer.php index a1b25da..e6ad12c 100644 --- a/classes/observer.php +++ b/classes/observer.php @@ -14,22 +14,33 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +/** + * Class for handling Moodle observers - for handling events. + * + * @package plagiarism_turnitinsim + * @copyright 2018 Turnitin + * @author John McGettrick + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + if (!defined('MOODLE_INTERNAL')) { die('Direct access to this script is forbidden.'); // It must be included from a Moodle page. } require_once($CFG->dirroot.'/plagiarism/turnitinsim/lib.php'); +/** + * Class for handling Moodle observers - for handling events. + */ class plagiarism_turnitinsim_observer { - /** * Build the eventdata array. * - * @param $event - * @param $eventtype - * @param $module - * @return array $eventdata + * @param $event object The event we are handling. + * @param $eventtype string The type of event we are handling. + * @param $module string The name of the module. + * @return mixed */ public static function build_event_data($event, $eventtype, $module = '') { $eventdata = $event->get_data(); @@ -88,6 +99,10 @@ public static function workshop_assessable_uploaded( $plugin->submission_handler(self::build_event_data($event, 'assessable_submitted', 'workshop')); } + /** + * Handle the course_module_updated event. + * @param \core\event\course_module_updated $event + */ public static function module_updated(\core\event\course_module_updated $event) { $plugin = new plagiarism_plugin_turnitinsim(); $plugin->module_updated(self::build_event_data($event, 'module_updated')); diff --git a/classes/request.class.php b/classes/request.class.php index 2f4e860..d208b30 100644 --- a/classes/request.class.php +++ b/classes/request.class.php @@ -18,6 +18,7 @@ * Communicate with Turnitin. * * @package plagiarism_turnitinsim + * @copyright 2018 Turnitin * @author John McGettrick http://www.turnitin.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -28,19 +29,42 @@ require_once($CFG->dirroot . '/plagiarism/turnitinsim/lib.php'); /** - * Get report Scores from Turnitin. + * Communicate with Turnitin. */ class plagiarism_turnitinsim_request { + /** + * @var + */ public $headers; + + /** + * @var string The API URL for the account. + */ public $apiurl; + + /** + * @var string The API key for the account. + */ public $apikey; + + /** + * @var string The endpoint being requested. + */ public $endpoint; + + /** + * @var bool|plagiarism_turnitinsim_logger Instance of the logger. + */ public $logger; + /** + * plagiarism_turnitinsim_request constructor. + * @throws dml_exception + */ public function __construct() { - // Only set attributes if plugin is configured + // Only set attributes if plugin is configured. $plugin = new plagiarism_plugin_turnitinsim(); if ($plugin->is_plugin_configured()) { $pluginconfig = get_config('plagiarism_turnitinsim'); @@ -54,7 +78,9 @@ public function __construct() { } /** - * @param array $headers + * Set the headers for the request. + * + * @throws dml_exception */ public function set_headers() { global $CFG; @@ -69,7 +95,7 @@ public function set_headers() { /** * Merge additional headers with current headers. * - * @param array $additional_headers + * @param array $additionalheaders Additional headers to add. */ public function add_additional_headers($additionalheaders = array()) { $this->headers = array_merge($this->headers, $additionalheaders); @@ -78,11 +104,11 @@ public function add_additional_headers($additionalheaders = array()) { /** * Send request to Turnitin. * - * @param $endpoint - * @param $requestbody - * @param $method - * @param $requesttype general/submission - * @return mixed + * @param $endpoint string The endpoint to make a request to. + * @param $requestbody string The request body to send. + * @param $method string The request method eg GET/POST. + * @param string $requesttype The type of request, can be general or submission. + * @return array|bool|false|mixed|stdClass|string */ public function send_request($endpoint, $requestbody, $method, $requesttype = 'general') { global $CFG; @@ -192,8 +218,9 @@ public function test_connection($apiurl, $apikey) { /** * Handle API exceptions * - * @param $e - * @param string $displaystr + * @param $e object The exception. + * @param string $displaystr The string to display for the error. + * @throws coding_exception */ public function handle_exception($e, $displaystr = '') { @@ -259,6 +286,8 @@ public function get_language() { } /** + * Get the API URL. + * * @return mixed */ public function get_apiurl() { @@ -266,6 +295,8 @@ public function get_apiurl() { } /** + * Set the API URL. + * * @param mixed $apiurl */ public function set_apiurl($apiurl) { @@ -273,14 +304,17 @@ public function set_apiurl($apiurl) { } /** + * Get the API key. + * * @return mixed */ - public function get_apikey() { return $this->apikey; } /** + * Set the API key. + * * @param mixed $apikey */ public function set_apikey($apikey) { diff --git a/classes/settings.class.php b/classes/settings.class.php index f45cd15..45b8c1e 100644 --- a/classes/settings.class.php +++ b/classes/settings.class.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Plugin module settings form for plagiarism_turnitinsim component + * Plugin module settings form for plagiarism_turnitinsim component. * * @package plagiarism_turnitinsim * @copyright 2017 Turnitin @@ -25,10 +25,22 @@ defined('MOODLE_INTERNAL') || die(); +/** + * Plugin module settings form for plagiarism_turnitinsim component. + */ class plagiarism_turnitinsim_settings { + /** + * @var plagiarism_turnitinsim_request|null Request object. + */ public $tsrequest; + /** + * plagiarism_turnitinsim_settings constructor. + * + * @param plagiarism_turnitinsim_request|null $tsrequest Request object. + * @throws dml_exception + */ public function __construct(plagiarism_turnitinsim_request $tsrequest = null ) { $this->tsrequest = ($tsrequest) ? $tsrequest : new plagiarism_turnitinsim_request(); } @@ -36,7 +48,11 @@ public function __construct(plagiarism_turnitinsim_request $tsrequest = null ) { /** * Add Turnitin settings to module form. * - * @param $mform + * @param $mform object The Moodle form object. + * @param string $context The context, eg module or course. + * @param string $modulename The name of the module. + * @return mixed Moodle form with settings. + * @throws coding_exception */ public function add_settings_to_module($mform, $context = 'module', $modulename = '') { global $PAGE; @@ -47,7 +63,7 @@ public function add_settings_to_module($mform, $context = 'module', $modulename // Require JS modules. if ($modulename == 'mod_assign') { - $PAGE->requires->js_call_amd('plagiarism_turnitinsim/set_report_generation', 'set_report_generation'); + $PAGE->requires->js_call_amd('plagiarism_turnitinsim/set_report_generation', 'setReportGeneration'); } $mform->addElement('checkbox', 'turnitinenabled', get_string('turnitinpluginenabled', 'plagiarism_turnitinsim')); @@ -136,7 +152,8 @@ public function add_settings_to_module($mform, $context = 'module', $modulename /** * Save Turnitin settings for a module. * - * @param $mform + * @param $data object The settings data to add. + * @throws dml_exception */ public function save_module_settings($data) { global $DB; diff --git a/classes/setup_form.class.php b/classes/setup_form.class.php index fb0240d..3b95f70 100644 --- a/classes/setup_form.class.php +++ b/classes/setup_form.class.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Plugin setup form for plagiarism_turnitinsim component + * Plugin setup form for plagiarism_turnitinsim component. * * @package plagiarism_turnitinsim * @copyright 2017 Turnitin @@ -29,9 +29,16 @@ require_once($CFG->dirroot . '/plagiarism/turnitinsim/lib.php'); require_once($CFG->dirroot . '/plagiarism/turnitinsim/classes/task.class.php'); +/** + * Plugin setup form for plagiarism_turnitinsim component. + */ class plagiarism_turnitinsim_setup_form extends moodleform { - // Define the form. + /** + * Define the form. + * + * @throws coding_exception + */ public function definition() { $mform =& $this->_form; @@ -118,7 +125,7 @@ public function definition() { * Display the form, saving the contents of the output buffer overriding Moodle's * display function that prints to screen when called * - * @return the form as an object to print to screen at our convenience + * @return false|string The form as an object to print to screen at our convenience. */ public function display() { ob_start(); @@ -130,7 +137,10 @@ public function display() { } /** - * Save the plugin config data + * Save the plugin config data. + * + * @param $data object The data to save. + * @throws coding_exception */ public function save($data) { $useplugin = 0; @@ -195,6 +205,8 @@ public function display_features() { $tstask = new plagiarism_turnitinsim_task(); $tstask->check_enabled_features(); } catch (Exception $e) { + $logger = new plagiarism_turnitinsim_logger(); + $logger->error(get_string('errorenabledfeatures', 'plagiarism_turnitinsim')); // Gracefully handle error - do nothing. } $features = get_config('plagiarism_turnitinsim', 'turnitin_features_enabled'); diff --git a/classes/submission.class.php b/classes/submission.class.php index b9396d7..7c786cb 100644 --- a/classes/submission.class.php +++ b/classes/submission.class.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Submission class for plagiarism_turnitinsim component + * Submission class for plagiarism_turnitinsim component. * * @package plagiarism_turnitinsim * @copyright 2017 Turnitin @@ -32,26 +32,103 @@ require_once($CFG->dirroot . '/plagiarism/turnitinsim/classes/forum.class.php'); require_once($CFG->dirroot . '/plagiarism/turnitinsim/classes/workshop.class.php'); +/** + * Submission class for plagiarism_turnitinsim component. + */ class plagiarism_turnitinsim_submission { + /** + * @var int The submission ID. + */ public $id; + + /** + * @var object The course module. + */ public $cm; + + /** + * @var int The user ID. + */ public $userid; + + /** + * @var int The group ID. + */ public $groupid; + + /** + * @var int The submitter of the paper. + */ public $submitter; + + /** + * @var int The Turnitin submission ID. + */ public $turnitinid; + + /** + * @var string The submission status. + */ public $status; + + /** + * @var string The Moodle identifier for the file. + */ public $identifier; + + /** + * @var string The Moodle itemid for the submission. + */ public $itemid; + + /** + * @var string The type of submission, for example text or file. + */ public $type; - public $submittedtime; - public $togenerate; - public $generationtime; - public $requestedtime; - public $overallscore; + + /** + * @var int The time the submission was made. + */ + public $submitted_time; + + /** + * @var int Whether or not the submission is still to be generated. + */ + public $to_generate; + + /** + * @var int The time the originality report was generated. + */ + public $generation_time; + + /** + * @var int The time the originality report was requested. + */ + public $requested_time; + + /** + * @var int The originality report. + */ + public $overall_score; + + /** + * @var string The error nessage, if the submission did not complete successfully. + */ public $errormessage; + + /** + * @var object The request object. + */ public $tsrequest; + /** + * plagiarism_turnitinsim_submission constructor. + * + * @param plagiarism_turnitinsim_request|null $tsrequest Request object. + * @param null $id The submission ID. + * @throws dml_exception + */ public function __construct(plagiarism_turnitinsim_request $tsrequest = null, $id = null) { global $DB; @@ -98,6 +175,9 @@ public function update() { /** * Set the generation time for a paper. + * + * @param bool $generated true if originality report has been generated. + * @throws coding_exception */ public function calculate_generation_time($generated = false) { $cm = get_coursemodule_from_id('', $this->getcm()); @@ -173,8 +253,9 @@ public function calculate_generation_time($generated = false) { /** * Build a user array entry from a passed in user object for submission metadata. * - * @param $user + * @param $user object The user data object. * @return mixed + * @throws dml_exception */ public function build_user_array_entry($user) { @@ -196,7 +277,7 @@ public function build_user_array_entry($user) { return $userdata; } - /* + /** * Compile metadata for submission request. * * return mixed @@ -270,6 +351,7 @@ public function create_owners_metadata() { * Return the submission owner, this will be the group id for group submissions. * * @return integer Turnitin id identifying the owner. + * @throws dml_exception */ public function get_owner() { if (!empty($this->getgroupid())) { @@ -345,7 +427,8 @@ public function create_submission_in_turnitin() { /** * Handle the API create submission response. * - * @param $params + * @param $params object containing the submission response. + * @throws coding_exception */ public function handle_create_submission_response($params) { @@ -431,7 +514,10 @@ public function upload_submission_to_turnitin() { /** * Handle the API submission response and callback from Turnitin. * - * @param $params + * @param $params object containing the upload response. + * @param $filename string The name of the file submitted. + * @throws coding_exception + * @throws dml_exception */ public function handle_upload_response($params, $filename) { // Update submission status. @@ -457,7 +543,9 @@ public function handle_upload_response($params, $filename) { /** * Send digital receipts to the instructors and student. * - * @param $filename + * @param $filename string The name of the file submitted. + * @throws coding_exception + * @throws dml_exception */ public function send_digital_receipts($filename) { global $DB; @@ -585,7 +673,8 @@ public function request_turnitin_report_score() { /** * Handle the API similarity response and callback from Turnitin. * - * @param $params + * @param $params object containing the similarity score response. + * @throws coding_exception */ public function handle_similarity_response($params) { // Update submission details. @@ -604,8 +693,11 @@ public function handle_similarity_response($params) { /** * Get the details for a submission from the Moodle database. * - * @param $linkarray + * @param $linkarray array The linkarray given by Moodle containing module data. * @return mixed + * @throws coding_exception + * @throws dml_exception + * @throws moodle_exception */ public static function get_submission_details($linkarray) { global $DB; @@ -659,6 +751,7 @@ public static function get_submission_details($linkarray) { * Create the cloud viewer permissions array to send when requesting a viewer launch URL. * * @return array + * @throws dml_exception */ public function create_report_viewer_permissions() { $turnitinviewerviewfullsource = get_config('plagiarism_turnitinsim', 'turnitinviewerviewfullsource'); @@ -678,6 +771,7 @@ public function create_report_viewer_permissions() { * These are true but may be configurable in the future. * * @return array + * @throws dml_exception */ public function create_similarity_overrides() { $turnitinviewersavechanges = get_config('plagiarism_turnitinsim', 'turnitinviewersavechanges'); @@ -738,15 +832,18 @@ public function request_cv_launch_url() { $response = $this->tsrequest->send_request($endpoint, json_encode($request), 'POST'); return $response; } catch (Exception $e) { - $this->tsrequest->handle_exception($e, 'taskoutputfailedcvlaunchurl', $this->getturnitinid()); } + + return null; } /** * Check whether the submission is anonymous. * * @return bool + * @throws coding_exception + * @throws dml_exception */ public function is_submission_anonymous() { global $DB; @@ -773,7 +870,7 @@ public function is_submission_anonymous() { /** * Get the path to the file from the pathnamehash * - * @return $filepath + * @return bool|stored_file $filepath */ public function get_file_details() { $fs = get_file_storage(); @@ -783,6 +880,8 @@ public function get_file_details() { } /** + * Get the submission ID. + * * @return int */ public function getid() { @@ -790,6 +889,8 @@ public function getid() { } /** + * Set the submission ID. + * * @param int $id */ public function setid($id) { @@ -797,13 +898,17 @@ public function setid($id) { } /** - * @return int + * Get the course module. + * + * @return object */ public function getcm() { return $this->cm; } /** + * Set the course module. + * * @param int $cm */ public function setcm($cm) { @@ -811,6 +916,8 @@ public function setcm($cm) { } /** + * Get the user ID. + * * @return int */ public function getuserid() { @@ -818,6 +925,8 @@ public function getuserid() { } /** + * Set the user ID. + * * @param int $userid */ public function setuserid($userid) { @@ -825,6 +934,8 @@ public function setuserid($userid) { } /** + * Get the group ID. + * * @return mixed */ public function getgroupid() { @@ -832,13 +943,17 @@ public function getgroupid() { } /** - * @param mixed $ownertype + * Set the group ID. + * + * @param mixed $groupid */ public function setgroupid($groupid) { $this->groupid = $groupid; } /** + * Get the submitter of the paper. + * * @return mixed */ public function getsubmitter() { @@ -846,6 +961,8 @@ public function getsubmitter() { } /** + * Set the submitter of the paper. + * * @param mixed $submitter */ public function setsubmitter($submitter) { @@ -853,6 +970,8 @@ public function setsubmitter($submitter) { } /** + * Get the Turnitin submission ID. + * * @return int */ public function getturnitinid() { @@ -860,6 +979,8 @@ public function getturnitinid() { } /** + * Set the Turnitin submission ID. + * * @param int $turnitinid */ public function setturnitinid($turnitinid) { @@ -867,6 +988,8 @@ public function setturnitinid($turnitinid) { } /** + * Get the submission status. + * * @return mixed */ public function getstatus() { @@ -874,6 +997,8 @@ public function getstatus() { } /** + * Set the submission status. + * * @param mixed $status */ public function setstatus($status) { @@ -881,6 +1006,8 @@ public function setstatus($status) { } /** + * Get the Moodle identifier for the file. + * * @return mixed */ public function getidentifier() { @@ -888,6 +1015,8 @@ public function getidentifier() { } /** + * Set the Moodle identifier for the file. + * * @param mixed $identifier */ public function setidentifier($identifier) { @@ -895,6 +1024,8 @@ public function setidentifier($identifier) { } /** + * Get the time the submission was made. + * * @return mixed */ public function getsubmittedtime() { @@ -902,6 +1033,8 @@ public function getsubmittedtime() { } /** + * Set the time the submission was made. + * * @param mixed $submittedtime */ public function setsubmittedtime($submittedtime) { @@ -909,6 +1042,8 @@ public function setsubmittedtime($submittedtime) { } /** + * Get the originality report. + * * @return mixed */ public function getoverallscore() { @@ -916,6 +1051,8 @@ public function getoverallscore() { } /** + * Set the originality report. + * * @param mixed $overallscore */ public function setoverallscore($overallscore) { @@ -923,6 +1060,7 @@ public function setoverallscore($overallscore) { } /** + * Get the Moodle itemid for the submission. * @return mixed */ public function getitemid() { @@ -930,6 +1068,8 @@ public function getitemid() { } /** + * Set the Moodle itemid for the submission. + * * @param mixed $itemid */ public function setitemid($itemid) { @@ -937,6 +1077,8 @@ public function setitemid($itemid) { } /** + * Get the time the originality report was requested. + * * @return mixed */ public function getrequestedtime() { @@ -944,6 +1086,8 @@ public function getrequestedtime() { } /** + * Set the time the originality report was requested. + * * @param mixed $requestedtime */ public function setrequestedtime($requestedtime) { @@ -951,6 +1095,8 @@ public function setrequestedtime($requestedtime) { } /** + * Get the error nessage, if the submission did not complete successfully. + * * @return mixed */ public function geterrormessage() { @@ -958,6 +1104,8 @@ public function geterrormessage() { } /** + * Set the error nessage, if the submission did not complete successfully. + * * @param mixed $errormessage */ public function seterrormessage($errormessage) { @@ -965,6 +1113,8 @@ public function seterrormessage($errormessage) { } /** + * Get the type of submission, for example text or file. + * * @return mixed */ public function gettype() { @@ -972,6 +1122,8 @@ public function gettype() { } /** + * Set the type of submission, for example text or file. + * * @param mixed $type */ public function settype($type) { @@ -979,6 +1131,7 @@ public function settype($type) { } /** + * Get whether or not the submission is still to be generated. * @return mixed */ public function gettogenerate() { @@ -986,6 +1139,8 @@ public function gettogenerate() { } /** + * Set whether or not the submission is still to be generated. + * * @param mixed $togenerate */ public function settogenerate($togenerate) { @@ -993,6 +1148,8 @@ public function settogenerate($togenerate) { } /** + * Get the time the originality report was generated. + * * @return mixed */ public function getgenerationtime() { @@ -1000,6 +1157,8 @@ public function getgenerationtime() { } /** + * Get the time the originality report was generated. + * * @param mixed $generationtime */ public function setgenerationtime($generationtime) { diff --git a/classes/task.class.php b/classes/task.class.php index c7c9eea..a7e895c 100644 --- a/classes/task.class.php +++ b/classes/task.class.php @@ -18,6 +18,7 @@ * Perform Scheduled Tasks. * * @package plagiarism_turnitinsim + * @copyright 2017 Turnitin * @author John McGettrick * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -32,24 +33,44 @@ use plagiarism_turnitinsim\message\new_eula; /** - * Scheduled tasks. + * Perform Scheduled Tasks. */ class plagiarism_turnitinsim_task { + /** + * @var plagiarism_turnitinsim_request Request object. + */ public $tsrequest; + + /** + * @var plagiarism_turnitinsim_callback Callback object. + */ public $tscallback; + + /** + * @var plagiarism_turnitinsim_settings Settings object. + */ public $tssettings; + /** + * plagiarism_turnitinsim_task constructor. + * @param null $params for the task to run. + * @throws dml_exception + */ public function __construct( $params = null ) { $this->tsrequest = (!empty($params->tsrequest)) ? $params->tsrequest : new plagiarism_turnitinsim_request(); - $this->tscallback = (!empty($params->tscallback)) ? $params->tscallback : new plagiarism_turnitinsim_callback($this->tsrequest); - $this->tssettings = (!empty($params->tssettings)) ? $params->tssettings : new plagiarism_turnitinsim_settings($this->tsrequest); + $this->tscallback = (!empty($params->tscallback)) ? + $params->tscallback : new plagiarism_turnitinsim_callback($this->tsrequest); + $this->tssettings = (!empty($params->tssettings)) ? + $params->tssettings : new plagiarism_turnitinsim_settings($this->tsrequest); $this->tseula = (!empty($params->tseula)) ? $params->tseula : new plagiarism_turnitinsim_eula(); } /** * Send Queued submissions to Turnitin. * @return boolean + * @throws coding_exception + * @throws dml_exception */ public function send_queued_submissions() { global $DB; @@ -72,7 +93,7 @@ public function send_queued_submissions() { $submissions = $DB->get_records_sql('SELECT s.id FROM {plagiarism_turnitinsim_sub} s JOIN {course_modules} c ON s.cm = c.id - WHERE (status = ? OR status = ?) + WHERE (status = ? OR status = ?) AND c.deletioninprogress = ? LIMIT ?', array(TURNITINSIM_SUBMISSION_STATUS_QUEUED, TURNITINSIM_SUBMISSION_STATUS_CREATED, 0, TURNITINSIM_SUBMISSION_SEND_LIMIT) @@ -106,6 +127,8 @@ public function send_queued_submissions() { /** * Request a report to be generated and get report scores from Turnitin. * @return boolean + * @throws coding_exception + * @throws dml_exception */ public function get_reports() { global $DB; @@ -121,7 +144,7 @@ public function get_reports() { $submissions = $DB->get_records_sql('SELECT s.id FROM {plagiarism_turnitinsim_sub} s JOIN {course_modules} c ON s.cm = c.id - WHERE ((to_generate = ? AND generation_time <= ?) OR (status = ?)) + WHERE ((to_generate = ? AND generation_time <= ?) OR (status = ?)) AND c.deletioninprogress = ? AND turnitinid IS NOT NULL', array(1, time(), TURNITINSIM_SUBMISSION_STATUS_REQUESTED, 0) @@ -164,6 +187,7 @@ public function get_reports() { * Update the features enabled on the Turnitin Account and store locally. * * @return bool + * @throws coding_exception */ public function admin_update() { @@ -188,6 +212,7 @@ public function admin_update() { /** * Test whether the webhook is working, if not create a new one. * @return bool + * @throws dml_exception */ public function test_webhook() { // Reset headers. @@ -198,7 +223,7 @@ public function test_webhook() { // If we have a webhook id then retrieve the webhook. if ($webhookid) { - $valid = $this->tscallback->get_webhook($webhookid); + $valid = $this->tscallback->has_webhook($webhookid); if (!$valid) { $this->tscallback->delete_webhook($webhookid); @@ -275,7 +300,9 @@ public function check_enabled_features() { * Check if the task should be run. Initially this will check if the plugin is configured * and only run if it is but this could be expanded. * - * return boolean + * @param string $taskname The name of the scheduled task being ran. + * @return bool + * @throws coding_exception */ public function run_task($taskname = '') { $plugin = new plagiarism_plugin_turnitinsim(); diff --git a/classes/task/admin_update.php b/classes/task/admin_update.php index 98237d0..ab0597e 100644 --- a/classes/task/admin_update.php +++ b/classes/task/admin_update.php @@ -15,8 +15,7 @@ // along with Moodle. If not, see . /** - * Task to update local config from Turnitin including testing the webhook, eatures enabled and - * checking the latest version of the EULA with Turnitin. + * Update local configuration from Turnitin. * * @package plagiarism_turnitinsim * @copyright 2018 Turnitin @@ -29,14 +28,24 @@ defined('MOODLE_INTERNAL') || die(); /** - * Update local configuration from Turnitin. + * Task to update local config from Turnitin including testing the webhook, eatures enabled and + * checking the latest version of the EULA with Turnitin. */ class admin_update extends \core\task\scheduled_task { + /** + * Get the task name. + * + * @return string + * @throws \coding_exception + */ public function get_name() { return \get_string('taskadminupdate', 'plagiarism_turnitinsim'); } + /** + * Execute the task. + */ public function execute() { global $CFG; diff --git a/classes/task/get_reports.php b/classes/task/get_reports.php index 35c2d86..35d9e23 100644 --- a/classes/task/get_reports.php +++ b/classes/task/get_reports.php @@ -18,6 +18,7 @@ * Update report Scores from Turnitin. * * @package plagiarism_turnitinsim + * @copyright 2018 Turnitin * @author John McGettrick http://www.turnitin.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -31,10 +32,19 @@ */ class get_reports extends \core\task\scheduled_task { + /** + * Get the task name. + * + * @return string + * @throws \coding_exception + */ public function get_name() { return \get_string('taskgetreportscores', 'plagiarism_turnitinsim'); } + /** + * Execute the task. + */ public function execute() { global $CFG; diff --git a/classes/task/send_submissions.php b/classes/task/send_submissions.php index 30f3aa2..06f9a11 100644 --- a/classes/task/send_submissions.php +++ b/classes/task/send_submissions.php @@ -18,6 +18,7 @@ * Send queued submissions to Turnitin. * * @package plagiarism_turnitinsim + * @copyright 2018 Turnitin * @author John McGettrick http://www.turnitin.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -31,10 +32,19 @@ */ class send_submissions extends \core\task\scheduled_task { + /** + * Get the task name. + * + * @return string + * @throws \coding_exception + */ public function get_name() { return \get_string('tasksendqueuedsubmissions', 'plagiarism_turnitinsim'); } + /** + * Execute the task. + */ public function execute() { global $CFG; diff --git a/classes/user.class.php b/classes/user.class.php index 32c9972..5dbe017 100644 --- a/classes/user.class.php +++ b/classes/user.class.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * User class for plagiarism_turnitinsim component + * User class for plagiarism_turnitinsim component. * * @package plagiarism_turnitinsim * @copyright 2017 Turnitin @@ -27,15 +27,46 @@ require_once($CFG->dirroot . '/plagiarism/turnitinsim/utilities/handle_deprecation.php'); +/** + * User class for plagiarism_turnitinsim component. + */ class plagiarism_turnitinsim_user { + /** + * @var int The Moodle user ID. + */ public $userid; + + /** + * @var int The Turnitin user ID. + */ public $turnitinid; + + /** + * @var string The EULA version the user last accepted. + */ public $lasteulaaccepted; + + /** + * @var int The unix timestamp that latest EULA was accepted. + */ public $lasteulaacceptedtime; + + /** + * @var string The language of the EULA that was last accepted. + */ public $lasteulaacceptedlang; + + /** + * @var object Request object. + */ public $tsrequest; + /** + * plagiarism_turnitinsim_user constructor. + * @param $userid int The Moodle user ID. + * @throws dml_exception + */ public function __construct($userid) { global $DB; @@ -74,6 +105,8 @@ public function create_turnitinid() { } /** + * Get the Moodle user ID. + * * @return mixed */ public function get_userid() { @@ -81,13 +114,17 @@ public function get_userid() { } /** - * @param mixed $userid + * Set the Moodle user ID. + * + * @param int $userid The Moodle user ID. */ public function set_userid($userid) { $this->userid = $userid; } /** + * Get the Turnitin user ID. + * * @return mixed */ public function get_turnitinid() { @@ -95,13 +132,17 @@ public function get_turnitinid() { } /** - * @param mixed $turnitinid + * Set the Turnitin user ID. + * + * @param int $turnitinid The Turnitin user ID. */ public function set_turnitinid($turnitinid) { $this->turnitinid = $turnitinid; } /** + * Get the EULA version the user last accepted. + * * @return mixed */ public function get_lasteulaaccepted() { @@ -109,13 +150,16 @@ public function get_lasteulaaccepted() { } /** - * @param mixed $lasteulaaccepted + * Set the EULA version the user last accepted. + * + * @param string $lasteulaaccepted The EULA version the user last accepted. */ public function set_lasteulaaccepted($lasteulaaccepted) { $this->lasteulaaccepted = $lasteulaaccepted; } /** + * Get the unix timestamp that latest EULA was accepted. * @return mixed */ public function get_lasteulaacceptedtime() { @@ -123,13 +167,17 @@ public function get_lasteulaacceptedtime() { } /** - * @param mixed $lasteulaacceptedtime + * Set the unix timestamp that latest EULA was accepted. + * + * @param mixed $lasteulaacceptedtime The unix timestamp that latest EULA was accepted. */ public function set_lasteulaacceptedtime($lasteulaacceptedtime) { $this->lasteulaacceptedtime = $lasteulaacceptedtime; } /** + * Get the language of the EULA that was last accepted. + * * @return mixed */ public function get_lasteulaacceptedlang() { @@ -137,7 +185,9 @@ public function get_lasteulaacceptedlang() { } /** - * @param mixed $lasteulaacceptedtime + * Set the language of the EULA that was last accepted. + * + * @param string $lasteulaacceptedlang The language of the EULA that was last accepted. */ public function set_lasteulaacceptedlang($lasteulaacceptedlang) { $this->lasteulaacceptedlang = $lasteulaacceptedlang; diff --git a/classes/workshop.class.php b/classes/workshop.class.php index e318f27..c35c296 100644 --- a/classes/workshop.class.php +++ b/classes/workshop.class.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Helper class for plagiarism_turnitinsim component in workshops + * Helper class for plagiarism_turnitinsim component in workshops. * * @package plagiarism_turnitinsim * @copyright 2018 Turnitin @@ -25,13 +25,17 @@ defined('MOODLE_INTERNAL') || die(); +/** + * Helper class for plagiarism_turnitinsim component in workshops + */ class plagiarism_turnitinsim_workshop { /** - * Get the text from the database for the forum post. + * Get the text from the database for the submission. * - * @param $itemid - * @return mixed + * @param $itemid String The itemid for this submission. + * @return mixed The text of the submission. + * @throws dml_exception */ public function get_onlinetext($itemid) { global $DB; @@ -42,10 +46,11 @@ public function get_onlinetext($itemid) { } /** - * Get the item id from the database for this submission when we have userid, moduleid and content. + * Get the item id from the database for this submission. * - * @param $params - * @return mixed + * @param $params object The params to call the DB with. + * @return int The itemid. + * @throws dml_exception */ public function get_itemid($params) { global $DB; @@ -63,19 +68,19 @@ public function get_itemid($params) { /** * Get the actual author of the submission. * - * @param $userid - * @param $relateduserid - * @param $cmid + * @param $userid int The userid as given by Moodle. + * @param $relateduserid int The relateduserid as given by Moodle. + * @return int The authorid. */ - public function get_author($userid, $relateduserid, $cmid, $itemid) { + public function get_author($userid, $relateduserid) { return (!empty($relateduserid)) ? $relateduserid : $userid; } /** - * Get the group id that a submission belongs to - (N/A in workshops). + * Get the group id that a submission belongs to. - (N/A in workshops). * - * @param $itemid - * @return null + * @param $itemid string The itemid for the submission. + * @return int The group id. */ public function get_groupid($itemid) { return null; @@ -84,8 +89,8 @@ public function get_groupid($itemid) { /** * Return whether the submission is a draft. Never the case with a workshop submission. * - * @param $itemid - * @return bool + * @param $itemid string The itemid for the submission. + * @return bool If the submission is a draft. */ public function is_submission_draft($itemid) { return false; @@ -94,8 +99,8 @@ public function is_submission_draft($itemid) { /** * Return the due date so we can work out report generation time. Not applicable to forums. * - * @param $id - * @return int + * @param $id int The forum ID we want the due date for. + * @return int The due date for the assignment. */ public function get_due_date($id) { return 0; diff --git a/db/access.php b/db/access.php index cf62826..8f7bbfe 100644 --- a/db/access.php +++ b/db/access.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * Capability definitions for this plugin. + * * @package plagiarism_turnitinsim * @copyright 2017 Turnitin * @author John McGettrick diff --git a/db/install.php b/db/install.php index 5e62608..add55a8 100644 --- a/db/install.php +++ b/db/install.php @@ -41,6 +41,15 @@ function xmldb_plagiarism_turnitinsim_install() { } } +/** + * This method is ran on install so that anyone using the plugin namespaced turnitincheck can upgrade + * to the new plugin namespace without problems with losing data. + * + * @param $oldtable string The old table to migrate from. + * @param $newtable string The new table to migrate to. + * @throws ddl_exception + * @throws dml_exception + */ function upgrade_from_turnitincheck_plugin($oldtable, $newtable) { global $DB; diff --git a/db/messages.php b/db/messages.php index 251429f..10757f4 100644 --- a/db/messages.php +++ b/db/messages.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * Configuration for message providers for sending notifications. + * * @package plagiarism_turnitinsim * @copyright 2018 Turnitin * @author John McGettrick diff --git a/db/upgrade.php b/db/upgrade.php index fdf334f..d09af9a 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Database upgrade script for plagiarism_turnitinsim component + * Database upgrade script for plagiarism_turnitinsim component. * * @package plagiarism_turnitinsim * @copyright 2017 Turnitin @@ -26,9 +26,15 @@ defined('MOODLE_INTERNAL') || die(); /** - * @global moodle_database $DB - * @param int $oldversion - * @return bool + * Database upgrade script for plagiarism_turnitinsim component. + * + * @param int $oldversion The version that is currently installed. + * @return bool true if upgrade was successful. + * @throws ddl_exception + * @throws ddl_table_missing_exception + * @throws dml_exception + * @throws downgrade_exception + * @throws upgrade_exception */ function xmldb_plagiarism_turnitinsim_upgrade($oldversion) { global $DB; @@ -191,6 +197,8 @@ function xmldb_plagiarism_turnitinsim_upgrade($oldversion) { // if necessary when the scheduled tasks run. $features = json_decode(get_config('plagiarism_turnitinsim', 'turnitin_features_enabled')); if (!isset($features->tenant)) { + $features = new \stdClass(); + $features->tenant = new \stdClass(); $features->tenant->require_eula = true; set_config('turnitin_features_enabled', json_encode($features), 'plagiarism_turnitinsim'); } diff --git a/lang/en/plagiarism_turnitinsim.php b/lang/en/plagiarism_turnitinsim.php index 6c3c536..da05e23 100644 --- a/lang/en/plagiarism_turnitinsim.php +++ b/lang/en/plagiarism_turnitinsim.php @@ -190,3 +190,5 @@ $string['privacy:metadata:plagiarism_turnitinsim_client:submission_title'] = 'The title of the submission is sent to Turntin so that it is identifiable.'; $string['privacy:metadata:plagiarism_turnitinsim_client:submission_filename'] = 'The name of the submitted file is sent to Turntin so that it is identifiable.'; $string['privacy:metadata:plagiarism_turnitinsim_client:submission_content'] = 'Please be aware that the content of a file/submission is sent to Turnitin for processing.'; + +$string['errorenabledfeatures'] = 'Could not get the list of enabled features.'; \ No newline at end of file diff --git a/lib.php b/lib.php index d5f9cca..6860eee 100644 --- a/lib.php +++ b/lib.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Main library for plagiarism_turnitinsim component + * Main library for plagiarism_turnitinsim component. * * @package plagiarism_turnitinsim * @copyright 2017 Turnitin @@ -39,15 +39,20 @@ require_once( __DIR__ . '/classes/eula.class.php' ); require_once( __DIR__ . '/classes/task.class.php' ); +/** + * Main library for plagiarism_turnitinsim component. + */ class plagiarism_plugin_turnitinsim extends plagiarism_plugin { /** * Get the fields to be used in the form to configure each module's Turnitin settings. * - * @param object $mform - Moodle form + * @param object $mform - Moodle form * @param object $context - current context * @param string $modulename - Name of the module - * @return array of settings fields. + * @return void of settings fields. + * @throws coding_exception + * @throws dml_exception */ public function get_form_elements_module($mform, $context, $modulename = "") { @@ -92,6 +97,7 @@ public function get_form_elements_module($mform, $context, $modulename = "") { * Save the data associated with the plugin from the module's mod_form. * * @param object $data the form data to save + * @throws dml_exception */ public function save_form_elements($data) { @@ -108,7 +114,10 @@ public function save_form_elements($data) { * Hook to allow report score and link to be displayed beside a submission. * * @param array $linkarray contains all relevant information to display a report score and link to cloud viewer. - * @return string + * @return string Output for similarity score and other display information. + * @throws coding_exception + * @throws dml_exception + * @throws moodle_exception */ public function get_links($linkarray) { global $OUTPUT, $PAGE; @@ -119,9 +128,9 @@ public function get_links($linkarray) { $jsloaded = true; $PAGE->requires->string_for_js('loadingcv', 'plagiarism_turnitinsim'); $PAGE->requires->string_for_js('submissiondisplaystatus:queued', 'plagiarism_turnitinsim'); - $PAGE->requires->js_call_amd('plagiarism_turnitinsim/cv_launch', 'open_cv'); + $PAGE->requires->js_call_amd('plagiarism_turnitinsim/cv_launch', 'openCv'); $PAGE->requires->js_call_amd('plagiarism_turnitinsim/resend_submission', 'resendSubmission'); - $PAGE->requires->js_call_amd('plagiarism_turnitinsim/inbox_eula_launch', 'inbox_eula_launch'); + $PAGE->requires->js_call_amd('plagiarism_turnitinsim/inbox_eula_launch', 'inboxEulaLaunch'); } $output = ''; @@ -290,8 +299,9 @@ public function get_links($linkarray) { /** * Check whether the plugin is active. - * @param $cm - * @return bool + * @param $cm object The course module data. + * @return bool true if the plugin is active. + * @throws dml_exception */ public function is_plugin_active($cm) { // Get whether plugin is enabled for this module. @@ -326,8 +336,9 @@ public function is_plugin_configured() { /** * Render a link to resubmit the file to Turnitin. * - * @param $submissionid - * @return mixed + * @param $submissionid int The ID of the submission. + * @return mixed A link to resubmit the submission. + * @throws coding_exception */ public function render_resubmit_link($submissionid) { global $OUTPUT; @@ -351,6 +362,8 @@ public function render_resubmit_link($submissionid) { * * @param int $cmid - course module id * @return string + * @throws coding_exception + * @throws dml_exception */ public function print_disclosure($cmid) { global $CFG, $PAGE, $USER; @@ -384,7 +397,7 @@ public function print_disclosure($cmid) { // Require the JS module to handle the user's eula response. $PAGE->requires->string_for_js('eulaaccepted', 'plagiarism_turnitinsim'); $PAGE->requires->string_for_js('euladeclined', 'plagiarism_turnitinsim'); - $PAGE->requires->js_call_amd('plagiarism_turnitinsim/eula_response', 'eula_response'); + $PAGE->requires->js_call_amd('plagiarism_turnitinsim/eula_response', 'eulaResponse'); // Link to open the Turnitin EULA in a new tab. $tsrequest = new plagiarism_turnitinsim_request(); @@ -427,9 +440,10 @@ public function update_status($course, $cm) { /** * Get the Turnitin settings for a module. * - * @param int $cm_id - the course module id, if this is 0 the default settings will be retrieved + * @param int $cmid - the course module id, if this is 0 the default settings will be retrieved * @param string $fields - fields to return, all by default * @return array of Turnitin settings for a module + * @throws dml_exception */ public function get_settings($cmid = null, $fields = '*') { global $DB; @@ -441,6 +455,8 @@ public function get_settings($cmid = null, $fields = '*') { /** * @param array $eventdata - provided by Moodle, should contain enough data to process a submission. * @return bool + * @throws coding_exception + * @throws dml_exception */ public function submission_handler($eventdata) { global $DB; @@ -493,7 +509,10 @@ public function submission_handler($eventdata) { // If this is a user confirming a final submission then revert the submission to // TURNITINSIM_SUBMISSION_STATUS_UPLOADED so that a report gets requested and the paper gets indexed if needed. - if ($moduledata->submissiondrafts && $eventdata['other']['modulename'] == 'assign' && $eventdata['eventtype'] == "assessable_submitted") { + if ($moduledata->submissiondrafts && + $eventdata['other']['modulename'] == 'assign' && + $eventdata['eventtype'] == "assessable_submitted") { + $submissions = $DB->get_records_select( 'plagiarism_turnitinsim_sub', 'cm = ? AND userid = ? AND itemid = ? AND status != ?', @@ -509,11 +528,9 @@ public function submission_handler($eventdata) { TURNITINSIM_SUBMISSION_STATUS_QUEUED ); - $status = (in_array($tssubmission->getstatus(), $statusarray)) ? - TURNITINSIM_SUBMISSION_STATUS_QUEUED : TURNITINSIM_SUBMISSION_STATUS_UPLOADED; - - $generated = (in_array($tssubmission->getstatus(), $statusarray)) ? - false : true; + $statusexists = in_array($tssubmission->getstatus(), $statusarray); + $status = ($statusexists) ? TURNITINSIM_SUBMISSION_STATUS_QUEUED : TURNITINSIM_SUBMISSION_STATUS_UPLOADED; + $generated = ($statusexists) ? false : true; $tssubmission->calculate_generation_time($generated); $tssubmission->setstatus($status); @@ -640,7 +657,9 @@ public function submission_handler($eventdata) { /** * Event hook for when a module has been changed. Set the generation flag for a submission. * - * @param $eventdata + * @param $eventdata array containing information from the event being handled. + * @throws coding_exception + * @throws dml_exception */ public function module_updated($eventdata) { global $DB; @@ -687,6 +706,10 @@ public function module_updated($eventdata) { /** * Override Moodle's mtrace function for methods shared with tasks. + * + * @param $string string The message that would otherwise be displayed. + * @param $eol string end of line. + * @return bool */ function plagiarism_turnitinsim_mtrace($string, $eol) { return true; diff --git a/locallib.php b/locallib.php index dc81c17..cb8fcef 100644 --- a/locallib.php +++ b/locallib.php @@ -30,7 +30,7 @@ require_once($CFG->dirroot.'/plagiarism/turnitinsim/classes/task.class.php'); -/* +/** * Wrapper function for where PHP's getallheaders() function doesn't exist * * return array diff --git a/settings_tabs.php b/settings_tabs.php index 1eb75b1..f2bc29f 100644 --- a/settings_tabs.php +++ b/settings_tabs.php @@ -18,6 +18,7 @@ * Settings navigation tabs for plagiarism_turnitinsim * * @package plagiarism_turnitinsim + * @copyright 2018 Turnitin * @author John McGettrick http://www.turnitin.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/styles.css b/styles.css index 39550e4..8f6175a 100644 --- a/styles.css +++ b/styles.css @@ -3,7 +3,8 @@ position: relative; } -.turnitinsim_features, .turnitinsim_ferpa { +.turnitinsim_features, +.turnitinsim_ferpa { border: 1px solid #db4221; padding: 10px; margin-bottom: 10px; @@ -11,17 +12,17 @@ .turnitinsim_features .turnitinsim_featurelist { float: left; - margin-top: 0px; + margin-top: 0; margin-right: 32px; } .turnitinsim_features h4 { - margin-top: 0px; + margin-top: 0; } .turnitinsim_features p { clear: both; - margin-bottom: 0px; + margin-bottom: 0; } .turnitinsim_setup_download_links .mdl-align { @@ -71,10 +72,12 @@ } .turnitinsim_links .clear { - clear:both; + clear: both; } -.turnitinsim_links .pp_resubmit_link, .turnitinsim_links .turnitinsim_status_text_eula, .turnitinsim_links .eula-row-launch { +.turnitinsim_links .pp_resubmit_link, +.turnitinsim_links .turnitinsim_status_text_eula, +.turnitinsim_links .eula-row-launch { cursor: pointer; } @@ -132,17 +135,17 @@ /* Connection Test*/ .turnitinsim_connection-test-success, .turnitinsim_connection-test-failed { - background-image: none !important; - color: #FFFFFF !important; - text-shadow: none !important; + background-image: none; + color: #fff; + text-shadow: none; } .turnitinsim_connection-test-success button:focus, -.turnitinsim_connection-test-failed button:focus{ - outline: 0 !important; +.turnitinsim_connection-test-failed button:focus { + outline: 0; } .turnitinsim_connection-test-success { - background-color: #51a351 !important; + background-color: #51a351; } .turnitinsim_connection-test-failed { - background-color: #d9534f !important; + background-color: #d9534f; } \ No newline at end of file diff --git a/templates/modal_eula.mustache b/templates/modal_eula.mustache index 7f55b22..370f7b6 100644 --- a/templates/modal_eula.mustache +++ b/templates/modal_eula.mustache @@ -14,6 +14,11 @@ You should have received a copy of the GNU General Public License along with Moodle. If not, see . }} +{{! + @template plagiarism_turnitinsim/modal_eula + + Shown for a user to accept or decline the EULA. +}} {{< core/modal }} {{$title}}{{# str }} eulaheader, plagiarism_turnitinsim {{/ str }}{{/title}} {{$body}} diff --git a/tests/behat b/tests/behat index f28317c..264dcec 160000 --- a/tests/behat +++ b/tests/behat @@ -1 +1 @@ -Subproject commit f28317c08dd54d9cba8c2e5662f7a50937ed9023 +Subproject commit 264dcecb18185b88de449dce8f4c6a03be7b56c8 diff --git a/tests/classes/assign_test.php b/tests/classes/assign_test.php index d424092..9bad6f6 100644 --- a/tests/classes/assign_test.php +++ b/tests/classes/assign_test.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Tests for assign module class for plagiarism_turnitinsim component + * Tests for assign module class for plagiarism_turnitinsim component. * * @package plagiarism_turnitinsim * @copyright 2018 Turnitin @@ -28,8 +28,14 @@ global $CFG; require_once($CFG->dirroot . '/plagiarism/turnitinsim/classes/assign.class.php'); +/** + * Tests for assign module class for plagiarism_turnitinsim component. + */ class assign_test extends advanced_testcase { + /** + * This is text content for unit testing a text submission. + */ const TEST_ASSIGN_TEXT = 'This is text content for unit testing a text submission.'; /** @@ -43,7 +49,7 @@ public function setup() { set_config('turnitinapikey', 1234, 'plagiarism_turnitinsim'); set_config('turnitinenablelogging', 0, 'plagiarism_turnitinsim'); - // Set the features enabled + // Set the features enabled. $featuresenabled = file_get_contents(__DIR__ . '/../fixtures/get_features_enabled_success.json'); set_config('turnitin_features_enabled', $featuresenabled, 'plagiarism_turnitinsim'); @@ -192,7 +198,7 @@ public function test_get_itemid_returns_zero_if_no_submission() { $this->assertEquals($tsassign->get_itemid($params), 0); } - /* + /** * Test that getting the author returns the correct user id. */ public function test_get_author_returns_correct_user_id() { @@ -245,7 +251,7 @@ public function test_get_author_returns_correct_user_id() { } - /* + /** * Test that checking the group author returns the first student. */ public function test_check_group_first_author_returns_first_student() { @@ -265,7 +271,7 @@ public function test_check_group_first_author_returns_first_student() { $this->assertEquals($this->student1->id, $response); } - /* + /** * Test that checking the group author does not return an instructor. */ public function test_check_group_first_author_does_not_return_instructor() { @@ -285,7 +291,7 @@ public function test_check_group_first_author_does_not_return_instructor() { $this->assertEquals($this->student1->id, $response); } - /* + /** * Test that checking the group author does not return a user if no students are in the group. */ public function test_check_group_first_author_returns_no_user_if_no_students_in_group() { @@ -304,7 +310,7 @@ public function test_check_group_first_author_returns_no_user_if_no_students_in_ $this->assertEquals(0, $response); } - /* + /** * Test that is submission draft returns correctly. */ public function test_is_submission_draft() { diff --git a/tests/classes/forum_test.php b/tests/classes/forum_test.php index a6b195e..925e790 100644 --- a/tests/classes/forum_test.php +++ b/tests/classes/forum_test.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Tests for forum module class for plagiarism_turnitinsim component + * Tests for forum module class for plagiarism_turnitinsim component. * * @package plagiarism_turnitinsim * @copyright 2018 Turnitin @@ -28,8 +28,14 @@ global $CFG; require_once($CFG->dirroot . '/plagiarism/turnitinsim/classes/forum.class.php'); +/** + * Tests for forum module class for plagiarism_turnitinsim component. + */ class forum_test extends advanced_testcase { + /** + * Sample text for testing a forum. + */ const TEST_FORUM_TEXT = 'This is a test forum post'; /** @@ -43,7 +49,7 @@ public function setup() { set_config('turnitinapikey', 1234, 'plagiarism_turnitinsim'); set_config('turnitinenablelogging', 0, 'plagiarism_turnitinsim'); - // Set the features enabled + // Set the features enabled. $featuresenabled = file_get_contents(__DIR__ . '/../fixtures/get_features_enabled_success.json'); set_config('turnitin_features_enabled', $featuresenabled, 'plagiarism_turnitinsim'); @@ -73,6 +79,11 @@ public function setup() { ); } + /** + * Test that get_onlinetext returns the correct text. + * @throws coding_exception + * @throws dml_exception + */ public function test_get_onlinetext_returns_correct_text() { $this->resetAfterTest(); @@ -163,7 +174,7 @@ public function test_get_itemid_returns_zero_if_no_submission() { $this->assertEquals($result, 0); } - /* + /** * Test that getting the author returns the related user id. */ public function test_get_author_returns_related_user_id() { @@ -171,12 +182,12 @@ public function test_get_author_returns_related_user_id() { // Test that get author returns student2 as the author. $tsforum = new plagiarism_turnitinsim_forum(); - $response = $tsforum->get_author($this->student1->id, $this->student2->id, 0, 0); + $response = $tsforum->get_author($this->student1->id, $this->student2->id); $this->assertEquals($this->student2->id, $response); // Test that get author returns student1 as the author because relateduserid is empty. $tsforum = new plagiarism_turnitinsim_forum(); - $response = $tsforum->get_author($this->student1->id, 0, 0, 0); + $response = $tsforum->get_author($this->student1->id, 0); $this->assertEquals($this->student1->id, $response); } diff --git a/tests/classes/tscallback_test.php b/tests/classes/tscallback_test.php index 4eab887..ec812f4 100644 --- a/tests/classes/tscallback_test.php +++ b/tests/classes/tscallback_test.php @@ -32,9 +32,7 @@ require_once($CFG->dirroot . '/plagiarism/turnitinsim/tests/utilities.php'); /** - * Tests for Turnitin Integrity submission class - * - * @package turnitinsim + * Tests for Turnitin Integrity submission class. */ class plagiarism_tscallback_class_testcase extends advanced_testcase { @@ -75,7 +73,7 @@ public function test_get_webhook_failure() { // Get webhook. $tscallback = new plagiarism_turnitinsim_callback( $tsrequest ); $mockwebhookid = (new handle_deprecation)->create_uuid(); - $result = $tscallback->get_webhook($mockwebhookid); + $result = $tscallback->has_webhook($mockwebhookid); // Test that the webhook has not been retrieved. $this->assertFalse($result); @@ -101,7 +99,7 @@ public function test_get_webhook_exception() { // Get webhook. $tscallback = new plagiarism_turnitinsim_callback($tsrequest); $mockwebhookid = (new handle_deprecation)->create_uuid(); - $result = $tscallback->get_webhook($mockwebhookid); + $result = $tscallback->has_webhook($mockwebhookid); // Test that the webhook has not been retrieved. $this->assertTrue($result); @@ -130,7 +128,7 @@ public function test_get_webhook_failure_different_url() { // Get webhook. $tscallback = new plagiarism_turnitinsim_callback( $tsrequest ); $mockwebhookid = (new handle_deprecation)->create_uuid(); - $result = $tscallback->get_webhook($mockwebhookid); + $result = $tscallback->has_webhook($mockwebhookid); // Test that the webhook should return false as the URL does not match the current site. $this->assertFalse($result); @@ -159,7 +157,7 @@ public function test_get_webhook_success() { // Get webhook. $tscallback = new plagiarism_turnitinsim_callback( $tsrequest ); $mockwebhookid = (new handle_deprecation)->create_uuid(); - $result = $tscallback->get_webhook($mockwebhookid); + $result = $tscallback->has_webhook($mockwebhookid); // Test that the webhook should fail to retrieve as the URL does not match the current site. $this->assertTrue($result); diff --git a/tests/classes/tseula_test.php b/tests/classes/tseula_test.php index 22d9c24..a53139a 100644 --- a/tests/classes/tseula_test.php +++ b/tests/classes/tseula_test.php @@ -30,9 +30,7 @@ require_once($CFG->dirroot . '/plagiarism/turnitinsim/tests/utilities.php'); /** - * Tests for Turnitin Integrity submission class - * - * @package turnitinsim + * Tests for Turnitin Integrity submission class. */ class plagiarism_turnitinsim_eula_class_testcase extends advanced_testcase { diff --git a/tests/classes/tsgroup_test.php b/tests/classes/tsgroup_test.php index 1dd13a0..27fe237 100644 --- a/tests/classes/tsgroup_test.php +++ b/tests/classes/tsgroup_test.php @@ -30,8 +30,6 @@ /** * Tests for Turnitin Integrity group class. - * - * @package turnitinsim */ class plagiarism_turnitinsim_group_class_testcase extends advanced_testcase { diff --git a/tests/classes/tsrequest_test.php b/tests/classes/tsrequest_test.php index 8579cf1..e905ab6 100644 --- a/tests/classes/tsrequest_test.php +++ b/tests/classes/tsrequest_test.php @@ -31,9 +31,7 @@ require_once($CFG->dirroot . '/plagiarism/turnitinsim/tests/utilities.php'); /** - * Tests for Turnitin Integrity submission class - * - * @package turnitinsim + * Tests for Turnitin Integrity submission class. */ class plagiarism_tsrequest_testcase extends advanced_testcase { diff --git a/tests/classes/tssettings_test.php b/tests/classes/tssettings_test.php index 24231d9..b34bd9b 100644 --- a/tests/classes/tssettings_test.php +++ b/tests/classes/tssettings_test.php @@ -31,8 +31,6 @@ /** * Tests for settings form. - * - * @package turnitinsim */ class plagiarism_tssettings_class_testcase extends advanced_testcase { diff --git a/tests/classes/tssettingsdefaultsform_test.php b/tests/classes/tssettingsdefaultsform_test.php index b1623f5..4e9951a 100644 --- a/tests/classes/tssettingsdefaultsform_test.php +++ b/tests/classes/tssettingsdefaultsform_test.php @@ -30,8 +30,6 @@ /** * Tests for default settings form. - * - * @package turnitinsim */ class plagiarism_tsdefaultsform_testcase extends advanced_testcase { diff --git a/tests/classes/tssetupform_test.php b/tests/classes/tssetupform_test.php index 287d740..749ec42 100644 --- a/tests/classes/tssetupform_test.php +++ b/tests/classes/tssetupform_test.php @@ -30,8 +30,6 @@ /** * Tests for settings form. - * - * @package turnitinsim */ class plagiarism_tssetupform_class_testcase extends advanced_testcase { diff --git a/tests/classes/tssubmission_test.php b/tests/classes/tssubmission_test.php index 2746558..b100eca 100644 --- a/tests/classes/tssubmission_test.php +++ b/tests/classes/tssubmission_test.php @@ -30,13 +30,18 @@ require_once($CFG->dirroot . '/plagiarism/turnitinsim/tests/utilities.php'); /** - * Tests for Turnitin Integrity submission class - * - * @package turnitinsim + * Tests for Turnitin Integrity submission class. */ class plagiarism_turnitinsim_submission_class_testcase extends advanced_testcase { + /** + * A valid submission ID. + */ const VALID_SUBMISSION_ID = '0ec9141f-3390-460e-8d2f-a4080080e749'; + + /** + * An invalid submission ID. + */ const INVALID_SUBMISSION_ID = 'INVALID_ID'; /** @@ -117,6 +122,7 @@ public function test_update() { $tssubmission->setstatus(TURNITINSIM_SUBMISSION_STATUS_QUEUED); $tssubmission->settogenerate(1); $tssubmission->setgenerationtime(100000001); + $tssubmission->update(); // Submission id should now be set. @@ -203,7 +209,7 @@ public function test_build_user_array_entry_returns_userid_only_if_student_priva $this->assertEquals($tsuser->get_turnitinid(), $userentry['id']); } - /* + /** * Test that create metadata returns no data if the cm doesn't exist. */ public function test_create_group_metadata_no_cm() { @@ -321,7 +327,7 @@ public function test_get_owner_returns_group_id_for_group_submission() { $this->assertEquals($tsgroup->get_turnitinid(), $owner); } - /* + /** * Test that create metadata returns as expected. */ public function test_create_group_metadata_full() { @@ -1654,25 +1660,25 @@ public function test_similarity_overrides_are_true() { /** * Test that the similarity overrides are false when configured as such. */ - public function test_similarity_overrides_are_false() { - $this->resetAfterTest(); + public function test_similarity_overrides_are_false() { + $this->resetAfterTest(); - set_config('turnitinviewersavechanges', 0, 'plagiarism_turnitinsim'); + set_config('turnitinviewersavechanges', 0, 'plagiarism_turnitinsim'); - // Create assign module. - $record = new stdClass(); - $record->course = $this->course; - $module = $this->getDataGenerator()->create_module('assign', $record); + // Create assign module. + $record = new stdClass(); + $record->course = $this->course; + $module = $this->getDataGenerator()->create_module('assign', $record); - // Get course module data. - $cm = get_coursemodule_from_instance('assign', $module->id); + // Get course module data. + $cm = get_coursemodule_from_instance('assign', $module->id); - // Create submission object. - $tssubmission = new plagiarism_turnitinsim_submission(); - $tssubmission->setcm($cm->id); + // Create submission object. + $tssubmission = new plagiarism_turnitinsim_submission(); + $tssubmission->setcm($cm->id); - // Verify that viewer permissions are true as the config values are set to true. - $overrides = $tssubmission->create_similarity_overrides(); - $this->assertFalse($overrides['view_settings']['save_changes']); - } + // Verify that viewer permissions are true as the config values are set to true. + $overrides = $tssubmission->create_similarity_overrides(); + $this->assertFalse($overrides['view_settings']['save_changes']); + } } \ No newline at end of file diff --git a/tests/classes/tstask_test.php b/tests/classes/tstask_test.php index e3fe8f4..c57e2f3 100644 --- a/tests/classes/tstask_test.php +++ b/tests/classes/tstask_test.php @@ -30,12 +30,17 @@ /** * Tests for Turnitin Integrity user class. - * - * @package turnitinsim */ class plagiarism_turnitinsim_task_class_testcase extends advanced_testcase { + /** + * An example API URL used for unit testing. + */ const TURNITINSIM_API_URL = 'http://test.turnitin.com'; + + /** + * An example API key used for unit testing. + */ const TURNITINSIM_API_KEY = '123456'; /** @@ -106,7 +111,7 @@ public function test_test_webhook() { public function test_check_latest_eula_version() { $this->resetAfterTest(); - // Set the features enabled + // Set the features enabled. $featuresenabled = file_get_contents(__DIR__ . '/../fixtures/get_features_enabled_success.json'); set_config('turnitin_features_enabled', $featuresenabled, 'plagiarism_turnitinsim'); @@ -136,7 +141,7 @@ public function test_check_latest_eula_version() { $this->assertEquals($url, $latesteula->url); } - /* + /** * Test that test_check_enabled_features sets the config as expected. */ public function test_check_enabled_features() { diff --git a/tests/classes/tsuser_test.php b/tests/classes/tsuser_test.php index 3f032a8..909aae0 100644 --- a/tests/classes/tsuser_test.php +++ b/tests/classes/tsuser_test.php @@ -30,8 +30,6 @@ /** * Tests for Turnitin Integrity user class. - * - * @package turnitinsim */ class plagiarism_turnitinsim_user_class_testcase extends advanced_testcase { diff --git a/tests/classes/workshop_test.php b/tests/classes/workshop_test.php index 32748dc..9f3357f 100644 --- a/tests/classes/workshop_test.php +++ b/tests/classes/workshop_test.php @@ -30,8 +30,14 @@ require_once($CFG->dirroot . '/mod/workshop/locallib.php'); require_once($CFG->dirroot . '/mod/workshop/tests/fixtures/testable.php'); +/** + * Tests for workshop module class for plagiarism_turnitinsim component + */ class workshop_test extends advanced_testcase { + /** + * Sameple text used for unit testing a workshop. + */ const TEST_WORKSHOP_TEXT = 'Generated content'; /** @@ -43,7 +49,7 @@ public function setup() { set_config('turnitinapikey', 1234, 'plagiarism_turnitinsim'); set_config('turnitinenablelogging', 0, 'plagiarism_turnitinsim'); - // Set the features enabled + // Set the features enabled. $featuresenabled = file_get_contents(__DIR__ . '/../fixtures/get_features_enabled_success.json'); set_config('turnitin_features_enabled', $featuresenabled, 'plagiarism_turnitinsim'); @@ -51,6 +57,11 @@ public function setup() { $this->student2 = $this->getDataGenerator()->create_user(); } + /** + * Test that get_onlinetext returns the correct text. + * @throws coding_exception + * @throws dml_exception + */ public function test_get_onlinetext_returns_correct_text() { global $DB; @@ -138,7 +149,7 @@ public function test_get_itemid_returns_zero_if_no_submission() { $this->assertEquals($result, 0); } - /* + /** * Test that getting the author returns the related user id. */ public function test_get_author_returns_related_user_id() { @@ -146,12 +157,12 @@ public function test_get_author_returns_related_user_id() { // Test that get author returns student2 as the author. $tsworkshop = new plagiarism_turnitinsim_workshop(); - $response = $tsworkshop->get_author($this->student1->id, $this->student2->id, 0, 0); + $response = $tsworkshop->get_author($this->student1->id, $this->student2->id); $this->assertEquals($this->student2->id, $response); // Test that get author returns student1 as the author because relateduserid is empty. $tsworkshop = new plagiarism_turnitinsim_workshop(); - $response = $tsworkshop->get_author($this->student1->id, 0, 0, 0); + $response = $tsworkshop->get_author($this->student1->id, 0); $this->assertEquals($this->student1->id, $response); } diff --git a/tests/lib_test.php b/tests/lib_test.php index 9e21af1..feb17d7 100644 --- a/tests/lib_test.php +++ b/tests/lib_test.php @@ -30,16 +30,31 @@ require_once($CFG->dirroot . '/plagiarism/turnitinsim/classes/setup_form.class.php'); /** - * Tests for lib methods - * - * @package turnitinsim + * Tests for lib methods. */ class plagiarism_turnitinsim_lib_testcase extends advanced_testcase { + /** + * Sample eula version for unit testing. + */ const EULA_VERSION_1 = 'EULA1'; + + /** + * Sample API URL for unit testing. + */ const TURNITINSIM_API_URL = 'http://test.turnitin.com'; + + /** + * Sample API key for unit testing. + */ const TURNITINSIM_API_KEY = '123456'; + /** + * Get a list of activity modules that support plagiarism plugins. + * + * @return int|string + * @throws coding_exception + */ public function get_module_that_supports_plagiarism() { $mods = core_component::get_plugin_list('mod'); @@ -61,7 +76,7 @@ public function setup() { set_config('turnitinapikey', 1234, 'plagiarism_turnitinsim'); set_config('turnitinenablelogging', 0, 'plagiarism_turnitinsim'); - // Set the features enabled + // Set the features enabled. $featuresenabled = file_get_contents(__DIR__ . '/fixtures/get_features_enabled_success.json'); set_config('turnitin_features_enabled', $featuresenabled, 'plagiarism_turnitinsim'); @@ -387,7 +402,7 @@ public function test_get_links_with_submission() { $this->assertContains('or_score_colour_' . round($score, -1), $plagiarismturnitinsim->get_links($linkarray)); } - /* + /** * Test that a resubmit link is rendered correctly. */ public function test_render_resubmit_link() { @@ -482,7 +497,7 @@ public function test_is_plugin_configured_with_credentials_saved() { $this->assertTrue($plagiarismturnitinsim->is_plugin_configured($this->cm)); } - /* + /** * Test that the EULA is output if the user has not accepted the latest version previously. */ public function test_print_disclosure_display_latest() { @@ -516,7 +531,7 @@ public function test_print_disclosure_display_latest() { ); } - /* + /** * Test that the EULA is not output if the user has accepted the latest version previously. */ public function test_print_disclosure_not_display_latest() { @@ -559,7 +574,7 @@ public function test_print_disclosure_eula_not_displayed_if_not_required() { set_config('turnitinsim_use', 1, 'plagiarism'); set_config('turnitinmodenabledassign', 1, 'plagiarism_turnitinsim'); - // Set the features enabled + // Set the features enabled. $featuresenabled = file_get_contents(__DIR__ . '/fixtures/get_features_enabled_eula_not_required.json'); set_config('turnitin_features_enabled', $featuresenabled, 'plagiarism_turnitinsim'); @@ -787,7 +802,7 @@ public function test_submit_handler_file_queued_without_requiring_eula() { set_config('turnitinsim_use', 1, 'plagiarism'); set_config('turnitinmodenabledassign', 1, 'plagiarism_turnitinsim'); - // Set the features enabled + // Set the features enabled. $featuresenabled = file_get_contents(__DIR__ . '/fixtures/get_features_enabled_eula_not_required.json'); set_config('turnitin_features_enabled', $featuresenabled, 'plagiarism_turnitinsim'); diff --git a/tests/privacy/provider_test.php b/tests/privacy/provider_test.php index bcfa01d..43b59f3 100644 --- a/tests/privacy/provider_test.php +++ b/tests/privacy/provider_test.php @@ -34,8 +34,14 @@ require_once($CFG->dirroot . '/mod/assign/externallib.php'); require_once($CFG->dirroot . '/plagiarism/turnitinsim/tests/turnitinsim_generator.php'); +/** + * Privacy provider tests. + */ class plagiarism_turnitinsim_privacy_provider_testcase extends advanced_testcase { + /** + * Setup method that runs before each test. + */ public function setup() { $this->turnitinsim_generator = new turnitinsim_generator(); $this->submission = $this->turnitinsim_generator->create_submission(); @@ -112,6 +118,9 @@ public function test_get_contexts_for_userid() { $this->assertCount(1, $contextlist); } + /** + * Test that user data is exported, + */ public function test_export_plagiarism_user_data() { global $DB; $this->resetAfterTest(); @@ -125,6 +134,9 @@ public function test_export_plagiarism_user_data() { $this->assertTrue($writer->has_any_data()); } + /** + * Test that data can be deleted. + */ public function test_delete_plagiarism_for_user() { global $DB; $this->resetAfterTest(); @@ -139,6 +151,9 @@ public function test_delete_plagiarism_for_user() { $this->assertEquals(0, count($submissions)); } + /** + * Test that data for contexts can be deleted. + */ public function test_delete_plagiarism_for_context() { global $DB; $this->resetAfterTest(); diff --git a/tests/turnitinsim_generator.php b/tests/turnitinsim_generator.php index d24817d..1b3103d 100644 --- a/tests/turnitinsim_generator.php +++ b/tests/turnitinsim_generator.php @@ -25,8 +25,16 @@ defined('MOODLE_INTERNAL') || die(); +/** + * Generator for Turnitin tests. + */ class turnitinsim_generator extends advanced_testcase { + /** + * Define test_generator method. + * + * @return bool + */ public function test_generator() { return true; } @@ -37,6 +45,8 @@ public function test_generator() { * * @param array $params parameters to be provided to the assignment module creation * @return array containing the course, assignment module, student and teacher + * @throws coding_exception + * @throws dml_exception */ public function create_assign_with_student_and_teacher($params = array()) { global $DB; @@ -77,8 +87,10 @@ public function create_assign_with_student_and_teacher($params = array()) { /** * Create a Turnitin submission. * - * @param int $numsubmissions + * @param int $numsubmissions The number of submissions to create. * @return array + * @throws coding_exception + * @throws dml_exception */ public function create_submission($numsubmissions = 1) { global $DB, $CFG; diff --git a/tests/utilities.php b/tests/utilities.php index e938267..bf3a51f 100644 --- a/tests/utilities.php +++ b/tests/utilities.php @@ -28,8 +28,14 @@ /** * Create and return a file to use for test submissions. * - * @param $usercontextid + * @param $itemid string The Moodle item ID for the submission file. + * @param $usercontextid int The context ID. + * @param $component string The component the file belongs to. + * @param $filearea string The file area for the file. * @return mixed + * @throws coding_exception + * @throws file_exception + * @throws stored_file_creation_exception */ function create_test_file($itemid, $usercontextid, $component, $filearea) { diff --git a/thirdpartylibs.xml b/thirdpartylibs.xml index 47466f6..c6bdf49 100644 --- a/thirdpartylibs.xml +++ b/thirdpartylibs.xml @@ -14,4 +14,18 @@ PHP Framework Interoperability Group + + vendor/composer + Composer + + + + + + vendor/autoload.php + Composer + + + + \ No newline at end of file diff --git a/utilities/handle_deprecation.php b/utilities/handle_deprecation.php index abc351e..5bc4028 100644 --- a/utilities/handle_deprecation.php +++ b/utilities/handle_deprecation.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Constants for plagiarism_turnitinsim component + * Class for handling deprecations for plagiarism_turnitinsim component. * * @package plagiarism_turnitinsim * @copyright 2020 Turnitin @@ -26,12 +26,17 @@ defined('MOODLE_INTERNAL') || die(); /** - * Class deprecations - As Moodle development continues, we sometimes need to continue supporting methods that have - * been deprecated so that our plugin continues to work in older Moodle versions. + * Handle class deprecations so that we can support multiple Moodle versions. */ class handle_deprecation { + /** + * @var int The Moodle version. + */ public $branch; + /** + * handle_deprecation constructor. + */ public function __construct() { global $CFG; $this->branch = $CFG->branch; diff --git a/version.php b/version.php index 7e54cb3..e76e4ed 100644 --- a/version.php +++ b/version.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * Version file for the plagiarism_turnitinsim plugin. + * * @package plagiarism_turnitinsim * @copyright 2017 Turnitin * @author John McGettrick @@ -23,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2020030501; +$plugin->version = 2020031801; $plugin->release = "v1.0"; $plugin->requires = 2017051500; $plugin->component = 'plagiarism_turnitinsim';