Skip to content

Commit

Permalink
Merge pull request #36 from wiris/v4.5
Browse files Browse the repository at this point in the history
V4.5
  • Loading branch information
ptorrent-at-wiris authored Jun 15, 2022
2 parents 1d86aaa + 71812b9 commit 980b4c3
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 79 deletions.
46 changes: 6 additions & 40 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

services:
postgres:
image: postgres:9.6
image: postgres:10
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
Expand All @@ -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
Expand All @@ -88,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: |
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
15 changes: 9 additions & 6 deletions tests/behat/add.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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"
Expand All @@ -72,9 +74,10 @@ Feature: Test creating a Multianswer Wiris (Cloze) question
| Question name | multianswer-wiris-004 |
| Question text | <p>Type -10: {:SA:=\#a}</p> <p>Type 5: {:SA:=5}</p> <p>Choose 5/57: {:MC:=\#b~1~2}</p> <p>Formula #b</p> |
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"
49 changes: 21 additions & 28 deletions tests/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

0 comments on commit 980b4c3

Please sign in to comment.