Skip to content

Commit

Permalink
A logic expression should consider the order of a Ranking Question it…
Browse files Browse the repository at this point in the history
…ems fix #7298 (#7303)
  • Loading branch information
andrewtelnov committed Nov 8, 2023
1 parent 2d65d42 commit 8f7bc6f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/expressions/expressions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,8 @@ static unaryFunctions: HashTable<Function> = {
right = OperandMaker.convertValForDateCompare(right, left);
return OperandMaker.isTwoValueEquals(left, right, strictCompare !== true);
},
notequal: function(left: any, right: any): boolean {
return !OperandMaker.binaryFunctions.equal(left, right);
notequal: function(left: any, right: any, strictCompare?: boolean): boolean {
return !OperandMaker.binaryFunctions.equal(left, right, strictCompare);
},
contains: function(left: any, right: any): boolean {
return OperandMaker.binaryFunctions.containsCore(left, right, true);
Expand Down
16 changes: 16 additions & 0 deletions tests/question_ranking_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,22 @@ QUnit.test("Ranking: strict compare, Bug#6644", function(assert) {
q1.value = ["a", "c", "b"];
assert.equal(q2.isVisible, false, "not visible #3");
});
QUnit.test("Ranking: strict compare with not equal, Bug#7298", function(assert) {
var survey = new SurveyModel({
elements: [
{ type: "ranking", name: "q1", choices: ["a", "b", "c"] },
{ type: "text", name: "q2", visibleIf: "{q1} != ['b', 'c', 'a']"
}
]
});
const q1 = survey.getQuestionByName("q1");
const q2 = survey.getQuestionByName("q2");
assert.equal(q2.isVisible, true, "visible initially");
q1.value = ["b", "c", "a"];
assert.equal(q2.isVisible, false, "not visible #2");
q1.value = ["a", "c", "b"];
assert.equal(q2.isVisible, true, "visible #3");
});

QUnit.test("Ranking: disabledItem", function(assert) {
var survey = new SurveyModel({
Expand Down

0 comments on commit 8f7bc6f

Please sign in to comment.