Skip to content

Commit b9d40a3

Browse files
Merge pull request #94 from wiris/feat/php84
Feat/php84
2 parents bd70589 + c5417fc commit b9d40a3

18 files changed

+150
-21
lines changed

question.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class qtype_wq_question extends question_graded_automatically {
5050
*/
5151
public $corrupt = false;
5252

53-
public function __construct(question_definition $base = null) {
53+
public function __construct(?question_definition $base = null) {
5454
$this->base = $base;
5555
}
5656

@@ -184,7 +184,7 @@ public function format_text($text, $format, $qa, $component, $filearea, $itemid,
184184
$text = $this->base->format_text($text, $format, $qa, $component, $filearea, $itemid, $clean);
185185
$format = FORMAT_HTML;
186186
}
187-
$text = $this->expand_variables($text);
187+
$text = $this->expand_variables($text);
188188
return $this->base->format_text($text, $format, $qa, $component, $filearea, $itemid, $clean);
189189
}
190190

@@ -193,7 +193,7 @@ private function mathml_to_safe($input) {
193193
$mathml = array('<', '>', '"', '&', '\'');
194194
return str_replace($mathml, $safe, $input);
195195
}
196-
196+
197197
public function expand_variables($text) {
198198
if (isset($this->wirisquestioninstance)) {
199199
$text = $this->wirisquestioninstance->expandVariables($text);
@@ -216,9 +216,10 @@ public function expand_variables($text) {
216216
* safe enconding so MathJax does not interact with it.
217217
*/
218218
private function mathjax_compatibility($text) {
219-
return preg_replace_callback('/<math.*?<\/math>/s',
220-
function ($matches) {
221-
return $this->mathml_to_safe($matches[0]);
219+
return preg_replace_callback(
220+
'/<math.*?<\/math>/s',
221+
function ($matches) {
222+
return $this->mathml_to_safe($matches[0]);
222223
},
223224
$text
224225
);

questiontype.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class qtype_wq extends question_type {
2424

2525
protected $base;
2626

27-
public function __construct(question_type $base = null) {
27+
public function __construct(?question_type $base = null) {
2828
$this->base = $base;
2929
}
3030

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
interface com_wiris_quizzes_api_QuestionRequest extends com_wiris_quizzes_api_Serializable{
4+
function prefixVariables($prefix, $variablesToPrefix);
45
function isEmpty();
56
function addMetaProperty($name, $value);
67
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
22

33
interface com_wiris_quizzes_api_QuestionResponse extends com_wiris_quizzes_api_Serializable{
4+
function removePrefix($prefix, $variablesWithPrefix);
45
}

quizzes/lib/com/wiris/quizzes/api/QuizzesConstants.class.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ static function __meta__() { $»args = func_get_args(); return call_user_func_ar
1717
static $OPTION_FLOAT_FORMAT = "float_format";
1818
static $OPTION_DECIMAL_SEPARATOR = "decimal_separator";
1919
static $OPTION_DIGIT_GROUP_SEPARATOR = "digit_group_separator";
20+
static $OPTION_ITEM_SEPARATOR = "item_separator";
2021
static $OPTION_STUDENT_ANSWER_PARAMETER = "answer_parameter";
2122
static $OPTION_STUDENT_ANSWER_PARAMETER_NAME = "answer_parameter_name";
2223
static $PROPERTY_ANSWER_FIELD_TYPE = "inputField";

quizzes/lib/com/wiris/quizzes/impl/CalcDocumentTools.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,4 @@ static function setCalcSessionTitle($calcSession, $title) {
210210
}
211211
function __toString() { return 'com.wiris.quizzes.impl.CalcDocumentTools'; }
212212
}
213-
com_wiris_quizzes_impl_CalcDocumentTools::$options = new _hx_array(array(com_wiris_quizzes_api_QuizzesConstants::$OPTION_PRECISION, com_wiris_quizzes_api_QuizzesConstants::$OPTION_TIMES_OPERATOR, com_wiris_quizzes_api_QuizzesConstants::$OPTION_IMAGINARY_UNIT, com_wiris_quizzes_api_QuizzesConstants::$OPTION_IMPLICIT_TIMES_OPERATOR, com_wiris_quizzes_api_QuizzesConstants::$OPTION_FLOAT_FORMAT, com_wiris_quizzes_api_QuizzesConstants::$OPTION_DECIMAL_SEPARATOR, com_wiris_quizzes_api_QuizzesConstants::$OPTION_DIGIT_GROUP_SEPARATOR));
213+
com_wiris_quizzes_impl_CalcDocumentTools::$options = new _hx_array(array(com_wiris_quizzes_api_QuizzesConstants::$OPTION_PRECISION, com_wiris_quizzes_api_QuizzesConstants::$OPTION_TIMES_OPERATOR, com_wiris_quizzes_api_QuizzesConstants::$OPTION_IMAGINARY_UNIT, com_wiris_quizzes_api_QuizzesConstants::$OPTION_IMPLICIT_TIMES_OPERATOR, com_wiris_quizzes_api_QuizzesConstants::$OPTION_FLOAT_FORMAT, com_wiris_quizzes_api_QuizzesConstants::$OPTION_DECIMAL_SEPARATOR, com_wiris_quizzes_api_QuizzesConstants::$OPTION_DIGIT_GROUP_SEPARATOR, com_wiris_quizzes_api_QuizzesConstants::$OPTION_ITEM_SEPARATOR));

quizzes/lib/com/wiris/quizzes/impl/Option.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ public function __call($m, $a) {
2828
static $options;
2929
function __toString() { return 'com.wiris.quizzes.impl.Option'; }
3030
}
31-
com_wiris_quizzes_impl_Option::$options = new _hx_array(array(com_wiris_quizzes_api_QuizzesConstants::$OPTION_RELATIVE_TOLERANCE, com_wiris_quizzes_api_QuizzesConstants::$OPTION_TOLERANCE, com_wiris_quizzes_api_QuizzesConstants::$OPTION_PRECISION, com_wiris_quizzes_api_QuizzesConstants::$OPTION_TIMES_OPERATOR, com_wiris_quizzes_api_QuizzesConstants::$OPTION_IMAGINARY_UNIT, com_wiris_quizzes_api_QuizzesConstants::$OPTION_EXPONENTIAL_E, com_wiris_quizzes_api_QuizzesConstants::$OPTION_NUMBER_PI, com_wiris_quizzes_api_QuizzesConstants::$OPTION_IMPLICIT_TIMES_OPERATOR, com_wiris_quizzes_api_QuizzesConstants::$OPTION_FLOAT_FORMAT, com_wiris_quizzes_api_QuizzesConstants::$OPTION_DECIMAL_SEPARATOR, com_wiris_quizzes_api_QuizzesConstants::$OPTION_DIGIT_GROUP_SEPARATOR, com_wiris_quizzes_api_QuizzesConstants::$OPTION_STUDENT_ANSWER_PARAMETER, com_wiris_quizzes_api_QuizzesConstants::$OPTION_STUDENT_ANSWER_PARAMETER_NAME, com_wiris_quizzes_api_QuizzesConstants::$OPTION_TOLERANCE_DIGITS));
31+
com_wiris_quizzes_impl_Option::$options = new _hx_array(array(com_wiris_quizzes_api_QuizzesConstants::$OPTION_RELATIVE_TOLERANCE, com_wiris_quizzes_api_QuizzesConstants::$OPTION_TOLERANCE, com_wiris_quizzes_api_QuizzesConstants::$OPTION_PRECISION, com_wiris_quizzes_api_QuizzesConstants::$OPTION_TIMES_OPERATOR, com_wiris_quizzes_api_QuizzesConstants::$OPTION_IMAGINARY_UNIT, com_wiris_quizzes_api_QuizzesConstants::$OPTION_EXPONENTIAL_E, com_wiris_quizzes_api_QuizzesConstants::$OPTION_NUMBER_PI, com_wiris_quizzes_api_QuizzesConstants::$OPTION_IMPLICIT_TIMES_OPERATOR, com_wiris_quizzes_api_QuizzesConstants::$OPTION_FLOAT_FORMAT, com_wiris_quizzes_api_QuizzesConstants::$OPTION_DECIMAL_SEPARATOR, com_wiris_quizzes_api_QuizzesConstants::$OPTION_DIGIT_GROUP_SEPARATOR, com_wiris_quizzes_api_QuizzesConstants::$OPTION_STUDENT_ANSWER_PARAMETER, com_wiris_quizzes_api_QuizzesConstants::$OPTION_STUDENT_ANSWER_PARAMETER_NAME, com_wiris_quizzes_api_QuizzesConstants::$OPTION_TOLERANCE_DIGITS, com_wiris_quizzes_api_QuizzesConstants::$OPTION_ITEM_SEPARATOR));

quizzes/lib/com/wiris/quizzes/impl/QuestionImpl.class.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,6 +1571,7 @@ static function getDefaultOptions() {
15711571
$dopt->set(com_wiris_quizzes_api_QuizzesConstants::$OPTION_DIGIT_GROUP_SEPARATOR, "");
15721572
$dopt->set(com_wiris_quizzes_api_QuizzesConstants::$OPTION_STUDENT_ANSWER_PARAMETER, "false");
15731573
$dopt->set(com_wiris_quizzes_api_QuizzesConstants::$OPTION_STUDENT_ANSWER_PARAMETER_NAME, "answer");
1574+
$dopt->set(com_wiris_quizzes_api_QuizzesConstants::$OPTION_ITEM_SEPARATOR, ",");
15741575
return $dopt;
15751576
}
15761577
static function setLocalDataToArray($name, $value, $ld) {

quizzes/lib/com/wiris/quizzes/impl/QuestionRequestImpl.class.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,37 @@ public function __construct() {
88
public function isEmpty() {
99
return $this->processes === null || $this->processes->length === 0;
1010
}
11+
public function prefixVariables($prefix, $variablesToPrefix) {
12+
$_g = 0; $_g1 = $this->processes;
13+
while($_g < $_g1->length) {
14+
$p = $_g1[$_g];
15+
++$_g;
16+
if(Std::is($p, _hx_qtype("com.wiris.quizzes.impl.ProcessGetVariables"))) {
17+
$pp = $p;
18+
$variables = _hx_explode(",", $pp->names);
19+
$sb = new StringBuf();
20+
{
21+
$_g3 = 0; $_g2 = $variables->length;
22+
while($_g3 < $_g2) {
23+
$i = $_g3++;
24+
$v = $variables[$i];
25+
if($i > 0) {
26+
$sb->add(",");
27+
}
28+
if(com_wiris_util_type_Arrays::containsArray($variablesToPrefix, $v)) {
29+
$sb->add($prefix);
30+
}
31+
$sb->add($v);
32+
unset($v,$i);
33+
}
34+
unset($_g3,$_g2);
35+
}
36+
$pp->names = $sb->b;
37+
unset($variables,$sb,$pp);
38+
}
39+
unset($p);
40+
}
41+
}
1142
public function addMetaProperty($name, $value) {
1243
if($this->meta === null) {
1344
$this->meta = new _hx_array(array());

quizzes/lib/com/wiris/quizzes/impl/QuestionResponseImpl.class.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@ public function __construct() {
55
if(!php_Boot::$skip_constructor) {
66
parent::__construct();
77
}}
8+
public function removePrefix($prefix, $variablesWithPrefix) {
9+
$prefixLen = strlen($prefix);
10+
{
11+
$_g = 0; $_g1 = $this->results;
12+
while($_g < $_g1->length) {
13+
$r = $_g1[$_g];
14+
++$_g;
15+
if(Std::is($r, _hx_qtype("com.wiris.quizzes.impl.ResultGetVariables"))) {
16+
$rr = $r;
17+
$variables = $rr->variables;
18+
{
19+
$_g2 = 0;
20+
while($_g2 < $variables->length) {
21+
$v = $variables[$_g2];
22+
++$_g2;
23+
if(StringTools::startsWith($v->name, $prefix) && com_wiris_util_type_Arrays::containsArray($variablesWithPrefix, _hx_substr($v->name, $prefixLen, null))) {
24+
$v->name = _hx_substr($v->name, $prefixLen, null);
25+
}
26+
unset($v);
27+
}
28+
unset($_g2);
29+
}
30+
unset($variables,$rr);
31+
}
32+
unset($r);
33+
}
34+
}
35+
}
836
public function newInstance() {
937
return new com_wiris_quizzes_impl_QuestionResponseImpl();
1038
}

0 commit comments

Comments
 (0)