使用Survey JS的想法是要求用户从预定义的选项列表(单选按钮)中回答一些问题。
每个选项都将分配一个分数(0、25、75、100),因为每个选择都是我想在屏幕上的某处显示实时比分。
我知道我需要像这个例子一样创建一个表达式,但我不知道从哪里开始。
我已经创建了表单的基本结构,可以在这里看到。
$.material.init();
var json = {
title: "Audit Example",
showProgressBar: "top",
pages: [{
questions: [{
type: "matrix",
name: "Quality",
title: "Please score each department below.",
columns: [{
value: 0,
text: "None"
}, {
value: 25,
text: "Isolated"
}, {
value: 50,
text: "Some"
}, {
value: 100,
text: "Widespread"
}],
rows: [{
value: "training",
text: "Training"
}, {
value: "support",
text: "Support"
}, {
value: "safety",
text: "Safety"
}, {
value: "communication",
text: "Communication"
}]
}]
}
]
};
Survey.defaultBootstrapMaterialCss.navigationButton = "btn btn-green";
Survey.defaultBootstrapMaterialCss.rating.item = "btn btn-default my-rating";
Survey.Survey.cssType = "bootstrapmaterial";
var survey = new Survey.Model(json);
survey.onComplete.add(function(result) {
document.querySelector('#result').innerHTML = "result: " + JSON.stringify(result.data);
});
survey.render("surveyElement");
任何建议表示赞赏。