Skip to content

Commit 7a38ce0

Browse files
authored
Merge pull request #543 from turnitin/develop
Release v2019070201
2 parents 06523a9 + e5d06c6 commit 7a38ce0

8 files changed

+203
-112
lines changed

CHANGELOG.md

+27
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
### Date: 2019-Jul-02
2+
### Release: v2019070201
3+
4+
#### :zap: What's new
5+
6+
---
7+
8+
#### Moodle 3.7 support and course overview bug fixes
9+
10+
We've been working on supporting Moodle 3.7 and improving the course overview area.
11+
12+
We've given the student and instructor views a refresh, and squashed some bugs that were affecting the Moodle timeline and student submissions. The details of the bug fixes are below.
13+
14+
#### :wrench: Fixes and enhancements
15+
16+
---
17+
18+
#### Moodle timeline bug resolved
19+
20+
There was a bug impacting the Moodle timeline that occurred when resetting courses with new assignment dates. As a result of this bug, after resetting, the new assignment wasn’t visible. This has now been resolved.
21+
22+
#### Overdue messaging bug resolved
23+
24+
Students were experiencing a bug that was causing the 'Recently Overdue' message to display even after students had submitted to the assignment. The message would only disappear once the submission has been graded. The message no longer displays once the student has submitted.
25+
26+
---
27+
128
### Date: 2019-May-01
229
### Release: v2019050101
330

lib.php

+67-47
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
require_once($CFG->libdir . "/gradelib.php");
3232

3333
// Constants.
34-
define('TURNITINTOOLTWO_MAX_FILE_UPLOAD_SIZE', 41943040);
34+
define('TURNITINTOOLTWO_MAX_FILE_UPLOAD_SIZE', 104857600);
3535
define('TURNITINTOOLTWO_DEFAULT_PSEUDO_DOMAIN', '@tiimoodle.com');
3636
define('TURNITINTOOLTWO_DEFAULT_PSEUDO_FIRSTNAME', get_string('defaultcoursestudent'));
3737
define('TURNITINTOOLTWO_SUBMISSION_GET_LIMIT', 100);
@@ -69,24 +69,22 @@
6969
* @param int $cmid Course module id
7070
*/
7171
function turnitintooltwo_add_to_log($courseid, $eventname, $link, $desc, $cmid, $userid = 0) {
72-
global $CFG, $USER;
73-
if ( ( property_exists( $CFG, 'branch' ) AND ( $CFG->branch < 27 ) ) || ( !property_exists( $CFG, 'branch' ) ) ) {
74-
add_to_log($courseid, "turnitintooltwo", $eventname, $link, $desc, $cmid);
75-
} else {
76-
$eventname = str_replace(' ', '_', $eventname);
77-
$eventpath = '\mod_turnitintooltwo\event\\'.$eventname;
78-
79-
$data = array(
80-
'objectid' => $cmid,
81-
'context' => ( $cmid == 0 ) ? context_course::instance($courseid) : context_module::instance($cmid),
82-
'other' => array('desc' => $desc)
83-
);
84-
if (!empty($userid) && ($userid != $USER->id)) {
85-
$data['relateduserid'] = $userid;
86-
}
87-
$event = $eventpath::create($data);
88-
$event->trigger();
72+
global $USER;
73+
74+
75+
$eventname = str_replace(' ', '_', $eventname);
76+
$eventpath = '\mod_turnitintooltwo\event\\'.$eventname;
77+
78+
$data = array(
79+
'objectid' => $cmid,
80+
'context' => ( $cmid == 0 ) ? context_course::instance($courseid) : context_module::instance($cmid),
81+
'other' => array('desc' => $desc)
82+
);
83+
if (!empty($userid) && ($userid != $USER->id)) {
84+
$data['relateduserid'] = $userid;
8985
}
86+
$event = $eventpath::create($data);
87+
$event->trigger();
9088
}
9189

9290
/**
@@ -115,18 +113,10 @@ function turnitintooltwo_supports($feature) {
115113
* @return int the plugin version for use within the plugin.
116114
*/
117115
function turnitintooltwo_get_version() {
118-
global $DB, $CFG;
119-
$pluginversion = '';
120-
121-
if ($CFG->branch >= 26) {
122-
$module = $DB->get_record('config_plugins', array('plugin' => 'mod_turnitintooltwo', 'name' => 'version'));
123-
$pluginversion = $module->value;
124-
} else {
125-
$module = $DB->get_record('modules', array('name' => 'turnitintooltwo'));
126-
$pluginversion = $module->version;
127-
}
116+
global $DB;
117+
$version = $DB->get_record('config_plugins', array('plugin' => 'mod_turnitintooltwo', 'name' => 'version'));
128118

129-
return $pluginversion;
119+
return $version->value;
130120
}
131121

132122
/**
@@ -351,6 +341,11 @@ function turnitintooltwo_duplicate_recycle($courseid, $action, $renewdates = nul
351341

352342
foreach ($parts as $part) {
353343
$partsarray[$courseid][$turnitintooltwo->id][$part->id]['tiiassignid'] = $part->tiiassignid;
344+
345+
if ($action == "UNTOUCHED") {
346+
$turnitintooltwoassignment = new turnitintooltwo_assignment($turnitintooltwo->id);
347+
turnitintooltwo_update_event($turnitintooltwoassignment->turnitintooltwo, $part);
348+
}
354349
}
355350

356351
/* Set legacy to 0 for all TII2s so that we can have all recreated assignments on the same TII class.
@@ -368,6 +363,11 @@ function turnitintooltwo_duplicate_recycle($courseid, $action, $renewdates = nul
368363
}
369364
}
370365

366+
// We don't want to go any further if Turnitin Assignments aren't going to be touched.
367+
if ($action == "UNTOUCHED") {
368+
return array();
369+
}
370+
371371
$currentcourse = turnitintooltwo_assignment::get_course_data($courseid);
372372
if ($action == "NEWCLASS") {
373373
// Delete Turnitin class link.
@@ -577,15 +577,20 @@ function turnitintooltwo_reset_part_update($part, $i) {
577577
* @return array The Result of the turnitintooltwo_duplicate_recycle call
578578
*/
579579
function turnitintooltwo_reset_userdata($data) {
580-
$status = array();
581-
582580
$renew_dates = isset($data->renew_assignment_dates) ? 1 : null;
583581

584-
if ($data->reset_turnitintooltwo == 0) {
585-
$status = turnitintooltwo_duplicate_recycle($data->courseid, 'NEWCLASS', $renew_dates);
586-
} else if ($data->reset_turnitintooltwo == 1) {
587-
$status = turnitintooltwo_duplicate_recycle($data->courseid, 'OLDCLASS', $renew_dates);
582+
$action = 'UNTOUCHED';
583+
switch ($data->reset_turnitintooltwo) {
584+
case 0:
585+
$action = 'NEWCLASS';
586+
break;
587+
case 1:
588+
$action = 'OLDCLASS';
589+
break;
588590
}
591+
592+
$status = turnitintooltwo_duplicate_recycle($data->courseid, $action, $renew_dates);
593+
589594
return $status;
590595
}
591596

@@ -1719,22 +1724,33 @@ function turnitintooltwo_override_repository($submitpapersto) {
17191724
*/
17201725
function mod_turnitintooltwo_core_calendar_provide_event_action(calendar_event $event,
17211726
\core_calendar\action_factory $factory) {
1727+
global $DB, $USER;
17221728
$cm = get_fast_modinfo($event->courseid)->instances['turnitintooltwo'][$event->instance];
1723-
1724-
if (!empty($cm->customdata['timeclose']) && $cm->customdata['timeclose'] < time()) {
1725-
// The assignment has closed so the user can no longer submit anything.
1726-
return null;
1727-
}
1729+
$isinstructor = (has_capability('mod/turnitintooltwo:grade', context_module::instance($cm->id)));
17281730

17291731
// Restore object from cached values in $cm, we only need id, timeclose and timeopen.
17301732
$customdata = $cm->customdata ?: [];
17311733
$customdata['id'] = $cm->instance;
17321734
$data = (object)($customdata + ['timeclose' => 0, 'timeopen' => 0]);
1735+
$assignmentpart = $DB->get_record('turnitintooltwo_parts', array('turnitintooltwoid' => $customdata['id']), 'max(dtpost)');
1736+
1737+
// Check whether the logged in user has a submission, should always be false for Instructors.
1738+
$hassubmission = false;
1739+
if (!$isinstructor) {
1740+
$queryparams = array('userid' => $USER->id, 'turnitintooltwoid' => $customdata['id']);
1741+
$hassubmission = $DB->get_records('turnitintooltwo_submissions', $queryparams);
1742+
}
1743+
1744+
if ((!empty($cm->customdata['timeclose']) && $cm->customdata['timeclose'] < time()) ||
1745+
$assignmentpart->max < time() || !empty($hassubmission)) {
1746+
// The assignment has closed so the user can no longer submit anything.
1747+
return null;
1748+
}
17331749

17341750
// Check that the activity is open.
17351751
list($actionable, $warnings) = mod_turnitintooltwo_get_availability_status($data, true, context_module::instance($cm->id));
17361752

1737-
$identifier = (has_capability('mod/turnitintooltwo:grade', context_module::instance($cm->id))) ? 'allsubmissions' : 'addsubmission';
1753+
$identifier = ($isinstructor) ? 'allsubmissions' : 'addsubmission';
17381754
return $factory->create_instance(
17391755
get_string($identifier, 'turnitintooltwo'),
17401756
new \moodle_url('/mod/turnitintooltwo/view.php', array('id' => $cm->id)),
@@ -1791,14 +1807,15 @@ function turnitintooltwo_update_event($turnitintooltwo, $part, $courseparam = fa
17911807
$dbparams[] = $turnitintooltwo->course;
17921808
}
17931809
try {
1794-
// Update event for assignment part.
1810+
// Create event data.
1811+
$updatedevent = new stdClass();
1812+
$updatedevent->userid = $USER->id;
1813+
$updatedevent->name = $turnitintooltwo->name." - ".$part->partname;
1814+
$updatedevent->timestart = $part->dtdue;
1815+
1816+
// Create/Update event for assignment part.
17951817
if ($event = $DB->get_record_select("event", $dbselect, $dbparams)) {
1796-
// Update the event.
1797-
$updatedevent = new stdClass();
17981818
$updatedevent->id = $event->id;
1799-
$updatedevent->userid = $USER->id;
1800-
$updatedevent->name = $turnitintooltwo->name." - ".$part->partname;
1801-
$updatedevent->timestart = $part->dtdue;
18021819

18031820
if ($CFG->branch >= 33) {
18041821
$updatedevent->timesort = $part->dtdue;
@@ -1811,6 +1828,9 @@ function turnitintooltwo_update_event($turnitintooltwo, $part, $courseparam = fa
18111828
}
18121829

18131830
$DB->update_record('event', $updatedevent);
1831+
} else {
1832+
$turnitintooltwoassignment = new turnitintooltwo_assignment($turnitintooltwo->id);
1833+
$turnitintooltwoassignment->create_event($turnitintooltwo->id, $part->partname, $part->dtdue);
18141834
}
18151835
} catch (Exception $e) {
18161836
turnitintooltwo_comms::handle_exceptions($e, 'turnitintooltwoupdateerror', false);

sass/partials/_inbox.scss

+12-10
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,19 @@
7373
top: -5px;
7474
}
7575

76-
.dropdown-menu .origchecked_zip_open:hover {
77-
background-color: $hover-blue;
78-
display: block;
79-
line-height: 20px;
80-
color: #fff;
81-
font-weight: normal;
82-
}
76+
.zip_downloads {
77+
.dropdown-menu .origchecked_zip_open:hover {
78+
background-color: $hover-blue;
79+
display: block;
80+
line-height: 20px;
81+
color: #fff;
82+
font-weight: normal;
83+
}
8384

84-
.dropdown-menu {
85-
white-space: nowrap;
86-
margin-top: 2px !important;
85+
.dropdown-menu {
86+
white-space: nowrap;
87+
margin-top: 2px !important;
88+
}
8789
}
8890

8991
#rubric_view_form {

settings_extras.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@
350350
$createbutton = html_writer::tag('button', get_string('createmoodlecourses', 'turnitintooltwo'),
351351
array("id" => "create_classes_button"));
352352
$output .= $OUTPUT->box($categoryselectlabel." ".$categoryselect.$createassign.$createbutton,
353-
'create_checkboxes navbar');
353+
'create_checkboxes');
354354

355355
$table = new html_table();
356356
$table->id = "courseBrowserTable";
@@ -468,7 +468,7 @@
468468
$string = ($type == "success") ? 'enablemigrationtoolsuccess' : 'enablemigrationtoolfail';
469469

470470
$close = html_writer::tag('button', '&times;', array('class' => 'close', 'data-dismiss' => 'alert'));
471-
$alert = html_writer::tag('div', $close.get_string($string, 'turnitintooltwo'),
471+
$alert = html_writer::tag('div', $close.get_string($string, 'turnitintooltwo'),
472472
array('class' => 'alert alert-'.$type, 'role' => 'alert'));
473473
}
474474

@@ -565,4 +565,4 @@
565565
}
566566

567567
echo html_writer::end_tag("div");
568-
echo $OUTPUT->footer();
568+
echo $OUTPUT->footer();

settingslib.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function validate($data) {
7878
}
7979

8080
$cleaned = clean_param($data, $this->paramtype);
81-
if ("$data" === "$cleaned" && strlen($data) == 8) { // Implicit conversion to string is needed to do exact comparison.
81+
if ("$data" === "$cleaned" && strlen($data) > 0) { // Implicit conversion to string is needed to do exact comparison.
8282
return true;
8383
} else {
8484
return get_string('validateerror', 'admin');

tests/unit/lib_test.php

+13-3
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ public function test_turnitintooltwo_availability_status() {
281281
$course = $this->getDataGenerator()->create_course();
282282

283283
$turnitintooltwoassignment = $this->make_test_tii_assignment();
284-
$cmid = $this->make_test_module($turnitintooltwoassignment->turnitintooltwo->course,'turnitintooltwo', $turnitintooltwoassignment->turnitintooltwo->id);
284+
$cmid = $this->make_test_module($turnitintooltwoassignment->turnitintooltwo->course,
285+
'turnitintooltwo', $turnitintooltwoassignment->turnitintooltwo->id);
285286
$context = context_module::instance($cmid);
286287
$cm = $DB->get_record("course_modules", array('id' => $cmid));
287288

@@ -427,7 +428,6 @@ public function test_turnitintooltwo_update_event() {
427428
$DB->update_record('event', $updatedevent);
428429

429430
// This test is only relevant to 3.3+;
430-
431431
if ($CFG->branch >= 33) {
432432
// Check that we can convert an old event to a new event.
433433
turnitintooltwo_update_event($turnitintooltwo, $part, null, true);
@@ -439,7 +439,8 @@ public function test_turnitintooltwo_update_event() {
439439
}
440440
$this->assertNotEquals(0, $response->timestart);
441441

442-
// We can check that a second call to convert an event will not update the event by resetting only the timestart value and checking it is not updated,
442+
// We can check that a second call to convert an event will not update the event by resetting only the
443+
// timestart value and checking it is not updated,
443444
$updatedevent = new stdClass();
444445
$updatedevent->id = $event->id;
445446
$updatedevent->timestart = 0;
@@ -451,5 +452,14 @@ public function test_turnitintooltwo_update_event() {
451452

452453
$this->assertEquals(0, $response->timestart);
453454
}
455+
456+
// Remove event and check that the update event method will create one if one doesn't exist.
457+
$DB->delete_records('event', array('id' => $updatedevent->id));
458+
$this->assertEquals(0, $DB->count_records('event', array('id' => $updatedevent->id)));
459+
460+
turnitintooltwo_update_event($turnitintooltwo, $part);
461+
$dbselect = " name = ? ";
462+
$dbparams = array($turnitintooltwo->name." - ".$part->partname);
463+
$this->assertEquals(1, $DB->count_records_select('event', $dbselect, $dbparams));
454464
}
455465
}

0 commit comments

Comments
 (0)