Skip to content

Commit e8c0c5c

Browse files
authored
Merge pull request #149 from turnitin/develop
Release v2023042001
2 parents 655d87a + 37c275f commit e8c0c5c

7 files changed

+68
-15
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
### Date: 2023-April-20
2+
### Release: v2023042001
3+
4+
#### Turnitin language settings are now syncing with Moodle environment
5+
6+
This release addresses an issue where the report viewer and the EULA pages were defaulting to English only for most languages, even when the Turnitin account is set to a different language. This has now been fixed and the correct language should be displayed to match what is set.
7+
8+
---
9+
110
### Date: 2022-September-21
211
### Release: v2022092101
312

classes/eula.class.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ public function get_latest_version() {
5656

5757
// Make request to get the latest EULA version.
5858
try {
59-
$endpoint = TURNITINSIM_ENDPOINT_GET_LATEST_EULA;
59+
$lang = $this->tsrequest->get_language();
60+
$langcode = $lang->localecode;
61+
$endpoint = TURNITINSIM_ENDPOINT_GET_LATEST_EULA."?lang=".$langcode;
6062
$response = $this->tsrequest->send_request($endpoint, json_encode(array()), 'GET');
6163
$responsedata = json_decode($response);
6264

classes/request.class.php

+36-4
Original file line numberDiff line numberDiff line change
@@ -330,16 +330,48 @@ public function get_language() {
330330

331331
// Replace with language code for CV launch.
332332
$langarray = array(
333-
'de' => 'de',
333+
'da' => 'da',
334+
'de' => 'de',
334335
'de_du' => 'de',
335-
'nl' => 'nl'
336+
'es' => 'es',
337+
'es_mx' => 'es',
338+
'fr' => 'fr',
339+
'fr_ca' => 'fr',
340+
'ja' => 'ja',
341+
'ko' => 'ko',
342+
'nb' => 'nb',
343+
'nl' => 'nl',
344+
'no' => 'nb',
345+
'pt' => 'pt',
346+
'pt_br' => 'pt',
347+
'ru' => 'ru',
348+
'sv' => 'sv',
349+
'sv_fi' => 'sv',
350+
'zh_cn' => 'zh-CN',
351+
'zh_tw' => 'zh-TW'
336352
);
337353

338354
// Replace with locale for EULA link.
339355
$localearray = array(
340-
'de' => 'de-DE',
356+
'da' => 'da-DK',
357+
'de' => 'de-DE',
341358
'de_du' => 'de-DE',
342-
'nl' => 'nl-NL'
359+
'es' => 'es-MX',
360+
'es_mx' => 'es-MX',
361+
'fr' => 'fr-FR',
362+
'fr_ca' => 'fr-FR',
363+
'ja' => 'ja-JP',
364+
'ko' => 'ko-KR',
365+
'nb' => 'nb-NO',
366+
'nl' => 'nl-NL',
367+
'no' => 'nb-NO',
368+
'pt' => 'pt-BR',
369+
'pt_br' => 'pt-BR',
370+
'ru' => 'ru-RU',
371+
'sv' => 'sv-SE',
372+
'sv_fi' => 'sv-SE',
373+
'zh_cn' => 'zh-CN',
374+
'zh_tw' => 'zh-TW'
343375
);
344376

345377
$lang = new stdClass();

classes/task.class.php

+7
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ public function check_latest_eula_version() {
268268
if (!empty($response)) {
269269
// Compare latest EULA to the current EULA we have stored.
270270
$currenteulaversion = get_config('plagiarism_turnitinsim', 'turnitin_eula_version');
271+
$currenteulaurl = get_config('plagiarism_turnitinsim', 'turnitin_eula_url');
271272
$neweulaversion = (empty($response->version)) ? '' : $response->version;
273+
$neweulaurl = (empty($response->url)) ? '' : $response->url;
272274

273275
// Update EULA version and url if necessary.
274276
if ($currenteulaversion != $neweulaversion) {
@@ -278,6 +280,11 @@ public function check_latest_eula_version() {
278280
// Notify all users linked to Turnitin that there is a new EULA to accept.
279281
$message = new new_eula();
280282
$message->send_message();
283+
} else if ($currenteulaurl != $neweulaurl){
284+
// This runs if there is no new EULA version, but a user still needs an updated EULA URL for their supported language.
285+
// We do not want to notify all users that there is a new EULA url for the translation.
286+
set_config('turnitin_eula_version', $response->version, 'plagiarism_turnitinsim');
287+
set_config('turnitin_eula_url', $response->url, 'plagiarism_turnitinsim');
281288
}
282289
}
283290

lib.php

+11-8
Original file line numberDiff line numberDiff line change
@@ -488,21 +488,21 @@ public function print_disclosure($cmid, $submissiontype = 'file') {
488488
}
489489
}
490490

491+
// We don't need to continue if the user has accepted the latest EULA and/or EULA acceptance is not required.
492+
$user = new plagiarism_turnitinsim_user($USER->id);
493+
$features = json_decode(get_config('plagiarism_turnitinsim', 'turnitin_features_enabled'));
494+
491495
// Check we have the latest version of the EULA stored.
492496
// This should only happen the very first time someone submits.
493497
$eulaversion = get_config('plagiarism_turnitinsim', 'turnitin_eula_version');
494498
// Overwrite mtrace so when EULA is checked it doesn't output to screen.
495499
$CFG->mtrace_wrapper = 'plagiarism_turnitinsim_mtrace';
496-
if (empty($eulaversion)) {
500+
if (empty($eulaversion) || empty($user->get_lasteulaaccepted())) {
497501
$tstask = new plagiarism_turnitinsim_task();
498502
$tstask->check_latest_eula_version();
499503
$eulaversion = get_config('plagiarism_turnitinsim', 'turnitin_eula_version');
500504
}
501505

502-
// We don't need to continue if the user has accepted the latest EULA and/or EULA acceptance is not required.
503-
$user = new plagiarism_turnitinsim_user($USER->id);
504-
$features = json_decode(get_config('plagiarism_turnitinsim', 'turnitin_features_enabled'));
505-
506506
if ($user->get_lasteulaaccepted() == $eulaversion) {
507507
return html_writer::tag(
508508
'div',
@@ -526,9 +526,7 @@ public function print_disclosure($cmid, $submissiontype = 'file') {
526526
$PAGE->requires->js_call_amd('plagiarism_turnitinsim/eula_response', 'eulaResponse');
527527

528528
// Link to open the Turnitin EULA in a new tab.
529-
$tsrequest = new plagiarism_turnitinsim_request();
530-
$lang = $tsrequest->get_language();
531-
$eulaurl = get_config('plagiarism_turnitinsim', 'turnitin_eula_url')."?lang=".$lang->localecode;
529+
$eulaurl = get_config('plagiarism_turnitinsim', 'turnitin_eula_url');
532530
$eulastring = ($cmid > -1) ? 'eulalink' : 'eulalinkgeneric';
533531
$eulalink = get_string($eulastring, 'plagiarism_turnitinsim', $eulaurl);
534532

@@ -869,6 +867,11 @@ public function quiz_handler($cm, $eventdata, $sendtoturnitin, $features) {
869867
foreach ($attempt->get_slots() as $slot) {
870868
$eventdata['other']['pathnamehashes'] = array();
871869
$qa = $attempt->get_question_attempt($slot);
870+
871+
if ($qa->get_question()->get_type_name() != 'essay') {
872+
continue;
873+
}
874+
872875
$quizanswer = $qa->get_usage_id().'-'.$qa->get_slot();
873876

874877
$files = $qa->get_last_qt_files('attachments', $context->id);

utilities/handle_deprecation.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,6 @@ public static function assertregex($object, $pattern, $string) {
173173
global $CFG;
174174

175175
$CFG->branch >= 311 ? $object->assertMatchesRegularExpression($pattern, $string) :
176-
$object->assertRegExp("int", $pattern, $string);
176+
$object->assertRegExp($pattern, $string);
177177
}
178178
}

version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
defined('MOODLE_INTERNAL') || die();
2727

28-
$plugin->version = 2022092101;
28+
$plugin->version = 2023042001;
2929
$plugin->release = "v1.2";
3030
$plugin->requires = 2017051500;
3131
$plugin->component = 'plagiarism_turnitinsim';

0 commit comments

Comments
 (0)