Hi I tried to create my own custom rating "NPS (0-10)" using "rating" question type. It works on survey creator and viewer, but the when I try to export survey as pdf, this new component is not detected and I get blank pdf file. Below the code to that I used to add new component.
CodeSurvey.ComponentCollection
.Instance
.add({
name: "nps",
title: "nps",
questionJSON: {
type: "rating",
rateValues: [
{text: "1", value: "1"},
{text: "2", value: "2"},
{text: "3", value: "3"},
{text: "4", value: "4"},
{text: "5", value: "5"},
{text: "6", value: "6"},
{text: "7", value: "7"},
{text: "8", value: "8"},
{text: "9", value: "9"},
{text: "10", value: "10"}
]
},
onInit() {
Survey
.Serializer
.addClass("rateValues", [
{name: "value:number"}, {name: "text"}
],
function () {
return new Survey.ItemValue(null, null, "rateValues");
}, "itemvalue");
Survey
.Serializer
.addProperty("nps", {
name: "rateValues:rateValues[]",
category: "rateValues"
});
}
});
To give exact example, my nps question (new component) doesn't list on console when I write this code while generating pdf.
Codevar surveyPDF = new SurveyPDF.SurveyPDF(this.json, options);
surveyPDF.data = surveyModel.data;
surveyPDF.getAllQuestions().forEach((q: any) => {
console.log(q.name);
});