';
var icon = M.cfg.wwwroot + '/plagiarism/turnitinsim/pix/tiiIcon.svg';
loading += '
';
- var loadingCvStr = M.str.plagiarism_turnitinsim.loadingcv;
- loading += '
' + loadingCvStr + '
';
+
+ str.get_string('loadingcv', 'plagiarism_turnitinsim').done(function(text) {
+ loading += '
' + text + '
';
+ $('.eulacontainer').hide().html(text).fadeIn();
+ });
+
loading += '
';
$(dvWindow.document.body).html(loading);
diff --git a/amd/src/eula_response.js b/amd/src/eula_response.js
index ff45f92..87b2ecc 100644
--- a/amd/src/eula_response.js
+++ b/amd/src/eula_response.js
@@ -26,9 +26,9 @@
* @module plagiarism_turnitinsim/handleEulaResponse
*/
-define(['jquery'], function($) {
+define(['jquery', 'core/str'], function($, str) {
return {
- eula_response: function() {
+ eulaResponse: function() {
$(document).ready(function() {
$('input[name=submitbutton]').prop('disabled', 'disabled');
});
@@ -43,13 +43,18 @@ define(['jquery'], function($) {
dataType: "text",
data: {action: "accept_eula", sesskey: M.cfg.sesskey},
success: function() {
- $('.eulacontainer').hide().html(M.str.plagiarism_turnitinsim.eulaaccepted).fadeIn();
+ str.get_string('eulaaccepted', 'plagiarism_turnitinsim').done(function(text) {
+ $('.eulacontainer').hide().html(text).fadeIn();
+ });
}
});
});
$(document).on('click', '#pp-eula-decline', function() {
- $('.eulacontainer').hide().html(M.str.plagiarism_turnitinsim.euladeclined).fadeIn();
+ str.get_string('euladeclined', 'plagiarism_turnitinsim').done(function(text) {
+ $('.eulacontainer').hide().html(text).fadeIn();
+ });
+
$('input[name=submitbutton]').prop('disabled', '');
});
}
diff --git a/amd/src/inbox_eula_launch.js b/amd/src/inbox_eula_launch.js
index d8e2dbe..1fd49de 100644
--- a/amd/src/inbox_eula_launch.js
+++ b/amd/src/inbox_eula_launch.js
@@ -24,7 +24,7 @@ define(['jquery',
],
function($, Templates, ModalFactory, ModalTcEula) {
return {
- inbox_eula_launch: function() {
+ inboxEulaLaunch: function() {
var trigger = $('.eula-row-launch');
ModalFactory.create(
diff --git a/amd/src/modal_eula.js b/amd/src/modal_eula.js
index c62a65f..034464f 100644
--- a/amd/src/modal_eula.js
+++ b/amd/src/modal_eula.js
@@ -74,7 +74,7 @@ define(
Config.wwwroot + '/plagiarism/turnitinsim/eula.php?cmd=eularedirect&sesskey=' + Config.sesskey,
'_blank'
);
- }.bind(this));
+ });
// On accepting the EULA, update the db and queue submissions for this module.
this.getModal().on(CustomEvents.events.activate, SELECTORS.ACCEPT_BUTTON, function() {
@@ -89,7 +89,7 @@ define(
contextid: Config.contextid,
sesskey: Config.sesskey
},
- success: function () {
+ success: function() {
modal.hide();
var link = window.location.origin + window.location.pathname + window.location.search + '&eula=1';
window.location.href = link;
diff --git a/amd/src/resend_submission.js b/amd/src/resend_submission.js
index c87b5b8..5cbb00f 100644
--- a/amd/src/resend_submission.js
+++ b/amd/src/resend_submission.js
@@ -26,7 +26,7 @@
* @module plagiarism_turnitinsim/resendSubmission
*/
-define(['jquery'], function($) {
+define(['jquery', 'core/str'], function($, str) {
return {
resendSubmission: function() {
$(document).on('click', '.pp_resubmit_link', function() {
@@ -37,7 +37,7 @@ define(['jquery'], function($) {
// Moodle forums strip ids from elements so we have to use classes.
var classList = $(this).attr('class').split(/\s+/);
var submissionid = 0;
- $(classList).each(function(index){
+ $(classList).each(function(index) {
if (classList[index].match("^pp_resubmit_id_")) {
submissionid = classList[index].split("_")[3];
}
@@ -50,7 +50,11 @@ define(['jquery'], function($) {
data: {action: "resubmit_event", submissionid: submissionid, sesskey: M.cfg.sesskey},
success: function() {
that.siblings('.turnitinsim_status').removeClass('hidden');
- that.siblings('.tii_status_text').html(M.str.plagiarism_turnitinsim.submissiondisplaystatusqueued);
+
+ str.get_string('euladeclined', 'plagiarism_turnitinsim').done(function(text) {
+ that.siblings('.tii_status_text').html(text);
+ });
+
that.siblings('.pp_resubmitting').addClass('hidden');
},
error: function() {
diff --git a/amd/src/set_report_generation.js b/amd/src/set_report_generation.js
index a6ca6a4..bee955e 100644
--- a/amd/src/set_report_generation.js
+++ b/amd/src/set_report_generation.js
@@ -28,7 +28,7 @@
define(['jquery'], function($) {
return {
- set_report_generation: function() {
+ setReportGeneration: function() {
$(document).on('click', 'input[name="duedate[enabled]"]', function() {
if (!$(this).is(":checked")) {
$('select[name=reportgeneration]')[0].selectedIndex = 0;
diff --git a/backup/moodle2/backup_plagiarism_turnitinsim_plugin.class.php b/backup/moodle2/backup_plagiarism_turnitinsim_plugin.class.php
index ba71953..76f3431 100644
--- a/backup/moodle2/backup_plagiarism_turnitinsim_plugin.class.php
+++ b/backup/moodle2/backup_plagiarism_turnitinsim_plugin.class.php
@@ -25,8 +25,18 @@
defined('MOODLE_INTERNAL') || die();
+/**
+ * Used when backing up data created by the plugin.
+ */
class backup_plagiarism_turnitinsim_plugin extends backup_plagiarism_plugin {
+ /**
+ * Required by Moodle's backup tool to define the plugin structure.
+ *
+ * @return backup_plugin_element
+ * @throws backup_step_exception
+ * @throws base_element_struct_exception
+ */
protected function define_module_plugin_structure() {
$plugin = $this->get_plugin_element();
diff --git a/backup/moodle2/restore_plagiarism_turnitinsim_plugin.class.php b/backup/moodle2/restore_plagiarism_turnitinsim_plugin.class.php
index 1bc2aa9..80a2bd8 100644
--- a/backup/moodle2/restore_plagiarism_turnitinsim_plugin.class.php
+++ b/backup/moodle2/restore_plagiarism_turnitinsim_plugin.class.php
@@ -25,6 +25,9 @@
defined('MOODLE_INTERNAL') || die();
+/**
+ * Used when restoring data created by the plugin.
+ */
class restore_plagiarism_turnitinsim_plugin extends restore_plagiarism_plugin {
/**
@@ -42,6 +45,9 @@ protected function define_module_plugin_structure() {
/**
* Restore the Turnitin settings for this module.
* This will only be done if the module is from the same site from where it was backed up.
+ *
+ * @param $data object The data we are restoring.
+ * @throws dml_exception
*/
public function process_turnitinsim_mods($data) {
global $DB;
@@ -59,6 +65,9 @@ public function process_turnitinsim_mods($data) {
* Restore the links to Turnitin submissions.
* This will only be done if the module is from the same site from where it was backed up
* and if the Turnitin submission does not currently exist in the database.
+ *
+ * @param $data object The data we are restoring.
+ * @throws dml_exception
*/
public function process_turnitinsim_subs($data) {
global $DB, $SESSION;
@@ -83,6 +92,9 @@ public function process_turnitinsim_subs($data) {
* Restore the Turnitin users.
* This will only be done if the module is from the same site from where it was backed up
* and if the Turnitin user id does not currently exist in the database.
+ *
+ * @param $data object The data we are restoring.
+ * @throws dml_exception
*/
public function process_turnitinsim_usrs($data) {
global $DB;
diff --git a/callbacks.php b/callbacks.php
index ef3523d..56a4803 100644
--- a/callbacks.php
+++ b/callbacks.php
@@ -86,7 +86,8 @@
}
// Handle Similarity complete callback.
-if ($reqheaders['X-Turnitin-EventType'] == TURNITINSIM_SIMILARITY_COMPLETE || $reqheaders['X-Turnitin-EventType'] == TURNITINSIM_SIMILARITY_UPDATED) {
+if ($reqheaders['X-Turnitin-EventType'] == TURNITINSIM_SIMILARITY_COMPLETE ||
+ $reqheaders['X-Turnitin-EventType'] == TURNITINSIM_SIMILARITY_UPDATED) {
// Get Moodle submission id from Turnitin id.
$submission = $DB->get_record_select('plagiarism_turnitinsim_sub', 'turnitinid = ?', array($params->submission_id));
$tssubmission = new plagiarism_turnitinsim_submission( new plagiarism_turnitinsim_request(), $submission->id );
diff --git a/classes/assign.class.php b/classes/assign.class.php
index d8bc4a0..29d68a7 100644
--- a/classes/assign.class.php
+++ b/classes/assign.class.php
@@ -25,13 +25,17 @@
defined('MOODLE_INTERNAL') || die();
+/**
+ * Helper class for plagiarism_turnitinsim component in assignments
+ */
class plagiarism_turnitinsim_assign {
/**
* Get the text from the database for the submission.
*
- * @param $itemid
- * @return mixed
+ * @param $itemid String The itemid for this submission.
+ * @return mixed The text of the submission.
+ * @throws dml_exception
*/
public function get_onlinetext($itemid) {
global $DB;
@@ -44,8 +48,9 @@ public function get_onlinetext($itemid) {
/**
* Get the item id from the database for this submission.
*
- * @param $params
- * @return mixed
+ * @param $params object The params to call the DB with.
+ * @return int The itemid.
+ * @throws dml_exception
*/
public function get_itemid($params) {
global $DB;
@@ -65,10 +70,13 @@ public function get_itemid($params) {
/**
* Get the actual author of the submission.
*
- * @param $userid
- * @param $relateduserid
- * @param $cm
- * @param $itemid
+ * @param $userid int The userid as given by Moodle.
+ * @param $relateduserid int The relateduserid as given by Moodle.
+ * @param $cm object The course module.
+ * @param $itemid string the itemid for this submission.
+ * @return int The authorid.
+ * @throws coding_exception
+ * @throws dml_exception
*/
public function get_author($userid, $relateduserid, $cm, $itemid) {
$author = (!empty($relateduserid)) ? $relateduserid : $userid;
@@ -94,8 +102,9 @@ public function get_author($userid, $relateduserid, $cm, $itemid) {
/**
* Get the group id that a submission belongs to.
*
- * @param $itemid
- * @return int
+ * @param $itemid string The itemid for the submission.
+ * @return int The group id.
+ * @throws dml_exception
*/
public function get_groupid($itemid) {
global $DB;
@@ -105,13 +114,14 @@ public function get_groupid($itemid) {
return (!empty($moodlesubmission->groupid)) ? $moodlesubmission->groupid : null;
}
- /*
+ /**
* Related user ID will be NULL if an instructor submits on behalf of a student who is in a group.
* To get around this, we get the group ID, get the group members and set the author as the first student in the group.
* @param int $courseid - The course ID.
* @param int $groupid - The ID of the Moodle group that we're getting from.
* @return int $author The Moodle user ID that we'll be using for the author.
+ * @throws coding_exception
*/
public function get_first_group_author($courseid, $groupid) {
static $context;
@@ -132,8 +142,9 @@ public function get_first_group_author($courseid, $groupid) {
/**
* Return whether the submission is a draft.
*
- * @param $itemid
- * @return bool
+ * @param $itemid string The itemid for the submission.
+ * @return bool If the submission is a draft.
+ * @throws dml_exception
*/
public function is_submission_draft($itemid) {
global $DB;
@@ -143,9 +154,12 @@ public function is_submission_draft($itemid) {
return ($moodlesubmission->status == 'draft') ? true : false;
}
- /*
+ /**
* Get the assignment due date.
- * @param $id
+ *
+ * @param $id int The assignment ID we want the due date for.
+ * @return mixed The due date for the assignment.
+ * @throws dml_exception
*/
public function get_due_date($id) {
global $DB;
@@ -155,12 +169,12 @@ public function get_due_date($id) {
return $module->duedate;
}
- /*
+ /**
* Determines whether the OR links in other posts should be seen. This is not applicable for assignments.
*
- * @param $courseid
- * @param $userid
- * @return bool
+ * @param $courseid int The ID for this course.
+ * @param $userid int The userid.
+ * @return bool if showing other posts links.
*/
public function show_other_posts_links($courseid, $userid) {
return true;
diff --git a/classes/callback.class.php b/classes/callback.class.php
index e8acf8e..f3654af 100644
--- a/classes/callback.class.php
+++ b/classes/callback.class.php
@@ -27,10 +27,18 @@
defined('MOODLE_INTERNAL') || die();
+/**
+ * Class for handling callbacks from Turnitin.
+ */
class plagiarism_turnitinsim_callback {
public $tsrequest;
+ /**
+ * plagiarism_turnitinsim_callback constructor.
+ *
+ * @param plagiarism_turnitinsim_request|null $tsrequest The request we're handling.
+ */
public function __construct(plagiarism_turnitinsim_request $tsrequest = null ) {
$this->tsrequest = $tsrequest;
}
@@ -38,10 +46,10 @@ public function __construct(plagiarism_turnitinsim_request $tsrequest = null ) {
/**
* Attempt to retrieve the webhook.
*
- * @param $webhookid
- * @return bool
+ * @param $webhookid string The webhookid to check.
+ * @return bool true if has webhook.
*/
- public function get_webhook($webhookid) {
+ public function has_webhook($webhookid) {
// Make request to get webhook.
try {
$endpoint = TURNITINSIM_ENDPOINT_GET_WEBHOOK;
@@ -78,8 +86,8 @@ public function get_webhook($webhookid) {
/**
* Attempt to delete the webhook (not currently used).
*
- * @param $webhookid
- * @return bool
+ * @param $webhookid string The webhookid to be deleted.
+ * @return bool true if webhook has been deleted.
*/
public function delete_webhook($webhookid) {
// Make request to get webhook.
@@ -115,7 +123,11 @@ public function create_webhook() {
$request['signing_secret'] = $secret;
$request['description'] = get_string('webhook_description', 'plagiarism_turnitinsim', TURNITINSIM_CALLBACK_URL);
$request['url'] = TURNITINSIM_CALLBACK_URL;
- $request['event_types'] = array(TURNITINSIM_SUBMISSION_COMPLETE, TURNITINSIM_SIMILARITY_COMPLETE, TURNITINSIM_SIMILARITY_UPDATED);
+ $request['event_types'] = array(
+ TURNITINSIM_SUBMISSION_COMPLETE,
+ TURNITINSIM_SIMILARITY_COMPLETE,
+ TURNITINSIM_SIMILARITY_UPDATED
+ );
$request['allow_insecure'] = preg_match("@^https?://@", $CFG->wwwroot) ? true : false;
// Make request to add webhook.
@@ -141,11 +153,15 @@ public function create_webhook() {
}
/**
- * Handle callbacks from Turnitin.
+ * Generate a 64 character length hash of the request string.
+ *
+ * @param $requeststring string The request in string format.
+ * @return string A 64 character length hash.
+ * @throws dml_exception
*/
- public function expected_callback_signature($requeststr) {
+ public function expected_callback_signature($requeststring) {
$secret = get_config('plagiarism_turnitinsim', 'turnitin_webhook_secret');
- $sig = hash_hmac('sha256', $requeststr, base64_decode($secret));
+ $sig = hash_hmac('sha256', $requeststring, base64_decode($secret));
return $sig;
}
@@ -153,7 +169,8 @@ public function expected_callback_signature($requeststr) {
/**
* Generate random webhook secret.
*
- * @return string
+ * @return string Random webhook secret.
+ * @throws Exception
*/
public function generate_secret() {
$randomstring = random_bytes(20);
diff --git a/classes/defaults_form.class.php b/classes/defaults_form.class.php
index e0260be..34cbcb2 100644
--- a/classes/defaults_form.class.php
+++ b/classes/defaults_form.class.php
@@ -15,7 +15,7 @@
// along with Moodle. If not, see