From 9fb7d92a822adfbc2a55092293fb540bf8a83484 Mon Sep 17 00:00:00 2001 From: David Winn Date: Thu, 1 Oct 2020 09:18:28 +0100 Subject: [PATCH 01/42] Support submission type for all types --- classes/submission.class.php | 2 +- tests/classes/tssubmission_test.php | 72 +++++++++++++++++++++++++++++ utilities/constants.php | 3 -- 3 files changed, 73 insertions(+), 4 deletions(-) diff --git a/classes/submission.class.php b/classes/submission.class.php index 44c54f0..ab75e97 100644 --- a/classes/submission.class.php +++ b/classes/submission.class.php @@ -314,7 +314,7 @@ public function create_group_metadata() { $assignment = array( 'id' => $cm->id, 'name' => $cm->name, - 'type' => TURNITINSIM_GROUP_TYPE_ASSIGNMENT + 'type' => $cm->modname == "assign" ? "ASSIGNMENT" : strtoupper($cm->modname) ); // Add course metadata. diff --git a/tests/classes/tssubmission_test.php b/tests/classes/tssubmission_test.php index 99523e6..cc18e2a 100644 --- a/tests/classes/tssubmission_test.php +++ b/tests/classes/tssubmission_test.php @@ -362,6 +362,7 @@ public function test_create_group_metadata_full() { // Verify assignment is in metadata. $this->assertEquals($metadata['group']['id'], $cm->id); $this->assertEquals($metadata['group']['name'], $cm->name); + $this->assertEquals($metadata['group']['type'], 'ASSIGNMENT'); // Verify course data is in metadata. $coursedetails = $DB->get_record('course', array('id' => $cm->course), 'fullname'); @@ -378,6 +379,77 @@ public function test_create_group_metadata_full() { $this->assertEquals($metadata['group_context']['owners'][0]['email'], $instructor->email); } + /** + * Test that create metadata returns expected group type for forum. + */ + public function test_create_group_metadata_forum() { + $this->resetAfterTest(); + + // Create assign module. + $record = new stdClass(); + $record->course = $this->course; + $module = $this->getDataGenerator()->create_module('forum', $record); + + // Get course module data. + $cm = get_coursemodule_from_instance('forum', $module->id); + + $tssubmission = new plagiarism_turnitinsim_submission(); + $tssubmission->setcm($cm->id); + + $metadata = $tssubmission->create_group_metadata(); + + // Verify forum is in metadata. + $this->assertEquals($metadata['group']['type'], 'FORUM'); + } + + /** + * Test that create metadata returns expected group type for workshop. + */ + public function test_create_group_metadata_workshop() { + $this->resetAfterTest(); + + $this->setAdminUser(); + + // Create assign module. + $record = new stdClass(); + $record->course = $this->course; + $module = $this->getDataGenerator()->create_module('workshop', $record); + + // Get course module data. + $cm = get_coursemodule_from_instance('workshop', $module->id); + + $tssubmission = new plagiarism_turnitinsim_submission(); + $tssubmission->setcm($cm->id); + + $metadata = $tssubmission->create_group_metadata(); + + // Verify forum is in metadata. + $this->assertEquals($metadata['group']['type'], 'WORKSHOP'); + } + + /** + * Test that create metadata returns expected group type for quiz. + */ + public function test_create_group_metadata_quiz() { + $this->resetAfterTest(); + + // Create assign module. + $record = new stdClass(); + $record->course = $this->course; + $module = $this->getDataGenerator()->create_module('quiz', $record); + + // Get course module data. + $cm = get_coursemodule_from_instance('quiz', $module->id); + + $tssubmission = new plagiarism_turnitinsim_submission(); + $tssubmission->setcm($cm->id); + + $metadata = $tssubmission->create_group_metadata(); + + // Verify forum is in metadata. + $this->assertEquals($metadata['group']['type'], 'QUIZ'); + } + /** * Test that get file details returns false if a file doesn't exist. */ diff --git a/utilities/constants.php b/utilities/constants.php index b74ed6f..f484ac8 100644 --- a/utilities/constants.php +++ b/utilities/constants.php @@ -103,9 +103,6 @@ define('TURNITINSIM_REPORT_GEN_RETRY_WAIT_SECONDS', 3600); define('TURNITINSIM_REPORT_GEN_FIRST_ATTEMPT_RETRY_WAIT_SECONDS', 900); -// Metadata. -define('TURNITINSIM_GROUP_TYPE_ASSIGNMENT', 'ASSIGNMENT'); - // Turnitin Roles. define('TURNITINSIM_ROLE_INSTRUCTOR', 'INSTRUCTOR'); define('TURNITINSIM_ROLE_LEARNER', 'LEARNER'); \ No newline at end of file From db5cd2905a26b9aa6f0143f41a4fc5ddfd7d586a Mon Sep 17 00:00:00 2001 From: David Winn Date: Thu, 1 Oct 2020 11:12:07 +0100 Subject: [PATCH 02/42] Fixing comments --- tests/classes/tssubmission_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/classes/tssubmission_test.php b/tests/classes/tssubmission_test.php index cc18e2a..2d37d4b 100644 --- a/tests/classes/tssubmission_test.php +++ b/tests/classes/tssubmission_test.php @@ -385,7 +385,7 @@ public function test_create_group_metadata_full() { public function test_create_group_metadata_forum() { $this->resetAfterTest(); - // Create assign module. + // Create forum module. $record = new stdClass(); $record->course = $this->course; $module = $this->getDataGenerator()->create_module('forum', $record); @@ -410,7 +410,7 @@ public function test_create_group_metadata_workshop() { $this->setAdminUser(); - // Create assign module. + // Create workshop module. $record = new stdClass(); $record->course = $this->course; $module = $this->getDataGenerator()->create_module('workshop', $record); @@ -433,7 +433,7 @@ public function test_create_group_metadata_workshop() { public function test_create_group_metadata_quiz() { $this->resetAfterTest(); - // Create assign module. + // Create quiz module. $record = new stdClass(); $record->course = $this->course; $module = $this->getDataGenerator()->create_module('quiz', $record); From 5952c27fd3cb07752167d81f417560ba59f9ca47 Mon Sep 17 00:00:00 2001 From: Jordan Marshall Date: Thu, 1 Oct 2020 15:33:48 +0100 Subject: [PATCH 03/42] --Put EULA string in p tags --Add margin between the accept and decline buttons --- lib.php | 5 ++++- styles.css | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib.php b/lib.php index 746ebb6..afc2f0b 100644 --- a/lib.php +++ b/lib.php @@ -505,7 +505,10 @@ public function print_disclosure($cmid) { // Output EULA container. $output = html_writer::tag( 'div', - $eulalink.$eulaacceptbtn.$euladeclinebtn, + html_writer::tag( + 'p', + $eulalink + ).$eulaacceptbtn.$euladeclinebtn, array('class' => 'eulacontainer', 'id' => 'eulacontainer') ); diff --git a/styles.css b/styles.css index fdcbca0..4c48c24 100644 --- a/styles.css +++ b/styles.css @@ -42,7 +42,7 @@ } .turnitinsim_eulacontainer #pp-eula-accept { - margin-left: 20px; + margin-right: 5px; } /* Icons in get_links */ From 3ea344921eb91fd272cbeb4e8c0ddc8c48d2c94f Mon Sep 17 00:00:00 2001 From: Jordan Marshall Date: Thu, 1 Oct 2020 17:40:45 +0100 Subject: [PATCH 04/42] Remove turnitinsim from css styling --- styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles.css b/styles.css index 4c48c24..d845efb 100644 --- a/styles.css +++ b/styles.css @@ -41,7 +41,7 @@ margin-bottom: 10px; } -.turnitinsim_eulacontainer #pp-eula-accept { +.eulacontainer #pp-eula-accept { margin-right: 5px; } From 2e438f523095641b0846163319aed61644aed9cb Mon Sep 17 00:00:00 2001 From: Mat DeLong Date: Fri, 2 Oct 2020 12:09:33 +0100 Subject: [PATCH 05/42] INT-14332: Fix for spacing between all but first two radio buttons in settings --- classes/settings.class.php | 28 ++++++++++++++++++++++++---- styles.css | 6 +++++- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/classes/settings.class.php b/classes/settings.class.php index 93c1f64..645f037 100644 --- a/classes/settings.class.php +++ b/classes/settings.class.php @@ -100,16 +100,36 @@ public function add_settings_to_module($mform, $canconfigureplugin = false, $con // Immediate. $label = get_string('reportgen0', 'plagiarism_turnitinsim'); - $reportgen[] = $mform->createElement('radio', 'reportgeneration', null, $label, TURNITINSIM_REPORT_GEN_IMMEDIATE); + $reportgen[] = $mform->createElement( + 'radio', + 'reportgeneration', + null, + $label, + TURNITINSIM_REPORT_GEN_IMMEDIATE, + array('class' => 'turnitinsim_settings_radio') + ); // Immediate and Due Date. $label = get_string('reportgen1', 'plagiarism_turnitinsim'); - $reportgen[] = $mform->createElement('radio', 'reportgeneration', null, $label, - TURNITINSIM_REPORT_GEN_IMMEDIATE_AND_DUEDATE); + $reportgen[] = $mform->createElement( + 'radio', + 'reportgeneration', + null, + $label, + TURNITINSIM_REPORT_GEN_IMMEDIATE_AND_DUEDATE, + array('class' => 'turnitinsim_settings_radio') + ); // Due Date. $label = get_string('reportgen2', 'plagiarism_turnitinsim'); - $reportgen[] = $mform->createElement('radio', 'reportgeneration', null, $label, TURNITINSIM_REPORT_GEN_DUEDATE); + $reportgen[] = $mform->createElement( + 'radio', + 'reportgeneration', + null, + $label, + TURNITINSIM_REPORT_GEN_DUEDATE, + array('class' => 'turnitinsim_settings_radio') + ); // Group Report Gen options together. $mform->addGroup($reportgen, 'reportgenoptions', get_string('reportgenoptions', 'plagiarism_turnitinsim'), '
'); diff --git a/styles.css b/styles.css index fdcbca0..c73df53 100644 --- a/styles.css +++ b/styles.css @@ -126,4 +126,8 @@ .turnitinsim_links .turnitinsim_status .or_score_colour_100 { background: #db4221; color: #fff; -} \ No newline at end of file +} + +.turnitinsim_settings_radio { + margin-right: 0; +} From 32f58db9dc0fc9221853d658b97076dc13556b0b Mon Sep 17 00:00:00 2001 From: Jordan Marshall Date: Fri, 2 Oct 2020 13:24:56 +0100 Subject: [PATCH 06/42] -- Add turnitinsim prefix to styling --- styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles.css b/styles.css index d845efb..4c48c24 100644 --- a/styles.css +++ b/styles.css @@ -41,7 +41,7 @@ margin-bottom: 10px; } -.eulacontainer #pp-eula-accept { +.turnitinsim_eulacontainer #pp-eula-accept { margin-right: 5px; } From cbdd58ad7fa74d19ee4c2cabedc6e940e857f2e3 Mon Sep 17 00:00:00 2001 From: Jordan Marshall Date: Fri, 2 Oct 2020 14:07:53 +0100 Subject: [PATCH 07/42] Fix eulacontainer styling --- amd/src/cv_launch.js | 2 +- amd/src/eula_response.js | 4 ++-- lib.php | 4 ++-- styles.css | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/amd/src/cv_launch.js b/amd/src/cv_launch.js index a638cb4..281550d 100644 --- a/amd/src/cv_launch.js +++ b/amd/src/cv_launch.js @@ -48,7 +48,7 @@ define(['jquery', 'core/str'], function($, str) { str.get_string('loadingcv', 'plagiarism_turnitinsim').done(function(text) { loading += '

' + text + '

'; - $('.eulacontainer').hide().html(text).fadeIn(); + $('.turnitinsim_eulacontainer').hide().html(text).fadeIn(); }); loading += ''; diff --git a/amd/src/eula_response.js b/amd/src/eula_response.js index 87b2ecc..220f015 100644 --- a/amd/src/eula_response.js +++ b/amd/src/eula_response.js @@ -44,7 +44,7 @@ define(['jquery', 'core/str'], function($, str) { data: {action: "accept_eula", sesskey: M.cfg.sesskey}, success: function() { str.get_string('eulaaccepted', 'plagiarism_turnitinsim').done(function(text) { - $('.eulacontainer').hide().html(text).fadeIn(); + $('.turnitinsim_eulacontainer').hide().html(text).fadeIn(); }); } }); @@ -52,7 +52,7 @@ define(['jquery', 'core/str'], function($, str) { $(document).on('click', '#pp-eula-decline', function() { str.get_string('euladeclined', 'plagiarism_turnitinsim').done(function(text) { - $('.eulacontainer').hide().html(text).fadeIn(); + $('.turnitinsim_eulacontainer').hide().html(text).fadeIn(); }); $('input[name=submitbutton]').prop('disabled', ''); diff --git a/lib.php b/lib.php index 746ebb6..9649857 100644 --- a/lib.php +++ b/lib.php @@ -466,7 +466,7 @@ public function print_disclosure($cmid) { return html_writer::tag( 'div', get_string('eulaalreadyaccepted', 'plagiarism_turnitinsim'), - array('class' => 'eulacontainer', 'id' => 'eulacontainer') + array('class' => 'turnitinsim_eulacontainer', 'id' => 'turnitinsim_eulacontainer') ); } @@ -474,7 +474,7 @@ public function print_disclosure($cmid) { return html_writer::tag( 'div', get_string('eulanotrequired', 'plagiarism_turnitinsim'), - array('class' => 'eulacontainer', 'id' => 'eulacontainer') + array('class' => 'turnitinsim_eulacontainer', 'id' => 'turnitinsim_eulacontainer') ); } diff --git a/styles.css b/styles.css index fdcbca0..4c48c24 100644 --- a/styles.css +++ b/styles.css @@ -42,7 +42,7 @@ } .turnitinsim_eulacontainer #pp-eula-accept { - margin-left: 20px; + margin-right: 5px; } /* Icons in get_links */ From f4c6a4d069ba0ff7b2dd345c824102116105c3a7 Mon Sep 17 00:00:00 2001 From: Mat DeLong Date: Fri, 2 Oct 2020 14:44:32 +0100 Subject: [PATCH 08/42] Increase specificity of css targeting to override moodle style --- styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles.css b/styles.css index c73df53..a99557d 100644 --- a/styles.css +++ b/styles.css @@ -128,6 +128,6 @@ color: #fff; } -.turnitinsim_settings_radio { +.form-group .form-inline .form-check-inline.form-check-label.fitem.turnitinsim_settings_radio { margin-right: 0; } From 5c4494cf9ec51266640c64d892202453cd504403 Mon Sep 17 00:00:00 2001 From: Jordan Marshall Date: Fri, 2 Oct 2020 14:45:02 +0100 Subject: [PATCH 09/42] Change eulacontainer to turnitinsim_eulacontainer --- amd/build/cv_launch.min.js | 2 +- amd/build/cv_launch.min.js.map | 2 +- amd/build/eula_response.min.js | 2 +- amd/build/eula_response.min.js.map | 2 +- lib.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/amd/build/cv_launch.min.js b/amd/build/cv_launch.min.js index 273a4e6..295abb2 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","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(),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)}}})})}}}); +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(),f="
",g=M.cfg.wwwroot+"/plagiarism/turnitinsim/pix/tiiIcon.svg";f+="";b.get_string("loadingcv","plagiarism_turnitinsim").done(function(b){f+="

"+b+"

";a(".turnitinsim_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 6fa0b4b..5fbc2e8 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","$","str","openCv","document","on","classList","parent","attr","split","submissionid","each","index","match","cvWindow","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,GAYxCK,CAAAA,CAAQ,CAAGC,MAAM,CAACC,IAAP,EAZ6B,CAaxCC,CAAO,CAAG,6DAb8B,CAcxCC,CAAI,CAAGC,CAAC,CAACC,GAAF,CAAMC,OAAN,CAAgB,yCAdiB,CAe5CJ,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,CAlDD,CAmDH,CArDE,CAuDV,CAxDK,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 var cvWindow = window.open();\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 $(cvWindow.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 cvWindow.location = data.viewer_url;\n this.checkDVClosed(cvWindow);\n },\n checkDVClosed: function(cvWindow) {\n var that = this;\n if (cvWindow.closed) {\n window.location = window.location;\n } else {\n setTimeout(function() {\n that.checkDVClosed(cvWindow);\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","cvWindow","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,GAYxCK,CAAAA,CAAQ,CAAGC,MAAM,CAACC,IAAP,EAZ6B,CAaxCC,CAAO,CAAG,6DAb8B,CAcxCC,CAAI,CAAGC,CAAC,CAACC,GAAF,CAAMC,OAAN,CAAgB,yCAdiB,CAe5CJ,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,CAlDD,CAmDH,CArDE,CAuDV,CAxDK,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 var cvWindow = window.open();\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 $('.turnitinsim_eulacontainer').hide().html(text).fadeIn();\n });\n\n loading += '
';\n $(cvWindow.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 cvWindow.location = data.viewer_url;\n this.checkDVClosed(cvWindow);\n },\n checkDVClosed: function(cvWindow) {\n var that = this;\n if (cvWindow.closed) {\n window.location = window.location;\n } else {\n setTimeout(function() {\n that.checkDVClosed(cvWindow);\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 da8e566..c6b4e57 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","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","")})}}}); +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(".turnitinsim_eulacontainer").hide().html(b).fadeIn()})}})});a(document).on("click","#pp-eula-decline",function(){b.get_string("euladeclined","plagiarism_turnitinsim").done(function(b){a(".turnitinsim_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 6c00fdf..df86d98 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","$","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 +{"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 $('.turnitinsim_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 $('.turnitinsim_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/lib.php b/lib.php index 9649857..0e72acf 100644 --- a/lib.php +++ b/lib.php @@ -506,7 +506,7 @@ public function print_disclosure($cmid) { $output = html_writer::tag( 'div', $eulalink.$eulaacceptbtn.$euladeclinebtn, - array('class' => 'eulacontainer', 'id' => 'eulacontainer') + array('class' => 'turnitinsim_eulacontainer', 'id' => 'turnitinsim_eulacontainer') ); return $output; From 7fb0f2949be76a4cc9170d91d29028f781b392ab Mon Sep 17 00:00:00 2001 From: Jordan Marshall Date: Fri, 2 Oct 2020 14:46:21 +0100 Subject: [PATCH 10/42] Remove styling change --- styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles.css b/styles.css index 4c48c24..fdcbca0 100644 --- a/styles.css +++ b/styles.css @@ -42,7 +42,7 @@ } .turnitinsim_eulacontainer #pp-eula-accept { - margin-right: 5px; + margin-left: 20px; } /* Icons in get_links */ From 57851bf391a86f242f2ef2b12fbd3f507b1de142 Mon Sep 17 00:00:00 2001 From: David Winn Date: Mon, 5 Oct 2020 17:40:18 +0100 Subject: [PATCH 11/42] Improve the viewer launch page --- amd/build/cv_launch.min.js | 2 -- amd/build/cv_launch.min.js.map | 1 - amd/src/cv_launch.js | 26 ++++++++------ pix/tiiLogo.svg | 18 ++++++++++ styles.css | 64 ++++++++++++++++++++++++++++++++++ 5 files changed, 98 insertions(+), 13 deletions(-) delete mode 100644 amd/build/cv_launch.min.js delete mode 100644 amd/build/cv_launch.min.js.map create mode 100644 pix/tiiLogo.svg diff --git a/amd/build/cv_launch.min.js b/amd/build/cv_launch.min.js deleted file mode 100644 index 295abb2..0000000 --- a/amd/build/cv_launch.min.js +++ /dev/null @@ -1,2 +0,0 @@ -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(),f="
",g=M.cfg.wwwroot+"/plagiarism/turnitinsim/pix/tiiIcon.svg";f+="";b.get_string("loadingcv","plagiarism_turnitinsim").done(function(b){f+="

"+b+"

";a(".turnitinsim_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 deleted file mode 100644 index 5fbc2e8..0000000 --- a/amd/build/cv_launch.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../src/cv_launch.js"],"names":["define","$","str","openCv","document","on","classList","parent","attr","split","submissionid","each","index","match","cvWindow","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,GAYxCK,CAAAA,CAAQ,CAAGC,MAAM,CAACC,IAAP,EAZ6B,CAaxCC,CAAO,CAAG,6DAb8B,CAcxCC,CAAI,CAAGC,CAAC,CAACC,GAAF,CAAMC,OAAN,CAAgB,yCAdiB,CAe5CJ,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,CAlDD,CAmDH,CArDE,CAuDV,CAxDK,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 var cvWindow = window.open();\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 $('.turnitinsim_eulacontainer').hide().html(text).fadeIn();\n });\n\n loading += '
';\n $(cvWindow.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 cvWindow.location = data.viewer_url;\n this.checkDVClosed(cvWindow);\n },\n checkDVClosed: function(cvWindow) {\n var that = this;\n if (cvWindow.closed) {\n window.location = window.location;\n } else {\n setTimeout(function() {\n that.checkDVClosed(cvWindow);\n }, 500);\n }\n }\n });\n });\n }\n };\n});"],"file":"cv_launch.min.js"} \ No newline at end of file diff --git a/amd/src/cv_launch.js b/amd/src/cv_launch.js index 281550d..bb41e73 100644 --- a/amd/src/cv_launch.js +++ b/amd/src/cv_launch.js @@ -26,7 +26,7 @@ * @module plagiarism_turnitinsim/cv_launch */ -define(['jquery', 'core/str'], function($, str) { +define(['jquery'], function($) { return { openCv: function() { $(document).on('click', '.or_score', function() { @@ -41,17 +41,23 @@ define(['jquery', 'core/str'], function($, str) { }); // Launch the Cloud Viewer in a new window. + var icon = M.cfg.wwwroot + '/plagiarism/turnitinsim/pix/tiiLogo.svg'; var cvWindow = window.open(); - var loading = '
'; - var icon = M.cfg.wwwroot + '/plagiarism/turnitinsim/pix/tiiIcon.svg'; - loading += ''; - str.get_string('loadingcv', 'plagiarism_turnitinsim').done(function(text) { - loading += '

' + text + '

'; - $('.turnitinsim_eulacontainer').hide().html(text).fadeIn(); - }); + cvWindow.document.write(''); + cvWindow.document.write(''); - loading += '
'; + var loading = '
' + + '
' + + '' + + '
' + + '
' + + '' + + '' + + '' + + '
' + + '
'; $(cvWindow.document.body).html(loading); $.ajax({ @@ -71,7 +77,7 @@ define(['jquery', 'core/str'], function($, str) { checkDVClosed: function(cvWindow) { var that = this; if (cvWindow.closed) { - window.location = window.location; + window.location = window.location + ''; } else { setTimeout(function() { that.checkDVClosed(cvWindow); diff --git a/pix/tiiLogo.svg b/pix/tiiLogo.svg new file mode 100644 index 0000000..22da669 --- /dev/null +++ b/pix/tiiLogo.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/styles.css b/styles.css index 91e5138..8f52a39 100644 --- a/styles.css +++ b/styles.css @@ -131,3 +131,67 @@ .form-group .form-inline .form-check-inline.form-check-label.fitem.turnitinsim_settings_radio { margin-right: 0; } + +.turnitinsim_loadingLogo { + width: 250px; + height: 72px; + display: inline-block; +} + +.turnitinsim_Loading { + text-align: center; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + height: 168px; + margin: auto; +} + +.turnitinsim_Loading_Circles { + margin-top: 40px; +} + +.turnitinsim_Loading_Circle-1 { + animation-delay: -0.32s; + margin-right: 7px; +} + +.turnitinsim_Loading_Circle-1, +.turnitinsim_Loading_Circle-2, +.turnitinsim_Loading_Circle-3 { + background-color: #BAD8EE; + animation-name: three-bubbles; + animation-duration: 2s; + animation-iteration-count: infinite; + border-radius: 100%; + display: inline-block; +} + +.turnitinsim_Loading_Circle-2 { + width: 24px; + height: 24px; + animation-delay: -0.16s; +} + +.turnitinsim_Loading_Circle-3 { + margin-left: 7px; +} + +.turnitinsim_Loading_Circle-1, +.turnitinsim_Loading_Circle-3 { + width: 16px; + height: 16px; + opacity: 0.5; + margin-bottom: 3px; +} + +@keyframes three-bubbles { + 0%, 80%, 100% { + transform: scale(0); + } + 40% { + transform: scale(1); + } +} From 4698c519de17f9c6ea59e7b14d2443655c27c81f Mon Sep 17 00:00:00 2001 From: David Winn Date: Wed, 7 Oct 2020 14:06:54 +0100 Subject: [PATCH 12/42] Rebase --- amd/build/cv_launch.min.js | 2 ++ amd/build/cv_launch.min.js.map | 1 + amd/build/eula_response.min.js.map | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 amd/build/cv_launch.min.js create mode 100644 amd/build/cv_launch.min.js.map diff --git a/amd/build/cv_launch.min.js b/amd/build/cv_launch.min.js new file mode 100644 index 0000000..22f3d9f --- /dev/null +++ b/amd/build/cv_launch.min.js @@ -0,0 +1,2 @@ +define ("plagiarism_turnitinsim/cv_launch",["jquery"],function(a){return{openCv:function openCv(){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=M.cfg.wwwroot+"/plagiarism/turnitinsim/pix/tiiLogo.svg",e=window.open();e.document.write("");e.document.write("");a(e.document.body).html("
");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){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 new file mode 100644 index 0000000..dac57eb --- /dev/null +++ b/amd/build/cv_launch.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/cv_launch.js"],"names":["define","$","openCv","document","on","classList","parent","attr","split","submissionid","each","index","match","icon","M","cfg","wwwroot","cvWindow","window","open","write","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,MAAM,CAAE,iBAAW,CACfD,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,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,GAYxCK,CAAAA,CAAI,CAAGC,CAAC,CAACC,GAAF,CAAMC,OAAN,CAAgB,yCAZiB,CAaxCC,CAAQ,CAAGC,MAAM,CAACC,IAAP,EAb6B,CAe5CF,CAAQ,CAACd,QAAT,CAAkBiB,KAAlB,CAAwB,iEACKN,CAAC,CAACC,GAAF,CAAMC,OADX,qDAAxB,EAEAC,CAAQ,CAACd,QAAT,CAAkBiB,KAAlB,CAAwB,gBAAxB,EAYAnB,CAAC,CAACgB,CAAQ,CAACd,QAAT,CAAkBkB,IAAnB,CAAD,CAA0BC,IAA1B,CAVc,sFAEaT,CAFb,6MAUd,EAEAZ,CAAC,CAACsB,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,CAEFnB,YAAY,CAAEA,CAFZ,CAGFoB,OAAO,CAAEf,CAAC,CAACC,GAAF,CAAMc,OAHb,CAJH,CASHC,OAAO,CAAE,iBAASH,CAAT,CAAe,CAEpBV,CAAQ,CAACc,QAAT,CAAoBJ,CAAI,CAACK,UAAzB,CACA,KAAKC,aAAL,CAAmBhB,CAAnB,CACH,CAbE,CAcHgB,aAAa,CAAE,uBAAShB,CAAT,CAAmB,CAC9B,GAAIiB,CAAAA,CAAI,CAAG,IAAX,CACA,GAAIjB,CAAQ,CAACkB,MAAb,CAAqB,CACjBjB,MAAM,CAACa,QAAP,CAAkBb,MAAM,CAACa,QAAP,CAAkB,EACvC,CAFD,IAEO,CACHK,UAAU,CAAC,UAAW,CAClBF,CAAI,CAACD,aAAL,CAAmBhB,CAAnB,CACH,CAFS,CAEP,GAFO,CAGb,CACJ,CAvBE,CAAP,CAyBH,CAxDD,CAyDH,CA3DE,CA6DV,CA9DK,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 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 var icon = M.cfg.wwwroot + '/plagiarism/turnitinsim/pix/tiiLogo.svg';\n var cvWindow = window.open();\n\n cvWindow.document.write('');\n cvWindow.document.write('');\n\n var loading = '
' +\n '
' +\n '' +\n '
' +\n '
' +\n '' +\n '' +\n '' +\n '
' +\n '
';\n $(cvWindow.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 cvWindow.location = data.viewer_url;\n this.checkDVClosed(cvWindow);\n },\n checkDVClosed: function(cvWindow) {\n var that = this;\n if (cvWindow.closed) {\n window.location = window.location + '';\n } else {\n setTimeout(function() {\n that.checkDVClosed(cvWindow);\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.map b/amd/build/eula_response.min.js.map index df86d98..56c4b27 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","$","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 $('.turnitinsim_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 $('.turnitinsim_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 +{"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,4BAAD,CAAD,CAAgCqB,IAAhC,GAAuCC,IAAvC,CAA4CF,CAA5C,EAAkDG,MAAlD,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,4BAAD,CAAD,CAAgCqB,IAAhC,GAAuCC,IAAvC,CAA4CF,CAA5C,EAAkDG,MAAlD,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 $('.turnitinsim_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 $('.turnitinsim_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 From 5f8935380e12b6b674edb9d82db5c1c69f970279 Mon Sep 17 00:00:00 2001 From: David Winn Date: Wed, 7 Oct 2020 14:24:55 +0100 Subject: [PATCH 13/42] Removing escape characters --- amd/src/cv_launch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd/src/cv_launch.js b/amd/src/cv_launch.js index bb41e73..f4341a5 100644 --- a/amd/src/cv_launch.js +++ b/amd/src/cv_launch.js @@ -49,7 +49,7 @@ define(['jquery'], function($) { cvWindow.document.write(''); var loading = '
' + - '
' + + '' + '
' + From 42405fc94a84994fee5435c3de03858b23e63d9b Mon Sep 17 00:00:00 2001 From: David Winn Date: Wed, 14 Oct 2020 09:47:09 +0100 Subject: [PATCH 14/42] Correct unit test file/class names --- tests/classes/{assign_test.php => assign.class_test.php} | 2 +- tests/classes/{tscallback_test.php => callback.class_test.php} | 2 +- ...ttingsdefaultsform_test.php => defaults_form_class_test.php} | 2 +- tests/classes/{tseula_test.php => eula.class_test.php} | 2 +- tests/classes/{forum_test.php => forum.class_test.php} | 2 +- tests/classes/{tsgroup_test.php => group.class_test.php} | 2 +- ...slogging_request_test.php => logging_request_class_test.php} | 2 +- tests/classes/{quiz_test.php => quiz.class_test.php} | 2 +- tests/classes/{tsrequest_test.php => request_class_test.php} | 2 +- tests/classes/{tssettings_test.php => settings_class_test.php} | 2 +- .../classes/{tssetupform_test.php => setup_form_class_test.php} | 2 +- .../{tssubmission_test.php => submission_class_test.php} | 2 +- tests/classes/{tstask_test.php => task_class_test.php} | 2 +- tests/classes/{tsuser_test.php => user_class_test.php} | 2 +- tests/classes/{workshop_test.php => workshop_class_test.php} | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) rename tests/classes/{assign_test.php => assign.class_test.php} (99%) rename tests/classes/{tscallback_test.php => callback.class_test.php} (99%) rename tests/classes/{tssettingsdefaultsform_test.php => defaults_form_class_test.php} (97%) rename tests/classes/{tseula_test.php => eula.class_test.php} (98%) rename tests/classes/{forum_test.php => forum.class_test.php} (99%) rename tests/classes/{tsgroup_test.php => group.class_test.php} (96%) rename tests/classes/{tslogging_request_test.php => logging_request_class_test.php} (97%) rename tests/classes/{quiz_test.php => quiz.class_test.php} (99%) rename tests/classes/{tsrequest_test.php => request_class_test.php} (99%) rename tests/classes/{tssettings_test.php => settings_class_test.php} (98%) rename tests/classes/{tssetupform_test.php => setup_form_class_test.php} (99%) rename tests/classes/{tssubmission_test.php => submission_class_test.php} (99%) rename tests/classes/{tstask_test.php => task_class_test.php} (99%) rename tests/classes/{tsuser_test.php => user_class_test.php} (95%) rename tests/classes/{workshop_test.php => workshop_class_test.php} (99%) diff --git a/tests/classes/assign_test.php b/tests/classes/assign.class_test.php similarity index 99% rename from tests/classes/assign_test.php rename to tests/classes/assign.class_test.php index 1cb55c0..3e2a076 100644 --- a/tests/classes/assign_test.php +++ b/tests/classes/assign.class_test.php @@ -32,7 +32,7 @@ /** * Tests for assign module class for plagiarism_turnitinsim component. */ -class assign_test extends advanced_testcase { +class assign_class_testcase extends advanced_testcase { /** * This is text content for unit testing a text submission. diff --git a/tests/classes/tscallback_test.php b/tests/classes/callback.class_test.php similarity index 99% rename from tests/classes/tscallback_test.php rename to tests/classes/callback.class_test.php index 16a807e..19184fa 100644 --- a/tests/classes/tscallback_test.php +++ b/tests/classes/callback.class_test.php @@ -34,7 +34,7 @@ /** * Tests for Turnitin Integrity submission class. */ -class plagiarism_tscallback_class_testcase extends advanced_testcase { +class callback_class_testcase extends advanced_testcase { /** * Set config for use in the tests. diff --git a/tests/classes/tssettingsdefaultsform_test.php b/tests/classes/defaults_form_class_test.php similarity index 97% rename from tests/classes/tssettingsdefaultsform_test.php rename to tests/classes/defaults_form_class_test.php index 4e9951a..b413c3d 100644 --- a/tests/classes/tssettingsdefaultsform_test.php +++ b/tests/classes/defaults_form_class_test.php @@ -31,7 +31,7 @@ /** * Tests for default settings form. */ -class plagiarism_tsdefaultsform_testcase extends advanced_testcase { +class defaultsform_class_testcase extends advanced_testcase { /** * Set config for use in the tests. diff --git a/tests/classes/tseula_test.php b/tests/classes/eula.class_test.php similarity index 98% rename from tests/classes/tseula_test.php rename to tests/classes/eula.class_test.php index a53139a..2c6db51 100644 --- a/tests/classes/tseula_test.php +++ b/tests/classes/eula.class_test.php @@ -32,7 +32,7 @@ /** * Tests for Turnitin Integrity submission class. */ -class plagiarism_turnitinsim_eula_class_testcase extends advanced_testcase { +class eula_class_testcase extends advanced_testcase { /** * Set config for use in the tests. diff --git a/tests/classes/forum_test.php b/tests/classes/forum.class_test.php similarity index 99% rename from tests/classes/forum_test.php rename to tests/classes/forum.class_test.php index ffd3161..c9e69d5 100644 --- a/tests/classes/forum_test.php +++ b/tests/classes/forum.class_test.php @@ -32,7 +32,7 @@ /** * Tests for forum module class for plagiarism_turnitinsim component. */ -class forum_test extends advanced_testcase { +class forum_class_testcase extends advanced_testcase { /** * Sample text for testing a forum. diff --git a/tests/classes/tsgroup_test.php b/tests/classes/group.class_test.php similarity index 96% rename from tests/classes/tsgroup_test.php rename to tests/classes/group.class_test.php index 27fe237..ecac43d 100644 --- a/tests/classes/tsgroup_test.php +++ b/tests/classes/group.class_test.php @@ -31,7 +31,7 @@ /** * Tests for Turnitin Integrity group class. */ -class plagiarism_turnitinsim_group_class_testcase extends advanced_testcase { +class group_class_testcase extends advanced_testcase { /** * Test that group constructor creates a turnitinid in the correct format. diff --git a/tests/classes/tslogging_request_test.php b/tests/classes/logging_request_class_test.php similarity index 97% rename from tests/classes/tslogging_request_test.php rename to tests/classes/logging_request_class_test.php index 209e296..6f83a58 100644 --- a/tests/classes/tslogging_request_test.php +++ b/tests/classes/logging_request_class_test.php @@ -32,7 +32,7 @@ /** * Tests for Turnitin Integrity submission class. */ -class plagiarism_turnitinsim_logging_request_class_testcase extends advanced_testcase { +class logging_request_class_testcase extends advanced_testcase { /** diff --git a/tests/classes/quiz_test.php b/tests/classes/quiz.class_test.php similarity index 99% rename from tests/classes/quiz_test.php rename to tests/classes/quiz.class_test.php index 08472d7..8fb90d9 100644 --- a/tests/classes/quiz_test.php +++ b/tests/classes/quiz.class_test.php @@ -34,7 +34,7 @@ /** * Tests for quiz module class for plagiarism_turnitinsim component */ -class quiz_test extends advanced_testcase { +class quiz_class_testcase extends advanced_testcase { /** * Sample text used for unit testing a quiz. diff --git a/tests/classes/tsrequest_test.php b/tests/classes/request_class_test.php similarity index 99% rename from tests/classes/tsrequest_test.php rename to tests/classes/request_class_test.php index c890e3e..9069ac9 100644 --- a/tests/classes/tsrequest_test.php +++ b/tests/classes/request_class_test.php @@ -33,7 +33,7 @@ /** * Tests for Turnitin Integrity submission class. */ -class plagiarism_tsrequest_testcase extends advanced_testcase { +class request_class_testcase extends advanced_testcase { /** * Set config for use in the tests. diff --git a/tests/classes/tssettings_test.php b/tests/classes/settings_class_test.php similarity index 98% rename from tests/classes/tssettings_test.php rename to tests/classes/settings_class_test.php index b34bd9b..bfc1508 100644 --- a/tests/classes/tssettings_test.php +++ b/tests/classes/settings_class_test.php @@ -32,7 +32,7 @@ /** * Tests for settings form. */ -class plagiarism_tssettings_class_testcase extends advanced_testcase { +class settings_class_testcase extends advanced_testcase { /** * Set config for use in the tests. diff --git a/tests/classes/tssetupform_test.php b/tests/classes/setup_form_class_test.php similarity index 99% rename from tests/classes/tssetupform_test.php rename to tests/classes/setup_form_class_test.php index dc9b4ab..0f03cf0 100644 --- a/tests/classes/tssetupform_test.php +++ b/tests/classes/setup_form_class_test.php @@ -31,7 +31,7 @@ /** * Tests for settings form. */ -class plagiarism_tssetupform_class_testcase extends advanced_testcase { +class setupform_class_testcase extends advanced_testcase { /** * Plugin enabled. diff --git a/tests/classes/tssubmission_test.php b/tests/classes/submission_class_test.php similarity index 99% rename from tests/classes/tssubmission_test.php rename to tests/classes/submission_class_test.php index 2d37d4b..3e78cbb 100644 --- a/tests/classes/tssubmission_test.php +++ b/tests/classes/submission_class_test.php @@ -32,7 +32,7 @@ /** * Tests for Turnitin Integrity submission class. */ -class plagiarism_turnitinsim_submission_class_testcase extends advanced_testcase { +class submission_class_testcase extends advanced_testcase { /** * A valid submission ID. diff --git a/tests/classes/tstask_test.php b/tests/classes/task_class_test.php similarity index 99% rename from tests/classes/tstask_test.php rename to tests/classes/task_class_test.php index c57e2f3..f69ab3e 100644 --- a/tests/classes/tstask_test.php +++ b/tests/classes/task_class_test.php @@ -31,7 +31,7 @@ /** * Tests for Turnitin Integrity user class. */ -class plagiarism_turnitinsim_task_class_testcase extends advanced_testcase { +class task_class_testcase extends advanced_testcase { /** * An example API URL used for unit testing. diff --git a/tests/classes/tsuser_test.php b/tests/classes/user_class_test.php similarity index 95% rename from tests/classes/tsuser_test.php rename to tests/classes/user_class_test.php index 909aae0..fc380f1 100644 --- a/tests/classes/tsuser_test.php +++ b/tests/classes/user_class_test.php @@ -31,7 +31,7 @@ /** * Tests for Turnitin Integrity user class. */ -class plagiarism_turnitinsim_user_class_testcase extends advanced_testcase { +class user_class_testcase extends advanced_testcase { /** * Test that user constructor creates a turnitinid in the correct format. diff --git a/tests/classes/workshop_test.php b/tests/classes/workshop_class_test.php similarity index 99% rename from tests/classes/workshop_test.php rename to tests/classes/workshop_class_test.php index 0fdf992..ffdb213 100644 --- a/tests/classes/workshop_test.php +++ b/tests/classes/workshop_class_test.php @@ -34,7 +34,7 @@ /** * Tests for workshop module class for plagiarism_turnitinsim component */ -class workshop_test extends advanced_testcase { +class workshop_class_testcase extends advanced_testcase { /** * Sample text used for unit testing a workshop. From be9c2088242f7e8023c8652a51c6d0e6c6602432 Mon Sep 17 00:00:00 2001 From: David Winn Date: Sat, 17 Oct 2020 15:39:00 +0100 Subject: [PATCH 15/42] Updates to the readme file --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 02cbbdb..3a82ffe 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Turnitin Integrity Plugin for Moodle Description: - -Utilize **Turnitin Integrity’s** Similarity Report and Authorship investigating tools within Moodle’s assignment workflow by integrating with the Turnitin Integrity plugin. **Turnitin Integrity** is a commercial plagiarism and authorship detection system whose features depend on which paid license has been selected. This plugin is developed and maintained by Turnitin. +Utilize **Turnitin Integrity’s** Similarity Report and Authorship investigating tools within Moodle's assignment workflow by integrating with the Turnitin Integrity plugin. **Turnitin Integrity** is a commercial plagiarism and authorship detection system whose features depend on which paid license has been selected. This plugin is developed and maintained by Turnitin. Features: - @@ -19,8 +19,9 @@ Useful Links Installation - +Before installing this plugin firstly make sure you are logged in as an Administrator and that you are using Moodle 3.5 or higher. -To install, all you need to do is copy all the files into the plagiarism/turnitinsim directory on your moodle installation. You should then go to `"Site Administration" > "Notifications"` and follow the on screen instructions. +To install, all you need to do is copy all the files into the plagiarism/turnitinsim directory on your Moodle installation. You should then go to `"Site Administration" > "Notifications"` and follow the on screen instructions. Plagiarism plugins also need to be enabled before this plugin can be used. This should happen as part of the install process but if it doesn't then you can do this by going to `"Site Administration" > "Advanced Features"` and ticking the `"Enable plagiarism plugins"` checkbox before saving. @@ -28,6 +29,8 @@ Configuring - To configure the plugin go to `"Site administration" > "Plugins" > "Plagiarism" > "Turnitin Integrity plagiarism plugin"` and enter your API key and API URL. +Other options can also be set, such as which Moodle modules to enable the plugin for or logging. Logging can be useful in scenarios where there is a problem with your installation. Default settings for the plugin can also be enabled so that you don't have to configure every individual assignment each time. + Testing - This plugin contains a full suite of PHPUnit tests which can be run against your Moodle installation. From 809223b6d0e07f6b23a357d7c8a8e64f7dd56128 Mon Sep 17 00:00:00 2001 From: Jordan Marshall Date: Mon, 26 Oct 2020 11:15:29 +0000 Subject: [PATCH 16/42] Change CV references --- lang/en/plagiarism_turnitinsim.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lang/en/plagiarism_turnitinsim.php b/lang/en/plagiarism_turnitinsim.php index f03714e..6fa5553 100644 --- a/lang/en/plagiarism_turnitinsim.php +++ b/lang/en/plagiarism_turnitinsim.php @@ -53,7 +53,7 @@ $string['indexoptions_help'] = 'Indexed submissions will be available for comparison in Similarity Reports.'; $string['invalidtablename'] = 'Table {$a} could not be exported'; $string['line'] = 'Line'; -$string['loadingcv'] = 'Loading Turnitin Cloud Viewer'; +$string['loadingcv'] = 'Loading Turnitin Viewer'; $string['message'] = 'Message'; $string['messageprovider:digital_receipt_student'] = 'Turnitin Student Digital Receipt'; $string['messageprovider:digital_receipt_instructor'] = 'Turnitin Instructor Digital Receipt'; @@ -119,7 +119,7 @@ $string['taskoutputlatesteulanotretrieved'] = 'Latest EULA version could not be retrieved'; $string['taskoutputlatesteularetrievalfailure'] = 'Latest EULA version call failed.'; $string['taskoutputfailedconnection'] = 'There was a problem connecting to the Turnitin API'; -$string['taskoutputfailedcvlaunchurl'] = 'There was a problem requesting a Cloud Viewer launch URL from the Turnitin API for submission id: {$a}'; +$string['taskoutputfailedcvlaunchurl'] = 'There was a problem requesting a Turnitin Viewer URL from the Turnitin API for submission id: {$a}'; $string['taskoutputfailedreportrequest'] = 'There was a problem requesting an originality report generation from the Turnitin API for submission id: {$a}'; $string['taskoutputfailedscorerequest'] = 'There was a problem requesting an originality report score from the Turnitin API for submission id: {$a}'; $string['taskoutputfailedupload'] = 'There was a problem uploading a file to the Turnitin API for submission id: {$a}'; @@ -153,7 +153,7 @@ $string['turnitinfeatures::header'] = 'Turnitin Integrity features'; $string['turnitinfeatures::moreinfo'] = 'For more information on the enabled features and packages available from Turnitin please see http://www.turnitin.com.'; $string['turnitinfeatures::repositories'] = 'Repositories checked against: '; -$string['turnitinfeatures::viewoptions'] = 'Cloud Viewer options: '; +$string['turnitinfeatures::viewoptions'] = 'Turnitin Viewer options: '; $string['turnitinfeatures::eularequired'] = 'Acceptance of the Turnitin EULA is required for all users'; $string['turnitinfeatures::eulanotrequired'] = 'Acceptance of the Turnitin EULA is not required by users'; $string['turnitinhideidentity'] = 'Hide student\'s identity from Turnitin'; @@ -189,8 +189,8 @@ $string['privacy:metadata:plagiarism_turnitinsim_users:lasteulaacceptedlang'] = 'The langauge in which the user last accepted the Turnitin EULA.'; $string['privacy:metadata:plagiarism_turnitinsim_client'] = 'To successfully make a submission to Turnitin, specific user data needs to be exchanged between Moodle and Turnitin. For more information around Moodle Plugins and GDPR, please visit: https://help.turnitin.com/feedback-studio/moodle/moodle-plugins-and-gdpr.htm'; -$string['privacy:metadata:plagiarism_turnitinsim_client:firstname'] = 'The user\'s first name is sent to Turnitin on a Cloud Viewer launch so that the user can be identified.'; -$string['privacy:metadata:plagiarism_turnitinsim_client:lastname'] = 'The user\'s last name is sent to Turnitin on a Cloud Viewer launch so that the user can be identified.'; +$string['privacy:metadata:plagiarism_turnitinsim_client:firstname'] = 'The user\'s first name is sent to Turnitin on a Turnitin Viewer launch so that the user can be identified.'; +$string['privacy:metadata:plagiarism_turnitinsim_client:lastname'] = 'The user\'s last name is sent to Turnitin on a Turnitin Viewer launch so that the user can be identified.'; $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.'; From 4eaa19cd4848f32c4324142eebefaa0e7984e096 Mon Sep 17 00:00:00 2001 From: Jordan Marshall Date: Mon, 26 Oct 2020 12:25:08 +0000 Subject: [PATCH 17/42] Remove references to "loadingcv" string --- lang/en/plagiarism_turnitinsim.php | 1 - lib.php | 1 - 2 files changed, 2 deletions(-) diff --git a/lang/en/plagiarism_turnitinsim.php b/lang/en/plagiarism_turnitinsim.php index 6fa5553..0254b5c 100644 --- a/lang/en/plagiarism_turnitinsim.php +++ b/lang/en/plagiarism_turnitinsim.php @@ -53,7 +53,6 @@ $string['indexoptions_help'] = 'Indexed submissions will be available for comparison in Similarity Reports.'; $string['invalidtablename'] = 'Table {$a} could not be exported'; $string['line'] = 'Line'; -$string['loadingcv'] = 'Loading Turnitin Viewer'; $string['message'] = 'Message'; $string['messageprovider:digital_receipt_student'] = 'Turnitin Student Digital Receipt'; $string['messageprovider:digital_receipt_instructor'] = 'Turnitin Instructor Digital Receipt'; diff --git a/lib.php b/lib.php index d2398b8..e695bea 100644 --- a/lib.php +++ b/lib.php @@ -167,7 +167,6 @@ public function get_links($linkarray) { static $jsloaded; if (empty($jsloaded)) { $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', 'openCv'); $PAGE->requires->js_call_amd('plagiarism_turnitinsim/resend_submission', 'resendSubmission'); From 01d05cb6bd042e8f1d659cc0714aafee11a59e87 Mon Sep 17 00:00:00 2001 From: David Winn Date: Mon, 2 Nov 2020 10:56:33 +0000 Subject: [PATCH 18/42] Update help links for JS, KO, ZH_CN, ZN_TW --- lang/ja/plagiarism_turnitinsim.php | 28 +++++++++++++++++++++++++++ lang/ko/plagiarism_turnitinsim.php | 28 +++++++++++++++++++++++++++ lang/zh_cn/plagiarism_turnitinsim.php | 28 +++++++++++++++++++++++++++ lang/zh_tw/plagiarism_turnitinsim.php | 28 +++++++++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 lang/ja/plagiarism_turnitinsim.php create mode 100644 lang/ko/plagiarism_turnitinsim.php create mode 100644 lang/zh_cn/plagiarism_turnitinsim.php create mode 100644 lang/zh_tw/plagiarism_turnitinsim.php diff --git a/lang/ja/plagiarism_turnitinsim.php b/lang/ja/plagiarism_turnitinsim.php new file mode 100644 index 0000000..f8af95d --- /dev/null +++ b/lang/ja/plagiarism_turnitinsim.php @@ -0,0 +1,28 @@ +. + +/** + * Strings for plagiarism_turnitinsim component, language: Japanese. + * + * This file should only contain *_link strings as other strings are handling through AMOS. + * + * @package plagiarism_turnitinsim + * @copyright 2020 Turnitin + * @author David Winn + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['help_link'] = 'https://help.turnitin.com/jp/integrity/管理者/moodle.htm#step-four'; diff --git a/lang/ko/plagiarism_turnitinsim.php b/lang/ko/plagiarism_turnitinsim.php new file mode 100644 index 0000000..b40fd14 --- /dev/null +++ b/lang/ko/plagiarism_turnitinsim.php @@ -0,0 +1,28 @@ +. + +/** + * Strings for plagiarism_turnitinsim component, language: Korean. + * + * This file should only contain *_link strings as other strings are handling through AMOS. + * + * @package plagiarism_turnitinsim + * @copyright 2020 Turnitin + * @author David Winn + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['help_link'] = 'https://help.turnitin.com/ko/integrity/관리자/moodle.htm#step-four'; diff --git a/lang/zh_cn/plagiarism_turnitinsim.php b/lang/zh_cn/plagiarism_turnitinsim.php new file mode 100644 index 0000000..e605ddd --- /dev/null +++ b/lang/zh_cn/plagiarism_turnitinsim.php @@ -0,0 +1,28 @@ +. + +/** + * Strings for plagiarism_turnitinsim component, language: Simplified Chinese. + * + * This file should only contain *_link strings as other strings are handling through AMOS. + * + * @package plagiarism_turnitinsim + * @copyright 2020 Turnitin + * @author David Winn + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['help_link'] = 'https://help.turnitin.com/zh-hans/integrity/管理员身/moodle.htm#step-four'; diff --git a/lang/zh_tw/plagiarism_turnitinsim.php b/lang/zh_tw/plagiarism_turnitinsim.php new file mode 100644 index 0000000..4fa6c5f --- /dev/null +++ b/lang/zh_tw/plagiarism_turnitinsim.php @@ -0,0 +1,28 @@ +. + +/** + * Strings for plagiarism_turnitinsim component, language: Traditional Chinese. + * + * This file should only contain *_link strings as other strings are handling through AMOS. + * + * @package plagiarism_turnitinsim + * @copyright 2020 Turnitin + * @author David Winn + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['help_link'] = 'https://help.turnitin.com/zh-tw/integrity/管理員/moodle.htm#step-four'; From f7857678fa8cf83267a2ab6d0f483b7109e10cb8 Mon Sep 17 00:00:00 2001 From: David Winn Date: Thu, 12 Nov 2020 11:55:06 +0000 Subject: [PATCH 19/42] Fix handle_exception method to use third parameter --- classes/request.class.php | 6 ++++-- classes/settings.class.php | 26 +++++++++++++------------- classes/submission.class.php | 1 - 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/classes/request.class.php b/classes/request.class.php index 828ceba..c9700ee 100644 --- a/classes/request.class.php +++ b/classes/request.class.php @@ -281,11 +281,13 @@ public function test_connection($apiurl, $apikey) { * * @param object $e The exception. * @param string $displaystr The string to display for the error. + * @param string|object|array $a An object, string or number that can be used + * within translation strings * @throws coding_exception */ - public function handle_exception($e, $displaystr = '') { + public function handle_exception($e, $displaystr = '', $a = null) { - $errorstr = get_string($displaystr, 'plagiarism_turnitinsim').PHP_EOL; + $errorstr = get_string($displaystr, 'plagiarism_turnitinsim', $a).PHP_EOL; if (is_callable(array($e, 'getFaultCode'))) { $errorstr .= get_string('faultcode', 'plagiarism_turnitinsim').": ".$e->getFaultCode().PHP_EOL; diff --git a/classes/settings.class.php b/classes/settings.class.php index 645f037..938999b 100644 --- a/classes/settings.class.php +++ b/classes/settings.class.php @@ -101,20 +101,20 @@ public function add_settings_to_module($mform, $canconfigureplugin = false, $con // Immediate. $label = get_string('reportgen0', 'plagiarism_turnitinsim'); $reportgen[] = $mform->createElement( - 'radio', - 'reportgeneration', - null, - $label, - TURNITINSIM_REPORT_GEN_IMMEDIATE, + 'radio', + 'reportgeneration', + null, + $label, + TURNITINSIM_REPORT_GEN_IMMEDIATE, array('class' => 'turnitinsim_settings_radio') ); // Immediate and Due Date. $label = get_string('reportgen1', 'plagiarism_turnitinsim'); $reportgen[] = $mform->createElement( - 'radio', - 'reportgeneration', - null, + 'radio', + 'reportgeneration', + null, $label, TURNITINSIM_REPORT_GEN_IMMEDIATE_AND_DUEDATE, array('class' => 'turnitinsim_settings_radio') @@ -123,11 +123,11 @@ public function add_settings_to_module($mform, $canconfigureplugin = false, $con // Due Date. $label = get_string('reportgen2', 'plagiarism_turnitinsim'); $reportgen[] = $mform->createElement( - 'radio', - 'reportgeneration', - null, - $label, - TURNITINSIM_REPORT_GEN_DUEDATE, + 'radio', + 'reportgeneration', + null, + $label, + TURNITINSIM_REPORT_GEN_DUEDATE, array('class' => 'turnitinsim_settings_radio') ); diff --git a/classes/submission.class.php b/classes/submission.class.php index ab75e97..63a229a 100644 --- a/classes/submission.class.php +++ b/classes/submission.class.php @@ -597,7 +597,6 @@ public function upload_submission_to_turnitin() { // Handle response from the API. $this->handle_upload_response($responsedata, $filename); } catch (Exception $e) { - $this->tsrequest->handle_exception($e, 'taskoutputfailedupload', $this->getturnitinid()); } } From a9406f5c3fe5e454a2ff5bd364313e2a419c391c Mon Sep 17 00:00:00 2001 From: David Winn Date: Thu, 12 Nov 2020 15:52:58 +0000 Subject: [PATCH 20/42] Handle delete module event --- classes/observer.php | 12 ++++++++++++ db/events.php | 6 +++++- version.php | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/classes/observer.php b/classes/observer.php index 37f8907..1bb4a45 100644 --- a/classes/observer.php +++ b/classes/observer.php @@ -118,4 +118,16 @@ 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')); } + + /** + * Handle the course_module_deleted event. + * @param \core\event\course_module_deleted $event + */ + public static function course_module_deleted(\core\event\course_module_deleted $event) { + global $DB; + $eventdata = $event->get_data(); + + $DB->delete_records('plagiarism_turnitinsim_sub', array('cm' => $eventdata['contextinstanceid'])); + $DB->delete_records('plagiarism_turnitinsim_mod', array('cm' => $eventdata['contextinstanceid'])); + } } \ No newline at end of file diff --git a/db/events.php b/db/events.php index 76fa369..5f2e4ec 100644 --- a/db/events.php +++ b/db/events.php @@ -53,5 +53,9 @@ array( 'eventname' => '\core\event\course_module_updated', 'callback' => 'plagiarism_turnitinsim_observer::module_updated' - ) + ), + array( + 'eventname' => '\core\event\course_module_deleted', + 'callback' => 'plagiarism_turnitinsim_observer::course_module_deleted' + ), ); \ No newline at end of file diff --git a/version.php b/version.php index 82cd46f..c41cf70 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2020092301; +$plugin->version = 2020111201; $plugin->release = "v1.2"; $plugin->requires = 2017051500; $plugin->component = 'plagiarism_turnitinsim'; From a0896c55ff3095723492783a28d47e29e73b1aa2 Mon Sep 17 00:00:00 2001 From: Jordan Marshall Date: Fri, 13 Nov 2020 14:11:26 +0000 Subject: [PATCH 21/42] Dont show link for feedback and intro files --- lib.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib.php b/lib.php index e695bea..d3d61a2 100644 --- a/lib.php +++ b/lib.php @@ -174,6 +174,16 @@ public function get_links($linkarray) { } $output = ''; + // Don't show links for certain file types as they won't have been submitted to Turnitin. + if (!empty($linkarray["file"])) { + $file = $linkarray["file"]; + $filearea = $file->get_filearea(); + $nonsubmittingareas = array("feedback_files", "introattachment"); + if (in_array($filearea, $nonsubmittingareas)) { + return $output; + } + } + // If this is a quiz, retrieve the cmid. $component = (!empty($linkarray['component'])) ? $linkarray['component'] : ""; if ($component == "qtype_essay" && !empty($linkarray['area'])) { From 7ce5862faa4c45e844112a7f2257b052e7f48e49 Mon Sep 17 00:00:00 2001 From: Jordan Marshall Date: Tue, 17 Nov 2020 10:34:52 +0000 Subject: [PATCH 22/42] Prevent submission being created for into/feedback --- lib.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib.php b/lib.php index d3d61a2..da849a0 100644 --- a/lib.php +++ b/lib.php @@ -737,6 +737,12 @@ public function queue_files($cm, $eventdata, $sendtoturnitin, $features, $quizan $submission = $DB->get_record_select('plagiarism_turnitinsim_sub', $query, $params); $filedetails = $tssubmission->get_file_details(); + $filearea = $filedetails->get_filearea(); + $nonsubmittingareas = array("feedback_files", "introattachment"); + if (in_array($filearea, $nonsubmittingareas)) { + return true; + } + // Check that the file exists and is not empty. if (!$filedetails) { $tssubmission->settogenerate(0); From a0744287505362915895a6e51ade08ec73441e08 Mon Sep 17 00:00:00 2001 From: Jordan Marshall Date: Wed, 18 Nov 2020 17:06:35 +0000 Subject: [PATCH 23/42] Fix for when filedetails is empty --- lib.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib.php b/lib.php index da849a0..8a63038 100644 --- a/lib.php +++ b/lib.php @@ -737,12 +737,15 @@ public function queue_files($cm, $eventdata, $sendtoturnitin, $features, $quizan $submission = $DB->get_record_select('plagiarism_turnitinsim_sub', $query, $params); $filedetails = $tssubmission->get_file_details(); - $filearea = $filedetails->get_filearea(); - $nonsubmittingareas = array("feedback_files", "introattachment"); - if (in_array($filearea, $nonsubmittingareas)) { - return true; + // Do not submit feedback or into files + if($filedetails) { + $filearea = $filedetails->get_filearea(); + $nonsubmittingareas = array("feedback_files", "introattachment"); + if (in_array($filearea, $nonsubmittingareas)) { + return true; + } } - + // Check that the file exists and is not empty. if (!$filedetails) { $tssubmission->settogenerate(0); From bc0382fd5cd59f9a86bdbbb91b2c8165202af491 Mon Sep 17 00:00:00 2001 From: David Winn Date: Thu, 19 Nov 2020 08:59:48 +0000 Subject: [PATCH 24/42] Adding space to comply with Moodle style guide --- lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib.php b/lib.php index 8a63038..813dfde 100644 --- a/lib.php +++ b/lib.php @@ -738,7 +738,7 @@ public function queue_files($cm, $eventdata, $sendtoturnitin, $features, $quizan $filedetails = $tssubmission->get_file_details(); // Do not submit feedback or into files - if($filedetails) { + if ($filedetails) { $filearea = $filedetails->get_filearea(); $nonsubmittingareas = array("feedback_files", "introattachment"); if (in_array($filearea, $nonsubmittingareas)) { From 6a67f5b87edef53d7185a159f4123c74fafec205 Mon Sep 17 00:00:00 2001 From: David Winn Date: Tue, 24 Nov 2020 18:05:14 +0000 Subject: [PATCH 25/42] Fix issue with null pointer exception on status --- lib.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib.php b/lib.php index e695bea..d4f0d1c 100644 --- a/lib.php +++ b/lib.php @@ -237,16 +237,17 @@ public function get_links($linkarray) { return $output; } + $plagiarismsettings = $this->get_settings($cm->id); + if ($plagiarismfile) { $submission = new plagiarism_turnitinsim_submission(new plagiarism_turnitinsim_request(), $plagiarismfile->id); - } - // If the user is a student and they are not allowed to view reports, - // and they have accepted the EULA then return empty output. - $plagiarismsettings = $this->get_settings($cm->id); - if (!$instructor && empty($plagiarismsettings->accessstudents) && - $submission->getstatus() !== TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED) { - return $output; + // If the user is a student and they are not allowed to view reports, + // and they have accepted the EULA then return empty output. + if (!$instructor && empty($plagiarismsettings->accessstudents) && + $submission->getstatus() !== TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED) { + return $output; + } } // Render the OR score or current submission status. @@ -360,8 +361,10 @@ public function get_links($linkarray) { $resubmitlink = ($instructor && $showresubmitlink) ? $this->render_resubmit_link($submission->getid()) : ''; // Output rendered status and resubmission link if applicable. - $output .= html_writer::tag('div', $turnitinicon.$status.$resubmitlink, - array('class' => 'turnitinsim_status submission_'.$submissionid)); + if ($instructor || (!$instructor && $plagiarismsettings->accessstudents)) { + $output .= html_writer::tag('div', $turnitinicon . $status . $resubmitlink, + array('class' => 'turnitinsim_status submission_' . $submissionid)); + } } return html_writer::tag('div', $output, array('class' => 'turnitinsim_links')); From e120a038f549db2d166e717129827af5835b8148 Mon Sep 17 00:00:00 2001 From: JMarshall841 <70380488+JMarshall841@users.noreply.github.com> Date: Wed, 2 Dec 2020 15:15:07 +0000 Subject: [PATCH 26/42] INT-15084: Use new download_data (#88) * If branch > 38 use new dataformat download * Use handle_deprecation class --- dbexport.php | 4 +++- utilities/handle_deprecation.php | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/dbexport.php b/dbexport.php index ae6ef14..b8c438e 100644 --- a/dbexport.php +++ b/dbexport.php @@ -27,6 +27,7 @@ require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/dataformatlib.php'); +require_once( __DIR__ . '/utilities/handle_deprecation.php' ); // Restrict access to admins only. require_login(); @@ -67,7 +68,8 @@ $data = $DB->get_records($table, null, 'id ASC'); // Use Moodle's dataformatting functions to output the data in the desired format. - download_as_dataformat($exportfile, $dataformat, array_keys($DB->get_columns($table)), $data); + handle_deprecation::download_data($exportfile, $dataformat, array_keys($DB->get_columns($table)), $data); + exit; } else { diff --git a/utilities/handle_deprecation.php b/utilities/handle_deprecation.php index 93e21aa..d3264ba 100644 --- a/utilities/handle_deprecation.php +++ b/utilities/handle_deprecation.php @@ -97,4 +97,20 @@ public static function get_plugin_enabled() { return $CFG->branch < 39 ? get_config('plagiarism', 'turnitinsim_use') : get_config('plagiarism_turnitinsim', 'enabled'); } + + /** + * In Moodle 3.9, download_as_dataformat() was deprecated and \core\dataformat::download_data() was introduced. + * This method handles our support for multiple Moodle versions. + * + * @param string $filename The name of the dile to download. + * @param string $dataformat The format of the file. + * @param array $columns The names of the columns. + * @param string $data The data to download. + */ + public static function download_data($exportfile, $dataformat, $columns, $data) { + global $CFG; + + $CFG->branch >= 39 ? \core\dataformat::download_data($exportfile, $dataformat, $columns, $data) + : download_as_dataformat($exportfile, $dataformat, $columns, $data); + } } \ No newline at end of file From a4eab62cce97691680b631e2ce359aba68509613 Mon Sep 17 00:00:00 2001 From: David Winn Date: Thu, 10 Dec 2020 11:41:48 +0000 Subject: [PATCH 27/42] Updating the unit tests to work in Moodle 3.10. --- tests/classes/assign.class_test.php | 2 +- tests/classes/callback.class_test.php | 2 +- tests/classes/defaults_form_class_test.php | 5 +- tests/classes/eula.class_test.php | 2 +- tests/classes/forum.class_test.php | 2 +- tests/classes/logging_request_class_test.php | 2 +- tests/classes/quiz.class_test.php | 2 +- tests/classes/request_class_test.php | 2 +- tests/classes/settings_class_test.php | 2 +- tests/classes/setup_form_class_test.php | 7 +-- tests/classes/submission_class_test.php | 23 ++++----- tests/classes/task_class_test.php | 2 +- tests/classes/workshop_class_test.php | 2 +- tests/lib_test.php | 39 +++++++-------- tests/privacy/provider_test.php | 2 +- utilities/handle_deprecation.php | 50 +++++++++++++++++++- 16 files changed, 98 insertions(+), 48 deletions(-) diff --git a/tests/classes/assign.class_test.php b/tests/classes/assign.class_test.php index 3e2a076..4011595 100644 --- a/tests/classes/assign.class_test.php +++ b/tests/classes/assign.class_test.php @@ -42,7 +42,7 @@ class assign_class_testcase extends advanced_testcase { /** * Set config for use in the tests. */ - public function setup() { + public function setUp(): void { global $DB; // Set plugin as enabled in config for this module type. diff --git a/tests/classes/callback.class_test.php b/tests/classes/callback.class_test.php index 19184fa..c1af782 100644 --- a/tests/classes/callback.class_test.php +++ b/tests/classes/callback.class_test.php @@ -39,7 +39,7 @@ class callback_class_testcase extends advanced_testcase { /** * Set config for use in the tests. */ - public function setup() { + public function setUp(): void { global $CFG; // Set plugin as enabled in config for this module type. diff --git a/tests/classes/defaults_form_class_test.php b/tests/classes/defaults_form_class_test.php index b413c3d..782cb2e 100644 --- a/tests/classes/defaults_form_class_test.php +++ b/tests/classes/defaults_form_class_test.php @@ -27,6 +27,7 @@ global $CFG; require_once($CFG->dirroot . '/plagiarism/turnitinsim/classes/defaults_form.class.php'); +require_once($CFG->dirroot . '/plagiarism/turnitinsim/utilities/handle_deprecation.php'); /** * Tests for default settings form. @@ -36,7 +37,7 @@ class defaultsform_class_testcase extends advanced_testcase { /** * Set config for use in the tests. */ - public function setup() { + public function setUp(): void { // Set API details in config. set_config('turnitinapiurl', 'http://www.example.com', 'plagiarism_turnitinsim'); set_config('turnitinapikey', 1234, 'plagiarism_turnitinsim'); @@ -87,6 +88,6 @@ public function test_display() { $form = new plagiarism_turnitinsim_defaults_form(); $output = $form->display(); - $this->assertContains('', $output); + handle_deprecation::assertContains($this, '', $output); } } \ No newline at end of file diff --git a/tests/classes/eula.class_test.php b/tests/classes/eula.class_test.php index 2c6db51..631c7a0 100644 --- a/tests/classes/eula.class_test.php +++ b/tests/classes/eula.class_test.php @@ -37,7 +37,7 @@ class eula_class_testcase extends advanced_testcase { /** * Set config for use in the tests. */ - public function setup() { + public function setUp(): void { global $CFG; // Set plugin as enabled in config for this module type. diff --git a/tests/classes/forum.class_test.php b/tests/classes/forum.class_test.php index c9e69d5..ad2d5ca 100644 --- a/tests/classes/forum.class_test.php +++ b/tests/classes/forum.class_test.php @@ -42,7 +42,7 @@ class forum_class_testcase extends advanced_testcase { /** * Set config for use in the tests. */ - public function setup() { + public function setUp(): void { global $DB; // Set plugin as enabled in config for this module type. diff --git a/tests/classes/logging_request_class_test.php b/tests/classes/logging_request_class_test.php index 6f83a58..3363735 100644 --- a/tests/classes/logging_request_class_test.php +++ b/tests/classes/logging_request_class_test.php @@ -38,7 +38,7 @@ class logging_request_class_testcase extends advanced_testcase { /** * Set config for use in the tests. */ - public function setup() { + public function setUp(): void { // Set plugin as enabled in config for this module type. set_config('turnitinenableremotelogging', 1, 'plagiarism_turnitinsim'); set_config('turnitinenablelogging', 0, 'plagiarism_turnitinsim'); diff --git a/tests/classes/quiz.class_test.php b/tests/classes/quiz.class_test.php index 8fb90d9..b40ac20 100644 --- a/tests/classes/quiz.class_test.php +++ b/tests/classes/quiz.class_test.php @@ -49,7 +49,7 @@ class quiz_class_testcase extends advanced_testcase { /** * Set config for use in the tests. */ - public function setup() { + public function setUp(): void { // Set plugin as enabled in config for this module type. set_config('turnitinapiurl', 'http://www.example.com', 'plagiarism_turnitinsim'); set_config('turnitinapikey', 1234, 'plagiarism_turnitinsim'); diff --git a/tests/classes/request_class_test.php b/tests/classes/request_class_test.php index 9069ac9..549ff5b 100644 --- a/tests/classes/request_class_test.php +++ b/tests/classes/request_class_test.php @@ -38,7 +38,7 @@ class request_class_testcase extends advanced_testcase { /** * Set config for use in the tests. */ - public function setup() { + public function setUp(): void { // Set plugin as enabled in config for this module type. set_config('turnitinapiurl', 'http://www.example.com', 'plagiarism_turnitinsim'); set_config('turnitinapikey', 1234, 'plagiarism_turnitinsim'); diff --git a/tests/classes/settings_class_test.php b/tests/classes/settings_class_test.php index bfc1508..a841088 100644 --- a/tests/classes/settings_class_test.php +++ b/tests/classes/settings_class_test.php @@ -37,7 +37,7 @@ class settings_class_testcase extends advanced_testcase { /** * Set config for use in the tests. */ - public function setup() { + public function setUp(): void { global $CFG; // Set API details in config. diff --git a/tests/classes/setup_form_class_test.php b/tests/classes/setup_form_class_test.php index 0f03cf0..b709a5b 100644 --- a/tests/classes/setup_form_class_test.php +++ b/tests/classes/setup_form_class_test.php @@ -27,6 +27,7 @@ global $CFG; require_once($CFG->dirroot . '/plagiarism/turnitinsim/classes/setup_form.class.php'); +require_once($CFG->dirroot . '/plagiarism/turnitinsim/utilities/handle_deprecation.php'); /** * Tests for settings form. @@ -132,10 +133,10 @@ public function test_display() { $form = new plagiarism_turnitinsim_setup_form(); $output = $form->display(); - $this->assertContains('', $output); + handle_deprecation::assertContains($this, '', $output); // Verify that FERPA statement is present. - $this->assertContains(get_string('viewerpermissionferpa', 'plagiarism_turnitinsim'), $output); + handle_deprecation::assertContains($this, get_string('viewerpermissionferpa', 'plagiarism_turnitinsim'), $output); } /** @@ -170,6 +171,6 @@ public function test_display_features_features_stored() { $form = new plagiarism_turnitinsim_setup_form(); $output = $form->display_features(); - $this->assertContains(get_string('turnitinfeatures::moreinfo', 'plagiarism_turnitinsim'), $output); + handle_deprecation::assertContains($this, get_string('turnitinfeatures::moreinfo', 'plagiarism_turnitinsim'), $output); } } \ No newline at end of file diff --git a/tests/classes/submission_class_test.php b/tests/classes/submission_class_test.php index 3e78cbb..984856d 100644 --- a/tests/classes/submission_class_test.php +++ b/tests/classes/submission_class_test.php @@ -28,6 +28,7 @@ global $CFG; require_once($CFG->dirroot . '/plagiarism/turnitinsim/lib.php'); require_once($CFG->dirroot . '/plagiarism/turnitinsim/tests/utilities.php'); +require_once($CFG->dirroot . '/plagiarism/turnitinsim/utilities/handle_deprecation.php'); /** * Tests for Turnitin Integrity submission class. @@ -57,7 +58,7 @@ class submission_class_testcase extends advanced_testcase { /** * Set config for use in the tests. */ - public function setup() { + public function setUp(): void { global $CFG, $DB; // Set plugin as enabled in config for this module type. @@ -137,7 +138,7 @@ public function test_update() { $tssubmission->update(); // Submission id should now be set. - $this->assertInternalType("int", $tssubmission->getid()); + handle_deprecation::assertInternalTypeInt($this, $tssubmission->getid()); // Check an id that doesn't exist doesn't return an object. $submission = $DB->get_record('plagiarism_turnitinsim_sub', array('id' => 0)); @@ -252,15 +253,15 @@ public function test_create_owners_metadata_returns_all_group_member_details_as_ $tsuser2 = new plagiarism_turnitinsim_user($this->student2->id); // Check user array returns correct details. - $this->assertContains($this->student1->lastname, $owners[0]['family_name']); - $this->assertContains($this->student1->firstname, $owners[0]['given_name']); - $this->assertContains($this->student1->email, $owners[0]['email']); - $this->assertContains($tsuser1->get_turnitinid(), $owners[0]['id']); - - $this->assertContains($this->student2->lastname, $owners[1]['family_name']); - $this->assertContains($this->student2->firstname, $owners[1]['given_name']); - $this->assertContains($this->student2->email, $owners[1]['email']); - $this->assertContains($tsuser2->get_turnitinid(), $owners[1]['id']); + handle_deprecation::assertContains($this, $this->student1->lastname, $owners[0]['family_name']); + handle_deprecation::assertContains($this, $this->student1->firstname, $owners[0]['given_name']); + handle_deprecation::assertContains($this, $this->student1->email, $owners[0]['email']); + handle_deprecation::assertContains($this, $tsuser1->get_turnitinid(), $owners[0]['id']); + + handle_deprecation::assertContains($this, $this->student2->lastname, $owners[1]['family_name']); + handle_deprecation::assertContains($this, $this->student2->firstname, $owners[1]['given_name']); + handle_deprecation::assertContains($this, $this->student2->email, $owners[1]['email']); + handle_deprecation::assertContains($this, $tsuser2->get_turnitinid(), $owners[1]['id']); } /** diff --git a/tests/classes/task_class_test.php b/tests/classes/task_class_test.php index f69ab3e..6d45466 100644 --- a/tests/classes/task_class_test.php +++ b/tests/classes/task_class_test.php @@ -46,7 +46,7 @@ class task_class_testcase extends advanced_testcase { /** * Set config for use in the tests. */ - public function setup() { + public function setUp(): void { global $CFG; // Set plugin as enabled in config for this module type. diff --git a/tests/classes/workshop_class_test.php b/tests/classes/workshop_class_test.php index ffdb213..e2dc7ae 100644 --- a/tests/classes/workshop_class_test.php +++ b/tests/classes/workshop_class_test.php @@ -44,7 +44,7 @@ class workshop_class_testcase extends advanced_testcase { /** * Set config for use in the tests. */ - public function setup() { + public function setUp(): void { // Set plugin as enabled in config for this module type. set_config('turnitinapiurl', 'http://www.example.com', 'plagiarism_turnitinsim'); set_config('turnitinapikey', 1234, 'plagiarism_turnitinsim'); diff --git a/tests/lib_test.php b/tests/lib_test.php index e309bdc..21289b6 100644 --- a/tests/lib_test.php +++ b/tests/lib_test.php @@ -28,6 +28,7 @@ global $CFG; require_once($CFG->dirroot . '/plagiarism/turnitinsim/lib.php'); require_once($CFG->dirroot . '/plagiarism/turnitinsim/classes/setup_form.class.php'); +require_once($CFG->dirroot . '/plagiarism/turnitinsim/utilities/handle_deprecation.php'); /** * Tests for lib methods. @@ -68,7 +69,7 @@ public function get_module_that_supports_plagiarism() { /** * Set config for use in the tests. */ - public function setup() { + public function setUp(): void { global $DB; // Set plugin as enabled in config for this module type. @@ -276,16 +277,16 @@ public function test_get_links_with_submission() { // The HTML returned should contain the queued status and a Tii icon. $plagiarismturnitinsim = new plagiarism_plugin_turnitinsim(); - $this->assertContains( + handle_deprecation::assertContains($this, ''.get_string( 'submissiondisplaystatus:queued', 'plagiarism_turnitinsim').'', $plagiarismturnitinsim->get_links($linkarray) ); - $this->assertContains('tii_icon', $plagiarismturnitinsim->get_links($linkarray)); + handle_deprecation::assertContains($this, 'tii_icon', $plagiarismturnitinsim->get_links($linkarray)); // Change submission status to Uploaded and verify that pending is displayed. $tssubmission->setstatus(TURNITINSIM_SUBMISSION_STATUS_UPLOADED); $tssubmission->update(); - $this->assertContains( + handle_deprecation::assertContains($this, ''.get_string( 'submissiondisplaystatus:pending', 'plagiarism_turnitinsim').'', $plagiarismturnitinsim->get_links($linkarray) ); @@ -293,7 +294,7 @@ public function test_get_links_with_submission() { // Change submission status to Uploaded and verify that not sent is displayed. $tssubmission->setstatus(TURNITINSIM_SUBMISSION_STATUS_NOT_SENT); $tssubmission->update(); - $this->assertContains( + handle_deprecation::assertContains($this, ''.get_string( 'submissiondisplaystatus:notsent', 'plagiarism_turnitinsim').'', $plagiarismturnitinsim->get_links($linkarray) ); @@ -301,7 +302,7 @@ public function test_get_links_with_submission() { // Change submission status to Requested and verify that pending is displayed. $tssubmission->setstatus(TURNITINSIM_SUBMISSION_STATUS_REQUESTED); $tssubmission->update(); - $this->assertContains( + handle_deprecation::assertContains($this, ''.get_string( 'submissiondisplaystatus:pending', 'plagiarism_turnitinsim').'', $plagiarismturnitinsim->get_links($linkarray) ); @@ -311,17 +312,17 @@ public function test_get_links_with_submission() { $tssubmission->update(); $output = $plagiarismturnitinsim->get_links($linkarray); - $this->assertContains( + handle_deprecation::assertContains($this, get_string('submissiondisplaystatus:awaitingeula', 'plagiarism_turnitinsim'), $output ); - $this->assertContains( + handle_deprecation::assertContains($this, get_string('submissiondisplayerror:eulanotaccepted_help', 'plagiarism_turnitinsim'), $output ); // Log instructor in and check they do not see a resubmit link. $this->setUser($this->instructor); - $this->assertNotContains( + handle_deprecation::assertNotContains($this, get_string('resubmittoturnitin', 'plagiarism_turnitinsim'), $output ); @@ -329,7 +330,7 @@ public function test_get_links_with_submission() { // Change submission status to a non constant and verify that the default is displayed. $tssubmission->setstatus('nonconstantstring'); $tssubmission->update(); - $this->assertContains( + handle_deprecation::assertContains($this, get_string( 'submissiondisplaystatus:unknown', 'plagiarism_turnitinsim'), $plagiarismturnitinsim->get_links($linkarray)); @@ -337,7 +338,7 @@ public function test_get_links_with_submission() { $tssubmission->setstatus(TURNITINSIM_SUBMISSION_STATUS_ERROR); $tssubmission->seterrormessage(TURNITINSIM_SUBMISSION_STATUS_TOO_MUCH_TEXT); $tssubmission->update(); - $this->assertContains( + handle_deprecation::assertContains($this, get_string( 'submissiondisplayerror:toomuchtext', 'plagiarism_turnitinsim'), $plagiarismturnitinsim->get_links($linkarray) ); @@ -345,14 +346,14 @@ public function test_get_links_with_submission() { // Change error message to generic and verify that it is displayed. $tssubmission->seterrormessage('random_string_that_is_not_a_constant'); $tssubmission->update(); - $this->assertContains( + handle_deprecation::assertContains($this, get_string( 'submissiondisplayerror:generic', 'plagiarism_turnitinsim'), $plagiarismturnitinsim->get_links($linkarray) ); // Log instructor in and check they see a resubmit link. $this->setUser($this->instructor); - $this->assertContains( + handle_deprecation::assertContains($this, get_string( 'resubmittoturnitin', 'plagiarism_turnitinsim'), $plagiarismturnitinsim->get_links($linkarray) ); @@ -362,8 +363,8 @@ public function test_get_links_with_submission() { $tssubmission->setstatus(TURNITINSIM_SUBMISSION_STATUS_COMPLETE); $tssubmission->setoverallscore($score); $tssubmission->update(); - $this->assertContains($score.'%', $plagiarismturnitinsim->get_links($linkarray)); - $this->assertContains('or_score_colour_' . round($score, -1), $plagiarismturnitinsim->get_links($linkarray)); + handle_deprecation::assertContains($this, $score.'%', $plagiarismturnitinsim->get_links($linkarray)); + handle_deprecation::assertContains($this, 'or_score_colour_' . round($score, -1), $plagiarismturnitinsim->get_links($linkarray)); } /** @@ -374,7 +375,7 @@ public function test_render_resubmit_link() { $plagiarismturnitinsim = new plagiarism_plugin_turnitinsim(); $submissionid = 1; - $this->assertContains('pp_resubmit_id_'.$submissionid, $plagiarismturnitinsim->render_resubmit_link($submissionid)); + handle_deprecation::assertContains($this, 'pp_resubmit_id_'.$submissionid, $plagiarismturnitinsim->render_resubmit_link($submissionid)); } /** @@ -489,7 +490,7 @@ public function test_print_disclosure_display_latest() { // Verify EULA is output. $plagiarismturnitinsim = new plagiarism_plugin_turnitinsim(); - $this->assertContains( + handle_deprecation::assertContains($this, get_string('eulalink', 'plagiarism_turnitinsim', $eulaurl), $plagiarismturnitinsim->print_disclosure($this->cm->id) ); @@ -525,7 +526,7 @@ public function test_print_disclosure_not_display_latest() { // Verify EULA is not output. $plagiarismturnitinsim = new plagiarism_plugin_turnitinsim(); - $this->assertContains( + handle_deprecation::assertContains($this, get_string('eulaalreadyaccepted', 'plagiarism_turnitinsim'), $plagiarismturnitinsim->print_disclosure($this->cm->id)); } @@ -557,7 +558,7 @@ public function test_print_disclosure_eula_not_displayed_if_not_required() { // Verify EULA is not output. $plagiarismturnitinsim = new plagiarism_plugin_turnitinsim(); - $this->assertContains( + handle_deprecation::assertContains($this, get_string('eulanotrequired', 'plagiarism_turnitinsim'), $plagiarismturnitinsim->print_disclosure($this->cm->id)); } diff --git a/tests/privacy/provider_test.php b/tests/privacy/provider_test.php index 98cbbcb..118985d 100644 --- a/tests/privacy/provider_test.php +++ b/tests/privacy/provider_test.php @@ -42,7 +42,7 @@ class plagiarism_turnitinsim_privacy_provider_testcase extends advanced_testcase /** * Setup method that runs before each test. */ - public function setup() { + public function setUp(): void { $this->turnitinsim_generator = new turnitinsim_generator(); $this->submission = $this->turnitinsim_generator->create_submission(); } diff --git a/utilities/handle_deprecation.php b/utilities/handle_deprecation.php index d3264ba..e455cb6 100644 --- a/utilities/handle_deprecation.php +++ b/utilities/handle_deprecation.php @@ -109,8 +109,54 @@ public static function get_plugin_enabled() { */ public static function download_data($exportfile, $dataformat, $columns, $data) { global $CFG; - - $CFG->branch >= 39 ? \core\dataformat::download_data($exportfile, $dataformat, $columns, $data) + + $CFG->branch >= 39 ? \core\dataformat::download_data($exportfile, $dataformat, $columns, $data) : download_as_dataformat($exportfile, $dataformat, $columns, $data); } + + /** + * In Moodle 3.10, Moodle switched to use PHPUnit 8.5 which contains deprecations for some assertions. + * assertContains was deprecated in favour of the newer assertStringContainsString. (PHPUnit 7.5) + * This method handles our support for Moodle versions that use PHPUnit 6.5. (Moodle 3.5 and 3.6) + * + * @param object $object The test class object. + * @param string $needle The string we want to find. + * @param string $haystack The string we are searching within. + */ + public static function assertContains($object, $needle, $haystack) { + global $CFG; + + $CFG->branch >= 37 ? $object->assertStringContainsString($needle, $haystack) + : $object->assertContains($needle, $haystack); + } + + /** + * In Moodle 3.10, Moodle switched to use PHPUnit 8.5 which contains deprecations for some assertions. + * assertNotContains was deprecated in favour of the newer assertStringNotContainsString. (PHPUnit 7.5) + * This method handles our support for Moodle versions that use PHPUnit 6.5. (Moodle 3.5 and 3.6) + * + * @param object $object The test class object. + * @param string $needle The string we want to find. + * @param string $haystack The string we are searching within. + */ + public static function assertNotContains($object, $needle, $haystack) { + global $CFG; + + $CFG->branch >= 37 ? $object->assertStringNotContainsString($needle, $haystack) + : $object->assertNotContains($needle, $haystack); + } + + /** + * In Moodle 3.10, Moodle switched to use PHPUnit 8.5 which contains deprecations for some assertions. + * assertInternalType was deprecated in favour of newer methods such as assertIsInt. (PHPUnit 7.5) + * This method handles our support for Moodle versions that use PHPUnit 6.5. (Moodle 3.5 and 3.6) + * + * @param object $object The test class object. + * @param string $value The value we are looking for. + */ + public static function assertInternalTypeInt($object, $value) { + global $CFG; + + $CFG->branch >= 37 ? $object->assertIsInt($value) : $object->assertInternalType("int", $value); + } } \ No newline at end of file From e692d618a6ba3934102d7af52c2fcd0ba451d15b Mon Sep 17 00:00:00 2001 From: David Winn Date: Thu, 10 Dec 2020 16:55:59 +0000 Subject: [PATCH 28/42] Don't create mod entry if Turnitin disabled --- classes/settings.class.php | 5 ++++- tests/classes/settings_class_test.php | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/classes/settings.class.php b/classes/settings.class.php index 938999b..dfd1f8b 100644 --- a/classes/settings.class.php +++ b/classes/settings.class.php @@ -206,7 +206,10 @@ public function save_module_settings($data) { $settings->id = $modsettings->id; $DB->update_record('plagiarism_turnitinsim_mod', $settings); } else { - $DB->insert_record('plagiarism_turnitinsim_mod', $settings); + // Inserts only happen on activity creation, so if turnitinenabled is false - don't insert. + if ($settings->turnitinenabled) { + $DB->insert_record('plagiarism_turnitinsim_mod', $settings); + } } } diff --git a/tests/classes/settings_class_test.php b/tests/classes/settings_class_test.php index bfc1508..54aeb71 100644 --- a/tests/classes/settings_class_test.php +++ b/tests/classes/settings_class_test.php @@ -98,6 +98,27 @@ public function test_save_module_settings() { $this->assertEquals(0, $settings->excludebiblio); } + /** + * Test that save module settings does not create an entry if Turnitin is disabled. + */ + public function test_save_module_settings_does_not_create_entry_if_turnitin_disabled() { + global $DB; + + $this->resetAfterTest(); + + // Create data object for new assignment. + $data = new stdClass(); + $data->coursemodule = 1; + $data->turnitinenabled = 0; + + // Save Module Settings to test inserting. + $form = new plagiarism_turnitinsim_settings(); + $form->save_module_settings($data); + + // Check that there is no entry for this module. + $this->assertFalse($DB->get_record('plagiarism_turnitinsim_mod', array('cm' => $data->coursemodule))); + } + /** * Test that get_enabled_features does not return features on failure. */ From 7edad2603c37f4d33dd79850f16ebb9c1b8eb056 Mon Sep 17 00:00:00 2001 From: David Winn Date: Thu, 10 Dec 2020 17:47:22 +0000 Subject: [PATCH 29/42] Adding original submitted time as a parameter in create submission request --- classes/submission.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/classes/submission.class.php b/classes/submission.class.php index 63a229a..b7f89ca 100644 --- a/classes/submission.class.php +++ b/classes/submission.class.php @@ -411,6 +411,9 @@ public function create_submission_in_turnitin() { // Add owners to the metadata. $request['metadata']['owners'] = $this->create_owners_metadata(); + // Add original submission time metadata. + $request['metadata']['original_submitted_time'] = gmdate("Y-m-d\TH:i:s\Z", time()); + // Add EULA acceptance details to submission if the submitter has accepted it. $language = $this->tsrequest->get_language()->localecode; $locale = ($tssubmitter->get_lasteulaacceptedlang()) ? $tssubmitter->get_lasteulaacceptedlang() : $language; From b3b2684dc218856df70a4f45f41f5bfd7ac3a5b5 Mon Sep 17 00:00:00 2001 From: David Winn Date: Mon, 14 Dec 2020 15:57:50 +0000 Subject: [PATCH 30/42] Check submission status when submissions are processed after enabling Turnitin --- classes/submission.class.php | 3 ++ lib.php | 60 ++++++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/classes/submission.class.php b/classes/submission.class.php index b7f89ca..6cc96c4 100644 --- a/classes/submission.class.php +++ b/classes/submission.class.php @@ -947,6 +947,9 @@ public static function get_submission_details($linkarray) { 'type' => 'content', 'cm' => $linkarray['cmid'], 'quizanswer' => $quizanswer)); } } + echo 'test'; + var_dump(array('userid' => $linkarray['userid'], + 'cm' => $linkarray['cmid'], 'identifier' => $identifier, 'quizanswer' => $quizanswer)); return $DB->get_record('plagiarism_turnitinsim_sub', array('userid' => $linkarray['userid'], 'cm' => $linkarray['cmid'], 'identifier' => $identifier, 'quizanswer' => $quizanswer)); diff --git a/lib.php b/lib.php index f5444d6..f33c705 100644 --- a/lib.php +++ b/lib.php @@ -290,25 +290,8 @@ public function get_links($linkarray) { break; case TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED: - // Allow a modal to be launched with a EULA link and ability to accept. - $tsrequest = new plagiarism_turnitinsim_request(); - $lang = $tsrequest->get_language(); - $eulaurl = get_config('plagiarism_turnitinsim', 'turnitin_eula_url')."?lang=".$lang->localecode; - - $helpicon = $OUTPUT->pix_icon( - 'help', - get_string('submissiondisplayerror:eulanotaccepted_help', 'plagiarism_turnitinsim'), - 'core', - ['class' => 'eula-row-launch', 'data-eula-link' => $eulaurl] - ); - - $eulalaunch = ' '.$helpicon; - $status = html_writer::tag( - 'span', - get_string('submissiondisplaystatus:awaitingeula', 'plagiarism_turnitinsim') . $eulalaunch, - array('class' => 'tii_status_text tii_status_text_eula') - ); + $status = $this->get_eula_status(); $showresubmitlink = false; break; @@ -360,8 +343,14 @@ public function get_links($linkarray) { $eventdata = $moduleobject->create_submission_event_data($linkarray); $this->submission_handler($eventdata); - $status = html_writer::tag('span', get_string('submissiondisplaystatus:queued', - 'plagiarism_turnitinsim')); + // Check if student has accepted the EULA. + $plagiarismfile = plagiarism_turnitinsim_submission::get_submission_details($linkarray); + if ($plagiarismfile->status === TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED) { + $status = $this->get_eula_status(); + } else { + $status = html_writer::tag('span', get_string('submissiondisplaystatus:queued', + 'plagiarism_turnitinsim')); + } } // Render a Turnitin logo. @@ -380,6 +369,37 @@ public function get_links($linkarray) { return html_writer::tag('div', $output, array('class' => 'turnitinsim_links')); } + /** + * This returns the HTML elements required to display a EULA_NOT_ACCEPTED status. + * + * @return string The HTML element for a EULA NOT ACCEPTED status. + * @throws coding_exception + * @throws dml_exception + */ + private function get_eula_status() { + global $OUTPUT; + + // Allow a modal to be launched with a EULA link and ability to accept. + $tsrequest = new plagiarism_turnitinsim_request(); + $lang = $tsrequest->get_language(); + $eulaurl = get_config('plagiarism_turnitinsim', 'turnitin_eula_url')."?lang=".$lang->localecode; + + $helpicon = $OUTPUT->pix_icon( + 'help', + get_string('submissiondisplayerror:eulanotaccepted_help', 'plagiarism_turnitinsim'), + 'core', + ['class' => 'eula-row-launch', 'data-eula-link' => $eulaurl] + ); + + $eulalaunch = ' '.$helpicon; + + return html_writer::tag( + 'span', + get_string('submissiondisplaystatus:awaitingeula', 'plagiarism_turnitinsim') . $eulalaunch, + array('class' => 'tii_status_text tii_status_text_eula') + ); + } + /** * Check whether the plugin is active. * @param object $cm The course module data. From b953c794beaee877c32b867de1798d62a52bfbc2 Mon Sep 17 00:00:00 2001 From: David Winn Date: Mon, 14 Dec 2020 16:07:40 +0000 Subject: [PATCH 31/42] Remove debug line --- classes/submission.class.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/classes/submission.class.php b/classes/submission.class.php index 6cc96c4..b7f89ca 100644 --- a/classes/submission.class.php +++ b/classes/submission.class.php @@ -947,9 +947,6 @@ public static function get_submission_details($linkarray) { 'type' => 'content', 'cm' => $linkarray['cmid'], 'quizanswer' => $quizanswer)); } } - echo 'test'; - var_dump(array('userid' => $linkarray['userid'], - 'cm' => $linkarray['cmid'], 'identifier' => $identifier, 'quizanswer' => $quizanswer)); return $DB->get_record('plagiarism_turnitinsim_sub', array('userid' => $linkarray['userid'], 'cm' => $linkarray['cmid'], 'identifier' => $identifier, 'quizanswer' => $quizanswer)); From cbd65071b650e4b9071179abd3266d7af2d3ac6f Mon Sep 17 00:00:00 2001 From: David Winn Date: Mon, 14 Dec 2020 17:48:48 +0000 Subject: [PATCH 32/42] Save webhook on creation if one already exists. --- classes/callback.class.php | 13 +++++++ tests/classes/callback.class_test.php | 35 +++++++++++++++++++ .../create_webhook_already_exists.json | 5 +++ .../create_webhook_list_webhooks.json | 28 +++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 tests/fixtures/create_webhook_already_exists.json create mode 100644 tests/fixtures/create_webhook_list_webhooks.json diff --git a/classes/callback.class.php b/classes/callback.class.php index 2448530..3b34727 100644 --- a/classes/callback.class.php +++ b/classes/callback.class.php @@ -151,6 +151,19 @@ public function create_webhook() { set_config('turnitin_webhook_secret', $secret, 'plagiarism_turnitinsim'); mtrace(get_string('taskoutputwebhookcreated', 'plagiarism_turnitinsim', TURNITINSIM_CALLBACK_URL)); + } elseif ($responsedata->httpstatus === TURNITINSIM_HTTP_CANNOT_EXTRACT_TEXT) { + // Webhook for this URL already exists in Turnitin, but not Moodle. Get webhooks. + $response = $this->tsrequest->send_request(TURNITINSIM_ENDPOINT_WEBHOOKS, json_encode(array()), 'GET'); + $webhooks = json_decode($response); + + // We want the webhook ID for this callback URL. Save it. + foreach ($webhooks as $webhook) { + if (is_object($webhook) && $webhook->url === TURNITINSIM_CALLBACK_URL) { + set_config('turnitin_webhook_id', $webhook->id, 'plagiarism_turnitinsim'); + set_config('turnitin_webhook_secret', $secret, 'plagiarism_turnitinsim'); + break; + } + } } else { mtrace(get_string('taskoutputwebhooknotcreated', 'plagiarism_turnitinsim', TURNITINSIM_CALLBACK_URL)); $loggingrequestinfo = new plagiarism_turnitinsim_logging_request_info(TURNITINSIM_ENDPOINT_WEBHOOKS, "POST", diff --git a/tests/classes/callback.class_test.php b/tests/classes/callback.class_test.php index c1af782..b2f2740 100644 --- a/tests/classes/callback.class_test.php +++ b/tests/classes/callback.class_test.php @@ -195,6 +195,41 @@ public function test_create_webhook_in_turnitin_failure() { $this->assertFalse(get_config('plagiarism_turnitinsim', 'turnitin_webhook_id')); } + /** + * Test create webhook where a webhook already exists and needs to be retrieved. + */ + public function test_create_webhook_if_already_exists() { + $this->resetAfterTest(); + + // Get the response for a failed webhook creation. + $existsresponse = file_get_contents(__DIR__ . '/../fixtures/create_webhook_already_exists.json'); + + // Get the response for a successfully created webhook. + $successresponse = file_get_contents(__DIR__ . '/../fixtures/create_webhook_list_webhooks.json'); + $jsonresponse = (array)json_decode($successresponse); + + // Test that the webhook does not exist in Moodle. + $this->assertFalse(get_config('plagiarism_turnitinsim', 'turnitin_webhook_id')); + + // Mock API request class. + $tsrequest = $this->getMockBuilder(plagiarism_turnitinsim_request::class) + ->setMethods(['send_request']) + ->setConstructorArgs([TURNITINSIM_ENDPOINT_WEBHOOKS]) + ->getMock(); + + // Mock API send request method. + $tsrequest->expects($this->exactly(2)) + ->method('send_request') + ->willReturnOnConsecutiveCalls($existsresponse, $successresponse); + + // Attempt to create webhook. This should retrieve an existing webhook. + $tscallback = new plagiarism_turnitinsim_callback( $tsrequest ); + $tscallback->create_webhook(); + + // Test that the webhook is created. + $this->assertEquals($jsonresponse[0]->id, get_config('plagiarism_turnitinsim', 'turnitin_webhook_id')); + } + /** * Test create webhook failed request to Turnitin. */ diff --git a/tests/fixtures/create_webhook_already_exists.json b/tests/fixtures/create_webhook_already_exists.json new file mode 100644 index 0000000..2762772 --- /dev/null +++ b/tests/fixtures/create_webhook_already_exists.json @@ -0,0 +1,5 @@ +{ + "status": 409, + "message": "A webhook with the same URL already exist. Either update or delete the existing webhook.", + "httpstatus": 409 +} \ No newline at end of file diff --git a/tests/fixtures/create_webhook_list_webhooks.json b/tests/fixtures/create_webhook_list_webhooks.json new file mode 100644 index 0000000..8d94ffe --- /dev/null +++ b/tests/fixtures/create_webhook_list_webhooks.json @@ -0,0 +1,28 @@ +[ + { + "id": "a7275318-232a-43ef-a3d6-8f3b732effa7", + "url": "https://www.example.com/moodle/plagiarism/turnitinsim/callbacks.php", + "description": "testing webhook", + "created_time": "2017-11-28T14:20:34.934Z", + "event_types": [ + "SIMILARITY_COMPLETE", + "SUBMISSION_COMPLETE", + "SIMILARITY_UPDATED" + ], + "allow_insecure": false, + "httpstatus": 201 + }, + { + "id": "2d294ff3-f032-4562-adab-9538727c3ed7", + "url": "https://www.example.com/moodle/extra/plagiarism/turnitinsim/callbacks.php", + "description": "testing webhook", + "created_time": "2020-11-28T14:20:34.934Z", + "event_types": [ + "SIMILARITY_COMPLETE", + "SUBMISSION_COMPLETE", + "SIMILARITY_UPDATED" + ], + "allow_insecure": false, + "httpstatus": 201 + } +] \ No newline at end of file From 8c046c466ac5f81eec01e6007e33b9f59a8f274d Mon Sep 17 00:00:00 2001 From: David Winn Date: Mon, 21 Dec 2020 13:36:08 +0000 Subject: [PATCH 33/42] Accepting EULA changes EULA status for all submissions for that user, and store correct submitter when enabling plugin after submissions have been made --- ajax/eula_response.php | 41 ++++++++++++++++---------------------- classes/assign.class.php | 4 ++-- classes/forum.class.php | 2 +- classes/quiz.class.php | 2 +- classes/workshop.class.php | 2 +- 5 files changed, 22 insertions(+), 29 deletions(-) diff --git a/ajax/eula_response.php b/ajax/eula_response.php index 205ff79..15d64fe 100644 --- a/ajax/eula_response.php +++ b/ajax/eula_response.php @@ -34,7 +34,6 @@ // Get any params passed in. $action = required_param('action', PARAM_ALPHAEXT); -$contextid = optional_param('contextid', 0, PARAM_INT); $tsrequest = new plagiarism_turnitinsim_request(); @@ -52,31 +51,25 @@ $data->lasteulaacceptedlang = $lang->localecode; $DB->update_record('plagiarism_turnitinsim_users', $data); - // If we have a context id then this is an instructor. So we update current submissions. - if (!empty($contextid)) { + // Update all existing submissions where EULA was not accepted. + // Get all submissions for this student with EULA_NOT_ACCEPTED status. + $submissions = $DB->get_records( + 'plagiarism_turnitinsim_sub', + array( + 'status' => TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED, + 'submitter' => $USER->id + ) + ); - // Get all submissions in this context. - $context = context::instance_by_id($contextid); - $submissions = $DB->get_records( - 'plagiarism_turnitinsim_sub', - array( - 'cm' => $context->instanceid, - 'status' => TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED, - 'submitter' => $USER->id - ) - ); + // Set each paper in this module submitted by this user to queued. + foreach ($submissions as $submission) { + $data = new stdClass(); + $data->id = $submission->id; + $data->status = TURNITINSIM_SUBMISSION_STATUS_QUEUED; + $data->tiiattempts = 0; + $data->tiiretrytime = 0; - // Set each paper in this module submitted by this user to queued. - foreach ($submissions as $submission) { - $data = new stdClass(); - $data->id = $submission->id; - $data->status = TURNITINSIM_SUBMISSION_STATUS_QUEUED; - $data->cm = $context->instanceid; - $data->tiiattempts = 0; - $data->tiiretrytime = 0; - - $DB->update_record('plagiarism_turnitinsim_sub', $data); - } + $DB->update_record('plagiarism_turnitinsim_sub', $data); } echo json_encode(["success" => true]); diff --git a/classes/assign.class.php b/classes/assign.class.php index 08b8456..36987d9 100644 --- a/classes/assign.class.php +++ b/classes/assign.class.php @@ -194,7 +194,7 @@ public function show_other_posts_links($courseid, $userid) { * @throws dml_exception */ public function create_submission_event_data($linkarray) { - global $DB, $USER; + global $DB; $cm = get_coursemodule_from_id('', $linkarray['cmid']); @@ -202,7 +202,7 @@ public function create_submission_event_data($linkarray) { $eventdata['contextinstanceid'] = $linkarray['cmid']; $eventdata['eventtype'] = 'assessable_submitted'; - $eventdata['userid'] = $USER->id; + $eventdata['userid'] = $linkarray['userid']; if (isset($linkarray['file'])) { $eventdata['other']['pathnamehashes'] = array($linkarray['file']->get_pathnamehash()); diff --git a/classes/forum.class.php b/classes/forum.class.php index 671f27b..af9adf5 100644 --- a/classes/forum.class.php +++ b/classes/forum.class.php @@ -152,7 +152,7 @@ public function create_submission_event_data($linkarray) { $eventdata['contextinstanceid'] = $linkarray['cmid']; $eventdata['eventtype'] = 'assessable_submitted'; - $eventdata['userid'] = $USER->id; + $eventdata['userid'] = $linkarray['userid']; if (isset($linkarray['file'])) { $eventdata['other']['pathnamehashes'] = array($linkarray['file']->get_pathnamehash()); diff --git a/classes/quiz.class.php b/classes/quiz.class.php index ec2ce08..1973e66 100644 --- a/classes/quiz.class.php +++ b/classes/quiz.class.php @@ -141,7 +141,7 @@ public function create_submission_event_data($linkarray) { $eventdata['contextinstanceid'] = $linkarray['cmid']; $eventdata['eventtype'] = 'quiz_submitted'; - $eventdata['userid'] = $USER->id; + $eventdata['userid'] = $linkarray['userid']; $eventdata['objectid'] = $linkarray['area']; if (isset($linkarray['file'])) { diff --git a/classes/workshop.class.php b/classes/workshop.class.php index 98fa969..23ec5e9 100644 --- a/classes/workshop.class.php +++ b/classes/workshop.class.php @@ -138,7 +138,7 @@ public function create_submission_event_data($linkarray) { $eventdata['contextinstanceid'] = $linkarray['cmid']; $eventdata['eventtype'] = 'assessable_submitted'; - $eventdata['userid'] = $USER->id; + $eventdata['userid'] = $linkarray['userid']; if (isset($linkarray['file'])) { $eventdata['other']['pathnamehashes'] = array($linkarray['file']->get_pathnamehash()); From ed3866f665f283cfb3a3b244de6c7070b3c0430e Mon Sep 17 00:00:00 2001 From: David Winn Date: Mon, 21 Dec 2020 13:38:59 +0000 Subject: [PATCH 34/42] Updating comment --- ajax/eula_response.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ajax/eula_response.php b/ajax/eula_response.php index 15d64fe..318ee8a 100644 --- a/ajax/eula_response.php +++ b/ajax/eula_response.php @@ -51,7 +51,6 @@ $data->lasteulaacceptedlang = $lang->localecode; $DB->update_record('plagiarism_turnitinsim_users', $data); - // Update all existing submissions where EULA was not accepted. // Get all submissions for this student with EULA_NOT_ACCEPTED status. $submissions = $DB->get_records( 'plagiarism_turnitinsim_sub', @@ -61,7 +60,7 @@ ) ); - // Set each paper in this module submitted by this user to queued. + // Update all existing submissions where EULA was not accepted. foreach ($submissions as $submission) { $data = new stdClass(); $data->id = $submission->id; From fca268c05900143110d930851989fa3fffc6475c Mon Sep 17 00:00:00 2001 From: David Winn Date: Tue, 5 Jan 2021 18:26:53 +0000 Subject: [PATCH 35/42] EULA workflow fix and unit test --- ajax/eula_response.php | 38 +++-------------------- classes/eula.class.php | 42 +++++++++++++++++++++++++ tests/classes/eula.class_test.php | 48 +++++++++++++++++++++++++++++ tests/turnitinsim_generator.php | 51 ++++++++++++++++++++++++++++++- 4 files changed, 144 insertions(+), 35 deletions(-) diff --git a/ajax/eula_response.php b/ajax/eula_response.php index 318ee8a..bdd982e 100644 --- a/ajax/eula_response.php +++ b/ajax/eula_response.php @@ -25,6 +25,7 @@ require_once(__DIR__."/../../../config.php"); require_once(__DIR__."/../lib.php"); +require_once(__DIR__."/../classes/eula.class.php"); require_login(); @@ -35,42 +36,11 @@ // Get any params passed in. $action = required_param('action', PARAM_ALPHAEXT); -$tsrequest = new plagiarism_turnitinsim_request(); - switch ($action) { case "accept_eula": - // Get current user record. - $user = $DB->get_record('plagiarism_turnitinsim_users', array('userid' => $USER->id)); - - // Update EULA accepted version and timestamp for user. - $data = new stdClass(); - $data->id = $user->id; - $data->lasteulaaccepted = get_config('plagiarism_turnitinsim', 'turnitin_eula_version'); - $data->lasteulaacceptedtime = time(); - $lang = $tsrequest->get_language(); - $data->lasteulaacceptedlang = $lang->localecode; - $DB->update_record('plagiarism_turnitinsim_users', $data); - - // Get all submissions for this student with EULA_NOT_ACCEPTED status. - $submissions = $DB->get_records( - 'plagiarism_turnitinsim_sub', - array( - 'status' => TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED, - 'submitter' => $USER->id - ) - ); + $eula = new plagiarism_turnitinsim_eula(); - // Update all existing submissions where EULA was not accepted. - foreach ($submissions as $submission) { - $data = new stdClass(); - $data->id = $submission->id; - $data->status = TURNITINSIM_SUBMISSION_STATUS_QUEUED; - $data->tiiattempts = 0; - $data->tiiretrytime = 0; - - $DB->update_record('plagiarism_turnitinsim_sub', $data); - } - echo json_encode(["success" => true]); + echo $eula->accept_eula(); break; -} +} \ No newline at end of file diff --git a/classes/eula.class.php b/classes/eula.class.php index 2eb531c..a0bb36f 100644 --- a/classes/eula.class.php +++ b/classes/eula.class.php @@ -74,4 +74,46 @@ public function get_latest_version() { return $responsedata; } } + + /** + * Method for handling the acceptance of the EULA, called from eula_response. + * @throws dml_exception + */ + public function accept_eula() { + global $DB, $USER; + + // Get current user record. + $user = $DB->get_record('plagiarism_turnitinsim_users', array('userid' => $USER->id)); + + // Update EULA accepted version and timestamp for user. + $data = new stdClass(); + $data->id = $user->id; + $data->lasteulaaccepted = get_config('plagiarism_turnitinsim', 'turnitin_eula_version'); + $data->lasteulaacceptedtime = time(); + $lang = $this->tsrequest->get_language(); + $data->lasteulaacceptedlang = $lang->localecode; + $DB->update_record('plagiarism_turnitinsim_users', $data); + + // Get all submissions for this student with EULA_NOT_ACCEPTED status. + $submissions = $DB->get_records( + 'plagiarism_turnitinsim_sub', + array( + 'status' => TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED, + 'userid' => $USER->id + ) + ); + + // Update all existing submissions where EULA was not accepted. + foreach ($submissions as $submission) { + $data = new stdClass(); + $data->id = $submission->id; + $data->status = TURNITINSIM_SUBMISSION_STATUS_QUEUED; + $data->tiiattempts = 0; + $data->tiiretrytime = 0; + + $DB->update_record('plagiarism_turnitinsim_sub', $data); + } + + return json_encode(["success" => true]); + } } \ No newline at end of file diff --git a/tests/classes/eula.class_test.php b/tests/classes/eula.class_test.php index 631c7a0..90a3790 100644 --- a/tests/classes/eula.class_test.php +++ b/tests/classes/eula.class_test.php @@ -28,6 +28,7 @@ global $CFG; require_once($CFG->dirroot . '/plagiarism/turnitinsim/lib.php'); require_once($CFG->dirroot . '/plagiarism/turnitinsim/tests/utilities.php'); +require_once($CFG->dirroot . '/plagiarism/turnitinsim/tests/turnitinsim_generator.php'); /** * Tests for Turnitin Integrity submission class. @@ -128,4 +129,51 @@ public function test_get_latest_version_success() { // Test that the latest EULA version has been retrieved. $this->assertTrue(isset($result->version)); } + + /** + * Test accept EULA updates the status of the EULA for all of a student's submissions. + */ + public function test_accept_eula_saves_eula_and_updates_submissions() { + global $DB; + + $this->resetAfterTest(); + + set_config('turnitin_eula_version', 'v1beta', 'plagiarism_turnitinsim'); + + // Create 3 submissions. + $this->turnitinsim_generator = new turnitinsim_generator(); + $submission = $this->turnitinsim_generator->create_submission(3, TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED); + + $this->setUser($submission['student']); + + // Insert a user to the TII table. + $user = new stdClass(); + $user->userid = $submission['student']->id; + $user->turnitinid = (new handle_deprecation)->create_uuid(); + $DB->insert_record('plagiarism_turnitinsim_users', $user); + + // Check the data. + $submissions = $DB->get_records('plagiarism_turnitinsim_sub'); + $this->assertCount(3, $submissions); + + $users = $DB->get_records('plagiarism_turnitinsim_users'); + $this->assertCount(1, $users); + + // Accept the EULA. + $tseula = new plagiarism_turnitinsim_eula(); + $result = json_decode($tseula->accept_eula()); + $this->assertEquals(true, $result->success); + + // Check the results. + $userresult = $DB->get_record('plagiarism_turnitinsim_users', array('userid' => $user->userid)); + $this->assertEquals('v1beta', $userresult->lasteulaaccepted); + $this->assertGreaterThan('lasteulaacceptedtime', time() - 60); + $this->assertEquals('en-US', $userresult->lasteulaacceptedlang); + + $submissionresult = $DB->get_records( + 'plagiarism_turnitinsim_sub', + array('status' => TURNITINSIM_SUBMISSION_STATUS_QUEUED) + ); + $this->assertCount(3, $submissionresult); + } } \ No newline at end of file diff --git a/tests/turnitinsim_generator.php b/tests/turnitinsim_generator.php index 1b3103d..8f42254 100644 --- a/tests/turnitinsim_generator.php +++ b/tests/turnitinsim_generator.php @@ -92,7 +92,56 @@ public function create_assign_with_student_and_teacher($params = array()) { * @throws coding_exception * @throws dml_exception */ - public function create_submission($numsubmissions = 1) { + public function create_submission($numsubmissions = 1, $status = TURNITINSIM_SUBMISSION_STATUS_QUEUED) { + global $DB, $CFG; + require_once($CFG->dirroot . '/mod/assign/tests/base_test.php'); + + $result = $this->create_assign_with_student_and_teacher(array( + 'assignsubmission_onlinetext_enabled' => 1, + 'teamsubmission' => 0 + )); + + $assignmodule = $result['assign']; + $student = $result['student']; + $cm = get_coursemodule_from_instance('assign', $assignmodule->id); + $context = context_module::instance($cm->id); + + $plagiarismfile = new stdClass(); + $plagiarismfile->cm = $cm->id; + $plagiarismfile->userid = $student->id; + $plagiarismfile->identifier = "abcd"; + $plagiarismfile->statuscode = "success"; + $plagiarismfile->similarityscore = 50; + $plagiarismfile->externalid = 123456789; + $plagiarismfile->attempt = 1; + $plagiarismfile->transmatch = 0; + $plagiarismfile->lastmodified = time(); + $plagiarismfile->submissiontype = 2; + $plagiarismfile->itemid = 12; + $plagiarismfile->submitter = $student->id; + $plagiarismfile->status = $status; + + for ($i = 0; $i < $numsubmissions; $i++) { + $DB->insert_record('plagiarism_turnitinsim_sub', $plagiarismfile); + } + + $this->setUser($student); + + return array( + 'student' => $student, + 'context' => $context + ); + } + + /** + * Create a Turnitin user. + * + * @param int $numusers The number of users to create. + * @return array + * @throws coding_exception + * @throws dml_exception + */ + public function create_user($numusers = 1) { global $DB, $CFG; require_once($CFG->dirroot . '/mod/assign/tests/base_test.php'); From b6bc9d0ce6b28889f595bb8374d1023b67c1f88a Mon Sep 17 00:00:00 2001 From: David Winn Date: Tue, 5 Jan 2021 18:30:18 +0000 Subject: [PATCH 36/42] Tidying up code --- tests/turnitinsim_generator.php | 48 --------------------------------- 1 file changed, 48 deletions(-) diff --git a/tests/turnitinsim_generator.php b/tests/turnitinsim_generator.php index 8f42254..cd705b5 100644 --- a/tests/turnitinsim_generator.php +++ b/tests/turnitinsim_generator.php @@ -132,52 +132,4 @@ public function create_submission($numsubmissions = 1, $status = TURNITINSIM_SUB 'context' => $context ); } - - /** - * Create a Turnitin user. - * - * @param int $numusers The number of users to create. - * @return array - * @throws coding_exception - * @throws dml_exception - */ - public function create_user($numusers = 1) { - global $DB, $CFG; - require_once($CFG->dirroot . '/mod/assign/tests/base_test.php'); - - $result = $this->create_assign_with_student_and_teacher(array( - 'assignsubmission_onlinetext_enabled' => 1, - 'teamsubmission' => 0 - )); - - $assignmodule = $result['assign']; - $student = $result['student']; - $cm = get_coursemodule_from_instance('assign', $assignmodule->id); - $context = context_module::instance($cm->id); - - $plagiarismfile = new stdClass(); - $plagiarismfile->cm = $cm->id; - $plagiarismfile->userid = $student->id; - $plagiarismfile->identifier = "abcd"; - $plagiarismfile->statuscode = "success"; - $plagiarismfile->similarityscore = 50; - $plagiarismfile->externalid = 123456789; - $plagiarismfile->attempt = 1; - $plagiarismfile->transmatch = 0; - $plagiarismfile->lastmodified = time(); - $plagiarismfile->submissiontype = 2; - $plagiarismfile->itemid = 12; - $plagiarismfile->submitter = $student->id; - - for ($i = 0; $i < $numsubmissions; $i++) { - $DB->insert_record('plagiarism_turnitinsim_sub', $plagiarismfile); - } - - $this->setUser($student); - - return array( - 'student' => $student, - 'context' => $context - ); - } } \ No newline at end of file From c8829d9240b250034ba2c58d01c9438909f50e29 Mon Sep 17 00:00:00 2001 From: David Winn Date: Fri, 8 Jan 2021 17:10:15 +0000 Subject: [PATCH 37/42] Ensure consistency in submitter and userid fields when submitting on behalf of a student. --- classes/forum.class.php | 2 -- classes/quiz.class.php | 2 -- classes/submission.class.php | 1 + classes/workshop.class.php | 2 +- lib.php | 9 ++++++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/classes/forum.class.php b/classes/forum.class.php index af9adf5..2cb318a 100644 --- a/classes/forum.class.php +++ b/classes/forum.class.php @@ -144,8 +144,6 @@ public function show_other_posts_links($courseid, $userid) { * @throws dml_exception */ public function create_submission_event_data($linkarray) { - global $USER; - $cm = get_coursemodule_from_id('', $linkarray['cmid']); $eventdata = array(); diff --git a/classes/quiz.class.php b/classes/quiz.class.php index 1973e66..99f1b4f 100644 --- a/classes/quiz.class.php +++ b/classes/quiz.class.php @@ -133,8 +133,6 @@ public function show_other_posts_links($courseid, $userid) { * @throws dml_exception */ public function create_submission_event_data($linkarray) { - global $USER; - $cm = get_coursemodule_from_id('', $linkarray['cmid']); $eventdata = array(); diff --git a/classes/submission.class.php b/classes/submission.class.php index b7f89ca..2fd0332 100644 --- a/classes/submission.class.php +++ b/classes/submission.class.php @@ -947,6 +947,7 @@ public static function get_submission_details($linkarray) { 'type' => 'content', 'cm' => $linkarray['cmid'], 'quizanswer' => $quizanswer)); } } + return $DB->get_record('plagiarism_turnitinsim_sub', array('userid' => $linkarray['userid'], 'cm' => $linkarray['cmid'], 'identifier' => $identifier, 'quizanswer' => $quizanswer)); diff --git a/classes/workshop.class.php b/classes/workshop.class.php index 23ec5e9..b983fc2 100644 --- a/classes/workshop.class.php +++ b/classes/workshop.class.php @@ -130,7 +130,7 @@ public function show_other_posts_links($courseid, $userid) { * @throws dml_exception */ public function create_submission_event_data($linkarray) { - global $DB, $USER; + global $DB; $cm = get_coursemodule_from_id('', $linkarray['cmid']); diff --git a/lib.php b/lib.php index f33c705..a5e1e18 100644 --- a/lib.php +++ b/lib.php @@ -345,6 +345,7 @@ public function get_links($linkarray) { // Check if student has accepted the EULA. $plagiarismfile = plagiarism_turnitinsim_submission::get_submission_details($linkarray); + if ($plagiarismfile->status === TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED) { $status = $this->get_eula_status(); } else { @@ -697,7 +698,8 @@ public function submission_handler($eventdata) { } // If the submitter has not accepted the EULA then flag accordingly. - if ($submitter->get_lasteulaaccepted() < get_config('plagiarism_turnitinsim', 'turnitin_eula_version')) { + $authoruser = new plagiarism_turnitinsim_user($author); + if ($authoruser->get_lasteulaaccepted() < get_config('plagiarism_turnitinsim', 'turnitin_eula_version')) { $tssubmission->setstatus(TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED); $tssubmission->update(); return true; @@ -805,8 +807,9 @@ public function queue_files($cm, $eventdata, $sendtoturnitin, $features, $quizan } // If the submitter has not accepted the EULA then flag accordingly. - if ((empty($submitter->get_lasteulaaccepted()) || - $submitter->get_lasteulaaccepted() < get_config('plagiarism_turnitinsim', 'turnitin_eula_version')) && + $authoruser = new plagiarism_turnitinsim_user($author); + if ((empty($authoruser->get_lasteulaaccepted()) || + $authoruser->get_lasteulaaccepted() < get_config('plagiarism_turnitinsim', 'turnitin_eula_version')) && (bool)$features->tenant->require_eula ) { $tssubmission->setstatus(TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED); From a1442c912b1d1e2e67632bb7f6eb6330bfc98ae4 Mon Sep 17 00:00:00 2001 From: David Winn Date: Wed, 13 Jan 2021 16:49:03 +0000 Subject: [PATCH 38/42] Implementing a better way for students to accept the EULA if they originally declined it --- amd/build/cv_launch.min.js | 2 +- amd/build/cv_launch.min.js.map | 2 +- amd/build/eula_response.min.js | 2 +- amd/build/eula_response.min.js.map | 2 +- amd/build/inbox_eula_launch.min.js | 2 - amd/build/inbox_eula_launch.min.js.map | 1 - amd/src/eula_response.js | 4 + amd/src/inbox_eula_launch.js | 39 ---- classes/eula.class.php | 31 +++ lib.php | 180 +++++++-------- templates/modal_eula.mustache | 49 ---- tests/classes/eula.class_test.php | 303 +++++++++++++++++-------- tests/lib_test.php | 1 + utilities/handle_deprecation.php | 1 + 14 files changed, 332 insertions(+), 287 deletions(-) delete mode 100644 amd/build/inbox_eula_launch.min.js delete mode 100644 amd/build/inbox_eula_launch.min.js.map delete mode 100644 amd/src/inbox_eula_launch.js delete mode 100644 templates/modal_eula.mustache diff --git a/amd/build/cv_launch.min.js b/amd/build/cv_launch.min.js index 22f3d9f..fb3b5e8 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{openCv:function openCv(){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=M.cfg.wwwroot+"/plagiarism/turnitinsim/pix/tiiLogo.svg",e=window.open();e.document.write("");e.document.write("");a(e.document.body).html("
");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){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)}}})})}}}); +define ("plagiarism_turnitinsim/cv_launch",["jquery"],function(a){return{openCv:function openCv(){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=M.cfg.wwwroot+"/plagiarism/turnitinsim/pix/tiiLogo.svg",e=window.open();e.document.write("");e.document.write("");a(e.document.body).html("
");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){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 dac57eb..9e10d1a 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","$","openCv","document","on","classList","parent","attr","split","submissionid","each","index","match","icon","M","cfg","wwwroot","cvWindow","window","open","write","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,MAAM,CAAE,iBAAW,CACfD,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,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,GAYxCK,CAAAA,CAAI,CAAGC,CAAC,CAACC,GAAF,CAAMC,OAAN,CAAgB,yCAZiB,CAaxCC,CAAQ,CAAGC,MAAM,CAACC,IAAP,EAb6B,CAe5CF,CAAQ,CAACd,QAAT,CAAkBiB,KAAlB,CAAwB,iEACKN,CAAC,CAACC,GAAF,CAAMC,OADX,qDAAxB,EAEAC,CAAQ,CAACd,QAAT,CAAkBiB,KAAlB,CAAwB,gBAAxB,EAYAnB,CAAC,CAACgB,CAAQ,CAACd,QAAT,CAAkBkB,IAAnB,CAAD,CAA0BC,IAA1B,CAVc,sFAEaT,CAFb,6MAUd,EAEAZ,CAAC,CAACsB,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,CAEFnB,YAAY,CAAEA,CAFZ,CAGFoB,OAAO,CAAEf,CAAC,CAACC,GAAF,CAAMc,OAHb,CAJH,CASHC,OAAO,CAAE,iBAASH,CAAT,CAAe,CAEpBV,CAAQ,CAACc,QAAT,CAAoBJ,CAAI,CAACK,UAAzB,CACA,KAAKC,aAAL,CAAmBhB,CAAnB,CACH,CAbE,CAcHgB,aAAa,CAAE,uBAAShB,CAAT,CAAmB,CAC9B,GAAIiB,CAAAA,CAAI,CAAG,IAAX,CACA,GAAIjB,CAAQ,CAACkB,MAAb,CAAqB,CACjBjB,MAAM,CAACa,QAAP,CAAkBb,MAAM,CAACa,QAAP,CAAkB,EACvC,CAFD,IAEO,CACHK,UAAU,CAAC,UAAW,CAClBF,CAAI,CAACD,aAAL,CAAmBhB,CAAnB,CACH,CAFS,CAEP,GAFO,CAGb,CACJ,CAvBE,CAAP,CAyBH,CAxDD,CAyDH,CA3DE,CA6DV,CA9DK,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 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 var icon = M.cfg.wwwroot + '/plagiarism/turnitinsim/pix/tiiLogo.svg';\n var cvWindow = window.open();\n\n cvWindow.document.write('');\n cvWindow.document.write('');\n\n var loading = '
' +\n '
' +\n '' +\n '
' +\n '
' +\n '' +\n '' +\n '' +\n '
' +\n '
';\n $(cvWindow.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 cvWindow.location = data.viewer_url;\n this.checkDVClosed(cvWindow);\n },\n checkDVClosed: function(cvWindow) {\n var that = this;\n if (cvWindow.closed) {\n window.location = window.location + '';\n } else {\n setTimeout(function() {\n that.checkDVClosed(cvWindow);\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","$","openCv","document","on","classList","parent","attr","split","submissionid","each","index","match","icon","M","cfg","wwwroot","cvWindow","window","open","write","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,MAAM,CAAE,iBAAW,CACfD,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,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,GAYxCK,CAAAA,CAAI,CAAGC,CAAC,CAACC,GAAF,CAAMC,OAAN,CAAgB,yCAZiB,CAaxCC,CAAQ,CAAGC,MAAM,CAACC,IAAP,EAb6B,CAe5CF,CAAQ,CAACd,QAAT,CAAkBiB,KAAlB,CAAwB,iEACKN,CAAC,CAACC,GAAF,CAAMC,OADX,qDAAxB,EAEAC,CAAQ,CAACd,QAAT,CAAkBiB,KAAlB,CAAwB,gBAAxB,EAYAnB,CAAC,CAACgB,CAAQ,CAACd,QAAT,CAAkBkB,IAAnB,CAAD,CAA0BC,IAA1B,CAVc,wFAEaT,CAFb,6MAUd,EAEAZ,CAAC,CAACsB,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,CAEFnB,YAAY,CAAEA,CAFZ,CAGFoB,OAAO,CAAEf,CAAC,CAACC,GAAF,CAAMc,OAHb,CAJH,CASHC,OAAO,CAAE,iBAASH,CAAT,CAAe,CAEpBV,CAAQ,CAACc,QAAT,CAAoBJ,CAAI,CAACK,UAAzB,CACA,KAAKC,aAAL,CAAmBhB,CAAnB,CACH,CAbE,CAcHgB,aAAa,CAAE,uBAAShB,CAAT,CAAmB,CAC9B,GAAIiB,CAAAA,CAAI,CAAG,IAAX,CACA,GAAIjB,CAAQ,CAACkB,MAAb,CAAqB,CACjBjB,MAAM,CAACa,QAAP,CAAkBb,MAAM,CAACa,QAAP,CAAkB,EACvC,CAFD,IAEO,CACHK,UAAU,CAAC,UAAW,CAClBF,CAAI,CAACD,aAAL,CAAmBhB,CAAnB,CACH,CAFS,CAEP,GAFO,CAGb,CACJ,CAvBE,CAAP,CAyBH,CAxDD,CAyDH,CA3DE,CA6DV,CA9DK,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 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 var icon = M.cfg.wwwroot + '/plagiarism/turnitinsim/pix/tiiLogo.svg';\n var cvWindow = window.open();\n\n cvWindow.document.write('');\n cvWindow.document.write('');\n\n var loading = '
' +\n '
' +\n '' +\n '
' +\n '
' +\n '' +\n '' +\n '' +\n '
' +\n '
';\n $(cvWindow.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 cvWindow.location = data.viewer_url;\n this.checkDVClosed(cvWindow);\n },\n checkDVClosed: function(cvWindow) {\n var that = this;\n if (cvWindow.closed) {\n window.location = window.location + '';\n } else {\n setTimeout(function() {\n that.checkDVClosed(cvWindow);\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 c6b4e57..1e1fadb 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","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(".turnitinsim_eulacontainer").hide().html(b).fadeIn()})}})});a(document).on("click","#pp-eula-decline",function(){b.get_string("euladeclined","plagiarism_turnitinsim").done(function(b){a(".turnitinsim_eulacontainer").hide().html(b).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(c){a(".turnitinsim_eulacontainer").hide().html(c).fadeIn();b.get_string("submissiondisplaystatus:queued","plagiarism_turnitinsim").done(function(b){a(".tii_status_text").html(b)})})}})});a(document).on("click","#pp-eula-decline",function(){b.get_string("euladeclined","plagiarism_turnitinsim").done(function(b){a(".turnitinsim_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 56c4b27..c004984 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","$","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,4BAAD,CAAD,CAAgCqB,IAAhC,GAAuCC,IAAvC,CAA4CF,CAA5C,EAAkDG,MAAlD,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,4BAAD,CAAD,CAAgCqB,IAAhC,GAAuCC,IAAvC,CAA4CF,CAA5C,EAAkDG,MAAlD,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 $('.turnitinsim_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 $('.turnitinsim_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 +{"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,4BAAD,CAAD,CAAgCqB,IAAhC,GAAuCC,IAAvC,CAA4CF,CAA5C,EAAkDG,MAAlD,GAEAtB,CAAG,CAACiB,UAAJ,CAAe,gCAAf,CAAiD,wBAAjD,EAA2EC,IAA3E,CAAgF,SAASC,CAAT,CAAe,CAC3FpB,CAAC,CAAC,kBAAD,CAAD,CAAsBsB,IAAtB,CAA2BF,CAA3B,CACH,CAFD,CAGH,CAND,CAOH,CAbE,CAAP,CAeH,CAnBD,EAqBApB,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,4BAAD,CAAD,CAAgCqB,IAAhC,GAAuCC,IAAvC,CAA4CF,CAA5C,EAAkDG,MAAlD,EACH,CAFD,EAIAvB,CAAC,CAAC,0BAAD,CAAD,CAA8BK,IAA9B,CAAmC,UAAnC,CAA+C,EAA/C,CACH,CAND,CAOH,CAlCE,CAoCV,CArCK,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 $('.turnitinsim_eulacontainer').hide().html(text).fadeIn();\n\n str.get_string('submissiondisplaystatus:queued', 'plagiarism_turnitinsim').done(function(text) {\n $('.tii_status_text').html(text);\n });\n });\n }\n });\n });\n\n $(document).on('click', '#pp-eula-decline', function() {\n str.get_string('euladeclined', 'plagiarism_turnitinsim').done(function(text) {\n $('.turnitinsim_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 deleted file mode 100644 index 82b4464..0000000 --- a/amd/build/inbox_eula_launch.min.js +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index f846138..0000000 --- a/amd/build/inbox_eula_launch.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"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/src/eula_response.js b/amd/src/eula_response.js index 220f015..237623a 100644 --- a/amd/src/eula_response.js +++ b/amd/src/eula_response.js @@ -45,6 +45,10 @@ define(['jquery', 'core/str'], function($, str) { success: function() { str.get_string('eulaaccepted', 'plagiarism_turnitinsim').done(function(text) { $('.turnitinsim_eulacontainer').hide().html(text).fadeIn(); + + str.get_string('submissiondisplaystatus:queued', 'plagiarism_turnitinsim').done(function(text) { + $('.tii_status_text').html(text); + }); }); } }); diff --git a/amd/src/inbox_eula_launch.js b/amd/src/inbox_eula_launch.js deleted file mode 100644 index 1fd49de..0000000 --- a/amd/src/inbox_eula_launch.js +++ /dev/null @@ -1,39 +0,0 @@ -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see . - -/** - * @module plagiarism_turnitinsim/inbox_eula_launch - */ - -define(['jquery', - 'core/templates', - 'core/modal_factory', - 'plagiarism_turnitinsim/modal_eula' - ], - function($, Templates, ModalFactory, ModalTcEula) { - return { - inboxEulaLaunch: function() { - var trigger = $('.eula-row-launch'); - - ModalFactory.create( - { - type: ModalTcEula.TYPE - }, - trigger - ); - } - }; - } -); \ No newline at end of file diff --git a/classes/eula.class.php b/classes/eula.class.php index a0bb36f..1171414 100644 --- a/classes/eula.class.php +++ b/classes/eula.class.php @@ -116,4 +116,35 @@ public function accept_eula() { return json_encode(["success" => true]); } + + + /** + * This returns the HTML elements required to display a EULA_NOT_ACCEPTED status. + * + * @param int $cmid - course module id + * @return array The HTML elements for a EULA NOT ACCEPTED status. + * @throws coding_exception + * @throws dml_exception + */ + public function get_eula_status($cmid) { + global $OUTPUT; + + $eulaconfirm = ''; + if (!has_capability('plagiarism/turnitinsim:viewfullreport', context_module::instance($cmid))) { + $plagiarismpluginturnitinsim = new plagiarism_plugin_turnitinsim(); + $eulaconfirm = $plagiarismpluginturnitinsim->print_disclosure($cmid); + } + + $helpicon = $OUTPUT->pix_icon( + 'help', + get_string('submissiondisplayerror:eulanotaccepted_help', 'plagiarism_turnitinsim'), + 'core' + ); + + return array('eula-confirm' => $eulaconfirm, 'eula-status' => html_writer::tag( + 'span', + get_string('submissiondisplaystatus:awaitingeula', 'plagiarism_turnitinsim') . $helpicon, + array('class' => 'tii_status_text tii_status_text_eula') + )); + } } \ No newline at end of file diff --git a/lib.php b/lib.php index a5e1e18..4771a5f 100644 --- a/lib.php +++ b/lib.php @@ -235,6 +235,7 @@ public function get_links($linkarray) { // Display cv link and OR score or status. if ((!empty($linkarray['file'])) || (!empty($linkarray['content']))) { $submissionid = ''; + $eulaconfirm = ''; $showresubmitlink = false; $submission = null; @@ -290,9 +291,12 @@ public function get_links($linkarray) { break; case TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED: - - $status = $this->get_eula_status(); + $eula = new plagiarism_turnitinsim_eula(); + $statusset = $eula->get_eula_status($cm->id); + $status = $statusset['eula-status']; + $eulaconfirm = $statusset['eula-confirm']; $showresubmitlink = false; + break; case TURNITINSIM_SUBMISSION_STATUS_ERROR: @@ -347,7 +351,10 @@ public function get_links($linkarray) { $plagiarismfile = plagiarism_turnitinsim_submission::get_submission_details($linkarray); if ($plagiarismfile->status === TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED) { - $status = $this->get_eula_status(); + $eula = new plagiarism_turnitinsim_eula(); + $statusset = $eula->get_eula_status($cm->id); + $status = $statusset['eula-status']; + $eulaconfirm = $statusset['eula-confirm']; } else { $status = html_writer::tag('span', get_string('submissiondisplaystatus:queued', 'plagiarism_turnitinsim')); @@ -362,7 +369,7 @@ public function get_links($linkarray) { // Output rendered status and resubmission link if applicable. if ($instructor || (!$instructor && $plagiarismsettings->accessstudents)) { - $output .= html_writer::tag('div', $turnitinicon . $status . $resubmitlink, + $output .= html_writer::tag('div', $eulaconfirm . $turnitinicon . $status . $resubmitlink, array('class' => 'turnitinsim_status submission_' . $submissionid)); } } @@ -370,37 +377,6 @@ public function get_links($linkarray) { return html_writer::tag('div', $output, array('class' => 'turnitinsim_links')); } - /** - * This returns the HTML elements required to display a EULA_NOT_ACCEPTED status. - * - * @return string The HTML element for a EULA NOT ACCEPTED status. - * @throws coding_exception - * @throws dml_exception - */ - private function get_eula_status() { - global $OUTPUT; - - // Allow a modal to be launched with a EULA link and ability to accept. - $tsrequest = new plagiarism_turnitinsim_request(); - $lang = $tsrequest->get_language(); - $eulaurl = get_config('plagiarism_turnitinsim', 'turnitin_eula_url')."?lang=".$lang->localecode; - - $helpicon = $OUTPUT->pix_icon( - 'help', - get_string('submissiondisplayerror:eulanotaccepted_help', 'plagiarism_turnitinsim'), - 'core', - ['class' => 'eula-row-launch', 'data-eula-link' => $eulaurl] - ); - - $eulalaunch = ' '.$helpicon; - - return html_writer::tag( - 'span', - get_string('submissiondisplaystatus:awaitingeula', 'plagiarism_turnitinsim') . $eulalaunch, - array('class' => 'tii_status_text tii_status_text_eula') - ); - } - /** * Check whether the plugin is active. * @param object $cm The course module data. @@ -472,80 +448,88 @@ public function render_resubmit_link($submissionid) { public function print_disclosure($cmid) { global $CFG, $PAGE, $USER; - // Return empty output if the plugin is not being used. - if ($cmid > -1) { - $cm = get_coursemodule_from_id('', $cmid); - if (!$this->is_plugin_active($cm)) { - return ''; + // Avoid printing the EULA acceptance box more than once. + // Allowed for unit testing otherwise only the first test that calls this would work. + static $disclosurefirstrun = true; + if ($disclosurefirstrun || PHPUNIT_TEST) { + $disclosurefirstrun = false; + + // Return empty output if the plugin is not being used. + if ($cmid > -1) { + $cm = get_coursemodule_from_id('', $cmid); + if (!$this->is_plugin_active($cm)) { + return ''; + } } - } - // Check we have the latest version of the EULA stored. - // This should only happen the very first time someone submits. - $eulaversion = get_config('plagiarism_turnitinsim', 'turnitin_eula_version'); - // Overwrite mtrace so when EULA is checked it doesn't output to screen. - $CFG->mtrace_wrapper = 'plagiarism_turnitinsim_mtrace'; - if (empty($eulaversion)) { - $tstask = new plagiarism_turnitinsim_task(); - $tstask->check_latest_eula_version(); + // Check we have the latest version of the EULA stored. + // This should only happen the very first time someone submits. $eulaversion = get_config('plagiarism_turnitinsim', 'turnitin_eula_version'); - } + // Overwrite mtrace so when EULA is checked it doesn't output to screen. + $CFG->mtrace_wrapper = 'plagiarism_turnitinsim_mtrace'; + if (empty($eulaversion)) { + $tstask = new plagiarism_turnitinsim_task(); + $tstask->check_latest_eula_version(); + $eulaversion = get_config('plagiarism_turnitinsim', 'turnitin_eula_version'); + } - // We don't need to continue if the user has accepted the latest EULA and/or EULA acceptance is not required. - $user = new plagiarism_turnitinsim_user($USER->id); - $features = json_decode(get_config('plagiarism_turnitinsim', 'turnitin_features_enabled')); + // We don't need to continue if the user has accepted the latest EULA and/or EULA acceptance is not required. + $user = new plagiarism_turnitinsim_user($USER->id); + $features = json_decode(get_config('plagiarism_turnitinsim', 'turnitin_features_enabled')); - if ($user->get_lasteulaaccepted() == $eulaversion) { - return html_writer::tag( - 'div', - get_string('eulaalreadyaccepted', 'plagiarism_turnitinsim'), - array('class' => 'turnitinsim_eulacontainer', 'id' => 'turnitinsim_eulacontainer') + if ($user->get_lasteulaaccepted() == $eulaversion) { + return html_writer::tag( + 'div', + get_string('eulaalreadyaccepted', 'plagiarism_turnitinsim'), + array('class' => 'turnitinsim_eulacontainer', 'id' => 'turnitinsim_eulacontainer') + ); + } + + if (!(bool)$features->tenant->require_eula) { + return html_writer::tag( + 'div', + get_string('eulanotrequired', 'plagiarism_turnitinsim'), + array('class' => 'turnitinsim_eulacontainer', 'id' => 'turnitinsim_eulacontainer') + ); + } + + // 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->string_for_js('submissiondisplaystatus:queued', 'plagiarism_turnitinsim'); + $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(); + $lang = $tsrequest->get_language(); + $eulaurl = get_config('plagiarism_turnitinsim', 'turnitin_eula_url')."?lang=".$lang->localecode; + $eulastring = ($cmid > -1) ? 'eulalink' : 'eulalinkgeneric'; + $eulalink = get_string($eulastring, 'plagiarism_turnitinsim', $eulaurl); + + // Button to allow the user to accept the Turnitin EULA. + $eulaacceptbtn = html_writer::tag('span', + get_string('eulaaccept', 'plagiarism_turnitinsim'), + array('class' => 'btn btn-primary', 'id' => 'pp-eula-accept') + ); + + // Button to allow the user to decline the Turnitin EULA. + $euladeclinebtn = html_writer::tag('span', + get_string('euladecline', 'plagiarism_turnitinsim'), + array('class' => 'btn btn-secondary', 'id' => 'pp-eula-decline') ); - } - if (!(bool)$features->tenant->require_eula) { - return html_writer::tag( + // Output EULA container. + $output = html_writer::tag( 'div', - get_string('eulanotrequired', 'plagiarism_turnitinsim'), + html_writer::tag( + 'p', + $eulalink + ).$eulaacceptbtn.$euladeclinebtn, array('class' => 'turnitinsim_eulacontainer', 'id' => 'turnitinsim_eulacontainer') ); - } - - // 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', 'eulaResponse'); - - // Link to open the Turnitin EULA in a new tab. - $tsrequest = new plagiarism_turnitinsim_request(); - $lang = $tsrequest->get_language(); - $eulaurl = get_config('plagiarism_turnitinsim', 'turnitin_eula_url')."?lang=".$lang->localecode; - $eulastring = ($cmid > -1) ? 'eulalink' : 'eulalinkgeneric'; - $eulalink = get_string($eulastring, 'plagiarism_turnitinsim', $eulaurl); - - // Button to allow the user to accept the Turnitin EULA. - $eulaacceptbtn = html_writer::tag('button', - get_string('eulaaccept', 'plagiarism_turnitinsim'), - array('class' => 'btn btn-primary', 'id' => 'pp-eula-accept') - ); - - // Button to allow the user to decline the Turnitin EULA. - $euladeclinebtn = html_writer::tag('button', - get_string('euladecline', 'plagiarism_turnitinsim'), - array('class' => 'btn btn-secondary', 'id' => 'pp-eula-decline') - ); - // Output EULA container. - $output = html_writer::tag( - 'div', - html_writer::tag( - 'p', - $eulalink - ).$eulaacceptbtn.$euladeclinebtn, - array('class' => 'turnitinsim_eulacontainer', 'id' => 'turnitinsim_eulacontainer') - ); - - return $output; + return $output; + } } /** diff --git a/templates/modal_eula.mustache b/templates/modal_eula.mustache deleted file mode 100644 index e639214..0000000 --- a/templates/modal_eula.mustache +++ /dev/null @@ -1,49 +0,0 @@ -{{! - This file is part of Moodle - http://moodle.org/ - - Moodle is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Moodle is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - 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. - - Classes required for JS: - * none - - Data attributes required for JS: - * none - - Context variables required for this template: - * title Content for the title - * body Content for the body - * footer Content for the footer - - Example context (json): - { - "title": "Example modal", - "body": "Some example content for the body", - "footer": "Accept, decline buttons." - } -}} -{{< core/modal }} - {{$title}}{{# str }} eulaheader, plagiarism_turnitinsim {{/ str }}{{/title}} - {{$body}} -

{{# str }} eulalinkmodal, plagiarism_turnitinsim {{/ str }}

- {{/body}} - {{$footer}} - - - {{/footer}} -{{/ core/modal }} \ No newline at end of file diff --git a/tests/classes/eula.class_test.php b/tests/classes/eula.class_test.php index 90a3790..56f75cb 100644 --- a/tests/classes/eula.class_test.php +++ b/tests/classes/eula.class_test.php @@ -52,128 +52,243 @@ public function setUp(): void { /** * Test get latest eula version failed request to Turnitin. */ - public function test_get_latest_version_failure() { - $this->resetAfterTest(); - - // Get the response for a failed EULA version retrieval. - $response = file_get_contents(__DIR__ . '/../fixtures/get_latest_eula_version_failure.json'); - - // Mock API request class. - $tsrequest = $this->getMockBuilder(plagiarism_turnitinsim_request::class) - ->setMethods(['send_request']) - ->setConstructorArgs([TURNITINSIM_ENDPOINT_GET_LATEST_EULA]) - ->getMock(); - - // Mock API send request method. - $tsrequest->expects($this->once()) - ->method('send_request') - ->willReturn($response); - - // Get latest EULA version. - $tseula = new plagiarism_turnitinsim_eula( $tsrequest ); - $result = $tseula->get_latest_version(); - - // Test that the EULA version has not been retrieved. - $this->assertFalse(isset($result->version)); - } +// public function test_get_latest_version_failure() { +// $this->resetAfterTest(); +// +// // Get the response for a failed EULA version retrieval. +// $response = file_get_contents(__DIR__ . '/../fixtures/get_latest_eula_version_failure.json'); +// +// // Mock API request class. +// $tsrequest = $this->getMockBuilder(plagiarism_turnitinsim_request::class) +// ->setMethods(['send_request']) +// ->setConstructorArgs([TURNITINSIM_ENDPOINT_GET_LATEST_EULA]) +// ->getMock(); +// +// // Mock API send request method. +// $tsrequest->expects($this->once()) +// ->method('send_request') +// ->willReturn($response); +// +// // Get latest EULA version. +// $tseula = new plagiarism_turnitinsim_eula( $tsrequest ); +// $result = $tseula->get_latest_version(); +// +// // Test that the EULA version has not been retrieved. +// $this->assertFalse(isset($result->version)); +// } +// +// /** +// * Test get latest eula version request to Turnitin fails with exception. +// */ +// public function test_get_latest_version_exception() { +// $this->resetAfterTest(); +// +// // Mock API request class. +// $tsrequest = $this->getMockBuilder(plagiarism_turnitinsim_request::class) +// ->setMethods(['send_request']) +// ->setConstructorArgs([TURNITINSIM_ENDPOINT_GET_LATEST_EULA]) +// ->getMock(); +// +// // Mock API send request method. +// $tsrequest->expects($this->once()) +// ->method('send_request') +// ->will($this->throwException(new Exception())); +// +// // Get the latest EULA version. +// $tseula = new plagiarism_turnitinsim_eula($tsrequest); +// $result = $tseula->get_latest_version(); +// +// // Test that the latest EULA version has not been retrieved. +// $this->assertFalse(isset($result->version)); +// } +// +// /** +// * Test get latest eula version success request to Turnitin. +// */ +// public function test_get_latest_version_success() { +// $this->resetAfterTest(); +// +// // Get the response for a failed EULA version retrieval. +// $response = file_get_contents(__DIR__ . '/../fixtures/get_latest_eula_version_success.json'); +// +// // Mock API request class. +// $tsrequest = $this->getMockBuilder(plagiarism_turnitinsim_request::class) +// ->setMethods(['send_request']) +// ->setConstructorArgs([TURNITINSIM_ENDPOINT_GET_LATEST_EULA]) +// ->getMock(); +// +// // Mock API send request method. +// $tsrequest->expects($this->once()) +// ->method('send_request') +// ->willReturn($response); +// +// // Get the latest EULA version. +// $tseula = new plagiarism_turnitinsim_eula( $tsrequest ); +// $result = $tseula->get_latest_version(); +// +// // Test that the latest EULA version has been retrieved. +// $this->assertTrue(isset($result->version)); +// } +// +// /** +// * Test accept EULA updates the status of the EULA for all of a student's submissions. +// */ +// public function test_accept_eula_saves_eula_and_updates_submissions() { +// global $DB; +// +// $this->resetAfterTest(); +// +// set_config('turnitin_eula_version', 'v1beta', 'plagiarism_turnitinsim'); +// +// // Create 3 submissions. +// $this->turnitinsim_generator = new turnitinsim_generator(); +// $submission = $this->turnitinsim_generator->create_submission(3, TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED); +// +// $this->setUser($submission['student']); +// +// // Insert a user to the TII table. +// $user = new stdClass(); +// $user->userid = $submission['student']->id; +// $user->turnitinid = (new handle_deprecation)->create_uuid(); +// $DB->insert_record('plagiarism_turnitinsim_users', $user); +// +// // Check the data. +// $submissions = $DB->get_records('plagiarism_turnitinsim_sub'); +// $this->assertCount(3, $submissions); +// +// $users = $DB->get_records('plagiarism_turnitinsim_users'); +// $this->assertCount(1, $users); +// +// // Accept the EULA. +// $tseula = new plagiarism_turnitinsim_eula(); +// $result = json_decode($tseula->accept_eula()); +// $this->assertEquals(true, $result->success); +// +// // Check the results. +// $userresult = $DB->get_record('plagiarism_turnitinsim_users', array('userid' => $user->userid)); +// $this->assertEquals('v1beta', $userresult->lasteulaaccepted); +// $this->assertGreaterThan('lasteulaacceptedtime', time() - 60); +// $this->assertEquals('en-US', $userresult->lasteulaacceptedlang); +// +// $submissionresult = $DB->get_records( +// 'plagiarism_turnitinsim_sub', +// array('status' => TURNITINSIM_SUBMISSION_STATUS_QUEUED) +// ); +// $this->assertCount(3, $submissionresult); +// } /** - * Test get latest eula version request to Turnitin fails with exception. + * Test get_eula_status returns expected output for student. */ - public function test_get_latest_version_exception() { + public function test_get_eula_status_for_student() { + global $DB; + $this->resetAfterTest(); - // Mock API request class. - $tsrequest = $this->getMockBuilder(plagiarism_turnitinsim_request::class) - ->setMethods(['send_request']) - ->setConstructorArgs([TURNITINSIM_ENDPOINT_GET_LATEST_EULA]) - ->getMock(); + // Set the features enabled. + $featuresenabled = file_get_contents(__DIR__ . '/../fixtures/get_features_enabled_success.json'); + set_config('turnitin_features_enabled', $featuresenabled, 'plagiarism_turnitinsim'); + set_config('turnitin_eula_version', 'v1-beta', 'plagiarism_turnitinsim'); - // Mock API send request method. - $tsrequest->expects($this->once()) - ->method('send_request') - ->will($this->throwException(new Exception())); + // Create a course. + $this->course = $this->getDataGenerator()->create_course(); - // Get the latest EULA version. - $tseula = new plagiarism_turnitinsim_eula($tsrequest); - $result = $tseula->get_latest_version(); + // Create student and enrol on course. + $studentrole = $DB->get_record('role', array('shortname' => 'student')); + $this->student = $this->getDataGenerator()->create_user(); + $this->getDataGenerator()->enrol_user($this->student->id, + $this->course->id, + $studentrole->id + ); - // Test that the latest EULA version has not been retrieved. - $this->assertFalse(isset($result->version)); - } + // Log new user in. + $this->setUser($this->student); - /** - * Test get latest eula version success request to Turnitin. - */ - public function test_get_latest_version_success() { - $this->resetAfterTest(); + // Create assign module. + $record = new stdClass(); + $record->course = $this->course; + $module = $this->getDataGenerator()->create_module('assign', $record); - // Get the response for a failed EULA version retrieval. - $response = file_get_contents(__DIR__ . '/../fixtures/get_latest_eula_version_success.json'); + // Get course module data. + $cm = get_coursemodule_from_instance('assign', $module->id); + $context = context_module::instance($cm->id); + $assign = new assign($context, $cm, $record->course); - // Mock API request class. - $tsrequest = $this->getMockBuilder(plagiarism_turnitinsim_request::class) - ->setMethods(['send_request']) - ->setConstructorArgs([TURNITINSIM_ENDPOINT_GET_LATEST_EULA]) - ->getMock(); + // Set plugin config. + plagiarism_plugin_turnitinsim::enable_plugin(1); + set_config('turnitinmodenabledassign', 1, 'plagiarism_turnitinsim'); - // Mock API send request method. - $tsrequest->expects($this->once()) - ->method('send_request') - ->willReturn($response); + // Enable plugin for module. + $modsettings = array('cm' => $cm->id, 'turnitinenabled' => 1); + $DB->insert_record('plagiarism_turnitinsim_mod', $modsettings); - // Get the latest EULA version. - $tseula = new plagiarism_turnitinsim_eula( $tsrequest ); - $result = $tseula->get_latest_version(); + // Get course module data. + $cm = get_coursemodule_from_instance('assign', $module->id); - // Test that the latest EULA version has been retrieved. - $this->assertTrue(isset($result->version)); + $tseula = new plagiarism_turnitinsim_eula(); + $result = $tseula->get_eula_status($cm->id); + + handle_deprecation::assertContains($this, get_string('eulalink', 'plagiarism_turnitinsim', '?lang=en-US'), $result['eula-confirm']); + handle_deprecation::assertContains($this, get_string('submissiondisplayerror:eulanotaccepted_help', 'plagiarism_turnitinsim'), $result['eula-status']); } /** - * Test accept EULA updates the status of the EULA for all of a student's submissions. + * Test get_eula_status returns expected output for instructor. */ - public function test_accept_eula_saves_eula_and_updates_submissions() { + public function test_get_eula_status_for_instructor() { global $DB; $this->resetAfterTest(); - set_config('turnitin_eula_version', 'v1beta', 'plagiarism_turnitinsim'); + // Set the features enabled. + $featuresenabled = file_get_contents(__DIR__ . '/../fixtures/get_features_enabled_success.json'); + set_config('turnitin_features_enabled', $featuresenabled, 'plagiarism_turnitinsim'); + set_config('turnitin_eula_version', 'v1-beta', 'plagiarism_turnitinsim'); + + // Create a course. + $this->course = $this->getDataGenerator()->create_course(); - // Create 3 submissions. - $this->turnitinsim_generator = new turnitinsim_generator(); - $submission = $this->turnitinsim_generator->create_submission(3, TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED); + // Create instructor and enrol on course. + $this->instructor = $this->getDataGenerator()->create_user(); + $instructorrole = $DB->get_record('role', array('shortname' => 'teacher')); + $this->getDataGenerator()->enrol_user($this->instructor->id, + $this->course->id, + $instructorrole->id + ); + + // Assign capability to instructor to view full reports at course level. + $context = context_course::instance($this->course->id); + assign_capability('plagiarism/turnitinsim:viewfullreport', CAP_ALLOW, $instructorrole->id, $context->id); + role_assign($instructorrole->id, $this->instructor->id, $context->id); + accesslib_clear_all_caches_for_unit_testing(); + + // Log new user in. + $this->setUser($this->instructor); - $this->setUser($submission['student']); + // Create assign module. + $record = new stdClass(); + $record->course = $this->course; + $module = $this->getDataGenerator()->create_module('assign', $record); - // Insert a user to the TII table. - $user = new stdClass(); - $user->userid = $submission['student']->id; - $user->turnitinid = (new handle_deprecation)->create_uuid(); - $DB->insert_record('plagiarism_turnitinsim_users', $user); + // Get course module data. + $cm = get_coursemodule_from_instance('assign', $module->id); + $context = context_module::instance($cm->id); - // Check the data. - $submissions = $DB->get_records('plagiarism_turnitinsim_sub'); - $this->assertCount(3, $submissions); + // Set plugin config. + plagiarism_plugin_turnitinsim::enable_plugin(1); + set_config('turnitinmodenabledassign', 1, 'plagiarism_turnitinsim'); - $users = $DB->get_records('plagiarism_turnitinsim_users'); - $this->assertCount(1, $users); + // Enable plugin for module. + $modsettings = array('cm' => $cm->id, 'turnitinenabled' => 1); + $DB->insert_record('plagiarism_turnitinsim_mod', $modsettings); + + // Get course module data. + $cm = get_coursemodule_from_instance('assign', $module->id); - // Accept the EULA. $tseula = new plagiarism_turnitinsim_eula(); - $result = json_decode($tseula->accept_eula()); - $this->assertEquals(true, $result->success); - - // Check the results. - $userresult = $DB->get_record('plagiarism_turnitinsim_users', array('userid' => $user->userid)); - $this->assertEquals('v1beta', $userresult->lasteulaaccepted); - $this->assertGreaterThan('lasteulaacceptedtime', time() - 60); - $this->assertEquals('en-US', $userresult->lasteulaacceptedlang); - - $submissionresult = $DB->get_records( - 'plagiarism_turnitinsim_sub', - array('status' => TURNITINSIM_SUBMISSION_STATUS_QUEUED) - ); - $this->assertCount(3, $submissionresult); + $result = $tseula->get_eula_status($cm->id); + + $this->assertEmpty($result['eula-confirm']); + handle_deprecation::assertContains($this, get_string('submissiondisplayerror:eulanotaccepted_help', 'plagiarism_turnitinsim'), $result['eula-status']); } } \ No newline at end of file diff --git a/tests/lib_test.php b/tests/lib_test.php index 21289b6..c53df10 100644 --- a/tests/lib_test.php +++ b/tests/lib_test.php @@ -29,6 +29,7 @@ require_once($CFG->dirroot . '/plagiarism/turnitinsim/lib.php'); require_once($CFG->dirroot . '/plagiarism/turnitinsim/classes/setup_form.class.php'); require_once($CFG->dirroot . '/plagiarism/turnitinsim/utilities/handle_deprecation.php'); +require_once($CFG->dirroot . '/plagiarism/turnitinsim/tests/utilities.php'); /** * Tests for lib methods. diff --git a/utilities/handle_deprecation.php b/utilities/handle_deprecation.php index e455cb6..1c8933d 100644 --- a/utilities/handle_deprecation.php +++ b/utilities/handle_deprecation.php @@ -125,6 +125,7 @@ public static function download_data($exportfile, $dataformat, $columns, $data) */ public static function assertContains($object, $needle, $haystack) { global $CFG; +//echo $haystack; $CFG->branch >= 37 ? $object->assertStringContainsString($needle, $haystack) : $object->assertContains($needle, $haystack); From eff720e96ebb986b342448e77b56aa19a5bb44d3 Mon Sep 17 00:00:00 2001 From: David Winn Date: Wed, 13 Jan 2021 16:53:22 +0000 Subject: [PATCH 39/42] Uncommenting test code that needs to be there. --- tests/classes/eula.class_test.php | 248 +++++++++++++++--------------- utilities/handle_deprecation.php | 1 - 2 files changed, 124 insertions(+), 125 deletions(-) diff --git a/tests/classes/eula.class_test.php b/tests/classes/eula.class_test.php index 56f75cb..a1cb0ff 100644 --- a/tests/classes/eula.class_test.php +++ b/tests/classes/eula.class_test.php @@ -52,130 +52,130 @@ public function setUp(): void { /** * Test get latest eula version failed request to Turnitin. */ -// public function test_get_latest_version_failure() { -// $this->resetAfterTest(); -// -// // Get the response for a failed EULA version retrieval. -// $response = file_get_contents(__DIR__ . '/../fixtures/get_latest_eula_version_failure.json'); -// -// // Mock API request class. -// $tsrequest = $this->getMockBuilder(plagiarism_turnitinsim_request::class) -// ->setMethods(['send_request']) -// ->setConstructorArgs([TURNITINSIM_ENDPOINT_GET_LATEST_EULA]) -// ->getMock(); -// -// // Mock API send request method. -// $tsrequest->expects($this->once()) -// ->method('send_request') -// ->willReturn($response); -// -// // Get latest EULA version. -// $tseula = new plagiarism_turnitinsim_eula( $tsrequest ); -// $result = $tseula->get_latest_version(); -// -// // Test that the EULA version has not been retrieved. -// $this->assertFalse(isset($result->version)); -// } -// -// /** -// * Test get latest eula version request to Turnitin fails with exception. -// */ -// public function test_get_latest_version_exception() { -// $this->resetAfterTest(); -// -// // Mock API request class. -// $tsrequest = $this->getMockBuilder(plagiarism_turnitinsim_request::class) -// ->setMethods(['send_request']) -// ->setConstructorArgs([TURNITINSIM_ENDPOINT_GET_LATEST_EULA]) -// ->getMock(); -// -// // Mock API send request method. -// $tsrequest->expects($this->once()) -// ->method('send_request') -// ->will($this->throwException(new Exception())); -// -// // Get the latest EULA version. -// $tseula = new plagiarism_turnitinsim_eula($tsrequest); -// $result = $tseula->get_latest_version(); -// -// // Test that the latest EULA version has not been retrieved. -// $this->assertFalse(isset($result->version)); -// } -// -// /** -// * Test get latest eula version success request to Turnitin. -// */ -// public function test_get_latest_version_success() { -// $this->resetAfterTest(); -// -// // Get the response for a failed EULA version retrieval. -// $response = file_get_contents(__DIR__ . '/../fixtures/get_latest_eula_version_success.json'); -// -// // Mock API request class. -// $tsrequest = $this->getMockBuilder(plagiarism_turnitinsim_request::class) -// ->setMethods(['send_request']) -// ->setConstructorArgs([TURNITINSIM_ENDPOINT_GET_LATEST_EULA]) -// ->getMock(); -// -// // Mock API send request method. -// $tsrequest->expects($this->once()) -// ->method('send_request') -// ->willReturn($response); -// -// // Get the latest EULA version. -// $tseula = new plagiarism_turnitinsim_eula( $tsrequest ); -// $result = $tseula->get_latest_version(); -// -// // Test that the latest EULA version has been retrieved. -// $this->assertTrue(isset($result->version)); -// } -// -// /** -// * Test accept EULA updates the status of the EULA for all of a student's submissions. -// */ -// public function test_accept_eula_saves_eula_and_updates_submissions() { -// global $DB; -// -// $this->resetAfterTest(); -// -// set_config('turnitin_eula_version', 'v1beta', 'plagiarism_turnitinsim'); -// -// // Create 3 submissions. -// $this->turnitinsim_generator = new turnitinsim_generator(); -// $submission = $this->turnitinsim_generator->create_submission(3, TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED); -// -// $this->setUser($submission['student']); -// -// // Insert a user to the TII table. -// $user = new stdClass(); -// $user->userid = $submission['student']->id; -// $user->turnitinid = (new handle_deprecation)->create_uuid(); -// $DB->insert_record('plagiarism_turnitinsim_users', $user); -// -// // Check the data. -// $submissions = $DB->get_records('plagiarism_turnitinsim_sub'); -// $this->assertCount(3, $submissions); -// -// $users = $DB->get_records('plagiarism_turnitinsim_users'); -// $this->assertCount(1, $users); -// -// // Accept the EULA. -// $tseula = new plagiarism_turnitinsim_eula(); -// $result = json_decode($tseula->accept_eula()); -// $this->assertEquals(true, $result->success); -// -// // Check the results. -// $userresult = $DB->get_record('plagiarism_turnitinsim_users', array('userid' => $user->userid)); -// $this->assertEquals('v1beta', $userresult->lasteulaaccepted); -// $this->assertGreaterThan('lasteulaacceptedtime', time() - 60); -// $this->assertEquals('en-US', $userresult->lasteulaacceptedlang); -// -// $submissionresult = $DB->get_records( -// 'plagiarism_turnitinsim_sub', -// array('status' => TURNITINSIM_SUBMISSION_STATUS_QUEUED) -// ); -// $this->assertCount(3, $submissionresult); -// } + public function test_get_latest_version_failure() { + $this->resetAfterTest(); + + // Get the response for a failed EULA version retrieval. + $response = file_get_contents(__DIR__ . '/../fixtures/get_latest_eula_version_failure.json'); + + // Mock API request class. + $tsrequest = $this->getMockBuilder(plagiarism_turnitinsim_request::class) + ->setMethods(['send_request']) + ->setConstructorArgs([TURNITINSIM_ENDPOINT_GET_LATEST_EULA]) + ->getMock(); + + // Mock API send request method. + $tsrequest->expects($this->once()) + ->method('send_request') + ->willReturn($response); + + // Get latest EULA version. + $tseula = new plagiarism_turnitinsim_eula( $tsrequest ); + $result = $tseula->get_latest_version(); + + // Test that the EULA version has not been retrieved. + $this->assertFalse(isset($result->version)); + } + + /** + * Test get latest eula version request to Turnitin fails with exception. + */ + public function test_get_latest_version_exception() { + $this->resetAfterTest(); + + // Mock API request class. + $tsrequest = $this->getMockBuilder(plagiarism_turnitinsim_request::class) + ->setMethods(['send_request']) + ->setConstructorArgs([TURNITINSIM_ENDPOINT_GET_LATEST_EULA]) + ->getMock(); + + // Mock API send request method. + $tsrequest->expects($this->once()) + ->method('send_request') + ->will($this->throwException(new Exception())); + + // Get the latest EULA version. + $tseula = new plagiarism_turnitinsim_eula($tsrequest); + $result = $tseula->get_latest_version(); + + // Test that the latest EULA version has not been retrieved. + $this->assertFalse(isset($result->version)); + } + + /** + * Test get latest eula version success request to Turnitin. + */ + public function test_get_latest_version_success() { + $this->resetAfterTest(); + + // Get the response for a failed EULA version retrieval. + $response = file_get_contents(__DIR__ . '/../fixtures/get_latest_eula_version_success.json'); + + // Mock API request class. + $tsrequest = $this->getMockBuilder(plagiarism_turnitinsim_request::class) + ->setMethods(['send_request']) + ->setConstructorArgs([TURNITINSIM_ENDPOINT_GET_LATEST_EULA]) + ->getMock(); + + // Mock API send request method. + $tsrequest->expects($this->once()) + ->method('send_request') + ->willReturn($response); + + // Get the latest EULA version. + $tseula = new plagiarism_turnitinsim_eula( $tsrequest ); + $result = $tseula->get_latest_version(); + + // Test that the latest EULA version has been retrieved. + $this->assertTrue(isset($result->version)); + } + + /** + * Test accept EULA updates the status of the EULA for all of a student's submissions. + */ + public function test_accept_eula_saves_eula_and_updates_submissions() { + global $DB; + + $this->resetAfterTest(); + + set_config('turnitin_eula_version', 'v1beta', 'plagiarism_turnitinsim'); + + // Create 3 submissions. + $this->turnitinsim_generator = new turnitinsim_generator(); + $submission = $this->turnitinsim_generator->create_submission(3, TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED); + + $this->setUser($submission['student']); + + // Insert a user to the TII table. + $user = new stdClass(); + $user->userid = $submission['student']->id; + $user->turnitinid = (new handle_deprecation)->create_uuid(); + $DB->insert_record('plagiarism_turnitinsim_users', $user); + + // Check the data. + $submissions = $DB->get_records('plagiarism_turnitinsim_sub'); + $this->assertCount(3, $submissions); + + $users = $DB->get_records('plagiarism_turnitinsim_users'); + $this->assertCount(1, $users); + + // Accept the EULA. + $tseula = new plagiarism_turnitinsim_eula(); + $result = json_decode($tseula->accept_eula()); + $this->assertEquals(true, $result->success); + + // Check the results. + $userresult = $DB->get_record('plagiarism_turnitinsim_users', array('userid' => $user->userid)); + $this->assertEquals('v1beta', $userresult->lasteulaaccepted); + $this->assertGreaterThan('lasteulaacceptedtime', time() - 60); + $this->assertEquals('en-US', $userresult->lasteulaacceptedlang); + + $submissionresult = $DB->get_records( + 'plagiarism_turnitinsim_sub', + array('status' => TURNITINSIM_SUBMISSION_STATUS_QUEUED) + ); + $this->assertCount(3, $submissionresult); + } /** * Test get_eula_status returns expected output for student. diff --git a/utilities/handle_deprecation.php b/utilities/handle_deprecation.php index 1c8933d..e455cb6 100644 --- a/utilities/handle_deprecation.php +++ b/utilities/handle_deprecation.php @@ -125,7 +125,6 @@ public static function download_data($exportfile, $dataformat, $columns, $data) */ public static function assertContains($object, $needle, $haystack) { global $CFG; -//echo $haystack; $CFG->branch >= 37 ? $object->assertStringContainsString($needle, $haystack) : $object->assertContains($needle, $haystack); From 7aa45dddf015cfac37f4d8c7ac9313af59c8412a Mon Sep 17 00:00:00 2001 From: David Winn Date: Thu, 14 Jan 2021 11:15:52 +0000 Subject: [PATCH 40/42] Allow an extra disclosure for text submissions --- classes/eula.class.php | 5 +++-- lib.php | 16 ++++++++++------ tests/classes/eula.class_test.php | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/classes/eula.class.php b/classes/eula.class.php index 1171414..8d033b7 100644 --- a/classes/eula.class.php +++ b/classes/eula.class.php @@ -122,17 +122,18 @@ public function accept_eula() { * This returns the HTML elements required to display a EULA_NOT_ACCEPTED status. * * @param int $cmid - course module id + * @param string $submissiontype - The type of submission - file or content. * @return array The HTML elements for a EULA NOT ACCEPTED status. * @throws coding_exception * @throws dml_exception */ - public function get_eula_status($cmid) { + public function get_eula_status($cmid, $submissiontype) { global $OUTPUT; $eulaconfirm = ''; if (!has_capability('plagiarism/turnitinsim:viewfullreport', context_module::instance($cmid))) { $plagiarismpluginturnitinsim = new plagiarism_plugin_turnitinsim(); - $eulaconfirm = $plagiarismpluginturnitinsim->print_disclosure($cmid); + $eulaconfirm = $plagiarismpluginturnitinsim->print_disclosure($cmid, $submissiontype); } $helpicon = $OUTPUT->pix_icon( diff --git a/lib.php b/lib.php index 4771a5f..6c8e8b2 100644 --- a/lib.php +++ b/lib.php @@ -292,7 +292,7 @@ public function get_links($linkarray) { case TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED: $eula = new plagiarism_turnitinsim_eula(); - $statusset = $eula->get_eula_status($cm->id); + $statusset = $eula->get_eula_status($cm->id, $submission->gettype()); $status = $statusset['eula-status']; $eulaconfirm = $statusset['eula-confirm']; $showresubmitlink = false; @@ -352,7 +352,7 @@ public function get_links($linkarray) { if ($plagiarismfile->status === TURNITINSIM_SUBMISSION_STATUS_EULA_NOT_ACCEPTED) { $eula = new plagiarism_turnitinsim_eula(); - $statusset = $eula->get_eula_status($cm->id); + $statusset = $eula->get_eula_status($cm->id, $submission->gettype()); $status = $statusset['eula-status']; $eulaconfirm = $statusset['eula-confirm']; } else { @@ -441,18 +441,22 @@ public function render_resubmit_link($submissionid) { * Hook to allow a disclosure to be printed notifying users what will happen with their submission. * * @param int $cmid - course module id + * @param string $submissiontype - The type of submission - file or content. * @return string * @throws coding_exception * @throws dml_exception */ - public function print_disclosure($cmid) { + public function print_disclosure($cmid, $submissiontype = 'file') { global $CFG, $PAGE, $USER; // Avoid printing the EULA acceptance box more than once. + // This needs to be shown twice for a text submission as it exists in the dom twice. // Allowed for unit testing otherwise only the first test that calls this would work. - static $disclosurefirstrun = true; - if ($disclosurefirstrun || PHPUNIT_TEST) { - $disclosurefirstrun = false; + static $disclosurecount = 1; + if (($submissiontype == 'file' && $disclosurecount === 1) || + ($submissiontype == 'content' && $disclosurecount <= 2) || + PHPUNIT_TEST) { + $disclosurecount++; // Return empty output if the plugin is not being used. if ($cmid > -1) { diff --git a/tests/classes/eula.class_test.php b/tests/classes/eula.class_test.php index a1cb0ff..e55b882 100644 --- a/tests/classes/eula.class_test.php +++ b/tests/classes/eula.class_test.php @@ -226,7 +226,7 @@ public function test_get_eula_status_for_student() { $cm = get_coursemodule_from_instance('assign', $module->id); $tseula = new plagiarism_turnitinsim_eula(); - $result = $tseula->get_eula_status($cm->id); + $result = $tseula->get_eula_status($cm->id, 'file'); handle_deprecation::assertContains($this, get_string('eulalink', 'plagiarism_turnitinsim', '?lang=en-US'), $result['eula-confirm']); handle_deprecation::assertContains($this, get_string('submissiondisplayerror:eulanotaccepted_help', 'plagiarism_turnitinsim'), $result['eula-status']); @@ -286,7 +286,7 @@ public function test_get_eula_status_for_instructor() { $cm = get_coursemodule_from_instance('assign', $module->id); $tseula = new plagiarism_turnitinsim_eula(); - $result = $tseula->get_eula_status($cm->id); + $result = $tseula->get_eula_status($cm->id, 'file'); $this->assertEmpty($result['eula-confirm']); handle_deprecation::assertContains($this, get_string('submissiondisplayerror:eulanotaccepted_help', 'plagiarism_turnitinsim'), $result['eula-status']); From 3528391aee67c318b8a136740e73a231802c786a Mon Sep 17 00:00:00 2001 From: David Winn Date: Thu, 14 Jan 2021 16:43:06 +0000 Subject: [PATCH 41/42] Remove inbox_eula_launch --- lib.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib.php b/lib.php index 6c8e8b2..6701f04 100644 --- a/lib.php +++ b/lib.php @@ -170,7 +170,6 @@ public function get_links($linkarray) { $PAGE->requires->string_for_js('submissiondisplaystatus:queued', 'plagiarism_turnitinsim'); $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', 'inboxEulaLaunch'); } $output = ''; From e1e548c912b639d9d59741eaf1ad8ec86a64d6dc Mon Sep 17 00:00:00 2001 From: David Winn Date: Mon, 18 Jan 2021 11:17:39 +0000 Subject: [PATCH 42/42] Release 2021011801 --- CHANGELOG.md | 55 ++++++++++++++++++++++ classes/callback.class.php | 2 +- lib.php | 2 +- tests/classes/defaults_form_class_test.php | 2 +- tests/classes/eula.class_test.php | 9 ++-- tests/classes/setup_form_class_test.php | 6 +-- tests/classes/submission_class_test.php | 20 ++++---- tests/lib_test.php | 38 ++++++++------- tests/turnitinsim_generator.php | 1 + utilities/handle_deprecation.php | 8 ++-- version.php | 2 +- 11 files changed, 103 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be9c064..68280c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,58 @@ +### Date: 2021-January-18 +### Release: v2021011801 + +#### :zap: What's new + +--- + +#### Support for Moodle 3.10 + +You can now confidently use Turnitin with Moodle 3.10. + +#### Improved loading screen for the Turnitin Integrity Viewer + +We’ve improved the loading screen you see when you launch the Turnitin Integrity viewer. The new loading screen includes an animation to indicate that the viewer is still opening and will be ready soon. + +You can use this new animation to tell if something may have gone wrong and needs to be investigated. + +#### Styling and workflow improvements to the Turnitin EULA + +We haven’t made any changes to the EULA itself, but we have adjusted the styling of the box that is shown to ask you to review and accept it when a user first uses Turnitin. We’ve also taken the opportunity to fix a few bugs that could interrupt the intended EULA workflow + +#### Get Help in all of Turnitin’s supported languages + +Did you know we offer full step-by-step guidance for all Turnitin features? You’ll find direct links to the pages relevant for the language you view the Turnitin Integrity plugin in. + +#### Use Turnitin with older submissions + +If you enable Turnitin for an assignment after submissions have already been made, we will now queue these for report generation the next time you view the inbox in Moodle. These files will have the QUEUED status. If a student has not accepted the Turnitin EULA yet, we will instead show Awaiting EULA and will only process the file after the student has accepted it. + +#### :wrench: Fixes and enhancements + +--- + +#### Assignment settings have the correct spacing + +The Turnitin settings configured when creating a Moodle assignment could have odd spacing. We’ve cleaned this up so the settings flow as they should. + +#### Feedback and Intro files will no longer be checked for similarity + +We no longer check any feedback or intro files you attach to an assignment for your students for similarity. + +#### Deleting a course module will now also delete any attached Turnitin submissions + +If a course module is deleted, along with its Moodle Assignments, we will now also delete any relevant Turnitin settings or entries in our database. + +#### dateformat now uses the correct format + +Thanks to our friends at OpenLMS who let us know that the download_as_dataformat() method was deprecated in Moodle 3.9. We’ve now updated this to the latest code to ensure everything works correctly for all users. + +#### Accept the Turnitin EULA once for all assignment types + +The EULA could show multiple times for each type of Moodle assignment. Now users only have to accept it once and we will remember this choice when generating Similarity Reports for Moodle Assignments, Workshops, Forums, and quizzes. + +--- + ### Date: 2020-September-23 ### Release: v2020092301 diff --git a/classes/callback.class.php b/classes/callback.class.php index 3b34727..1f05e17 100644 --- a/classes/callback.class.php +++ b/classes/callback.class.php @@ -151,7 +151,7 @@ public function create_webhook() { set_config('turnitin_webhook_secret', $secret, 'plagiarism_turnitinsim'); mtrace(get_string('taskoutputwebhookcreated', 'plagiarism_turnitinsim', TURNITINSIM_CALLBACK_URL)); - } elseif ($responsedata->httpstatus === TURNITINSIM_HTTP_CANNOT_EXTRACT_TEXT) { + } else if ($responsedata->httpstatus === TURNITINSIM_HTTP_CANNOT_EXTRACT_TEXT) { // Webhook for this URL already exists in Turnitin, but not Moodle. Get webhooks. $response = $this->tsrequest->send_request(TURNITINSIM_ENDPOINT_WEBHOOKS, json_encode(array()), 'GET'); $webhooks = json_decode($response); diff --git a/lib.php b/lib.php index 6701f04..4d6386c 100644 --- a/lib.php +++ b/lib.php @@ -749,7 +749,7 @@ public function queue_files($cm, $eventdata, $sendtoturnitin, $features, $quizan $submission = $DB->get_record_select('plagiarism_turnitinsim_sub', $query, $params); $filedetails = $tssubmission->get_file_details(); - // Do not submit feedback or into files + // Do not submit feedback or into files. if ($filedetails) { $filearea = $filedetails->get_filearea(); $nonsubmittingareas = array("feedback_files", "introattachment"); diff --git a/tests/classes/defaults_form_class_test.php b/tests/classes/defaults_form_class_test.php index 782cb2e..965bca5 100644 --- a/tests/classes/defaults_form_class_test.php +++ b/tests/classes/defaults_form_class_test.php @@ -88,6 +88,6 @@ public function test_display() { $form = new plagiarism_turnitinsim_defaults_form(); $output = $form->display(); - handle_deprecation::assertContains($this, '', $output); + handle_deprecation::assertcontains($this, '', $output); } } \ No newline at end of file diff --git a/tests/classes/eula.class_test.php b/tests/classes/eula.class_test.php index e55b882..c85773b 100644 --- a/tests/classes/eula.class_test.php +++ b/tests/classes/eula.class_test.php @@ -228,8 +228,10 @@ public function test_get_eula_status_for_student() { $tseula = new plagiarism_turnitinsim_eula(); $result = $tseula->get_eula_status($cm->id, 'file'); - handle_deprecation::assertContains($this, get_string('eulalink', 'plagiarism_turnitinsim', '?lang=en-US'), $result['eula-confirm']); - handle_deprecation::assertContains($this, get_string('submissiondisplayerror:eulanotaccepted_help', 'plagiarism_turnitinsim'), $result['eula-status']); + handle_deprecation::assertcontains($this, + get_string('eulalink', 'plagiarism_turnitinsim', '?lang=en-US'), $result['eula-confirm']); + handle_deprecation::assertcontains($this, + get_string('submissiondisplayerror:eulanotaccepted_help', 'plagiarism_turnitinsim'), $result['eula-status']); } /** @@ -289,6 +291,7 @@ public function test_get_eula_status_for_instructor() { $result = $tseula->get_eula_status($cm->id, 'file'); $this->assertEmpty($result['eula-confirm']); - handle_deprecation::assertContains($this, get_string('submissiondisplayerror:eulanotaccepted_help', 'plagiarism_turnitinsim'), $result['eula-status']); + handle_deprecation::assertcontains($this, + get_string('submissiondisplayerror:eulanotaccepted_help', 'plagiarism_turnitinsim'), $result['eula-status']); } } \ No newline at end of file diff --git a/tests/classes/setup_form_class_test.php b/tests/classes/setup_form_class_test.php index b709a5b..ccdc031 100644 --- a/tests/classes/setup_form_class_test.php +++ b/tests/classes/setup_form_class_test.php @@ -133,10 +133,10 @@ public function test_display() { $form = new plagiarism_turnitinsim_setup_form(); $output = $form->display(); - handle_deprecation::assertContains($this, '', $output); + handle_deprecation::assertcontains($this, '', $output); // Verify that FERPA statement is present. - handle_deprecation::assertContains($this, get_string('viewerpermissionferpa', 'plagiarism_turnitinsim'), $output); + handle_deprecation::assertcontains($this, get_string('viewerpermissionferpa', 'plagiarism_turnitinsim'), $output); } /** @@ -171,6 +171,6 @@ public function test_display_features_features_stored() { $form = new plagiarism_turnitinsim_setup_form(); $output = $form->display_features(); - handle_deprecation::assertContains($this, get_string('turnitinfeatures::moreinfo', 'plagiarism_turnitinsim'), $output); + handle_deprecation::assertcontains($this, get_string('turnitinfeatures::moreinfo', 'plagiarism_turnitinsim'), $output); } } \ No newline at end of file diff --git a/tests/classes/submission_class_test.php b/tests/classes/submission_class_test.php index 984856d..d7e80a8 100644 --- a/tests/classes/submission_class_test.php +++ b/tests/classes/submission_class_test.php @@ -138,7 +138,7 @@ public function test_update() { $tssubmission->update(); // Submission id should now be set. - handle_deprecation::assertInternalTypeInt($this, $tssubmission->getid()); + handle_deprecation::assertinternaltypeint($this, $tssubmission->getid()); // Check an id that doesn't exist doesn't return an object. $submission = $DB->get_record('plagiarism_turnitinsim_sub', array('id' => 0)); @@ -253,15 +253,15 @@ public function test_create_owners_metadata_returns_all_group_member_details_as_ $tsuser2 = new plagiarism_turnitinsim_user($this->student2->id); // Check user array returns correct details. - handle_deprecation::assertContains($this, $this->student1->lastname, $owners[0]['family_name']); - handle_deprecation::assertContains($this, $this->student1->firstname, $owners[0]['given_name']); - handle_deprecation::assertContains($this, $this->student1->email, $owners[0]['email']); - handle_deprecation::assertContains($this, $tsuser1->get_turnitinid(), $owners[0]['id']); - - handle_deprecation::assertContains($this, $this->student2->lastname, $owners[1]['family_name']); - handle_deprecation::assertContains($this, $this->student2->firstname, $owners[1]['given_name']); - handle_deprecation::assertContains($this, $this->student2->email, $owners[1]['email']); - handle_deprecation::assertContains($this, $tsuser2->get_turnitinid(), $owners[1]['id']); + handle_deprecation::assertcontains($this, $this->student1->lastname, $owners[0]['family_name']); + handle_deprecation::assertcontains($this, $this->student1->firstname, $owners[0]['given_name']); + handle_deprecation::assertcontains($this, $this->student1->email, $owners[0]['email']); + handle_deprecation::assertcontains($this, $tsuser1->get_turnitinid(), $owners[0]['id']); + + handle_deprecation::assertcontains($this, $this->student2->lastname, $owners[1]['family_name']); + handle_deprecation::assertcontains($this, $this->student2->firstname, $owners[1]['given_name']); + handle_deprecation::assertcontains($this, $this->student2->email, $owners[1]['email']); + handle_deprecation::assertcontains($this, $tsuser2->get_turnitinid(), $owners[1]['id']); } /** diff --git a/tests/lib_test.php b/tests/lib_test.php index c53df10..54c35e5 100644 --- a/tests/lib_test.php +++ b/tests/lib_test.php @@ -278,16 +278,16 @@ public function test_get_links_with_submission() { // The HTML returned should contain the queued status and a Tii icon. $plagiarismturnitinsim = new plagiarism_plugin_turnitinsim(); - handle_deprecation::assertContains($this, + handle_deprecation::assertcontains($this, ''.get_string( 'submissiondisplaystatus:queued', 'plagiarism_turnitinsim').'', $plagiarismturnitinsim->get_links($linkarray) ); - handle_deprecation::assertContains($this, 'tii_icon', $plagiarismturnitinsim->get_links($linkarray)); + handle_deprecation::assertcontains($this, 'tii_icon', $plagiarismturnitinsim->get_links($linkarray)); // Change submission status to Uploaded and verify that pending is displayed. $tssubmission->setstatus(TURNITINSIM_SUBMISSION_STATUS_UPLOADED); $tssubmission->update(); - handle_deprecation::assertContains($this, + handle_deprecation::assertcontains($this, ''.get_string( 'submissiondisplaystatus:pending', 'plagiarism_turnitinsim').'', $plagiarismturnitinsim->get_links($linkarray) ); @@ -295,7 +295,7 @@ public function test_get_links_with_submission() { // Change submission status to Uploaded and verify that not sent is displayed. $tssubmission->setstatus(TURNITINSIM_SUBMISSION_STATUS_NOT_SENT); $tssubmission->update(); - handle_deprecation::assertContains($this, + handle_deprecation::assertcontains($this, ''.get_string( 'submissiondisplaystatus:notsent', 'plagiarism_turnitinsim').'', $plagiarismturnitinsim->get_links($linkarray) ); @@ -303,7 +303,7 @@ public function test_get_links_with_submission() { // Change submission status to Requested and verify that pending is displayed. $tssubmission->setstatus(TURNITINSIM_SUBMISSION_STATUS_REQUESTED); $tssubmission->update(); - handle_deprecation::assertContains($this, + handle_deprecation::assertcontains($this, ''.get_string( 'submissiondisplaystatus:pending', 'plagiarism_turnitinsim').'', $plagiarismturnitinsim->get_links($linkarray) ); @@ -313,17 +313,17 @@ public function test_get_links_with_submission() { $tssubmission->update(); $output = $plagiarismturnitinsim->get_links($linkarray); - handle_deprecation::assertContains($this, + handle_deprecation::assertcontains($this, get_string('submissiondisplaystatus:awaitingeula', 'plagiarism_turnitinsim'), $output ); - handle_deprecation::assertContains($this, + handle_deprecation::assertcontains($this, get_string('submissiondisplayerror:eulanotaccepted_help', 'plagiarism_turnitinsim'), $output ); // Log instructor in and check they do not see a resubmit link. $this->setUser($this->instructor); - handle_deprecation::assertNotContains($this, + handle_deprecation::assertnotcontains($this, get_string('resubmittoturnitin', 'plagiarism_turnitinsim'), $output ); @@ -331,7 +331,7 @@ public function test_get_links_with_submission() { // Change submission status to a non constant and verify that the default is displayed. $tssubmission->setstatus('nonconstantstring'); $tssubmission->update(); - handle_deprecation::assertContains($this, + handle_deprecation::assertcontains($this, get_string( 'submissiondisplaystatus:unknown', 'plagiarism_turnitinsim'), $plagiarismturnitinsim->get_links($linkarray)); @@ -339,7 +339,7 @@ public function test_get_links_with_submission() { $tssubmission->setstatus(TURNITINSIM_SUBMISSION_STATUS_ERROR); $tssubmission->seterrormessage(TURNITINSIM_SUBMISSION_STATUS_TOO_MUCH_TEXT); $tssubmission->update(); - handle_deprecation::assertContains($this, + handle_deprecation::assertcontains($this, get_string( 'submissiondisplayerror:toomuchtext', 'plagiarism_turnitinsim'), $plagiarismturnitinsim->get_links($linkarray) ); @@ -347,14 +347,14 @@ public function test_get_links_with_submission() { // Change error message to generic and verify that it is displayed. $tssubmission->seterrormessage('random_string_that_is_not_a_constant'); $tssubmission->update(); - handle_deprecation::assertContains($this, + handle_deprecation::assertcontains($this, get_string( 'submissiondisplayerror:generic', 'plagiarism_turnitinsim'), $plagiarismturnitinsim->get_links($linkarray) ); // Log instructor in and check they see a resubmit link. $this->setUser($this->instructor); - handle_deprecation::assertContains($this, + handle_deprecation::assertcontains($this, get_string( 'resubmittoturnitin', 'plagiarism_turnitinsim'), $plagiarismturnitinsim->get_links($linkarray) ); @@ -364,8 +364,9 @@ public function test_get_links_with_submission() { $tssubmission->setstatus(TURNITINSIM_SUBMISSION_STATUS_COMPLETE); $tssubmission->setoverallscore($score); $tssubmission->update(); - handle_deprecation::assertContains($this, $score.'%', $plagiarismturnitinsim->get_links($linkarray)); - handle_deprecation::assertContains($this, 'or_score_colour_' . round($score, -1), $plagiarismturnitinsim->get_links($linkarray)); + handle_deprecation::assertcontains($this, $score.'%', $plagiarismturnitinsim->get_links($linkarray)); + handle_deprecation::assertcontains($this, + 'or_score_colour_' . round($score, -1), $plagiarismturnitinsim->get_links($linkarray)); } /** @@ -376,7 +377,8 @@ public function test_render_resubmit_link() { $plagiarismturnitinsim = new plagiarism_plugin_turnitinsim(); $submissionid = 1; - handle_deprecation::assertContains($this, 'pp_resubmit_id_'.$submissionid, $plagiarismturnitinsim->render_resubmit_link($submissionid)); + handle_deprecation::assertcontains($this, + 'pp_resubmit_id_'.$submissionid, $plagiarismturnitinsim->render_resubmit_link($submissionid)); } /** @@ -491,7 +493,7 @@ public function test_print_disclosure_display_latest() { // Verify EULA is output. $plagiarismturnitinsim = new plagiarism_plugin_turnitinsim(); - handle_deprecation::assertContains($this, + handle_deprecation::assertcontains($this, get_string('eulalink', 'plagiarism_turnitinsim', $eulaurl), $plagiarismturnitinsim->print_disclosure($this->cm->id) ); @@ -527,7 +529,7 @@ public function test_print_disclosure_not_display_latest() { // Verify EULA is not output. $plagiarismturnitinsim = new plagiarism_plugin_turnitinsim(); - handle_deprecation::assertContains($this, + handle_deprecation::assertcontains($this, get_string('eulaalreadyaccepted', 'plagiarism_turnitinsim'), $plagiarismturnitinsim->print_disclosure($this->cm->id)); } @@ -559,7 +561,7 @@ public function test_print_disclosure_eula_not_displayed_if_not_required() { // Verify EULA is not output. $plagiarismturnitinsim = new plagiarism_plugin_turnitinsim(); - handle_deprecation::assertContains($this, + handle_deprecation::assertcontains($this, get_string('eulanotrequired', 'plagiarism_turnitinsim'), $plagiarismturnitinsim->print_disclosure($this->cm->id)); } diff --git a/tests/turnitinsim_generator.php b/tests/turnitinsim_generator.php index cd705b5..f115425 100644 --- a/tests/turnitinsim_generator.php +++ b/tests/turnitinsim_generator.php @@ -88,6 +88,7 @@ public function create_assign_with_student_and_teacher($params = array()) { * Create a Turnitin submission. * * @param int $numsubmissions The number of submissions to create. + * @param string $status The Turnitin status for this submission. * @return array * @throws coding_exception * @throws dml_exception diff --git a/utilities/handle_deprecation.php b/utilities/handle_deprecation.php index e455cb6..b10a039 100644 --- a/utilities/handle_deprecation.php +++ b/utilities/handle_deprecation.php @@ -102,7 +102,7 @@ public static function get_plugin_enabled() { * In Moodle 3.9, download_as_dataformat() was deprecated and \core\dataformat::download_data() was introduced. * This method handles our support for multiple Moodle versions. * - * @param string $filename The name of the dile to download. + * @param string $exportfile The name of the file to download. * @param string $dataformat The format of the file. * @param array $columns The names of the columns. * @param string $data The data to download. @@ -123,7 +123,7 @@ public static function download_data($exportfile, $dataformat, $columns, $data) * @param string $needle The string we want to find. * @param string $haystack The string we are searching within. */ - public static function assertContains($object, $needle, $haystack) { + public static function assertcontains($object, $needle, $haystack) { global $CFG; $CFG->branch >= 37 ? $object->assertStringContainsString($needle, $haystack) @@ -139,7 +139,7 @@ public static function assertContains($object, $needle, $haystack) { * @param string $needle The string we want to find. * @param string $haystack The string we are searching within. */ - public static function assertNotContains($object, $needle, $haystack) { + public static function assertnotcontains($object, $needle, $haystack) { global $CFG; $CFG->branch >= 37 ? $object->assertStringNotContainsString($needle, $haystack) @@ -154,7 +154,7 @@ public static function assertNotContains($object, $needle, $haystack) { * @param object $object The test class object. * @param string $value The value we are looking for. */ - public static function assertInternalTypeInt($object, $value) { + public static function assertinternaltypeint($object, $value) { global $CFG; $CFG->branch >= 37 ? $object->assertIsInt($value) : $object->assertInternalType("int", $value); diff --git a/version.php b/version.php index c41cf70..11593e6 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2020111201; +$plugin->version = 2021011801; $plugin->release = "v1.2"; $plugin->requires = 2017051500; $plugin->component = 'plagiarism_turnitinsim';