data structure

Discussion in 'PHP' started by kuttappan, May 22, 2010.

  1. #1
    Ok, so I am trying to build something like an interactive application that works like a Q/A. The user is presented with information, and presented with a choice. When they choose, that choice is sent (ajax) to a php script that takes that choice and spits out more questions/options.

    I want to build a generalizable solution, so that I can take that code and aim it at some sort of data source (DB, flat file, not sure) and use that data to create the interactive logic.

    Thoughts on how to design the data source so that it holds logic (like, if user selects B, send them to the earlier slide/state).

    I have never implemented something this complex before.
     
    kuttappan, May 22, 2010 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,901
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #2
    I have seen this implemented as

    If you wanted to take the surveymonkey approach where you have questions (and the answer options serialised into the table) you would have another table called logic. The fields would be
    * id
    * question_id
    * next_question_id

    So when someone answers a question it would look to see if there is any logic associated with that question and feed the next_q_id into a function to get the question. If no logic exists then just get question_id + 1
     
    sarahk, May 22, 2010 IP