Skip to content
This repository has been archived by the owner on Jun 15, 2020. It is now read-only.

Commit

Permalink
Turnitin - tidy up code based on codechecker tool, ignoring line leng…
Browse files Browse the repository at this point in the history
…th check, some commented code and an if/else statemetn that looks tidier in it's current form than using Moodle standard.
  • Loading branch information
danmarsden committed Feb 1, 2012
1 parent dba8e21 commit c42d5d4
Show file tree
Hide file tree
Showing 16 changed files with 472 additions and 387 deletions.
3 changes: 2 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Moodle Turnitin Plagiarism Plugin written by Dan Marsden <dan@danmarsden.com>

for installation/configuration information see: http://docs.moodle.org/en/Plagiarism_Prevention_Turnitin
for installation/configuration information see:
http://docs.moodle.org/en/Plagiarism_Prevention_Turnitin
20 changes: 17 additions & 3 deletions backup/moodle2/backup_plagiarism_turnitin_plugin.class.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
<?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/>.

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


class backup_plagiarism_turnitin_plugin extends backup_plagiarism_plugin {
function define_module_plugin_structure() {
protected function define_module_plugin_structure() {
// To know if we are including userinfo
$userinfo = $this->get_setting_value('userinfo');

Expand All @@ -26,7 +40,7 @@ function define_module_plugin_structure() {
//now information about files to module
$turnitinfiles = new backup_nested_element('turnitin_files');
$turnitinfile = new backup_nested_element('turnitin_file', array('id'),
array('userid', 'identifier','externalid','externalstatus','statuscode','similarityscore'));
array('userid', 'identifier', 'externalid', 'externalstatus', 'statuscode', 'similarityscore'));

$pluginwrapper->add_child($turnitinfiles);
$turnitinfiles->add_child($turnitinfile);
Expand All @@ -36,7 +50,7 @@ function define_module_plugin_structure() {
return $plugin;
}

function define_course_plugin_structure() {
protected function define_course_plugin_structure() {
// Define the virtual plugin element without conditions as the global class checks already.
$plugin = $this->get_plugin_element();

Expand Down
16 changes: 15 additions & 1 deletion backup/moodle2/restore_plagiarism_turnitin_plugin.class.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
<?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/>.

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

Expand Down Expand Up @@ -26,7 +40,7 @@ public function process_turnitinconfig($data) {

if ($this->task->is_samesite()) { //files can only be restored if this is the same site as was backed up.
//check to see if this plagiarism id already exists in a different course.
$recexists = $DB->record_exists_select('config_plugins', "plugin = ? AND ".$DB->sql_compare_text('value',10). " = ?", array($data->plugin, $data->value));
$recexists = $DB->record_exists_select('config_plugins', "plugin = ? AND ".$DB->sql_compare_text('value', 10). " = ?", array($data->plugin, $data->value));
if ($data->name == $this->task->get_courseid() || !$recexists) {
//only restore if a link to this course doesn't already exist in this install.
$this->existingcourse = false;
Expand Down
14 changes: 14 additions & 0 deletions db/access.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
<?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/>.

$capabilities = array(

Expand Down
14 changes: 14 additions & 0 deletions db/events.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
<?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/>.

$handlers = array (

Expand Down
19 changes: 17 additions & 2 deletions db/install.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
<?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/>.

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

function xmldb_plagiarism_turnitin_install() {
Expand All @@ -12,8 +27,8 @@ function xmldb_plagiarism_turnitin_install() {
//now insert field
$newfield = new stdClass();
$newfield->shortname = 'turnitinteachercoursecache';
$newfield->name = get_string('userprofileteachercache','plagiarism_turnitin');
$newfield->description = get_string('userprofileteachercache_desc','plagiarism_turnitin');
$newfield->name = get_string('userprofileteachercache', 'plagiarism_turnitin');
$newfield->description = get_string('userprofileteachercache_desc', 'plagiarism_turnitin');
$newfield->datatype = 'text';
$newfield->descriptionformat = 1;
$newfield->categoryid = $catid;
Expand Down
2 changes: 1 addition & 1 deletion db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
</XMLDB>
37 changes: 17 additions & 20 deletions db/upgrade.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
<?php

// This file keeps track of upgrades to
// the plagiarism Turnitin module
//
// Sometimes, changes between versions involve
// alterations to database structures and other
// major things that may break installations.
// This file is part of Moodle - http://moodle.org/
//
// The upgrade function in this file will attempt
// to perform all the necessary actions to upgrade
// your older installation to the current version.
// 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.
//
// If there's something it cannot do itself, it
// will tell you what you need to do.
// 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.
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

// This file keeps track of upgrades to
// the plagiarism Turnitin module

/**
* @global moodle_database $DB
Expand All @@ -35,7 +32,7 @@ function xmldb_plagiarism_turnitin_upgrade($oldversion) {
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_plugin_savepoint(true, 2011041200, 'plagiarism','turnitin');
upgrade_plugin_savepoint(true, 2011041200, 'plagiarism', 'turnitin');
}

if ($oldversion < 2011083100) {
Expand Down Expand Up @@ -118,8 +115,8 @@ function xmldb_plagiarism_turnitin_upgrade($oldversion) {
//now insert field
$newfield = new stdClass();
$newfield->shortname = 'turnitinteachercoursecache';
$newfield->name = get_string('userprofileteachercache','plagiarism_turnitin');
$newfield->description = get_string('userprofileteachercache_desc','plagiarism_turnitin');
$newfield->name = get_string('userprofileteachercache', 'plagiarism_turnitin');
$newfield->description = get_string('userprofileteachercache_desc', 'plagiarism_turnitin');
$newfield->datatype = 'text';
$newfield->descriptionformat = 1;
$newfield->categoryid = $catid;
Expand Down
Loading

0 comments on commit c42d5d4

Please sign in to comment.