/** * Synchronises the assignment part settings with the settings that Turnitin has for the assignment parts * * @global object * @param object $cm The moodle course module object for this instance * @param object $turnitintool The turnitintool object for this activity * @param boolean $forced True if we want ot force the operation otherwise determined by a session array updatedconfig * @param object $loaderbar Passed by reference can be NULL if no loader bar is used * @return boolean Returns false on failure */ function turnitintool_synch_parts($cm, $turnitintool, $forced = false, $loaderbar = NULL) { $param_type = optional_param('type', null, PARAM_CLEAN); if ((isset($_SESSION['updatedconfig'][$turnitintool->id]) and $_SESSION['updatedconfig'][$turnitintool->id] == 1 or !is_null($param_type)) and !$forced) { return false; } else { if (!($parts = turnitintool_get_records_select('turnitintool_parts', 'turnitintoolid=' . $turnitintool->id . ' AND deleted=0'))) { mtrace(get_string('partgeterror', 'turnitintool') . ' - ID: ' . $turnitintool->id . '\\n'); } $partsarray = array(); $owner = turnitintool_get_owner($turnitintool->course); $tii = new turnitintool_commclass(turnitintool_getUID($owner), $owner->firstname, $owner->lastname, $owner->email, 2, $loaderbar); $tii->startSession(); $tiitooldone = false; foreach ($parts as $part) { $post = new stdClass(); $post->cid = turnitintool_getCID($turnitintool->course); $post->ctl = turnitintool_getCTL($turnitintool->course); $post->assign = $turnitintool->name . ' - ' . $part->partname . ' (Moodle: ' . $part->tiiassignid . ')'; $post->assignid = $part->tiiassignid; $post->assignid = $part->maxmarks; $tii->queryAssignment($post, get_string('synchassignments', 'turnitintool')); $assignObj = $tii->getAssignmentObject(); if (!$tii->getRerror()) { if (!$tiitooldone) { $tiiupdate = new stdClass(); $tiiupdate->id = $turnitintool->id; $tiiupdate->anon = $assignObj->anon; $tiiupdate->reportgenspeed = $assignObj->report_gen_speed; $tiiupdate->studentreports = $assignObj->s_view_report; $tiiupdate->allowlate = $assignObj->late_accept_flag; $tiiupdate->submitpapersto = $assignObj->submit_papers_to; $tiiupdate->internetcheck = $assignObj->internet_check; $tiiupdate->journalcheck = $assignObj->journal_check; if (!($update = turnitintool_update_record('turnitintool', $tiiupdate))) { mtrace(get_string('turnitintoolupdateerror', 'turnitintool') . ' - ID: ' . $turnitintool->id . '\\n'); } $partupdate = new stdClass(); $partupdate->id = $part->id; $partupdate->maxmarks = $assignObj->maxpoints; $partupdate->dtstart = $assignObj->dtstart; $partupdate->dtdue = $assignObj->dtdue; $partupdate->dtpost = $assignObj->dtpost; if (!($update = turnitintool_update_record('turnitintool_parts', $partupdate))) { mtrace(get_string('partupdateerror', 'turnitintool') . ' - ID: ' . $part->id . '\\n'); } } } } $tii->endSession(); } }
if (!is_null($param_part)) { if (!has_capability('mod/turnitintool:grade', turnitintool_get_context('MODULE', $cm->id))) { turnitintool_print_error('permissiondeniederror', 'turnitintool', NULL, NULL, __FILE__, __LINE__); exit; } $owner = turnitintool_get_owner($course->id); $loaderbar = null; $tii = new turnitintool_commclass(turnitintool_getUID($owner), $owner->firstname, $owner->lastname, $owner->email, 2, $loaderbar); $post = new stdClass(); $post->cid = turnitintool_getCID($course->id); $post->assignid = turnitintool_getAID($param_part); $post->ctl = turnitintool_getCTL($course->id); $post->assign = $turnitintool->name . ' - ' . turnitintool_partnamefromnum($param_part) . ' (Moodle ' . $post->assignid . ')'; $post->fcmd = 4; $tii->listSubmissions($post, get_string('downloadingfile', 'turnitintool')); if ($tii->getRerror()) { if (!$tii->getAPIunavailable()) { $reason = $tii->getRcode() == TURNITINTOOL_DB_UNIQUEID_ERROR ? get_string('assignmentdoesnotexist', 'turnitintool') : $tii->getRmessage(); } else { $reason = get_string('apiunavailable', 'turnitintool'); } turnitintool_print_error('downloadingfileerror', 'turnitintool', NULL, NULL, __FILE__, __LINE__); exit; } else { $output = $tii->getFileData(); if (function_exists('mb_strlen')) { $size = mb_strlen($output, '8bit'); } else { $size = strlen($output); } header("Pragma: public");
/** * @package turnitintool * @copyright 2012 Turnitin */ function xmldb_turnitintool_upgrade($oldversion) { global $CFG, $THEME, $DB, $OUTPUT; $result = true; // Do necessary DB upgrades here //function add_field($name, $type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) // Newer DB Man ($name, $type=null, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) if ($result && $oldversion < 2009071501) { if (is_callable(array($DB, 'get_manager'))) { $dbman = $DB->get_manager(); $table = new xmldb_table('turnitintool_submissions'); $field = new xmldb_field('submission_gmimaged', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'submission_grade'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } } else { $table = new XMLDBTable('turnitintool_submissions'); $field = new XMLDBField('submission_gmimaged'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'submission_grade'); $result = $result && add_field($table, $field); } } if ($result && $oldversion < 2009091401) { if (is_callable(array($DB, 'get_manager'))) { $dbman = $DB->get_manager(); $table = new xmldb_table('turnitintool'); $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, null, null, '0', 'intro'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } } else { $table = new XMLDBTable('turnitintool'); $field = new XMLDBField('introformat'); $field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, null, null, '0', 'intro'); $result = $result && add_field($table, $field); } } if ($result && $oldversion < 2009092901) { if (is_callable(array($DB, 'get_manager'))) { $dbman = $DB->get_manager(); $table1 = new xmldb_table('turnitintool'); $field1 = new xmldb_field('resubmit', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, '0', 'defaultdtpost'); if ($dbman->field_exists($table1, $field1)) { $dbman->rename_field($table1, $field1, 'anon'); } $table2 = new xmldb_table('turnitintool_submissions'); $field2 = new xmldb_field('submission_unanon', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, NULL, null, null, null, '0', 'submission_nmlastname'); $field3 = new xmldb_field('submission_unanonreason', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'submission_unanon'); $field4 = new xmldb_field('submission_nmuserid', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null); if (!$dbman->field_exists($table2, $field2)) { $dbman->add_field($table2, $field2); } if (!$dbman->field_exists($table2, $field3)) { $dbman->add_field($table2, $field3); } $dbman->change_field_type($table2, $field4); } else { $table1 = new XMLDBTable('turnitintool'); $field1 = new XMLDBField('resubmit'); $field1->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, '0', 'defaultdtpost'); $result = $result && rename_field($table1, $field1, 'anon'); $table2 = new XMLDBTable('turnitintool_submissions'); $field2 = new XMLDBField('submission_unanon'); $field3 = new XMLDBField('submission_unanonreason'); $field4 = new XMLDBField('submission_nmuserid'); $field2->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, '0', 'submission_nmlastname'); $result = $result && add_field($table2, $field2); $field3->setAttributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, 'submission_unanon'); $result = $result && add_field($table2, $field3); $field4->setAttributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, null); $result = $result && change_field_type($table2, $field4); } } if ($result && $oldversion < 2009120501) { if (is_callable(array($DB, 'get_manager'))) { $dbman = $DB->get_manager(); // Launch add index userid $table = new xmldb_table('turnitintool_submissions'); $index = new xmldb_index('userid', XMLDB_INDEX_NOTUNIQUE, array('userid')); if (!$dbman->index_exists($table, $index)) { $dbman->add_index($table, $index); } // Launch add index turnitintoolid $table = new xmldb_table('turnitintool_submissions'); $index = new xmldb_index('turnitintoolid', XMLDB_INDEX_NOTUNIQUE, array('turnitintoolid')); if (!$dbman->index_exists($table, $index)) { $dbman->add_index($table, $index); } } else { $table = new XMLDBTable('turnitintool_submissions'); // Launch add index userid $index = new XMLDBIndex('userid'); $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('userid')); if (index_exists($table, $index)) { $result = $result && add_index($table, $index); } // Launch add index turnitintoolid $index = new XMLDBIndex('turnitintoolid'); $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('turnitintoolid')); if (index_exists($table, $index)) { $result = $result && add_index($table, $index); } } } if ($result && $oldversion < 2010012201) { if (is_callable(array($DB, 'get_manager'))) { $dbman = $DB->get_manager(); // Fix fields where '' has been used $DB->execute("UPDATE " . $CFG->prefix . "turnitintool_submissions SET submission_score=NULL WHERE submission_score=''"); $DB->execute("UPDATE " . $CFG->prefix . "turnitintool_submissions SET submission_grade=NULL WHERE submission_grade=''"); $DB->execute("UPDATE " . $CFG->prefix . "turnitintool_submissions SET submission_objectid=NULL WHERE submission_objectid=''"); $table = new xmldb_table('turnitintool_submissions'); $field1 = new xmldb_field('submission_score', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, NULL, null, null, null, null, 'submission_objectid'); $field2 = new xmldb_field('submission_grade', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, NULL, null, null, null, null, 'submission_score'); $field3 = new xmldb_field('submission_objectid', XMLDB_TYPE_INTEGER, '50', XMLDB_UNSIGNED, NULL, null, null, null, null, 'submission_filename'); $dbman->change_field_type($table, $field1); $dbman->change_field_type($table, $field2); $dbman->change_field_type($table, $field3); } else { $table = new XMLDBTable('turnitintool_submissions'); $field1 = new XMLDBField('submission_score'); $field2 = new XMLDBField('submission_grade'); $field3 = new XMLDBField('submission_objectid'); // Fix fields where '' has been used execute_sql("UPDATE " . $CFG->prefix . "turnitintool_submissions SET submission_score=NULL WHERE submission_score=''"); execute_sql("UPDATE " . $CFG->prefix . "turnitintool_submissions SET submission_grade=NULL WHERE submission_grade=''"); execute_sql("UPDATE " . $CFG->prefix . "turnitintool_submissions SET submission_objectid=NULL WHERE submission_objectid=''"); $field1->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'submission_objectid'); $result = $result && change_field_type($table, $field1); $field2->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'submission_score'); $result = $result && change_field_type($table, $field2); $field3->setAttributes(XMLDB_TYPE_INTEGER, '50', XMLDB_UNSIGNED, null, null, null, null, null, 'submission_filename'); $result = $result && change_field_type($table, $field3); } } if ($result && $oldversion < 2010021901) { require_once $CFG->dirroot . "/mod/turnitintool/lib.php"; $loaderbar = NULL; if (turnitintool_check_config()) { $tii = new turnitintool_commclass("", "FID99", "Turnitin", "*****@*****.**", "2", $loaderbar, false); $tii->migrateSRCData(); if (is_callable(array($DB, 'get_manager'))) { if (!$tii->getRerror()) { echo $OUTPUT->notification("Migrating Turnitin SRC Namespace: " . $tii->getRmessage(), 'notifysuccess'); } else { echo $OUTPUT->notification("Migrating Turnitin SRC Namespace: " . $tii->getRmessage()); } } else { if (!$tii->getRerror()) { notify($tii->getRmessage(), 'notifysuccess'); } else { notify($tii->getRmessage()); } } $result = $result && !$tii->getRerror(); } } if ($result && $oldversion < 2010090701) { $table = 'config'; $dataobject->name = 'turnitin_userepository'; $dataobject->value = 1; if (is_callable(array($DB, 'get_manager'))) { $DB->insert_record($table, $dataobject); } else { insert_record($table, $dataobject); } } if ($result && $oldversion < 2010102601) { if (is_callable(array($DB, 'get_manager'))) { $dbman = $DB->get_manager(); // Change the field size from 50 to 20 to add oracle compatibility $table1 = new xmldb_table('turnitintool_submissions'); $field1 = new xmldb_field('submission_objectid', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, NULL, null, null, 'submission_filename'); $field2 = new xmldb_field('submission_nmuserid', XMLDB_TYPE_CHAR, '100', XMLDB_UNSIGNED, NULL, null, null, 'submission_parent'); $dbman->change_field_type($table1, $field1); $dbman->change_field_type($table1, $field2); // Add the exclude small matches db fields $table2 = new xmldb_table('turnitintool'); $field3 = new xmldb_field('excludebiblio', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'shownonsubmission'); $field4 = new xmldb_field('excludequoted', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'excludebiblio'); $field5 = new xmldb_field('excludevalue', XMLDB_TYPE_INTEGER, '9', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'excludequoted'); $field6 = new xmldb_field('excludetype', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 1, 'excludevalue'); $field7 = new xmldb_field('perpage', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 25, 'excludetype'); if (!$dbman->field_exists($table2, $field3)) { $dbman->add_field($table2, $field3); } if (!$dbman->field_exists($table2, $field4)) { $dbman->add_field($table2, $field4); } if (!$dbman->field_exists($table2, $field5)) { $dbman->add_field($table2, $field5); } if (!$dbman->field_exists($table2, $field6)) { $dbman->add_field($table2, $field6); } if (!$dbman->field_exists($table2, $field7)) { $dbman->add_field($table2, $field7); } // Rename table fields to add Oracle compatibility $table3 = new xmldb_table('turnitintool_comments'); $field8 = new xmldb_field('comment', XMLDB_TYPE_TEXT, 'medium', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'userid'); $dbman->rename_field($table3, $field8, "commenttext"); $field9 = new xmldb_field('date', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'comment'); $dbman->rename_field($table3, $field9, "dateupdated"); } else { // Change the field size from 50 to 20 to add oracle compatibility $table1 = new XMLDBTable('turnitintool_submissions'); $field1 = new XMLDBField('submission_objectid'); $field2 = new XMLDBField('submission_nmuserid'); $field1->setAttributes(XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, null, null, null, null, null, 'submission_filename'); $field2->setAttributes(XMLDB_TYPE_CHAR, '100', XMLDB_UNSIGNED, null, null, null, null, null, 'submission_parent'); $result = $result && change_field_type($table1, $field1); $result = $result && change_field_type($table1, $field2); // Add the exclude small matches db fields $table2 = new XMLDBTable('turnitintool'); $field3 = new XMLDBField('excludebiblio'); $field4 = new XMLDBField('excludequoted'); $field5 = new XMLDBField('excludevalue'); $field6 = new XMLDBField('excludetype'); $field7 = new XMLDBField('perpage'); $field3->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'shownonsubmission'); $result = $result && add_field($table2, $field3); $field4->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'excludebiblio'); $result = $result && add_field($table2, $field4); $field5->setAttributes(XMLDB_TYPE_INTEGER, '9', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'excludequoted'); $result = $result && add_field($table2, $field5); $field6->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 1, 'excludevalue'); $result = $result && add_field($table2, $field6); $field7->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 25, 'excludetype'); $result = $result && add_field($table2, $field7); // Rename table fields to add Oracle compatibility $table3 = new XMLDBTable('turnitintool_comments'); $field8 = new XMLDBField('comment'); $field8->setAttributes(XMLDB_TYPE_TEXT, 'medium', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'userid'); $result = $result && rename_field($table3, $field8, "commenttext"); $field9 = new XMLDBField('date'); $field9->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'comment'); $result = $result && rename_field($table3, $field9, "dateupdated"); } } if ($result && $oldversion < 2011030101) { if (is_callable(array($DB, 'get_manager'))) { $dbman = $DB->get_manager(); $table = new xmldb_table('turnitintool'); $field1 = new xmldb_field('grade', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null, 'name'); $dbman->change_field_type($table, $field1); } else { $table = new XMLDBTable('turnitintool'); $field1 = new XMLDBField('grade'); $field1->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null, 'name'); $result = $result && change_field_type($table, $field1); } } if ($result && $oldversion < 2011081701) { if (is_callable(array($DB, 'get_manager'))) { $dbman = $DB->get_manager(); // Add erater fields $table = new xmldb_table('turnitintool'); $field1 = new xmldb_field('erater', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, 0, 'perpage'); $field2 = new xmldb_field('erater_handbook', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, 0, 'erater'); $field3 = new xmldb_field('erater_dictionary', XMLDB_TYPE_CHAR, '10', XMLDB_UNSIGNED, null, null, null, 'erater_handbook'); $field4 = new xmldb_field('erater_spelling', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, 0, 'erater_dictionary'); $field5 = new xmldb_field('erater_grammar', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, 0, 'erater_spelling'); $field6 = new xmldb_field('erater_usage', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, 0, 'erater_grammar'); $field7 = new xmldb_field('erater_mechanics', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, 0, 'erater_usage'); $field8 = new xmldb_field('erater_style', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, 0, 'erater_mechanics'); if (!$dbman->field_exists($table, $field1)) { $dbman->add_field($table, $field1); } if (!$dbman->field_exists($table, $field2)) { $dbman->add_field($table, $field2); } if (!$dbman->field_exists($table, $field3)) { $dbman->add_field($table, $field3); } if (!$dbman->field_exists($table, $field4)) { $dbman->add_field($table, $field4); } if (!$dbman->field_exists($table, $field5)) { $dbman->add_field($table, $field5); } if (!$dbman->field_exists($table, $field6)) { $dbman->add_field($table, $field6); } if (!$dbman->field_exists($table, $field7)) { $dbman->add_field($table, $field7); } if (!$dbman->field_exists($table, $field8)) { $dbman->add_field($table, $field8); } } else { // Add erater fields $table = new XMLDBTable('turnitintool'); $field1 = new XMLDBField('erater'); $field2 = new XMLDBField('erater_handbook'); $field3 = new XMLDBField('erater_dictionary'); $field4 = new XMLDBField('erater_spelling'); $field5 = new XMLDBField('erater_grammar'); $field6 = new XMLDBField('erater_usage'); $field7 = new XMLDBField('erater_mechanics'); $field8 = new XMLDBField('erater_style'); $field1->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null, 'perpage'); $result = $result && add_field($table, $field1); $field2->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null, 'erater'); $result = $result && add_field($table, $field2); $field3->setAttributes(XMLDB_TYPE_TEXT, '10', null, null, null, null, null, null, 'erater_handbook'); $result = $result && add_field($table, $field3); $field4->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null, 'erater_dictionary'); $result = $result && add_field($table, $field4); $field5->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null, 'erater_spelling'); $result = $result && add_field($table, $field5); $field6->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null, 'erater_grammar'); $result = $result && add_field($table, $field6); $field7->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null, 'erater_usage'); $result = $result && add_field($table, $field7); $field8->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null, 'erater_mechanics'); $result = $result && add_field($table, $field8); } } if ($result && $oldversion < 2012030501) { if (is_callable(array($DB, 'get_manager'))) { $dbman = $DB->get_manager(); $table = new xmldb_table('turnitintool_users'); // Launch add index userid $index = new xmldb_index('userid', XMLDB_INDEX_UNIQUE, array('userid')); if (!$dbman->index_exists($table, $index)) { $dbman->add_index($table, $index); } } else { $table = new XMLDBTable('turnitintool_users'); // Launch add index userid $index = new XMLDBIndex('userid'); $index->setAttributes(XMLDB_INDEX_UNIQUE, array('userid')); if (index_exists($table, $index)) { $result = $result && add_index($table, $index); } } } if ($result && $oldversion < 2012042701) { if (is_callable(array($DB, 'get_manager'))) { $dbman = $DB->get_manager(); $table = new xmldb_table('turnitintool_users'); $field = new xmldb_field('turnitin_utp', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, 0, 'turnitin_uid'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } } else { $table = new XMLDBTable('turnitintool_users'); $field = new XMLDBField('turnitin_utp'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, 0, 'turnitin_uid'); $result = $result && add_field($table, $field); } } if ($result && $oldversion < 2012081301) { if (is_callable(array($DB, 'get_manager'))) { $dbman = $DB->get_manager(); $table = new xmldb_table('turnitintool_submissions'); $field = new xmldb_field('submission_transmatch', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, 0, 'submission_unanonreason'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } $table = new xmldb_table('turnitintool'); $field = new xmldb_field('transmatch', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, 0, 'erater_style'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } } else { $table = new XMLDBTable('turnitintool_submissions'); $field = new XMLDBField('submission_transmatch'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, 0, 'submission_unanonreason'); $result = $result && add_field($table, $field); $table = new XMLDBTable('turnitintool'); $field = new XMLDBField('transmatch'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, 0, 'erater_style'); $result = $result && add_field($table, $field); } } if ($result && $oldversion < 2013111403) { if (is_callable(array($DB, 'get_manager'))) { $dbman = $DB->get_manager(); $table = new xmldb_table('turnitintool'); $field = new xmldb_field('submitted', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, 0, 'anon'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } } else { $table = new XMLDBTable('turnitintool'); $field = new XMLDBField('submitted'); $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, 0, 'anon'); $result = $result && add_field($table, $field); } } if ($result && $oldversion < 2015030302) { if (is_callable(array($DB, 'get_manager'))) { $dbman = $DB->get_manager(); $table = new xmldb_table('turnitintool'); $field = new xmldb_field('needs_updating', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'transmatch'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } } else { $table = new XMLDBTable('turnitintool'); $field = new XMLDBField('needs_updating'); $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'transmatch'); $result = $result && add_field($table, $field); } } if ($result && $oldversion < 2015030303) { // Update URL for UK accounts. $apiurl = get_config('', 'turnitin_apiurl'); $newurl = str_replace('submit.ac.uk', 'api.turnitinuk.com', strtolower($apiurl)); set_config('turnitin_apiurl', $newurl); } return $result; }
} if (!is_null($param_relink) and isset($param_userlinks) and count($param_userlinks) > 0) { $loaderbar = new turnitintool_loaderbarclass(count($param_userlinks)); foreach ($param_userlinks as $userlink) { if ($tuser = turnitintool_get_record('turnitintool_users', 'id', $userlink) and $muser = turnitintool_get_record('user', 'id', $tuser->userid)) { // Get the email address if the user has been deleted if (empty($muser->email) or strpos($muser->email, '@') === false) { $split = explode('.', $muser->username); array_pop($split); $muser->email = join('.', $split); } $tii = new turnitintool_commclass(null, $muser->firstname, $muser->lastname, $muser->email, $tuser->turnitin_utp, $loaderbar); $tii->createUser($post, get_string('userprocess', 'turnitintool')); $user = new stdClass(); $user->id = $userlink; $user->turnitin_uid = $tii->getRerror() ? 0 : $tii->getUserID(); turnitintool_update_record('turnitintool_users', $user); unset($tii); } else { turnitintool_delete_records('turnitintool_users', 'id', $userlink); } } unset($loader); turnitintool_redirect($CFG->wwwroot . '/mod/turnitintool/extras.php?do=unlinkusers'); } turnitintool_header(NULL, NULL, $_SERVER["REQUEST_URI"], get_string("modulenameplural", "turnitintool"), $SITE->fullname); echo '<div id="turnitintool_style">'; turnitintool_box_start('generalbox boxwidthwide boxaligncenter', 'general'); echo '<b>' . get_string('unlinkrelinkusers', 'turnitintool') . '</b><br /><br />'; echo '<form method="POST" id="turnitin_unlink" action="' . $CFG->wwwroot . '/mod/turnitintool/extras.php?do=unlinkusers"><div style="height: 400px;overflow: auto;"> ';