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

Commit

Permalink
add Turnitin errors page to display errors allow resubmission/deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
danmarsden committed Oct 15, 2010
1 parent 413fb62 commit 74ba90c
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 4 deletions.
7 changes: 6 additions & 1 deletion lang/en/plagiarism_turnitin.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
$string['submitonfinal'] = 'Submit file when student sends for marking';
$string['teacherlogin'] = 'Login to Turnitin as Teacher';
$string['turnitindefaults'] = 'Turnitin Defaults';
$string['turnitinerrors'] = 'Turnitin Errors';
$string['tii'] = 'Turnitin';
$string['tiiaccountid'] ='Turnitin Account ID';
$string['tiiaccountid_help'] ='This is your Account ID as provided from Turnitin.com';
Expand All @@ -88,7 +89,7 @@
$string['tiierrorpaperfail'] = 'Turnitin could not process this file.';
$string['tiierrorpending'] ='File pending submission to Turnitin';
$string['tiiexplain'] = 'Turnitin is a commercial product and you must have a paid subscription to use this service; for more information see <a href=\"http://docs.moodle.org/en/Turnitin_administration\">http://docs.moodle.org/en/Turnitin_administration</a>';
$string['tiiexplainerrors'] = 'This page lists any files submitted to Turnitin that are currently in an error state. A list of turnitin Error codes and their description is available here:<a href=\"http://docs.moodle.org/en/Turnitin_errors\">docs.moodle.org/en/Turnitin_errors</a><br/>When files are reset, the cron will attempt to submit the file to turnitin again.<br/>NOTE: files with errors in the range 1000-1999 will not benefit from being reset, and will probably always fail.';
$string['tiiexplainerrors'] = 'This page lists any files submitted to Turnitin that are currently in an error state. A list of turnitin Error codes and their description is available here:<a href=\"http://docs.moodle.org/en/Turnitin_errors\">docs.moodle.org/en/Turnitin_errors</a><br/>When files are reset, the cron will attempt to submit the file to turnitin again.<br/>When files are deleted on this page they will not be able to be resubmitted to turnitin and errors will no longer display to teachers or students';
$string['tiisecretkey'] ='Turnitin Secret Key';
$string['tiisecretkey_help'] ='Log into Turnitin.com as your site administrator to obtain this.';
$string['tiisenduseremail'] = 'Send User E-mail';
Expand All @@ -98,3 +99,7 @@
$string['turnitin_institutionnode_help'] = 'If you have setup/purchased an institution node with your account enable this to allow the node to be selected when creating assignments. NOTE: if you do not have an institution node, enabling this setting will cause your paper submission to fail.';
$string['useturnitin'] ='Enable Turnitin';
$string['wordcount'] = 'Word count';
$string['resubmit'] = 'Resubmit';
$string['fileresubmitted'] = 'File Queued for resubmission';
$string['filedeleted'] = 'File deleted from queue';
$string['module'] = 'Module';
2 changes: 1 addition & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* lib.php - Contains Turnitin soecific functions called by Modules.
*
* @since 2.0
* @package moodlecore
* @package plagiarism_turnitin
* @subpackage plagiarism
* @copyright 2010 Dan Marsden http://danmarsden.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand Down
2 changes: 1 addition & 1 deletion settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* plagiarism.php - allows the admin to configure plagiarism stuff
*
* @package administration
* @package plagiarism_turnitin
* @author Dan Marsden <dan@danmarsden.com>
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand Down
2 changes: 1 addition & 1 deletion turnitin_defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* turnitin_errors.php - Displays Turnitin files with a current error state.
*
* @package administration
* @package plagiarism_turnitin
* @author Dan Marsden <dan@danmarsden.com>
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand Down
99 changes: 99 additions & 0 deletions turnitin_errors.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?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/>.

/**
* turnitin_errors.php - Displays Turnitin files with a current error state.
*
* @package plagiarism_turnitin
* @author Dan Marsden <dan@danmarsden.com>
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

require_once(dirname(dirname(__FILE__)) . '/../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/plagiarismlib.php');
require_once($CFG->dirroot.'/plagiarism/turnitin/lib.php');
require_once('turnitin_form.php');

require_login();
admin_externalpage_setup('plagiarismturnitin');

$id = optional_param('id',0,PARAM_INT);
$resetuser = optional_param('reset',0,PARAM_INT);
$delete = optional_param('delete', 0, PARAM_INT);
$page = optional_param('page', 0, PARAM_INT);
$limit = 20;
$baseurl = new moodle_url('turnitin_errors.php', array('page' => $page));

echo $OUTPUT->header();
$currenttab='turnitinerrors';
require_once('turnitin_tabs.php');

echo $OUTPUT->box(get_string('tiiexplainerrors','plagiarism_turnitin'));
$sqlallfiles = "SELECT t.*, u.firstname, u.lastname, u.id as userid, m.name as moduletype FROM {turnitin_files} t, {user} u, {modules} m, {course_modules} cm WHERE m.id=cm.module AND cm.id=t.cm AND t.userid=u.id AND t.statuscode <>'success' AND t.statuscode <>'pending' AND t.statuscode <> '51'";
$sqlcount = "SELECT COUNT(id) FROM {turnitin_files} WHERE statuscode <>'success' AND statuscode <>'pending' AND statuscode <> '51'";
if ($resetuser==1 && $id) {
$tfile = $DB->get_record('turnitin_files', array('id'=>$id));
$tfile->statuscode = 'pending';
if ($DB->update_record('turnitin_files', $tfile)) {
notify(get_string('fileresubmitted','plagiarism_turnitin'));
}
} elseif ($resetuser==2) {
$tiifiles = get_records_sql($sqlallfiles);
foreach($tiifiles as $tiifile) {
$tiifile->statuscode = 'pending';
if ($DB->update_record('turnitin_files', $tiifile)) {
notify(get_string('fileresubmitted','plagiarism_turnitin'));
}
}
}
if (!empty($delete)) {
$DB->delete_records('turnitin_files', array('id'=>$id));
notify(get_string('filedeleted','plagiarism_turnitin'));

}

$count = $DB->count_records_sql($sqlcount);

$turnitin_files = $DB->get_records_sql($sqlallfiles." LIMIT ".$page*$limit.', '.$limit);


$table = new html_table();
$table->head = array(get_string('name'),
get_string('module', 'plagiarism_turnitin'),
get_string('file'),
get_string('status'), '');
$table->align = array ("left", "left", "left", "center", "center");
$table->width = "95%";
foreach ($turnitin_files as $tf) {
$user = "<a href='".$CFG->wwwroot."/user/profile.php?id=".$tf->userid."'>".fullname($tf)."</a>";

$reset = '<a href="turnitin_errors.php?reset=1&id='.$tf->id.'">'.get_string('resubmit','plagiarism_turnitin').'</a> | '.
'<a href="turnitin_errors.php?delete=1&id='.$tf->id.'">'.get_string('delete').'</a>';
$cmlink = '<a href="'.$CFG->wwwroot.'/'.$tf->moduletype.'/view.php?id='.$tf->cm.'">'.get_string('module', 'plagiarism_turnitin').'</a>';
$table->data[] = array ($user,
$cmlink,
$tf->identifier,
$tf->statuscode,
$reset);
}
if (!empty($table)) {
echo html_writer::table($table);
echo $OUTPUT->paging_bar($count, $page, $limit, $baseurl);
}

echo $OUTPUT->footer();
2 changes: 2 additions & 0 deletions turnitin_tabs.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php
$strplagiarism = get_string('turnitin', 'plagiarism_turnitin');
$strplagiarismdefaults = get_string('turnitindefaults', 'plagiarism_turnitin');
$strplagiarismerrors = get_string('turnitinerrors', 'plagiarism_turnitin');

$tabs = array();
$tabs[] = new tabobject('turnitinsettings', 'settings.php', $strplagiarism, $strplagiarism, false);
$tabs[] = new tabobject('turnitindefaults', 'turnitin_defaults.php', $strplagiarismdefaults, $strplagiarismdefaults, false);
$tabs[] = new tabobject('turnitinerrors', 'turnitin_errors.php', $strplagiarismerrors, $strplagiarismerrors, false);
print_tabs(array($tabs), $currenttab);

0 comments on commit 74ba90c

Please sign in to comment.