diff --git a/backup/moodle2/backup_game_stepslib.php b/backup/moodle2/backup_game_stepslib.php index d3079da..be5e5d7 100644 --- a/backup/moodle2/backup_game_stepslib.php +++ b/backup/moodle2/backup_game_stepslib.php @@ -187,7 +187,7 @@ class backup_game_activity_structure_step extends backup_activity_structure_step $repetition->set_source_table('game_repetitions', array('gameid' => backup::VAR_ACTIVITYID)); $attempt->set_source_table('game_attempts', array( 'gameid' => backup::VAR_ACTIVITYID)); - $attempt->set_source_table('game_queries', array( 'attemptid' => backup::VAR_PARENTID)); + $query->set_source_table('game_queries', array( 'attemptid' => backup::VAR_PARENTID)); $bookquiz->set_source_table('game_bookquiz', array( 'id' => backup::VAR_ACTIVITYID)); $bookquizchapter->set_source_table('game_bookquiz_chapters', array( 'id' => backup::VAR_PARENTID)); diff --git a/backup/moodle2/restore_game_stepslib.php b/backup/moodle2/restore_game_stepslib.php index fd9b181..976ef31 100644 --- a/backup/moodle2/restore_game_stepslib.php +++ b/backup/moodle2/restore_game_stepslib.php @@ -85,6 +85,8 @@ class restore_game_activity_structure_step extends restore_activity_structure_st // Insert the game record. $newitemid = $DB->insert_record('game', $data); + $this->set_mapping('game', $oldid, $newitemid); + // Immediately after inserting "activity" record, call this. $this->apply_activity_instance($newitemid); } @@ -338,7 +340,7 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $data = (object)$data; - $data->id = $this->get_new_parentid('game'); + $data->id = $this->get_mappingid('game', $data->id); $data->queryid = $this->get_mappingid('game_query', $data->queryid); $DB->insert_record('game_snakes', $data); diff --git a/db/upgrade.php b/db/upgrade.php index f5ad12a..9b52428 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -1649,6 +1649,33 @@ function xmldb_game_upgrade($oldversion) { $DB->execute( $sql); } + if ($oldversion < ($ver = 2017070403)) { + $sql = "SELECT * FROM {$CFG->prefix}game_snakes_database"; + $recs = $DB->get_records_sql( $sql); + foreach ($recs as $rec) { + if (($rec->usedcols != 0) and ($rec->usedrows != 0)) { + continue; + } + + $updrec = new stdClass; + $updrec->id = $rec->id; + if ( $rec->id == 1) { + $value = 8; + } else if ( $rec->id == 2) { + $value = 6; + } else { + continue; + } + if ($rec->usedcols == 0) { + $updrec->usedcols = $value; + } + if ($rec->usedrows == 0) { + $updrec->usedrows = $value; + } + $DB->update_record( 'game_snakes_database', $updrec); + } + } + return true; } diff --git a/version.php b/version.php index 6997883..4f5a16a 100644 --- a/version.php +++ b/version.php @@ -35,7 +35,7 @@ if (!isset( $plugin)) { } $plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics). -$plugin->version = 2017070401; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2017070403; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2010112400; // Requires Moodle 2.0. $plugin->cron = 0; // Period for cron to check this module (secs). $plugin->release = '2017-07-04';