Skip to content

Commit

Permalink
work for the #8836 (#8877)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-kurmanov authored Oct 1, 2024
1 parent 994f0fb commit 834f00c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/survey-core/src/question_ranking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ export class QuestionRankingModel extends QuestionCheckboxModel {
this.updateRankingChoices();
};

updateValueFromSurvey(newValue: any, clearData: boolean): void {
super.updateValueFromSurvey(newValue, clearData);
if (newValue) this.isValueSetByUser = true;
}

public localeChanged = (): void => {
super.localeChanged();
this.updateRankingChoicesSync();
Expand Down
28 changes: 28 additions & 0 deletions packages/survey-core/tests/question_ranking_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,34 @@ QUnit.test("Ranking: Carry Forward: Default Value", function(assert) {
});
});

QUnit.test("Ranking: Carry Forward: Data", function(assert) {
var survey = new SurveyModel({
elements: [
{
"type": "checkbox",
"name": "q1",
"choices": [1, 2, 3, 4, 5]
},
{
"type": "ranking",
"name": "q2",
"choicesFromQuestion": "q1",
"choicesFromQuestionMode": "selected"
}
]
});

survey.data = {
"q1": [1, 2, 3],
"q2": [3, 2, 1]
};

assert.deepEqual(survey.data, {
q1: [1, 2, 3],
q2: [3, 2, 1],
});
});

QUnit.test("Ranking: CorrectAnswer, Bug#3720", function(assert) {
var survey = new SurveyModel({
elements: [
Expand Down

0 comments on commit 834f00c

Please sign in to comment.