Skip to content

Commit 5d917d7

Browse files
authored
Merge pull request #434 from turnitin/develop
Develop to master for v2019050201
2 parents 8510fda + 7f6af5f commit 5d917d7

File tree

228 files changed

+43926
-3683
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+43926
-3683
lines changed

.travis.yml

+32-14
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,48 @@ language: php
22

33
sudo: false
44

5+
addons:
6+
postgresql: "9.3"
7+
58
cache:
69
directories:
710
- $HOME/.composer/cache
811

912
php:
1013
- 5.5
11-
# - 5.6
1214
- 7.0
15+
- 7.2
1316

1417
env:
1518
global:
16-
- IGNORE_PATHS=sdk/,pix/
17-
- IGNORE_NAMES=jquery*,styles.css
19+
- IGNORE_PATHS=sdk/,pix/,vendor/
20+
- IGNORE_NAMES=jquery*,styles.css,autoload_static.php
1821
matrix:
19-
# - DB=pgsql MOODLE_BRANCH=MOODLE_31_STABLE
20-
# - DB=mysqli MOODLE_BRANCH=MOODLE_31_STABLE
21-
- DB=pgsql MOODLE_BRANCH=MOODLE_30_STABLE
22-
- DB=mysqli MOODLE_BRANCH=MOODLE_30_STABLE
23-
# - DB=pgsql MOODLE_BRANCH=MOODLE_27_STABLE
24-
# - DB=mysqli MOODLE_BRANCH=MOODLE_27_STABLE
22+
- DB=pgsql MOODLE_BRANCH=MOODLE_31_STABLE
23+
- DB=mysqli MOODLE_BRANCH=MOODLE_31_STABLE
24+
25+
26+
#TODO: Readd these once the split is complete.
27+
28+
# - DB=pgsql MOODLE_BRANCH=MOODLE_34_STABLE
29+
# - DB=mysqli MOODLE_BRANCH=MOODLE_34_STABLE
30+
# - DB=pgsql MOODLE_BRANCH=MOODLE_35_STABLE
31+
# - DB=mysqli MOODLE_BRANCH=MOODLE_35_STABLE
32+
33+
matrix:
34+
exclude:
35+
- env: DB=pgsql MOODLE_BRANCH=MOODLE_31_STABLE
36+
php: 7.2
37+
- env: DB=mysqli MOODLE_BRANCH=MOODLE_31_STABLE
38+
php: 7.2
39+
- env: DB=pgsql MOODLE_BRANCH=MOODLE_34_STABLE
40+
php: 5.5
41+
- env: DB=mysqli MOODLE_BRANCH=MOODLE_34_STABLE
42+
php: 5.5
43+
- env: DB=pgsql MOODLE_BRANCH=MOODLE_35_STABLE
44+
php: 5.5
45+
- env: DB=mysqli MOODLE_BRANCH=MOODLE_35_STABLE
46+
php: 5.5
2547

2648
before_install:
2749
- phpenv config-rm xdebug.ini
@@ -35,12 +57,8 @@ install:
3557

3658
script:
3759
- moodle-plugin-ci phplint
38-
- moodle-plugin-ci phpcpd
3960
- moodle-plugin-ci phpmd
40-
- moodle-plugin-ci codechecker
4161
- moodle-plugin-ci csslint
4262
- moodle-plugin-ci shifter
43-
# - moodle-plugin-ci jshint
4463
- moodle-plugin-ci validate
45-
# - moodle-plugin-ci phpunit
46-
- moodle-plugin-ci behat
64+
# - moodle-plugin-ci phpunit

CHANGELOG.md

+25
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
### Date: 2019-May-02
2+
### Release: v2019050201
3+
4+
#### :zap: What's new
5+
6+
---
7+
8+
#### Moodle Plagiarism Plugin no longer dependant on Moodle V2
9+
10+
Previously, the Plagiarism Plugin was bundled along with Moodle Direct V2. Now, the Plagiarism Plugin is installed and configured separately.
11+
12+
If you are upgrading from a previous version of the Plagiarism Plugin, your existing configuration will be migrated over from Moodle V2.
13+
14+
For more details on how to configure your instance of Moodle Plagiarism Plugin, [please see the guidance](https://help.turnitin.com/feedback-studio/moodle/plagiarism-plugin/administrator/getting-started/step-3-configuring-turnitin-in-moodle.htm).
15+
16+
#### Forum messaging error resolved
17+
18+
When creating a forum post within Turnitin, we were showing information about report regeneration times when resubmitting. As information about resubmissions is not relevant to forum users, we’ve removed this notification from this view.
19+
20+
#### Improvements to plugin stability and modals
21+
22+
We’ve improved the stability of the plugin and made changes to our modals (dialog boxes) within Moodle. Modals will now be clearer and adapt to the browser theme that you’re using to improve the usability of the plugin.
23+
24+
---
25+
126
### Date: 2019-March-13
227
### Release: v2019031301
328

README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ If you are having issues, please consult our [TROUBLE SHOOTING](https://github.c
1212
Installation
1313
------------
1414

15-
Before installing this plugin firstly make sure you are logged in as an Administrator and that you are using Moodle 2.3 or higher.
16-
17-
Note: the [TURNITINTOOLTWO](https://github.com/turnitin/moodle-mod_turnitintooltwo) module must be installed before you can use the plagiarism plugin.
15+
Before installing this plugin firstly make sure you are logged in as an Administrator and that you are using Moodle 2.7 or higher.
1816

1917
The Plagiarism Plugin can be used within the following Moodle modules:
2018

@@ -29,5 +27,3 @@ Plagiarism plugins also need to be enabled before this plugin can be used. You c
2927
The Plagiarism Plugin will inherit connection settings from the turnitintooltwo module, but you can set default values and whether the plugin is enabled within Moodle modules by going to `"Site Administration" > "Plugins" > "Plagiarism prevention" > "Turnitin plagiarism plugin"`.
3028

3129
To create/update assignments, process submissions and update grades your moodle environment will need to have cron job running regularly. For information on how to do this please consult http://docs.moodle.org/26/en/Cron.
32-
33-
Note that this plugin inherits it's Turnitin connection from the turnitintooltwo module.

TROUBLESHOOTING.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
#Moodle Direct V2 Troubleshooting
1+
#Turnitin Plagiarism Plugin Troubleshooting
22

3-
1) You may need to ensure that within your designated moodledata directory; the turnitintooltwo subdirectory and the subsequent logs subdirectory have the correct permissions to be able to create directories and files.
3+
1) You may need to ensure that within your designated moodledata directory; the plagiarism_turnitin subdirectory and the subsequent logs subdirectory have the correct permissions to be able to create directories and files.
44

5-
2) You may need to ensure that the turnitintooltwo directory within your designated data directory and it's logs subdirectory have the correct permissions to be able to create directories and files.
5+
2) Pop-ups will need to be enabled on the browser being used if access to the Turnitin Document Viewer is required.
66

7-
3) Pop-ups will need to be enabled on the browser being used if access to the Turnitin Document Viewer is required.
8-
9-
4) There have been very isolated reports of the settings not showing for the Plagiarism plugin despite it being enabled, this is due to it not showing in Moodle cache. The solution is for an administrator to purge all caches and it should then appear.
7+
3) There have been very isolated reports of the settings not showing for the Plagiarism plugin despite it being enabled, this is due to it not showing in Moodle cache. The solution is for an administrator to purge all caches and it should then appear.
108

119
##Required PHP Extensions
1210

ajax.php

+157-29
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
1616

17-
require_once(__DIR__."/../../config.php");
18-
require_once(__DIR__."/lib.php");
19-
require_once($CFG->dirroot.'/mod/turnitintooltwo/turnitintooltwo_assignment.class.php');
20-
require_once($CFG->dirroot.'/mod/turnitintooltwo/turnitintooltwo_view.class.php');
17+
use Integrations\PhpSdk\TiiClass;
18+
19+
require_once(__DIR__.'/../../config.php');
20+
require_once($CFG->dirroot.'/plagiarism/turnitin/lib.php');
21+
require_once($CFG->dirroot.'/plagiarism/turnitin/classes/turnitin_assignment.class.php');
22+
require_once($CFG->dirroot.'/plagiarism/turnitin/classes/turnitin_user.class.php');
2123

2224
require_login();
2325

@@ -52,8 +54,8 @@
5254
case "get_dv_html":
5355
$submissionid = required_param('submissionid', PARAM_INT);
5456
$dvtype = optional_param('dvtype', 'default', PARAM_ALPHAEXT);
55-
$user = new turnitintooltwo_user($USER->id, $userrole);
56-
$coursedata = turnitintooltwo_assignment::get_course_data($cm->course, 'PP');
57+
$user = new turnitin_user($USER->id, $userrole);
58+
$coursedata = turnitin_assignment::get_course_data($cm->course);
5759

5860
if ($userrole == 'Instructor') {
5961
$user->join_user_to_class($coursedata->turnitin_cid);
@@ -64,10 +66,17 @@
6466
$syncassignment = $pluginturnitin->sync_tii_assignment($cm, $coursedata->turnitin_cid);
6567

6668
if ($syncassignment['success']) {
67-
$turnitintooltwoview = new turnitintooltwo_view();
68-
$return = html_writer::tag("div",
69-
$turnitintooltwoview->output_dv_launch_form($dvtype, $submissionid, $user->tiiuserid,
70-
$userrole, ''), array('style' => 'display: none'));
69+
$return = html_writer::tag(
70+
"div",
71+
turnitin_view::output_launch_form(
72+
$dvtype,
73+
$submissionid,
74+
$user->tiiuserid,
75+
$userrole,
76+
''
77+
),
78+
array('style' => 'display: none')
79+
);
7180
}
7281
break;
7382

@@ -129,12 +138,18 @@
129138
$tiiassignmentid = $tiiassignment['tiiassignmentid'];
130139
}
131140

132-
$user = new turnitintooltwo_user($USER->id, "Instructor");
141+
$user = new turnitin_user($USER->id, "Instructor");
133142
$user->join_user_to_class($coursedata->turnitin_cid);
134143

135-
echo html_writer::tag("div", turnitintooltwo_view::output_lti_form_launch('peermark_manager',
136-
'Instructor', $tiiassignmentid),
137-
array("class" => "launch_form", "style" => "display:none;"));
144+
echo html_writer::tag(
145+
'div',
146+
turnitin_view::output_lti_form_launch('peermark_manager', 'Instructor', $tiiassignmentid),
147+
array(
148+
'class' => 'launch_form',
149+
'style' => 'display:none;'
150+
)
151+
);
152+
138153
echo html_writer::script("<!--
139154
window.document.forms[0].submit();
140155
//-->");
@@ -149,13 +164,19 @@
149164
if ($isstudent) {
150165
$tiiassignment = $DB->get_record('plagiarism_turnitin_config', array('cm' => $cm->id, 'name' => 'turnitin_assignid'));
151166

152-
$user = new turnitintooltwo_user($USER->id, "Learner");
153-
$coursedata = turnitintooltwo_assignment::get_course_data($cm->course, 'PP');
167+
$user = new turnitin_user($USER->id, "Learner");
168+
$coursedata = turnitin_assignment::get_course_data($cm->course);
154169
$user->join_user_to_class($coursedata->turnitin_cid);
155170

156-
echo html_writer::tag("div", turnitintooltwo_view::output_lti_form_launch('rubric_view',
157-
'Learner', $tiiassignment->value),
158-
array("class" => "launch_form", "style" => "display:none;"));
171+
echo html_writer::tag(
172+
'div',
173+
turnitin_view::output_lti_form_launch('rubric_view', 'Learner', $tiiassignment->value),
174+
array(
175+
'class' => 'launch_form',
176+
'style' => 'display:none;'
177+
)
178+
);
179+
159180
echo html_writer::script("<!--
160181
window.document.forms[0].submit();
161182
//-->");
@@ -170,13 +191,19 @@
170191
if ($userrole == 'Instructor' || $isstudent) {
171192
$tiiassignment = $DB->get_record('plagiarism_turnitin_config', array('cm' => $cm->id, 'name' => 'turnitin_assignid'));
172193

173-
$user = new turnitintooltwo_user($USER->id, $userrole);
174-
$coursedata = turnitintooltwo_assignment::get_course_data($cm->course, 'PP');
194+
$user = new turnitin_user($USER->id, $userrole);
195+
$coursedata = turnitin_assignment::get_course_data($cm->course);
175196
$user->join_user_to_class($coursedata->turnitin_cid);
176197

177-
echo html_writer::tag("div", turnitintooltwo_view::output_lti_form_launch('peermark_reviews',
178-
$userrole, $tiiassignment->value),
179-
array("class" => "launch_form", "style" => "display:none;"));
198+
echo html_writer::tag(
199+
'div',
200+
turnitin_view::output_lti_form_launch('peermark_reviews', $userrole, $tiiassignment->value),
201+
array(
202+
'class' => 'launch_form',
203+
'style' => 'display:none;'
204+
)
205+
);
206+
180207
echo html_writer::script("<!--
181208
window.document.forms[0].submit();
182209
//-->");
@@ -190,23 +217,23 @@
190217

191218
$message = optional_param('message', '', PARAM_ALPHAEXT);
192219

193-
// Get the id from the turnitintooltwo_users table so we can update.
194-
$turnitinuser = $DB->get_record('turnitintooltwo_users', array('userid' => $USER->id));
220+
// Get the id from the plagiarism_turnitin_users table so we can update.
221+
$turnitinuser = $DB->get_record('plagiarism_turnitin_users', array('userid' => $USER->id));
195222

196223
// Build user object for update.
197224
$eulauser = new stdClass();
198225
$eulauser->id = $turnitinuser->id;
199226
$eulauser->user_agreement_accepted = 0;
200227
if ($message == 'turnitin_eula_accepted') {
201228
$eulauser->user_agreement_accepted = 1;
202-
turnitintooltwo_activitylog("User ".$USER->id." (".$turnitinuser->turnitin_uid.") accepted the EULA.", "PP_EULA_ACCEPTANCE");
229+
plagiarism_turnitin_activitylog("User ".$USER->id." (".$turnitinuser->turnitin_uid.") accepted the EULA.", "PP_EULA_ACCEPTANCE");
203230
} else if ($message == 'turnitin_eula_declined') {
204231
$eulauser->user_agreement_accepted = -1;
205-
turnitintooltwo_activitylog("User ".$USER->id." (".$turnitinuser->turnitin_uid.") declined the EULA.", "PP_EULA_ACCEPTANCE");
232+
plagiarism_turnitin_activitylog("User ".$USER->id." (".$turnitinuser->turnitin_uid.") declined the EULA.", "PP_EULA_ACCEPTANCE");
206233
}
207234

208235
// Update the user using the above object.
209-
$DB->update_record('turnitintooltwo_users', $eulauser, $bulk = false);
236+
$DB->update_record('plagiarism_turnitin_users', $eulauser, $bulk = false);
210237
break;
211238

212239
case "resubmit_event":
@@ -243,6 +270,107 @@
243270
}
244271
$return['errors'] = $errors;
245272
break;
273+
274+
case "test_connection":
275+
if (!confirm_sesskey()) {
276+
throw new moodle_exception('invalidsesskey', 'error');
277+
}
278+
$data = array("connection_status" => "fail", "msg" => get_string('connecttestcommerror', 'plagiarism_turnitin'));
279+
280+
$PAGE->set_context(context_system::instance());
281+
if (is_siteadmin()) {
282+
// Initialise API connection.
283+
284+
$accountid = required_param('accountid', PARAM_RAW);
285+
$accountshared = required_param('accountshared', PARAM_RAW);
286+
$url = required_param('url', PARAM_RAW);
287+
288+
$turnitincomms = new turnitin_comms($accountid, $accountshared, $url);
289+
290+
// We only want an API log entry for this if diagnostic mode is set to Debugging.
291+
if (empty($config)) {
292+
$config = plagiarism_plugin_turnitin::plagiarism_turnitin_admin_config();
293+
}
294+
if ($config->plagiarism_turnitin_enablediagnostic != 2) {
295+
$turnitincomms->set_diagnostic(0);
296+
}
297+
298+
$tiiapi = $turnitincomms->initialise_api(true);
299+
300+
$class = new TiiClass();
301+
$class->setTitle('Test finding a class to see if connection works');
302+
303+
try {
304+
$response = $tiiapi->findClasses($class);
305+
$data["connection_status"] = 200;
306+
$data["msg"] = get_string('connecttestsuccess', 'plagiarism_turnitin');
307+
} catch (Exception $e) {
308+
$turnitincomms->handle_exceptions($e, 'connecttesterror', false);
309+
}
310+
}
311+
echo json_encode($data);
312+
break;
313+
314+
case "get_users":
315+
$PAGE->set_context(context_system::instance());
316+
if (is_siteadmin()) {
317+
echo json_encode(turnitin_user::plagiarism_turnitin_getusers());
318+
} else {
319+
throw new moodle_exception('accessdenied', 'admin');
320+
}
321+
break;
322+
323+
case "refresh_rubric_select":
324+
$courseid = required_param('course', PARAM_INT);
325+
$assignmentid = required_param('assignment', PARAM_INT);
326+
$modulename = required_param('modulename', PARAM_ALPHA);
327+
328+
$PAGE->set_context(context_course::instance($courseid));
329+
330+
if (has_capability('moodle/course:update', context_course::instance($courseid))) {
331+
// Set Rubric options to instructor rubrics.
332+
$instructor = new turnitin_user($USER->id, 'Instructor');
333+
$instructor->set_user_values_from_tii();
334+
$instructorrubrics = $instructor->get_instructor_rubrics();
335+
336+
$options = array('' => get_string('norubric', 'plagiarism_turnitin')) + $instructorrubrics;
337+
338+
// Get rubrics that are shared on the Turnitin account.
339+
$turnitinclass = new turnitin_class($courseid);
340+
341+
$turnitinclass->read_class_from_tii();
342+
$sharedrubrics = $turnitinclass->sharedrubrics;
343+
344+
foreach ($sharedrubrics as $group => $grouprubrics) {
345+
foreach ($grouprubrics as $rubricid => $rubricname) {
346+
$options[$group][$rubricid] = $rubricname;
347+
}
348+
}
349+
350+
// Get assignment details.
351+
if (!empty($assignmentid)) {
352+
$cm = get_coursemodule_from_instance($modulename, $assignmentid);
353+
$plagiarismsettings = $pluginturnitin->get_settings($cm->id);
354+
}
355+
356+
// Add in selected rubric if it belongs to another instructor.
357+
if (!empty($assignmentid)) {
358+
if (!empty($plagiarismsettings["plagiarism_rubric"])) {
359+
if (isset($options[$plagiarismsettings["plagiarism_rubric"]])) {
360+
$rubricname = $options[$plagiarismsettings["plagiarism_rubric"]];
361+
} else {
362+
$rubricname = get_string('otherrubric', 'plagiarism_turnitin');
363+
}
364+
$options[$plagiarismsettings["plagiarism_rubric"]] = $rubricname;
365+
}
366+
}
367+
} else {
368+
$options = array();
369+
}
370+
371+
echo json_encode($options);
372+
break;
373+
246374
}
247375

248376
if (!empty($return)) {

0 commit comments

Comments
 (0)