Created
August 30, 2013 16:58
-
-
Save SpenserJ/6392012 to your computer and use it in GitHub Desktop.
Starter-patch for TurnItIn Moodle Integration
This fixes the bare minimum for MSSQL support. There are significantly more SQL Queries that need to be checked.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -Naur original/turnitintool/lib.php fixed/turnitintool/lib.php | |
--- original/turnitintool/lib.php 2013-08-30 09:26:23.421505801 -0600 | |
+++ fixed/turnitintool/lib.php 2013-08-30 10:52:56.173505801 -0600 | |
@@ -289,7 +289,7 @@ | |
*/ | |
function turnitintool_update_instance($turnitintool) { | |
- global $USER,$CFG; | |
+ global $USER,$CFG,$DB; | |
$turnitintool->timemodified = time(); | |
$turnitintool->id = $turnitintool->instance; | |
@@ -395,7 +395,7 @@ | |
if (!$delete=turnitintool_update_record('turnitintool_parts',$part,false)) { | |
turnitintool_print_error('partdberror','turnitintool',NULL,$i,__FILE__,__LINE__); | |
} | |
- turnitintool_delete_records_select('event', "modulename='turnitintool' AND instance=".$turnitintool->id." AND name='".$turnitintool->name." - ".$part->partname."'"); | |
+ turnitintool_delete_records_select('event', "modulename='turnitintool' AND instance=".$turnitintool->id." AND ".$DB->sql_compare_text('name')."='".$turnitintool->name." - ".$part->partname."'"); | |
// ]]]] | |
} | |
} | |
@@ -558,7 +558,7 @@ | |
} | |
// Delete existing events for this assignment / part | |
- turnitintool_delete_records_select('event', "modulename='turnitintool' AND instance=".$turnitintool->id." AND name='".$turnitintoolnow->name.' - '.$part->partname."'"); | |
+ turnitintool_delete_records_select('event', "modulename='turnitintool' AND instance=".$turnitintool->id." AND ".$DB->sql_compare_text('name')."='".$turnitintoolnow->name.' - '.$part->partname."'"); | |
add_event($event); | |
unset($tiipost); | |
@@ -719,6 +719,7 @@ | |
* @return bool success | |
*/ | |
function turnitintool_refresh_events($courseid=0) { | |
+ global $DB; | |
if ($courseid == 0) { | |
if (!$turnitintools = turnitintool_get_records("turnitintool")) { | |
@@ -742,7 +743,7 @@ | |
foreach ($parts as $part) { | |
$event->timestart=$part->dtdue; | |
- if ($events = turnitintool_get_record_select('event', "modulename='turnitintool' AND instance=".$turnitintool->id." AND name='".$turnitintool->name." - ".$part->partname."'")) { | |
+ if ($events = turnitintool_get_record_select('event', "modulename='turnitintool' AND instance=".$turnitintool->id." AND ".$DB->sql_compare_text('name')."='".$turnitintool->name." - ".$part->partname."'")) { | |
$event->id = $events->id; | |
update_event($event); | |
} else { | |
@@ -1156,7 +1157,7 @@ | |
* @return array A notice array contains error details for display on page load in the case of an error nothing returned if no errors occur | |
*/ | |
function turnitintool_update_partnames($cm,$turnitintool,$post) { | |
- global $CFG,$USER; | |
+ global $CFG,$USER,$DB; | |
if (has_capability('mod/turnitintool:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) { | |
$notice['message']=''; | |
$error=false; | |
@@ -1311,7 +1312,7 @@ | |
turnitintool_print_error('partdberror','turnitintool',NULL,NULL,__FILE__,__LINE__); | |
} | |
- if ($events = turnitintool_get_record_select('event', "modulename='turnitintool' AND instance='".$turnitintool->id."' AND name='".$currentevent."'")) { | |
+ if ($events = turnitintool_get_record_select('event', "modulename='turnitintool' AND instance='".$turnitintool->id."' AND ".$DB->sql_compare_text('name')."='".$currentevent."'")) { | |
$event->id = $events->id; | |
update_event($event); | |
} | |
@@ -1345,7 +1346,7 @@ | |
* @return array A notice array contains error details for display on page load in the case of an error nothing returned if no errors occur | |
*/ | |
function turnitintool_delete_part($cm,$turnitintool,$partid) { | |
- global $CFG,$USER; | |
+ global $CFG,$USER,$DB; | |
$notice['message']=''; | |
if ($turnitintool->numparts==1) { | |
$error=true; | |
@@ -1375,7 +1376,7 @@ | |
} | |
// Delete events for this assignment / part | |
- turnitintool_delete_records_select('event', "modulename='turnitintool' AND instance=".$turnitintool->id." AND name='".$turnitintool->name." - ".turnitintool_partnamefromnum($partid)."'"); | |
+ turnitintool_delete_records_select('event', "modulename='turnitintool' AND instance=".$turnitintool->id." AND ".$DB->sql_compare_text('name')."='".$turnitintool->name." - ".turnitintool_partnamefromnum($partid)."'"); | |
$update = new stdClass(); | |
$update->id=$turnitintool->id; | |
@@ -7281,4 +7282,4 @@ | |
return array('submit'); | |
} | |
-/* ?> */ | |
\ No newline at end of file | |
+/* ?> */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment