Skip to content

Commit

Permalink
Merge pull request #185 from turnitin/develop
Browse files Browse the repository at this point in the history
Release 25th November
  • Loading branch information
jack-tii authored Nov 25, 2024
2 parents 3ccbc32 + c5b0edc commit 2b043bc
Show file tree
Hide file tree
Showing 19 changed files with 194 additions and 87 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
### Date: 2024-November-25
### Release: v2024112501

#### Fixed a bug with Anonymous Marking

Previously, if a student submitted with anonymous marking enabled for the assignment, their email would sometimes be visible when viewing the online similarity report. This has now been fixed.

#### Streamlined Eula Workflow

In line with our other plagiarism plugin we have removed the Eula decline button, simplifying the Eula acceptance workflow.

#### Added Userlist Provider for Privacy Compliance

Previously we were missing a userlist provider for this plugin. We have now added this.

---

### Date: 2023-June-29
### Release: v2023062901
(Moodle Integration Only graphic)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ 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.
Before installing this plugin firstly make sure you are logged in as an Administrator and that you are using Moodle 4.1 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.

Expand Down
4 changes: 2 additions & 2 deletions amd/build/eula_response.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/eula_response.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions amd/src/eula_response.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ define(['jquery', 'core/str'], function($, str) {
$(document).ready(function() {
if ($("#turnitinsim_eulacontainer").length) {
$('input[name=submitbutton]').prop('disabled', 'disabled');
$('.editsubmissionform').hide();
$('.mform').hide();
}
});

Expand All @@ -50,6 +52,8 @@ define(['jquery', 'core/str'], function($, str) {

str.get_string('submissiondisplaystatus:queued', 'plagiarism_turnitinsim').done(function(text) {
$('.tii_status_text').html(text);
$('.editsubmissionform').show();
$('.mform').show();
});
});
}
Expand Down
17 changes: 12 additions & 5 deletions backup/moodle2/backup_plagiarism_turnitinsim_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class backup_plagiarism_turnitinsim_plugin extends backup_plagiarism_plugin {
* @throws base_element_struct_exception
*/
protected function define_module_plugin_structure() {
global $DB;

$plugin = $this->get_plugin_element();

$pluginelement = new backup_nested_element($this->get_recommended_name());
Expand Down Expand Up @@ -71,18 +73,23 @@ protected function define_module_plugin_structure() {
$pluginelement->add_child($submissions);
$submissions->add_child($submission);

// Get submission details along with contenthash from files table.
$submission->set_source_sql(
// Get submission details
$submissiondetails = $DB->get_records_sql(
'SELECT PTS.userid, PTS.turnitinid, PTS.status, PTS.identifier, PTS.itemid, PTS.type,
PTS.submittedtime, PTS.togenerate, PTS.generationtime, PTS.overallscore, PTS.requestedtime,
PTS.errormessage, F.contenthash
PTS.errormessage
FROM {plagiarism_turnitinsim_sub} PTS
LEFT JOIN {files} F
ON PTS.identifier = F.pathnamehash
WHERE PTS.cm = ? ',
array(backup::VAR_PARENTID)
);

// Use file API to get content hash
$fs = get_file_storage();
$file = $fs->get_file_by_hash($submissiondetails->identifier);
$submissiondetails['contenthash'] = $file->contenthash;

$submission->set_source_array($submissiondetails);

// Backup users who have submitted to this module.
$users = new backup_nested_element('turnitinsim_usrs');
$user = new backup_nested_element(
Expand Down
2 changes: 1 addition & 1 deletion classes/defaults_form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function definition () {
$mform =& $this->_form;

$plugin = new plagiarism_plugin_turnitinsim();
$plugin->get_form_elements_module($mform, context_system::instance());
$plugin->add_elements_to_settings_form($mform, context_system::instance());

$this->add_action_buttons(true);
}
Expand Down
70 changes: 70 additions & 0 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
defined('MOODLE_INTERNAL') || die();

use core_privacy\local\metadata\collection;
use core_privacy\local\request\approved_userlist;
use core_privacy\local\request\contextlist;
use core_privacy\local\request\helper;
use core_privacy\local\request\userlist;
use core_privacy\local\request\writer;

/**
Expand All @@ -38,6 +40,7 @@
class provider implements
// This plugin does store personal user data.
\core_privacy\local\metadata\provider,
\core_privacy\local\request\core_userlist_provider,
\core_plagiarism\privacy\plagiarism_provider {

// This trait must be included to provide the relevant polyfill for the metadata provider.
Expand Down Expand Up @@ -204,4 +207,71 @@ public static function _delete_plagiarism_for_user($userid, \context $context) {
$DB->delete_records('plagiarism_turnitinsim_sub', ['userid' => $userid]);
$DB->delete_records('plagiarism_turnitinsim_users', ['userid' => $userid]);
}

/**
* Get a list of users who have data within a context.
*
* @param userlist $userlist The userlist containing the list of users who have data in this context/plugin combination.
*/
public static function get_users_in_context(userlist $userlist) {
$context = $userlist->get_context();

if ($context->contextlevel != CONTEXT_MODULE) {
return;
}

$sql = "SELECT pts.userid
FROM {plagiarism_turnitinsim_sub} pts
JOIN {course_modules} c
ON pts.cm = c.id
JOIN {modules} m
ON m.id = c.module AND m.name = :modname
WHERE c.id = :cmid";

$params = [
'modname' => 'plagiarism_turnitinsim',
'cmid' => $context->instanceid
];

$userlist->add_from_sql('userid', $sql, $params);
}

/**
* Delete data for multiple users within a single context.
*
* @param approved_userlist $userlist The approved context and user information to delete information for.
*/
public static function delete_data_for_users(approved_userlist $userlist) {
global $DB;

$context = $userlist->get_context();

if ($context->contextlevel != CONTEXT_MODULE) {
return;
}

$userids = $userlist->get_userids();

list($insql, $inparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);

$sql1 = "SELECT pts.id
FROM {plagiarism_turnitinsim_sub} pts
JOIN {course_modules} c
ON pts.cm = c.id
JOIN {modules} m
ON m.id = c.module AND m.name = :modname
WHERE pts.userid $insql
AND c.id = :cmid";

$params = [
'modname' => 'plagiarism_turnitinsim',
'cmid' => $context->instanceid
];

$params = array_merge($params, $inparams);

$attempt = $DB->get_fieldset_sql($sql1, $params);

$DB->delete_records_list('plagiarism_turnitinsim_sub', 'id', array_values($attempt));
}
}
4 changes: 2 additions & 2 deletions classes/quiz.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function get_onlinetext($itemid) {
public function get_itemid($params) {
global $DB;

$item = $DB->get_record_sql('SELECT DISTINCT(q.id) FROM {question_attempt_steps} s
$item = $DB->get_record_sql('SELECT DISTINCT(q.uniqueid) FROM {question_attempt_steps} s
RIGHT JOIN {question_attempts} a
ON s.questionattemptid = a.id
RIGHT JOIN {quiz_attempts} q
Expand All @@ -69,7 +69,7 @@ public function get_itemid($params) {
array($params->moduleid, $params->userid, $params->onlinetext, 'finished')
);

return ($item) ? $item->id : 0;
return ($item) ? $item->uniqueid : 0;
}

/**
Expand Down
31 changes: 15 additions & 16 deletions classes/submission.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ class plagiarism_turnitinsim_submission {
*/
public $tsrequest;

/**
* @var object The plugin object.
*/
public $plugin;

/**
* plagiarism_turnitinsim_submission constructor.
*
Expand All @@ -152,7 +157,7 @@ public function __construct(plagiarism_turnitinsim_request $tsrequest = null, $i

$this->setid($id);
$this->tsrequest = ($tsrequest) ? $tsrequest : new plagiarism_turnitinsim_request();
$this->plagiarism_plugin_turnitinsim = new plagiarism_plugin_turnitinsim();
$this->plugin = new plagiarism_plugin_turnitinsim();

if (!empty($id)) {
$submission = $DB->get_record('plagiarism_turnitinsim_sub', array('id' => $id));
Expand Down Expand Up @@ -209,7 +214,7 @@ public function calculate_generation_time($generated = false) {
return;
}

$plagiarismsettings = $this->plagiarism_plugin_turnitinsim->get_settings($cm->id);
$plagiarismsettings = $this->plugin->get_settings($cm->id);

// Create module object.
$moduleclass = 'plagiarism_turnitinsim_'.$cm->modname;
Expand Down Expand Up @@ -290,7 +295,7 @@ public function build_user_array_entry($user) {

$userdata = array('id' => $tsuser->get_turnitinid());

if (!get_config('plagiarism_turnitinsim', 'turnitinhideidentity')) {
if (!$this->is_submission_anonymous()) {
$userdata["family_name"] = $user->lastname;
$userdata["given_name"] = $user->firstname;
$userdata["email"] = $user->email;
Expand Down Expand Up @@ -737,8 +742,7 @@ public function send_digital_receipts($filename) {
*/
public function request_turnitin_report_generation($regenerateonduedate = false) {
// Get module settings.
$plugin = new plagiarism_plugin_turnitinsim();
$modulesettings = $plugin->get_settings($this->getcm());
$modulesettings = $this->plugin->get_settings($this->getcm());
$cm = get_coursemodule_from_id('', $this->getcm());

// Create module helper object.
Expand Down Expand Up @@ -967,7 +971,7 @@ public function create_report_viewer_permissions() {
return array(
'may_view_submission_full_source' => (!empty($turnitinviewerviewfullsource)) ? true : false,
'may_view_match_submission_info' => (!empty($turnitinviewermatchsubinfo)) &&
!$this->is_submission_anonymous() ? true : false,
!$this->is_submission_anonymous(),
'may_view_save_viewer_changes' => (!empty($turnitinviewersavechanges)) ? true : false
);
}
Expand Down Expand Up @@ -1060,18 +1064,13 @@ public function is_submission_anonymous() {
$cm = get_coursemodule_from_id('', $this->getcm());
$moduledata = $DB->get_record($cm->modname, array('id' => $cm->instance));

$blindmarkingon = !empty($moduledata->blindmarking);
$identitiesrevealed = !empty($moduledata->revealidentities);

// Return true if hide identities is on, otherwise go by module blind marking settings.
// Check if Hide Student's Identity is set at the plugin settings level, otherwise go by module blind marking settings.
$turnitinhideidentity = get_config('plagiarism_turnitinsim', 'turnitinhideidentity');
if ($turnitinhideidentity) {
$anon = true;
} else {
$anon = $blindmarkingon && !$identitiesrevealed;
}

return $anon;
// Check if blind marking is on and revealidentities is not set yet.
$blindon = (!empty($moduledata->blindmarking) && empty($moduledata->revealidentities));

return $blindon || $turnitinhideidentity;
}

/**
Expand Down
Loading

0 comments on commit 2b043bc

Please sign in to comment.