Skip to content

Commit fb7c3a5

Browse files
committed
Allow administrators to force submissions to go to the institutional repository
1 parent 7c8ea12 commit fb7c3a5

8 files changed

+102
-41
lines changed

CHANGELOG.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
### 2018-XXX-XXX
2+
### v2018xxxxxx
3+
4+
- If GradeMark is not being used, the Gradebook column created has the assignment title as it's header rather than 'Grade'
5+
- Feature added to allow admins to force all submissions to go to the Institutional Repository
6+
17
### 2018-March-12
28
### v2018031201
39

4-
### Fixes and enhancements
10+
#### Fixes and enhancements
511

612
---
713

@@ -19,7 +25,6 @@
1925

2026
> You can manually delete your previously migrated assignments from the usual spot in the Moodle Migration Tool; we encourage you to delete these as soon as possible in order to resolve any current issues in the grade book. Any V1 assignments migrated after this update will be automatically deleted.
2127
22-
---
2328

2429
### :snowflake: Date: 2018-January-16
2530
### :snowflake: Release: v2018011601

lang/en/turnitintooltwo.php

+1
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@
475475
$string['repositoryoptions_1'] = 'Enable instructor expanded repository options';
476476
$string['repositoryoptions_2'] = 'Submit all papers to the standard repository';
477477
$string['repositoryoptions_3'] = 'Do not submit any papers into a repository';
478+
$string['repositoryoptions_4'] = 'Submit all papers to the institutional repository';
478479
$string['turnitinula_btn'] = 'Please click here to read and accept the Agreement.';
479480
$string['turnitinula'] = 'You must accept the latest Turnitin User Agreement before you can make a submission.';
480481
$string['upgradenotavailable'] = 'No Upgrade Available';

lib.php

+36-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@
4040
define('REPORT_GEN_SPEED_NUM_RESUBMISSIONS', 3);
4141
define('REPORT_GEN_SPEED_NUM_HOURS', 24);
4242

43+
// Admin Repository constants.
44+
define('ADMIN_REPOSITORY_OPTION_STANDARD', 0);
45+
define('ADMIN_REPOSITORY_OPTION_EXPANDED', 1);
46+
define('ADMIN_REPOSITORY_OPTION_FORCE_STANDARD', 2);
47+
define('ADMIN_REPOSITORY_OPTION_FORCE_NO', 3);
48+
define('ADMIN_REPOSITORY_OPTION_FORCE_INSTITUTIONAL', 4);
49+
50+
// Submit Papers to Repository constants.
51+
define('SUBMIT_TO_NO_REPOSITORY', 0);
52+
define('SUBMIT_TO_STANDARD_REPOSITORY', 1);
53+
define('SUBMIT_TO_INSTITUTIONAL_REPOSITORY', 2);
54+
4355
// For use in course migration.
4456
$tiiintegrationids = array(0 => get_string('nointegration', 'turnitintooltwo'), 1 => 'Blackboard Basic',
4557
2 => 'WebCT', 5 => 'Angel', 6 => 'Moodle Basic', 7 => 'eCollege', 8 => 'Desire2Learn',
@@ -1790,4 +1802,27 @@ function turnitintooltwo_get_report_gen_speed_params() {
17901802
$genparams->num_hours = REPORT_GEN_SPEED_NUM_HOURS;
17911803

17921804
return $genparams;
1793-
}
1805+
}
1806+
1807+
/**
1808+
* Override the repository option if necessary depending on the configuration setting.
1809+
* @param $submitpapersto int - The repository to submit to.
1810+
* @return $submitpapersto int - The repository to submit to.
1811+
*/
1812+
function turnitintooltwo_override_repository($submitpapersto) {
1813+
$config = turnitintooltwo_admin_config();
1814+
1815+
switch ($config->repositoryoption) {
1816+
case ADMIN_REPOSITORY_OPTION_FORCE_STANDARD; // Force Standard Repository.
1817+
$submitpapersto = SUBMIT_TO_STANDARD_REPOSITORY;
1818+
break;
1819+
case ADMIN_REPOSITORY_OPTION_FORCE_NO; // Force No Repository.
1820+
$submitpapersto = SUBMIT_TO_NO_REPOSITORY;
1821+
break;
1822+
case ADMIN_REPOSITORY_OPTION_FORCE_INSTITUTIONAL; // Force Individual Repository.
1823+
$submitpapersto = SUBMIT_TO_INSTITUTIONAL_REPOSITORY;
1824+
break;
1825+
}
1826+
1827+
return $submitpapersto;
1828+
}

mod_form.php

+12-14
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class mod_turnitintooltwo_mod_form extends moodleform_mod {
3535

3636
public function definition() {
3737
global $DB, $USER, $COURSE;
38-
$config = turnitintooltwo_admin_config();
3938

4039
// Module string is useful for product support.
4140
$modulestring = '<!-- Turnitin Moodle Direct Version: '.turnitintooltwo_get_version().' - (';
@@ -112,14 +111,7 @@ public function definition() {
112111
}
113112

114113
// Overwrite instructor default repository if admin is forcing repository setting.
115-
switch ($config->repositoryoption) {
116-
case 2; // Force Standard Repository.
117-
$this->current->submitpapersto = 1;
118-
break;
119-
case 3; // Force No Repository.
120-
$this->current->submitpapersto = 0;
121-
break;
122-
}
114+
$this->current->submitpapersto = turnitintooltwo_override_repository($this->current->submitpapersto);
123115

124116
$modulestring .= ') -->';
125117

@@ -421,28 +413,33 @@ public function show_form($instructorrubrics, $sharedrubrics, $modulestring = ''
421413

422414
$suboptions = array(0 => get_string('norepository', 'turnitintooltwo'),
423415
1 => get_string('standardrepository', 'turnitintooltwo'));
416+
424417
switch ($config->repositoryoption) {
425-
case 0; // Standard options.
418+
case ADMIN_REPOSITORY_OPTION_STANDARD; // Standard options.
426419
$mform->addElement('select', 'submitpapersto', get_string('submitpapersto', 'turnitintooltwo'), $suboptions);
427420
$mform->addHelpButton('submitpapersto', 'submitpapersto', 'turnitintooltwo');
428421
$mform->setDefault('submitpapersto', $config->default_submitpapersto);
429422
break;
430-
case 1; // Standard options + Allow Instituional Repository.
423+
case ADMIN_REPOSITORY_OPTION_EXPANDED; // Standard options + Allow Instituional Repository.
431424
$suboptions[2] = get_string('institutionalrepository', 'turnitintooltwo');
432425

433426
$mform->addElement('select', 'submitpapersto', get_string('submitpapersto', 'turnitintooltwo'), $suboptions);
434427
$mform->addHelpButton('submitpapersto', 'submitpapersto', 'turnitintooltwo');
435428
$mform->setDefault('submitpapersto', $config->default_submitpapersto);
436429

437430
break;
438-
case 2; // Force Standard Repository.
431+
case ADMIN_REPOSITORY_OPTION_FORCE_STANDARD; // Force Standard Repository.
439432
$mform->addElement('hidden', 'submitpapersto', 1);
440433
$mform->setType('submitpapersto', PARAM_RAW);
441434
break;
442-
case 3; // Force No Repository.
435+
case ADMIN_REPOSITORY_OPTION_FORCE_NO; // Force No Repository.
443436
$mform->addElement('hidden', 'submitpapersto', 0);
444437
$mform->setType('submitpapersto', PARAM_RAW);
445438
break;
439+
case ADMIN_REPOSITORY_OPTION_FORCE_INSTITUTIONAL; // Force Individual Repository.
440+
$mform->addElement('hidden', 'submitpapersto', 2);
441+
$mform->setType('submitpapersto', PARAM_RAW);
442+
break;
446443
}
447444

448445
$mform->addElement('html', html_writer::tag('div', get_string('checkagainstnote', 'turnitintooltwo'),
@@ -460,7 +457,8 @@ public function show_form($instructorrubrics, $sharedrubrics, $modulestring = ''
460457
$mform->addHelpButton('journalcheck', 'journalcheck', 'turnitintooltwo');
461458
$mform->setDefault('journalcheck', $config->default_journalcheck);
462459

463-
if ($config->repositoryoption == "1") {
460+
if ($config->repositoryoption == ADMIN_REPOSITORY_OPTION_EXPANDED ||
461+
$config->repositoryoption == ADMIN_REPOSITORY_OPTION_FORCE_INSTITUTIONAL) {
464462
$mform->addElement('select', 'institution_check', get_string('institutionalcheck', 'turnitintooltwo'), $ynoptions);
465463
$mform->setDefault('institution_check', $config->default_institutioncheck);
466464
}

settings.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,12 @@
216216
0, $ynoptions));
217217

218218
$repositoryoptions = array(
219-
0 => get_string('repositoryoptions_0', 'turnitintooltwo'),
220-
1 => get_string('repositoryoptions_1', 'turnitintooltwo'),
221-
2 => get_string('repositoryoptions_2', 'turnitintooltwo'),
222-
3 => get_string('repositoryoptions_3', 'turnitintooltwo')
223-
);
219+
ADMIN_REPOSITORY_OPTION_STANDARD => get_string('repositoryoptions_0', 'turnitintooltwo'),
220+
ADMIN_REPOSITORY_OPTION_EXPANDED => get_string('repositoryoptions_1', 'turnitintooltwo'),
221+
ADMIN_REPOSITORY_OPTION_FORCE_STANDARD => get_string('repositoryoptions_2', 'turnitintooltwo'),
222+
ADMIN_REPOSITORY_OPTION_FORCE_NO => get_string('repositoryoptions_3', 'turnitintooltwo'),
223+
ADMIN_REPOSITORY_OPTION_FORCE_INSTITUTIONAL => get_string('repositoryoptions_4', 'turnitintooltwo')
224+
);
224225

225226
$settings->add(new admin_setting_configselect('turnitintooltwo/repositoryoption',
226227
get_string('turnitinrepositoryoptions', 'turnitintooltwo'),

tests/unit/lib_test.php

+36
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,42 @@ public function test_turnitintooltwo_get_course_type() {
3232
$this->assertEquals($response, "TT");
3333
}
3434

35+
/**
36+
* Test that we have the correct repository depending on the config settings.
37+
*/
38+
public function test_turnitintooltwo_override_repository() {
39+
$this->resetAfterTest();
40+
41+
// Note that $submitpapersto would only ever be 0, 1 or 2 but this is to illustrate
42+
// that it won't be overridden by the turnitintooltwo_override_repository method.
43+
$submitpapersto = 6;
44+
45+
// Test that repository is not overridden for value of 0.
46+
set_config('repositoryoption', '0', 'turnitintooltwo');
47+
$response = turnitintooltwo_override_repository($submitpapersto);
48+
$this->assertEquals($response, $submitpapersto);
49+
50+
// Test that repository is not overridden for value of 1.
51+
set_config('repositoryoption', '1', 'turnitintooltwo');
52+
$response = turnitintooltwo_override_repository($submitpapersto);
53+
$this->assertEquals($response, $submitpapersto);
54+
55+
// Standard Repository is being forced.
56+
set_config('repositoryoption', '2', 'turnitintooltwo');
57+
$response = turnitintooltwo_override_repository($submitpapersto);
58+
$this->assertEquals($response, SUBMIT_TO_STANDARD_REPOSITORY);
59+
60+
// No Repository is being forced.
61+
set_config('repositoryoption', '3', 'turnitintooltwo');
62+
$response = turnitintooltwo_override_repository($submitpapersto);
63+
$this->assertEquals($response, SUBMIT_TO_NO_REPOSITORY);
64+
65+
// Institutional Repository is being forced.
66+
set_config('repositoryoption', '4', 'turnitintooltwo');
67+
$response = turnitintooltwo_override_repository($submitpapersto);
68+
$this->assertEquals($response, SUBMIT_TO_INSTITUTIONAL_REPOSITORY);
69+
}
70+
3571
/**
3672
* Test that the cron processes gradebook migrations.
3773
*/

turnitintooltwo_assignment.class.php

+3-18
Original file line numberDiff line numberDiff line change
@@ -1328,14 +1328,6 @@ public function edit_moodle_assignment($createevent = true, $restore = false) {
13281328
$coursetype = turnitintooltwo_get_course_type($legacy);
13291329
$course = $this->get_course_data($this->turnitintooltwo->course, $coursetype);
13301330

1331-
// Get the Turnitin owner of this this Course or make user the owner if none.
1332-
$ownerid = $this->get_tii_owner($course->id);
1333-
if (!empty($ownerid)) {
1334-
$owner = new turnitintooltwo_user($ownerid, 'Instructor');
1335-
} else {
1336-
$owner = new turnitintooltwo_user($USER->id, 'Instructor');
1337-
}
1338-
13391331
// Edit course in Turnitin.
13401332
$this->edit_tii_course($course);
13411333
$course->turnitin_ctl = $course->fullname . " (Moodle TT)";
@@ -1353,15 +1345,8 @@ public function edit_moodle_assignment($createevent = true, $restore = false) {
13531345
}
13541346
$partids = array_keys($parts);
13551347

1356-
// Override submitpapersto if necessary when admin is forcing standard/no repository.
1357-
switch ($config->repositoryoption) {
1358-
case 2; // Standard repository being forced.
1359-
$this->turnitintooltwo->submitpapersto = 1;
1360-
break;
1361-
case 3; // No repository being forced.
1362-
$this->turnitintooltwo->submitpapersto = 0;
1363-
break;
1364-
}
1348+
// Override submitpapersto if necessary when admin is forcing repository setting.
1349+
$this->turnitintooltwo->submitpapersto = turnitintooltwo_override_repository($this->turnitintooltwo->submitpapersto);
13651350

13661351
// Update GradeMark setting depending on config setting.
13671352
$this->turnitintooltwo->usegrademark = $config->usegrademark;
@@ -1387,7 +1372,7 @@ public function edit_moodle_assignment($createevent = true, $restore = false) {
13871372
$assignment->setSmallMatchExclusionType($this->turnitintooltwo->excludetype);
13881373
$assignment->setSmallMatchExclusionThreshold((int) $this->turnitintooltwo->excludevalue);
13891374
$assignment->setLateSubmissionsAllowed($this->turnitintooltwo->allowlate);
1390-
if ($config->repositoryoption == 1) {
1375+
if ($config->repositoryoption >= ADMIN_REPOSITORY_OPTION_EXPANDED) {
13911376
$institutioncheck = (isset($this->turnitintooltwo->institution_check)) ? $this->turnitintooltwo->institution_check : 0;
13921377
$assignment->setInstitutionCheck($institutioncheck);
13931378
}

turnitintooltwo_submission.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ public function save_updated_submission_data($tiisubmissiondata, $bulk = false,
811811
$sub->id = $DB->insert_record("turnitintooltwo_submissions", $sub, true, $bulk);
812812
}
813813

814-
//Update the Moodle gradebook.
814+
// Update the Moodle gradebook.
815815
$this->update_gradebook($sub, $turnitintooltwoassignment);
816816
}
817817
}

0 commit comments

Comments
 (0)