diff --git a/lang/ar/plagiarism_turnitin.php b/lang/ar/plagiarism_turnitin.php index 145b18b5..9972d95e 100755 --- a/lang/ar/plagiarism_turnitin.php +++ b/lang/ar/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'ar' + * Strings for component 'plagiarism_turnitin', language 'ar' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/cs/plagiarism_turnitin.php b/lang/cs/plagiarism_turnitin.php index eea71ad2..6c43327d 100755 --- a/lang/cs/plagiarism_turnitin.php +++ b/lang/cs/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'cs' + * Strings for component 'plagiarism_turnitin', language 'cs' * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/lang/de/plagiarism_turnitin.php b/lang/de/plagiarism_turnitin.php index 6b931069..048dc70c 100755 --- a/lang/de/plagiarism_turnitin.php +++ b/lang/de/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'de' + * Strings for component 'plagiarism_turnitin', language 'de' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/en/plagiarism_turnitin.php b/lang/en/plagiarism_turnitin.php index 0c2b9a1c..93a8b47a 100644 --- a/lang/en/plagiarism_turnitin.php +++ b/lang/en/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'en' + * Strings for component 'plagiarism_turnitin', language 'en' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/es/plagiarism_turnitin.php b/lang/es/plagiarism_turnitin.php index f76674d5..9ed89ba2 100755 --- a/lang/es/plagiarism_turnitin.php +++ b/lang/es/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'es' + * Strings for component 'plagiarism_turnitin', language 'es' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/fi/plagiarism_turnitin.php b/lang/fi/plagiarism_turnitin.php index 2cd70daf..54cba427 100755 --- a/lang/fi/plagiarism_turnitin.php +++ b/lang/fi/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'fi' + * Strings for component 'plagiarism_turnitin', language 'fi' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/fr/plagiarism_turnitin.php b/lang/fr/plagiarism_turnitin.php index 288bde7f..d96e0622 100755 --- a/lang/fr/plagiarism_turnitin.php +++ b/lang/fr/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'fr' + * Strings for component 'plagiarism_turnitin', language 'fr' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/it/plagiarism_turnitin.php b/lang/it/plagiarism_turnitin.php index b04aaedd..0516d574 100755 --- a/lang/it/plagiarism_turnitin.php +++ b/lang/it/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'it' + * Strings for component 'plagiarism_turnitin', language 'it' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/ja/plagiarism_turnitin.php b/lang/ja/plagiarism_turnitin.php index d6b19eca..acb0966c 100755 --- a/lang/ja/plagiarism_turnitin.php +++ b/lang/ja/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'ja' + * Strings for component 'plagiarism_turnitin', language 'ja' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/ko/plagiarism_turnitin.php b/lang/ko/plagiarism_turnitin.php index 3f9804ec..b88e09fc 100755 --- a/lang/ko/plagiarism_turnitin.php +++ b/lang/ko/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'ko' + * Strings for component 'plagiarism_turnitin', language 'ko' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/nl/plagiarism_turnitin.php b/lang/nl/plagiarism_turnitin.php index 266db802..9dcb7c23 100755 --- a/lang/nl/plagiarism_turnitin.php +++ b/lang/nl/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'nl' + * Strings for component 'plagiarism_turnitin', language 'nl' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/pl/plagiarism_turnitin.php b/lang/pl/plagiarism_turnitin.php index d7c1bcd3..d9601d4d 100755 --- a/lang/pl/plagiarism_turnitin.php +++ b/lang/pl/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'pl' + * Strings for component 'plagiarism_turnitin', language 'pl' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/pt_br/plagiarism_turnitin.php b/lang/pt_br/plagiarism_turnitin.php index 1761cb97..9f9778a8 100755 --- a/lang/pt_br/plagiarism_turnitin.php +++ b/lang/pt_br/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'pt_br' + * Strings for component 'plagiarism_turnitin', language 'pt_br' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/ro/plagiarism_turnitin.php b/lang/ro/plagiarism_turnitin.php index 08dba4b8..dae157e2 100755 --- a/lang/ro/plagiarism_turnitin.php +++ b/lang/ro/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'ro' + * Strings for component 'plagiarism_turnitin', language 'ro' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/ru/plagiarism_turnitin.php b/lang/ru/plagiarism_turnitin.php index d37119a9..378363fc 100755 --- a/lang/ru/plagiarism_turnitin.php +++ b/lang/ru/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'ru' + * Strings for component 'plagiarism_turnitin', language 'ru' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/sv/plagiarism_turnitin.php b/lang/sv/plagiarism_turnitin.php index c9804946..040beff1 100755 --- a/lang/sv/plagiarism_turnitin.php +++ b/lang/sv/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'sv' + * Strings for component 'plagiarism_turnitin', language 'sv' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/tr/plagiarism_turnitin.php b/lang/tr/plagiarism_turnitin.php index 14fb0e47..cab79d1f 100755 --- a/lang/tr/plagiarism_turnitin.php +++ b/lang/tr/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'tr' + * Strings for component 'plagiarism_turnitin', language 'tr' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/vi/plagiarism_turnitin.php b/lang/vi/plagiarism_turnitin.php index 55a9c93a..ff15baaf 100755 --- a/lang/vi/plagiarism_turnitin.php +++ b/lang/vi/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'vi' + * Strings for component 'plagiarism_turnitin', language 'vi' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/zh_hans/plagiarism_turnitin.php b/lang/zh_hans/plagiarism_turnitin.php index 648f87e3..e2d533a1 100755 --- a/lang/zh_hans/plagiarism_turnitin.php +++ b/lang/zh_hans/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'zh_hans' + * Strings for component 'plagiarism_turnitin', language 'zh_hans' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lang/zh_tw/plagiarism_turnitin.php b/lang/zh_tw/plagiarism_turnitin.php index d820619a..2956f765 100755 --- a/lang/zh_tw/plagiarism_turnitin.php +++ b/lang/zh_tw/plagiarism_turnitin.php @@ -19,7 +19,7 @@ // phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder /** - * Strings for component 'qtype_kprime', language 'zh_tw' + * Strings for component 'plagiarism_turnitin', language 'zh_tw' * * @package plagiarism_turnitin * @copyright 2012 iParadigms LLC diff --git a/lib.php b/lib.php index c4ee2e27..1e2b115b 100755 --- a/lib.php +++ b/lib.php @@ -1528,8 +1528,9 @@ private function update_submission($cm, $submissionid, $tiisubmission) { * @param object $cm The course module. * @param object $submission The submission object. * @param int $userid The user id. + * @param bool $cron Whether this is a cron job. */ - private function update_grade($cm, $submission, $userid, $cron = FALSE) { + private function update_grade($cm, $submission, $userid, $cron = false) { global $DB, $USER, $CFG; $return = true; @@ -1629,7 +1630,7 @@ private function update_grade($cm, $submission, $userid, $cron = FALSE) { $context = context_course::instance($cm->course); if (has_capability('mod/assign:grade', $context, $USER->id)) { // If the grade has changed and the change is not from a cron task then update the grader. - if ($currentgrade->grade != $grade->grade && $cron == FALSE) { + if ($currentgrade->grade != $grade->grade && $cron == false) { $grade->grader = $USER->id; } } @@ -2258,7 +2259,7 @@ public function cron_update_scores() { // At the moment TII doesn't support double marking so we won't synchronise grades from Grade Mark // as it would destroy the workflow. if (!is_null($plagiarismfile->grade) && $cm->modname != "coursework") { - $this->update_grade($cm, $readsubmission, $currentsubmission->userid, TRUE); + $this->update_grade($cm, $readsubmission, $currentsubmission->userid, true); } } } catch (Exception $e) { diff --git a/tests/classes/turnitin_assignment_class_test.php b/tests/classes/turnitin_assignment_class_test.php index 68accc86..d18f899b 100644 --- a/tests/classes/turnitin_assignment_class_test.php +++ b/tests/classes/turnitin_assignment_class_test.php @@ -36,7 +36,7 @@ * * @package turnitin */ -final class turnitin_assignment_class_test extends advanced_testcase { +final class turnitin_assignment_class_test extends \advanced_testcase { /** * Set Overwrite mtrace to avoid output during the tests. @@ -61,7 +61,7 @@ public function test_get_course_data(): void { $this->resetAfterTest(); // Create a PP course. - $course = new stdClass(); + $course = new \stdClass(); $course->courseid = 1; $course->turnitin_ctl = "Test Course"; $course->turnitin_cid = 10; @@ -69,7 +69,7 @@ public function test_get_course_data(): void { // Insert the course to the plagiarism turnitin courses table. $DB->insert_record('plagiarism_turnitin_courses', $course); - $response = turnitin_assignment::get_course_data(1, "site"); + $response = \turnitin_assignment::get_course_data(1, "site"); $this->assertEquals($course->turnitin_ctl, $response->turnitin_ctl); $this->assertEquals($course->turnitin_cid, $response->turnitin_cid); @@ -88,7 +88,7 @@ public function test_create_tii_course(): void { $this->resetAfterTest(); // Create a PP course. - $course = new stdClass(); + $course = new \stdClass(); $course->courseid = 1; $course->turnitin_ctl = "Test Course"; $course->turnitin_cid = 10; @@ -119,7 +119,7 @@ public function test_create_tii_course(): void { $response = $mock->create_tii_course($course, 1); - $expected = new stdClass(); + $expected = new \stdClass(); $expected->id = $course->tii_rel_id; $expected->turnitin_cid = 1; $expected->turnitin_ctl = "This is a test course (Moodle PP)"; @@ -147,7 +147,7 @@ public function test_edit_tii_course(): void { $this->resetAfterTest(); // Create a PP course. - $course = new stdClass(); + $course = new \stdClass(); $course->courseid = 1; $course->turnitin_ctl = "Test Course"; $course->turnitin_cid = 1; @@ -173,7 +173,7 @@ public function test_edit_tii_course(): void { ->getMock(); // Edit a PP course. - $editcourse = new stdClass(); + $editcourse = new \stdClass(); $editcourse->id = 1; $editcourse->turnitin_cid = 10; $editcourse->fullname = "This is an edited test course"; @@ -184,7 +184,7 @@ public function test_edit_tii_course(): void { $responsecourse = $DB->get_record("plagiarism_turnitin_courses", ["id" => $course->id]); - $expected = new stdClass(); + $expected = new \stdClass(); $expected->id = $course->id; $expected->courseid = $course->courseid; $expected->turnitin_ctl = "This is an edited test course (Moodle PP)"; @@ -206,12 +206,12 @@ public function test_truncate_title(): void { $title = "This is a very long title that we are going to use to test the truncate title method."; $limit = 50; - $response = turnitin_assignment::truncate_title($title, $limit); + $response = \turnitin_assignment::truncate_title($title, $limit); $this->assertEquals('This is a very long title that we a... (Moodle PP)', $response); // Try a title that is within our limit. - $response = turnitin_assignment::truncate_title("This title should not be truncated.", $limit); + $response = \turnitin_assignment::truncate_title("This title should not be truncated.", $limit); $this->assertEquals('This title should not be truncated. (Moodle PP)', $response); } @@ -225,7 +225,7 @@ public function test_create_tii_assignment(): void { $this->resetAfterTest(); // Create a PP assignment. - $assignment = new stdClass(); + $assignment = new \stdClass(); $assignment->id = 1; // Stub a fake tii comms. @@ -264,7 +264,7 @@ public function test_edit_tii_assignment(): void { $this->resetAfterTest(); // Create a PP assignment. - $assignment = new stdClass(); + $assignment = new \stdClass(); $assignment->id = 1; $assignment->title = "This is a test assignment."; @@ -312,7 +312,7 @@ public function test_edit_tii_assignment(): void { $this->assertEquals(get_string('editassignmenterror', 'plagiarism_turnitin'), $response["error"]); // Test the error handling for the cron workflow. - $error = new stdClass(); + $error = new \stdClass(); $error->title = $assignment->title; $error->assignmentid = 1; @@ -335,7 +335,7 @@ public function test_get_peermark_assignments(): void { $this->resetAfterTest(); // Create a PP course. - $peermark = new stdClass(); + $peermark = new \stdClass(); $peermark->parent_tii_assign_id = 1; $peermark->title = "This is a test Peermark assignment."; $peermark->tiiassignid = 1; @@ -347,7 +347,7 @@ public function test_get_peermark_assignments(): void { // Insert the peermark to the plagiarism turnitin courses table. $DB->insert_record('plagiarism_turnitin_peermark', $peermark); - $assignment = new turnitin_assignment(0, 1); + $assignment = new \turnitin_assignment(0, 1); // We should have a peermark object. $response = $assignment->get_peermark_assignments(1, $peermark->parent_tii_assign_id); diff --git a/tests/classes/turnitin_user_class_test.php b/tests/classes/turnitin_user_class_test.php index e3b9c534..2fd838a7 100644 --- a/tests/classes/turnitin_user_class_test.php +++ b/tests/classes/turnitin_user_class_test.php @@ -65,7 +65,7 @@ public function test_get_moodle_user(): void { $student = $this->getDataGenerator()->create_user(); - $turnitinuser = new turnitin_user(0, null, null, null, null); + $turnitinuser = new \turnitin_user(0, null, null, null, null); $response = $turnitinuser->get_moodle_user($student->id); // Check that we have an object back with user details. No need to check all params. @@ -82,7 +82,7 @@ public function test_get_moodle_user(): void { public function test_get_pseudo_domain(): void { $this->resetAfterTest(); - $response = turnitin_user::get_pseudo_domain(); + $response = \turnitin_user::get_pseudo_domain(); $this->assertEquals(PLAGIARISM_TURNITIN_DEFAULT_PSEUDO_DOMAIN, $response); } @@ -95,7 +95,7 @@ public function test_get_pseudo_domain(): void { public function test_get_pseudo_firstname(): void { $this->resetAfterTest(); - $turnitinuser = new turnitin_user(0, null, null, null, null); + $turnitinuser = new \turnitin_user(0, null, null, null, null); $response = $turnitinuser->get_pseudo_firstname(); $this->assertEquals(PLAGIARISM_TURNITIN_DEFAULT_PSEUDO_FIRSTNAME, $response); } @@ -117,7 +117,7 @@ public function test_get_pseudo_lastname(): void { set_config('plagiarism_turnitin_pseudolastname', 1, 'plagiarism_turnitin'); set_config('plagiarism_turnitin_lastnamegen', 1, 'plagiarism_turnitin'); - $turnitinuser = new turnitin_user($student->id, null, null, null, null); + $turnitinuser = new \turnitin_user($student->id, null, null, null, null); $response = $turnitinuser->get_pseudo_lastname(); $this->assertEquals(PLAGIARISM_TURNITIN_DEFAULT_PSEUDO_FIRSTNAME, $response); } @@ -142,7 +142,7 @@ public function test_unlink_user(): void { $this->assertEquals(1, $count); // Unlink the user. - $turnitinuser = new turnitin_user(0, null, null, null, null); + $turnitinuser = new \turnitin_user(0, null, null, null, null); $turnitinuser->unlink_user($testuser["joins"][0]); // We should have a Turnitin user ID of 0. diff --git a/tests/generator/lib.php b/tests/generator/lib.php index 07c785f4..9f11b019 100644 --- a/tests/generator/lib.php +++ b/tests/generator/lib.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace plagiarism_turnitin; + defined('MOODLE_INTERNAL') || die(); global $CFG; global $DB; @@ -34,7 +36,7 @@ * @copyright 2017 Turnitin * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -abstract class plagiarism_turnitin_test_lib extends advanced_testcase { +abstract class plagiarism_turnitin_test_lib extends \advanced_testcase { /** * Creates a number of test plagiarism_turnitin users, creates an equivalent moodle user for each, and handles the database @@ -51,7 +53,7 @@ public function make_test_users($numberofusers, $roles) { for ($i = 0; $i < $numberofusers; $i++) { $role = isset($roles[$i]) ? $roles[$i] : 'Instructor'; - $newuser = new turnitin_user( $i + 1, $role, false, 'site', false ); + $newuser = new \turnitin_user( $i + 1, $role, false, 'site', false ); array_push($return['plagiarism_turnitin_users'], $newuser); $joinid = $this->join_test_user($newuser); array_push($return['joins'], $joinid); @@ -72,7 +74,7 @@ public function join_test_user($plagiarismturnitinuser) { global $DB; $mdluser = $this->getDataGenerator()->create_user(); - $tiiuserrecord = new stdClass(); + $tiiuserrecord = new \stdClass(); $tiiuserrecord->userid = $mdluser->id; $tiiuserrecord->turnitin_uid = $plagiarismturnitinuser->id; $tiiuserrecord->user_agreement_accepted = 1; diff --git a/tests/lib_test.php b/tests/lib_test.php index 9f7d977f..4c0d11b0 100644 --- a/tests/lib_test.php +++ b/tests/lib_test.php @@ -35,7 +35,7 @@ * * @package turnitin */ -final class lib_test extends advanced_testcase { +final class lib_test extends \advanced_testcase { /** * Test that the plugin is configured correctly. @@ -46,7 +46,7 @@ final class lib_test extends advanced_testcase { public function test_is_plugin_configured(): void { $this->resetAfterTest(); - $plagiarismturnitin = new plagiarism_plugin_turnitin(); + $plagiarismturnitin = new \plagiarism_plugin_turnitin(); // Check if plugin is configured with no plugin config set. $ispluginconfigured = $plagiarismturnitin->is_plugin_configured(); @@ -91,8 +91,8 @@ public function test_check_group_submission(): void { $course = $result['course']; $group = $this->getDataGenerator()->create_group(['courseid' => $course->id]); $cm = get_coursemodule_from_instance('assign', $assignmodule->id); - $context = context_module::instance($cm->id); - $assign = new testable_assign($context, $cm, $course); + $context = \context_module::instance($cm->id); + $assign = new \testable_assign($context, $cm, $course); groups_add_member($group, $student); @@ -100,14 +100,14 @@ public function test_check_group_submission(): void { $submission = $assign->get_group_submission($student->id, $group->id, true); $submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED; $assign->testable_update_submission($submission, $student->id, true, false); - $data = new stdClass(); + $data = new \stdClass(); $data->onlinetext_editor = ['itemid' => file_get_unused_draft_itemid(), 'text' => 'Submission text', 'format' => FORMAT_MOODLE, ]; $plugin = $assign->get_submission_plugin_by_type('onlinetext'); $plugin->save($submission, $data); - $plagiarismturnitin = new plagiarism_plugin_turnitin(); + $plagiarismturnitin = new \plagiarism_plugin_turnitin(); $response = $plagiarismturnitin->check_group_submission($cm, $student->id); // Test should pass as we return the correct group ID. @@ -122,21 +122,21 @@ public function test_check_group_submission(): void { $student = $result['student']; $course = $result['course']; $cm = get_coursemodule_from_instance('assign', $assignmodule->id); - $context = context_module::instance($cm->id); - $assign = new testable_assign($context, $cm, $course); + $context = \context_module::instance($cm->id); + $assign = new \testable_assign($context, $cm, $course); $this->setUser($student); $submission = $assign->get_user_submission($student->id, true); $submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED; $assign->testable_update_submission($submission, $student->id, true, false); - $data = new stdClass(); + $data = new \stdClass(); $data->onlinetext_editor = ['itemid' => file_get_unused_draft_itemid(), 'text' => 'Submission text', 'format' => FORMAT_MOODLE, ]; $plugin = $assign->get_submission_plugin_by_type('onlinetext'); $plugin->save($submission, $data); - $plagiarismturnitin = new plagiarism_plugin_turnitin(); + $plagiarismturnitin = new \plagiarism_plugin_turnitin(); $response = $plagiarismturnitin->check_group_submission($cm, $student->id); // Test should pass as we return false when checking the group ID. @@ -164,7 +164,7 @@ public function create_assign_with_student_and_teacher($params = []) { $assign = $this->getDataGenerator()->create_module('assign', $params); $cm = get_coursemodule_from_instance('assign', $assign->id); - $context = context_module::instance($cm->id); + $context = \context_module::instance($cm->id); $student = $this->getDataGenerator()->create_user(); $studentrole = $DB->get_record('role', ['shortname' => 'student']); @@ -194,11 +194,11 @@ public function create_assign_with_student_and_teacher($params = []) { public function test_plagiarism_get_report_gen_speed_params(): void { $this->resetAfterTest(); - $expected = new stdClass(); + $expected = new \stdClass(); $expected->num_resubmissions = 3; $expected->num_hours = 24; - $plagiarismturnitin = new plagiarism_plugin_turnitin(); + $plagiarismturnitin = new \plagiarism_plugin_turnitin(); $response = $plagiarismturnitin->plagiarism_get_report_gen_speed_params(); $this->assertEquals($expected, $response); @@ -212,10 +212,10 @@ public function test_plagiarism_get_report_gen_speed_params(): void { public function test_plagiarism_set_config(): void { $this->resetAfterTest(); - $plagiarismturnitin = new plagiarism_plugin_turnitin(); + $plagiarismturnitin = new \plagiarism_plugin_turnitin(); // Check that we can set config value when a full property name is given. - $data = new stdClass(); + $data = new \stdClass(); $data->plagiarism_turnitin_accountid = 123456789; $property = "plagiarism_turnitin_accountid"; @@ -227,7 +227,7 @@ public function test_plagiarism_set_config(): void { $this->assertEquals(123456789, $config->plagiarism_turnitin_accountid); // Check that we can set config value when a partial property name is given. - $data = new stdClass(); + $data = new \stdClass(); $data->secretkey = "Test"; $property = "secretkey"; $plagiarismturnitin->plagiarism_set_config($data, $property); @@ -238,7 +238,7 @@ public function test_plagiarism_set_config(): void { $this->assertEquals("Test", $config->plagiarism_turnitin_secretkey); // Check that an undefined property does not set a config value. - $data = new stdClass(); + $data = new \stdClass(); $data->test = "Test"; $property = "NotTest"; $plagiarismturnitin->plagiarism_set_config($data, $property); @@ -246,6 +246,6 @@ public function test_plagiarism_set_config(): void { // Get the config. $config = $plagiarismturnitin->plagiarism_turnitin_admin_config(); - $this->assertObjectNotHasAttribute("plagiarism_turnitin_test", $config); + $this->assertObjectNotHasProperty("plagiarism_turnitin_test", $config); } } diff --git a/tests/locallib_test.php b/tests/locallib_test.php index b8a3eb82..97e55b0f 100644 --- a/tests/locallib_test.php +++ b/tests/locallib_test.php @@ -35,7 +35,7 @@ * * @package turnitin */ -final class locallib_test extends advanced_testcase { +final class locallib_test extends \advanced_testcase { /** * Test that we have the correct repository depending on the config settings. diff --git a/tests/modules/turnitin_assign_test.php b/tests/modules/turnitin_assign_test.php index 471e95ff..0f43aacd 100644 --- a/tests/modules/turnitin_assign_test.php +++ b/tests/modules/turnitin_assign_test.php @@ -35,7 +35,16 @@ * * @package turnitin */ -final class turnitin_assign_test extends advanced_testcase { +final class turnitin_assign_test extends \advanced_testcase { + + /** + * @var \stdClass + */ + public $course; + /** + * @var \stdClass + */ + public $assign; /** @var stdClass created in setUp. */ protected $course; @@ -68,7 +77,7 @@ public function test_check_is_resubmission_allowed(): void { $this->resetAfterTest(true); // Create module object. - $moduleobject = new turnitin_assign(); + $moduleobject = new \turnitin_assign(); $resubmissionallowed = $moduleobject->is_resubmission_allowed($this->assign->id, 1, 'file', ASSIGN_ATTEMPT_REOPEN_METHOD_NONE); @@ -115,7 +124,7 @@ public function test_check_is_resubmission_allowed_maxfiles_above_threshold(): v $assign = $this->getDataGenerator()->create_module('assign', $params); // Create module object. - $moduleobject = new turnitin_assign(); + $moduleobject = new \turnitin_assign(); $resubmissionallowed = $moduleobject->is_resubmission_allowed($assign->id, 1, 'file', ASSIGN_ATTEMPT_REOPEN_METHOD_NONE); $this->assertFalse($resubmissionallowed); diff --git a/tests/modules/turnitin_forum_test.php b/tests/modules/turnitin_forum_test.php index f111a8c9..42e3eada 100644 --- a/tests/modules/turnitin_forum_test.php +++ b/tests/modules/turnitin_forum_test.php @@ -34,7 +34,22 @@ * * @package turnitin */ -final class turnitin_forum_test extends advanced_testcase { +final class turnitin_forum_test extends \advanced_testcase { + + /** + * @var \stdClass $forum + */ + public $forum; + + /** + * @var \stdClass $discussion + */ + public $discussion; + + /** + * @var \stdClass $post + */ + public $post; /** @var stdClass created in setUp. */ protected $forum; @@ -52,19 +67,19 @@ public function setUp(): void { // Create a course, user and a forum. $course = $this->getDataGenerator()->create_course(); $user = $this->getDataGenerator()->create_user(); - $record = new stdClass(); + $record = new \stdClass(); $record->course = $course->id; $this->forum = $this->getDataGenerator()->create_module('forum', $record); // Add discussion to course. - $record = new stdClass(); + $record = new \stdClass(); $record->course = $course->id; $record->userid = $user->id; $record->forum = $this->forum->id; $this->discussion = $this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion($record); // Add post to discussion. - $record = new stdClass(); + $record = new \stdClass(); $record->course = $course->id; $record->userid = $user->id; $record->forum = $this->forum->id; @@ -82,7 +97,7 @@ public function test_to_check_content_in_array_is_returned_by_set_content(): voi $this->resetAfterTest(true); // Create module object. - $moduleobject = new turnitin_forum(); + $moduleobject = new \turnitin_forum(); $params = [ 'content' => $this->post->message, @@ -103,7 +118,7 @@ public function test_to_check_content_from_database_is_returned_by_set_content_i $this->resetAfterTest(true); // Create module object. - $moduleobject = new turnitin_forum(); + $moduleobject = new \turnitin_forum(); $params = [ 'content' => 'content should not come back', diff --git a/tests/modules/turnitin_quiz_test.php b/tests/modules/turnitin_quiz_test.php index f4309d02..39a435d0 100644 --- a/tests/modules/turnitin_quiz_test.php +++ b/tests/modules/turnitin_quiz_test.php @@ -36,7 +36,7 @@ * @package plagiarism_turnitin * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -final class turnitin_quiz_test extends advanced_testcase { +final class turnitin_quiz_test extends \advanced_testcase { /** * Proves that essay response marks are correctly updated. * @@ -90,7 +90,7 @@ public function test_update_mark(): void { $this->assertEquals(0.0, $grade); // Now update the grade of the essay question through the Turnitin quiz class. - $tiiquiz = new turnitin_quiz; + $tiiquiz = new \turnitin_quiz; $answer = $attemptobj->get_question_attempt(1)->get_response_summary(); $slot = 1; $identifier = sha1($answer.$slot); diff --git a/tests/privacy/provider_test.php b/tests/privacy/provider_test.php index cb2a0371..19a90cb3 100644 --- a/tests/privacy/provider_test.php +++ b/tests/privacy/provider_test.php @@ -49,13 +49,13 @@ final class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for _get_metadata shim. * - * @covers \core_plagiarism\privacy\legacy_polyfill::get_metadata + * @covers \core_plagiarism\privacy\legacy_polyfill::_get_metadata */ public function test_get_metadata(): void { $this->resetAfterTest(); $collection = new collection('plagiarism_turnitin'); - $newcollection = provider::get_metadata($collection); + $newcollection = \plagiarism_turnitin\privacy\provider::_get_metadata($collection); $itemcollection = $newcollection->get_collection(); $this->assertCount(4, $itemcollection); @@ -207,7 +207,7 @@ public function create_submission($numsubmissions = 1) { global $DB, $CFG; require_once($CFG->dirroot . '/mod/assign/tests/base_test.php'); - $libtest = new plagiarism_turnitin_lib_testcase(); + $libtest = new \plagiarism_turnitin\lib_test(); $result = $libtest->create_assign_with_student_and_teacher([ 'assignsubmission_onlinetext_enabled' => 1, 'teamsubmission' => 0, @@ -216,9 +216,9 @@ public function create_submission($numsubmissions = 1) { $assignmodule = $result['assign']; $student = $result['student']; $cm = get_coursemodule_from_instance('assign', $assignmodule->id); - $context = context_module::instance($cm->id); + $context = \context_module::instance($cm->id); - $plagiarismfile = new stdClass(); + $plagiarismfile = new \stdClass(); $plagiarismfile->cm = $cm->id; $plagiarismfile->userid = $student->id; $plagiarismfile->identifier = "abcd"; diff --git a/tests/turnitin_test.php b/tests/turnitin_test.php index bda1d7da..c418ab31 100644 --- a/tests/turnitin_test.php +++ b/tests/turnitin_test.php @@ -33,7 +33,7 @@ * @copyright 2016 Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -final class turnitin_test extends advanced_testcase { +final class turnitin_test extends \advanced_testcase { /** * Isolates a problem found running core tests in Moodle 31. *