From 9df2b777e8b7d6dc9c07c591cf808a2538d3b9b4 Mon Sep 17 00:00:00 2001 From: Manuel Cagigas Date: Tue, 12 Dec 2017 08:17:59 +0100 Subject: [PATCH] 3.59.0 stable version --- quizzes/configuration.ini.dist | 2 +- .../wiris/quizzes/impl/Assertion.class.php | 23 ++- .../com/wiris/quizzes/impl/HTMLGui.class.php | 5 +- .../quizzes/service/ServiceTools.class.php | 2 +- .../system/service/HttpRequest.class.php | 122 ++++++------- quizzes/lib/quizzes.js | 169 ++++++++++++------ quizzes/lib/version.txt | 2 +- thirdpartylibs.xml | 2 +- version.php | 4 +- 9 files changed, 205 insertions(+), 126 deletions(-) diff --git a/quizzes/configuration.ini.dist b/quizzes/configuration.ini.dist index ae705224..a0edab87 100644 --- a/quizzes/configuration.ini.dist +++ b/quizzes/configuration.ini.dist @@ -99,7 +99,7 @@ ; ; Enable WIRIS calc for algorithm edition -;quizzes.calc.enabled = "true" +;quizzes.calc.enabled = "false" ; ; Log correct answers for WIRIS hand training. diff --git a/quizzes/lib/com/wiris/quizzes/impl/Assertion.class.php b/quizzes/lib/com/wiris/quizzes/impl/Assertion.class.php index d1feccfa..4dc544ba 100644 --- a/quizzes/lib/com/wiris/quizzes/impl/Assertion.class.php +++ b/quizzes/lib/com/wiris/quizzes/impl/Assertion.class.php @@ -315,9 +315,10 @@ static function initParams() { com_wiris_quizzes_impl_Assertion::$paramnames->set(com_wiris_quizzes_impl_Assertion::$CHECK_NO_MORE_DECIMALS, new _hx_array(array("digits"))); com_wiris_quizzes_impl_Assertion::$paramnames->set(com_wiris_quizzes_impl_Assertion::$CHECK_NO_MORE_DIGITS, new _hx_array(array("digits"))); com_wiris_quizzes_impl_Assertion::$paramnames->set(com_wiris_quizzes_impl_Assertion::$CHECK_PRECISION, new _hx_array(array("min", "max", "relative"))); - com_wiris_quizzes_impl_Assertion::$paramnames->set(com_wiris_quizzes_impl_Assertion::$EQUIVALENT_FUNCTION, new _hx_array(array("name"))); - com_wiris_quizzes_impl_Assertion::$paramnames->set(com_wiris_quizzes_impl_Assertion::$EQUIVALENT_SYMBOLIC, new _hx_array(array("ordermatters", "repetitionmatters"))); - com_wiris_quizzes_impl_Assertion::$paramnames->set(com_wiris_quizzes_impl_Assertion::$EQUIVALENT_LITERAL, new _hx_array(array("ordermatters", "repetitionmatters"))); + com_wiris_quizzes_impl_Assertion::$paramnames->set(com_wiris_quizzes_impl_Assertion::$EQUIVALENT_FUNCTION, new _hx_array(array("name", com_wiris_quizzes_api_QuizzesConstants::$OPTION_TOLERANCE, com_wiris_quizzes_api_QuizzesConstants::$OPTION_RELATIVE_TOLERANCE))); + com_wiris_quizzes_impl_Assertion::$paramnames->set(com_wiris_quizzes_impl_Assertion::$EQUIVALENT_SYMBOLIC, new _hx_array(array("ordermatters", "repetitionmatters", com_wiris_quizzes_api_QuizzesConstants::$OPTION_TOLERANCE, com_wiris_quizzes_api_QuizzesConstants::$OPTION_RELATIVE_TOLERANCE))); + com_wiris_quizzes_impl_Assertion::$paramnames->set(com_wiris_quizzes_impl_Assertion::$EQUIVALENT_LITERAL, new _hx_array(array("ordermatters", "repetitionmatters", com_wiris_quizzes_api_QuizzesConstants::$OPTION_TOLERANCE, com_wiris_quizzes_api_QuizzesConstants::$OPTION_RELATIVE_TOLERANCE))); + com_wiris_quizzes_impl_Assertion::$paramnames->set(com_wiris_quizzes_impl_Assertion::$EQUIVALENT_EQUATIONS, new _hx_array(array(com_wiris_quizzes_api_QuizzesConstants::$OPTION_TOLERANCE, com_wiris_quizzes_api_QuizzesConstants::$OPTION_RELATIVE_TOLERANCE))); $paramvalues = null; com_wiris_quizzes_impl_Assertion::$paramdefault = new Hash(); $constantsExpression = com_wiris_quizzes_impl_Assertion_0($paramvalues) . ", e, i, j"; @@ -355,12 +356,25 @@ static function initParams() { $paramvalues = new Hash(); $paramvalues->set("ordermatters", "true"); $paramvalues->set("repetitionmatters", "true"); + $paramvalues->set(com_wiris_quizzes_api_QuizzesConstants::$OPTION_TOLERANCE, ""); + $paramvalues->set(com_wiris_quizzes_api_QuizzesConstants::$OPTION_RELATIVE_TOLERANCE, ""); com_wiris_quizzes_impl_Assertion::$paramdefault->set(com_wiris_quizzes_impl_Assertion::$EQUIVALENT_SYMBOLIC, $paramvalues); $paramvalues = new Hash(); $paramvalues->set("ordermatters", "true"); $paramvalues->set("repetitionmatters", "true"); + $paramvalues->set(com_wiris_quizzes_api_QuizzesConstants::$OPTION_TOLERANCE, ""); + $paramvalues->set(com_wiris_quizzes_api_QuizzesConstants::$OPTION_RELATIVE_TOLERANCE, ""); com_wiris_quizzes_impl_Assertion::$paramdefault->set(com_wiris_quizzes_impl_Assertion::$EQUIVALENT_LITERAL, $paramvalues); $paramvalues = new Hash(); + $paramvalues->set("name", ""); + $paramvalues->set(com_wiris_quizzes_api_QuizzesConstants::$OPTION_TOLERANCE, ""); + $paramvalues->set(com_wiris_quizzes_api_QuizzesConstants::$OPTION_RELATIVE_TOLERANCE, ""); + com_wiris_quizzes_impl_Assertion::$paramdefault->set(com_wiris_quizzes_impl_Assertion::$EQUIVALENT_FUNCTION, $paramvalues); + $paramvalues = new Hash(); + $paramvalues->set(com_wiris_quizzes_api_QuizzesConstants::$OPTION_TOLERANCE, ""); + $paramvalues->set(com_wiris_quizzes_api_QuizzesConstants::$OPTION_RELATIVE_TOLERANCE, ""); + com_wiris_quizzes_impl_Assertion::$paramdefault->set(com_wiris_quizzes_impl_Assertion::$EQUIVALENT_EQUATIONS, $paramvalues); + $paramvalues = new Hash(); $paramvalues->set("value", ""); com_wiris_quizzes_impl_Assertion::$paramdefault->set(com_wiris_quizzes_impl_Assertion::$CHECK_DIVISIBLE, $paramvalues); $paramvalues = new Hash(); @@ -380,9 +394,6 @@ static function initParams() { $paramvalues->set("max", ""); $paramvalues->set("relative", "true"); com_wiris_quizzes_impl_Assertion::$paramdefault->set(com_wiris_quizzes_impl_Assertion::$CHECK_PRECISION, $paramvalues); - $paramvalues = new Hash(); - $paramvalues->set("name", ""); - com_wiris_quizzes_impl_Assertion::$paramdefault->set(com_wiris_quizzes_impl_Assertion::$EQUIVALENT_FUNCTION, $paramvalues); } static function getParameterNames($name) { if(com_wiris_quizzes_impl_Assertion::$paramnames === null) { diff --git a/quizzes/lib/com/wiris/quizzes/impl/HTMLGui.class.php b/quizzes/lib/com/wiris/quizzes/impl/HTMLGui.class.php index 5742d273..280bd06d 100644 --- a/quizzes/lib/com/wiris/quizzes/impl/HTMLGui.class.php +++ b/quizzes/lib/com/wiris/quizzes/impl/HTMLGui.class.php @@ -312,11 +312,12 @@ public function printAssertionsControls($h, $q, $correctAnswer, $userAnswer, $un $h->openFieldset("wiriscomparisonfieldset" . _hx_string_rec($unique, "") . $answers, $this->t->t("comparisonwithstudentanswer"), "wirismainfieldset wiriscomparisonfieldset"); $h->help("wiriscomparisonhelp" . _hx_string_rec($unique, ""), "http://www.wiris.com/quizzes/docs/moodle/manual/validation#comparison", $this->t->t("manual")); $h->openDivClass("wiristolerance" . _hx_string_rec($unique, ""), "wiristolerance"); - $idtol = "wirisoption" . _hx_string_rec($unique, "") . "[" . com_wiris_quizzes_api_QuizzesConstants::$OPTION_TOLERANCE . "]"; + $idtolPrefix = "wirisassertionparam" . _hx_string_rec($unique, "") . "[" . com_wiris_quizzes_impl_Assertion::$EQUIVALENT_LITERAL . "," . com_wiris_quizzes_impl_Assertion::$EQUIVALENT_SYMBOLIC . "," . com_wiris_quizzes_impl_Assertion::$EQUIVALENT_EQUATIONS . "," . com_wiris_quizzes_impl_Assertion::$EQUIVALENT_FUNCTION . "]"; + $idtol = $idtolPrefix . "[" . com_wiris_quizzes_api_QuizzesConstants::$OPTION_TOLERANCE . "]" . $answers; $h->label($this->t->t("tolerancedigits") . ":", $idtol, "wirisleftlabel2"); $h->text(" "); $h->input("text", $idtol, "", null, null, null); - $idRelTol = "wirisoption" . _hx_string_rec($unique, "") . "[" . com_wiris_quizzes_api_QuizzesConstants::$OPTION_RELATIVE_TOLERANCE . "]"; + $idRelTol = $idtolPrefix . "[" . com_wiris_quizzes_api_QuizzesConstants::$OPTION_RELATIVE_TOLERANCE . "]" . $answers; $h->input("checkbox", $idRelTol, "", null, null, null); $h->label($this->t->t("relative"), $idRelTol, null); $h->close(); diff --git a/quizzes/lib/com/wiris/quizzes/service/ServiceTools.class.php b/quizzes/lib/com/wiris/quizzes/service/ServiceTools.class.php index e9239280..868e5b69 100644 --- a/quizzes/lib/com/wiris/quizzes/service/ServiceTools.class.php +++ b/quizzes/lib/com/wiris/quizzes/service/ServiceTools.class.php @@ -42,7 +42,7 @@ static function getContentType($name) { static function appendQuizzesJS() { $cfg = com_wiris_quizzes_impl_QuizzesBuilderImpl::getInstance()->getConfiguration(); $config = $cfg->getJSConfig(); - $expose = "if(!window.com) window.com={};\x0A" . "if(!window.com.wiris) window.com.wiris={};\x0A" . "if(!window.com.wiris.quizzes) window.com.wiris.quizzes={};\x0A" . "if(!window.com.wiris.quizzes.api) window.com.wiris.quizzes.api={};\x0A" . "if(!window.com.wiris.quizzes.api.ui) window.com.wiris.quizzes.api.ui={};\x0A" . "window.com.wiris.quizzes.api.QuizzesBuilder = com.wiris.quizzes.api.QuizzesBuilder;\x0A" . "window.com.wiris.quizzes.api.ConfigurationKeys = com.wiris.quizzes.api.ConfigurationKeys;\x0A" . "window.com.wiris.quizzes.api.ui.QuizzesUIConstants = com.wiris.quizzes.api.ui.QuizzesUIConstants;\x0A"; + $expose = "if(!window.com) window.com={};\x0A" . "if(!window.com.wiris) window.com.wiris={};\x0A" . "if(!window.com.wiris.quizzes) window.com.wiris.quizzes={};\x0A" . "if(!window.com.wiris.quizzes.api) window.com.wiris.quizzes.api={};\x0A" . "if(!window.com.wiris.quizzes.api.ui) window.com.wiris.quizzes.api.ui={};\x0A" . "window.com.wiris.quizzes.api.QuizzesBuilder = com.wiris.quizzes.api.QuizzesBuilder;\x0A" . "window.com.wiris.quizzes.api.ConfigurationKeys = com.wiris.quizzes.api.ConfigurationKeys;\x0A" . "window.com.wiris.quizzes.api.QuizzesConstants = com.wiris.quizzes.api.QuizzesConstants;\x0A" . "window.com.wiris.quizzes.api.ui.QuizzesUIConstants = com.wiris.quizzes.api.ui.QuizzesUIConstants;\x0A"; $main = "com.wiris.quizzes.JsQuizzesFilter.main();\x0A"; return $config . $expose . $main; } diff --git a/quizzes/lib/com/wiris/system/service/HttpRequest.class.php b/quizzes/lib/com/wiris/system/service/HttpRequest.class.php index 11880a62..c21d0c1a 100644 --- a/quizzes/lib/com/wiris/system/service/HttpRequest.class.php +++ b/quizzes/lib/com/wiris/system/service/HttpRequest.class.php @@ -1,65 +1,65 @@ . - class com_wiris_system_service_HttpRequest { - public $extraParams; - private $wrap; - - public function __construct() { - if(!php_Boot::$skip_constructor) { - $this->extraParams = new Hash(); - $this->wrap = com_wiris_system_CallWrapper::getInstance(); - }} - - public function setParameter($key, $value) { - $this->extraParams->set($key, $value); - } - public function getParameterNames() { - // At this point we need to access directly to $_GET and $_POST variables because - // we don't know what params are sended via POST or GET. - // For security reasons this method only returns the params names. - // To get the param value optional_param method. - $param = new _hx_array(array()); - $key = ""; - foreach ($_GET as $key => $value) { - $param->insert(0, $key); - } - foreach ($_POST as $key => $value) { - $param->insert(0, $key); - } - return $param; - } - - public function getContextURL() { - return ""; - } - - public function getParameter($key) { - $this->wrap->stop(); - $parameter = null; - if (optional_param($key, null, PARAM_RAW) != null) { - $parameter = optional_param($key, null, PARAM_RAW); - } else { - if ($this->extraParams->exists($key)) { - $parameter = $this->extraParams->get($key); - } - } - $this->wrap->start(); - return $parameter; - } - + public function __construct() { + if(!php_Boot::$skip_constructor) { + $this->extraParams = new Hash(); + $this->headers = new Hash(); + $this->setHeaders(); + }} + public function getHeader($key) { + $httpKey = null; + $httpKey = "HTTP_" . $this->headers->get($key); + $header = null; + $header = isset($_SERVER[$httpKey]) ? $_SERVER[$httpKey] : ''; + return $header; + } + public function setParameter($key, $value) { + $this->extraParams->set($key, $value); + } + public function getParameterNames() { + $param = new _hx_array(array()); + $key = ""; + foreach ($_GET as $key => $value) { + $param->insert(0, $key); + } + foreach ($_POST as $key => $value) { + $param->insert(0, $key); + } + return $param; + } + public function getContextURL() { + return ""; + } + public function getParameter($key) { + $param = null; + if(isset($_POST[$key])) { + $param = $_POST[$key]; + } else { + if(isset($_GET[$key])) { + $param = $_GET[$key]; + } else { + if($this->extraParams->exists($key)) { + return $this->extraParams->get($key); + } + } + } + return $param; + } + public function setHeaders() { + $this->headers->set("User-Agent", "USER_AGENT"); + } + public $headers; + public $extraParams; + public function __call($m, $a) { + if(isset($this->$m) && is_callable($this->$m)) + return call_user_func_array($this->$m, $a); + else if(isset($this->»dynamics[$m]) && is_callable($this->»dynamics[$m])) + return call_user_func_array($this->»dynamics[$m], $a); + else if('toString' == $m) + return $this->__toString(); + else + throw new HException('Unable to call «'.$m.'»'); + } + function __toString() { return 'com.wiris.system.service.HttpRequest'; } } diff --git a/quizzes/lib/quizzes.js b/quizzes/lib/quizzes.js index f8cbfd09..27a3a4bd 100644 --- a/quizzes/lib/quizzes.js +++ b/quizzes/lib/quizzes.js @@ -2585,12 +2585,18 @@ com.wiris.quizzes.JsEditorInput.prototype = $extend(com.wiris.quizzes.JsInput.pr return this.editor; } ,setHandListener: function() { - if(this.editor != null && this.editor.isReady()) { - if(this.editor.getHand && this.editor.getHand() != null) this.editor.getHand().addHandListener(new com.wiris.quizzes.QuizzesHandListener(null,this.startHandler)); - } else this.delay($bind(this,this.setHandListener),200); + var win = this.getOwnerWindow(); + if(win != null && !win.closed) { + if(this.editor != null && this.editor.isReady()) { + if(this.editor.getHand && this.editor.getHand() != null) this.editor.getHand().addHandListener(new com.wiris.quizzes.QuizzesHandListener(null,this.startHandler)); + } else this.delay($bind(this,this.setHandListener),200); + } } ,setEditorListener: function() { - if(this.editor != null) this.editor.getEditorModel().addEditorListener(new com.wiris.quizzes.QuizzesEditorListener(this.changeHandler,this.editor)); else this.delay($bind(this,this.setEditorListener),200); + var win = this.getOwnerWindow(); + if(win != null && !win.closed) { + if(this.editor != null) this.editor.getEditorModel().addEditorListener(new com.wiris.quizzes.QuizzesEditorListener(this.changeHandler,this.editor)); else this.delay($bind(this,this.setEditorListener),200); + } } ,addOnChangeHandler: function(handler) { var _g = this; @@ -5756,11 +5762,8 @@ com.wiris.quizzes.JsStudio.prototype = $extend(com.wiris.quizzes.JsInput.prototy ,updateTolerancePrecisionWarnings: function(name,question) { if(name == "wiriscassession" || name == com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE || name == com.wiris.quizzes.api.QuizzesConstants.OPTION_PRECISION) { if(this.htmlguiconf.tabVariables && this.htmlguiconf.tabCorrectAnswer && this.htmlguiconf.optOpenAnswer) { - var precision = question.getOption(com.wiris.quizzes.api.QuizzesConstants.OPTION_PRECISION); - var tolerance = question.getOption(com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE); - tolerance = HxOverrides.substr(tolerance,5,tolerance.length - 6); - var pint = Std.parseInt(precision); - var tint = Std.parseInt(tolerance); + var pint = Std.parseInt(question.getOption(com.wiris.quizzes.api.QuizzesConstants.OPTION_PRECISION)); + var tint = this.getCurrentTolerance(); var show = question.wirisCasSession != null; var warn = pint == null || tint == null || pint <= tint; this.setWarning("warningtoleranceprecision",com.wiris.quizzes.JsMessageBox.MESSAGE_WARNING,warn && show); @@ -5777,7 +5780,7 @@ com.wiris.quizzes.JsStudio.prototype = $extend(com.wiris.quizzes.JsInput.prototy if(this.htmlguiconf.tabVariables && this.htmlguiconf.tabCorrectAnswer && this.htmlguiconf.optOpenAnswer) { var format = question.getOption(com.wiris.quizzes.api.QuizzesConstants.OPTION_FLOAT_FORMAT); format = format.substring(format.length - 1); - var relative = question.getOption(com.wiris.quizzes.api.QuizzesConstants.OPTION_RELATIVE_TOLERANCE) == "true"; + var relative = this.getCurrentRelativeTolerance(); var show = question.wirisCasSession != null; this.setWarning("warningreltolfixedprec",com.wiris.quizzes.JsMessageBox.MESSAGE_WARNING,relative && format == "f" && show); this.setWarning("warningabstolfloatprec",com.wiris.quizzes.JsMessageBox.MESSAGE_WARNING,!relative && format != "f" && show); @@ -5795,7 +5798,7 @@ com.wiris.quizzes.JsStudio.prototype = $extend(com.wiris.quizzes.JsInput.prototy var amaxi = Std.parseInt(amax); var warn = amin != "" && amini == null || amax != "" && amaxi == null || amax == "" && amin == "" || amini != null && amaxi != null && amini > amaxi; this.setWarning("warningcheckprecisionformat",com.wiris.quizzes.JsMessageBox.MESSAGE_ERROR,warn); - var trel = question.getOption(com.wiris.quizzes.api.QuizzesConstants.OPTION_RELATIVE_TOLERANCE) == "true"; + var trel = this.getCurrentRelativeTolerance(); this.setWarning("warningcheckprecisionvsrelativetolerance",com.wiris.quizzes.JsMessageBox.MESSAGE_WARNING,trel && !arel); this.setWarning("warningcheckprecisionvsabsolutetolerance",com.wiris.quizzes.JsMessageBox.MESSAGE_WARNING,!trel && arel); if(this.htmlguiconf.tabVariables) { @@ -5815,6 +5818,31 @@ com.wiris.quizzes.JsStudio.prototype = $extend(com.wiris.quizzes.JsInput.prototy } } } + ,getCurrentRelativeTolerance: function() { + var rel = this.getCurrentToleranceImpl(com.wiris.quizzes.api.QuizzesConstants.OPTION_RELATIVE_TOLERANCE); + return rel.toLowerCase() == "true"; + } + ,getCurrentTolerance: function() { + var tol = this.getCurrentToleranceImpl(com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE); + tol = HxOverrides.substr(tol,5,tol.length - 6); + return Std.parseInt(tol); + } + ,getCurrentToleranceImpl: function(paramName) { + var q = (js.Boot.__cast(this.question , com.wiris.quizzes.impl.QuestionInternal)).getImpl(); + var tolAssertions = [com.wiris.quizzes.impl.Assertion.EQUIVALENT_LITERAL,com.wiris.quizzes.impl.Assertion.EQUIVALENT_SYMBOLIC,com.wiris.quizzes.impl.Assertion.EQUIVALENT_EQUATIONS,com.wiris.quizzes.impl.Assertion.EQUIVALENT_FUNCTION]; + var tol = null; + var _g = 0, _g1 = q.assertions; + while(_g < _g1.length) { + var a = _g1[_g]; + ++_g; + if(a.getCorrectAnswer() == "" + this.index && a.getAnswer() == "" + this.userAnswer && com.wiris.util.type.Arrays.contains(tolAssertions,a.name)) { + tol = a.getParam(paramName); + break; + } + } + if(tol == null || tol == com.wiris.quizzes.impl.Assertion.getParameterDefaultValue(com.wiris.quizzes.impl.Assertion.EQUIVALENT_LITERAL,paramName)) tol = q.getOption(paramName); + return tol; + } ,addBehaviors: function(element,question,instance) { var _g1 = this; var allelements = element.getElementsByTagName("*"); @@ -6051,41 +6079,64 @@ com.wiris.quizzes.JsStudio.prototype = $extend(com.wiris.quizzes.JsInput.prototy var userAnswer = [isSyntactic?0:Std.parseInt(this.getIndex(elem[0].id,4))]; controller[0].setQuestionValue = (function(userAnswer,correctAnswer,paramName,names,elem) { return function(value) { - var _g11 = 0; - while(_g11 < names[0].length) { - var assertionName = names[0][_g11]; - ++_g11; - var _g3 = 0, _g2 = question.assertions.length; - while(_g3 < _g2) { - var index = _g3++; - if(question.assertions[index].name == assertionName && question.assertions[index].getAnswer() == "" + userAnswer[0] && question.assertions[index].getCorrectAnswer() == "" + correctAnswer[0]) { - var actualName = paramName[0]; - if(assertionName == "equivalent_function" && paramName[0] == "name") { - if(StringTools.startsWith(value,"#")) { - value = HxOverrides.substr(value,1,null); - elem[0].value = value; - } - } else if(paramName[0] == "list") { - if(assertionName == "syntax_quantity" || value != "true") question.assertions[index].setParam("nobracketslist",value); - value = value == "true"?"(,[":"(,[,{"; - actualName = "groupoperators"; - } else if(paramName[0] == "forcebrackets") { - value = value == "true"?"false":"true"; - actualName = "nobracketslist"; - } else if(paramName[0] == "comparesets") { - value = value == "true"?"false":"true"; - question.assertions[index].setParam("ordermatters",value); - actualName = "repetitionmatters"; + if(paramName[0] == com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE) value = "10^(-" + value + ")"; + if(paramName[0] == com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE || paramName[0] == com.wiris.quizzes.api.QuizzesConstants.OPTION_RELATIVE_TOLERANCE) { + var defValue = com.wiris.quizzes.impl.Assertion.getParameterDefaultValue(names[0][0],paramName[0]); + if(question.getOption(paramName[0]) == value) { + question.setOption(paramName[0],value); + value = defValue; + } else { + var otherToleranceAssertions = false; + var _g2 = 0, _g11 = question.assertions.length; + while(_g2 < _g11) { + var index = _g2++; + if(com.wiris.util.type.Arrays.contains(names[0],question.assertions[index].name) && question.assertions[index].getParam(paramName[0]) == defValue && (question.assertions[index].getAnswer() != "" + userAnswer[0] || question.assertions[index].getCorrectAnswer() != "" + correctAnswer[0])) { + otherToleranceAssertions = true; + break; + } + } + if(!otherToleranceAssertions) { + question.setOption(paramName[0],value); + var _g2 = 0, _g11 = question.assertions.length; + while(_g2 < _g11) { + var index = _g2++; + if(com.wiris.util.type.Arrays.contains(names[0],question.assertions[index].name) && question.assertions[index].getParam(paramName[0]) == value) question.assertions[index].setParam(paramName[0],defValue); + } + value = defValue; + } + } + } + var _g2 = 0, _g11 = question.assertions.length; + while(_g2 < _g11) { + var index = _g2++; + if(question.assertions[index].getAnswer() == "" + userAnswer[0] && question.assertions[index].getCorrectAnswer() == "" + correctAnswer[0] && com.wiris.util.type.Arrays.contains(names[0],question.assertions[index].name)) { + var assertionName = question.assertions[index].name; + var actualName = paramName[0]; + if(assertionName == "equivalent_function" && paramName[0] == "name") { + if(StringTools.startsWith(value,"#")) { + value = HxOverrides.substr(value,1,null); + elem[0].value = value; } - question.assertions[index].setParam(actualName,value); + } else if(paramName[0] == "list") { + if(assertionName == "syntax_quantity" || value != "true") question.assertions[index].setParam("nobracketslist",value); + value = value == "true"?"(,[":"(,[,{"; + actualName = "groupoperators"; + } else if(paramName[0] == "forcebrackets") { + value = value == "true"?"false":"true"; + actualName = "nobracketslist"; + } else if(paramName[0] == "comparesets") { + value = value == "true"?"false":"true"; + question.assertions[index].setParam("ordermatters",value); + actualName = "repetitionmatters"; } + question.assertions[index].setParam(actualName,value); } } }; })(userAnswer,correctAnswer,paramName,names,elem); controller[0].getQuestionValue = (function(userAnswer,correctAnswer,paramName,names) { return function() { - var value; + var value = ""; var _g11 = 0; while(_g11 < names[0].length) { var assertionName = names[0][_g11]; @@ -6096,10 +6147,13 @@ com.wiris.quizzes.JsStudio.prototype = $extend(com.wiris.quizzes.JsInput.prototy value = "" + Std.string(!_g1.inList("{",question.assertions[index].getParam("groupoperators"))); if(assertionName == "syntax_quantity" && value == "true") value = question.assertions[index].getParam("nobracketslist"); } else if(paramName[0] == "forcebrackets") value = question.assertions[index].getParam("nobracketslist") == "true"?"false":"true"; else if(paramName[0] == "comparesets") value = question.assertions[index].getParam("ordermatters") == "true"?"false":"true"; else value = question.assertions[index].getParam(paramName[0]); - return value; - } else if(names[0].length == 1) return com.wiris.quizzes.impl.Assertion.getParameterDefaultValue(assertionName,paramName[0]); + } else if(names[0].length == 1) value = com.wiris.quizzes.impl.Assertion.getParameterDefaultValue(assertionName,paramName[0]); } - return ""; + if(paramName[0] == com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE || paramName[0] == com.wiris.quizzes.api.QuizzesConstants.OPTION_RELATIVE_TOLERANCE) { + if(value == com.wiris.quizzes.impl.Assertion.getParameterDefaultValue(names[0][0],paramName[0])) value = question.getOption(paramName[0]); + if(paramName[0] == com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE) value = HxOverrides.substr(value,5,value.length - 6); + } + return value; }; })(userAnswer,correctAnswer,paramName,names); controller[0].updateInterface = (function(userAnswer,paramName,names,elem) { @@ -6133,6 +6187,7 @@ com.wiris.quizzes.JsStudio.prototype = $extend(com.wiris.quizzes.JsInput.prototy } } if(names[0].length == 1 && names[0][0] == com.wiris.quizzes.impl.Assertion.CHECK_PRECISION) _g1.updateTolerancePrecisionWarnings(com.wiris.quizzes.impl.Assertion.CHECK_PRECISION,question); + if(paramName[0] == com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE || paramName[0] == com.wiris.quizzes.api.QuizzesConstants.OPTION_RELATIVE_TOLERANCE) _g1.updateTolerancePrecisionWarnings(paramName[0],question); if(_g1.ready) { var _g2 = 0; while(_g2 < names[0].length) { @@ -6446,7 +6501,7 @@ com.wiris.quizzes.JsStudio.prototype = $extend(com.wiris.quizzes.JsInput.prototy var formelem = elem[0]; controller[0].setQuestionValue = (function(name,elem) { return function(value) { - if(name[0] == com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE) value = "10^(-" + value + ")"; else if(name[0] == com.wiris.quizzes.api.QuizzesConstants.OPTION_FLOAT_FORMAT) { + if(name[0] == com.wiris.quizzes.api.QuizzesConstants.OPTION_FLOAT_FORMAT) { var prev = _g1.splitFloatFormat(question.getOption(com.wiris.quizzes.api.QuizzesConstants.OPTION_FLOAT_FORMAT)); var index = _g1.getIndex(elem[0].id,2); if(index == "0") prev[1] = value; else if(index == "1") prev[2] = value; @@ -6462,7 +6517,7 @@ com.wiris.quizzes.JsStudio.prototype = $extend(com.wiris.quizzes.JsInput.prototy controller[0].getQuestionValue = (function(name,elem) { return function() { var value = question.getOption(name[0]); - if(name[0] == com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE) value = HxOverrides.substr(value,5,value.length - 6); else if(name[0] == com.wiris.quizzes.api.QuizzesConstants.OPTION_DIGIT_GROUP_SEPARATOR) { + if(name[0] == com.wiris.quizzes.api.QuizzesConstants.OPTION_DIGIT_GROUP_SEPARATOR) { var format = question.getOption(com.wiris.quizzes.api.QuizzesConstants.OPTION_FLOAT_FORMAT); var s = _g1.splitFloatFormat(format); value = s[0]; @@ -7320,9 +7375,10 @@ com.wiris.quizzes.impl.Assertion.initParams = function() { com.wiris.quizzes.impl.Assertion.paramnames.set(com.wiris.quizzes.impl.Assertion.CHECK_NO_MORE_DECIMALS,["digits"]); com.wiris.quizzes.impl.Assertion.paramnames.set(com.wiris.quizzes.impl.Assertion.CHECK_NO_MORE_DIGITS,["digits"]); com.wiris.quizzes.impl.Assertion.paramnames.set(com.wiris.quizzes.impl.Assertion.CHECK_PRECISION,["min","max","relative"]); - com.wiris.quizzes.impl.Assertion.paramnames.set(com.wiris.quizzes.impl.Assertion.EQUIVALENT_FUNCTION,["name"]); - com.wiris.quizzes.impl.Assertion.paramnames.set(com.wiris.quizzes.impl.Assertion.EQUIVALENT_SYMBOLIC,["ordermatters","repetitionmatters"]); - com.wiris.quizzes.impl.Assertion.paramnames.set(com.wiris.quizzes.impl.Assertion.EQUIVALENT_LITERAL,["ordermatters","repetitionmatters"]); + com.wiris.quizzes.impl.Assertion.paramnames.set(com.wiris.quizzes.impl.Assertion.EQUIVALENT_FUNCTION,["name",com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE,com.wiris.quizzes.api.QuizzesConstants.OPTION_RELATIVE_TOLERANCE]); + com.wiris.quizzes.impl.Assertion.paramnames.set(com.wiris.quizzes.impl.Assertion.EQUIVALENT_SYMBOLIC,["ordermatters","repetitionmatters",com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE,com.wiris.quizzes.api.QuizzesConstants.OPTION_RELATIVE_TOLERANCE]); + com.wiris.quizzes.impl.Assertion.paramnames.set(com.wiris.quizzes.impl.Assertion.EQUIVALENT_LITERAL,["ordermatters","repetitionmatters",com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE,com.wiris.quizzes.api.QuizzesConstants.OPTION_RELATIVE_TOLERANCE]); + com.wiris.quizzes.impl.Assertion.paramnames.set(com.wiris.quizzes.impl.Assertion.EQUIVALENT_EQUATIONS,[com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE,com.wiris.quizzes.api.QuizzesConstants.OPTION_RELATIVE_TOLERANCE]); var paramvalues; com.wiris.quizzes.impl.Assertion.paramdefault = new Hash(); var constantsExpression = com.wiris.system.Utf8.uchr(960) + ", e, i, j"; @@ -7360,12 +7416,25 @@ com.wiris.quizzes.impl.Assertion.initParams = function() { paramvalues = new Hash(); paramvalues.set("ordermatters","true"); paramvalues.set("repetitionmatters","true"); + paramvalues.set(com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE,""); + paramvalues.set(com.wiris.quizzes.api.QuizzesConstants.OPTION_RELATIVE_TOLERANCE,""); com.wiris.quizzes.impl.Assertion.paramdefault.set(com.wiris.quizzes.impl.Assertion.EQUIVALENT_SYMBOLIC,paramvalues); paramvalues = new Hash(); paramvalues.set("ordermatters","true"); paramvalues.set("repetitionmatters","true"); + paramvalues.set(com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE,""); + paramvalues.set(com.wiris.quizzes.api.QuizzesConstants.OPTION_RELATIVE_TOLERANCE,""); com.wiris.quizzes.impl.Assertion.paramdefault.set(com.wiris.quizzes.impl.Assertion.EQUIVALENT_LITERAL,paramvalues); paramvalues = new Hash(); + paramvalues.set("name",""); + paramvalues.set(com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE,""); + paramvalues.set(com.wiris.quizzes.api.QuizzesConstants.OPTION_RELATIVE_TOLERANCE,""); + com.wiris.quizzes.impl.Assertion.paramdefault.set(com.wiris.quizzes.impl.Assertion.EQUIVALENT_FUNCTION,paramvalues); + paramvalues = new Hash(); + paramvalues.set(com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE,""); + paramvalues.set(com.wiris.quizzes.api.QuizzesConstants.OPTION_RELATIVE_TOLERANCE,""); + com.wiris.quizzes.impl.Assertion.paramdefault.set(com.wiris.quizzes.impl.Assertion.EQUIVALENT_EQUATIONS,paramvalues); + paramvalues = new Hash(); paramvalues.set("value",""); com.wiris.quizzes.impl.Assertion.paramdefault.set(com.wiris.quizzes.impl.Assertion.CHECK_DIVISIBLE,paramvalues); paramvalues = new Hash(); @@ -7385,9 +7454,6 @@ com.wiris.quizzes.impl.Assertion.initParams = function() { paramvalues.set("max",""); paramvalues.set("relative","true"); com.wiris.quizzes.impl.Assertion.paramdefault.set(com.wiris.quizzes.impl.Assertion.CHECK_PRECISION,paramvalues); - paramvalues = new Hash(); - paramvalues.set("name",""); - com.wiris.quizzes.impl.Assertion.paramdefault.set(com.wiris.quizzes.impl.Assertion.EQUIVALENT_FUNCTION,paramvalues); } com.wiris.quizzes.impl.Assertion.getParameterNames = function(name) { if(com.wiris.quizzes.impl.Assertion.paramnames == null) com.wiris.quizzes.impl.Assertion.initParams(); @@ -8505,11 +8571,12 @@ com.wiris.quizzes.impl.HTMLGui.prototype = { h.openFieldset("wiriscomparisonfieldset" + unique + answers,this.t.t("comparisonwithstudentanswer"),"wirismainfieldset wiriscomparisonfieldset"); h.help("wiriscomparisonhelp" + unique,"http://www.wiris.com/quizzes/docs/moodle/manual/validation#comparison",this.t.t("manual")); h.openDivClass("wiristolerance" + unique,"wiristolerance"); - var idtol = "wirisoption" + unique + "[" + com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE + "]"; + var idtolPrefix = "wirisassertionparam" + unique + "[" + com.wiris.quizzes.impl.Assertion.EQUIVALENT_LITERAL + "," + com.wiris.quizzes.impl.Assertion.EQUIVALENT_SYMBOLIC + "," + com.wiris.quizzes.impl.Assertion.EQUIVALENT_EQUATIONS + "," + com.wiris.quizzes.impl.Assertion.EQUIVALENT_FUNCTION + "]"; + var idtol = idtolPrefix + "[" + com.wiris.quizzes.api.QuizzesConstants.OPTION_TOLERANCE + "]" + answers; h.label(this.t.t("tolerancedigits") + ":",idtol,"wirisleftlabel2"); h.text(" "); h.input("text",idtol,"",null,null,null); - var idRelTol = "wirisoption" + unique + "[" + com.wiris.quizzes.api.QuizzesConstants.OPTION_RELATIVE_TOLERANCE + "]"; + var idRelTol = idtolPrefix + "[" + com.wiris.quizzes.api.QuizzesConstants.OPTION_RELATIVE_TOLERANCE + "]" + answers; h.input("checkbox",idRelTol,"",null,null,null); h.label(this.t.t("relative"),idRelTol,null); h.close(); diff --git a/quizzes/lib/version.txt b/quizzes/lib/version.txt index 840ebda7..9c93023b 100644 --- a/quizzes/lib/version.txt +++ b/quizzes/lib/version.txt @@ -1 +1 @@ -3.58.0 \ No newline at end of file +3.59.0 \ No newline at end of file diff --git a/thirdpartylibs.xml b/thirdpartylibs.xml index 6be28cfe..94dfc9e5 100644 --- a/thirdpartylibs.xml +++ b/thirdpartylibs.xml @@ -3,7 +3,7 @@ quizzes WIRIS QUIZZES engine - 3.58.0.1029 + 3.59.0.1031 GPL 3.0+ diff --git a/version.php b/version.php index b32108e7..547c6744 100644 --- a/version.php +++ b/version.php @@ -16,9 +16,9 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2017112300; +$plugin->version = 2017121200; $plugin->requires = 2011120500; // Moodle 2.2. -$plugin->release = '3.58.0.1029'; +$plugin->release = '3.59.0.1031'; $plugin->maturity = MATURITY_STABLE; $plugin->component = 'qtype_wq'; $plugin->dependencies = array (