Skip to content

Commit

Permalink
Merge pull request #211 from turnitin/develop
Browse files Browse the repository at this point in the history
Merge develop into master for release 2015012501
  • Loading branch information
dwinn authored Jan 26, 2017
2 parents 31ae422 + e208f8f commit 0636b8a
Show file tree
Hide file tree
Showing 52 changed files with 5,535 additions and 1,384 deletions.
46 changes: 46 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
language: php

sudo: false

cache:
directories:
- $HOME/.composer/cache

php:
- 5.5
# - 5.6
- 7.0

env:
global:
- IGNORE_PATHS=sdk/,pix/
- IGNORE_NAMES=jquery*,styles.css
matrix:
# - DB=pgsql MOODLE_BRANCH=MOODLE_31_STABLE
# - DB=mysqli MOODLE_BRANCH=MOODLE_31_STABLE
- DB=pgsql MOODLE_BRANCH=MOODLE_30_STABLE
- DB=mysqli MOODLE_BRANCH=MOODLE_30_STABLE
# - DB=pgsql MOODLE_BRANCH=MOODLE_27_STABLE
# - DB=mysqli MOODLE_BRANCH=MOODLE_27_STABLE

before_install:
- phpenv config-rm xdebug.ini
- cd ../..
- composer selfupdate
- composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^1
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"

install:
- moodle-plugin-ci install

script:
- moodle-plugin-ci phplint
- moodle-plugin-ci phpcpd
- moodle-plugin-ci phpmd
- moodle-plugin-ci codechecker
- moodle-plugin-ci csslint
- moodle-plugin-ci shifter
# - moodle-plugin-ci jshint
- moodle-plugin-ci validate
# - moodle-plugin-ci phpunit
- moodle-plugin-ci behat
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
### Date: 2017-January-25
### Release: v2017012501

- The events now use Moodle's new Events 2 API, which is a requirement to support future Moodle versions. Admins should ensure the Events Queue has been cleared for Plagiarism events. Following this change to the Events API this release and future releases will no longer work on Moodle 2.6.
- The language strings have been updated across all supported languages.
- The unused database columns legacyteacher, apimd5 and externalstatus have been removed from the plugin's plagiarism_turnitin_files table. These were leftovers from Dan Marsden's version of the plugin that are no longer used.
- Travis-CI has been aded to the plugin as an extra QA resource to help flag any issues with the code.
- Fixes:
- The assignment edit API call no longer fails if repository settings don't match the plugin settings.
- JavaScript error no longer appears when closing the PeerMark manager.
- The & character no longer appears in TFS as &.
- Default values for submitter and student_read columns are now consistent between upgrade and install. (Thanks to @danmarsden).
- The error message when submitting a file >40mb now displays correctly.
- Fixed an issue with anonymous marking where grades would appear in the gradebook before the assignment has been unanonymised.
- Fixed an issue where the first submission to an assignment would sometimes fail to send to Turnitin.
- Moodle's Behat unit tests will no longer fail. (Thanks to @roperto)

---

### Date: 2016-September-14
### Release: v2016091401

Expand Down
44 changes: 23 additions & 21 deletions ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
$action = required_param('action', PARAM_ALPHAEXT);
$cmid = optional_param('cmid', 0, PARAM_INT);
$itemid = optional_param('itemid', 0, PARAM_INT);
if( !empty( $cmid ) ){
if ( !empty( $cmid ) ) {
$cm = get_coursemodule_from_id('', $cmid);
$context = context_course::instance($cm->course);

Expand Down Expand Up @@ -66,7 +66,7 @@
if ($syncassignment['success']) {
$turnitintooltwoview = new turnitintooltwo_view();
$return = html_writer::tag("div",
$turnitintooltwoview->output_dv_launch_form($dvtype, $submissionid, $user->tii_user_id,
$turnitintooltwoview->output_dv_launch_form($dvtype, $submissionid, $user->tiiuserid,
$userrole, ''), array('style' => 'display: none'));
}
break;
Expand Down Expand Up @@ -115,8 +115,8 @@
case "peermarkmanager":

if ($userrole == 'Instructor') {
$plagiarism_plugin_turnitin = new plagiarism_plugin_turnitin();
$coursedata = $plagiarism_plugin_turnitin->get_course_data($cm->id, $cm->course);
$plagiarismpluginturnitin = new plagiarism_plugin_turnitin();
$coursedata = $plagiarismpluginturnitin->get_course_data($cm->id, $cm->course);

$tiiassignment = $DB->get_record('plagiarism_turnitin_config', array('cm' => $cm->id, 'name' => 'turnitin_assignid'));

Expand All @@ -141,8 +141,10 @@
break;

case "rubricview":
$isstudent = ($cm->modname == "forum") ? has_capability('mod/'.$cm->modname.':replypost', $context) :
has_capability('mod/'.$cm->modname.':submit', $context);
$replypost = 'mod/'.$cm->modname.':replypost';
$submit = 'mod/'.$cm->modname.':submit';
$isstudent = ($cm->modname == "forum") ? has_capability($replypost, $context) : has_capability($submit, $context);

if ($isstudent) {
$tiiassignment = $DB->get_record('plagiarism_turnitin_config', array('cm' => $cm->id, 'name' => 'turnitin_assignid'));

Expand All @@ -160,9 +162,9 @@
break;

case "peermarkreviews":

$isstudent = ($cm->modname == "forum") ? has_capability('mod/'.$cm->modname.':replypost', $context) :
has_capability('mod/'.$cm->modname.':submit', $context);
$replypost = 'mod/'.$cm->modname.':replypost';
$submit = 'mod/'.$cm->modname.':submit';
$isstudent = ($cm->modname == "forum") ? has_capability($replypost, $context) : has_capability($submit, $context);

if ($userrole == 'Instructor' || $isstudent) {
$tiiassignment = $DB->get_record('plagiarism_turnitin_config', array('cm' => $cm->id, 'name' => 'turnitin_assignid'));
Expand All @@ -187,23 +189,23 @@

$message = optional_param('message', '', PARAM_ALPHAEXT);

// Get the id from the turnitintooltwo_users table so we can update
$turnitin_user = $DB->get_record('turnitintooltwo_users', array('userid' => $USER->id));
// Get the id from the turnitintooltwo_users table so we can update.
$turnitinuser = $DB->get_record('turnitintooltwo_users', array('userid' => $USER->id));

// Build user object for update
$eula_user = new stdClass();
$eula_user->id = $turnitin_user->id;
$eula_user->user_agreement_accepted = 0;
// Build user object for update.
$eulauser = new stdClass();
$eulauser->id = $turnitinuser->id;
$eulauser->user_agreement_accepted = 0;
if ($message == 'turnitin_eula_accepted') {
$eula_user->user_agreement_accepted = 1;
turnitintooltwo_activitylog("User ".$USER->id." (".$turnitin_user->turnitin_uid.") accepted the EULA.", "PP_EULA_ACCEPTANCE");
$eulauser->user_agreement_accepted = 1;
turnitintooltwo_activitylog("User ".$USER->id." (".$turnitinuser->turnitin_uid.") accepted the EULA.", "PP_EULA_ACCEPTANCE");
} else if ($message == 'turnitin_eula_declined') {
$eula_user->user_agreement_accepted = -1;
turnitintooltwo_activitylog("User ".$USER->id." (".$turnitin_user->turnitin_uid.") declined the EULA.", "PP_EULA_ACCEPTANCE");
$eulauser->user_agreement_accepted = -1;
turnitintooltwo_activitylog("User ".$USER->id." (".$turnitinuser->turnitin_uid.") declined the EULA.", "PP_EULA_ACCEPTANCE");
}

// Update the user using the above object
$DB->update_record('turnitintooltwo_users', $eula_user, $bulk=false);
// Update the user using the above object.
$DB->update_record('turnitintooltwo_users', $eulauser, $bulk = false);
break;

case "resubmit_event":
Expand Down
49 changes: 26 additions & 23 deletions backup/moodle2/backup_plagiarism_turnitin_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,45 @@ class backup_plagiarism_turnitin_plugin extends backup_plagiarism_plugin {
protected function define_module_plugin_structure() {
$plugin = $this->get_plugin_element();

$plugin_element = new backup_nested_element($this->get_recommended_name());
$plugin->add_child($plugin_element);
$pluginelement = new backup_nested_element($this->get_recommended_name());
$plugin->add_child($pluginelement);

// Add module config elements
$turnitin_configs = new backup_nested_element('turnitin_configs');
$turnitin_config = new backup_nested_element('turnitin_config', array('id'), array('name', 'value'));
$plugin_element->add_child($turnitin_configs);
$turnitin_configs->add_child($turnitin_config);
$turnitin_config->set_source_table('plagiarism_turnitin_config', array('cm' => backup::VAR_PARENTID));
// Add module config elements.
$turnitinconfigs = new backup_nested_element('turnitin_configs');
$turnitinconfig = new backup_nested_element('turnitin_config', array('id'), array('name', 'value'));
$pluginelement->add_child($turnitinconfigs);
$turnitinconfigs->add_child($turnitinconfig);
$turnitinconfig->set_source_table('plagiarism_turnitin_config', array('cm' => backup::VAR_PARENTID));

// Add file elements if required
// Add file elements if required.
if ($this->get_setting_value('userinfo')) {
$turnitin_files = new backup_nested_element('turnitin_files');
$turnitin_file = new backup_nested_element('turnitin_file', array('id'),
array('userid', 'identifier', 'externalid', 'externalstatus', 'statuscode', 'similarityscore', 'transmatch', 'lastmodified', 'grade', 'submissiontype'));
$plugin_element->add_child($turnitin_files);
$turnitin_files->add_child($turnitin_file);
$turnitinfiles = new backup_nested_element('turnitin_files');
$turnitinfile = new backup_nested_element('turnitin_file', array('id'),
array('userid', 'identifier', 'externalid', 'externalstatus',
'statuscode', 'similarityscore', 'transmatch', 'lastmodified', 'grade', 'submissiontype'));
$pluginelement->add_child($turnitinfiles);
$turnitinfiles->add_child($turnitinfile);

$turnitin_file->set_source_table('plagiarism_turnitin_files', array('cm' => backup::VAR_PARENTID));
$turnitinfile->set_source_table('plagiarism_turnitin_files', array('cm' => backup::VAR_PARENTID));
}
return $plugin;
}

protected function define_course_plugin_structure() {
$plugin = $this->get_plugin_element();

$plugin_element = new backup_nested_element($this->get_recommended_name());
$plugin->add_child($plugin_element);
$pluginelement = new backup_nested_element($this->get_recommended_name());
$plugin->add_child($pluginelement);

// Add courses from Turnitintool table
$turnitin_courses = new backup_nested_element('turnitin_courses');
$turnitin_course = new backup_nested_element('turnitin_course', array('id'), array('courseid', 'ownerid', 'turnitin_ctl', 'turnitin_cid', 'course_type'));
$plugin_element->add_child($turnitin_courses);
$turnitin_courses->add_child($turnitin_course);
// Add courses from Turnitintool table.
$turnitincourses = new backup_nested_element('turnitin_courses');
$turnitincourse = new backup_nested_element('turnitin_course', array('id'),
array('courseid', 'ownerid', 'turnitin_ctl', 'turnitin_cid', 'course_type'));
$pluginelement->add_child($turnitincourses);
$turnitincourses->add_child($turnitincourse);

$turnitin_course->set_source_table('turnitintooltwo_courses', array('courseid'=> backup::VAR_COURSEID, 'course_type' => backup_helper::is_sqlparam('PP')));
$turnitincourse->set_source_table('turnitintooltwo_courses', array('courseid' => backup::VAR_COURSEID,
'course_type' => backup_helper::is_sqlparam('PP')));
return $plugin;
}
}
18 changes: 11 additions & 7 deletions backup/moodle2/restore_plagiarism_turnitin_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ public function process_turnitin_course($data) {

if ($this->task->is_samesite()) {
$data = (object)$data;
$record_exists = $DB->record_exists('turnitintooltwo_courses', array('turnitin_cid' => $data->turnitin_cid, 'course_type' => 'PP'));
$recordexists = $DB->record_exists('turnitintooltwo_courses',
array('turnitin_cid' => $data->turnitin_cid, 'course_type' => 'PP'));

if (!$record_exists) {
if (!$recordexists) {
$data = (object)$data;
$data->courseid = $this->task->get_courseid();

Expand Down Expand Up @@ -71,10 +72,12 @@ public function process_turnitin_config($data) {

if ($this->task->is_samesite()) {
$data = (object)$data;
$record_exists = ($data->name == 'turnitin_assign') ? $DB->record_exists('plagiarism_turnitin_config', array('name' => 'turnitin_assign', 'value' => $data->value)) : false;
$record_exists = ($data->name == 'turnitin_assignid') ? $DB->record_exists('plagiarism_turnitin_config', array('name' => 'turnitin_assignid', 'value' => $data->value)) : $record_exists;
$recordexists = ($data->name == 'turnitin_assign') ? $DB->record_exists('plagiarism_turnitin_config',
array('name' => 'turnitin_assign', 'value' => $data->value)) : false;
$recordexists = ($data->name == 'turnitin_assignid') ? $DB->record_exists('plagiarism_turnitin_config',
array('name' => 'turnitin_assignid', 'value' => $data->value)) : $recordexists;

if (!$record_exists) {
if (!$recordexists) {
$data = (object)$data;
$data->name = ($data->name == 'turnitin_assign') ? 'turnitin_assignid' : $data->name;
$data->cm = $this->task->get_moduleid();
Expand All @@ -94,9 +97,10 @@ public function process_turnitin_files($data) {

if ($this->task->is_samesite()) {
$data = (object)$data;
$record_exists = (!empty($data->externalid)) ? $DB->record_exists('plagiarism_turnitin_files', array('externalid'=>$data->externalid)) : false;
$recordexists = (!empty($data->externalid)) ? $DB->record_exists('plagiarism_turnitin_files',
array('externalid' => $data->externalid)) : false;

if (!$record_exists) {
if (!$recordexists) {
$data->cm = $this->task->get_moduleid();
$data->userid = $this->get_mappingid('user', $data->userid);

Expand Down
41 changes: 31 additions & 10 deletions classes/digitalreceipt/pp_receipt_message.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* @package moodlecore
* @subpackage backup-moodle2
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

class pp_receipt_message {

Expand All @@ -13,16 +36,16 @@ public function send_message($userid, $message) {
$subject = get_string('digital_receipt_subject', 'plagiarism_turnitin');

$eventdata = new stdClass();
$eventdata->component = 'plagiarism_turnitin'; //your component name
$eventdata->name = 'submission'; //this is the message name from messages.php
$eventdata->component = 'plagiarism_turnitin'; // Your component name.
$eventdata->name = 'submission'; // This is the message name from messages.php.
$eventdata->userfrom = \core_user::get_noreply_user();
$eventdata->userto = $userid;
$eventdata->subject = $subject;
$eventdata->fullmessage = $message;
$eventdata->fullmessageformat = FORMAT_HTML;
$eventdata->fullmessagehtml = $message;
$eventdata->smallmessage = '';
$eventdata->notification = 1; //this is only set to 0 for personal messages between users
$eventdata->notification = 1; // This is only set to 0 for personal messages between users.

message_send($eventdata);
}
Expand Down Expand Up @@ -58,8 +81,7 @@ public function build_message($input) {
* @param array $input - used tob uild message
* @return string
*/
public function build_instructor_message($input)
{
public function build_instructor_message($input) {
$message->submission_title = $input['submission_title'];
$message->assignment_name = $input['assignment_name'];
if ( isset($input['assignment_part']) ) {
Expand All @@ -81,20 +103,19 @@ public function build_instructor_message($input)
* @param string $message
* @return void
*/
public function send_instructor_message($instructors, $message)
{
public function send_instructor_message($instructors, $message) {
$subject = get_string('receipt_instructor_copy_subject', 'plagiarism_turnitin');

$eventdata = new stdClass();
$eventdata->component = 'plagiarism_turnitin'; //your component name
$eventdata->name = 'submission'; //this is the message name from messages.php
$eventdata->component = 'plagiarism_turnitin'; // Your component name.
$eventdata->name = 'submission'; // This is the message name from messages.php.
$eventdata->userfrom = \core_user::get_noreply_user();
$eventdata->subject = $subject;
$eventdata->fullmessage = $message;
$eventdata->fullmessageformat = FORMAT_HTML;
$eventdata->fullmessagehtml = $message;
$eventdata->smallmessage = '';
$eventdata->notification = 1; //this is only set to 0 for personal messages between users
$eventdata->notification = 1; // This is only set to 0 for personal messages between users.

foreach ($instructors as $instructor) {
$eventdata->userto = $instructor;
Expand Down
Loading

0 comments on commit 0636b8a

Please sign in to comment.