Skip to content

Commit b5e4c81

Browse files
authoredSep 14, 2016
Merge pull request #209 from turnitin/develop
Release 2016091401
2 parents 838260d + 33f9146 commit b5e4c81

8 files changed

+81
-71
lines changed
 

‎CHANGELOG.md

+32-16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
### Date: 2016-September-14
2+
### Release: v2016091401
3+
4+
5+
- Remove leftover counter variable from get_submission_inbox function.
6+
- Refactored the get users functionality in several places to not include users with roles inherited from site level.
7+
- Fixes:
8+
- Add missing string to email non submitters.
9+
- Check $CFG exists before using in version.php (Thanks to @micaherne).
10+
- Assignments starting more than a year ago can now be restored without user info.
11+
- Check for GradeMark feedback changes when saving submission.
12+
- Only show GradeMark launch to student if the paper has feedback or grade.
13+
- Slight tweak to overall grade to show overall grade on normal assignments.
14+
15+
---
16+
117
### Date: 2016-July-26
218
### Release: v2016072601
319

@@ -383,8 +399,8 @@ Releases before version 2015040106 will refer to changes made to the Turnitin's
383399

384400
---
385401

386-
###Date: 2014-September-04
387-
###Release: v2014012407
402+
### Date: 2014-September-04
403+
### Release: v2014012407
388404

389405
- Remove Grademark settings if GradeMark is disabled. (Thanks to Alex Rowe)
390406
- Date handling reconfigured in PP to prevent erros (Thanks to Dan Marsden)
@@ -398,8 +414,8 @@ Releases before version 2015040106 will refer to changes made to the Turnitin's
398414

399415
---
400416

401-
###Date: 2014-August-19
402-
###Release: v2014012406
417+
### Date: 2014-August-19
418+
### Release: v2014012406
403419

404420
- Error reporting added for files that are too large, small submissions and any other submission errors.
405421
- Error reporting added to cron.
@@ -419,8 +435,8 @@ Releases before version 2015040106 will refer to changes made to the Turnitin's
419435

420436
---
421437

422-
###Date: 2014-June-11
423-
###Release: v2014012405
438+
### Date: 2014-June-11
439+
### Release: v2014012405
424440

425441
- Course reset functionality added to remove Turnitin data when a class/module is reset.
426442
- Ability added to enable/disable Turnitin in individual modules.
@@ -467,15 +483,15 @@ Releases before version 2015040106 will refer to changes made to the Turnitin's
467483

468484
---
469485

470-
###Date: 2014-June-11
471-
###Release: v2014012404
486+
### Date: 2014-June-11
487+
### Release: v2014012404
472488

473489
- EULA acceptance is now stored locally for submissions.
474490

475491
---
476492

477-
###Date: 2014-April-17
478-
###Release: v2014012403
493+
### Date: 2014-April-17
494+
### Release: v2014012403
479495

480496
- Grademark link removed for student if a grade has not been set in Plagiarism Plugin.
481497
- Feedback release date changed on forum with plagiarism plugin to be the same as start date.
@@ -492,8 +508,8 @@ Releases before version 2015040106 will refer to changes made to the Turnitin's
492508

493509
---
494510

495-
###Date: 2014-February-26
496-
###Release: v2014012402
511+
### Date: 2014-February-26
512+
### Release: v2014012402
497513

498514
- Vietnamese Language pack added.
499515
- Option to send draft submissions to Turnitin in Plagiarism Plugin reinstated.
@@ -516,8 +532,8 @@ Releases before version 2015040106 will refer to changes made to the Turnitin's
516532

517533
---
518534

519-
###Date: 2014-January-24
520-
###Release: v2014012401
535+
### Date: 2014-January-24
536+
### Release: v2014012401
521537

522538
- File type limit removed.
523539
- Ability to accept no file added so that marks / grades can be allocated to non file submissions
@@ -527,8 +543,8 @@ Releases before version 2015040106 will refer to changes made to the Turnitin's
527543

528544
---
529545

530-
###Date: 2013-December-18
531-
###Release: v2013121801
546+
### Date: 2013-December-18
547+
### Release: v2013121801
532548

533549
- Supports Turnitin Originality Checking, GradeMark and PeerMark
534550
- Allows access to the Rubric Manager and Quickmark Manager from within the Moodle environment

‎backup/moodle2/restore_turnitintooltwo_activity_task.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function after_restore() {
122122
foreach($_SESSION["assignments_to_create"] as $new_assignment_id) {
123123
$assignment = new turnitintooltwo_assignment($new_assignment_id);
124124
$assignment->unlink_assignment();
125-
$assignment->edit_moodle_assignment();
125+
$assignment->edit_moodle_assignment(true, true);
126126
}
127127
unset($_SESSION['tii_assignment_reset']);
128128
unset($_SESSION['assignments_to_create']);

‎lib.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,8 @@ function turnitintooltwo_cron_update_gradbook($assignment, $task) {
610610
$turnitintooltwoassignment->turnitintooltwo->course);
611611

612612
if ($cm) {
613-
$users = $turnitintooltwoassignment->get_moodle_course_users($cm);
613+
$users = get_enrolled_users(context_module::instance($cm->id),
614+
'mod/turnitintooltwo:submit', groups_get_activity_group($cm), 'u.id');
614615

615616
foreach ($users as $user) {
616617
$fieldList = array('turnitintooltwoid' => $turnitintooltwoassignment->turnitintooltwo->id,
@@ -1361,7 +1362,6 @@ function turnitintooltwo_print_overview($courses, &$htmlarray) {
13611362
$partsarray = array();
13621363
$grader = has_capability('mod/turnitintooltwo:grade', $context);
13631364
if ($grader) {
1364-
$allusers = get_users_by_capability($context, 'mod/turnitintooltwo:submit', 'u.id', '', '', '', 0, '', false);
13651365
$submissionsquery = $DB->get_records_select('turnitintooltwo_submissions',
13661366
'turnitintooltwoid = ? GROUP BY id, submission_part, submission_grade, submission_gmimaged',
13671367
array($turnitintooltwo->id), '', 'id, submission_part, submission_grade, submission_gmimaged');
@@ -1392,7 +1392,7 @@ function turnitintooltwo_print_overview($courses, &$htmlarray) {
13921392
$input = new stdClass();
13931393
$input->submitted = $numsubmissions;
13941394
$input->graded = $graded;
1395-
$input->total = count($allusers);
1395+
$input->total = count_enrolled_users($context, 'mod/turnitintooltwo:submit', 0);
13961396
$input->gplural = ($graded != 1) ? 's' : '';
13971397
$partsarray[$part->id]['status'] = get_string('tutorstatus', 'turnitintooltwo', $input);
13981398
} else {

‎turnitintooltwo_assignment.class.php

+22-29
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,10 @@ public function enrol_all_students($cm) {
576576
$course = $this->get_course_data($this->turnitintooltwo->course);
577577

578578
// Get local course members.
579-
$moodleclassmembers = $this->get_moodle_course_users($cm);
579+
$students = get_enrolled_users(context_module::instance($cm->id),
580+
'mod/turnitintooltwo:submit', groups_get_activity_group($cm), 'u.id');
580581

581-
// Get the user ids of who is already enrolled and remove them
582-
// from the local course members array.
582+
// Get the user ids of who is already enrolled and remove them from the students array.
583583
$tiiclassmemberships = $this->get_class_memberships($course->turnitin_cid);
584584
$turnitincomms = new turnitintooltwo_comms();
585585
$turnitincall = $turnitincomms->initialise_api();
@@ -593,15 +593,15 @@ public function enrol_all_students($cm) {
593593
foreach ($readmemberships as $readmembership) {
594594
if ($readmembership->getRole() == "Learner") {
595595
$moodleuserid = turnitintooltwo_user::get_moodle_user_id($readmembership->getUserId());
596-
unset($moodleclassmembers[$moodleuserid]);
596+
unset($students[$moodleuserid]);
597597
}
598598
}
599599
} catch (Exception $e) {
600600
$turnitincomms->handle_exceptions($e, 'membercheckerror');
601601
}
602602

603603
// Enrol remaining unenrolled users to the course.
604-
$members = array_keys($moodleclassmembers);
604+
$members = array_keys($students);
605605
foreach ($members as $member) {
606606
$user = new turnitintooltwo_user($member, "Learner");
607607
$user->join_user_to_class($course->turnitin_cid);
@@ -1110,7 +1110,7 @@ public function edit_part_field($partid, $fieldname, $fieldvalue) {
11101110
switch ($fieldname) {
11111111
case "partname":
11121112
$fieldvalue = trim($fieldvalue);
1113-
$partnames = $DB->get_records_select('turnitintooltwo_parts',
1113+
$partnames = $DB->get_records_select('turnitintooltwo_parts',
11141114
' turnitintooltwoid = ? AND id != ? ',
11151115
array($partdetails->turnitintooltwoid, $partid), '', 'partname');
11161116

@@ -1251,7 +1251,7 @@ public function edit_part_field($partid, $fieldname, $fieldvalue) {
12511251
* @param boolean $createevent - setting to determine whether to create a calendar event.
12521252
* @return boolean
12531253
*/
1254-
public function edit_moodle_assignment($createevent = true) {
1254+
public function edit_moodle_assignment($createevent = true, $restore = false) {
12551255
global $USER, $DB, $CFG;
12561256

12571257
$config = turnitintooltwo_admin_config();
@@ -1346,11 +1346,17 @@ public function edit_moodle_assignment($createevent = true) {
13461346
$this->turnitintooltwo->erater_handbook : 0);
13471347

13481348
$attribute = "dtstart".$i;
1349-
$assignment->setStartDate(gmdate("Y-m-d\TH:i:s\Z", $this->turnitintooltwo->$attribute));
1350-
$attribute = "dtdue".$i;
1351-
$assignment->setDueDate(gmdate("Y-m-d\TH:i:s\Z", $this->turnitintooltwo->$attribute));
1352-
$attribute = "dtpost".$i;
1353-
$assignment->setFeedbackReleaseDate(gmdate("Y-m-d\TH:i:s\Z", $this->turnitintooltwo->$attribute));
1349+
if (($restore) && ($this->turnitintooltwo->$attribute < strtotime("-1 year"))) {
1350+
$assignment->setStartDate(gmdate("Y-m-d\TH:i:s\Z", time()));
1351+
$assignment->setDueDate(gmdate("Y-m-d\TH:i:s\Z", strtotime("+1 week")));
1352+
$assignment->setFeedbackReleaseDate(gmdate("Y-m-d\TH:i:s\Z", strtotime("+1 week")));
1353+
} else {
1354+
$assignment->setStartDate(gmdate("Y-m-d\TH:i:s\Z", $this->turnitintooltwo->$attribute));
1355+
$attribute = "dtdue".$i;
1356+
$assignment->setDueDate(gmdate("Y-m-d\TH:i:s\Z", $this->turnitintooltwo->$attribute));
1357+
$attribute = "dtpost".$i;
1358+
$assignment->setFeedbackReleaseDate(gmdate("Y-m-d\TH:i:s\Z", $this->turnitintooltwo->$attribute));
1359+
}
13541360

13551361
$attribute = "partname".$i;
13561362
$assignment->setTitle($this->turnitintooltwo->name." ".$this->turnitintooltwo->$attribute." (Moodle TT)");
@@ -1458,19 +1464,6 @@ public function edit_moodle_assignment($createevent = true) {
14581464
return $update;
14591465
}
14601466

1461-
/**
1462-
* Get the Moodle users who are students
1463-
*
1464-
* @param object $cm the course module
1465-
* @return array of course users or empty array if none
1466-
*/
1467-
public function get_moodle_course_users($cm) {
1468-
$courseusers = get_users_by_capability(context_module::instance($cm->id),
1469-
'mod/turnitintooltwo:submit', '', 'u.lastname, u.firstname');
1470-
1471-
return (!is_array($courseusers)) ? array() : $courseusers;
1472-
}
1473-
14741467
/**
14751468
* Return an array with the parts still available to be submitted to
14761469
*
@@ -1869,13 +1862,13 @@ public function get_submissions($cm, $partid = 0, $userid = 0, $submissionsonly
18691862
$istutor = has_capability('mod/turnitintooltwo:grade', $context);
18701863

18711864
// If logged in as instructor then get for all users.
1865+
$allnamefields = get_all_user_name_fields();
18721866
if ($istutor && $userid == 0) {
1873-
$allnames = get_all_user_name_fields();
1874-
$users = get_users_by_capability($context, 'mod/turnitintooltwo:submit', 'u.id, ' . implode($allnames, ', '),
1875-
'', '', '', groups_get_activity_group($cm), '');
1867+
$users = get_enrolled_users($context, 'mod/turnitintooltwo:submit', groups_get_activity_group($cm),
1868+
'u.id, ' . implode($allnamefields, ', '));
18761869
$users = (!$users) ? array() : $users;
18771870
} else if ($istutor) {
1878-
$user = $DB->get_record('user', array('id' => $userid));
1871+
$user = $DB->get_record('user', array('id' => $userid), 'id, ' . implode($allnamefields, ', '));
18791872
$users = array($userid => $user);
18801873
$sql .= " AND userid = ? ";
18811874
$sqlparams[] = $userid;

‎turnitintooltwo_submission.class.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ private function get_submission_details($idtype = "moodle", $turnitintooltwoassi
187187
}
188188

189189
if ($submission->userid > 0) {
190-
$user = $DB->get_record('user', array('id' => $submission->userid), 'firstname, lastname');
190+
$allnamefields = get_all_user_name_fields();
191+
$user = $DB->get_record('user', array('id' => $submission->userid), 'id, '.implode($allnamefields, ', '));
191192
$this->firstname = $user->firstname;
192193
$this->lastname = $user->lastname;
193194
$this->fullname = fullname($user);
@@ -625,7 +626,7 @@ public function do_tii_submission($cm, $turnitintooltwoassignment) {
625626
$this->receipt->send_message($this->userid, $message);
626627

627628
// Instructor digital receipt
628-
$this->submission_instructors = get_enrolled_users($context,'mod/turnitintooltwo:grade', 0, 'u.id');
629+
$this->submission_instructors = get_enrolled_users($context, 'mod/turnitintooltwo:grade', 0, 'u.id');
629630
if(!empty($this->submission_instructors)){
630631
$message = $this->instructor_receipt->build_instructor_message($input);
631632
$this->instructor_receipt->send_instructor_message($this->submission_instructors, $message);
@@ -737,7 +738,8 @@ public function save_updated_submission_data($tiisubmissiondata, $bulk = false,
737738
// If save not passed in then only update if certain items have changed to save on database load.
738739
if ($this->submission_grade != $sub->submission_grade || $this->submission_score != $sub->submission_score ||
739740
$this->submission_modified != $sub->submission_modified || $this->submission_attempts != $sub->submission_attempts ||
740-
$this->submission_unanon != $sub->submission_unanon || $this->submission_part != $sub->submission_part) {
741+
$this->submission_unanon != $sub->submission_unanon || $this->submission_part != $sub->submission_part ||
742+
$this->submission_gmimaged != $sub->submission_gmimaged) {
741743
$save = true;
742744
}
743745

‎turnitintooltwo_view.class.php

+12-11
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ public function get_submission_inbox_row($cm, $turnitintooltwoassignment, $parts
10911091
if ($parts[$v]->dtpost > time()) {
10921092
$display_overall_grade = 0;
10931093
}
1094-
if ($parts[$v]->unanon != 1 && $all_parts_unanonymised) {
1094+
if ($turnitintooltwoassignment->turnitintooltwo->anon && $parts[$v]->unanon != 1 && $all_parts_unanonymised) {
10951095
$all_parts_unanonymised = 0;
10961096
}
10971097
}
@@ -1252,11 +1252,14 @@ public function get_submission_inbox_row($cm, $turnitintooltwoassignment, $parts
12521252
$class = $canresubmit && ($tutorbeforeduedate || $allowedlate) ? 'graded_warning' : '';
12531253

12541254
// Output grademark icon.
1255-
$grade = $OUTPUT->box(
1256-
html_writer::tag('i', '', array('class' => 'fa fa-pencil fa-lg gm-blue')),
1257-
'grademark_open ' . $class, 'grademark_' . $submission->submission_objectid . '_' . $partid . '_' . $moodleuserid,
1258-
array('title' => $CFG->wwwroot . '/mod/turnitintooltwo/view.php?id=' . $cm->id)
1259-
);
1255+
$grade = '';
1256+
if (!is_null($submission->submission_grade) || $submission->submission_gmimaged != 0 || $istutor) {
1257+
$grade = $OUTPUT->box(
1258+
html_writer::tag('i', '', array('class' => 'fa fa-pencil fa-lg gm-blue')),
1259+
'grademark_open ' . $class, 'grademark_' . $submission->submission_objectid . '_' . $partid . '_' . $moodleuserid,
1260+
array('title' => $CFG->wwwroot . '/mod/turnitintooltwo/view.php?id=' . $cm->id)
1261+
);
1262+
}
12601263

12611264
// Show grade.
12621265
if ($turnitintooltwoassignment->turnitintooltwo->gradedisplay == 2) { // 2 is fraction
@@ -1288,9 +1291,10 @@ public function get_submission_inbox_row($cm, $turnitintooltwoassignment, $parts
12881291
$grade = $OUTPUT->box('--', '');
12891292
}
12901293

1291-
// Show average grade if more than 1 part.
1294+
// Show average grade if more than 1 part or using a scale.
12921295
if (count($parts) > 1 || $turnitintooltwoassignment->turnitintooltwo->grade < 0) {
12931296
$overallgrade = '--';
1297+
12941298
if ($submission->nmoodle != 1 && $all_parts_unanonymised &&
12951299
($istutor || (!$istutor && $parts[$partid]->dtpost < time()))) {
12961300
if (!isset($useroverallgrades[$submission->userid])) {
@@ -1476,11 +1480,9 @@ public function get_submission_inbox($cm, $turnitintooltwoassignment, $parts, $p
14761480

14771481
$submissiondata = array();
14781482

1479-
$i = -1;
14801483
$j = 0;
14811484

14821485
foreach ($_SESSION["submissions"][$partid] as $submission) {
1483-
$i++;
14841486

14851487
$data = $this->get_submission_inbox_row($cm, $turnitintooltwoassignment, $parts, $partid, $submission,
14861488
$useroverallgrades, $istutor);
@@ -1896,8 +1898,7 @@ public function get_tii_members_by_role($cm, $turnitintooltwoassignment, $member
18961898
public function show_add_tii_tutors_form($cm, $tutors) {
18971899
global $CFG, $OUTPUT;
18981900

1899-
$moodletutors = get_users_by_capability(context_module::instance($cm->id), 'mod/turnitintooltwo:grade',
1900-
'u.id, u.firstname, u.lastname, u.username');
1901+
$moodletutors = get_enrolled_users(context_module::instance($cm->id), 'mod/turnitintooltwo:grade', 0, 'u.id');
19011902

19021903
// Populate elements array which will generate the form elements
19031904
// Each element is in following format: (type, name, label, helptext (minus _help), options (if select).

‎version.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@
2323
$plugin = new StdClass();
2424
}
2525

26-
$plugin->version = 2016072601;
26+
$plugin->version = 2016091401;
2727
$plugin->release = "2.6+";
2828
$plugin->requires = 2013111800;
2929
$plugin->component = 'mod_turnitintooltwo';
3030
$plugin->maturity = MATURITY_STABLE;
3131

3232
global $CFG;
33-
if ($CFG->version > 2014051200) {
34-
$plugin->cron = 0;
35-
} else {
36-
$plugin->cron = 1800;
33+
$plugin->cron = 0;
34+
if (!empty($CFG->version)) {
35+
$plugin->cron = ($CFG->version > 2014051200) ? 0 : 1800;
3736
}

‎view.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,7 @@
389389

390390
// Get all users enrolled in the class.
391391
$context = context_module::instance($cm->id);
392-
$allusers = get_users_by_capability(context_module::instance($cm->id), 'mod/turnitintooltwo:submit', 'u.id',
393-
'', '', '', groups_get_activity_group($cm));
392+
$allusers = get_enrolled_users($context, 'mod/turnitintooltwo:submit', groups_get_activity_group($cm), 'u.id');
394393

395394
// Get users who've submitted.
396395
$params = array('turnitintooltwoid' => $turnitintooltwo->id, 'submission_part' => $part);
@@ -760,7 +759,7 @@
760759
}
761760

762761
$elements = array();
763-
$elements[] = array('header', 'nonsubmitters_header', get_string('emailnonsubmitters', 'turnitintooltwo'));
762+
$elements[] = array('header', 'nonsubmitters_header', get_string('messagenonsubmitters', 'turnitintooltwo'));
764763
$elements[] = array('static', 'nonsubmittersformdesc', get_string('nonsubmittersformdesc', 'turnitintooltwo'), '', '');
765764
$elements[] = array('text', 'nonsubmitters_subject', get_string('nonsubmitterssubject', 'turnitintooltwo'), '', '',
766765
'required', get_string('nonsubmitterssubjecterror', 'turnitintooltwo'), PARAM_TEXT);

0 commit comments

Comments
 (0)
Please sign in to comment.