/** * Does a class setup up routine, if the class exists in turnitintool_class then the Turnitin Class ID is returned for that class * if not then A call to FID2 to Create the Class is called and the ID is returned and stored in turnitintool_courses * * @param object $course The moodle course object for the course we are setting up * @param object $owner The moodle user object for the turnitin class owner of the course * @param string $status The status message that is displayed in the loader bar if the class needs to be created * @param object $tii The turnitintool_commclass object is passed by reference * @param object $loaderbar The turnitintool_loaderbarclass object is passed by reference can be NULL if no loader bar is to be used * @return object A turnitintool_courses data object that was either created or found during this call */ function turnitintool_classsetup($course, $owner, $status = '', &$tii, &$loaderbar) { // Make sure the Turnitin Module has been fully configured if (!turnitintool_check_config()) { turnitintool_print_error('configureerror', 'turnitintool', NULL, NULL, __FILE__, __LINE__); exit; } // Check to see if we have an ID and Title stored for this course if (!($turnitintool_course = turnitintool_get_record("turnitintool_courses", "courseid", $course->id))) { $classexists = false; } else { $classexists = true; } // We do not have an ID stored // Action: Create the class on turnitin and store relevant details if (!$classexists) { // Create a Turnitin Comm Object if (isset($loaderbar->total)) { $loaderbar->total = $loaderbar->total + 1; } // Create without IDs initially $uniquestring = strtoupper(uniqid()); $turnitin_ctl = strlen($course->fullname) > 76 ? substr($course->fullname, 0, 76) . "... (" . $uniquestring . ")" : $course->fullname . " (" . $uniquestring . ")"; $post = new stdClass(); $post->ctl = $turnitin_ctl; $post->idsync = 1; $tii->createClass($post, $status); if ($tii->getRerror()) { if ($tii->getAPIunavailable()) { turnitintool_print_error('apiunavailable', 'turnitintool', NULL, NULL, __FILE__, __LINE__); } else { turnitintool_print_error($tii->getRmessage(), NULL, NULL, NULL, __FILE__, __LINE__); } exit; } $post->cid = $tii->getClassID(); $turnitin_ctl = str_replace("(" . $uniquestring . ")", "(Moodle " . $post->cid . ")", $turnitin_ctl); $turnitincourse = new stdClass(); $turnitincourse->courseid = $course->id; $turnitincourse->ownerid = $owner->id; $turnitincourse->turnitin_cid = $post->cid; $turnitincourse->turnitin_ctl = $turnitin_ctl; if (!($insertid = turnitintool_insert_record('turnitintool_courses', $turnitincourse))) { turnitintool_print_error('classupdateerror', 'turnitintool', NULL, NULL, __FILE__, __LINE__); exit; } $turnitincourse->id = $insertid; } // We already have an ID stored // Action: Do a call to Turnitin with the Stored IDs to ensure the class has not changed if (isset($insertid) and !($turnitintool_course = turnitintool_get_record("turnitintool_courses", "courseid", $course->id))) { turnitintool_print_error('classgeterror', 'turnitintool', NULL, NULL, __FILE__, __LINE__); exit; } // Create a Turnitin Comm Object if (isset($loaderbar->total)) { $loaderbar->total = $loaderbar->total + 2; } $post = new stdClass(); $post->cid = $turnitintool_course->turnitin_cid; $post->ctl = $turnitintool_course->turnitin_ctl; $post->idsync = 0; $tii->createClass($post, $status); if ($tii->getRerror()) { if ($tii->getAPIunavailable()) { turnitintool_print_error('apiunavailable', 'turnitintool', NULL, NULL, __FILE__, __LINE__); } else { turnitintool_print_error($tii->getRmessage(), NULL, NULL, NULL, __FILE__, __LINE__); } exit; } return $turnitintool_course; }
* @package turnitintool * @copyright 2012 Turnitin */ require_once __DIR__ . "/../../config.php"; require_once __DIR__ . "/lib.php"; if ($CFG->branch >= 20) { require_once $CFG->libdir . "/completionlib.php"; } require_once $CFG->libdir . "/formslib.php"; require_once $CFG->libdir . "/form/text.php"; require_once $CFG->libdir . "/form/datetimeselector.php"; require_once $CFG->libdir . "/form/hidden.php"; require_once $CFG->libdir . "/form/button.php"; require_once $CFG->libdir . "/form/submit.php"; require_once __DIR__ . "/version.php"; if (!turnitintool_check_config()) { turnitintool_print_error('configureerror', 'turnitintool', NULL, NULL, __FILE__, __LINE__); exit; } $viewpage = 'view.php'; $viewpage .= isset($_REQUEST['id']) ? '?id=' . $_REQUEST['id'] : ''; $viewpage .= isset($_REQUEST['do']) ? '&do=' . $_REQUEST['do'] : ''; turnitintool_activitylog($viewpage, "REQUEST"); turnitintool_activitylog("lib.php Loaded", "REQUIRE_ONCE"); require_once $CFG->dirroot . "/lib/uploadlib.php"; turnitintool_activitylog("uploadlib.php Loaded", "REQUIRE_ONCE"); turnitintool_process_api_error(); $id = required_param('id', PARAM_INT); // Course Module ID, or $a = optional_param('a', 0, PARAM_INT); // turnitintool ID
/** * @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; }
/** * Call to API FID15, FCMD3 to set the GradeMark grade for a particular submission * * @param object $post The post object that contains the necessary query parameters for the call * @param string $status The status to pass to the loaderbar class */ function setGradeMark($post, $status) { if (!turnitintool_check_config()) { turnitintool_print_error('configureerror', 'turnitintool', NULL, NULL, __FILE__, __LINE__); exit; } $assigndata = array('gmtime' => $this->tiiGmtime(), 'encrypt' => TII_ENCRYPT, 'aid' => $this->accountid, 'diagnostic' => 0, 'fcmd' => 3, 'cid' => $post->cid, 'oid' => $post->oid, 'utp' => 2, 'fid' => 15, 'uid' => $this->uid, 'uem' => $this->uem, 'ufn' => $this->ufn, 'uln' => $this->uln); $assigndata['dis'] = $this->disableEmail(); $assigndata["md5"] = $this->doMD5($assigndata); $assigndata['session-id'] = $this->tiisession; $assigndata["score"] = $post->score; $assigndata['src'] = TURNITIN_APISRC; $assigndata['apilang'] = $this->getLang(); $this->result = $this->doRequest("POST", $this->apiurl, $assigndata, true, $status); }