Code Monkey home page Code Monkey logo

Comments (3)

etosch avatar etosch commented on July 20, 2024

The python ids get converted by the java, since the json produced by the python serves as input to the java program. The java program then converts the json ids into ids that are analogous to the csv ids. These are used for debugging and should be replaced, since they're overloaded with semantic importance.

I think what would be best for the json the web interface produces would be for it to just maintain a unique id. In addition to the provenance info needed for debugging, using cell data for ids allows us to know the ordering on answer options. I will update the json schema so that the options field takes a list of ids representing the total order on the options for a given question. If omitted or falsey, the question is unordered. I don't know if this change will affect the correctness of surveyman.js -- some time ago, the logic relied on the ids having meaning, but may have been replaced (in my cursory review, I don't see any of that old code, but I may have just missed it). In any case, if it's still present, it should go.

Long story short: just generate unique ids in the normal way.

from react-surveyman.

prakhar1989 avatar prakhar1989 commented on July 20, 2024

Thanks for the update!

Here's a sample json generated from react-surveyman. Any specific preferences on the IDs or is this okay?

{
  "survey": [
    {
      "id": 0,
      "randomizable": true,
      "ordering": false,
      "questions": [
        {
          "id": 753,
          "qtext": "Which is your favorite color?",
          "options": [
            {
              "id": 655,
              "otext": "red"
            },
            {
              "id": 805,
              "otext": "green"
            },
            {
              "id": 617,
              "otext": "blue"
            },
            {
              "id": 684,
              "otext": "white"
            },
            {
              "id": 842,
              "otext": "black"
            }
          ],
          "ordering": false,
          "freetext": false,
          "exclusive": true
        },
        {
          "id": 30,
          "qtext": "Which color tshirt do you like to wear the most?",
          "options": [
            {
              "id": 285,
              "otext": "red"
            },
            {
              "id": 17,
              "otext": "green"
            },
            {
              "id": 807,
              "otext": "blue"
            }
          ],
          "ordering": false,
          "freetext": false,
          "exclusive": true
        }
      ],
      "subblocks": []
    },
    {
      "id": 328,
      "questions": [
        {
          "id": 526,
          "qtext": "what is the value of 4 + 5?",
          "options": [
            {
              "id": 32,
              "otext": "9"
            },
            {
              "id": 783,
              "otext": "10"
            },
            {
              "id": 934,
              "otext": "Dont know"
            },
            {
              "id": 937,
              "otext": "Dont care"
            }
          ],
          "ordering": false,
          "freetext": true,
          "exclusive": true
        }
      ],
      "subblocks": [],
      "randomizable": true,
      "ordering": false
    }
  ]
}

This is just Math.floor((Math.random() * 1000) + 1) for now, but I can do something like prefix + uuid.uuid4().hex().toString().

from react-surveyman.

etosch avatar etosch commented on July 20, 2024

These look totally fine; in fact they don't even need to be universally unique, since the lookup is according to type. The previous conventions were about human readability. The only thing is, they will need to be strings if you're validating against the survey_input schema.

EDIT: I see in the commit that the type is now a string. 🎯

from react-surveyman.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.