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

Extending rating scale question #4661

Closed
kmhigashioka opened this issue Sep 28, 2023 · 1 comment
Closed

Extending rating scale question #4661

kmhigashioka opened this issue Sep 28, 2023 · 1 comment
Labels

Comments

@kmhigashioka
Copy link

Are you requesting a feature, reporting a bug or ask a question?

Asking a question

What is the current behavior?

Hi! I would like to check if this is doable, I'm trying to create a new question type which is enps. In our use-case, the enps behaves the same as Rating scale question but there can only be one instance of enps question and the user should be able to select that question from "Add question" selection dropdown. I tried to create a custom widget and inherit the rating scale model and use the React UI. However, the display is different.
image

What is the expected behavior?

Expecting to see the same UI as rating scale question.

How would you reproduce the current behavior (if this is a bug)?

Provide the test code and the tested page URL (if applicable)

Tested page URL: https://codesandbox.io/s/flamboyant-sun-jj8ctr?file=/src/SurveyCreatorComponent.jsx

Test code

export class EnpsQuestionModel extends QuestionRatingModel {
  getType() {
    return CUSTOM_TYPE;
  }
}

Serializer.addClass(
  CUSTOM_TYPE,
  [],
  function () {
    return new EnpsQuestionModel("");
  },
  "question"
);

ElementFactory.Instance.registerElement(CUSTOM_TYPE, (name) => {
  return new EnpsQuestionModel(name);
});

ReactQuestionFactory.Instance.registerQuestion(CUSTOM_TYPE, (props) => {
  return React.createElement(SurveyQuestionRating, props);
});

Specify your

  • browser: Firefox 111.0.1
  • editor version: 1.9.110
@JaneSjs
Copy link
Contributor

JaneSjs commented Nov 21, 2023

Hello @kmhigashioka,
If you wish to create a copy of a Rating question but with some customized settings like name and title, you can use the creator.toolbox.addItem function. Consider this code:

creator.toolbox.addItem({
    name: "nps",
    title: "NPS",
    iconName: "icon-rating",
    isCopied: true,
    id: "npsQuestion",
    category: "General",
    json: {
      type: "rating",
      title: "How satisfied are you with your in-store experience today?",
      rateType: "stars"
    }
});

Please let me know if this option works for you.

P.S. Let me note that a SurveyJS Creator is available under a commercial developer license.

@JaneSjs JaneSjs removed their assignment Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants