]> git.mjollnir.org Git - moodle.git/commitdiff
use "md5key" as secondary key on hotpot_strings table; allow for non-unique secondary...
authorgbateson <gbateson>
Thu, 30 Oct 2008 06:25:45 +0000 (06:25 +0000)
committergbateson <gbateson>
Thu, 30 Oct 2008 06:25:45 +0000 (06:25 +0000)
mod/hotpot/restorelib.php

index 8406c90cdb6219049e71bb257f5ecf89c69128b4..4aa1ebe5b909e05ce6cbb9065a387361d37bbcbb 100644 (file)
@@ -122,7 +122,7 @@ function hotpot_restore_strings(&$restore, $status, &$xml, &$record) {
     // $xml is an XML tree for a hotpot record
     // $record is the newly added hotpot record
     return hotpot_restore_records(
-        $restore, $status, $xml, 'hotpot_strings', array(), '', 'STRING_DATA', 'STRING', 'string'
+        $restore, $status, $xml, 'hotpot_strings', array(), '', 'STRING_DATA', 'STRING', 'md5key'
     );
 }
 function hotpot_restore_questions(&$restore, $status, &$xml, &$record) {
@@ -391,9 +391,10 @@ function hotpot_restore_record(&$restore, $status, &$xml, $table, $foreign_keys,
         // if there is a secondary key field  ...
         if ($secondary_key) {
             // check to see if a record with the same value already exists
-            $key_record = $DB->get_record($table, array($secondary_key=>$record->$secondary_key));
-            if ($key_record) {
+            $key_records = $DB->get_records($table, array($secondary_key=>$record->$secondary_key));
+            if ($key_records) {
                 // set new record id from already existing record
+                $key_record = reset($key_records);
                 $record->id = $key_record->id;
             }
         }