Skip to content

Commit

Permalink
Merge pull request #197 from turnitin/develop
Browse files Browse the repository at this point in the history
Release v2025021301
  • Loading branch information
jack-tii authored Feb 17, 2025
2 parents 2b043bc + 6a2b445 commit 511ce30
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 73 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
### Date: 2025-February-13
### Release: v2025021301

#### Fixed Issue with Database Download

An issue was identified where database downloads were not working for some users. This has now been resolved.

#### Fixed Issue with Quizzes

Previously when reviewing a quiz attempt, some users would encounter an error. This has now been resolved.

---

### Date: 2024-November-25
### Release: v2024112501

Expand Down
7 changes: 4 additions & 3 deletions classes/eula.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ public function get_latest_version() {
$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);
$response = json_decode($response);

// Latest version retrieved.
if ($responsedata->httpstatus == TURNITINSIM_HTTP_OK) {
if ($response->httpstatus == TURNITINSIM_HTTP_OK) {
$responsedata = $response;
mtrace(get_string('taskoutputlatesteularetrieved', 'plagiarism_turnitinsim', $responsedata->version));
return $responsedata;
}
Expand Down Expand Up @@ -151,4 +152,4 @@ public function get_eula_status($cmid, $submissiontype, $submissionuserid) {
array('class' => 'tii_status_text tii_status_text_eula')
));
}
}
}
2 changes: 1 addition & 1 deletion classes/settings.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function add_settings_to_module($mform, $canconfigureplugin = false, $con
global $PAGE;

if ($context == 'module') {
$mform->addElement('header', 'plugin_header', get_string('turnitinpluginsettings', 'plagiarism_turnitinsim'));
$mform->addElement('header', 'turnitinsim_plugin_header', get_string('turnitinpluginsettings', 'plagiarism_turnitinsim'));
}

// Require JS modules.
Expand Down
7 changes: 6 additions & 1 deletion classes/submission.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,12 @@ public function upload_submission_to_turnitin() {
}

// Queue each answer to a question.
$attempt = quiz_attempt::create($this->getitemid());
if (class_exists('\mod_quiz\quiz_attempt')) {
$quizattemptclass = '\mod_quiz\quiz_attempt';
} else {
$quizattemptclass = 'quiz_attempt';
}
$attempt = $quizattemptclass::create($this->getitemid());
foreach ($attempt->get_slots() as $slot) {
$qa = $attempt->get_question_attempt($slot);
if ($this->getidentifier() == sha1($qa->get_response_summary())) {
Expand Down
11 changes: 6 additions & 5 deletions classes/task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,14 @@ public function send_queued_submissions() {

if ($tssubmission->getstatus() == TURNITINSIM_SUBMISSION_STATUS_QUEUED) {
$tssubmission->create_submission_in_turnitin();
}

if (!empty($tssubmission->getturnitinid())) {
$tssubmission->upload_submission_to_turnitin();
// TII ID will only exist if submission has been created successfully
if (!empty($tssubmission->getturnitinid())) {
$tssubmission->upload_submission_to_turnitin();

// Set the time for the report to be generated.
$tssubmission->calculate_generation_time();
// Set the time for the report to be generated.
$tssubmission->calculate_generation_time();
}
}

$tssubmission->update();
Expand Down
3 changes: 1 addition & 2 deletions dbexport.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
// Require libs.
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/dataformatlib.php');
require_once( __DIR__ . '/utilities/handle_deprecation.php' );

// Restrict access to admins only.
Expand Down Expand Up @@ -68,7 +67,7 @@
$data = $DB->get_records($table, null, 'id ASC');

// Use Moodle's dataformatting functions to output the data in the desired format.
handle_deprecation::download_data($exportfile, $dataformat, array_keys($DB->get_columns($table)), $data);
\core\dataformat::download_data($exportfile, $dataformat, array_keys($DB->get_columns($table)), $data);

exit;

Expand Down
7 changes: 6 additions & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,12 @@ public function quiz_handler($cm, $eventdata, $sendtoturnitin, $features) {
$submitter = new plagiarism_turnitinsim_user($eventdata['userid']);

// Queue every question submitted in a quiz attempt.
$attempt = quiz_attempt::create($eventdata['objectid']);
if (class_exists('\mod_quiz\quiz_attempt')) {
$quizattemptclass = '\mod_quiz\quiz_attempt';
} else {
$quizattemptclass = 'quiz_attempt';
}
$attempt = $quizattemptclass::create($eventdata['objectid']);
$context = context_module::instance($attempt->get_cmid());
foreach ($attempt->get_slots() as $slot) {
$eventdata['other']['pathnamehashes'] = array();
Expand Down
51 changes: 9 additions & 42 deletions tests/lib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,40 +139,6 @@ public function setUp(): void {
$this->eulaurl = get_config('plagiarism_turnitinsim', 'turnitin_eula_url', self::TURNITINSIM_API_URL);
}

/**
* Save Form elements
*/
public function test_save_form_elements() {
global $DB;

$this->resetAfterTest();

// Create data object for new assignment.
$data = new stdClass();
$data->modulename = 'assign';
$data->coursemodule = 1;
$data->turnitinenabled = 1;

$plugin = new plagiarism_plugin_turnitinsim();
$plugin->save_form_elements($data);

// Check settings are not saved.
$settings = $DB->get_record('plagiarism_turnitinsim_mod', array('cm' => $data->coursemodule));

$this->assertEmpty($settings);

// Set plugin as enabled in config for this module type.
plagiarism_plugin_turnitinsim::enable_plugin(1);
set_config('turnitinmodenabledassign', 1, 'plagiarism_turnitinsim');

$plugin->save_form_elements($data);

// Check settings are saved.
$settings = $DB->get_record('plagiarism_turnitinsim_mod', array('cm' => $data->coursemodule));

$this->assertEquals(1, $settings->turnitinenabled);
}

/**
* Test that get_links returns an empty div if there is no submission.
*/
Expand Down Expand Up @@ -421,9 +387,10 @@ public function test_is_plugin_active_not_enabled_for_mod() {
$data->coursemodule = $this->cm->id;
$data->turnitinenabled = 0;

$plugin = new plagiarism_plugin_turnitinsim();
$plugin->save_form_elements($data);
$form = new plagiarism_turnitinsim_settings();
$form->save_module_settings($data);

$plugin = new plagiarism_plugin_turnitinsim();
$this->assertFalse($plugin->is_plugin_active($this->cm));
}

Expand Down Expand Up @@ -490,8 +457,8 @@ public function test_print_disclosure_display_latest() {
$data->modulename = 'assign';
$data->coursemodule = $this->cm->id;
$data->turnitinenabled = 1;
$plugin = new plagiarism_plugin_turnitinsim();
$plugin->save_form_elements($data);
$form = new plagiarism_turnitinsim_settings();
$form->save_module_settings($data);

// Log student in.
$this->setUser($this->student1);
Expand Down Expand Up @@ -526,8 +493,8 @@ public function test_print_disclosure_not_display_latest() {
$data->modulename = 'assign';
$data->coursemodule = $this->cm->id;
$data->turnitinenabled = 1;
$plugin = new plagiarism_plugin_turnitinsim();
$plugin->save_form_elements($data);
$form = new plagiarism_turnitinsim_settings();
$form->save_module_settings($data);

// Accept EULA for student.
$data = $DB->get_record('plagiarism_turnitinsim_users', ['userid' => $this->student1->id]);
Expand Down Expand Up @@ -563,8 +530,8 @@ public function test_print_disclosure_eula_not_displayed_if_not_required() {
$data->modulename = 'assign';
$data->coursemodule = $this->cm->id;
$data->turnitinenabled = 1;
$plugin = new plagiarism_plugin_turnitinsim();
$plugin->save_form_elements($data);
$form = new plagiarism_turnitinsim_settings();
$form->save_module_settings($data);

// Log student in.
$this->setUser($this->student1);
Expand Down
16 changes: 0 additions & 16 deletions utilities/handle_deprecation.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,6 @@ public static function get_plugin_enabled() {
: get_config('plagiarism_turnitinsim', 'enabled');
}

/**
* In Moodle 3.9, download_as_dataformat() was deprecated and \core\dataformat::download_data() was introduced.
* This method handles our support for multiple Moodle versions.
*
* @param string $exportfile The name of the file to download.
* @param string $dataformat The format of the file.
* @param array $columns The names of the columns.
* @param string $data The data to download.
*/
public static function download_data($exportfile, $dataformat, $columns, $data) {
global $CFG;

$CFG->branch >= 39 ? \core\dataformat::download_data($exportfile, $dataformat, $columns, $data)
: download_as_dataformat($exportfile, $dataformat, $columns, $data);
}

/**
* In Moodle 3.10, Moodle switched to use PHPUnit 8.5 which contains deprecations for some assertions.
* assertContains was deprecated in favour of the newer assertStringContainsString. (PHPUnit 7.5)
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

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

$plugin->version = 2024112501;
$plugin->version = 2025021301;
$plugin->release = "v1.2";
$plugin->requires = 2017051500;
$plugin->requires = 2022112800;
$plugin->component = 'plagiarism_turnitinsim';
$plugin->maturity = MATURITY_STABLE;

0 comments on commit 511ce30

Please sign in to comment.