Browse Source

Fix problems on backup/restore

MOODLE_20_STABLE
bdaloukas 8 years ago
parent
commit
4c34cc5c88
  1. 2
      CHANGES.md
  2. 4
      backup/moodle2/backup_game_stepslib.php
  3. 12
      backup/moodle2/restore_game_stepslib.php
  4. 1
      hangman/play.php
  5. 3
      snakes/play.php
  6. 2
      version.php

2
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 - Fix: Problems on backup/restore
Changes in version 2017-07-03 (2017070301) Changes in version 2017-07-03 (2017070301)

4
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'); $grade->annotate_ids('user', 'userid');
$repetition->annotate_ids('user', 'userid'); $repetition->annotate_ids('user', 'userid');
$repetition->annotate_ids('question', 'questionid'); $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('user', 'userid');
$query->annotate_ids('question', 'questionid'); $query->annotate_ids('question', 'questionid');
$query->annotate_ids('glossary_enrty', 'glossaryentryid'); $query->annotate_ids('glossary_entries', 'glossaryentryid');
$query->annotate_ids('question_answer', 'answerid'); $query->annotate_ids('question_answer', 'answerid');
$bookquizquestion->annotate_ids('book_chapter', 'chapterid'); $bookquizquestion->annotate_ids('book_chapter', 'chapterid');

12
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_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_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_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. // The games.
$paths[] = new restore_path_element('game_bookquiz', '/activity/game/game_attempts/game_attempt/game_bookquiz'); $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; $oldid = $data->id;
$data->gameid = $this->get_new_parentid('game'); $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->userid = $this->get_mappingid('user', $data->userid);
$data->questionid = $this->get_mappingid('question', $data->questionid); $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); $data->answerid = $this->get_mappingid('question_answers', $data->answerid);
$newitemid = $DB->insert_record('game_queries', $data); $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 = (object)$data;
$data->id = $this->get_new_parentid('game_attempt'); $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); game_insert_record( 'game_hangman', $data);
} }

1
hangman/play.php

@ -156,6 +156,7 @@ function game_hangman_continue( $id, $game, $attempt, $hangman, $newletter, $act
$query = new stdClass(); $query = new stdClass();
$query->attemptid = $attempt->id; $query->attemptid = $attempt->id;
$query->gamekind = $game->gamekind;
$query->gameid = $game->id; $query->gameid = $game->id;
$query->userid = $USER->id; $query->userid = $USER->id;
$query->sourcemodule = $game->sourcemodule; $query->sourcemodule = $game->sourcemodule;

3
snakes/play.php

@ -246,6 +246,7 @@ function game_snakes_computenextquestion( $game, &$snakes, &$query) {
if (($query->glossaryentryid == 0) and ($query->questionid == 0)) { if (($query->glossaryentryid == 0) and ($query->questionid == 0)) {
return false; return false;
} }
$query->gamekind = $game->gamekind;
$query->attemptid = $snakes->id; $query->attemptid = $snakes->id;
$query->gameid = $game->id; $query->gameid = $game->id;
$query->userid = $USER->id; $query->userid = $USER->id;
@ -282,7 +283,7 @@ function game_snakes_computenextquestion( $game, &$snakes, &$query) {
* @param stdClass $context * @param stdClass $context
*/ */
function game_snakes_showquestion( $id, $game, $snakes, $query, $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); game_snakes_showquestion_glossary( $id, $snakes, $query, $game);
} else { } else {
game_snakes_showquestion_question( $game, $id, $snakes, $query, $context); game_snakes_showquestion_question( $game, $id, $snakes, $query, $context);

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 = 2017070501; // The current module version (Date: YYYYMMDDXX). $plugin->version = 2017070502; // 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-05'; $plugin->release = '2017-07-05';

Loading…
Cancel
Save