Skip to content

Commit

Permalink
Merge pull request #191 from turnitin/develop
Browse files Browse the repository at this point in the history
Merge Release v2016062701
  • Loading branch information
David Hatton authored Jul 26, 2016
2 parents c65ef0a + 0829e66 commit 838260d
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 109 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
### Date: 2016-July-26
### Release: v2016072601

- Verified against Moodle 3.1
- Changed display of names to be consistent with Moodle (Thanks to junwan6).
- Improved the way grade updates are handled for entering grades to the gradebook.
- Fixes:
- Ignore inherited roles when sending instructor notifications.
- Scheduled tasks problems with deleting classes from database where no entry exists in course_modules table.
- Replace a couple of missing icons in plugin configuration area.
- Grade related settings are now hidden if GradeMark is not enabled.

---

### Date: 2016-April-11
### Release: v2016011105

Expand All @@ -10,7 +24,6 @@
- Enrolls user if necessary when performing a course restoration.
- Fixed cron logic to prevent multiple assignment creation upon cron event failure.


---

### Date: 2016-February-23
Expand Down
20 changes: 15 additions & 5 deletions ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@
if ($updatefromtii && $start == 0) {
$turnitintooltwoassignment->get_submission_ids_from_tii($parts[$partid]);
$total = $_SESSION["TiiSubmissions"][$partid];
$_SESSION["TiiSubmissionsRefreshed"][$partid] = time();
}

if ($start < $total && $updatefromtii) {
Expand All @@ -259,9 +258,15 @@
$return["total"] = $_SESSION["num_submissions"][$partid];
$return["nonsubmitters"] = $return["total"] - $totalsubmitters;

// Remove any leftover submissions from session
// Remove any leftover submissions from session and update grade timestamp/
if ($return["end"] >= $return["total"]) {
unset($_SESSION["submissions"][$partid]);

$updatepart = new stdClass();
$updatepart->id = $partid;
// Set timestamp to 10 minutes ago to account for time taken to complete (somewhat exagerrated).
$updatepart->gradesupdated = time()-(60*10);
$DB->update_record('turnitintooltwo_parts', $updatepart);
}
} else {
$return["aaData"] = '';
Expand Down Expand Up @@ -360,6 +365,7 @@

$submission->firstname = $user->firstname;
$submission->lastname = $user->lastname;
$submission->fullname = $user->fullname;
$submission->userid = $user->id;
}

Expand Down Expand Up @@ -496,11 +502,15 @@
$turnitintooltwosubmission = new turnitintooltwo_submission($submissionid, "turnitin");
if ($turnitintooltwosubmission->unanonymise_submission($reason)) {
if ($turnitintooltwosubmission->userid == 0) {
$return["name"] = format_string($turnitintooltwosubmission->nmlastname).", ".
format_string($turnitintooltwosubmission->nmfirstname);

$tmpuser = new stdClass();
$tmpuser->firstname = $turnitintooltwosubmission->nmfirstname;
$tmpuser->lastname = $turnitintooltwosubmission->nmlastname;

$return["name"] = fullname($tmpuser);
} else {
$user = new turnitintooltwo_user($turnitintooltwosubmission->userid);
$return["name"] = format_string($user->lastname).", ".format_string($user->firstname);
$return["name"] = fullname($user);
}
$return["status"] = "success";
$return["userid"] = $turnitintooltwosubmission->userid;
Expand Down
2 changes: 1 addition & 1 deletion classes/digitalreceipt/instructor_message.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function send_instructor_message($instructors, $message)

$eventdata = new stdClass();
$eventdata->component = 'mod_turnitintooltwo'; //your component name
$eventdata->name = 'submission'; //this is the message name from messages.php
$eventdata->name = 'notify_instructor_of_submission'; //this is the message name from messages.php
$eventdata->userfrom = \core_user::get_noreply_user();
$eventdata->subject = $subject;
$eventdata->fullmessage = $message;
Expand Down
3 changes: 2 additions & 1 deletion db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
<FIELD NAME="deleted" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" PREVIOUS="maxmarks" NEXT="migrated"/>
<FIELD NAME="migrated" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" UNSIGNED="false" SEQUENCE="false" PREVIOUS="deleted" NEXT="unanon"/>
<FIELD NAME="unanon" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" UNSIGNED="false" SEQUENCE="false" PREVIOUS="migrated" NEXT="submitted"/>
<FIELD NAME="submitted" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" UNSIGNED="false" SEQUENCE="false" PREVIOUS="unanon"/>
<FIELD NAME="submitted" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" UNSIGNED="false" SEQUENCE="false" PREVIOUS="unanon" NEXT="gradesupdated"/>
<FIELD NAME="gradesupdated" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" UNSIGNED="false" SEQUENCE="false" PREVIOUS="submitted"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
Expand Down
2 changes: 1 addition & 1 deletion db/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
),
//Notify nonsubmitters for an assignment.
'nonsubmitters' => array (),
// Notify student with their digital receipt.
// Notify instructors with their copy of the digital receipt.
'notify_instructor_of_submission' => array (
)
);
Expand Down
10 changes: 10 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,15 @@ function xmldb_turnitintooltwo_upgrade($oldversion) {
}
}

if ($oldversion < 2016011107) {
$table = new xmldb_table('turnitintooltwo_parts');
// Add timestamp to store when grades were last updated.
$field = new xmldb_field('gradesupdated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0, 'submitted');

if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
}

return true;
}
89 changes: 46 additions & 43 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,13 @@ function turnitintooltwo_grade_item_update($turnitintooltwo, $grades = null) {
$params['itemname'] = $turnitintooltwo->name;
$params['idnumber'] = isset($cm->idnumber) ? $cm->idnumber : null;

if ($turnitintooltwo->grade < 0) { // If we're using a grade scale.
$grade = (empty($turnitintooltwo->grade)) ? 0 : $turnitintooltwo->grade;
if ($grade < 0) { // If we're using a grade scale.
$params['gradetype'] = GRADE_TYPE_SCALE;
$params['scaleid'] = -$turnitintooltwo->grade;
} else if ($turnitintooltwo->grade > 0) { // If we are using a grade value.
$params['scaleid'] = -$grade;
} else if ($grade > 0) { // If we are using a grade value.
$params['gradetype'] = GRADE_TYPE_VALUE;
$params['grademax'] = $turnitintooltwo->grade;
$params['grademax'] = $grade;
$params['grademin'] = 0;
} else { // If we aren't using a grade at all.
$params['gradetype'] = GRADE_TYPE_NONE;
Expand Down Expand Up @@ -608,51 +609,53 @@ function turnitintooltwo_cron_update_gradbook($assignment, $task) {
$cm = get_coursemodule_from_instance("turnitintooltwo", $turnitintooltwoassignment->turnitintooltwo->id,
$turnitintooltwoassignment->turnitintooltwo->course);

$users = $turnitintooltwoassignment->get_moodle_course_users($cm);
if ($cm) {
$users = $turnitintooltwoassignment->get_moodle_course_users($cm);

foreach ($users as $user) {
$fieldList = array('turnitintooltwoid' => $turnitintooltwoassignment->turnitintooltwo->id,
'userid' => $user->id);
foreach ($users as $user) {
$fieldList = array('turnitintooltwoid' => $turnitintooltwoassignment->turnitintooltwo->id,
'userid' => $user->id);

// Set submission_unanon when needsupdating is used.
if ($task == "needsupdating") {
$fieldList['submission_unanon'] = 1;
}
// Set submission_unanon when needsupdating is used.
if ($task == "needsupdating") {
$fieldList['submission_unanon'] = 1;
}

$grades = new stdClass();
$grades = new stdClass();

if ($submissions = $DB->get_records('turnitintooltwo_submissions', $fieldList)) {
$overallgrade = $turnitintooltwoassignment->get_overall_grade($submissions, $cm);
if ($turnitintooltwoassignment->turnitintooltwo->grade < 0) {
// Using a scale.
$grades->rawgrade = ($overallgrade == '--') ? null : $overallgrade;
} else {
$grades->rawgrade = ($overallgrade == '--') ? null : number_format($overallgrade, 2);
if ($submissions = $DB->get_records('turnitintooltwo_submissions', $fieldList)) {
$overallgrade = $turnitintooltwoassignment->get_overall_grade($submissions, $cm);
if ($turnitintooltwoassignment->turnitintooltwo->grade < 0) {
// Using a scale.
$grades->rawgrade = ($overallgrade == '--') ? null : $overallgrade;
} else {
$grades->rawgrade = ($overallgrade == '--') ? null : number_format($overallgrade, 2);
}
}
$grades->userid = $user->id;
$params['idnumber'] = $cm->idnumber;

grade_update('mod/turnitintooltwo', $turnitintooltwoassignment->turnitintooltwo->course, 'mod',
'turnitintooltwo', $turnitintooltwoassignment->turnitintooltwo->id, 0, $grades, $params);
}
$grades->userid = $user->id;
$params['idnumber'] = $cm->idnumber;

grade_update('mod/turnitintooltwo', $turnitintooltwoassignment->turnitintooltwo->course, 'mod',
'turnitintooltwo', $turnitintooltwoassignment->turnitintooltwo->id, 0, $grades, $params);
}
// Remove the "anongradebook" flag
$update_assignment = new stdClass();
$update_assignment->id = $assignment->id;

// Remove the "anongradebook" flag
$update_assignment = new stdClass();
$update_assignment->id = $assignment->id;
// Depending on the task we need to update a different column.
switch($task) {
case "needsupdating":
$update_assignment->needs_updating = 0;
break;

// Depending on the task we need to update a different column.
switch($task) {
case "needsupdating":
$update_assignment->needs_updating = 0;
break;
case "anongradebook":
$update_assignment->anongradebook = 1;
break;
}

case "anongradebook":
$update_assignment->anongradebook = 1;
break;
$DB->update_record("turnitintooltwo", $update_assignment);
}

$DB->update_record("turnitintooltwo", $update_assignment);
}

/**
Expand Down Expand Up @@ -985,7 +988,7 @@ function turnitintooltwo_get_courses_from_tii($tiiintegrationids, $coursetitle,
gmdate("j", strtotime($readclass->getEndDate()))."_".
gmdate("n", strtotime($readclass->getEndDate()))."_".
gmdate("Y", strtotime($readclass->getEndDate()))))." ".
$OUTPUT->pix_icon('edit', get_string('edit'), 'mod_turnitintooltwo'),
html_writer::tag('i', '', array('class' => 'fa fa-pencil fa-lg grey')),
array("class" => "edit_course_end_link", "id" => "course_date_".$readclass->getClassId()));

$checkbox = '';
Expand Down Expand Up @@ -1170,7 +1173,7 @@ function turnitintooltwo_getfiles($moduleid) {
if (($file->anon_enabled == 1 && $file->unanon == 1) ||
($file->anon_enabled == 0 && (!empty($file->firstname) || !empty($file->lastname)))) {
$user = html_writer::link($CFG->wwwroot.'/user/view.php?id='.$file->userid,
$file->lastname . ', ' . $file->firstname . '</a> (' . $file->email . ')');
fullname($file) . '</a> (' . $file->email . ')');
} else if ($file->anon_enabled == 1 && empty($file->unanon)) {
$user = get_string('anonenabled', 'turnitintooltwo');
} else {
Expand All @@ -1184,8 +1187,8 @@ function turnitintooltwo_getfiles($moduleid) {
$attributes["onclick"] = "return confirm('".str_replace($fnd, $rep,
get_string('filedeleteconfirm', 'turnitintooltwo'))."');";
$delete = html_writer::link($CFG->wwwroot.'/mod/turnitintooltwo/settings_extras.php?cmd=files&file='.
$file->id.'&filehash='.$file->hash, $OUTPUT->pix_icon('delete',
get_string('delete'), 'mod_turnitintooltwo'), $attributes);
$file->id.'&filehash='.$file->hash,
html_writer::tag('i', '', array('class' => 'fa fa-trash-o fa-lg')), $attributes);
}

$return["aaData"][] = array($assignment, $file->courseshort, $file->coursetitle, $submission,
Expand All @@ -1207,7 +1210,7 @@ function turnitintooltwo_getfiles($moduleid) {
* @param array $options additional options affecting the file serving
* @return bool false if file not found, does not return if found - just send the file
*/
function turnitintooltwo_pluginfile($course,
function turnitintooltwo_pluginfile($course,
$cm,
context $context,
$filearea,
Expand Down
28 changes: 17 additions & 11 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,13 @@ public function show_form($instructorrubrics, $modulestring = '', $tiicourseid)
$mform->addHelpButton('studentreports', 'studentreports', 'turnitintooltwo');
$mform->setDefault('studentreports', $config->default_studentreports);

$gradedisplayoptions = array(1 => get_string('displaygradesaspercent', 'turnitintooltwo'),
2 => get_string('displaygradesasfraction', 'turnitintooltwo'));
$mform->addElement('select', 'gradedisplay', get_string('displaygradesas', 'turnitintooltwo'), $gradedisplayoptions);
$mform->addHelpButton('gradedisplay', 'displaygradesas', 'turnitintooltwo');
$mform->setDefault('gradedisplay', $config->default_gradedisplay);
if (!empty($config->usegrademark)) {
$gradedisplayoptions = array(1 => get_string('displaygradesaspercent', 'turnitintooltwo'),
2 => get_string('displaygradesasfraction', 'turnitintooltwo'));
$mform->addElement('select', 'gradedisplay', get_string('displaygradesas', 'turnitintooltwo'), $gradedisplayoptions);
$mform->addHelpButton('gradedisplay', 'displaygradesas', 'turnitintooltwo');
$mform->setDefault('gradedisplay', $config->default_gradedisplay);
}

$refreshoptions = array(1 => get_string('yesgrades', 'turnitintooltwo'), 0 => get_string('nogrades', 'turnitintooltwo'));

Expand All @@ -299,7 +301,9 @@ public function show_form($instructorrubrics, $modulestring = '', $tiicourseid)
$dateoptions = array('startyear' => date( 'Y', strtotime( '-6 years' )), 'stopyear' => date( 'Y', strtotime( '+6 years' )),
'timezone' => 99, 'applydst' => true, 'step' => 1, 'optional' => false);

$this->standard_grading_coursemodule_elements();
if (!empty($config->usegrademark)) {
$this->standard_grading_coursemodule_elements();
}

if (isset($this->_cm->id)) {
$turnitintooltwoassignment = new turnitintooltwo_assignment($this->_cm->instance);
Expand Down Expand Up @@ -358,10 +362,12 @@ public function show_form($instructorrubrics, $modulestring = '', $tiicourseid)
$mform->addElement('date_time_selector', 'dtpost'.$i, get_string('dtpost', 'turnitintooltwo'), $dateoptions);
$mform->setDefault('dtpost'.$i, strtotime('+7 days'));

$mform->addElement('text', 'maxmarks'.$i, get_string('maxmarks', 'turnitintooltwo'));
$mform->setType('maxmarks'.$i, PARAM_INT);
$mform->setDefault('maxmarks'.$i, '100');
$mform->addRule('maxmarks'.$i, null, 'numeric', null, 'client');
if (!empty($config->usegrademark)) {
$mform->addElement('text', 'maxmarks'.$i, get_string('maxmarks', 'turnitintooltwo'));
$mform->setType('maxmarks'.$i, PARAM_INT);
$mform->setDefault('maxmarks'.$i, '100');
$mform->addRule('maxmarks'.$i, null, 'numeric', null, 'client');
}
}

$mform->addElement('header', 'advanced', get_string('turnitinoroptions', 'turnitintooltwo'));
Expand Down Expand Up @@ -606,7 +612,7 @@ public function validation($data, $files) {
$dtstart = $data['dtstart'.$i];
$dtdue = $data['dtdue'.$i];
$dtpost = $data['dtpost'.$i];
$maxmarks = $data['maxmarks'.$i];
$maxmarks = (empty($data['maxmarks'.$i])) ? 0 : $data['maxmarks'.$i];

if (!is_int($maxmarks) && $maxmarks > 100) {
$errors['maxmarks'.$i] = get_string('maxmarkserror', 'turnitintooltwo');
Expand Down
Loading

0 comments on commit 838260d

Please sign in to comment.