Skip to content

Commit

Permalink
Merge pull request #149 from turnitin/develop
Browse files Browse the repository at this point in the history
Release v2023042001
  • Loading branch information
ixiongtii authored Apr 20, 2023
2 parents 655d87a + 37c275f commit e8c0c5c
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 15 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
### Date: 2023-April-20
### Release: v2023042001

#### Turnitin language settings are now syncing with Moodle environment

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.

---

### Date: 2022-September-21
### Release: v2022092101

Expand Down
4 changes: 3 additions & 1 deletion classes/eula.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public function get_latest_version() {

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

Expand Down
40 changes: 36 additions & 4 deletions classes/request.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,48 @@ public function get_language() {

// Replace with language code for CV launch.
$langarray = array(
'de' => 'de',
'da' => 'da',
'de' => 'de',
'de_du' => 'de',
'nl' => 'nl'
'es' => 'es',
'es_mx' => 'es',
'fr' => 'fr',
'fr_ca' => 'fr',
'ja' => 'ja',
'ko' => 'ko',
'nb' => 'nb',
'nl' => 'nl',
'no' => 'nb',
'pt' => 'pt',
'pt_br' => 'pt',
'ru' => 'ru',
'sv' => 'sv',
'sv_fi' => 'sv',
'zh_cn' => 'zh-CN',
'zh_tw' => 'zh-TW'
);

// Replace with locale for EULA link.
$localearray = array(
'de' => 'de-DE',
'da' => 'da-DK',
'de' => 'de-DE',
'de_du' => 'de-DE',
'nl' => 'nl-NL'
'es' => 'es-MX',
'es_mx' => 'es-MX',
'fr' => 'fr-FR',
'fr_ca' => 'fr-FR',
'ja' => 'ja-JP',
'ko' => 'ko-KR',
'nb' => 'nb-NO',
'nl' => 'nl-NL',
'no' => 'nb-NO',
'pt' => 'pt-BR',
'pt_br' => 'pt-BR',
'ru' => 'ru-RU',
'sv' => 'sv-SE',
'sv_fi' => 'sv-SE',
'zh_cn' => 'zh-CN',
'zh_tw' => 'zh-TW'
);

$lang = new stdClass();
Expand Down
7 changes: 7 additions & 0 deletions classes/task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ public function check_latest_eula_version() {
if (!empty($response)) {
// Compare latest EULA to the current EULA we have stored.
$currenteulaversion = get_config('plagiarism_turnitinsim', 'turnitin_eula_version');
$currenteulaurl = get_config('plagiarism_turnitinsim', 'turnitin_eula_url');
$neweulaversion = (empty($response->version)) ? '' : $response->version;
$neweulaurl = (empty($response->url)) ? '' : $response->url;

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

Expand Down
19 changes: 11 additions & 8 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,21 +488,21 @@ public function print_disclosure($cmid, $submissiontype = 'file') {
}
}

// We don't need to continue if the user has accepted the latest EULA and/or EULA acceptance is not required.
$user = new plagiarism_turnitinsim_user($USER->id);
$features = json_decode(get_config('plagiarism_turnitinsim', 'turnitin_features_enabled'));

// Check we have the latest version of the EULA stored.
// This should only happen the very first time someone submits.
$eulaversion = get_config('plagiarism_turnitinsim', 'turnitin_eula_version');
// Overwrite mtrace so when EULA is checked it doesn't output to screen.
$CFG->mtrace_wrapper = 'plagiarism_turnitinsim_mtrace';
if (empty($eulaversion)) {
if (empty($eulaversion) || empty($user->get_lasteulaaccepted())) {
$tstask = new plagiarism_turnitinsim_task();
$tstask->check_latest_eula_version();
$eulaversion = get_config('plagiarism_turnitinsim', 'turnitin_eula_version');
}

// We don't need to continue if the user has accepted the latest EULA and/or EULA acceptance is not required.
$user = new plagiarism_turnitinsim_user($USER->id);
$features = json_decode(get_config('plagiarism_turnitinsim', 'turnitin_features_enabled'));

if ($user->get_lasteulaaccepted() == $eulaversion) {
return html_writer::tag(
'div',
Expand All @@ -526,9 +526,7 @@ public function print_disclosure($cmid, $submissiontype = 'file') {
$PAGE->requires->js_call_amd('plagiarism_turnitinsim/eula_response', 'eulaResponse');

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

Expand Down Expand Up @@ -869,6 +867,11 @@ public function quiz_handler($cm, $eventdata, $sendtoturnitin, $features) {
foreach ($attempt->get_slots() as $slot) {
$eventdata['other']['pathnamehashes'] = array();
$qa = $attempt->get_question_attempt($slot);

if ($qa->get_question()->get_type_name() != 'essay') {
continue;
}

$quizanswer = $qa->get_usage_id().'-'.$qa->get_slot();

$files = $qa->get_last_qt_files('attachments', $context->id);
Expand Down
2 changes: 1 addition & 1 deletion utilities/handle_deprecation.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,6 @@ public static function assertregex($object, $pattern, $string) {
global $CFG;

$CFG->branch >= 311 ? $object->assertMatchesRegularExpression($pattern, $string) :
$object->assertRegExp("int", $pattern, $string);
$object->assertRegExp($pattern, $string);
}
}
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

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

$plugin->version = 2022092101;
$plugin->version = 2023042001;
$plugin->release = "v1.2";
$plugin->requires = 2017051500;
$plugin->component = 'plagiarism_turnitinsim';
Expand Down

0 comments on commit e8c0c5c

Please sign in to comment.