Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.57.0 Stable version #11

Merged
merged 38 commits into from
Oct 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9fc6a4d
2017083000 development version
mcagigas-at-wiris Aug 30, 2017
bdcd4ca
2017090100 development version
mcagigas-at-wiris Aug 31, 2017
e968cae
2017090200 development version
mcagigas-at-wiris Sep 1, 2017
c45edb1
2017090400 development version
mcagigas-at-wiris Sep 4, 2017
89aecc9
2017090500 development version
mcagigas-at-wiris Sep 4, 2017
2112f5b
2017090700 development version
mcagigas-at-wiris Sep 6, 2017
6cd6f17
2017090800 development version
mcagigas-at-wiris Sep 7, 2017
28f6dd1
2017090900 development version
mcagigas-at-wiris Sep 8, 2017
692f057
2017091000 development version
mcagigas-at-wiris Sep 9, 2017
aed0ffc
2017091100 development version
mcagigas-at-wiris Sep 10, 2017
ff64be4
2017091300 development version
mcagigas-at-wiris Sep 12, 2017
f240035
2017091400 development version
mcagigas-at-wiris Sep 13, 2017
1581cc4
2017091500 development version
mcagigas-at-wiris Sep 14, 2017
ce62112
2017091600 development version
mcagigas-at-wiris Sep 15, 2017
da2874f
2017091700 development version
mcagigas-at-wiris Sep 16, 2017
719f5ff
2017091800 development version
mcagigas-at-wiris Sep 17, 2017
a7004c3
2017091900 development version
mcagigas-at-wiris Sep 18, 2017
e686a57
2017092000 development version
mcagigas-at-wiris Sep 19, 2017
4c78219
2017092100 development version
mcagigas-at-wiris Sep 20, 2017
45fb700
2017092100 development version
mcagigas-at-wiris Sep 21, 2017
208e58b
2017092100 development version
mcagigas-at-wiris Sep 21, 2017
2bfd3e7
2017092300 development version
mcagigas-at-wiris Sep 22, 2017
89b03c6
2017092400 development version
mcagigas-at-wiris Sep 23, 2017
b2d7f05
2017092600 development version
mcagigas-at-wiris Sep 26, 2017
04c67b6
2017092700 development version
mcagigas-at-wiris Sep 26, 2017
b94d609
2017092800 development version
mcagigas-at-wiris Sep 27, 2017
c200826
2017092900 development version
mcagigas-at-wiris Sep 28, 2017
488b0d6
2017093000 development version
mcagigas-at-wiris Sep 30, 2017
b61aed8
2017100100 development version
mcagigas-at-wiris Sep 30, 2017
b0b324b
2017100200 development version
mcagigas-at-wiris Oct 2, 2017
1d5a713
2017100300 development version
mcagigas-at-wiris Oct 2, 2017
38ac722
2017100400 development version
mcagigas-at-wiris Oct 3, 2017
eb82f9b
2017100500 development version
mcagigas-at-wiris Oct 5, 2017
6e8d141
2017100600 development version
mcagigas-at-wiris Oct 6, 2017
ab2eaf7
2017100700 development version
mcagigas-at-wiris Oct 7, 2017
839c062
2017100800 development version
mcagigas-at-wiris Oct 8, 2017
2d6c04f
2017101000 development version
mcagigas-at-wiris Oct 10, 2017
5a57f1d
2017101100 Stable version
mcagigas-at-wiris Oct 11, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 80 additions & 47 deletions quizzes/lib/com/wiris/quizzes/impl/HTMLTools.class.php

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions quizzes/lib/com/wiris/quizzes/impl/QuestionInstanceImpl.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public function __construct() {
$this->variables = null;
$this->checks = null;
$this->subinstances = null;
$this->compoundChecks = null;
}}
public function pushSubinstance($subquestion) {
$this->addSubinstance($subquestion->getStepNumber() - 1);
Expand Down Expand Up @@ -863,7 +864,10 @@ public function storeImageVariable($v) {
$w->name = $v->name;
return $w;
}
public function isCompoundAnswer($checks) {
public function isCompoundAnswer() {
return $this->compoundChecks !== null;
}
public function isCompoundAnswerChecks($checks) {
if($checks !== null && $checks->length > 0) {
$id = _hx_array_get($checks, 0)->getCorrectAnswer();
if(_hx_index_of($id, "c", null) > -1) {
Expand Down Expand Up @@ -1005,7 +1009,7 @@ public function update($response) {
while($_g3 < $_g2) {
$j1 = $_g3++;
$resultChecks = $subchecks[$j1];
if($this->isCompoundAnswer($resultChecks)) {
if($this->isCompoundAnswerChecks($resultChecks)) {
if($j1 === 0) {
$this->collapseCompoundAnswerChecks($resultChecks);
} else {
Expand Down Expand Up @@ -1118,7 +1122,7 @@ public function expandVariablesText($text) {
$text = $h->expandVariablesText($text, $textvars);
}
if($this->userData->answers !== null) {
$text = $h->expandAnswersText($text, $this->userData->answers, $this->getAnswerParameterName());
$text = $h->expandAnswersText($text, $this->userData->answers, $this->getAnswerParameterName(), $this->isCompoundAnswer());
}
return $text;
}
Expand Down Expand Up @@ -1165,7 +1169,7 @@ public function expandVariablesMathML($equation) {
$equation = $h->textToMathML($equation);
}
$equation = $h->expandVariables($equation, $this->variables);
$equation = $h->expandAnswers($equation, $this->userData->answers, $this->getAnswerParameterName());
$equation = $h->expandAnswers($equation, $this->userData->answers, $this->getAnswerParameterName(), $this->isCompoundAnswer());
return $equation;
}
public function expandVariables($text) {
Expand All @@ -1175,7 +1179,7 @@ public function expandVariables($text) {
$h = new com_wiris_quizzes_impl_HTMLTools();
$h->setItemSeparator($this->getLocalData(com_wiris_quizzes_impl_LocalData::$KEY_ITEM_SEPARATOR));
$text = $h->expandVariables($text, $this->variables);
$text = $h->expandAnswers($text, $this->userData->answers, $this->getAnswerParameterName());
$text = $h->expandAnswers($text, $this->userData->answers, $this->getAnswerParameterName(), $this->isCompoundAnswer());
return $text;
}
public function defaultLocalData($name) {
Expand Down Expand Up @@ -1248,7 +1252,7 @@ public function onSerialize($s) {
$this->userData = $s->serializeChildName($this->userData, com_wiris_quizzes_impl_UserData::$TAGNAME);
$this->setChecksCompoundAnswers();
$a = $s->serializeArrayName($this->hashToChecks($this->checks), "checks");
if($this->isCompoundAnswer($a)) {
if($this->isCompoundAnswerChecks($a)) {
$this->collapseCompoundAnswerChecks($a);
}
$this->checks = $this->checksToHash($a, null);
Expand Down
17 changes: 15 additions & 2 deletions quizzes/lib/com/wiris/quizzes/impl/QuizzesBuilderImpl.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,12 @@ public function newEvalMultipleAnswersRequest($correctAnswers, $userAnswers, $qu
while($_g1 < $_g) {
$j1 = $_g1++;
$ass = $qq->assertions[$j1];
$corr = $this->getIndex($ass->getCorrectAnswer());
$ans = $this->getIndex($ass->getAnswer());
if($ass->isEquivalence()) {
$usedcorrectanswers[$this->getIndex($ass->getCorrectAnswer())] = true;
if($corr < $usedcorrectanswers->length) {
$usedcorrectanswers[$corr] = true;
}
if($ans < $usedanswers->length) {
$usedanswers[$ans] = true;
}
Expand All @@ -443,7 +446,7 @@ public function newEvalMultipleAnswersRequest($correctAnswers, $userAnswers, $qu
}
}
}
unset($j1,$ass,$ans);
unset($j1,$corr,$ass,$ans);
}
unset($_g1,$_g);
}
Expand Down Expand Up @@ -654,6 +657,16 @@ public function removeAnswerVariables($variables, $q, $qi) {
if(strlen($after) === 0 || com_wiris_util_type_IntegerTools::isInt($after) && Std::parseInt($after) <= $qi->getStudentAnswersLength()) {
$variables[$i1] = null;
$n++;
} else {
if($qq->getLocalData(com_wiris_quizzes_impl_LocalData::$KEY_OPENANSWER_COMPOUND_ANSWER) === com_wiris_quizzes_impl_LocalData::$VALUE_OPENANSWER_COMPOUND_ANSWER_TRUE) {
$qqi = $qi;
$parts = com_wiris_quizzes_impl_HTMLTools::parseCompoundAnswer($qqi->userData->answers[0]);
if(com_wiris_util_type_IntegerTools::isInt($after) && Std::parseInt($after) <= $parts->length) {
$variables[$i1] = null;
$n++;
}
unset($qqi,$parts);
}
}
unset($after);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function onSerialize($s) {
$this->userData = $s->serializeChildName($this->userData, com_wiris_quizzes_impl_UserData::$TAGNAME);
$this->setChecksCompoundAnswers();
$a = $s->serializeArrayName($this->hashToChecks($this->checks), "checks");
if($this->isCompoundAnswer($a)) {
if($this->isCompoundAnswerChecks($a)) {
$this->collapseCompoundAnswerChecks($a);
}
$this->checks = $this->checksToHash($a, null);
Expand Down
37 changes: 30 additions & 7 deletions quizzes/lib/com/wiris/quizzes/test/Tester.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testCompatibility() {
if($qi2->getCompoundAnswerGrade(0, 0, 1, $q) !== 0.0) {
throw new HException(new com_wiris_system_Exception("Failed compatibility test!", null));
}
haxe_Log::trace("Test compatibility OK!", _hx_anonymous(array("fileName" => "Tester.hx", "lineNumber" => 1186, "className" => "com.wiris.quizzes.test.Tester", "methodName" => "testCompatibility")));
haxe_Log::trace("Test compatibility OK!", _hx_anonymous(array("fileName" => "Tester.hx", "lineNumber" => 1209, "className" => "com.wiris.quizzes.test.Tester", "methodName" => "testCompatibility")));
}
public function testSubQuestion4() {
$question = "<question><subquestions><subquestion><correctAnswers><correctAnswer>12</correctAnswer></correctAnswers><assertions><assertion name=\"check_factorized\"/></assertions></subquestion><subquestion index=\"1\"><correctAnswers><correctAnswer type=\"mathml\"><![CDATA[<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mi>a</mi><mo>=</mo><mn>5</mn><mspace linebreak=\"newline\"/><mi>b</mi><mo>=</mo><mn>42</mn></math>]]></correctAnswer></correctAnswers><localData><data name=\"inputCompound\">true</data></localData></subquestion></subquestions></question>";
Expand Down Expand Up @@ -69,7 +69,7 @@ public function testSubQuestion4() {
if(_hx_index_of($s, "0_c0", null) < 0 || _hx_index_of($s, "0_c1", null) < 0) {
throw new HException(new com_wiris_system_Exception("Failed test subquestion 4! Compound indices not found", null));
}
haxe_Log::trace("Test subquestion4 OK!", _hx_anonymous(array("fileName" => "Tester.hx", "lineNumber" => 1165, "className" => "com.wiris.quizzes.test.Tester", "methodName" => "testSubQuestion4")));
haxe_Log::trace("Test subquestion4 OK!", _hx_anonymous(array("fileName" => "Tester.hx", "lineNumber" => 1188, "className" => "com.wiris.quizzes.test.Tester", "methodName" => "testSubQuestion4")));
}
public function responseSubQuestion3($s, $q, $qi) {
$qii = $qi;
Expand Down Expand Up @@ -171,6 +171,24 @@ public function testSubQuestion1() {
$this->numCalls++;
$builder->getQuizzesService()->executeAsync($qr, new com_wiris_quizzes_test_TestIdServiceListener("subquestion1", $this, $q, $qi));
}
public function responseFeedback3($r, $q, $qi) {
$qi->update($r);
if(!($qi->expandVariables("#answer1") === "<math><mn>2</mn></math>" && $qi->expandVariables("#answer2") === "<math><mn>3</mn></math>")) {
throw new HException(new com_wiris_system_Exception("Failed test feedback3!", null));
}
}
public function testFeedback3() {
$qb = com_wiris_quizzes_api_QuizzesBuilder::getInstance();
$q = $qb->readQuestion("<question><wirisCasSession><![CDATA[<session lang=\"en\" version=\"2.0\"><library closed=\"false\"><mtext style=\"color:#ffc800\" xml:lang=\"en\">variables</mtext><group><command><input><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mi>parameter</mi><mo>&nbsp;</mo><mi>answer1</mi><mo>=</mo><mn>0</mn></math></input></command><command><input><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mi>parameter</mi><mo>&nbsp;</mo><mi>answer2</mi><mo>=</mo><mn>0</mn></math></input></command></group></library></session>]]></wirisCasSession><correctAnswers><correctAnswer type=\"mathml\"><![CDATA[<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mi>a</mi><mo>=</mo><mn>1</mn><mspace linebreak=\"newline\"/><mi>b</mi><mo>=</mo><mn>2</mn></math>]]></correctAnswer></correctAnswers><assertions><assertion name=\"syntax_expression\"/><assertion name=\"equivalent_symbolic\"/></assertions><options><option name=\"tolerance\">10^(-3)</option><option name=\"relative_tolerance\">true</option><option name=\"precision\">4</option><option name=\"times_operator\">·</option><option name=\"implicit_times_operator\">false</option><option name=\"imaginary_unit\">i</option><option name=\"answer_parameter\">true</option></options><localData><data name=\"inputField\">popupEditor</data><data name=\"gradeCompound\">and</data><data name=\"gradeCompoundDistribution\"></data><data name=\"inputCompound\">true</data></localData></question>");
$qi = $qb->newQuestionInstance($q);
$u = new com_wiris_quizzes_impl_UserData();
$u->setUserCompoundAnswer(0, 0, "2");
$u->setUserCompoundAnswer(0, 1, "3");
$qi->setStudentAnswer(0, _hx_array_get($u->answers, 0)->content);
$r = $qb->newFeedbackRequest("<p>a=#answer1</p><p>b=#answer2</p>", $q, $qi);
$this->numCalls++;
$qb->getQuizzesService()->executeAsync($r, new com_wiris_quizzes_test_TestIdServiceListener("feedback3", $this, $q, $qi));
}
public function inArray($a, $b) {
$i = null;
{
Expand Down Expand Up @@ -274,7 +292,11 @@ public function onServiceResponse($id, $res, $q, $qi) {
if($id === "subquestion3") {
$this->responseSubQuestion3($res, $q, $qi);
} else {
throw new HException(new com_wiris_system_Exception("Unknown test id.", null));
if($id === "feedback3") {
$this->responseFeedback3($res, $q, $qi);
} else {
throw new HException(new com_wiris_system_Exception("Unknown test id.", null));
}
}
}
}
Expand Down Expand Up @@ -304,13 +326,13 @@ public function onServiceResponse($id, $res, $q, $qi) {
}
}
}
haxe_Log::trace("Test " . $id . " OK!", _hx_anonymous(array("fileName" => "Tester.hx", "lineNumber" => 1036, "className" => "com.wiris.quizzes.test.Tester", "methodName" => "onServiceResponse")));
haxe_Log::trace("Test " . $id . " OK!", _hx_anonymous(array("fileName" => "Tester.hx", "lineNumber" => 1039, "className" => "com.wiris.quizzes.test.Tester", "methodName" => "onServiceResponse")));
$this->endCall();
}catch(Exception $�e) {
$_ex_ = ($�e instanceof HException) ? $�e->e : $�e;
$e = $_ex_;
{
haxe_Log::trace("Failed test " . $id . "!!!", _hx_anonymous(array("fileName" => "Tester.hx", "lineNumber" => 1039, "className" => "com.wiris.quizzes.test.Tester", "methodName" => "onServiceResponse")));
haxe_Log::trace("Failed test " . $id . "!!!", _hx_anonymous(array("fileName" => "Tester.hx", "lineNumber" => 1042, "className" => "com.wiris.quizzes.test.Tester", "methodName" => "onServiceResponse")));
throw new HException($e);
}
}
Expand Down Expand Up @@ -476,7 +498,7 @@ public function testCache() {
throw new HException("Failed test");
}
if($t2 >= $t1) {
haxe_Log::trace("WARNING: Uncached question was faster than cached one! time miss: " . _hx_string_rec($t1, "") . "ms, time hit: " . _hx_string_rec($t2, "") . "ms.", _hx_anonymous(array("fileName" => "Tester.hx", "lineNumber" => 801, "className" => "com.wiris.quizzes.test.Tester", "methodName" => "testCache")));
haxe_Log::trace("WARNING: Uncached question was faster than cached one! time miss: " . _hx_string_rec($t1, "") . "ms, time hit: " . _hx_string_rec($t2, "") . "ms.", _hx_anonymous(array("fileName" => "Tester.hx", "lineNumber" => 802, "className" => "com.wiris.quizzes.test.Tester", "methodName" => "testCache")));
}
}
public function testFilter() {
Expand All @@ -499,7 +521,7 @@ public function testPerformance() {
$r = $qb->newVariablesRequest($text, $q, $qi);
$qi->update($qb->getQuizzesService()->execute($r));
$expanded = $qi->expandVariables($text);
haxe_Log::trace($expanded, _hx_anonymous(array("fileName" => "Tester.hx", "lineNumber" => 759, "className" => "com.wiris.quizzes.test.Tester", "methodName" => "testPerformance")));
haxe_Log::trace($expanded, _hx_anonymous(array("fileName" => "Tester.hx", "lineNumber" => 760, "className" => "com.wiris.quizzes.test.Tester", "methodName" => "testPerformance")));
}
public function responseTranslation1($s, $q) {
$fr = "<session lang=\"fr\" version=\"2.0\"><library closed=\"false\"><mtext style=\"color:#ffc800\">library</mtext><group><command><input><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mi>a</mi><mo>=</mo><mi>aléa</mi><mo>(</mo><mn>1</mn><mo>.</mo><mo>.</mo><mn>10</mn><mo>)</mo></math></input></command></group></library></session>";
Expand Down Expand Up @@ -1083,6 +1105,7 @@ public function run() {
$this->testBugs();
$this->testOpenQuestion();
$this->testFeedback();
$this->testFeedback3();
$this->testOpenQuestionHand();
$this->testAnyAnswer();
if(!(com_wiris_settings_PlatformSettings::$IS_FLASH || com_wiris_settings_PlatformSettings::$IS_JAVASCRIPT)) {
Expand Down
4 changes: 2 additions & 2 deletions quizzes/lib/com/wiris/util/type/Arrays.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static function partition($elements, $lower, $higher, $comparator) {
$i = $lower - 1;
$j = $lower;
while($j < $higher) {
if($comparator->compare($pivot, $elements[$j]) === 1) {
if($comparator->compare($pivot, $elements[$j]) > 0) {
$i++;
if($i !== $j) {
$swapper = $elements[$i];
Expand All @@ -178,7 +178,7 @@ static function partition($elements, $lower, $higher, $comparator) {
}
$j++;
}
if($comparator->compare($elements[$i + 1], $elements[$higher]) === 1) {
if($comparator->compare($elements[$i + 1], $elements[$higher]) > 0) {
$finalSwap = $elements[$i + 1];
$elements[$i + 1] = $elements[$higher];
$elements[$higher] = $finalSwap;
Expand Down
1 change: 1 addition & 0 deletions quizzes/lib/com/wiris/util/xml/WCharacterBase.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public function __construct(){}
static $ROOT_NO_TAIL_VERTICAL = 61759;
static $ROOT_LEFT_TAIL = 61760;
static $ROOT_VERTICAL_LINE = 61761;
static $LINE_FEED = 10;
static $ROUND_BRACKET_LEFT = 40;
static $ROUND_BRACKET_RIGHT = 41;
static $COMMA = 44;
Expand Down
Loading