Permalink
Browse files

correct the detection of HotPot 2.0 backups (from Moodle 1.5)

  • Loading branch information...
1 parent 22fa4da commit 5ab3937c6eb26c2204e5c2c0cc935c3ee602ba80 gbateson committed Sep 1, 2006
Showing with 11 additions and 4 deletions.
  1. +11 −4 mod/hotpot/restorelib.php
View
@@ -88,14 +88,21 @@ function hotpot_restore_mods($mod, $restore) {
$restore_userdata_selected = $restore->mods['hotpot']->userinfo;
}
if ($restore_userdata_selected) {
- if (isset($xml["STRING_DATA"]) && isset($xml["QUESTION_DATA"])) {
+ $has_details = false;
+ if (isset($xml["ATTEMPT_DATA"]["0"]["#"]["ATTEMPT"]["0"]["#"]["DETAILS"]["0"]["#"])) {
+ $details = trim($xml["ATTEMPT_DATA"]["0"]["#"]["ATTEMPT"]["0"]["#"]["DETAILS"]["0"]["#"]);
+ if ($details<>'' && $details<>'<?xml version="1.0"?><hpjsresult><fields></fields></hpjsresult>') {
+ $has_details = true;
+ }
+ }
+ if ($has_details && empty($xml["STRING_DATA"]) && empty($xml["QUESTION_DATA"])) {
+ // HotPot v2.0.x (regenerate questions, responses and strings from attempt details)
+ $more_restore .= '$status = hotpot_restore_attempts($restore, $status, $xml, $record, true);';
+ } else {
// HotPot v2.1+
$more_restore .= '$status = hotpot_restore_strings($restore, $status, $xml, $record);';
$more_restore .= '$status = hotpot_restore_questions($restore, $status, $xml, $record);';
$more_restore .= '$status = hotpot_restore_attempts($restore, $status, $xml, $record);';
- } else {
- // HotPot v2.0.x (regenerate questions, responses and strings from attempt details)
- $more_restore .= '$status = hotpot_restore_attempts($restore, $status, $xml, $record, true);';
}
}
$status = hotpot_restore_records(

0 comments on commit 5ab3937

Please sign in to comment.