diff --git a/mod/hotpot/restorelib.php b/mod/hotpot/restorelib.php index 4911cf93257..ee4a619972b 100644 --- a/mod/hotpot/restorelib.php +++ b/mod/hotpot/restorelib.php @@ -146,7 +146,7 @@ function hotpot_restore_attempts(&$restore, $status, &$xml, &$record, $hotpot_v2 $more_restore .= '$status = hotpot_restore_responses($restore, $status, $xml, $record);'; // save clickreportid (to be updated it later) - $more_restore .= 'if (isset($record->clickreportid)) {'; + $more_restore .= 'if (!empty($record->clickreportid)) {'; $more_restore .= '$GLOBALS["hotpot_backup_clickreportids"][$record->id]=$record->clickreportid;'; $more_restore .= '}'; @@ -178,13 +178,12 @@ function hotpot_restore_attempts(&$restore, $status, &$xml, &$record, $hotpot_v2 function hotpot_restore_clickreportids(&$restore, $status) { // update clickreport ids, if any global $CFG; - $sql = ''; foreach ($GLOBALS["hotpot_backup_clickreportids"] as $id=>$clickreportid) { if ($status) { $attempt_record = backup_getid($restore->backup_unique_code, 'hotpot_attempts', $clickreportid); if ($attempt_record) { $new_clickreportid = $attempt_record->new_id; - $sql .= "UPDATE {$CFG->prefix}hotpot_attempts SET clickreportid=$new_clickreportid WHERE id=$id;\n"; + $status = execute_sql("UPDATE {$CFG->prefix}hotpot_attempts SET clickreportid=$new_clickreportid WHERE id=$id", false); } else { // New clickreport id could not be found print ""; @@ -192,14 +191,6 @@ function hotpot_restore_clickreportids(&$restore, $status) { } } } - if ($status && $sql) { - if (execute_sql($sql, false)) { - // do nothing (update was ok :-) - } else { - print ""; - $status = false; - } - } return $status; } function hotpot_restore_responses(&$restore, $status, &$xml, &$record) { @@ -213,7 +204,7 @@ function hotpot_restore_responses(&$restore, $status, &$xml, &$record) { 'wrong'=>'hotpot_strings', 'ignored'=>'hotpot_strings' ); - + return hotpot_restore_records( $restore, $status, $xml, 'hotpot_responses', $foreignkeys, '', 'RESPONSE_DATA', 'RESPONSE' );