Skip to content

Commit 9c2c533

Browse files
authored
Merge pull request #629 from turnitin/develop
Release 2022072501
2 parents fd36a2b + 44d7a4d commit 9c2c533

14 files changed

+213
-13
lines changed

CHANGELOG.md

+49
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,52 @@
1+
### Date: 2022-July-25
2+
### Release: v2022072501
3+
4+
#### :zap: What's new
5+
6+
---
7+
8+
We’ve had several community members actively contribute towards making the Moodle plagiarism plugin the best it can be, with some insightful and much appreciated pull requests. Check out all the latest improvements, with special thanks to our community members who have contributed towards them.
9+
10+
#### Moodle Quizzes will perform better when many users take a quiz that involves essay-based questions
11+
12+
When viewing a Moodle Quiz results, Turnitin would request the CMID (Course Module ID) multiple times, even after it had already been provided. This could cause classes to see performance issues when a larger class used essay-based questions as a part of their Moodle Quiz. This enhancement fixes the issue and users should expect to see increased performance when using Moodle Quizzes with larger classes now.
13+
14+
With special thanks to [@aolley](https://github.com/aolley) for this contribution.
15+
16+
#### Performance improvements when Turnitin isn’t enabled for a Moodle activity
17+
18+
When Turnitin wasn’t enabled for a Moodle activity, multiple database calls would still be run for each user within the activity, resulting is a lot of unnecessary extra database load. This change removes these checks when Turnitin is not enabled. Users should expect to see some performance enhancements, particularly in larger classes.
19+
20+
With special thanks to [@danmarsden](https://github.com/danmarsden) for this contribution.
21+
22+
#### Database schema is now consistent when upgrading to a new version of the plugin
23+
24+
This change fixes an issue where there was an alignment issue between the install and upgrade scripts, resulting in multiple is mismatches.
25+
26+
With special thanks to [@golenkovm](https://github.com/golenkovm) and [@TomoTsuyuki](https://github.com/TomoTsuyuki) for the fix, and kristian-94 for their thorough initial investigation.
27+
28+
#### Messages sent by Turnitin to instructors and students now apply the Moodle filters
29+
30+
Filters can be used in Moodle to convert or change a message into a richer form of media. This includes creating links, converting mathematical formula into images, and even showing multiple languages at once on screen.
31+
32+
Any messages sent by Turnitin will now work with these filters.
33+
34+
With special thanks to [@izendegi](https://github.com/izendegi) for this contribution.
35+
36+
#### Turnitin EULA prompt will now show at all times when using Moodle Forums
37+
38+
When using a Moodle Forum, making an reply on the same page would not show the prompt to accept the Turnitin EULA for processing. The prompt would still be shown the first time the page is loaded. Users can now expect to see the EULA prompt on each interaction they would do in a forum that would potentially generate a Similarity Report if the EULA was accepted.
39+
40+
With special thanks to [@jonof](https://github.com/jonof) for this contribution.
41+
42+
#### Quiz attempt grades will set correct after opening the Similarity Report
43+
44+
Opening the Similarity Report in a quiz attempt could in some situations alter the calculated grade for a student. User can expect for the Similarity Report to no longer affect the calculated grade.
45+
46+
With special thanks again to [@jonof](https://github.com/jonof) for their contribution.
47+
48+
---
49+
150
### Date: 2022-March-23
251
### Release: 2022032301
352

amd/build/eula.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/build/eula.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/src/eula.js

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ define(['jquery',
1919
var turnitinEulaClass = $(".pp_turnitin_eula");
2020
turnitinEulaClass.show();
2121

22+
// Show the 'accept EULA' prompt for new in-page forum replies.
23+
$(document).on('mod_forum-post-created', '.forum-post-container', function (event, newid) {
24+
var turnitinEulaClass = $("#post-content-" + newid + " .pp_turnitin_eula");
25+
turnitinEulaClass.show();
26+
});
27+
2228
$(document).on('click', '.pp_turnitin_eula_link', function() {
2329
ModalFactory.create({
2430
type: ModalEulaLaunch.TYPE,

classes/digitalreceipt/pp_receipt_message.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function build_message($input) {
7373
$message->submission_date = $input['submission_date'];
7474
$message->submission_id = $input['submission_id'];
7575

76-
return get_string('pp_digital_receipt_message', 'plagiarism_turnitin', $message);
76+
return format_text(get_string('pp_digital_receipt_message', 'plagiarism_turnitin', $message));
7777
}
7878

7979
/**
@@ -96,7 +96,7 @@ public function build_instructor_message($input) {
9696
$message->submission_date = $input['submission_date'];
9797
$message->submission_id = $input['submission_id'];
9898

99-
return get_string('receipt_instructor_copy', 'plagiarism_turnitin', $message);
99+
return format_text(get_string('receipt_instructor_copy', 'plagiarism_turnitin', $message));
100100
}
101101

102102
/**

classes/modules/turnitin_quiz.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function update_mark($attemptid, $identifier, $userid, $grade, $quizgrade
7676
$transaction = $DB->start_delegated_transaction();
7777

7878
$attempt = quiz_attempt::create($attemptid);
79-
$quba = question_engine::load_questions_usage_by_activity($attemptid);
79+
$quba = question_engine::load_questions_usage_by_activity($attempt->get_uniqueid());
8080

8181
// Loop through each question slot.
8282
foreach ($attempt->get_slots() as $slot) {

db/upgrade.php

+51
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,57 @@ function xmldb_plagiarism_turnitin_upgrade($oldversion) {
500500
upgrade_plugin_savepoint(true, 2021081301, 'plagiarism', 'turnitin');
501501
}
502502

503+
if ($oldversion < 2022072501) {
504+
$table = new xmldb_table('plagiarism_turnitin_config');
505+
$index = new xmldb_index('config_hash', XMLDB_INDEX_UNIQUE, array('config_hash'));
506+
$field = new xmldb_field('config_hash', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'value');
507+
if ($dbman->field_exists($table, $field)) {
508+
// Double-check that there is no records with a NULL value.
509+
if ($DB->count_records_select('plagiarism_turnitin_config', 'config_hash IS NULL') == 0) {
510+
// Delete index if exists.
511+
if ($dbman->index_exists($table, $index)) {
512+
$dbman->drop_index($table, $index);
513+
}
514+
// Set config_hash to be NOT NULL, also set precision 255.
515+
$dbman->change_field_notnull($table, $field);
516+
}
517+
}
518+
519+
// Set userid to be NOT NULL.
520+
$table = new xmldb_table('plagiarism_turnitin_users');
521+
$index = new xmldb_index('userid', XMLDB_INDEX_UNIQUE, array('userid'));
522+
$field = new xmldb_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'id');
523+
if ($dbman->field_exists($table, $field)) {
524+
// Double-check that there is no records with a NULL value.
525+
if ($DB->count_records_select('plagiarism_turnitin_users', 'userid IS NULL') == 0) {
526+
// Drop and then recreate unique index, otherwise Moodle will throw dependency exception.
527+
if ($dbman->index_exists($table, $index)) {
528+
$dbman->drop_index($table, $index);
529+
}
530+
$dbman->change_field_notnull($table, $field);
531+
$dbman->add_index($table, $index);
532+
}
533+
}
534+
535+
// Set courseid to be NOT NULL.
536+
$table = new xmldb_table('plagiarism_turnitin_courses');
537+
$index = new xmldb_index('courseid', XMLDB_INDEX_UNIQUE, array('courseid'));
538+
$field = new xmldb_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'id');
539+
if ($dbman->field_exists($table, $field)) {
540+
// Double-check that there is no records with a NULL value.
541+
if ($DB->count_records_select('plagiarism_turnitin_courses', 'courseid IS NULL') == 0) {
542+
// Drop and then recreate unique index, otherwise Moodle will throw dependency exception.
543+
if ($dbman->index_exists($table, $index)) {
544+
$dbman->drop_index($table, $index);
545+
}
546+
$dbman->change_field_notnull($table, $field);
547+
$dbman->add_index($table, $index);
548+
}
549+
}
550+
551+
upgrade_plugin_savepoint(true, 2022072501, 'plagiarism', 'turnitin');
552+
}
553+
503554
return $result;
504555
}
505556

lib.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ public function get_links($linkarray) {
657657

658658
// If this is a quiz, retrieve the cmid
659659
$component = (!empty($linkarray['component'])) ? $linkarray['component'] : "";
660-
if ($component == "qtype_essay" && !empty($linkarray['area'])) {
660+
if ($component == "qtype_essay" && !empty($linkarray['area']) && empty($linkarray['cmid'])) {
661661
$questions = question_engine::load_questions_usage_by_activity($linkarray['area']);
662662

663663
// Try to get cm using the questions owning context.
@@ -686,8 +686,8 @@ public function get_links($linkarray) {
686686
}
687687

688688
// Retrieve the plugin settings for this module.
689-
static $plagiarismsettings;
690-
if (empty($plagiarismsettings)) {
689+
static $plagiarismsettings = null;
690+
if (is_null($plagiarismsettings)) {
691691
$plagiarismsettings = $this->get_settings($linkarray["cmid"]);
692692
}
693693

tests/classes/turnitin_assignment_class_test.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class plagiarism_turnitin_assignment_class_testcase extends advanced_testcase {
3939
/**
4040
* Set Overwrite mtrace to avoid output during the tests.
4141
*/
42-
public function setup() {
42+
public function setUp(): void {
4343
global $CFG;
4444

4545
// Overwrite mtrace.

tests/classes/turnitin_user_class_test.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class plagiarism_turnitin_user_class_testcase extends plagiarism_turnitin_test_l
4242
/**
4343
* Set Overwrite mtrace to avoid output during the tests.
4444
*/
45-
public function setup() {
45+
public function setUp(): void {
4646
// Stub a fake tii comms.
4747
$this->faketiicomms = $this->getMockBuilder(turnitin_comms::class)
4848
->disableOriginalConstructor()

tests/modules/turnitin_assign_test.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class plagiarism_turnitin_assign_testcase extends advanced_testcase {
3838
/**
3939
* Create a course and assignment module instance
4040
*/
41-
public function setup() {
41+
public function setUp(): void {
4242
$this->course = $this->getDataGenerator()->create_course();
4343
$params = array(
4444
'course' => $this->course->id,

tests/modules/turnitin_forum_test.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class plagiarism_turnitin_forum_testcase extends advanced_testcase {
3737
/**
3838
* Create a course and forum module instance
3939
*/
40-
public function setup() {
40+
public function setUp(): void {
4141
// Create a course, user and a forum.
4242
$course = $this->getDataGenerator()->create_course();
4343
$user = $this->getDataGenerator()->create_user();

0 commit comments

Comments
 (0)