0

I have a problem with my JSON pages.

For each page, I would have the same JSON questions but in my case when I modify the first page, all pages take the same value of the first page.

How can I make an array for this or other solutions or suggestions if it possible, and the onComplete takes the results of the first page without the other pages?

<div >
{ posts.slice(indexFirstPost, indexLastPost).map((threat,index) => {

            return (
<div  className="card bg-light col-lg-3 mr-3" key={threat.ID_THREAT}>
                 <div >
                  <p  } gutterBottom variant="h6" component="h7">
                  <h2 class="threatcolor">
                 <b >  Threat : 

                  </b>  {threat.THREAT_CATA} - {threat.THREAT_DESCP} 

                  <b >  Asset :  </b>  {threat.THREAT_CATEG}</h2>
                   </p>


        <Survey.Survey
          id={"survey"}

           onComplete={this.onComplete}
           showNavigationButtons={this.showNavigationButtons}
            onCurrentPageChanged={this.doOnCurrentPageChanged}
           showCompletedPage={this.showCompletedPage}
             onValueChanged={this.onValueChanged}
           model={new Survey.Model(json)} 

           /> 


         </div> </div>
    )}  )}
</div>

and my JSON is

json = {

    elements:[

      {
        "type": "paneldynamic",
      "name": "relatives1",
      "title": "Please enter all scenario informations",
      "renderMode": "progressTop",
    "templateElements":[
     {
        //"titleLocation": "hidden",
         type:"text",
         placeHolder:"identify...",
         title:"Scenario informations",
          name:"identify",
     },   

    {
    type:"dropdown",
    //"titleLocation": "hidden",
    "startWithNewLine": false,
    otherPlaceHolder:"1", 
    width:"150px",
    name:"probability",
    title:"probability",
    defaultValue:'1',
    choices:[
    {
    value:1,
    score:1,
    text:"Low",

    },
    {
      value:2,
      score:2,
      text:"Significant",

      },
      {
        value:3,
        score:3,
        text:"Very High",

        },

        {
          value:4,
          score:4,
          text:"Almost Certain",

          },

    ]
    },
    {
        type:"dropdown",
        //"titleLocation": "bottom",
        width:"150px",
        "startWithNewLine": false,
        name:"thechnical",
        title:"thechnical difficulty",
        defaultValue:'1',
        choices:[
        {
        value:1,
        score:1,
        text:"Low",

        },
        {
          value:2,
          score:2,
          text:"Moderate",
        },
          {
            value:3,
            score:3,
            text:"High",
            },
            {
              value:4,
              score:4,
              text:"Very High",
               },
         ]
        },
             {
            "titleLocation": "hidden",
             type:"text",
             placeHolder:"access...",
             title:"Access",
              name:"access",

         },   

        {
        type:"dropdown",
        "titleLocation": "hidden",
        width:"150px",
        "startWithNewLine": false,
        name:"probability1",
        defaultValue:'1',
        title:"qst1",
        choices:[
          {
            value:1,
            score:1,
            text:"Low",

            },
            {
              value:2,
              score:2,
              text:"Significant",

              },
              {
                value:3,
                score:3,
                text:"Very High",

                },

                {
                  value:4,
                  score:4,
                  text:"Almost Certain",

                  },

        ]
        },
        {
            type:"dropdown",
            "titleLocation": "hidden",
            width:"150px",
            "startWithNewLine": false,
            name:"thechnical1",
            title:"qst1",
            defaultValue:'1',
            choices:[
              {
                value:1,
                score:1,
                text:"Low",

                },
                {
                  value:2,
                  score:2,
                  text:"Moderate",
                },
                  {
                    value:3,
                    score:3,
                    text:"High",
                    },
                    {
                      value:4,
                      score:4,
                      text:"Very High",
                       },

            ]
            },
            {
                "titleLocation": "hidden",
                placeHolder:"discover...",
                 type:"text",
                 title:"Discover",
                  name:"discover",

             },   

            {
            type:"dropdown",
            "titleLocation": "hidden",
            width:"150px",
            "startWithNewLine": false,
            name:"probability2",
            title:"qst1",
            defaultValue:'1',
            choices:[
              {
                value:1,
                score:1,
                text:"Low",

                },
                {
                  value:2,
                  score:2,
                  text:"Significant",

                  },
                  {
                    value:3,
                    score:3,
                    text:"Very High",

                    },

                    {
                      value:4,
                      score:4,
                      text:"Almost Certain",

                      },

            ]
            },
            {
                type:"dropdown",
                "titleLocation": "hidden",
                width:"150px",
                "startWithNewLine": false,
                name:"thechnical2",
                title:"qst1",
                defaultValue:'1',
                choices:[
                  {
                    value:1,
                    score:1,
                    text:"Low",

                    },
                    {
                      value:2,
                      score:2,
                      text:"Moderate",
                    },
                      {
                        value:3,
                        score:3,
                        text:"High",
                        },
                        {
                          value:4,
                          score:4,
                          text:"Very High",
                           },

                ]
                },
                {
                    "titleLocation": "hidden",
                     type:"text",
                     placeHolder:"exploit...",
                     title:"Exploit",
                      name:"exploit",

                 },   

                {
                type:"dropdown",
                "titleLocation": "hidden",
                width:"150px",
                "startWithNewLine": false,
                name:"probability3",
                title:"qst1",
                defaultValue:'1',
                choices:[
                  {
                    value:1,
                    score:1,
                    text:"Low",

                    },
                    {
                      value:2,
                      score:2,
                      text:"Significant",

                      },
                      {
                        value:3,
                        score:3,
                        text:"Very High",

                        },

                        {
                          value:4,
                          score:4,
                          text:"Almost Certain",

                          },                ]
                },
                {
                    type:"dropdown",
                    "titleLocation": "hidden",
                    width:"150px",
                    "startWithNewLine": false,
                    name:"thechnical3",
                    title:"qst1",
                    defaultValue:'1',
                    choices:[
                      {
                        value:1,
                        score:1,
                        text:"Low",

                        },
                        {
                          value:2,
                          score:2,
                          text:"Moderate",
                        },
                          {
                            value:3,
                            score:3,
                            text:"High",
                            },
                            {
                              value:4,
                              score:4,
                              text:"Very High",
                               },
                    ]
                    }




                  ],
                  "panelCount": 0,
                  "panelAddText": "Add Scenario",
                  "panelRemoveText": "Remove"

                  },
    ], "showQuestionNumbers": "off",

    };
Mukyuu
  • 6,436
  • 8
  • 40
  • 59
RàMi
  • 3
  • 3

1 Answers1

0

If I correctly understand the issue with data. It looks like the questions on different pages have the same names. In this case they will share input data. If you set different names for questions on different pages, it should solve the issue with data.

As for "takes the results of the first page without the other pages" you need to get all questions from the first page, iterate through them and get corresponding values from the survey.data by the question name used as a key.

TSV
  • 7,538
  • 1
  • 29
  • 37