';loading+=' ',loading+=''+M.str.plagiarism_turnitin.loadingdv+"
",loading+="",$(dvWindow.document.body).html(loading),$.ajax({type:"POST",url:M.cfg.wwwroot+"/plagiarism/turnitin/ajax.php",dataType:"json",data:{action:"get_dv_html",submissionid:submissionid,dvtype:dvtype,cmid:coursemoduleid,sesskey:M.cfg.sesskey},success:function(data){$(dvWindow.document.body).html(loading+data),dvWindow.document.forms[0].submit(),dvWindow.document.close(),that.checkDVClosed(submissionid,coursemoduleid,dvWindow)}})},checkDVClosed:function(submissionid,coursemoduleid,dvWindow){var that=this;dvWindow.closed?that.refreshScores(submissionid,coursemoduleid):setTimeout(function(){that.checkDVClosed(submissionid,coursemoduleid,dvWindow)},500)},refreshScores:function(submission_id,coursemoduleid){var refreshStartTime=(new Date).getTime();$.ajax({type:"POST",url:M.cfg.wwwroot+"/plagiarism/turnitin/ajax.php",dataType:"json",data:{action:"update_grade",submission:submission_id,cmid:coursemoduleid,sesskey:M.cfg.sesskey},success:function(){(new Date).getTime()-refreshStartTime<3e3||!$(".turnitin_score_refresh_alert").length?window.location=window.location+"":$(".turnitin_score_refresh_alert").show()}})}}});
\ No newline at end of file
diff --git a/amd/build/peermark.min.min.js b/amd/build/peermark.min.min.js
deleted file mode 100644
index df870175..00000000
--- a/amd/build/peermark.min.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define("plagiarism_turnitin/peermark",["jquery","core/templates","core/modal_factory","core/modal_events","plagiarism_turnitin/modal_peermark_manager_launch","plagiarism_turnitin/modal_peermark_reviews_launch"],function($,Templates,ModalFactory,ModalEvents,ModalPeermarkManagerLaunch,ModalPeermarkReviewsLaunch){return{peermarkLaunch:function(){var that=this;$(".peermark_manager_launch").on("click",function(event){event.preventDefault(),that.peermarkCreateModal(ModalPeermarkManagerLaunch.TYPE)}),$(document).on("click",".peermark_reviews_pp_launch",function(){that.peermarkCreateModal(ModalPeermarkReviewsLaunch.TYPE)})},peermarkCreateModal:function(modalType){if($('input[name="coursemodule"]').val())var cmid=$('input[name="coursemodule"]').val();else cmid=new URLSearchParams(window.location.search).get("id");ModalFactory.create({type:modalType,templateContext:{cmid:cmid,wwwroot:M.cfg.wwwroot},large:!0}).then(function(modal){modal.show()})}}});
\ No newline at end of file
diff --git a/amd/build/quickmark.min.min.js b/amd/build/quickmark.min.min.js
deleted file mode 100644
index 9fd53aa7..00000000
--- a/amd/build/quickmark.min.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define("plagiarism_turnitin/quickmark",["jquery","core/templates","core/modal_factory","core/modal_events","plagiarism_turnitin/modal_quickmark_launch"],function($,Templates,ModalFactory,ModalEvents,ModalQuickmarkLaunch){return{quickmarkLaunch:function(){$(".plagiarism_turnitin_quickmark_manager_launch").on("click",function(event){event.preventDefault(),ModalFactory.create({type:ModalQuickmarkLaunch.TYPE,templateContext:{cmid:$('input[name="coursemodule"]').val(),wwwroot:M.cfg.wwwroot},large:!0}).then(function(modal){modal.show()})})}}});
\ No newline at end of file
diff --git a/amd/build/refresh_submissions.min.min.js b/amd/build/refresh_submissions.min.min.js
deleted file mode 100644
index eadfeb5a..00000000
--- a/amd/build/refresh_submissions.min.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define("plagiarism_turnitin/refresh_submissions",["jquery"],function($){return{refreshSubmissions:function(){$(".plagiarism_turnitin_refresh_grades").on("click",function(){$(".plagiarism_turnitin_refresh_grades").hide(),$(".plagiarism_turnitin_refreshing_grades").show(),$.ajax({type:"POST",url:M.cfg.wwwroot+"/plagiarism/turnitin/ajax.php",dataType:"json",data:{action:"update_grade",cmid:$('input[name="coursemodule"]').val(),sesskey:M.cfg.sesskey},success:function(){$(".plagiarism_turnitin_refresh_grades").show(),$(".plagiarism_turnitin_refreshing_grades").hide()}})})}}});
\ No newline at end of file
diff --git a/amd/build/resend_submission.min.min.js b/amd/build/resend_submission.min.min.js
deleted file mode 100644
index 0c72f5bf..00000000
--- a/amd/build/resend_submission.min.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define("plagiarism_turnitin/resend_submission",["jquery"],function($){return{resendSubmission:function(){$(document).on("click",".plagiarism_turnitin_resubmit_link",function(){$(this).hide(),$(this).siblings(".pp_resubmitting").removeClass("hidden");var that=$(this),submissionid=$(this).prop("id").split("_")[2],forumpost=$("#content_"+submissionid).html(),forumdata=$("#forumdata_"+submissionid).html();return $.ajax({type:"POST",url:M.cfg.wwwroot+"/plagiarism/turnitin/ajax.php",dataType:"json",data:{action:"resubmit_event",submissionid:submissionid,forumpost:forumpost,forumdata:forumdata,sesskey:M.cfg.sesskey},success:function(){that.siblings(".turnitin_status").removeClass("hidden"),that.siblings(".pp_resubmitting").addClass("hidden")},error:function(){that.show(),that.siblings(".pp_resubmitting").addClass("hidden")}}),!1})}}});
\ No newline at end of file
diff --git a/amd/build/rubric.min.min.js b/amd/build/rubric.min.min.js
deleted file mode 100644
index f54cfce6..00000000
--- a/amd/build/rubric.min.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define("plagiarism_turnitin/rubric",["jquery","core/templates","core/modal_factory","core/modal_events","plagiarism_turnitin/modal_rubric_manager_launch","plagiarism_turnitin/modal_rubric_view_launch"],function($,Templates,ModalFactory,ModalEvents,ModalRubricManagerLaunch,ModalRubricViewLaunch){return{rubric:function(){var that=this;$(".rubric_manager_launch").on("click",function(){var courseid=$(this).data("courseid"),cmid=$(this).data("cmid");that.rubricCreateModal(ModalRubricManagerLaunch.TYPE,courseid,cmid)}),$(document).on("click",".rubric_view",function(){var courseid=$(this).data("courseid"),cmid=$(this).data("cmid");that.rubricCreateModal(ModalRubricViewLaunch.TYPE,courseid,cmid)}),$("#id_plagiarism_rubric").mousedown(function(){""!=$('input[name="instance"]').val()&&"Y"!=$('input[name="rubric_warning_seen"]').val()&&confirm(M.str.plagiarism_turnitin.changerubricwarning)&&$('input[name="rubric_warning_seen"]').val("Y")})},rubricCreateModal:function(modalType,courseid,cmid){ModalFactory.create({type:modalType,templateContext:{courseid:courseid,cmid:cmid,wwwroot:M.cfg.wwwroot},large:!0}).then(function(modal){modal.show(),modal.getRoot().find(".modal").addClass("tii_pp_modal_rubric"),modal.getRoot().find(".modal-dialog").addClass("tii_pp_modal_rubric_content")})}}});
\ No newline at end of file
diff --git a/amd/src/eula.min.js b/amd/src/eula.min.js
deleted file mode 100644
index 86253974..00000000
--- a/amd/src/eula.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define(["jquery","core/templates","core/modal_factory","core/modal_events","plagiarism_turnitin/modal_eula_launch"],function($,Templates,ModalFactory,ModalEvents,ModalEulaLaunch){return{eulaLaunch:function(){var turnitinEulaClass=$(".pp_turnitin_eula");turnitinEulaClass.show();$(document).on("mod_forum-post-created",".forum-post-container",function(event,newid){var turnitinEulaClass=$("#post-content-"+newid+" .pp_turnitin_eula");turnitinEulaClass.show()});$(document).on("click",".pp_turnitin_eula_link",function(){ModalFactory.create({type:ModalEulaLaunch.TYPE,templateContext:{cmid:$('input[name="coursemodule"]').val(),wwwroot:M.cfg.wwwroot},large:true}).then(function(modal){modal.show();modal.getRoot().find(".modal").addClass("tii_pp_modal_eula");modal.getRoot().find(".modal-content").addClass("tii_pp_modal_eula_content")})});if($(".pp_turnitin_eula_ignored").length>0){if($(".editsubmissionform").length>0){$(".editsubmissionform").hide()}if(turnitinEulaClass.siblings(".mform").length>0){turnitinEulaClass.siblings(".mform").hide()}}}}});
\ No newline at end of file
diff --git a/amd/src/modal_eula_launch.min.js b/amd/src/modal_eula_launch.min.js
deleted file mode 100644
index 739f0b16..00000000
--- a/amd/src/modal_eula_launch.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define(["jquery","core/ajax","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/modal_events"],function($,Ajax,Notification,CustomEvents,Modal,ModalRegistry,ModalEvents){var registered=false;var SELECTORS={HIDE_BUTTON:'[data-action="hide"]',MODAL:'[data-region="modal"]'};var ModalEulaLaunch=function(root){Modal.call(this,root)};ModalEulaLaunch.TYPE="plagiarism_turnitin-modal_eula_launch";ModalEulaLaunch.prototype=Object.create(Modal.prototype);ModalEulaLaunch.prototype.constructor=ModalEulaLaunch;ModalEulaLaunch.prototype.registerEventListeners=function(){Modal.prototype.registerEventListeners.call(this);processEula();this.getModal().on(CustomEvents.events.activate,SELECTORS.HIDE_BUTTON,function(e,data){var cancelEvent=$.Event(ModalEvents.cancel);this.getRoot().trigger(cancelEvent,this);if(!cancelEvent.isDefaultPrevented()){this.hide();data.originalEvent.preventDefault()}}.bind(this))};function processEula(){$(window).on("message",function(ev){var message=typeof ev.data==="undefined"?ev.originalEvent.data:ev.data;if(message==="turnitin_eula_declined"||message==="turnitin_eula_accepted"){$.ajax({type:"POST",url:M.cfg.wwwroot+"/plagiarism/turnitin/ajax.php",dataType:"json",data:{action:"actionuseragreement",message:message,sesskey:M.cfg.sesskey},success:function(){window.location.reload()},error:function(){window.location.reload()}})}})}if(!registered){ModalRegistry.register(ModalEulaLaunch.TYPE,ModalEulaLaunch,"plagiarism_turnitin/modal_eula_launch");registered=true}return ModalEulaLaunch});
\ No newline at end of file
diff --git a/amd/src/modal_peermark_manager_launch.min.js b/amd/src/modal_peermark_manager_launch.min.js
deleted file mode 100644
index fec1cc58..00000000
--- a/amd/src/modal_peermark_manager_launch.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define(["jquery","core/ajax","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/modal_events"],function($,Ajax,Notification,CustomEvents,Modal,ModalRegistry,ModalEvents){var registered=false;var SELECTORS={HIDE_BUTTON:'[data-action="hide"]',MODAL:'[data-region="modal"]'};var ModalPeermarkManagerLaunch=function(root){Modal.call(this,root)};ModalPeermarkManagerLaunch.TYPE="plagiarism_turnitin-modal_peermark_manager_launch";ModalPeermarkManagerLaunch.prototype=Object.create(Modal.prototype);ModalPeermarkManagerLaunch.prototype.constructor=ModalPeermarkManagerLaunch;ModalPeermarkManagerLaunch.prototype.registerEventListeners=function(){Modal.prototype.registerEventListeners.call(this);this.getModal().on(CustomEvents.events.activate,SELECTORS.HIDE_BUTTON,function(e,data){var cancelEvent=$.Event(ModalEvents.cancel);this.getRoot().trigger(cancelEvent,this);if(!cancelEvent.isDefaultPrevented()){this.hide();data.originalEvent.preventDefault();refreshPeermarkAssignments()}}.bind(this));this.getRoot().click(function(e){if(!$(e.target).closest(SELECTORS.MODAL).length){refreshPeermarkAssignments()}}.bind(this))};function refreshPeermarkAssignments(){$.ajax({type:"POST",url:M.cfg.wwwroot+"/plagiarism/turnitin/ajax.php",dataType:"json",data:{action:"refresh_peermark_assignments",cmid:$('input[name="coursemodule"]').val(),sesskey:M.cfg.sesskey}})}if(!registered){ModalRegistry.register(ModalPeermarkManagerLaunch.TYPE,ModalPeermarkManagerLaunch,"plagiarism_turnitin/modal_peermark_manager_launch");registered=true}return ModalPeermarkManagerLaunch});
\ No newline at end of file
diff --git a/amd/src/modal_peermark_reviews_launch.min.js b/amd/src/modal_peermark_reviews_launch.min.js
deleted file mode 100644
index bfcd50cf..00000000
--- a/amd/src/modal_peermark_reviews_launch.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define(["jquery","core/ajax","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/modal_events"],function($,Ajax,Notification,CustomEvents,Modal,ModalRegistry,ModalEvents){var registered=false;var SELECTORS={HIDE_BUTTON:'[data-action="hide"]',MODAL:'[data-region="modal"]'};var ModalPeermarkReviewsLaunch=function(root){Modal.call(this,root)};ModalPeermarkReviewsLaunch.TYPE="plagiarism_turnitin-modal_peermark_reviews_launch";ModalPeermarkReviewsLaunch.prototype=Object.create(Modal.prototype);ModalPeermarkReviewsLaunch.prototype.constructor=ModalPeermarkReviewsLaunch;ModalPeermarkReviewsLaunch.prototype.registerEventListeners=function(){Modal.prototype.registerEventListeners.call(this);this.getModal().on(CustomEvents.events.activate,SELECTORS.HIDE_BUTTON,function(e,data){var cancelEvent=$.Event(ModalEvents.cancel);this.getRoot().trigger(cancelEvent,this);if(!cancelEvent.isDefaultPrevented()){this.hide();data.originalEvent.preventDefault()}}.bind(this))};if(!registered){ModalRegistry.register(ModalPeermarkReviewsLaunch.TYPE,ModalPeermarkReviewsLaunch,"plagiarism_turnitin/modal_peermark_reviews_launch");registered=true}return ModalPeermarkReviewsLaunch});
\ No newline at end of file
diff --git a/amd/src/modal_quickmark_launch.min.js b/amd/src/modal_quickmark_launch.min.js
deleted file mode 100644
index d86369d0..00000000
--- a/amd/src/modal_quickmark_launch.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define(["jquery","core/ajax","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/modal_events"],function($,Ajax,Notification,CustomEvents,Modal,ModalRegistry,ModalEvents){var registered=false;var SELECTORS={HIDE_BUTTON:'[data-action="hide"]',MODAL:'[data-region="modal"]'};var ModalQuickmarkLaunch=function(root){Modal.call(this,root)};ModalQuickmarkLaunch.TYPE="plagiarism_turnitin-modal_quickmark_launch";ModalQuickmarkLaunch.prototype=Object.create(Modal.prototype);ModalQuickmarkLaunch.prototype.constructor=ModalQuickmarkLaunch;ModalQuickmarkLaunch.prototype.registerEventListeners=function(){Modal.prototype.registerEventListeners.call(this);this.getModal().on(CustomEvents.events.activate,SELECTORS.HIDE_BUTTON,function(e,data){var cancelEvent=$.Event(ModalEvents.cancel);this.getRoot().trigger(cancelEvent,this);if(!cancelEvent.isDefaultPrevented()){this.hide();data.originalEvent.preventDefault()}}.bind(this))};if(!registered){ModalRegistry.register(ModalQuickmarkLaunch.TYPE,ModalQuickmarkLaunch,"plagiarism_turnitin/modal_quickmark_launch");registered=true}return ModalQuickmarkLaunch});
\ No newline at end of file
diff --git a/amd/src/modal_rubric_manager_launch.min.js b/amd/src/modal_rubric_manager_launch.min.js
deleted file mode 100644
index a918eb1f..00000000
--- a/amd/src/modal_rubric_manager_launch.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define(["jquery","core/ajax","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/modal_events"],function($,Ajax,Notification,CustomEvents,Modal,ModalRegistry,ModalEvents){var registered=false;var SELECTORS={HIDE_BUTTON:'[data-action="hide"]',MODAL:'[data-region="modal"]'};var ModalRubricManagerLaunch=function(root){Modal.call(this,root)};ModalRubricManagerLaunch.TYPE="plagiarism_turnitin-modal_rubric_manager_launch";ModalRubricManagerLaunch.prototype=Object.create(Modal.prototype);ModalRubricManagerLaunch.prototype.constructor=ModalRubricManagerLaunch;ModalRubricManagerLaunch.prototype.registerEventListeners=function(){Modal.prototype.registerEventListeners.call(this);this.getModal().on(CustomEvents.events.activate,SELECTORS.HIDE_BUTTON,function(e,data){var cancelEvent=$.Event(ModalEvents.cancel);this.getRoot().trigger(cancelEvent,this);if(!cancelEvent.isDefaultPrevented()){this.hide();data.originalEvent.preventDefault();refreshRubricSelect()}}.bind(this));this.getRoot().click(function(e){if(!$(e.target).closest(SELECTORS.MODAL).length){refreshRubricSelect()}}.bind(this))};function refreshRubricSelect(){var currentRubric=$("#id_plagiarism_rubric").val();$.ajax({dataType:"json",type:"POST",url:"../plagiarism/turnitin/ajax.php",data:{action:"refresh_rubric_select",assignment:$('input[name="instance"]').val(),modulename:$('input[name="modulename"]').val(),course:$('input[name="course"]').val()},success:function(data){$($("#id_plagiarism_rubric")).empty();var options=data;$.each(options,function(i,val){if(!$.isNumeric(i)&&i!==""){var optgroup=$("");optgroup.attr("label",i);$.each(val,function(j,rubric){var option=$(" ");option.val(j);option.text(rubric);optgroup.append(option)});$("#id_plagiarism_rubric").append(optgroup)}else{$($("#id_plagiarism_rubric")).append($("",{value:i,text:val}))}});$("#id_plagiarism_rubric"+' option[value="'+currentRubric+'"]').attr("selected","selected")}})}if(!registered){ModalRegistry.register(ModalRubricManagerLaunch.TYPE,ModalRubricManagerLaunch,"plagiarism_turnitin/modal_rubric_manager_launch");registered=true}return ModalRubricManagerLaunch});
\ No newline at end of file
diff --git a/amd/src/modal_rubric_view_launch.min.js b/amd/src/modal_rubric_view_launch.min.js
deleted file mode 100644
index 978ef62a..00000000
--- a/amd/src/modal_rubric_view_launch.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define(["jquery","core/ajax","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/modal_events"],function($,Ajax,Notification,CustomEvents,Modal,ModalRegistry,ModalEvents){var registered=false;var SELECTORS={HIDE_BUTTON:'[data-action="hide"]',MODAL:'[data-region="modal"]'};var ModalRubricViewLaunch=function(root){Modal.call(this,root)};ModalRubricViewLaunch.TYPE="plagiarism_turnitin-modal_rubric_view_launch";ModalRubricViewLaunch.prototype=Object.create(Modal.prototype);ModalRubricViewLaunch.prototype.constructor=ModalRubricViewLaunch;ModalRubricViewLaunch.prototype.registerEventListeners=function(){Modal.prototype.registerEventListeners.call(this);this.getModal().on(CustomEvents.events.activate,SELECTORS.HIDE_BUTTON,function(e,data){var cancelEvent=$.Event(ModalEvents.cancel);this.getRoot().trigger(cancelEvent,this);if(!cancelEvent.isDefaultPrevented()){this.hide();data.originalEvent.preventDefault()}}.bind(this))};if(!registered){ModalRegistry.register(ModalRubricViewLaunch.TYPE,ModalRubricViewLaunch,"plagiarism_turnitin/modal_rubric_view_launch");registered=true}return ModalRubricViewLaunch});
\ No newline at end of file
diff --git a/amd/src/open_viewer.min.js b/amd/src/open_viewer.min.js
deleted file mode 100644
index ee926d80..00000000
--- a/amd/src/open_viewer.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define(["jquery"],function($){return{origreport_open:function(){var that=this;$(document).on("click",".pp_origreport_open",function(){var classList=$(this).attr("class").replace(/\s+/," ").split(" ");for(var i=0;i';loading+=''+M.str.plagiarism_turnitin.loadingdv+"
";loading+="";$(dvWindow.document.body).html(loading);$.ajax({type:"POST",url:M.cfg.wwwroot+"/plagiarism/turnitin/ajax.php",dataType:"json",data:{action:"get_dv_html",submissionid:submissionid,dvtype:dvtype,cmid:coursemoduleid,sesskey:M.cfg.sesskey},success:function(data){$(dvWindow.document.body).html(loading+data);dvWindow.document.forms[0].submit();dvWindow.document.close();that.checkDVClosed(submissionid,coursemoduleid,dvWindow)}})},checkDVClosed:function(submissionid,coursemoduleid,dvWindow){var that=this;if(dvWindow.closed){that.refreshScores(submissionid,coursemoduleid)}else{setTimeout(function(){that.checkDVClosed(submissionid,coursemoduleid,dvWindow)},500)}},refreshScores:function(submission_id,coursemoduleid){var refreshStartTime=(new Date).getTime();$.ajax({type:"POST",url:M.cfg.wwwroot+"/plagiarism/turnitin/ajax.php",dataType:"json",data:{action:"update_grade",submission:submission_id,cmid:coursemoduleid,sesskey:M.cfg.sesskey},success:function(){var requestDuration=(new Date).getTime()-refreshStartTime;if(requestDuration<3e3||!$(".turnitin_score_refresh_alert").length){window.location=window.location+""}else{$(".turnitin_score_refresh_alert").show()}}})}}});
\ No newline at end of file
diff --git a/amd/src/peermark.min.js b/amd/src/peermark.min.js
deleted file mode 100644
index f828b8c1..00000000
--- a/amd/src/peermark.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define(["jquery","core/templates","core/modal_factory","core/modal_events","plagiarism_turnitin/modal_peermark_manager_launch","plagiarism_turnitin/modal_peermark_reviews_launch"],function($,Templates,ModalFactory,ModalEvents,ModalPeermarkManagerLaunch,ModalPeermarkReviewsLaunch){return{peermarkLaunch:function(){var that=this;$(".peermark_manager_launch").on("click",function(event){event.preventDefault();that.peermarkCreateModal(ModalPeermarkManagerLaunch.TYPE)});$(document).on("click",".peermark_reviews_pp_launch",function(){that.peermarkCreateModal(ModalPeermarkReviewsLaunch.TYPE)})},peermarkCreateModal:function(modalType){if($('input[name="coursemodule"]').val()){var cmid=$('input[name="coursemodule"]').val()}else{var urlParams=new URLSearchParams(window.location.search);var cmid=urlParams.get("id")}ModalFactory.create({type:modalType,templateContext:{cmid:cmid,wwwroot:M.cfg.wwwroot},large:true}).then(function(modal){modal.show()})}}});
\ No newline at end of file
diff --git a/amd/src/quickmark.min.js b/amd/src/quickmark.min.js
deleted file mode 100644
index 68e6cabc..00000000
--- a/amd/src/quickmark.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define(["jquery","core/templates","core/modal_factory","core/modal_events","plagiarism_turnitin/modal_quickmark_launch"],function($,Templates,ModalFactory,ModalEvents,ModalQuickmarkLaunch){return{quickmarkLaunch:function(){$(".plagiarism_turnitin_quickmark_manager_launch").on("click",function(event){event.preventDefault();ModalFactory.create({type:ModalQuickmarkLaunch.TYPE,templateContext:{cmid:$('input[name="coursemodule"]').val(),wwwroot:M.cfg.wwwroot},large:true}).then(function(modal){modal.show()})})}}});
\ No newline at end of file
diff --git a/amd/src/refresh_submissions.min.js b/amd/src/refresh_submissions.min.js
deleted file mode 100644
index 911a0daa..00000000
--- a/amd/src/refresh_submissions.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define(["jquery"],function($){return{refreshSubmissions:function(){$(".plagiarism_turnitin_refresh_grades").on("click",function(){$(".plagiarism_turnitin_refresh_grades").hide();$(".plagiarism_turnitin_refreshing_grades").show();$.ajax({type:"POST",url:M.cfg.wwwroot+"/plagiarism/turnitin/ajax.php",dataType:"json",data:{action:"update_grade",cmid:$('input[name="coursemodule"]').val(),sesskey:M.cfg.sesskey},success:function(){$(".plagiarism_turnitin_refresh_grades").show();$(".plagiarism_turnitin_refreshing_grades").hide()}})})}}});
\ No newline at end of file
diff --git a/amd/src/resend_submission.min.js b/amd/src/resend_submission.min.js
deleted file mode 100644
index 224571b0..00000000
--- a/amd/src/resend_submission.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define(["jquery"],function($){return{resendSubmission:function(){$(document).on("click",".plagiarism_turnitin_resubmit_link",function(){$(this).hide();$(this).siblings(".pp_resubmitting").removeClass("hidden");var that=$(this);var submissionid=$(this).prop("id").split("_")[2];var forumpost=$("#content_"+submissionid).html();var forumdata=$("#forumdata_"+submissionid).html();$.ajax({type:"POST",url:M.cfg.wwwroot+"/plagiarism/turnitin/ajax.php",dataType:"json",data:{action:"resubmit_event",submissionid:submissionid,forumpost:forumpost,forumdata:forumdata,sesskey:M.cfg.sesskey},success:function(){that.siblings(".turnitin_status").removeClass("hidden");that.siblings(".pp_resubmitting").addClass("hidden")},error:function(){that.show();that.siblings(".pp_resubmitting").addClass("hidden")}});return false})}}});
\ No newline at end of file
diff --git a/amd/src/rubric.min.js b/amd/src/rubric.min.js
deleted file mode 100644
index 0ef46fcf..00000000
--- a/amd/src/rubric.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define(["jquery","core/templates","core/modal_factory","core/modal_events","plagiarism_turnitin/modal_rubric_manager_launch","plagiarism_turnitin/modal_rubric_view_launch"],function($,Templates,ModalFactory,ModalEvents,ModalRubricManagerLaunch,ModalRubricViewLaunch){return{rubric:function(){var that=this;$(".rubric_manager_launch").on("click",function(){var courseid=$(this).data("courseid");var cmid=$(this).data("cmid");that.rubricCreateModal(ModalRubricManagerLaunch.TYPE,courseid,cmid)});$(document).on("click",".rubric_view",function(){var courseid=$(this).data("courseid");var cmid=$(this).data("cmid");that.rubricCreateModal(ModalRubricViewLaunch.TYPE,courseid,cmid)});$("#id_plagiarism_rubric").mousedown(function(){if($('input[name="instance"]').val()!=""&&$('input[name="rubric_warning_seen"]').val()!="Y"){if(confirm(M.str.plagiarism_turnitin.changerubricwarning)){$('input[name="rubric_warning_seen"]').val("Y")}}})},rubricCreateModal:function(modalType,courseid,cmid){ModalFactory.create({type:modalType,templateContext:{courseid:courseid,cmid:cmid,wwwroot:M.cfg.wwwroot},large:true}).then(function(modal){modal.show();modal.getRoot().find(".modal").addClass("tii_pp_modal_rubric");modal.getRoot().find(".modal-content").addClass("tii_pp_modal_rubric_content")})}}});
\ No newline at end of file
diff --git a/lib.php b/lib.php
index dfafe1ab..f97ccefe 100755
--- a/lib.php
+++ b/lib.php
@@ -1262,35 +1262,35 @@ public function update_grades_from_tii($cm) {
global $DB;
$submissionids = $this->fetch_updated_paper_ids_from_turnitin($cm);
- $return = ($submissionids === false) ? false : true;
-
+ if ($submissionids === false || count($submissionids) < 1) {
+ return false;
+ }
// Refresh updated submissions.
- if (count($submissionids) > 0) {
- // Initialise Comms Object.
- $turnitincomms = new turnitin_comms();
- $turnitincall = $turnitincomms->initialise_api();
+ $return = true;
+ // Initialise Comms Object.
+ $turnitincomms = new turnitin_comms();
+ $turnitincall = $turnitincomms->initialise_api();
- // Process submissions in batches, depending on the max. number of submissions the Turnitin API returns.
- $submissionbatches = array_chunk($submissionids, PLAGIARISM_TURNITIN_NUM_RECORDS_RETURN);
+ // Process submissions in batches, depending on the max. number of submissions the Turnitin API returns.
+ $submissionbatches = array_chunk($submissionids, PLAGIARISM_TURNITIN_NUM_RECORDS_RETURN);
- foreach ($submissionbatches as $submissionsbatch) {
- try {
- $submission = new TiiSubmission();
- $submission->setSubmissionIds($submissionsbatch);
-
- $response = $turnitincall->readSubmissions($submission);
- $readsubmissions = $response->getSubmissions();
+ foreach ($submissionbatches as $submissionsbatch) {
+ try {
+ $submission = new TiiSubmission();
+ $submission->setSubmissionIds($submissionsbatch);
- foreach ($readsubmissions as $readsubmission) {
- $submissiondata = $DB->get_record('plagiarism_turnitin_files',
- array('externalid' => $readsubmission->getSubmissionId()), 'id');
- $return = $this->update_submission($cm, $submissiondata->id, $readsubmission);
- }
+ $response = $turnitincall->readSubmissions($submission);
+ $readsubmissions = $response->getSubmissions();
- } catch (Exception $e) {
- $turnitincomms->handle_exceptions($e, 'tiisubmissiongeterror', false);
- $return = false;
+ foreach ($readsubmissions as $readsubmission) {
+ $submissiondata = $DB->get_record('plagiarism_turnitin_files',
+ array('externalid' => $readsubmission->getSubmissionId()), 'id');
+ $return = $this->update_submission($cm, $submissiondata->id, $readsubmission);
}
+
+ } catch (Exception $e) {
+ $turnitincomms->handle_exceptions($e, 'tiisubmissiongeterror', false);
+ $return = false;
}
}
@@ -1479,7 +1479,7 @@ private function update_grade($cm, $submission, $userid) {
$tiisubmissions = current($tiisubmissions);
}
- if (count($tiisubmissions) > 1) {
+ if (is_array($tiisubmissions) && count($tiisubmissions) > 1) {
$averagegrade = null;
$gradescounted = 0;
foreach ($tiisubmissions as $tiisubmission) {
@@ -2012,7 +2012,7 @@ public function cron_update_scores() {
$submissions = $DB->get_records_select(
'plagiarism_turnitin_files',
- 'statuscode = ?
+ 'statuscode = ?
AND ( similarityscore IS NULL OR duedate_report_refresh = 1 )
AND ( orcapable = ? OR orcapable IS NULL ) ',
array('success', 1),
diff --git a/tests/behat/eula.feature b/tests/behat/eula.feature
index b8c0709b..18c8000b 100644
--- a/tests/behat/eula.feature
+++ b/tests/behat/eula.feature
@@ -60,7 +60,6 @@ Feature: Plagiarism plugin works with a Moodle Assignment allowing EULA acceptan
And I wait "10" seconds
And I click save changes button "css_element" "#id_submitbutton"
Then I should see "Submitted for grading"
- And I should see "Queued"
And I should see "Your file has not been submitted to Turnitin. Please click here to accept our EULA."
# Trigger cron as admin for submission
And I log out
@@ -80,17 +79,17 @@ Feature: Plagiarism plugin works with a Moodle Assignment allowing EULA acceptan
And I am on "Turnitin Behat EULA Test Course" course homepage
And I follow "Test assignment name"
And I should see "Your file has not been submitted to Turnitin. Please click here to accept our EULA."
- And I should see "This file has not been submitted to Turnitin because the user has not accepted the Turnitin End User Licence Agreement."
And I accept the Turnitin EULA if necessary
- # Admin can trigger a resubmission from the errors tab of the settings page.
+ And I press "Edit submission"
+ # Resubmitting same paper
+ And I delete "testfile.txt" from "File submissions" filemanager
+ And I upload "plagiarism/turnitin/tests/fixtures/testfile.txt" file to "File submissions" filemanager
+ And I press "Save changes"
+ Then I should see "Submitted for grading"
+ And I should see "Queued"
+ # Admin can trigger a resubmission
And I log out
And I log in as "admin"
- And I navigate to "Plugins > Plagiarism > Turnitin plagiarism plugin" in site administration
- And I click on "Errors" "link"
- And I click on ".select_all_checkbox" "css_element"
- And I wait "2" seconds
- And I press "Resubmit Selected Files"
- And I wait "10" seconds
And I run the scheduled task "plagiarism_turnitin\task\send_submissions"
# Instructor opens assignment.
And I log out
diff --git a/tests/modules/turnitin_quiz_test.php b/tests/modules/turnitin_quiz_test.php
index 51e4f478..78e8381e 100644
--- a/tests/modules/turnitin_quiz_test.php
+++ b/tests/modules/turnitin_quiz_test.php
@@ -81,7 +81,8 @@ public function test_update_mark() {
// Now update the grade of the essay question through the Turnitin quiz class.
$tiiquiz = new turnitin_quiz;
$answer = $attemptobj->get_question_attempt(1)->get_response_summary();
- $identifier = sha1($answer);
+ $slot = 1;
+ $identifier = sha1($answer.$slot);
$tiiquiz->update_mark($attempt->id, $identifier, $user->id, 75, $quiz->grade);
// Reload the attempt and check the total marks and grade are as we expect it.
diff --git a/vendor/nategood/httpful/.gitignore b/vendor/nategood/httpful/.gitignore
index 6cf3a90c..7b39a0b1 100644
--- a/vendor/nategood/httpful/.gitignore
+++ b/vendor/nategood/httpful/.gitignore
@@ -3,3 +3,4 @@ composer.lock
vendor
downloads
.idea/*
+tests/.phpunit.result.cache
diff --git a/vendor/nategood/httpful/.travis.yml b/vendor/nategood/httpful/.travis.yml
index d962e3a7..9666b4b8 100644
--- a/vendor/nategood/httpful/.travis.yml
+++ b/vendor/nategood/httpful/.travis.yml
@@ -1,17 +1,12 @@
language: php
php:
- - 5.3
- - 5.4
- - 5.5
- - 5.6
- - 7.0
- - hhvm
-
+ - 7.2
+ - 7.3
+ - 7.4
+
matrix:
fast_finish: true
- allow_failures:
- - php: 7.0
-
+
script:
- phpunit -c ./tests/phpunit.xml
diff --git a/vendor/nategood/httpful/README.md b/vendor/nategood/httpful/README.md
index 705d8ccf..c68ee5a0 100644
--- a/vendor/nategood/httpful/README.md
+++ b/vendor/nategood/httpful/README.md
@@ -2,7 +2,7 @@
[![Build Status](https://secure.travis-ci.org/nategood/httpful.png?branch=master)](http://travis-ci.org/nategood/httpful) [![Total Downloads](https://poser.pugx.org/nategood/httpful/downloads.png)](https://packagist.org/packages/nategood/httpful)
-[Httpful](http://phphttpclient.com) is a simple Http Client library for PHP 5.3+. There is an emphasis of readability, simplicity, and flexibility – basically provide the features and flexibility to get the job done and make those features really easy to use.
+Httpful is a simple Http Client library for PHP 7.2+. There is an emphasis of readability, simplicity, and flexibility – basically provide the features and flexibility to get the job done and make those features really easy to use.
Features
@@ -34,16 +34,6 @@ echo "{$response->body->name} joined GitHub on " .
# Installation
-## Phar
-
-A [PHP Archive](http://php.net/manual/en/book.phar.php) (or .phar) file is available for [downloading](http://phphttpclient.com/httpful.phar). Simply [download](http://phphttpclient.com/httpful.phar) the .phar, drop it into your project, and include it like you would any other php file. _This method is ideal for smaller projects, one off scripts, and quick API hacking_.
-
-```php
-include('httpful.phar');
-$r = \Httpful\Request::get($uri)->sendIt();
-...
-```
-
## Composer
Httpful is PSR-0 compliant and can be installed using [composer](http://getcomposer.org/). Simply add `nategood/httpful` to your composer.json file. _Composer is the sane alternative to PEAR. It is excellent for managing dependencies in larger projects_.
@@ -62,11 +52,7 @@ Because Httpful is PSR-0 compliant, you can also just clone the Httpful reposito
If you want the build your own [Phar Archive](http://php.net/manual/en/book.phar.php) you can use the `build` script included.
Make sure that your `php.ini` has the *Off* or 0 value for the `phar.readonly` setting.
-Also you need to create ad empty `downloads` directory in the project root.
-
-# Show Me More!
-
-You can checkout the [Httpful Landing Page](http://phphttpclient.com) for more info including many examples and [documentation](http://phphttpclient.com/docs).
+Also you need to create an empty `downloads` directory in the project root.
# Contributing
@@ -81,6 +67,18 @@ Httpful highly encourages sending in pull requests. When submitting a pull requ
# Changelog
+## 0.3.2
+
+ - REFACTOR [PR #276](https://github.com/nategood/httpful/pull/276) Add properly subclassed, more descriptive Exceptions for JSON parse errors
+
+## 0.3.1
+
+ - FIX [PR #286](https://github.com/nategood/httpful/pull/286) Fixed header case sensitivity
+
+## 0.3.0
+
+ - REFACTOR Dropped support for dead versions of PHP. Updated the PHPUnit tests.
+
## 0.2.20
- MINOR Move Response building logic into separate function [PR #193](https://github.com/nategood/httpful/pull/193)
diff --git a/vendor/nategood/httpful/composer.json b/vendor/nategood/httpful/composer.json
index dd7a5496..56e93b89 100644
--- a/vendor/nategood/httpful/composer.json
+++ b/vendor/nategood/httpful/composer.json
@@ -4,7 +4,7 @@
"homepage": "http://github.com/nategood/httpful",
"license": "MIT",
"keywords": ["http", "curl", "rest", "restful", "api", "requests"],
- "version": "0.2.20",
+ "version": "0.3.2",
"authors": [
{
"name": "Nate Good",
@@ -13,7 +13,7 @@
}
],
"require": {
- "php": ">=5.3",
+ "php": ">=7.2",
"ext-curl": "*"
},
"autoload": {
diff --git a/vendor/nategood/httpful/src/Httpful/Exception/ConnectionErrorException.php b/vendor/nategood/httpful/src/Httpful/Exception/ConnectionErrorException.php
index bba73a69..b0a33911 100644
--- a/vendor/nategood/httpful/src/Httpful/Exception/ConnectionErrorException.php
+++ b/vendor/nategood/httpful/src/Httpful/Exception/ConnectionErrorException.php
@@ -1,7 +1,54 @@
-curlErrorNumber;
+ }
+
+ /**
+ * @param string $curlErrorNumber
+ * @return $this
+ */
+ public function setCurlErrorNumber($curlErrorNumber) {
+ $this->curlErrorNumber = $curlErrorNumber;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getCurlErrorString() {
+ return $this->curlErrorString;
+ }
+
+ /**
+ * @param string $curlErrorString
+ * @return $this
+ */
+ public function setCurlErrorString($curlErrorString) {
+ $this->curlErrorString = $curlErrorString;
+
+ return $this;
+ }
+
+
}
\ No newline at end of file
diff --git a/vendor/nategood/httpful/src/Httpful/Exception/JsonParseException.php b/vendor/nategood/httpful/src/Httpful/Exception/JsonParseException.php
new file mode 100644
index 00000000..6656056f
--- /dev/null
+++ b/vendor/nategood/httpful/src/Httpful/Exception/JsonParseException.php
@@ -0,0 +1,7 @@
+decode_as_array);
if (is_null($parsed) && 'null' !== strtolower($body))
- throw new \Exception("Unable to parse response as JSON");
+ throw new JsonParseException('Unable to parse response as JSON: ' . json_last_error_msg());
return $parsed;
}
diff --git a/vendor/nategood/httpful/src/Httpful/Httpful.php b/vendor/nategood/httpful/src/Httpful/Httpful.php
index e46053d1..e235fa34 100644
--- a/vendor/nategood/httpful/src/Httpful/Httpful.php
+++ b/vendor/nategood/httpful/src/Httpful/Httpful.php
@@ -3,7 +3,7 @@
namespace Httpful;
class Httpful {
- const VERSION = '0.2.20';
+ const VERSION = '0.3.0';
private static $mimeRegistrar = array();
private static $default = null;
diff --git a/vendor/nategood/httpful/src/Httpful/Request.php b/vendor/nategood/httpful/src/Httpful/Request.php
index b9b03e64..c04d230a 100644
--- a/vendor/nategood/httpful/src/Httpful/Request.php
+++ b/vendor/nategood/httpful/src/Httpful/Request.php
@@ -17,6 +17,31 @@
* and "chainabilty" of the library.
*
* @author Nate Good
+ *
+ * @method self sendsJson()
+ * @method self sendsXml()
+ * @method self sendsForm()
+ * @method self sendsPlain()
+ * @method self sendsText()
+ * @method self sendsUpload()
+ * @method self sendsHtml()
+ * @method self sendsXhtml()
+ * @method self sendsJs()
+ * @method self sendsJavascript()
+ * @method self sendsYaml()
+ * @method self sendsCsv()
+ * @method self expectsJson()
+ * @method self expectsXml()
+ * @method self expectsForm()
+ * @method self expectsPlain()
+ * @method self expectsText()
+ * @method self expectsUpload()
+ * @method self expectsHtml()
+ * @method self expectsXhtml()
+ * @method self expectsJs()
+ * @method self expectsJavascript()
+ * @method self expectsYaml()
+ * @method self expectsCsv()
*/
class Request
{
@@ -63,13 +88,13 @@ class Request
private static $_template;
/**
- * We made the constructor private to force the factory style. This was
+ * We made the constructor protected to force the factory style. This was
* done to keep the syntax cleaner and better the support the idea of
* "default templates". Very basic and flexible as it is only intended
* for internal use.
* @param array $attrs hash of initial attribute values
*/
- private function __construct($attrs = null)
+ protected function __construct($attrs = null)
{
if (!is_array($attrs)) return;
foreach ($attrs as $attr => $value) {
@@ -204,6 +229,7 @@ public function send()
$response = $this->buildResponse($result);
curl_close($this->_ch);
+ unset($this->_ch);
return $response;
}
@@ -487,7 +513,12 @@ public function useSocks5Proxy($proxy_host, $proxy_port = 80, $auth_type = null,
*/
public function hasProxy()
{
- return isset($this->additional_curl_opts[CURLOPT_PROXY]) && is_string($this->additional_curl_opts[CURLOPT_PROXY]);
+ /* We must be aware that proxy variables could come from environment also.
+ In curl extension, http proxy can be specified not only via CURLOPT_PROXY option,
+ but also by environment variable called http_proxy.
+ */
+ return isset($this->additional_curl_opts[CURLOPT_PROXY]) && is_string($this->additional_curl_opts[CURLOPT_PROXY]) ||
+ getenv("http_proxy");
}
/**
@@ -1025,7 +1056,14 @@ public function buildResponse($result) {
if ($curlErrorNumber = curl_errno($this->_ch)) {
$curlErrorString = curl_error($this->_ch);
$this->_error($curlErrorString);
- throw new ConnectionErrorException('Unable to connect to "'.$this->uri.'": ' . $curlErrorNumber . ' ' . $curlErrorString);
+
+ $exception = new ConnectionErrorException('Unable to connect to "'.$this->uri.'": '
+ . $curlErrorNumber . ' ' . $curlErrorString);
+
+ $exception->setCurlErrorNumber($curlErrorNumber)
+ ->setCurlErrorString($curlErrorString);
+
+ throw $exception;
}
$this->_error('Unable to connect to "'.$this->uri.'".');
diff --git a/vendor/nategood/httpful/src/Httpful/Response.php b/vendor/nategood/httpful/src/Httpful/Response.php
index 9e8747ff..09996b6d 100644
--- a/vendor/nategood/httpful/src/Httpful/Response.php
+++ b/vendor/nategood/httpful/src/Httpful/Response.php
@@ -115,24 +115,7 @@ public function _parse($body)
*/
public function _parseHeaders($headers)
{
- $headers = preg_split("/(\r|\n)+/", $headers, -1, \PREG_SPLIT_NO_EMPTY);
- $parse_headers = array();
- for ($i = 1; $i < count($headers); $i++) {
- list($key, $raw_value) = explode(':', $headers[$i], 2);
- $key = trim($key);
- $value = trim($raw_value);
- if (array_key_exists($key, $parse_headers)) {
- // See HTTP RFC Sec 4.2 Paragraph 5
- // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
- // If a header appears more than once, it must also be able to
- // be represented as a single header with a comma-separated
- // list of values. We transform accordingly.
- $parse_headers[$key] .= ',' . $value;
- } else {
- $parse_headers[$key] = $value;
- }
- }
- return $parse_headers;
+ return Response\Headers::fromString($headers)->toArray();
}
public function _parseCode($headers)
diff --git a/vendor/nategood/httpful/src/Httpful/Response/Headers.php b/vendor/nategood/httpful/src/Httpful/Response/Headers.php
index 0c922a54..8e8a8cd8 100644
--- a/vendor/nategood/httpful/src/Httpful/Response/Headers.php
+++ b/vendor/nategood/httpful/src/Httpful/Response/Headers.php
@@ -20,14 +20,24 @@ private function __construct($headers)
*/
public static function fromString($string)
{
- $lines = preg_split("/(\r|\n)+/", $string, -1, PREG_SPLIT_NO_EMPTY);
- array_shift($lines); // HTTP HEADER
- $headers = array();
- foreach ($lines as $line) {
- list($name, $value) = explode(':', $line, 2);
- $headers[strtolower(trim($name))] = trim($value);
+ $headers = preg_split("/(\r|\n)+/", $string, -1, \PREG_SPLIT_NO_EMPTY);
+ $parse_headers = array();
+ for ($i = 1; $i < count($headers); $i++) {
+ list($key, $raw_value) = explode(':', $headers[$i], 2);
+ $key = trim($key);
+ $value = trim($raw_value);
+ if (array_key_exists($key, $parse_headers)) {
+ // See HTTP RFC Sec 4.2 Paragraph 5
+ // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
+ // If a header appears more than once, it must also be able to
+ // be represented as a single header with a comma-separated
+ // list of values. We transform accordingly.
+ $parse_headers[$key] .= ',' . $value;
+ } else {
+ $parse_headers[$key] = $value;
+ }
}
- return new self($headers);
+ return new self($parse_headers);
}
/**
@@ -36,7 +46,7 @@ public static function fromString($string)
*/
public function offsetExists($offset)
{
- return isset($this->headers[strtolower($offset)]);
+ return $this->getCaseInsensitive($offset) !== null;
}
/**
@@ -45,9 +55,7 @@ public function offsetExists($offset)
*/
public function offsetGet($offset)
{
- if (isset($this->headers[$name = strtolower($offset)])) {
- return $this->headers[$name];
- }
+ return $this->getCaseInsensitive($offset);
}
/**
@@ -85,4 +93,14 @@ public function toArray()
return $this->headers;
}
-}
\ No newline at end of file
+ private function getCaseInsensitive(string $key)
+ {
+ foreach ($this->headers as $header => $value) {
+ if (strtolower($key) === strtolower($header)) {
+ return $value;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/vendor/nategood/httpful/tests/Httpful/HttpfulTest.php b/vendor/nategood/httpful/tests/Httpful/HttpfulTest.php
index ad74d0d1..062973e9 100644
--- a/vendor/nategood/httpful/tests/Httpful/HttpfulTest.php
+++ b/vendor/nategood/httpful/tests/Httpful/HttpfulTest.php
@@ -21,7 +21,7 @@
define('TEST_SERVER', WEB_SERVER_HOST . ':' . WEB_SERVER_PORT);
-class HttpfulTest extends \PHPUnit_Framework_TestCase
+class HttpfulTest extends \PHPUnit\Framework\TestCase
{
const TEST_SERVER = TEST_SERVER;
const TEST_URL = 'http://127.0.0.1:8008';
@@ -32,6 +32,15 @@ class HttpfulTest extends \PHPUnit_Framework_TestCase
Content-Type: application/json
Connection: keep-alive
Transfer-Encoding: chunked\r\n";
+ const SAMPLE_JSON_HEADER_LOWERCASE =
+ "HTTP/2 200
+date: Tue, 07 Jan 2020 09:11:21 GMT
+content-type: application/json
+content-length: 513
+access-control-allow-origin: *
+access-control-allow-methods: GET, POST, PUT, PATCH, DELETE
+access-control-allow-headers: Authorization, Content-Type, Accept-Encoding, Cache-Control, DNT
+cache-control: private, must-revalidate\r\n";
const SAMPLE_JSON_RESPONSE = '{"key":"value","object":{"key":"value"},"array":[1,2,3,4]}';
const SAMPLE_CSV_HEADER =
"HTTP/1.1 200 OK
@@ -198,7 +207,7 @@ function testAccept()
$this->assertEquals(Mime::JSON, $r->expected_type);
$r->_curlPrep();
- $this->assertContains('application/json', $r->raw_headers);
+ $this->assertStringContainsString('application/json', $r->raw_headers);
}
function testCustomAccept()
@@ -208,7 +217,7 @@ function testCustomAccept()
->addHeader('Accept', $accept);
$r->_curlPrep();
- $this->assertContains($accept, $r->raw_headers);
+ $this->assertStringContainsString($accept, $r->raw_headers);
$this->assertEquals($accept, $r->headers['Accept']);
}
@@ -219,16 +228,16 @@ function testUserAgent()
$this->assertArrayHasKey('User-Agent', $r->headers);
$r->_curlPrep();
- $this->assertContains('User-Agent: ACME/1.2.3', $r->raw_headers);
- $this->assertNotContains('User-Agent: HttpFul/1.0', $r->raw_headers);
+ $this->assertStringContainsString('User-Agent: ACME/1.2.3', $r->raw_headers);
+ $this->assertStringNotContainsString('User-Agent: HttpFul/1.0', $r->raw_headers);
$r = Request::get('http://example.com/')
->withUserAgent('');
$this->assertArrayHasKey('User-Agent', $r->headers);
$r->_curlPrep();
- $this->assertContains('User-Agent:', $r->raw_headers);
- $this->assertNotContains('User-Agent: HttpFul/1.0', $r->raw_headers);
+ $this->assertStringContainsString('User-Agent:', $r->raw_headers);
+ $this->assertStringNotContainsString('User-Agent: HttpFul/1.0', $r->raw_headers);
}
function testAuthSetup()
@@ -264,7 +273,18 @@ function testJsonResponseParse()
$this->assertEquals("value", $response->body->key);
$this->assertEquals("value", $response->body->object->key);
- $this->assertInternalType('array', $response->body->array);
+ $this->assertIsArray( $response->body->array);
+ $this->assertEquals(1, $response->body->array[0]);
+ }
+
+ function testJsonResponseParseLowercaseHeaders()
+ {
+ $req = Request::init();
+ $response = new Response(self::SAMPLE_JSON_RESPONSE, self::SAMPLE_JSON_HEADER_LOWERCASE, $req);
+
+ $this->assertEquals("value", $response->body->key);
+ $this->assertEquals("value", $response->body->object->key);
+ $this->assertIsArray( $response->body->array);
$this->assertEquals(1, $response->body->array[0]);
}
@@ -276,13 +296,16 @@ function testXMLResponseParse()
$this->assertEquals("object", gettype($sxe));
$this->assertEquals("SimpleXMLElement", get_class($sxe));
$bools = $sxe->xpath('/stdClass/boolProp');
- list( , $bool ) = each($bools);
+ // list( , $bool ) = each($bools);
+ $bool = array_shift($bools);
$this->assertEquals("TRUE", (string) $bool);
$ints = $sxe->xpath('/stdClass/arrayProp/array/k1/myClass/intProp');
- list( , $int ) = each($ints);
+ // list( , $int ) = each($ints);
+ $int = array_shift($ints);
$this->assertEquals("2", (string) $int);
$strings = $sxe->xpath('/stdClass/stringProp');
- list( , $string ) = each($strings);
+ // list( , $string ) = each($strings);
+ $string = array_shift($strings);
$this->assertEquals("a string", (string) $string);
}
@@ -293,7 +316,7 @@ function testCsvResponseParse()
$this->assertEquals("Key1", $response->body[0][0]);
$this->assertEquals("Value1", $response->body[1][0]);
- $this->assertInternalType('string', $response->body[2][0]);
+ $this->assertIsString( $response->body[2][0]);
$this->assertEquals("40.0", $response->body[2][0]);
}
@@ -361,10 +384,10 @@ function testNoAutoParse()
{
$req = Request::init()->sendsAndExpects(Mime::JSON)->withoutAutoParsing();
$response = new Response(self::SAMPLE_JSON_RESPONSE, self::SAMPLE_JSON_HEADER, $req);
- $this->assertInternalType('string', $response->body);
+ $this->assertIsString( $response->body);
$req = Request::init()->sendsAndExpects(Mime::JSON)->withAutoParsing();
$response = new Response(self::SAMPLE_JSON_RESPONSE, self::SAMPLE_JSON_HEADER, $req);
- $this->assertInternalType('object', $response->body);
+ $this->assertIsObject($response->body);
}
function testParseHeaders()
@@ -378,7 +401,7 @@ function testRawHeaders()
{
$req = Request::init()->sendsAndExpects(Mime::JSON);
$response = new Response(self::SAMPLE_JSON_RESPONSE, self::SAMPLE_JSON_HEADER, $req);
- $this->assertContains('Content-Type: application/json', $response->raw_headers);
+ $this->assertStringContainsString('Content-Type: application/json', $response->raw_headers);
}
function testHasErrors()
@@ -554,6 +577,14 @@ public function testHasProxyWithProxy()
$this->assertTrue($r->hasProxy());
}
+ public function testHasProxyWithEnvironmentProxy()
+ {
+ putenv('http_proxy=http://127.0.0.1:300/');
+ $r = Request::get('some_other_url');
+ $this->assertTrue($r->hasProxy());
+ }
+
+
public function testParseJSON()
{
$handler = new JsonHandler();
@@ -570,8 +601,8 @@ public function testParseJSON()
try {
$result = $handler->parse('invalid{json');
- } catch(\Exception $e) {
- $this->assertEquals('Unable to parse response as JSON', $e->getMessage());
+ } catch (\Httpful\Exception\JsonParseException $e) {
+ $this->assertEquals('Unable to parse response as JSON: ' . json_last_error_msg(), $e->getMessage());
return;
}
$this->fail('Expected an exception to be thrown due to invalid json');
diff --git a/vendor/nategood/httpful/tests/Httpful/requestTest.php b/vendor/nategood/httpful/tests/Httpful/requestTest.php
index 32867650..7566521a 100644
--- a/vendor/nategood/httpful/tests/Httpful/requestTest.php
+++ b/vendor/nategood/httpful/tests/Httpful/requestTest.php
@@ -4,18 +4,25 @@
*/
namespace Httpful\Test;
-class requestTest extends \PHPUnit_Framework_TestCase
+class requestTest extends \PHPUnit\Framework\TestCase
{
/**
* @author Nick Fox
- * @expectedException Httpful\Exception\ConnectionErrorException
- * @expectedExceptionMessage Unable to connect
*/
public function testGet_InvalidURL()
{
// Silence the default logger via whenError override
- \Httpful\Request::get('unavailable.url')->whenError(function($error) {})->send();
+ $caught = false;
+ try
+ {
+ \Httpful\Request::get('unavailable.url')->whenError(function($error) {})->send();
+ }
+ catch (\Httpful\Exception\ConnectionErrorException $e)
+ {
+ $caught = true;
+ }
+ $this->assertTrue($caught);
}
}
diff --git a/vendor/nategood/httpful/tests/phpunit.xml b/vendor/nategood/httpful/tests/phpunit.xml
index 18ab15ab..c2c9d44b 100644
--- a/vendor/nategood/httpful/tests/phpunit.xml
+++ b/vendor/nategood/httpful/tests/phpunit.xml
@@ -8,6 +8,7 @@
+
diff --git a/version.php b/version.php
index 9b27607f..17abdef5 100644
--- a/version.php
+++ b/version.php
@@ -19,7 +19,7 @@
* @copyright 2012 iParadigms LLC
*/
-$plugin->version = 2023033001;
+$plugin->version = 2023082201;
$plugin->release = "3.5+";
$plugin->requires = 2018051700;