Surveyjs choicesOrder random кроме некоторого значения - PullRequest
0 голосов
/ 04 ноября 2018

У меня проблема с порядком выбора в surveyjs, я хочу сделать случайный порядок выбора, кроме 1 значения (пример: верблюд), всегда внизу.

var json = {
"elements": [{
"type": "imagepicker",
"name": "Picture",
"title": "What animal would you like to see first ?",
"choices": [
 {
  "value": "lion",
  "imageLink": "https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg"
}, {
  "value": "giraffe",
  "imageLink": "https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg"
}, {
  "value": "panda",
  "imageLink": "https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg"
}, {
  "value": "camel",
  "imageLink": "https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg"
 }]
}]};

window.survey = new Survey.Model(json);
var q = survey.getQuestionByName('Picture');
q.choicesOrder = "random";
q.showLabel = "true";

1 Ответ

0 голосов
/ 06 ноября 2018

Я создал пример с вашим кодом и последним SurveyJS. Это выглядит нормально для меня.

Не могли бы вы попробовать обновить версию SurveyJS до последней версии. Спасибо.

Survey
    .StylesManager
    .applyTheme("default");

var json = {
  "elements": [{
  "type": "imagepicker",
  "name": "Picture",
  "title": "What animal would you like to see first ?",
  "choices": [
   {
    "value": "lion",
    "imageLink": "https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg"
  }, {
    "value": "giraffe",
    "imageLink": "https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg"
  }, {
    "value": "panda",
    "imageLink": "https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg"
  }, {
    "value": "camel",
    "imageLink": "https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg"
   }]
}]};

window.survey = new Survey.Model(json);
var q = survey.getQuestionByName('Picture');
q.choicesOrder = "random";
q.showLabel = "true";

$("#surveyElement").Survey({model: survey});
<!DOCTYPE html>
<html>
    <head>
        <title>One choice - Radio Group question, jQuery Survey Library Example</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="https://unpkg.com/jquery"></script>
        <script src="https://surveyjs.azureedge.net/1.0.53/survey.jquery.js"></script>
        <link href="https://surveyjs.azureedge.net/1.0.53/survey.css" type="text/css" rel="stylesheet"/>
        <link rel="stylesheet" href="./index.css">

    </head>
    <body>
        <div id="surveyElement"></div>
        <div id="surveyResult"></div>

        <script type="text/javascript" src="./index.js"></script>

    </body>
</html>
...