Skip to content

Commit

Permalink
3.46.1.1018
Browse files Browse the repository at this point in the history
  • Loading branch information
mcagigas-at-wiris committed Nov 18, 2016
1 parent 3882e8f commit 8f677cc
Show file tree
Hide file tree
Showing 19 changed files with 1,294 additions and 987 deletions.
69 changes: 69 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
language: php

sudo: false

cache:
directories:
- $HOME/.composer/cache

php:
- 5.6
- 7.0

env:
- MOODLE_BRANCH=MOODLE_31_STABLE DB=mysqli
- MOODLE_BRANCH=MOODLE_30_STABLE DB=pgsql
- MOODLE_BRANCH=MOODLE_29_STABLE DB=mysqli
- MOODLE_BRANCH=MOODLE_28_STABLE DB=pgsql
- MOODLE_BRANCH=MOODLE_27_STABLE DB=mysqli

matrix:
exclude:
- php: 7.0
env: MOODLE_BRANCH=MOODLE_29_STABLE DB=mysqli
- php: 7.0
env: MOODLE_BRANCH=MOODLE_28_STABLE DB=pgsql
- php: 7.0
env: MOODLE_BRANCH=MOODLE_27_STABLE DB=mysqli
- php: 5.6
env: MOODLE_BRANCH=MOODLE_31_STABLE DB=mysqli
- php: 5.6
env: MOODLE_BRANCH=MOODLE_30_STABLE DB=pgsql
- php: 5.6
env: MOODLE_BRANCH=MOODLE_29_STABLE DB=mysqli
- php: 5.6
env: MOODLE_BRANCH=MOODLE_28_STABLE DB=pgsql
- php: 5.6
env: MOODLE_BRANCH=MOODLE_27_STABLE DB=mysqli
include:
- php: 5.4
env: MOODLE_BRANCH=MOODLE_31_STABLE DB=mysqli
- php: 5.4
env: MOODLE_BRANCH=MOODLE_30_STABLE DB=pgsql
- php: 5.4
env: MOODLE_BRANCH=MOODLE_29_STABLE DB=mysqli
- php: 5.4
env: MOODLE_BRANCH=MOODLE_28_STABLE DB=pgsql
- php: 5.4
env: MOODLE_BRANCH=MOODLE_27_STABLE DB=mysqli

before_install:
- phpenv config-rm xdebug.ini
- cd ../..
- composer selfupdate
- composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^1
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"

install:
- moodle-plugin-ci add-plugin wiris/moodle-filter_wiris
- moodle-plugin-ci add-plugin wiris/moodle-qtype_wq
- moodle-plugin-ci install
script:
- moodle-plugin-ci phplint
- moodle-plugin-ci phpcpd
- moodle-plugin-ci phpmd
- moodle-plugin-ci codechecker
- moodle-plugin-ci shifter
- moodle-plugin-ci validate
- moodle-plugin-ci phpunit
- moodle-plugin-ci behat
208 changes: 115 additions & 93 deletions backup/moodle1/lib.php
Original file line number Diff line number Diff line change
@@ -1,93 +1,115 @@
<?php
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/question/type/wq/quizzes/quizzes.php');
require_once($CFG->dirroot . '/question/type/wq/lib.php');

/**
* Multianswer (aka embedded, cloze) question type conversion handler
*/
class moodle1_qtype_multianswerwiris_handler extends moodle1_qtype_multianswer_handler {

/**
* @return array
*/
public function get_question_subpaths() {
return array(
'ANSWERS/ANSWER',
'MULTIANSWERS/MULTIANSWER',
'MULTIANSWERWIRIS',
'MULTIANSWERWIRIS/WIRISOPTIONS'
);
}

/**
* Appends the multianswerwiris specific information to the question
*/
public function process_question(array $data, array $raw) {
parent::process_question($data, $raw);

$data['actualmultianswerwiris']['id'] = $this->converter->get_nextid();

$wirisprogram = '<question><wirisCasSession>';
$wirisprogram .= htmlspecialchars(wrsqz_mathmlDecode($data['multianswerwiris'][0]['wirisprogram']), ENT_COMPAT, "utf-8");
$wirisprogram .= '</wirisCasSession>';

if (isset($data['multianswerwiris'][0]['wirisoptions']) && count($data['multianswerwiris'][0]['wirisoptions']) > 0){
$wirisprogram .= '<localData>';
$wirisprogram .= $this->wrsqz_getCASForComputations($data);
$wirisprogram .= $this->wrsqz_hiddenInitialCASValue($data);
$wirisprogram .= '</localData>';
}

$wirisprogram .= '</question>';
$data['actualmultianswerwiris']['xml'] = $wirisprogram;
$this->write_xml('question_xml', $data['actualmultianswerwiris'], array('/question_xml/id'));
}

function wrsqz_getCASForComputations($data){
global $CFG;
$wrap = com_wiris_system_CallWrapper::getInstance();

$wirisquestion = '';
if (isset($data['multianswerwiris'][0]['wirisoptions'][0]['wiriscasforcomputations'])){
if ($data['multianswerwiris'][0]['wirisoptions'][0]['wiriscasforcomputations'] == 1){
$wrap->start();
$wirisquestion .= '<data name="' . com_wiris_quizzes_impl_LocalData::$KEY_SHOW_CAS . '">';
$wirisquestion .= com_wiris_quizzes_impl_LocalData::$VALUE_SHOW_CAS_ADD;
$wrap->stop();
$wirisquestion .= '</data>';
}else if ($data['multianswerwiris'][0]['wirisoptions'][0]['wiriscasforcomputations'] == 2){
$wrap->start();
$wirisquestion .= '<data name="' . com_wiris_quizzes_impl_LocalData::$KEY_SHOW_CAS . '">';
$wirisquestion .= com_wiris_quizzes_impl_LocalData::$VALUE_SHOW_CAS_REPLACE_INPUT;
$wrap->stop();
$wirisquestion .= '</data>';
}
}else{
$wrap->start();
$wirisquestion .= '<data name="' . com_wiris_quizzes_impl_LocalData::$KEY_SHOW_CAS . '">';
$wirisquestion .= com_wiris_quizzes_impl_LocalData::$VALUE_SHOW_CAS_FALSE;
$wrap->stop();
$wirisquestion .= '</data>';
}
return $wirisquestion;
}

function wrsqz_hiddenInitialCASValue($data){
global $CFG;
$wrap = com_wiris_system_CallWrapper::getInstance();

$wirisquestion = '';
if (isset($data['multianswerwiris'][0]['wirisoptions'][0]['hiddeninitialcasvalue'])){
$wrap->start();
$wirisquestion .= '<data name="' . com_wiris_quizzes_impl_LocalData::$KEY_CAS_INITIAL_SESSION . '">';
$wrap->stop();
$initialCASValue = $data['multianswerwiris'][0]['wirisoptions'][0]['hiddeninitialcasvalue'];
$wirisquestion .= htmlspecialchars(wrsqz_mathmlDecode(trim($initialCASValue)), ENT_COMPAT, "utf-8");
$wirisquestion .= '</data>';
}

return $wirisquestion;
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/question/type/wq/quizzes/quizzes.php');
require_once($CFG->dirroot . '/question/type/wq/lib.php');

/**
* Multianswer (aka embedded, cloze) question type conversion handler
*/
class moodle1_qtype_multianswerwiris_handler extends moodle1_qtype_multianswer_handler {

/**
* @return array
*/
public function get_question_subpaths() {
return array(
'ANSWERS/ANSWER',
'MULTIANSWERS/MULTIANSWER',
'MULTIANSWERWIRIS',
'MULTIANSWERWIRIS/WIRISOPTIONS'
);
}

/**
* Appends the multianswerwiris specific information to the question
*/
public function process_question(array $data, array $raw) {
parent::process_question($data, $raw);

$data['actualmultianswerwiris']['id'] = $this->converter->get_nextid();

$wirisprogram = '<question><wirisCasSession>';
$wirisprogram .= htmlspecialchars(wrsqz_mathml_decode($data['multianswerwiris'][0]['wirisprogram']), ENT_COMPAT, "utf-8");
$wirisprogram .= '</wirisCasSession>';

if (isset($data['multianswerwiris'][0]['wirisoptions']) && count($data['multianswerwiris'][0]['wirisoptions']) > 0) {
$wirisprogram .= '<localData>';
$wirisprogram .= $this->wrsqz_getcasforcomputations($data);
$wirisprogram .= $this->wrsqz_hiddeninitialcasvalue($data);
$wirisprogram .= '</localData>';
}

$wirisprogram .= '</question>';
$data['actualmultianswerwiris']['xml'] = $wirisprogram;
$this->write_xml('question_xml', $data['actualmultianswerwiris'], array('/question_xml/id'));
}

protected function wrsqz_getcasforcomputations($data) {
global $CFG;
$wrap = com_wiris_system_CallWrapper::getInstance();

$wirisquestion = '';
if (isset($data['multianswerwiris'][0]['wirisoptions'][0]['wiriscasforcomputations'])) {
if ($data['multianswerwiris'][0]['wirisoptions'][0]['wiriscasforcomputations'] == 1) {
$wrap->start();
// @codingStandardsIgnoreStart
$wirisquestion .= '<data name="' . com_wiris_quizzes_impl_LocalData::$KEY_SHOW_CAS . '">';
$wirisquestion .= com_wiris_quizzes_impl_LocalData::$VALUE_SHOW_CAS_ADD;
// @codingStandardsIgnoreEnd
$wrap->stop();
$wirisquestion .= '</data>';
} else if ($data['multianswerwiris'][0]['wirisoptions'][0]['wiriscasforcomputations'] == 2) {
$wrap->start();
// @codingStandardsIgnoreStart
$wirisquestion .= '<data name="' . com_wiris_quizzes_impl_LocalData::$KEY_SHOW_CAS . '">';
$wirisquestion .= com_wiris_quizzes_impl_LocalData::$VALUE_SHOW_CAS_REPLACE_INPUT;
// @codingStandardsIgnoreEnd
$wrap->stop();
$wirisquestion .= '</data>';
}
} else {
$wrap->start();
// @codingStandardsIgnoreStart
$wirisquestion .= '<data name="' . com_wiris_quizzes_impl_LocalData::$KEY_SHOW_CAS . '">';
$wirisquestion .= com_wiris_quizzes_impl_LocalData::$VALUE_SHOW_CAS_FALSE;
// @codingStandardsIgnoreEnd
$wrap->stop();
$wirisquestion .= '</data>';
}
return $wirisquestion;
}

protected function wrsqz_hiddeninitialcasvalue($data) {
global $CFG;
$wrap = com_wiris_system_CallWrapper::getInstance();

$wirisquestion = '';
if (isset($data['multianswerwiris'][0]['wirisoptions'][0]['hiddeninitialcasvalue'])) {
$wrap->start();
// @codingStandardsIgnoreLine
$wirisquestion .= '<data name="' . com_wiris_quizzes_impl_LocalData::$KEY_CAS_INITIAL_SESSION . '">';
$wrap->stop();
$initialcasvalue = $data['multianswerwiris'][0]['wirisoptions'][0]['hiddeninitialcasvalue'];
$wirisquestion .= htmlspecialchars(wrsqz_mathml_decode(trim($initialcasvalue)), ENT_COMPAT, "utf-8");
$wirisquestion .= '</data>';
}

return $wirisquestion;
}
}
Loading

0 comments on commit 8f677cc

Please sign in to comment.