Browse Source

Fix problems on backup/restore

MOODLE_20_STABLE
bdaloukas 8 years ago
parent
commit
9b34146b22
  1. 2
      backup/moodle2/backup_game_stepslib.php
  2. 4
      backup/moodle2/restore_game_stepslib.php
  3. 27
      db/upgrade.php
  4. 2
      version.php

2
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)); $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_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)); $bookquiz->set_source_table('game_bookquiz', array( 'id' => backup::VAR_ACTIVITYID));
$bookquizchapter->set_source_table('game_bookquiz_chapters', array( 'id' => backup::VAR_PARENTID)); $bookquizchapter->set_source_table('game_bookquiz_chapters', array( 'id' => backup::VAR_PARENTID));

4
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. // Insert the game record.
$newitemid = $DB->insert_record('game', $data); $newitemid = $DB->insert_record('game', $data);
$this->set_mapping('game', $oldid, $newitemid);
// Immediately after inserting "activity" record, call this. // Immediately after inserting "activity" record, call this.
$this->apply_activity_instance($newitemid); $this->apply_activity_instance($newitemid);
} }
@ -338,7 +340,7 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
$data = (object)$data; $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); $data->queryid = $this->get_mappingid('game_query', $data->queryid);
$DB->insert_record('game_snakes', $data); $DB->insert_record('game_snakes', $data);

27
db/upgrade.php

@ -1649,6 +1649,33 @@ function xmldb_game_upgrade($oldversion) {
$DB->execute( $sql); $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; return true;
} }

2
version.php

@ -35,7 +35,7 @@ if (!isset( $plugin)) {
} }
$plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics). $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->requires = 2010112400; // Requires Moodle 2.0.
$plugin->cron = 0; // Period for cron to check this module (secs). $plugin->cron = 0; // Period for cron to check this module (secs).
$plugin->release = '2017-07-04'; $plugin->release = '2017-07-04';

Loading…
Cancel
Save