From f8c0a17a919ebead678e2a33a937a55f57d8b6a1 Mon Sep 17 00:00:00 2001 From: Pol Torrent i Soler Date: Thu, 2 Jun 2022 14:41:24 +0200 Subject: [PATCH 1/8] ops: add release gha script --- .github/workflows/release.yml | 66 +++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0cc9d4d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,66 @@ +# +# Whenever a new tag starting with "v" is pushed, add the tagged version +# to the Moodle Plugins directory at https://moodle.org/plugins +# +# revision: 2021070201 +# +name: Releasing in the Plugins directory + +on: + push: + tags: + - v* + + workflow_dispatch: + inputs: + tag: + description: 'Tag to be released' + required: true + +defaults: + run: + shell: bash + +jobs: + release-at-moodle-org: + runs-on: ubuntu-latest + env: + PLUGIN: qtype_multianswerwiris + CURL: curl -s + ENDPOINT: https://moodle.org/webservice/rest/server.php + TOKEN: ${{ secrets.MOODLE_ORG_TOKEN }} + FUNCTION: local_plugins_add_version + + steps: + - name: Call the service function + id: add-version + run: | + if [[ ! -z "${{ github.event.inputs.tag }}" ]]; then + TAGNAME="${{ github.event.inputs.tag }}" + elif [[ $GITHUB_REF = refs/tags/* ]]; then + TAGNAME="${GITHUB_REF##*/}" + fi + if [[ -z "${TAGNAME}" ]]; then + echo "No tag name has been provided!" + exit 1 + fi + ZIPURL="https://api.github.com/repos/${{ github.repository }}/zipball/${TAGNAME}" + RESPONSE=$(${CURL} ${ENDPOINT} --data-urlencode "wstoken=${TOKEN}" \ + --data-urlencode "wsfunction=${FUNCTION}" \ + --data-urlencode "moodlewsrestformat=json" \ + --data-urlencode "frankenstyle=${PLUGIN}" \ + --data-urlencode "zipurl=${ZIPURL}" \ + --data-urlencode "vcssystem=git" \ + --data-urlencode "vcsrepositoryurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" \ + --data-urlencode "vcstag=${TAGNAME}" \ + --data-urlencode "changelogurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commits/${TAGNAME}" \ + --data-urlencode "altdownloadurl=${ZIPURL}") + echo "::set-output name=response::${RESPONSE}" + + - name: Evaluate the response + id: evaluate-response + env: + RESPONSE: ${{ steps.add-version.outputs.response }} + run: | + jq <<< ${RESPONSE} + jq --exit-status ".id" <<< ${RESPONSE} > /dev/null From 91e2c89f99a2cf7278c3ed26deb784806e687540 Mon Sep 17 00:00:00 2001 From: Pol Torrent i Soler Date: Thu, 2 Jun 2022 14:42:16 +0200 Subject: [PATCH 2/8] ops: run only on moodle-supported versions --- .github/workflows/ci.yml | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4abce4e..caf8caa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,43 +27,9 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.1', '7.2', '7.3', '7.4'] - moodle-branch: ['MOODLE_35_STABLE', 'MOODLE_36_STABLE', 'MOODLE_37_STABLE', 'MOODLE_38_STABLE', 'MOODLE_39_STABLE', 'MOODLE_310_STABLE', 'MOODLE_311_STABLE'] + php: ['7.3', '7.4'] + moodle-branch: ['MOODLE_39_STABLE', 'MOODLE_310_STABLE', 'MOODLE_311_STABLE'] database: [pgsql] - exclude: - # Exclude Moodle+PHP incompatible versions - # See: https://docs.moodle.org/dev/Moodle_and_PHP - - moodle-branch: 'MOODLE_36_STABLE' - php: '7.1' - - moodle-branch: 'MOODLE_37_STABLE' - php: '7.1' - - moodle-branch: 'MOODLE_38_STABLE' - php: '7.1' - - moodle-branch: 'MOODLE_39_STABLE' - php: '7.1' - - moodle-branch: 'MOODLE_310_STABLE' - php: '7.1' - - moodle-branch: 'MOODLE_311_STABLE' - php: '7.1' - - moodle-branch: 'MOODLE_36_STABLE' - php: '7.2' - - moodle-branch: 'MOODLE_37_STABLE' - php: '7.2' - - moodle-branch: 'MOODLE_311_STABLE' - php: '7.2' - - moodle-branch: 'MOODLE_35_STABLE' - php: '7.3' - - moodle-branch: 'MOODLE_36_STABLE' - php: '7.3' - - moodle-branch: 'MOODLE_37_STABLE' - php: '7.3' - - moodle-branch: 'MOODLE_35_STABLE' - php: '7.4' - - moodle-branch: 'MOODLE_36_STABLE' - php: '7.4' - - moodle-branch: 'MOODLE_37_STABLE' - php: '7.4' - steps: - name: Check out repository code uses: actions/checkout@v2 From 50d6551159b7f17d1f53b6b2803494b3f1b7b744 Mon Sep 17 00:00:00 2001 From: Pol Torrent i Soler Date: Thu, 2 Jun 2022 14:52:14 +0200 Subject: [PATCH 3/8] test: factor out duplicated code --- .github/workflows/ci.yml | 6 ++--- tests/helper.php | 49 +++++++++++++++++----------------------- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index caf8caa..8d58c26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,9 +54,9 @@ jobs: - name: Add filter & commons qtype run: | moodle-plugin-ci add-plugin wiris/moodle-filter_wiris - moodle-plugin-ci add-plugin wiris/moodle-qtype_wq - moodle-plugin-ci add-plugin wiris/moodle-qtype_shortanswerwiris - moodle-plugin-ci add-plugin wiris/moodle-qtype_multichoicewiris + moodle-plugin-ci add-plugin --branch ${GITHUB_REF##*/} wiris/moodle-qtype_wq + moodle-plugin-ci add-plugin --branch ${GITHUB_REF##*/} wiris/moodle-qtype_shortanswerwiris + moodle-plugin-ci add-plugin --branch ${GITHUB_REF##*/} wiris/moodle-qtype_multichoicewiris - name: Install moodle-plugin-ci run: | diff --git a/tests/helper.php b/tests/helper.php index 8db3eb7..3544092 100644 --- a/tests/helper.php +++ b/tests/helper.php @@ -98,24 +98,12 @@ public function get_multianswerwiris_question_data_threesubq() { $mc->penalty = 0.0; $mc->qtype = 'multichoicewiris'; - $mc->options = new stdClass(); - $mc->options->layout = 0; - $mc->options->single = 1; - $mc->options->shuffleanswers = 0; - $mc->options->correctfeedback = ''; - $mc->options->correctfeedbackformat = 1; - $mc->options->partiallycorrectfeedback = ''; - $mc->options->partiallycorrectfeedbackformat = 1; - $mc->options->incorrectfeedback = ''; - $mc->options->incorrectfeedbackformat = 1; - $mc->options->answernumbering = 0; - $mc->options->shownumcorrect = 0; - - $mc->options->answers = array( + $answers = array( 23 => new question_answer(23, '#b', 1, 'Well done!', FORMAT_HTML), 24 => new question_answer(24, '1', 0, '...', FORMAT_HTML), 25 => new question_answer(25, '2', 0, '...', FORMAT_HTML), ); + $this->set_mc_options($mc, $answers); $qdata->options = new stdClass(); $qdata->options->questions = array( @@ -185,23 +173,11 @@ public function get_multianswerwiris_question_data_dollarsigns() { $mc->penalty = 0.0; $mc->qtype = 'multichoice'; - $mc->options = new stdClass(); - $mc->options->layout = 0; - $mc->options->single = 1; - $mc->options->shuffleanswers = 0; - $mc->options->correctfeedback = ''; - $mc->options->correctfeedbackformat = 1; - $mc->options->partiallycorrectfeedback = ''; - $mc->options->partiallycorrectfeedbackformat = 1; - $mc->options->incorrectfeedback = ''; - $mc->options->incorrectfeedbackformat = 1; - $mc->options->answernumbering = 0; - $mc->options->shownumcorrect = 0; - - $mc->options->answers = array( + $answers = array( 23 => new question_answer(23, 'y,y,$3', 0, '', FORMAT_HTML), 24 => new question_answer(24, '$3,y,y', 0, '', FORMAT_HTML), ); + $this->set_mc_options($mc, $answers); $qdata->options = new stdClass(); $qdata->options->questions = array( @@ -214,6 +190,23 @@ public function get_multianswerwiris_question_data_dollarsigns() { return $qdata; } + private function set_mc_options($mc, $answers) { + $mc->options = new stdClass(); + $mc->options->layout = 0; + $mc->options->single = 1; + $mc->options->shuffleanswers = 0; + $mc->options->correctfeedback = ''; + $mc->options->correctfeedbackformat = 1; + $mc->options->partiallycorrectfeedback = ''; + $mc->options->partiallycorrectfeedbackformat = 1; + $mc->options->incorrectfeedback = ''; + $mc->options->incorrectfeedbackformat = 1; + $mc->options->answernumbering = 0; + $mc->options->shownumcorrect = 0; + + $mc->options->answers = $answers; + } + /** * Makes a multianswerwiris question about completing two blanks in some text. * @return object the question definition data, as it might be returned from From 2e32228b510c51d8c6e71de829cba22a82b3c18f Mon Sep 17 00:00:00 2001 From: Pol Torrent i Soler Date: Thu, 9 Jun 2022 12:18:35 +0200 Subject: [PATCH 4/8] test: behat corrections --- renderer.php | 2 +- tests/behat/add.feature | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/renderer.php b/renderer.php index 9d3cfd9..9e54180 100644 --- a/renderer.php +++ b/renderer.php @@ -26,7 +26,7 @@ public function __construct(moodle_page $page, $target) { } class qtype_multianswerwiris_helper_renderer extends qtype_multianswer_renderer { public function subquestion(question_attempt $qa, question_display_options $options, $index, - question_automatically_gradable $subq) { + $subq) { if ($subq->get_type_name() == 'shortanswerwiris') { $subquestion = new qtype_multianswerwiris_shortanswer_helper_question($subq); } else if (substr($subq->get_type_name(), -5) == 'wiris') { diff --git a/tests/behat/add.feature b/tests/behat/add.feature index d6aacc3..71bc96d 100644 --- a/tests/behat/add.feature +++ b/tests/behat/add.feature @@ -29,10 +29,11 @@ Feature: Test creating a Multianswer Wiris (Cloze) question | Question text | {1:SHORTANSWER:=#r1} is the number one. | | General feedback | The capital of Germany is #r1. | And I open Wiris Quizzes Studio - And I click on "Define random variables and functions" "text" + And I click on "Random variables" "text" And I wait "10" seconds And I add the variable "r1" with value "1" - And I click on "//*[@id='wrsUI_quizzesStudioHomeSaveButton']" "xpath_element" + And I go back in Wiris Quizzes Studio + And I save Wiris Quizzes Studio And I click on "//*[@id='id_submitbutton']" "xpath_element" Then I should see "multianswer-wiris-001" in the "categoryquestions" "table" @@ -42,10 +43,11 @@ Feature: Test creating a Multianswer Wiris (Cloze) question And I choose the question type "Cloze - science" And I set the field "Question name" to "multianswer-wiris-002" And I open Wiris Quizzes Studio - And I click on "Define random variables and functions" "text" + And I click on "Random variables" "text" And I add the variable "r1" with value "1" And I add the variable "r2" with value "5" - And I click on "//*[@id='wrsUI_quizzesStudioHomeSaveButton']" "xpath_element" + And I go back in Wiris Quizzes Studio + And I save Wiris Quizzes Studio And I set the field "Question text" to "Please select number one {1:MC:=#r1}" And I set the field "General feedback" to "You are the number one." When I press "id_submitbutton" @@ -72,9 +74,10 @@ Feature: Test creating a Multianswer Wiris (Cloze) question | Question name | multianswer-wiris-004 | | Question text |

Type -10: {:SA:=\#a}

Type 5: {:SA:=5}

Choose 5/57: {:MC:=\#b~1~2}

Formula #b

| And I open Wiris Quizzes Studio - And I click on "Define random variables and functions" "text" + And I click on "Random variables" "text" And I wait "10" seconds And I add the variable "a" with value "-10" And I add the variable "b" with value "15/171" - And I click on "//*[@id='wrsUI_quizzesStudioHomeSaveButton']" "xpath_element" + And I go back in Wiris Quizzes Studio + And I save Wiris Quizzes Studio And I press "id_submitbutton" From 361262081632b593080ce34db8a9e94c2bac6631 Mon Sep 17 00:00:00 2001 From: Pol Torrent i Soler Date: Thu, 9 Jun 2022 12:32:49 +0200 Subject: [PATCH 5/8] test: runs tests against moodle 400 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d58c26..0bc840d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: fail-fast: false matrix: php: ['7.3', '7.4'] - moodle-branch: ['MOODLE_39_STABLE', 'MOODLE_310_STABLE', 'MOODLE_311_STABLE'] + moodle-branch: ['MOODLE_39_STABLE', 'MOODLE_310_STABLE', 'MOODLE_311_STABLE', 'MOODLE_400_STABLE'] database: [pgsql] steps: - name: Check out repository code From 0c025f6ba5c7419074ac1aee1db3f5c2474dcb3b Mon Sep 17 00:00:00 2001 From: Pol Torrent i Soler Date: Thu, 9 Jun 2022 12:40:54 +0200 Subject: [PATCH 6/8] ops: use postgres 10 to test moodle 400 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0bc840d..dffe2e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: services: postgres: - image: postgres:9.6 + image: postgres:10 env: POSTGRES_USER: 'postgres' POSTGRES_HOST_AUTH_METHOD: 'trust' From f021c04c024d2e3766eabfc4e57837138a3ab2e0 Mon Sep 17 00:00:00 2001 From: Pol Torrent i Soler Date: Thu, 9 Jun 2022 12:59:32 +0200 Subject: [PATCH 7/8] ops: revert behat testing for moodle 40, will be done in separate branch --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dffe2e9..402bf3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: fail-fast: false matrix: php: ['7.3', '7.4'] - moodle-branch: ['MOODLE_39_STABLE', 'MOODLE_310_STABLE', 'MOODLE_311_STABLE', 'MOODLE_400_STABLE'] + moodle-branch: ['MOODLE_39_STABLE', 'MOODLE_310_STABLE', 'MOODLE_311_STABLE'] database: [pgsql] steps: - name: Check out repository code From 71812b99859581834c5f9614951820204bc2a0f2 Mon Sep 17 00:00:00 2001 From: Pol Torrent i Soler Date: Wed, 15 Jun 2022 15:22:53 +0200 Subject: [PATCH 8/8] chore: bump version number to 4.5.0 --- version.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/version.php b/version.php index 814b468..fff117c 100644 --- a/version.php +++ b/version.php @@ -16,11 +16,11 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2022040800; -$plugin->release = '4.4.3'; -$plugin->requires = 2011060313; +$plugin->version = 2022061500; +$plugin->requires = 2015111600; // Moodle 3.0. +$plugin->release = '4.5.0'; $plugin->maturity = MATURITY_STABLE; $plugin->component = 'qtype_multianswerwiris'; $plugin->dependencies = array ( - 'qtype_wq' => 2022040800 + 'qtype_wq' => 2022061500 );