Skip to content

Commit

Permalink
Merge pull request #209 from turnitin/develop
Browse files Browse the repository at this point in the history
Release 2016091401
  • Loading branch information
jmcgettrick authored Sep 14, 2016
2 parents 838260d + 33f9146 commit b5e4c81
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 71 deletions.
48 changes: 32 additions & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
### Date: 2016-September-14
### Release: v2016091401


- Remove leftover counter variable from get_submission_inbox function.
- Refactored the get users functionality in several places to not include users with roles inherited from site level.
- Fixes:
- Add missing string to email non submitters.
- Check $CFG exists before using in version.php (Thanks to @micaherne).
- Assignments starting more than a year ago can now be restored without user info.
- Check for GradeMark feedback changes when saving submission.
- Only show GradeMark launch to student if the paper has feedback or grade.
- Slight tweak to overall grade to show overall grade on normal assignments.

---

### Date: 2016-July-26
### Release: v2016072601

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

---

###Date: 2014-September-04
###Release: v2014012407
### Date: 2014-September-04
### Release: v2014012407

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

---

###Date: 2014-August-19
###Release: v2014012406
### Date: 2014-August-19
### Release: v2014012406

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

---

###Date: 2014-June-11
###Release: v2014012405
### Date: 2014-June-11
### Release: v2014012405

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

---

###Date: 2014-June-11
###Release: v2014012404
### Date: 2014-June-11
### Release: v2014012404

- EULA acceptance is now stored locally for submissions.

---

###Date: 2014-April-17
###Release: v2014012403
### Date: 2014-April-17
### Release: v2014012403

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

---

###Date: 2014-February-26
###Release: v2014012402
### Date: 2014-February-26
### Release: v2014012402

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

---

###Date: 2014-January-24
###Release: v2014012401
### Date: 2014-January-24
### Release: v2014012401

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

---

###Date: 2013-December-18
###Release: v2013121801
### Date: 2013-December-18
### Release: v2013121801

- Supports Turnitin Originality Checking, GradeMark and PeerMark
- Allows access to the Rubric Manager and Quickmark Manager from within the Moodle environment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function after_restore() {
foreach($_SESSION["assignments_to_create"] as $new_assignment_id) {
$assignment = new turnitintooltwo_assignment($new_assignment_id);
$assignment->unlink_assignment();
$assignment->edit_moodle_assignment();
$assignment->edit_moodle_assignment(true, true);
}
unset($_SESSION['tii_assignment_reset']);
unset($_SESSION['assignments_to_create']);
Expand Down
6 changes: 3 additions & 3 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,8 @@ function turnitintooltwo_cron_update_gradbook($assignment, $task) {
$turnitintooltwoassignment->turnitintooltwo->course);

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

foreach ($users as $user) {
$fieldList = array('turnitintooltwoid' => $turnitintooltwoassignment->turnitintooltwo->id,
Expand Down Expand Up @@ -1361,7 +1362,6 @@ function turnitintooltwo_print_overview($courses, &$htmlarray) {
$partsarray = array();
$grader = has_capability('mod/turnitintooltwo:grade', $context);
if ($grader) {
$allusers = get_users_by_capability($context, 'mod/turnitintooltwo:submit', 'u.id', '', '', '', 0, '', false);
$submissionsquery = $DB->get_records_select('turnitintooltwo_submissions',
'turnitintooltwoid = ? GROUP BY id, submission_part, submission_grade, submission_gmimaged',
array($turnitintooltwo->id), '', 'id, submission_part, submission_grade, submission_gmimaged');
Expand Down Expand Up @@ -1392,7 +1392,7 @@ function turnitintooltwo_print_overview($courses, &$htmlarray) {
$input = new stdClass();
$input->submitted = $numsubmissions;
$input->graded = $graded;
$input->total = count($allusers);
$input->total = count_enrolled_users($context, 'mod/turnitintooltwo:submit', 0);
$input->gplural = ($graded != 1) ? 's' : '';
$partsarray[$part->id]['status'] = get_string('tutorstatus', 'turnitintooltwo', $input);
} else {
Expand Down
51 changes: 22 additions & 29 deletions turnitintooltwo_assignment.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,10 +576,10 @@ public function enrol_all_students($cm) {
$course = $this->get_course_data($this->turnitintooltwo->course);

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

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

// Enrol remaining unenrolled users to the course.
$members = array_keys($moodleclassmembers);
$members = array_keys($students);
foreach ($members as $member) {
$user = new turnitintooltwo_user($member, "Learner");
$user->join_user_to_class($course->turnitin_cid);
Expand Down Expand Up @@ -1110,7 +1110,7 @@ public function edit_part_field($partid, $fieldname, $fieldvalue) {
switch ($fieldname) {
case "partname":
$fieldvalue = trim($fieldvalue);
$partnames = $DB->get_records_select('turnitintooltwo_parts',
$partnames = $DB->get_records_select('turnitintooltwo_parts',
' turnitintooltwoid = ? AND id != ? ',
array($partdetails->turnitintooltwoid, $partid), '', 'partname');

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

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

$attribute = "dtstart".$i;
$assignment->setStartDate(gmdate("Y-m-d\TH:i:s\Z", $this->turnitintooltwo->$attribute));
$attribute = "dtdue".$i;
$assignment->setDueDate(gmdate("Y-m-d\TH:i:s\Z", $this->turnitintooltwo->$attribute));
$attribute = "dtpost".$i;
$assignment->setFeedbackReleaseDate(gmdate("Y-m-d\TH:i:s\Z", $this->turnitintooltwo->$attribute));
if (($restore) && ($this->turnitintooltwo->$attribute < strtotime("-1 year"))) {
$assignment->setStartDate(gmdate("Y-m-d\TH:i:s\Z", time()));
$assignment->setDueDate(gmdate("Y-m-d\TH:i:s\Z", strtotime("+1 week")));
$assignment->setFeedbackReleaseDate(gmdate("Y-m-d\TH:i:s\Z", strtotime("+1 week")));
} else {
$assignment->setStartDate(gmdate("Y-m-d\TH:i:s\Z", $this->turnitintooltwo->$attribute));
$attribute = "dtdue".$i;
$assignment->setDueDate(gmdate("Y-m-d\TH:i:s\Z", $this->turnitintooltwo->$attribute));
$attribute = "dtpost".$i;
$assignment->setFeedbackReleaseDate(gmdate("Y-m-d\TH:i:s\Z", $this->turnitintooltwo->$attribute));
}

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

/**
* Get the Moodle users who are students
*
* @param object $cm the course module
* @return array of course users or empty array if none
*/
public function get_moodle_course_users($cm) {
$courseusers = get_users_by_capability(context_module::instance($cm->id),
'mod/turnitintooltwo:submit', '', 'u.lastname, u.firstname');

return (!is_array($courseusers)) ? array() : $courseusers;
}

/**
* Return an array with the parts still available to be submitted to
*
Expand Down Expand Up @@ -1869,13 +1862,13 @@ public function get_submissions($cm, $partid = 0, $userid = 0, $submissionsonly
$istutor = has_capability('mod/turnitintooltwo:grade', $context);

// If logged in as instructor then get for all users.
$allnamefields = get_all_user_name_fields();
if ($istutor && $userid == 0) {
$allnames = get_all_user_name_fields();
$users = get_users_by_capability($context, 'mod/turnitintooltwo:submit', 'u.id, ' . implode($allnames, ', '),
'', '', '', groups_get_activity_group($cm), '');
$users = get_enrolled_users($context, 'mod/turnitintooltwo:submit', groups_get_activity_group($cm),
'u.id, ' . implode($allnamefields, ', '));
$users = (!$users) ? array() : $users;
} else if ($istutor) {
$user = $DB->get_record('user', array('id' => $userid));
$user = $DB->get_record('user', array('id' => $userid), 'id, ' . implode($allnamefields, ', '));
$users = array($userid => $user);
$sql .= " AND userid = ? ";
$sqlparams[] = $userid;
Expand Down
8 changes: 5 additions & 3 deletions turnitintooltwo_submission.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ private function get_submission_details($idtype = "moodle", $turnitintooltwoassi
}

if ($submission->userid > 0) {
$user = $DB->get_record('user', array('id' => $submission->userid), 'firstname, lastname');
$allnamefields = get_all_user_name_fields();
$user = $DB->get_record('user', array('id' => $submission->userid), 'id, '.implode($allnamefields, ', '));
$this->firstname = $user->firstname;
$this->lastname = $user->lastname;
$this->fullname = fullname($user);
Expand Down Expand Up @@ -625,7 +626,7 @@ public function do_tii_submission($cm, $turnitintooltwoassignment) {
$this->receipt->send_message($this->userid, $message);

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

Expand Down
23 changes: 12 additions & 11 deletions turnitintooltwo_view.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ public function get_submission_inbox_row($cm, $turnitintooltwoassignment, $parts
if ($parts[$v]->dtpost > time()) {
$display_overall_grade = 0;
}
if ($parts[$v]->unanon != 1 && $all_parts_unanonymised) {
if ($turnitintooltwoassignment->turnitintooltwo->anon && $parts[$v]->unanon != 1 && $all_parts_unanonymised) {
$all_parts_unanonymised = 0;
}
}
Expand Down Expand Up @@ -1252,11 +1252,14 @@ public function get_submission_inbox_row($cm, $turnitintooltwoassignment, $parts
$class = $canresubmit && ($tutorbeforeduedate || $allowedlate) ? 'graded_warning' : '';

// Output grademark icon.
$grade = $OUTPUT->box(
html_writer::tag('i', '', array('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)
);
$grade = '';
if (!is_null($submission->submission_grade) || $submission->submission_gmimaged != 0 || $istutor) {
$grade = $OUTPUT->box(
html_writer::tag('i', '', array('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)
);
}

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

// Show average grade if more than 1 part.
// Show average grade if more than 1 part or using a scale.
if (count($parts) > 1 || $turnitintooltwoassignment->turnitintooltwo->grade < 0) {
$overallgrade = '--';

if ($submission->nmoodle != 1 && $all_parts_unanonymised &&
($istutor || (!$istutor && $parts[$partid]->dtpost < time()))) {
if (!isset($useroverallgrades[$submission->userid])) {
Expand Down Expand Up @@ -1476,11 +1480,9 @@ public function get_submission_inbox($cm, $turnitintooltwoassignment, $parts, $p

$submissiondata = array();

$i = -1;
$j = 0;

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

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

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

// Populate elements array which will generate the form elements
// Each element is in following format: (type, name, label, helptext (minus _help), options (if select).
Expand Down
9 changes: 4 additions & 5 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@
$plugin = new StdClass();
}

$plugin->version = 2016072601;
$plugin->version = 2016091401;
$plugin->release = "2.6+";
$plugin->requires = 2013111800;
$plugin->component = 'mod_turnitintooltwo';
$plugin->maturity = MATURITY_STABLE;

global $CFG;
if ($CFG->version > 2014051200) {
$plugin->cron = 0;
} else {
$plugin->cron = 1800;
$plugin->cron = 0;
if (!empty($CFG->version)) {
$plugin->cron = ($CFG->version > 2014051200) ? 0 : 1800;
}
5 changes: 2 additions & 3 deletions view.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,7 @@

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

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

$elements = array();
$elements[] = array('header', 'nonsubmitters_header', get_string('emailnonsubmitters', 'turnitintooltwo'));
$elements[] = array('header', 'nonsubmitters_header', get_string('messagenonsubmitters', 'turnitintooltwo'));
$elements[] = array('static', 'nonsubmittersformdesc', get_string('nonsubmittersformdesc', 'turnitintooltwo'), '', '');
$elements[] = array('text', 'nonsubmitters_subject', get_string('nonsubmitterssubject', 'turnitintooltwo'), '', '',
'required', get_string('nonsubmitterssubjecterror', 'turnitintooltwo'), PARAM_TEXT);
Expand Down

0 comments on commit b5e4c81

Please sign in to comment.