Skip to content

Commit

Permalink
Merge pull request #543 from turnitin/develop
Browse files Browse the repository at this point in the history
Release v2019070201
  • Loading branch information
dwinn authored Jul 2, 2019
2 parents 06523a9 + e5d06c6 commit 7a38ce0
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 112 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
### Date: 2019-Jul-02
### Release: v2019070201

#### :zap: What's new

---

#### Moodle 3.7 support and course overview bug fixes

We've been working on supporting Moodle 3.7 and improving the course overview area.

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.

#### :wrench: Fixes and enhancements

---

#### Moodle timeline bug resolved

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.

#### Overdue messaging bug resolved

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.

---

### Date: 2019-May-01
### Release: v2019050101

Expand Down
114 changes: 67 additions & 47 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
require_once($CFG->libdir . "/gradelib.php");

// Constants.
define('TURNITINTOOLTWO_MAX_FILE_UPLOAD_SIZE', 41943040);
define('TURNITINTOOLTWO_MAX_FILE_UPLOAD_SIZE', 104857600);
define('TURNITINTOOLTWO_DEFAULT_PSEUDO_DOMAIN', '@tiimoodle.com');
define('TURNITINTOOLTWO_DEFAULT_PSEUDO_FIRSTNAME', get_string('defaultcoursestudent'));
define('TURNITINTOOLTWO_SUBMISSION_GET_LIMIT', 100);
Expand Down Expand Up @@ -69,24 +69,22 @@
* @param int $cmid Course module id
*/
function turnitintooltwo_add_to_log($courseid, $eventname, $link, $desc, $cmid, $userid = 0) {
global $CFG, $USER;
if ( ( property_exists( $CFG, 'branch' ) AND ( $CFG->branch < 27 ) ) || ( !property_exists( $CFG, 'branch' ) ) ) {
add_to_log($courseid, "turnitintooltwo", $eventname, $link, $desc, $cmid);
} else {
$eventname = str_replace(' ', '_', $eventname);
$eventpath = '\mod_turnitintooltwo\event\\'.$eventname;

$data = array(
'objectid' => $cmid,
'context' => ( $cmid == 0 ) ? context_course::instance($courseid) : context_module::instance($cmid),
'other' => array('desc' => $desc)
);
if (!empty($userid) && ($userid != $USER->id)) {
$data['relateduserid'] = $userid;
}
$event = $eventpath::create($data);
$event->trigger();
global $USER;


$eventname = str_replace(' ', '_', $eventname);
$eventpath = '\mod_turnitintooltwo\event\\'.$eventname;

$data = array(
'objectid' => $cmid,
'context' => ( $cmid == 0 ) ? context_course::instance($courseid) : context_module::instance($cmid),
'other' => array('desc' => $desc)
);
if (!empty($userid) && ($userid != $USER->id)) {
$data['relateduserid'] = $userid;
}
$event = $eventpath::create($data);
$event->trigger();
}

/**
Expand Down Expand Up @@ -115,18 +113,10 @@ function turnitintooltwo_supports($feature) {
* @return int the plugin version for use within the plugin.
*/
function turnitintooltwo_get_version() {
global $DB, $CFG;
$pluginversion = '';

if ($CFG->branch >= 26) {
$module = $DB->get_record('config_plugins', array('plugin' => 'mod_turnitintooltwo', 'name' => 'version'));
$pluginversion = $module->value;
} else {
$module = $DB->get_record('modules', array('name' => 'turnitintooltwo'));
$pluginversion = $module->version;
}
global $DB;
$version = $DB->get_record('config_plugins', array('plugin' => 'mod_turnitintooltwo', 'name' => 'version'));

return $pluginversion;
return $version->value;
}

/**
Expand Down Expand Up @@ -351,6 +341,11 @@ function turnitintooltwo_duplicate_recycle($courseid, $action, $renewdates = nul

foreach ($parts as $part) {
$partsarray[$courseid][$turnitintooltwo->id][$part->id]['tiiassignid'] = $part->tiiassignid;

if ($action == "UNTOUCHED") {
$turnitintooltwoassignment = new turnitintooltwo_assignment($turnitintooltwo->id);
turnitintooltwo_update_event($turnitintooltwoassignment->turnitintooltwo, $part);
}
}

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

// We don't want to go any further if Turnitin Assignments aren't going to be touched.
if ($action == "UNTOUCHED") {
return array();
}

$currentcourse = turnitintooltwo_assignment::get_course_data($courseid);
if ($action == "NEWCLASS") {
// Delete Turnitin class link.
Expand Down Expand Up @@ -577,15 +577,20 @@ function turnitintooltwo_reset_part_update($part, $i) {
* @return array The Result of the turnitintooltwo_duplicate_recycle call
*/
function turnitintooltwo_reset_userdata($data) {
$status = array();

$renew_dates = isset($data->renew_assignment_dates) ? 1 : null;

if ($data->reset_turnitintooltwo == 0) {
$status = turnitintooltwo_duplicate_recycle($data->courseid, 'NEWCLASS', $renew_dates);
} else if ($data->reset_turnitintooltwo == 1) {
$status = turnitintooltwo_duplicate_recycle($data->courseid, 'OLDCLASS', $renew_dates);
$action = 'UNTOUCHED';
switch ($data->reset_turnitintooltwo) {
case 0:
$action = 'NEWCLASS';
break;
case 1:
$action = 'OLDCLASS';
break;
}

$status = turnitintooltwo_duplicate_recycle($data->courseid, $action, $renew_dates);

return $status;
}

Expand Down Expand Up @@ -1719,22 +1724,33 @@ function turnitintooltwo_override_repository($submitpapersto) {
*/
function mod_turnitintooltwo_core_calendar_provide_event_action(calendar_event $event,
\core_calendar\action_factory $factory) {
global $DB, $USER;
$cm = get_fast_modinfo($event->courseid)->instances['turnitintooltwo'][$event->instance];

if (!empty($cm->customdata['timeclose']) && $cm->customdata['timeclose'] < time()) {
// The assignment has closed so the user can no longer submit anything.
return null;
}
$isinstructor = (has_capability('mod/turnitintooltwo:grade', context_module::instance($cm->id)));

// Restore object from cached values in $cm, we only need id, timeclose and timeopen.
$customdata = $cm->customdata ?: [];
$customdata['id'] = $cm->instance;
$data = (object)($customdata + ['timeclose' => 0, 'timeopen' => 0]);
$assignmentpart = $DB->get_record('turnitintooltwo_parts', array('turnitintooltwoid' => $customdata['id']), 'max(dtpost)');

// Check whether the logged in user has a submission, should always be false for Instructors.
$hassubmission = false;
if (!$isinstructor) {
$queryparams = array('userid' => $USER->id, 'turnitintooltwoid' => $customdata['id']);
$hassubmission = $DB->get_records('turnitintooltwo_submissions', $queryparams);
}

if ((!empty($cm->customdata['timeclose']) && $cm->customdata['timeclose'] < time()) ||
$assignmentpart->max < time() || !empty($hassubmission)) {
// The assignment has closed so the user can no longer submit anything.
return null;
}

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

$identifier = (has_capability('mod/turnitintooltwo:grade', context_module::instance($cm->id))) ? 'allsubmissions' : 'addsubmission';
$identifier = ($isinstructor) ? 'allsubmissions' : 'addsubmission';
return $factory->create_instance(
get_string($identifier, 'turnitintooltwo'),
new \moodle_url('/mod/turnitintooltwo/view.php', array('id' => $cm->id)),
Expand Down Expand Up @@ -1791,14 +1807,15 @@ function turnitintooltwo_update_event($turnitintooltwo, $part, $courseparam = fa
$dbparams[] = $turnitintooltwo->course;
}
try {
// Update event for assignment part.
// Create event data.
$updatedevent = new stdClass();
$updatedevent->userid = $USER->id;
$updatedevent->name = $turnitintooltwo->name." - ".$part->partname;
$updatedevent->timestart = $part->dtdue;

// Create/Update event for assignment part.
if ($event = $DB->get_record_select("event", $dbselect, $dbparams)) {
// Update the event.
$updatedevent = new stdClass();
$updatedevent->id = $event->id;
$updatedevent->userid = $USER->id;
$updatedevent->name = $turnitintooltwo->name." - ".$part->partname;
$updatedevent->timestart = $part->dtdue;

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

$DB->update_record('event', $updatedevent);
} else {
$turnitintooltwoassignment = new turnitintooltwo_assignment($turnitintooltwo->id);
$turnitintooltwoassignment->create_event($turnitintooltwo->id, $part->partname, $part->dtdue);
}
} catch (Exception $e) {
turnitintooltwo_comms::handle_exceptions($e, 'turnitintooltwoupdateerror', false);
Expand Down
22 changes: 12 additions & 10 deletions sass/partials/_inbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,19 @@
top: -5px;
}

.dropdown-menu .origchecked_zip_open:hover {
background-color: $hover-blue;
display: block;
line-height: 20px;
color: #fff;
font-weight: normal;
}
.zip_downloads {
.dropdown-menu .origchecked_zip_open:hover {
background-color: $hover-blue;
display: block;
line-height: 20px;
color: #fff;
font-weight: normal;
}

.dropdown-menu {
white-space: nowrap;
margin-top: 2px !important;
.dropdown-menu {
white-space: nowrap;
margin-top: 2px !important;
}
}

#rubric_view_form {
Expand Down
6 changes: 3 additions & 3 deletions settings_extras.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@
$createbutton = html_writer::tag('button', get_string('createmoodlecourses', 'turnitintooltwo'),
array("id" => "create_classes_button"));
$output .= $OUTPUT->box($categoryselectlabel." ".$categoryselect.$createassign.$createbutton,
'create_checkboxes navbar');
'create_checkboxes');

$table = new html_table();
$table->id = "courseBrowserTable";
Expand Down Expand Up @@ -468,7 +468,7 @@
$string = ($type == "success") ? 'enablemigrationtoolsuccess' : 'enablemigrationtoolfail';

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

Expand Down Expand Up @@ -565,4 +565,4 @@
}

echo html_writer::end_tag("div");
echo $OUTPUT->footer();
echo $OUTPUT->footer();
2 changes: 1 addition & 1 deletion settingslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function validate($data) {
}

$cleaned = clean_param($data, $this->paramtype);
if ("$data" === "$cleaned" && strlen($data) == 8) { // Implicit conversion to string is needed to do exact comparison.
if ("$data" === "$cleaned" && strlen($data) > 0) { // Implicit conversion to string is needed to do exact comparison.
return true;
} else {
return get_string('validateerror', 'admin');
Expand Down
16 changes: 13 additions & 3 deletions tests/unit/lib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ public function test_turnitintooltwo_availability_status() {
$course = $this->getDataGenerator()->create_course();

$turnitintooltwoassignment = $this->make_test_tii_assignment();
$cmid = $this->make_test_module($turnitintooltwoassignment->turnitintooltwo->course,'turnitintooltwo', $turnitintooltwoassignment->turnitintooltwo->id);
$cmid = $this->make_test_module($turnitintooltwoassignment->turnitintooltwo->course,
'turnitintooltwo', $turnitintooltwoassignment->turnitintooltwo->id);
$context = context_module::instance($cmid);
$cm = $DB->get_record("course_modules", array('id' => $cmid));

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

// This test is only relevant to 3.3+;

if ($CFG->branch >= 33) {
// Check that we can convert an old event to a new event.
turnitintooltwo_update_event($turnitintooltwo, $part, null, true);
Expand All @@ -439,7 +439,8 @@ public function test_turnitintooltwo_update_event() {
}
$this->assertNotEquals(0, $response->timestart);

// 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,
// 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,
$updatedevent = new stdClass();
$updatedevent->id = $event->id;
$updatedevent->timestart = 0;
Expand All @@ -451,5 +452,14 @@ public function test_turnitintooltwo_update_event() {

$this->assertEquals(0, $response->timestart);
}

// Remove event and check that the update event method will create one if one doesn't exist.
$DB->delete_records('event', array('id' => $updatedevent->id));
$this->assertEquals(0, $DB->count_records('event', array('id' => $updatedevent->id)));

turnitintooltwo_update_event($turnitintooltwo, $part);
$dbselect = " name = ? ";
$dbparams = array($turnitintooltwo->name." - ".$part->partname);
$this->assertEquals(1, $DB->count_records_select('event', $dbselect, $dbparams));
}
}
Loading

0 comments on commit 7a38ce0

Please sign in to comment.