Forum Discussion

hilary_davis's avatar
hilary_davis
Occasional Contributor
13 years ago

How do I select a specific multiple choose answer?

I am trying to create a script which would select the correct answer depending on which question is displayed.



There are 15 questions total and all questions have a designated answer.



The tricky part is:


  • Only 3 of the 15 questions will be displayed during a test cycle


  • The questions are in no particular order


  • The answers are randomly shuffled (The answer to Question 1 will not always be the first bullet)


[This testing is for online account opening - the questions are specific to our (test) customer's personal information.]
  • Hi Hilary,



    The fastest way I see to solve that is to map the answers in your script (in an array, an XML or whatever is ok for you) by its text, if there is no possibility to add IDs to the objects (I assume your application is web application)



    If the page is multilanguage, you will have a problem there. Then you can or map all the languages in your script, or talk to de application developers to add IDs to the radiobuttons (those have not to change between application executions, or if they change, you should be able to generate the IDs by your own way)



    If the radio buttons have already IDs, you just need to map those IDs and it should work on different langauges.



    There is an example in JScript:





    var questions = {

      "Question 1": {  // With text

        "Question": {

          "English": "Question in english",

          "French": "Question in french"  // And so on

        }

        "Answers": {

          "Correct": {

            "English": "Answer in english",

            "French": "Answer in french"  // And so on

          }

        }

      },

      "Question 2": {  // With IDs

        "Question": "question2_id",

        "Answers": {

          "Correct": "answer_X",  // Don't differenciate correct answers from wrong ones in a meaningful way!

          "Incorrect": {

            "1": "answer_Y",

            "2": "answer_Z"  // And so on

          }

        }

      }

    }





    You can also map incorrect questions if you want to.



    Hope it helped!