diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..5237e0f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,23 @@ +name: Wiki sync + +on: [gollum] + +jobs: + copycat: + name: Copycat + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Copycat KQMATH + uses: andstor/copycat-action@v1.1.0 + env: + DST_BRANCH: master + DST_OWNER: KQMATH + DST_REPO_NAME: kqmath.github.io + DST_PATH: /docs/shortmath/ + GH_PAT: ${{ secrets.GH_PAT }} + SRC_BRANCH: master + SRC_PATH: /. + SRC_WIKI: "true" + USERNAME: nutsbot + EMAIL: andr3.storhaug+bot@gmail.com diff --git a/.gitignore b/.gitignore index e596047..0b470a7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ .idea/ out/ docs/ -node_modules/ \ No newline at end of file +node_modules/ +vendor/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 44b9bce..db749b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Changed - +## [0.4.2] - 2021-02-03 +### Fixed +- Fixed bug #33 regarding backup and restore problems. + ## [0.4.1] - 2019-05-29 ### Fixed - Fixed bug #26 regarding multiple ShortMath questions in one quiz page. @@ -32,7 +36,8 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Added - -[Unreleased]: https://github.com/KQMATH/moodle-qtype_shortmath/compare/v0.4.1...HEAD +[Unreleased]: https://github.com/KQMATH/moodle-qtype_shortmath/compare/v0.4.2...HEAD +[0.4.2]: https://github.com/KQMATH/moodle-qtype_shortmath/compare/v0.4.1...v0.4.2 [0.4.1]: https://github.com/KQMATH/moodle-qtype_shortmath/compare/v0.4.0...v0.4.1 [0.4.0]: https://github.com/KQMATH/moodle-qtype_shortmath/compare/v0.3.1...v0.4.0 [0.3.1]: https://github.com/KQMATH/moodle-qtype_shortmath/compare/v0.3.0...v0.3.1 diff --git a/backup/moodle2/backup_qtype_shortmath_plugin.class.php b/backup/moodle2/backup_qtype_shortmath_plugin.class.php index 1e0f63a..c9d3d2a 100644 --- a/backup/moodle2/backup_qtype_shortmath_plugin.class.php +++ b/backup/moodle2/backup_qtype_shortmath_plugin.class.php @@ -39,7 +39,7 @@ class backup_qtype_shortmath_plugin extends backup_qtype_plugin { */ protected function define_question_plugin_structure() { // Define the virtual plugin element with the condition to fulfill. - $plugin = $this->get_plugin_element(null, '../../qtype', 'shortmath'); + $plugin = $this->get_plugin_element(null, '../../qtype', $this->pluginname); // Create one standard named plugin element (the visible container). $pluginwrapper = new backup_nested_element($this->get_recommended_name()); // Connect the visible container ASAP. @@ -48,13 +48,11 @@ protected function define_question_plugin_structure() { // to the tree before any other information that will use them. $this->add_question_question_answers($pluginwrapper); // Now create the qtype own structures. - $shortmath = new backup_nested_element('shortmath', ['id'], ['answers', 'usecase', 'usehint']); + $shortmath = new backup_nested_element('shortmath', ['id'], ['questionid', 'usecase']); // Now the own qtype tree. $pluginwrapper->add_child($shortmath); // Set source to populate the data. - // JR changed table name to match new table name system in moodle 2.1 DEC 2011. - // JR changed field name question to questionid JAN 2012. - $shortmath->set_source_table('qtype_shortmath', ['questionid' => backup::VAR_PARENTID]); + $shortmath->set_source_table('qtype_shortmath_options', ['questionid' => backup::VAR_PARENTID]); // Don't need to annotate ids nor files. return $plugin; } diff --git a/backup/moodle2/restore_qtype_shortmath_plugin.class.php b/backup/moodle2/restore_qtype_shortmath_plugin.class.php index 22f8aac..7ab9428 100644 --- a/backup/moodle2/restore_qtype_shortmath_plugin.class.php +++ b/backup/moodle2/restore_qtype_shortmath_plugin.class.php @@ -64,20 +64,10 @@ public function process_shortmath($data) { if ($questioncreated) { // Adjust some columns. $data->questionid = $newquestionid; - // Map sequence of question_answer ids. - $answersarr = explode(',', $data->answers); - foreach ($answersarr as $key => $answer) { - // Postgresql does not handle empty strings as integer values. - if ($answer == '') { - $answer = null; - } - $answersarr[$key] = $this->get_mappingid('question_answer', $answer); - } - $data->answers = implode(',', $answersarr); // Insert record. - $newitemid = $DB->insert_record('qtype_shortmath', $data); + $newitemid = $DB->insert_record('qtype_shortmath_options', $data); // Create mapping. - $this->set_mapping('qtype_shortmath', $oldid, $newitemid); + $this->set_mapping('qtype_shortmath_options', $oldid, $newitemid); } } } diff --git a/package-lock.json b/package-lock.json index 237951f..5a44e83 100644 --- a/package-lock.json +++ b/package-lock.json @@ -250,9 +250,12 @@ } }, "eslint-utils": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.3.1.tgz", - "integrity": "sha512-Z7YjnIldX+2XMcjr7ZkgEsOj/bREONV60qYeB/bjMAqqqZ4zxKyWX+BOUkdmRmA9riiIPVvo5x86m5elviOk0Q==" + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.2.tgz", + "integrity": "sha512-eAZS2sEUMlIeCjBeubdj45dmBHQwPHWyBcT1VSYB7o9x9WRRqKxyUoiXlRjyAwzN7YEzHJlYg0NmzDRWx6GP4Q==", + "requires": { + "eslint-visitor-keys": "^1.0.0" + } }, "eslint-visitor-keys": { "version": "1.0.0", @@ -479,9 +482,9 @@ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "js-yaml": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", - "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" @@ -507,9 +510,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + "version": "4.17.14", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", + "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==" }, "mimic-fn": { "version": "1.2.0", diff --git a/version.php b/version.php index 9f03d00..d64dba7 100755 --- a/version.php +++ b/version.php @@ -26,8 +26,8 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2019052900; +$plugin->version = 2021020300; $plugin->requires = 2018051700; // Moodle version 3.5. $plugin->component = 'qtype_shortmath'; $plugin->maturity = MATURITY_STABLE; -$plugin->release = '0.4.1'; +$plugin->release = '0.4.2';