Skip to content

Commit 2b3fdd1

Browse files
authored
Merge pull request #253 from turnitin/develop
Merge develop into master for release.
2 parents 5a76b2b + 63f6788 commit 2b3fdd1

File tree

81 files changed

+32912
-31014
lines changed

Some content is hidden

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

81 files changed

+32912
-31014
lines changed

.travis.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
language: php
2+
3+
sudo: false
4+
5+
cache:
6+
directories:
7+
- $HOME/.composer/cache
8+
9+
php:
10+
- 5.5
11+
# - 5.6
12+
- 7.0
13+
14+
env:
15+
global:
16+
- IGNORE_PATHS=sdk/,fonts/,pix/
17+
- IGNORE_NAMES=jquery*,moment.js,colorbox.css,tooltipster.css,*.min.css,*.min.js,tii-icon-webfont.css,styles.css,styles.css.map,gulpfile.js
18+
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
25+
26+
before_install:
27+
- phpenv config-rm xdebug.ini
28+
- cd ../..
29+
- composer selfupdate
30+
- composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^1
31+
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
32+
33+
install:
34+
- moodle-plugin-ci install
35+
36+
script:
37+
- moodle-plugin-ci phplint
38+
# - moodle-plugin-ci phpcpd
39+
- moodle-plugin-ci phpmd
40+
# - moodle-plugin-ci codechecker
41+
- moodle-plugin-ci csslint
42+
- moodle-plugin-ci shifter
43+
# - moodle-plugin-ci jshint
44+
- moodle-plugin-ci validate
45+
- moodle-plugin-ci phpunit
46+
- moodle-plugin-ci behat

CHANGELOG.md

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
1+
### Date: 2017-January-25
2+
### Release: v2017012501
3+
4+
- This release and future releases will no longer work on Moodle 2.6.
5+
- The language strings have been updated across all supported languages.
6+
- The implementation of submission deletion has been changed so that it is no longer a link.
7+
- Data dump display has been optimised to help with large databases.
8+
- If the required fileinfo extension is missing it will now be mentioned on the plugin settings page.
9+
- The plugin will now not make excessive calls to Turnitin when using the bulk enrolment tool.
10+
- Suspended users now no longer appear in the assignment inbox.
11+
- Non-submitter e-mails will no longer be sent to inactive students. (Thanks to @junwan6)
12+
- Travis-CI has been aded to the plugin as an extra QA resource to help flag any issues with the code.
13+
- Inclusion paths were consolidated for the ./sdk directory. (Thanks to @eviweb)
14+
- Fixes:
15+
- Fixed an issue with duplicate submission rows showing in the Moodle database.
16+
- Fixed an issue with anonymous marking where the overall grade would sometimes not appear.
17+
- The assignment edit API call no longer fails if repository settings don't match the plugin settings.
18+
- The submission processing message that was missing in Moodle 3.1 is now visible again.
19+
- Fixed a bug where the submission inbox would not load if an enrolled student has been deleted in Turnitin.
20+
- Characters that cannot be used in a file name in Windows are now removed from submission titles to prevent submission errors.
21+
22+
---
23+
124
### Date: 2016-December-21
225
### Release: v2016122101
326

427
- Fixes:
528
- Changed the language codes to correctly recognise Simplified Chinese in Moodle.
629
- Pass the correct Simplified Chinese language code to Turnitin.
730

31+
---
32+
833
### Date: 2016-September-14
934
### Release: v2016091401
1035

11-
1236
- Remove leftover counter variable from get_submission_inbox function.
1337
- Refactored the get users functionality in several places to not include users with roles inherited from site level.
1438
- Fixes:

ajax.php

+81-47
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
$turnitintooltwoassignment = new turnitintooltwo_assignment($assignmentid);
3636
$part = $turnitintooltwoassignment->get_part_details($partid);
3737

38-
$anonData = array(
38+
$anondata = array(
3939
'anon' => $turnitintooltwoassignment->turnitintooltwo->anon,
4040
'unanon' => $part->unanon,
4141
'submitted' => $part->submitted
4242
);
43-
echo json_encode($anonData);
43+
echo json_encode($anondata);
4444
break;
4545

4646
case "edit_field":
@@ -97,8 +97,8 @@
9797

9898
$partdetails = $turnitintooltwoassignment->get_parts();
9999

100-
$return['export_option'] = ($turnitintooltwoassignment->turnitintooltwo->anon == 0 || time() > $partdetails[$partid]->dtpost) ?
101-
"tii_export_options_show" : "tii_export_options_hide";
100+
$unanonymised = ($turnitintooltwoassignment->turnitintooltwo->anon == 0 || time() > $partdetails[$partid]->dtpost);
101+
$return['export_option'] = ($unanonymised) ? "tii_export_options_show" : "tii_export_options_hide";
102102

103103
echo json_encode($return);
104104
break;
@@ -111,7 +111,7 @@
111111

112112
if (has_capability('mod/turnitintooltwo:read', context_module::instance($cm->id))) {
113113
$user = new turnitintooltwo_user($USER->id, "Learner");
114-
echo turnitintooltwo_view::output_dv_launch_form("useragreement", 0, $user->tii_user_id, "Learner", "Submit", true);
114+
echo turnitintooltwo_view::output_dv_launch_form("useragreement", 0, $user->tiiuserid, "Learner", "Submit", true);
115115
}
116116
break;
117117

@@ -122,19 +122,19 @@
122122

123123
$message = optional_param('message', '', PARAM_ALPHAEXT);
124124

125-
// Get the id from the turnitintooltwo_users table so we can update
126-
$turnitin_user = $DB->get_record('turnitintooltwo_users', array('userid' => $USER->id));
125+
// Get the id from the turnitintooltwo_users table so we can update.
126+
$turnitinuser = $DB->get_record('turnitintooltwo_users', array('userid' => $USER->id));
127127

128-
// Build user object for update
129-
$eula_user = new object();
130-
$eula_user->id = $turnitin_user->id;
131-
$eula_user->user_agreement_accepted = 0;
128+
// Build user object for update.
129+
$eulauser = new object();
130+
$eulauser->id = $turnitinuser->id;
131+
$eulauser->user_agreement_accepted = 0;
132132
if ($message == 'turnitin_eula_accepted') {
133-
$eula_user->user_agreement_accepted = 1;
133+
$eulauser->user_agreement_accepted = 1;
134134
}
135135

136-
// Update the user using the above object
137-
$DB->update_record('turnitintooltwo_users', $eula_user, $bulk=false);
136+
// Update the user using the above object.
137+
$DB->update_record('turnitintooltwo_users', $eulauser, false);
138138
break;
139139

140140
case "downloadoriginal":
@@ -152,12 +152,12 @@
152152

153153
$user = new turnitintooltwo_user($USER->id, $userrole);
154154

155-
$launch_form = turnitintooltwo_view::output_dv_launch_form($action, $submissionid, $user->tii_user_id, $userrole, '');
155+
$launchform = turnitintooltwo_view::output_dv_launch_form($action, $submissionid, $user->tiiuserid, $userrole, '');
156156
if ($action == 'downloadoriginal') {
157-
echo $launch_form;
157+
echo $launchform;
158158
} else {
159-
$launch_form = html_writer::tag("div", $launch_form, array('style' => 'display: none'));
160-
echo json_encode($launch_form);
159+
$launchform = html_writer::tag("div", $launchform, array('style' => 'display: none'));
160+
echo json_encode($launchform);
161161
}
162162
}
163163
break;
@@ -198,7 +198,7 @@
198198
$submissionids = optional_param_array('submission_ids', array(), PARAM_INT);
199199
}
200200

201-
echo turnitintooltwo_view::output_download_launch_form($action, $user->tii_user_id, $partid, $submissionids);
201+
echo turnitintooltwo_view::output_download_launch_form($action, $user->tiiuserid, $partid, $submissionids);
202202
}
203203
break;
204204

@@ -250,22 +250,23 @@
250250
$PAGE->set_context(context_module::instance($cm->id));
251251
$turnitintooltwoview = new turnitintooltwo_view();
252252

253-
$return["aaData"] = $turnitintooltwoview->get_submission_inbox($cm, $turnitintooltwoassignment, $parts, $partid, $start);
253+
$view = $turnitintooltwoview->get_submission_inbox($cm, $turnitintooltwoassignment, $parts, $partid, $start);
254+
$return["aaData"] = $view;
254255
$totalsubmitters = $DB->count_records('turnitintooltwo_submissions',
255256
array('turnitintooltwoid' => $turnitintooltwoassignment->turnitintooltwo->id,
256257
'submission_part' => $partid));
257258
$return["end"] = $start + TURNITINTOOLTWO_SUBMISSION_GET_LIMIT;
258259
$return["total"] = $_SESSION["num_submissions"][$partid];
259260
$return["nonsubmitters"] = $return["total"] - $totalsubmitters;
260261

261-
// Remove any leftover submissions from session and update grade timestamp/
262+
// Remove any leftover submissions from session and update grade timestamp.
262263
if ($return["end"] >= $return["total"]) {
263264
unset($_SESSION["submissions"][$partid]);
264265

265266
$updatepart = new stdClass();
266267
$updatepart->id = $partid;
267268
// Set timestamp to 10 minutes ago to account for time taken to complete (somewhat exagerrated).
268-
$updatepart->gradesupdated = time()-(60*10);
269+
$updatepart->gradesupdated = time() - (60 * 10);
269270
$DB->update_record('turnitintooltwo_parts', $updatepart);
270271
}
271272
} else {
@@ -439,17 +440,21 @@
439440
if (!empty($assignmentid)) {
440441
if ($modulename == "turnitintooltwo") {
441442
if (!empty($turnitintooltwoassignment->turnitintooltwo->rubric)) {
442-
$options[$turnitintooltwoassignment->turnitintooltwo->rubric] =
443-
(isset($options[$turnitintooltwoassignment->turnitintooltwo->rubric])) ?
444-
$options[$turnitintooltwoassignment->turnitintooltwo->rubric] :
445-
get_string('otherrubric', 'turnitintooltwo');
443+
if (isset($options[$turnitintooltwoassignment->turnitintooltwo->rubric])) {
444+
$rubricname = $options[$turnitintooltwoassignment->turnitintooltwo->rubric];
445+
} else {
446+
$rubricname = get_string('otherrubric', 'turnitintooltwo');
447+
}
448+
$options[$turnitintooltwoassignment->turnitintooltwo->rubric] = $rubricname;
446449
}
447450
} else {
448451
if (!empty($plagiarismsettings["plagiarism_rubric"])) {
449-
$options[$plagiarismsettings["plagiarism_rubric"]] =
450-
(isset($options[$plagiarismsettings["plagiarism_rubric"]])) ?
451-
$options[$plagiarismsettings["plagiarism_rubric"]] :
452-
get_string('otherrubric', 'turnitintooltwo');
452+
if (isset($options[$plagiarismsettings["plagiarism_rubric"]])) {
453+
$rubricname = $options[$plagiarismsettings["plagiarism_rubric"]];
454+
} else {
455+
$rubricname = get_string('otherrubric', 'turnitintooltwo');
456+
}
457+
$options[$plagiarismsettings["plagiarism_rubric"]] = $rubricname;
453458
}
454459
}
455460
}
@@ -532,14 +537,14 @@
532537
throw new moodle_exception('invalidsesskey', 'error');
533538
}
534539

535-
$coursetitle = optional_param('course_title', '', PARAM_TEXT);
540+
$title = optional_param('course_title', '', PARAM_TEXT);
536541
$courseintegration = optional_param('course_integration', '', PARAM_ALPHANUM);
537-
$courseenddate = optional_param('course_end_date', null, PARAM_TEXT);
538-
$requestsource = optional_param('request_source', 'mod', PARAM_TEXT);
542+
$enddate = optional_param('course_end_date', null, PARAM_TEXT);
543+
$source = optional_param('request_source', 'mod', PARAM_TEXT);
539544

540545
$modules = $DB->get_record('modules', array('name' => 'turnitintooltwo'));
541546

542-
$return = turnitintooltwo_get_courses_from_tii($tiiintegrationids, $coursetitle, $courseintegration, $courseenddate, $requestsource);
547+
$return = turnitintooltwo_get_courses_from_tii($tiiintegrationids, $title, $courseintegration, $enddate, $source);
543548
echo json_encode($return);
544549
break;
545550

@@ -558,10 +563,9 @@
558563

559564
$i = 0;
560565
foreach ($classids as $tiiclassid) {
561-
$tiicoursename = $_SESSION['tii_classes'][$tiiclassid];
562-
$coursename = $tiicoursename;
566+
$coursename = $_SESSION['tii_classes'][$tiiclassid];
563567

564-
$course = turnitintooltwo_assignment::create_moodle_course($tiiclassid, $tiicoursename, $coursename, $coursecategory);
568+
$course = turnitintooltwo_assignment::create_moodle_course($tiiclassid, $coursename, $coursename, $coursecategory);
565569
if ($createassignments == 1 && !empty($course)) {
566570
$return = turnitintooltwo_get_assignments_from_tii($tiiclassid, "raw");
567571

@@ -669,8 +673,11 @@
669673
$partids = required_param('parts', PARAM_SEQUENCE);
670674
$courseid = optional_param('course_id', 0, PARAM_INT);
671675
$assignmentname = optional_param('assignment_name', '', PARAM_TEXT);
672-
$assignmentname = (empty($assignmentname)) ? get_string('defaultassignmenttiititle', 'turnitintooltwo') :
673-
urldecode($assignmentname);
676+
if (empty($assignmentname)) {
677+
$assignmentname = get_string('defaultassignmenttiititle', 'turnitintooltwo');
678+
} else {
679+
$assignmentname = urldecode($assignmentname);
680+
}
674681

675682
$partids = explode(',', $partids);
676683
if (is_array($partids)) {
@@ -714,12 +721,12 @@
714721
throw new moodle_exception('invalidsesskey', 'error');
715722
}
716723
$data = '';
717-
$current_version = required_param('current_version', PARAM_INT);
724+
$currentversion = required_param('current_version', PARAM_INT);
718725

719726
$PAGE->set_context(context_system::instance());
720727

721728
if (is_siteadmin()) {
722-
$data = turnitintooltwo_updateavailable($current_version);
729+
$data = turnitintooltwo_updateavailable($currentversion);
723730
}
724731
echo json_encode($data);
725732
break;
@@ -734,20 +741,20 @@
734741
if (is_siteadmin()) {
735742
// Initialise API connection.
736743

737-
$account_id = required_param('account_id', PARAM_RAW);
738-
$account_shared = required_param('account_shared', PARAM_RAW);
744+
$accountid = required_param('accountid', PARAM_RAW);
745+
$accountshared = required_param('accountshared', PARAM_RAW);
739746
$url = required_param('url', PARAM_RAW);
740747

741-
$turnitincomms = new turnitintooltwo_comms($account_id, $account_shared, $url);
748+
$turnitincomms = new turnitintooltwo_comms($accountid, $accountshared, $url);
742749

743750
$testingconnection = true; // Provided by Androgogic to override offline mode for testing connection.
744751

745-
// We only want an API log entry for this if diagnostic mode is set to Debugging
752+
// We only want an API log entry for this if diagnostic mode is set to Debugging.
746753
if (empty($config)) {
747754
$config = turnitintooltwo_admin_config();
748755
}
749756
if ($config->enablediagnostic != 2) {
750-
$turnitincomms->setDiagnostic(0);
757+
$turnitincomms->set_diagnostic(0);
751758
}
752759

753760
$tiiapi = $turnitincomms->initialise_api($testingconnection);
@@ -794,5 +801,32 @@
794801
} else {
795802
echo json_encode($data);
796803
}
797-
break;
804+
break;
805+
806+
case "deletesubmission":
807+
808+
if (!confirm_sesskey()) {
809+
throw new moodle_exception('invalidsesskey', 'error');
810+
}
811+
812+
$submissionid = required_param('paper', PARAM_INT);
813+
$part = required_param('part', PARAM_INT);
814+
$assignmentid = required_param('assignment', PARAM_INT);
815+
816+
$turnitintooltwoassignment = new turnitintooltwo_assignment($assignmentid);
817+
$turnitintooltwosubmission = new turnitintooltwo_submission($submissionid, "moodle", $turnitintooltwoassignment);
818+
819+
$cm = get_coursemodule_from_instance("turnitintooltwo", $assignmentid);
820+
821+
if (has_capability('mod/turnitintooltwo:read', context_module::instance($cm->id))) {
822+
$istutor = (has_capability('mod/turnitintooltwo:grade', context_module::instance($cm->id))) ? true : false;
823+
}
824+
825+
// Allow instructors to delete submission and students to delete if the submission hasn't gone to Turnitin.
826+
if (($istutor && $submissionid != 0) ||
827+
($USER->id == $turnitintooltwosubmission->userid && empty($turnitintooltwosubmission->submission_objectid))) {
828+
$_SESSION["notice"] = $turnitintooltwosubmission->delete_submission();
829+
}
830+
exit();
831+
break;
798832
}

0 commit comments

Comments
 (0)