From 80d9a12b9e9709905dda626ef55e8e73107d08d4 Mon Sep 17 00:00:00 2001 From: John McGettrick Date: Wed, 8 May 2019 10:29:06 +0100 Subject: [PATCH 01/10] Don't step on .dropdown-menu global namespace (from @OdyX) --- sass/partials/_inbox.scss | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sass/partials/_inbox.scss b/sass/partials/_inbox.scss index 6267b1b3..b854ecf1 100644 --- a/sass/partials/_inbox.scss +++ b/sass/partials/_inbox.scss @@ -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 { From 926b6a926e0d999d24a79a267bb58cb1f4728cbb Mon Sep 17 00:00:00 2001 From: John McGettrick Date: Fri, 10 May 2019 15:40:03 +0100 Subject: [PATCH 02/10] Increase upload limit and add submit string for accessibility --- lib.php | 2 +- turnitintooltwo_view.class.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib.php b/lib.php index faae9eca..5153e9fc 100755 --- a/lib.php +++ b/lib.php @@ -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); diff --git a/turnitintooltwo_view.class.php b/turnitintooltwo_view.class.php index 0995a0da..b98251ca 100755 --- a/turnitintooltwo_view.class.php +++ b/turnitintooltwo_view.class.php @@ -1402,7 +1402,8 @@ public function get_submission_inbox_row($cm, $turnitintooltwoassignment, $parts $upload = html_writer::link($CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$cm->id.'&part='.$partid.'&user='. $submission->userid.'&do=submitpaper&view_context=box_solid', $uploadtext.' '. - html_writer::tag('i', '', array('class' => 'fa fa-cloud-upload fa-lg')), + html_writer::tag('i', '', array('title' => get_string('submitpaper', 'turnitintooltwo'), + 'class' => 'fa fa-cloud-upload fa-lg')), array("class" => "upload_box nowrap", "id" => "upload_".$submission->submission_objectid."_".$partid."_".$submission->userid, 'data-eula' => $eulaaccepted, 'data-user-type' => $istutor)); From a3d4849f22762df41322b515efe5a06a4ca3cfcd Mon Sep 17 00:00:00 2001 From: Charlotte Spinks Date: Thu, 6 Jun 2019 11:35:56 +0100 Subject: [PATCH 03/10] removed navbar to allow correct styling in 3.7 --- settings_extras.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/settings_extras.php b/settings_extras.php index 8b343740..ca45d0ee 100644 --- a/settings_extras.php +++ b/settings_extras.php @@ -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"; @@ -468,7 +468,7 @@ $string = ($type == "success") ? 'enablemigrationtoolsuccess' : 'enablemigrationtoolfail'; $close = html_writer::tag('button', '×', 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')); } @@ -565,4 +565,4 @@ } echo html_writer::end_tag("div"); -echo $OUTPUT->footer(); \ No newline at end of file +echo $OUTPUT->footer(); From 7f0de3651eddce5a7f428e8ff3a3e7f6fb4e2fe6 Mon Sep 17 00:00:00 2001 From: John McGettrick Date: Mon, 24 Jun 2019 14:56:49 +0100 Subject: [PATCH 04/10] Remove shared key validation --- settingslib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settingslib.php b/settingslib.php index 752a6808..e1d3d011 100644 --- a/settingslib.php +++ b/settingslib.php @@ -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'); From 1e6812a9e7af7273cabd0ce5b1111bc8f8860c75 Mon Sep 17 00:00:00 2001 From: John McGettrick Date: Mon, 24 Jun 2019 16:28:14 +0100 Subject: [PATCH 05/10] Create event if it does not exist when update has been called. --- lib.php | 16 ++++++++++------ tests/unit/lib_test.php | 16 +++++++++++++--- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/lib.php b/lib.php index 5153e9fc..35523928 100755 --- a/lib.php +++ b/lib.php @@ -1791,14 +1791,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; @@ -1811,6 +1812,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); diff --git a/tests/unit/lib_test.php b/tests/unit/lib_test.php index 32f07b44..d02ba262 100644 --- a/tests/unit/lib_test.php +++ b/tests/unit/lib_test.php @@ -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)); @@ -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); @@ -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; @@ -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)); } } From 71fc68a986e8aea77393d7d1a31088df006a30ef Mon Sep 17 00:00:00 2001 From: John McGettrick Date: Wed, 26 Jun 2019 12:35:36 +0100 Subject: [PATCH 06/10] Remove tech debt and handle untouched assignments --- lib.php | 73 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/lib.php b/lib.php index 35523928..81ab4f85 100755 --- a/lib.php +++ b/lib.php @@ -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(); } /** @@ -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; } /** @@ -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. @@ -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. @@ -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; } From 48bca7f5a618ef9610f43b7cd75d8491f30f3806 Mon Sep 17 00:00:00 2001 From: Charlotte Spinks <33542698+CharlotteSpinks@users.noreply.github.com> Date: Wed, 26 Jun 2019 15:09:02 +0100 Subject: [PATCH 07/10] refactored to html_writer to fix assignment inbox styling (#537) * refactored to html_writer to fix assignment inbox styling * indentation fixed * fixed indentation * formatting changed * fixed indentation * code review changes * code review changes * code review change * indent if block --- turnitintooltwo_view.class.php | 119 +++++++++++++++++++++------------ 1 file changed, 75 insertions(+), 44 deletions(-) diff --git a/turnitintooltwo_view.class.php b/turnitintooltwo_view.class.php index b98251ca..556b0095 100755 --- a/turnitintooltwo_view.class.php +++ b/turnitintooltwo_view.class.php @@ -1191,11 +1191,16 @@ public function get_submission_inbox_row($cm, $turnitintooltwoassignment, $parts // Submission title with link to open DV. if ( !empty($submission->submission_objectid) AND !empty($submission->submission_objectid) ) { - $title = $OUTPUT->box_start('default_open', 'default_'.$submission->submission_objectid.'_'.$partid.'_'.$moodleuserid); - $title .= $OUTPUT->box(format_string($submission->submission_title), 'submission_title underline'); - $title .= $OUTPUT->box($CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$cm->id, 'dv_url', - 'default_url_'.$submission->submission_objectid); - $title .= $OUTPUT->box_end(true); + $titleinner = html_writer::tag('div', format_string($submission->submission_title), + array('class' => 'submission_title underline')); + + $titleinner .= html_writer::tag('div', $CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$cm->id, + array('id' => 'default_url_'.$submission->submission_objectid, + 'class' => 'dv_url')); + + $title = html_writer::tag('div', $titleinner, + array('id' => 'default_'.$submission->submission_objectid.'_'.$partid.'_'.$moodleuserid, + 'class' => 'default_open')); $rawtitle = $submission->submission_title; } else { $title = "--"; @@ -1231,29 +1236,43 @@ public function get_submission_inbox_row($cm, $turnitintooltwoassignment, $parts } else if (!empty($submission->id) && !empty($submission->submission_objectid) && ($istutor || $turnitintooltwoassignment->turnitintooltwo->studentreports)) { - // Show score. + //Show score. if (is_null($submission->submission_score)) { - $score = $OUTPUT->box_start('row_score', - 'origreport_'.$submission->submission_objectid.'_'.$partid.'_'.$moodleuserid); - $score .= $OUTPUT->box(' ', 'score_colour score_colour_'); - $score .= $OUTPUT->box(get_string('pending', 'turnitintooltwo'), 'origreport_score'); - $rawscore = null; + $scoreinner = html_writer::tag('div', ' ', + array('class' => 'score_colour score_colour_')); + $scoreinner .= html_writer::tag('div', get_string('pending', 'turnitintooltwo'), + array('class' => 'origreport_score')); + } else { - $score = $OUTPUT->box_start('row_score origreport_open', - 'origreport_'.$submission->submission_objectid.'_'.$partid.'_'.$moodleuserid); // Put EN flag if translated matching is on and that is the score used. $transmatch = ($submission->submission_transmatch == 1) ? 'EN' : ' '; - $score .= $OUTPUT->box($transmatch, 'score_colour score_colour_'.round($submission->submission_score, -1)); - $score .= $OUTPUT->box($submission->submission_score.'%', 'origreport_score'); + + $scoreinner .= html_writer::tag('div', $transmatch, + array('class' => 'score_colour score_colour_'.round($submission->submission_score, -1) )); + $scoreinner .= html_writer::tag('div', $submission->submission_score.'%', + array('class' => 'origreport_score')); $rawscore = $submission->submission_score; } // Put in div placeholder for DV launch form. - $score .= $OUTPUT->box('', 'launch_form', 'origreport_form_'.$submission->submission_objectid); + $scoreinner .= html_writer::tag('div', '', + array('id' => 'origreport_form_'.$submission->submission_objectid, + 'class' => 'launch_form')); // URL for DV launcher. - $score .= $OUTPUT->box($CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$cm->id, 'dv_url', - 'origreport_url_'.$submission->submission_objectid); - $score .= $OUTPUT->box_end(true); + $scoreinner .= html_writer::tag('div', $CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$cm->id, + array('id' => 'origreport_url_'.$submission->submission_objectid, + 'class' => 'dv_url')); + + if (is_null($submission->submission_score)) { + $score = html_writer::tag('div', $scoreinner, + array('id' => 'origreport_'.$submission->submission_objectid.'_'.$partid.'_'.$moodleuserid, + 'class' => 'row_score')); + } else { + $score = html_writer::tag('div', $scoreinner, + array('id' => 'origreport_'.$submission->submission_objectid.'_'.$partid.'_'.$moodleuserid, + 'class' => 'row_score origreport_open')); + } + } else { $rawscore = null; $score = '--'; @@ -1281,39 +1300,46 @@ public function get_submission_inbox_row($cm, $turnitintooltwoassignment, $parts // Output grademark icon. $grade = ''; if (!is_null($submission->submission_grade) || $submission->submission_gmimaged != 0 || $istutor) { - $grade = $OUTPUT->box( - html_writer::tag('i', '', array('title' => get_string('submissiongrade', 'turnitintooltwo'), - 'class' => 'fa fa-pencil fa-lg gm-blue')), 'grademark_open ' . $class, - 'grademark_' . $submission->submission_objectid . '_' . $partid . '_' . $moodleuserid, - array('title' => $CFG->wwwroot . '/mod/turnitintooltwo/view.php?id=' . $cm->id) - ); + + $submissiongradeicon = html_writer::tag('i', '', + array('title' => get_string('submissiongrade', 'turnitintooltwo'), + 'class' => 'fa fa-pencil fa-lg gm-blue')); + + $grade = html_writer::tag('div', $submissiongradeicon, + array('id' => 'grademark_' . $submission->submission_objectid . '_' . $partid . '_' . $moodleuserid, + 'class' => 'grademark_open ' . $class, + 'title' => $CFG->wwwroot . '/mod/turnitintooltwo/view.php?id=' . $cm->id)); } // Show grade. if ($turnitintooltwoassignment->turnitintooltwo->gradedisplay == 2) { // 2 is fraction. - $grade .= $OUTPUT->box(html_writer::tag('span', $submissiongrade, array("class" => "grade")) - ."/".$parts[$partid]->maxmarks, 'grademark_grade'); + $grade .= html_writer::tag('span', $submissiongrade, array("class" => "grade")) + .html_writer::tag('span', "/".$parts[$partid]->maxmarks, + array("class" => "grademark_grade")); } else if ($turnitintooltwoassignment->turnitintooltwo->gradedisplay == 1) { // 1 is percentage. $submissiongrade = round($submissiongrade / $parts[$partid]->maxmarks * 100, 1).'%'; - $grade .= $OUTPUT->box(html_writer::tag('span', $submissiongrade, array("class" => "grade")) - , 'grademark_grade'); + $grade .= html_writer::tag('span', $submissiongrade, + array('class' => 'grade grademark_grade')); } // Put in div placeholder for DV launch form. - $grade .= $OUTPUT->box('', 'launch_form', 'grademark_form_'.$submission->submission_objectid); + $grade .= html_writer::tag('div', '', + array('id' => 'grademark_form_'.$submission->submission_objectid, + 'class' => 'launch_form')); // URL for DV launcher. - $grade .= $OUTPUT->box($CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$cm->id, 'dv_url', - 'grademark_url_'.$submission->submission_objectid); + $grade .= html_writer::tag('div', $CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$cm->id, + array('id' => 'grademark_url_'.$submission->submission_objectid, + 'class' => 'dv_url')); + $rawgrade = ($submissiongrade == "--") ? null : $submissiongrade; } else if (!isset($submission->submission_objectid) && empty($submission->id) && $istutor ) { // Allow nothing submission if no submission has been made and this is a tutor. - $grade = $OUTPUT->box( - html_writer::tag('i', '', array('class' => 'fa fa-pencil fa-lg grey')), - 'submit_nothing', - 'submitnothing_0_' . $partid . '_' . $submission->userid - ); + $greysubmissiongradeicon = html_writer::tag('i', '', array('class' => 'fa fa-pencil fa-lg grey')); + $grade = html_writer::tag('div', $greysubmissiongradeicon, + array('id' => $partid . '_' . $submission->userid, + 'class' =>'submit_nothing','submitnothing_0_' )); $rawgrade = null; } else { $rawgrade = null; @@ -1418,13 +1444,18 @@ public function get_submission_inbox_row($cm, $turnitintooltwoassignment, $parts // Download submission in original format. if (!empty($submission->submission_objectid) && !empty($submission->id) && !$submission->submission_acceptnothing) { - $download = $OUTPUT->box( - html_writer::tag('i', '', array('title' => get_string('downloadsubmission', 'turnitintooltwo'), - 'class' => 'fa fa-download fa-lg')), - 'download_original_open', - 'downloadoriginal_' . $submission->submission_objectid . "_" . $partid . "_" . $moodleuserid - ); - $download .= $OUTPUT->box('', 'launch_form', 'downloadoriginal_form_'.$submission->submission_objectid); + + $downloadicon = html_writer::tag('i', '', + array('title' => get_string('downloadsubmission', 'turnitintooltwo'), + 'class' => 'fa fa-download fa-lg')); + + $download = html_writer::tag('div', $downloadicon, + array('id' => 'downloadoriginal_' . $submission->submission_objectid . "_" . $partid . "_" . $moodleuserid, + 'class'=> 'download_original_open')); + + $download .= html_writer::tag('div', '', + array('id' => 'downloadoriginal_form_'.$submission->submission_objectid, + 'class' => 'launch_form')); // Add in LTI launch form incase Javascript is disabled. if (!$istutor) { From 2a354fd75625949b735ae0c5443a581c06a3f0a4 Mon Sep 17 00:00:00 2001 From: Charlotte Spinks Date: Thu, 27 Jun 2019 11:13:36 +0100 Subject: [PATCH 08/10] nothing submissions refactored and last two boxes refactored --- turnitintooltwo_view.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/turnitintooltwo_view.class.php b/turnitintooltwo_view.class.php index 556b0095..baa61eb2 100755 --- a/turnitintooltwo_view.class.php +++ b/turnitintooltwo_view.class.php @@ -1283,7 +1283,7 @@ public function get_submission_inbox_row($cm, $turnitintooltwoassignment, $parts if ($turnitintooltwoassignment->turnitintooltwo->grade == 0) { // We set the grade column to N/A if there is no grade type set. $rawgrade = null; - $grade = $OUTPUT->box('N/A', ''); + $grade = html_writer::tag('div', 'N/A', array()); } else if (isset($submission->submission_objectid) && ($istutor || (!$istutor && $parts[$partid]->dtpost < time()))) { $submissiongrade = (!is_null($submission->submission_grade)) ? $submission->submission_grade : ''; @@ -1338,12 +1338,12 @@ public function get_submission_inbox_row($cm, $turnitintooltwoassignment, $parts $greysubmissiongradeicon = html_writer::tag('i', '', array('class' => 'fa fa-pencil fa-lg grey')); $grade = html_writer::tag('div', $greysubmissiongradeicon, - array('id' => $partid . '_' . $submission->userid, - 'class' =>'submit_nothing','submitnothing_0_' )); + array('id' => 'submitnothing_0_'.$partid . '_' . $submission->userid, + 'class' =>'submit_nothing')); $rawgrade = null; } else { $rawgrade = null; - $grade = $OUTPUT->box('--', ''); + $grade = html_writer::tag('div', '--', array()); } // Show average grade if more than 1 part or using a scale. From c4d7c4750bed5bdaa478e17da90580609986da22 Mon Sep 17 00:00:00 2001 From: Charlotte Spinks Date: Tue, 2 Jul 2019 10:23:52 +0100 Subject: [PATCH 09/10] changed logic to check post date or submissions --- lib.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib.php b/lib.php index 81ab4f85..8e35b01f 100755 --- a/lib.php +++ b/lib.php @@ -1724,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)), From 90de89b87eb43a85c24e6190853d2b18d7b5a26f Mon Sep 17 00:00:00 2001 From: David Winn Date: Tue, 2 Jul 2019 17:20:35 +0100 Subject: [PATCH 10/10] Release v2019070201 --- CHANGELOG.md | 27 +++++++++++++++++++++++++++ version.php | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f856690..a73d1ce3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/version.php b/version.php index 9b9951bc..0bad7974 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ $plugin = new StdClass(); } -$plugin->version = 2019050101; +$plugin->version = 2019070201; $plugin->release = "3.1+"; $plugin->requires = 2016052300; $plugin->component = 'mod_turnitintooltwo';