Open zhitomir-oreshenski-mm opened 3 years ago
The rating file question value is a single number. You can't pass an array of default values, it willn't work.
Hi @tsv2013,
Is there any other way (or use different component) to be able to show the user more than one initial value?
Thank you in advance!
BR, Zhi
@zhitomir-oreshenski-mm We do not understand what you are trying to do. Survey sets "defaultValue" into question.value after creating/loading from JSON. It should be the same type as a value, a number in case of rating question.
Thank you, Andrew
Hi @andrewtelnov,
What I am trying to achieve:
`import React, { Component } from "react";
import * as Survey from "survey-react";
import "survey-react/modern.css"; import "./index.css";
Survey.StylesManager.applyTheme("modern");
class SurveyComponent extends Component { render() { const mock = { showCompletedPage: false, mode: "display", pages: [ { title: "DemoTest2", name: "page1", elements: [ { maxRateDescription: "minimum rate", minRateDescription: "maximum rate", name: "3121", order: 1, questionId: 2116, defaultValue: [2, 3], rateMax: 7, rateMin: 1, title: "TestRangeOne", type: "rating" } ] } ] };
const survey = new Survey.Model(mock);
return <Survey.Survey model={survey} />;
} }
export default SurveyComponent; `
Means, to allow somehow to sets an array of values as 'defaultValue' Eg. defaultValue: [2, 3].
BR, Zhi
@zhitomir-oreshenski-mm Why do you need it? You can not do it in SurveyJS Creator. It doesn't allow you. Of course you can assign to "defaultValue" any value in code or JSON, but then Survey will set this defaultValue into question.value and it excpects a single number. What is the point of doing it?
Thank you, Andrew
Hi @andrewtelnov,
The business case that we have is, to allow the user (teacher, volunteer) to preview the survey and answers before providing it to the students. It is just for information purposes, we have more than one correct/positive answer, but the student can choose only one.
Br, Zhi
@zhitomir-oreshenski-mm in this case you can create another property and use it. Your scenario has nothing to do with the "defaultValue" property.
Thank you, Andrew
Hi @andrewtelnov,
Thank you for your prompt response.
Yes correct, I want to be able to show correct answers in preview mode. Unfortunately, such functionality seems that do not exist and I tried to use some of existing properties.
Thank you, Zhitomir
Hi @andrewtelnov,
Is it possible to share some workaround about this?
Thank you in advance!
BR, Zhitomir
Are you requesting a feature, reporting a bug or asking a question?
Question
What is the current behavior?
Rate type question allow only one 'defaultValue' and selected value (correct answer)
What is the expected behavior?
I would like to have the ability to have multiple defaultValue or some way to show the user in display mode more than one
How would you reproduce the current behavior (if this is a bug)?
I think it is by design
Provide the test code and the tested page URL (if applicable)
Tested page URL:
https://codesandbox.io/s/little-meadow-pyzlr?file=/src/SurveyComponent.jsx
Test code
Specify your