public function show_file_errors_table($page = 0) { global $CFG, $OUTPUT; $limit = 100; $offset = $page * $limit; $plagiarismpluginturnitin = new plagiarism_plugin_turnitin(); $filescount = $plagiarismpluginturnitin->get_file_upload_errors(0, 0, true); $files = $plagiarismpluginturnitin->get_file_upload_errors($offset, $limit); $baseurl = new moodle_url('/plagiarism/turnitin/settings.php', array('do' => 'errors')); $pagingbar = $OUTPUT->paging_bar($filescount, $page, $limit, $baseurl); // Do the table headers. $cells = array(); $selectall = html_writer::checkbox('errors_select_all', false, false, '', array("class" => "select_all_checkbox")); $cells["checkbox"] = new html_table_cell($selectall); $cells["id"] = new html_table_cell(get_string('id', 'plagiarism_turnitin')); $cells["user"] = new html_table_cell(get_string('student', 'plagiarism_turnitin')); $cells["user"]->attributes['class'] = 'left'; $cells["course"] = new html_table_cell(get_string('course', 'plagiarism_turnitin')); $cells["module"] = new html_table_cell(get_string('module', 'plagiarism_turnitin')); $cells["file"] = new html_table_cell(get_string('file')); $cells["error"] = new html_table_cell(get_string('error')); $cells["delete"] = new html_table_cell(' '); $cells["delete"]->attributes['class'] = 'centered_cell'; $table = new html_table(); $table->head = $cells; $i = 0; $rows = array(); if (count($files) == 0) { $cells = array(); $cells["checkbox"] = new html_table_cell(get_string('semptytable', 'plagiarism_turnitin')); $cells["checkbox"]->colspan = 8; $cells["checkbox"]->attributes['class'] = 'centered_cell'; $rows[0] = new html_table_row($cells); } else { foreach ($files as $k => $v) { $cells = array(); if (!empty($v->moduletype) && $v->moduletype != "forum") { $cm = get_coursemodule_from_id($v->moduletype, $v->cm); $checkbox = html_writer::checkbox('check_' . $k, $k, false, '', array("class" => "errors_checkbox")); $cells["checkbox"] = new html_table_cell($checkbox); $cells["id"] = new html_table_cell($k); $cells["user"] = new html_table_cell($v->firstname . " " . $v->lastname . " (" . $v->email . ")"); $courselink = new moodle_url($CFG->wwwroot . '/course/view.php', array('id' => $v->courseid)); $cells["course"] = new html_table_cell(html_writer::link($courselink, $v->coursename, array('title' => $v->coursename))); $modulelink = new moodle_url($CFG->wwwroot . '/mod/' . $v->moduletype . '/view.php', array('id' => $v->cm)); $cells["module"] = new html_table_cell(html_writer::link($modulelink, $cm->name, array('title' => $cm->name))); if ($v->submissiontype == "file") { $fs = get_file_storage(); if ($file = $fs->get_file_by_hash($v->identifier)) { $cells["file"] = new html_table_cell(html_writer::link($CFG->wwwroot . '/pluginfile.php/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . '/' . $file->get_itemid() . '/' . $file->get_filename(), $OUTPUT->pix_icon('fileicon', 'open ' . $file->get_filename(), 'plagiarism_turnitin') . " " . $file->get_filename())); } else { $cells["file"] = get_string('filedoesnotexist', 'plagiarism_turnitin'); } } else { $cells["file"] = str_replace('_', ' ', ucfirst($v->submissiontype)); } $errorcode = $v->errorcode; // Deal with legacy error issues. if (is_null($errorcode)) { $errorcode = 0; if ($v->submissiontype == 'file') { if (is_object($file) && $file->get_filesize() > TURNITINTOOLTWO_MAX_FILE_UPLOAD_SIZE) { $errorcode = 2; } } } // Show error message if there is one. $errormsg = $v->errormsg; if ($errorcode == 0) { $errorstring = is_null($errormsg) ? get_string('ppsubmissionerrorseelogs', 'plagiarism_turnitin') : $errormsg; } else { $errorstring = get_string('errorcode' . $v->errorcode, 'plagiarism_turnitin', display_size(TURNITINTOOLTWO_MAX_FILE_UPLOAD_SIZE)); } $cells["error"] = $errorstring; $fnd = array("\n", "\r"); $rep = array('\\n', '\\r'); $string = str_replace($fnd, $rep, get_string('deleteconfirm', 'plagiarism_turnitin')); $attributes["onclick"] = "return confirm('" . $string . "');"; $cells["delete"] = new html_table_cell(html_writer::link($CFG->wwwroot . '/plagiarism/turnitin/settings.php?do=errors&action=deletefile&id=' . $k, $OUTPUT->pix_icon('delete', get_string('deletesubmission', 'plagiarism_turnitin'), 'plagiarism_turnitin'), $attributes)); $cells["delete"]->attributes['class'] = 'centered_cell'; $rows[$i] = new html_table_row($cells); $i++; } } if ($i == 0) { $cells = array(); $cells["checkbox"] = new html_table_cell(get_string('semptytable', 'plagiarism_turnitin')); $cells["checkbox"]->colspan = 8; $cells["checkbox"]->attributes['class'] = 'centered_cell'; $rows[0] = new html_table_row($cells); } else { $table->id = "ppErrors"; } } $table->data = $rows; $output = html_writer::table($table); return $pagingbar . $output . $pagingbar; }
$DB->insert_record('plagiarism_turnitin_config', $moduleconfigvalue); } } else { $return["status"] = $pluginturnitin->update_grade_from_tii($cm, $submissionid); } break; case "refresh_peermark_assignments": if (!confirm_sesskey()) { throw new moodle_exception('invalidsesskey', 'error'); } $tiiassignment = $DB->get_record('plagiarism_turnitin_config', array('cm' => $cm->id, 'name' => 'turnitin_assignid')); $pluginturnitin->refresh_peermark_assignments($cm, $tiiassignment->value); break; case "peermarkmanager": if ($userrole == 'Instructor') { $plagiarism_plugin_turnitin = new plagiarism_plugin_turnitin(); $coursedata = $plagiarism_plugin_turnitin->get_course_data($cm->id, $cm->course); $tiiassignment = $DB->get_record('plagiarism_turnitin_config', array('cm' => $cm->id, 'name' => 'turnitin_assignid')); if ($tiiassignment) { $tiiassignmentid = $tiiassignment->value; } else { // Create the module as an assignment in Turnitin. $tiiassignment = $pluginturnitin->sync_tii_assignment($cm, $coursedata->turnitin_cid); $tiiassignmentid = $tiiassignment['tiiassignmentid']; } $user = new turnitintooltwo_user($USER->id, "Instructor"); $user->join_user_to_class($coursedata->turnitin_cid); echo html_writer::tag("div", turnitintooltwo_view::output_lti_form_launch('peermark_manager', 'Instructor', $tiiassignmentid), array("class" => "launch_form", "style" => "display:none;")); echo html_writer::script("<!--\n window.document.forms[0].submit();\n //-->"); } break;
/** * Handle cron call from scheduled task */ function plagiarism_turnitin_cron() { $pluginturnitin = new plagiarism_plugin_turnitin(); return $pluginturnitin->cron(); }
$courseid = required_param('course', PARAM_INT); $assignmentid = required_param('assignment', PARAM_INT); $modulename = required_param('modulename', PARAM_ALPHA); if (has_capability('moodle/course:update', context_course::instance($courseid))) { // Set Rubric options to instructor rubrics. $instructor = new turnitintooltwo_user($USER->id, 'Instructor'); $instructor->set_user_values_from_tii(); $instructorrubrics = $instructor->get_instructor_rubrics(); $options = array('' => get_string('norubric', 'turnitintooltwo')) + $instructorrubrics; // Add in rubric if the selected rubric belongs to another instructor. if (!empty($assignmentid)) { if ($modulename == "turnitintooltwo") { $turnitintooltwoassignment = new turnitintooltwo_assignment($assignmentid); } else { require_once $CFG->dirroot . '/plagiarism/turnitin/lib.php'; $pluginturnitin = new plagiarism_plugin_turnitin(); $cm = get_coursemodule_from_instance($modulename, $assignmentid); $plagiarismsettings = $pluginturnitin->get_settings($cm->id); } if ($modulename == "turnitintooltwo") { if (!empty($turnitintooltwoassignment->turnitintooltwo->rubric)) { $options[$turnitintooltwoassignment->turnitintooltwo->rubric] = isset($options[$turnitintooltwoassignment->turnitintooltwo->rubric]) ? $options[$turnitintooltwoassignment->turnitintooltwo->rubric] : get_string('otherrubric', 'turnitintooltwo'); } } else { if (!empty($plagiarismsettings["plagiarism_rubric"])) { $options[$plagiarismsettings["plagiarism_rubric"]] = isset($options[$plagiarismsettings["plagiarism_rubric"]]) ? $options[$plagiarismsettings["plagiarism_rubric"]] : get_string('otherrubric', 'turnitintooltwo'); } } } } else { $options = array();
require_once __DIR__ . "/turnitinplugin_view.class.php"; $turnitinpluginview = new turnitinplugin_view(); require_login(); admin_externalpage_setup('plagiarismturnitin'); $context = context_system::instance(); require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions"); $do = optional_param('do', "config", PARAM_ALPHA); $action = optional_param('action', "", PARAM_ALPHA); if (isset($_SESSION["notice"])) { $notice = $_SESSION["notice"]; $notice["type"] = empty($_SESSION["notice"]["type"]) ? "general" : $_SESSION["notice"]["type"]; unset($_SESSION["notice"]); } else { $notice = null; } $plagiarismpluginturnitin = new plagiarism_plugin_turnitin(); $supported_mods = array('assign', 'forum', 'workshop'); // Get plugin config. $pluginconfig = array(); $pluginconfig['turnitin_use'] = get_config('plagiarism', 'turnitin_use'); // Check that mod enabled setting has been initialised. foreach ($supported_mods as $mod) { $pluginconfig['turnitin_use_mod_' . $mod] = $plagiarismpluginturnitin->get_config_settings('mod_' . $mod); } $plugindefaults = $plagiarismpluginturnitin->get_settings(); // Save Settings. if (!empty($action)) { switch ($action) { case "config": // Overall plugin use setting $turnitinoveralluse = optional_param('turnitin_use', 0, PARAM_INT);
/** * Upload content to Turnitin * * @param type $eventdata * @return type */ function plagiarism_turnitin_event_content_uploaded($eventdata) { $eventdata->event_type = 'content_uploaded'; $pluginturnitin = new plagiarism_plugin_turnitin(); return $pluginturnitin->event_handler($eventdata); }
admin_externalpage_setup('plagiarismturnitin'); $context = get_context_instance(CONTEXT_SYSTEM); $fileid = optional_param('fileid', 0, PARAM_INT); $resetuser = optional_param('reset', 0, PARAM_INT); $page = optional_param('page', 0, PARAM_INT); $mform = new turnitin_defaults_form(null); $plagiarismdefaults = $DB->get_records_menu('plagiarism_turnitin_config', array('cm' => 0), '', 'name,value'); //cmid(0) is the default list. if (!empty($plagiarismdefaults)) { $mform->set_data($plagiarismdefaults); } echo $OUTPUT->header(); $currenttab = 'turnitindefaults'; require_once 'turnitin_tabs.php'; if (($data = $mform->get_data()) && confirm_sesskey()) { $plagiarismplugin = new plagiarism_plugin_turnitin(); $plagiarismelements = $plagiarismplugin->config_options(); foreach ($plagiarismelements as $element) { if (isset($data->{$element})) { $newelement = new object(); $newelement->cm = 0; $newelement->name = $element; $newelement->value = $data->{$element}; if (isset($plagiarismdefaults[$element])) { //update $newelement->id = $DB->get_field('plagiarism_turnitin_config', 'id', array('cm' => 0, 'name' => $element)); $DB->update_record('plagiarism_turnitin_config', $newelement); } else { //insert $DB->insert_record('plagiarism_turnitin_config', $newelement); }
require_once __DIR__ . "/lib.php"; require_once $CFG->dirroot . '/mod/turnitintooltwo/turnitintooltwo_assignment.class.php'; require_once $CFG->dirroot . '/mod/turnitintooltwo/turnitintooltwo_view.class.php'; require_login(); $action = required_param('action', PARAM_ALPHAEXT); $cmid = optional_param('cmid', 0, PARAM_INT); $itemid = optional_param('itemid', 0, PARAM_INT); if (!empty($cmid)) { $cm = get_coursemodule_from_id('', $cmid); $context = context_course::instance($cm->course); } $pathnamehash = optional_param('pathnamehash', "", PARAM_ALPHANUM); $submissiontype = optional_param('submission_type', "", PARAM_ALPHAEXT); $return = array(); // Initialise plugin class. $pluginturnitin = new plagiarism_plugin_turnitin(); switch ($action) { case "process_submission": if (!confirm_sesskey()) { throw new moodle_exception('invalidsesskey', 'error'); } $cansubmit = $cm->modname == "forum" ? has_capability('mod/' . $cm->modname . ':replypost', $context) : has_capability('mod/' . $cm->modname . ':submit', $context) || has_capability('mod/' . $cm->modname . ':grade', $context); $textcontent = $cm->modname == "forum" ? optional_param('textcontent', "", PARAM_ALPHAEXT) : ''; if ($cansubmit) { // Create the course/class in Turnitin if it doesn't already exist. $coursedata = turnitintooltwo_assignment::get_course_data($cm->course, 'PP'); if (empty($coursedata->turnitin_cid)) { // Course may existed in a previous incarnation of this plugin so the Turnitin id may be located // in the config table. Get this and save it in courses table if so. if ($turnitincid = $pluginturnitin->get_previous_course_id($cm)) { $coursedata = $pluginturnitin->migrate_previous_course($coursedata, $turnitincid);
$userrole = has_capability('mod/' . $cm->modname . ':grade', $context) ? 'Instructor' : 'Learner'; break; } $PAGE->set_context(context_system::instance()); require_login(); switch ($cmd) { case "origreport": case "grademark": $submissionid = required_param('submissionid', PARAM_INT); $user = new turnitintooltwo_user($USER->id, $userrole); $coursedata = turnitintooltwo_assignment::get_course_data($cm->course, 'PP'); if ($userrole == 'Instructor') { $user->join_user_to_class($coursedata->turnitin_cid); } // Edit assignment in Turnitin in case any changes have been made that would affect DV. $pluginturnitin = new plagiarism_plugin_turnitin(); $syncassignment = $pluginturnitin->sync_tii_assignment($cm, $coursedata->turnitin_cid); if ($syncassignment['success']) { echo html_writer::tag("div", $turnitintooltwoview->output_dv_launch_form($cmd, $submissionid, $user->tii_user_id, $userrole, ''), array("class" => "launch_form")); echo html_writer::script("<!--\n window.document.forms[0].submit();\n //-->"); } exit; break; case "useragreement": $PAGE->set_pagelayout('embedded'); if ($CFG->branch <= 25) { $jsurl = new moodle_url($CFG->wwwroot . '/plagiarism/turnitin/jquery/jquery-1.8.2.min.js'); $PAGE->requires->js($jsurl, true); $jsurl = new moodle_url($CFG->wwwroot . '/plagiarism/turnitin/jquery/jquery-ui-1.10.4.custom.min.js'); $PAGE->requires->js($jsurl, true); $jsurl = new moodle_url($CFG->wwwroot . '/plagiarism/turnitin/jquery/turnitin_module.js');
function turnitin_event_mod_deleted($eventdata) { $eventdata->eventtype = 'mod_deleted'; $turnitin = new plagiarism_plugin_turnitin(); return $turnitin->event_handler($eventdata); }
* @package plagiarism_turnitin * @author Dan Marsden <*****@*****.**> * @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_login(); admin_externalpage_setup('plagiarismturnitin'); $context = get_context_instance(CONTEXT_SYSTEM); require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions"); require_once 'turnitin_form.php'; $mform = new turnitin_setup_form(); $plagiarismplugin = new plagiarism_plugin_turnitin(); $plagiarismsettings = $plagiarismplugin->get_settings(); if ($mform->is_cancelled()) { redirect(''); } echo $OUTPUT->header(); $currenttab = 'turnitinsettings'; require_once 'turnitin_tabs.php'; if (($data = $mform->get_data()) && confirm_sesskey()) { if (!isset($data->turnitin_use)) { $data->turnitin_use = 0; } if (!isset($data->turnitin_enablegrademark)) { $data->turnitin_enablegrademark = 0; } if (!isset($data->turnitin_senduseremail)) {