From 4c34cc5c8889ec9ac9c8f409b52eb73d380b8889 Mon Sep 17 00:00:00 2001 From: bdaloukas Date: Wed, 5 Jul 2017 21:13:43 +0300 Subject: [PATCH] Fix problems on backup/restore --- CHANGES.md | 2 +- backup/moodle2/backup_game_stepslib.php | 4 ++-- backup/moodle2/restore_game_stepslib.php | 12 +++++++----- hangman/play.php | 1 + snakes/play.php | 3 ++- version.php | 2 +- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7cdbe85..f5ace05 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,4 @@ -Changes in version 2017-07-04 (2017070401) +Changes in version 2017-07-05 (2017070502) - Fix: Problems on backup/restore Changes in version 2017-07-03 (2017070301) diff --git a/backup/moodle2/backup_game_stepslib.php b/backup/moodle2/backup_game_stepslib.php index 8541c72..b9680b9 100644 --- a/backup/moodle2/backup_game_stepslib.php +++ b/backup/moodle2/backup_game_stepslib.php @@ -176,10 +176,10 @@ class backup_game_activity_structure_step extends backup_activity_structure_step $grade->annotate_ids('user', 'userid'); $repetition->annotate_ids('user', 'userid'); $repetition->annotate_ids('question', 'questionid'); - $repetition->annotate_ids('glossary_entry', 'glossaryentryid'); + $repetition->annotate_ids('glossary_entries', 'glossaryentryid'); $query->annotate_ids('user', 'userid'); $query->annotate_ids('question', 'questionid'); - $query->annotate_ids('glossary_enrty', 'glossaryentryid'); + $query->annotate_ids('glossary_entries', 'glossaryentryid'); $query->annotate_ids('question_answer', 'answerid'); $bookquizquestion->annotate_ids('book_chapter', 'chapterid'); diff --git a/backup/moodle2/restore_game_stepslib.php b/backup/moodle2/restore_game_stepslib.php index b22f32d..c34bb90 100644 --- a/backup/moodle2/restore_game_stepslib.php +++ b/backup/moodle2/restore_game_stepslib.php @@ -54,7 +54,7 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $paths[] = new restore_path_element('game_grade', '/activity/game/game_grades/game_grade'); $paths[] = new restore_path_element('game_repetition', '/activity/game/game_repetiotions/game_repetition'); $paths[] = new restore_path_element('game_attempt', '/activity/game/game_attempts/game_attempt'); - $paths[] = new restore_path_element('game_query', '/activity/game/game_attempts/game_attempt/game_querys/game_query'); + $paths[] = new restore_path_element('game_query', '/activity/game/game_attempts/game_attempt/game_queries/game_query'); // The games. $paths[] = new restore_path_element('game_bookquiz', '/activity/game/game_attempts/game_attempt/game_bookquiz'); @@ -215,14 +215,16 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $oldid = $data->id; $data->gameid = $this->get_new_parentid('game'); - $data->attemptid = get_mappingid('game_attempt', $data->attemptid); + $data->attemptid = $this->get_new_parentid('game_attempt'); + $data->userid = $this->get_mappingid('user', $data->userid); $data->questionid = $this->get_mappingid('question', $data->questionid); - $data->glossaryentryid = $this->get_mappingid('glossary_entries', $data->glossaryentryid); + $data->glossaryentryid = $this->get_mappingid('glossary_entry', $data->glossaryentryid); $data->answerid = $this->get_mappingid('question_answers', $data->answerid); $newitemid = $DB->insert_record('game_queries', $data); - $this->set_mapping('game_query', $oldid, $newitemid); + + $this->set_mapping('game_queries', $oldid, $newitemid); } /** @@ -315,7 +317,7 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $data = (object)$data; $data->id = $this->get_new_parentid('game_attempt'); - $data->queryid = $this->get_mappingid('game_query', $data->queryid); + $data->queryid = $this->get_mappingid('game_queries', $data->queryid); game_insert_record( 'game_hangman', $data); } diff --git a/hangman/play.php b/hangman/play.php index 5f2d784..4b55838 100644 --- a/hangman/play.php +++ b/hangman/play.php @@ -156,6 +156,7 @@ function game_hangman_continue( $id, $game, $attempt, $hangman, $newletter, $act $query = new stdClass(); $query->attemptid = $attempt->id; + $query->gamekind = $game->gamekind; $query->gameid = $game->id; $query->userid = $USER->id; $query->sourcemodule = $game->sourcemodule; diff --git a/snakes/play.php b/snakes/play.php index 4dd7efe..b73d81f 100644 --- a/snakes/play.php +++ b/snakes/play.php @@ -246,6 +246,7 @@ function game_snakes_computenextquestion( $game, &$snakes, &$query) { if (($query->glossaryentryid == 0) and ($query->questionid == 0)) { return false; } + $query->gamekind = $game->gamekind; $query->attemptid = $snakes->id; $query->gameid = $game->id; $query->userid = $USER->id; @@ -282,7 +283,7 @@ function game_snakes_computenextquestion( $game, &$snakes, &$query) { * @param stdClass $context */ function game_snakes_showquestion( $id, $game, $snakes, $query, $context) { - if ($query->sourcemodule == 'glossary') { + if ($game->sourcemodule == 'glossary') { game_snakes_showquestion_glossary( $id, $snakes, $query, $game); } else { game_snakes_showquestion_question( $game, $id, $snakes, $query, $context); diff --git a/version.php b/version.php index 87c8250..fd73a3b 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 = 2017070501; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2017070502; // 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-05';