Dynamic Review Rule System PHP & MySQL
Posted: Fri May 13, 2016 8:51 am
So I've been tasked with a type of review system that has 4 types of reviews. The reviews will have 15-20 questions each in them and the questions will range from basic "Yes/No" through to a Date and Location answer. The system works on rules though where it takes into account the Yes/No answers and funnels them into a rule system.
The questions are stored in the database and pulled from it, I feel like I could do the same for the rules. In all of the prototypes I've been hard coding these rules but I wanted to move to a more user friendly dynamic method.
For example you do a review on What Movies You've Seen?:
Q1) Godfather Y/N
Q2) Journey To The Center Of The Earth Y/N
Q3) Snow White Y/N
Q4) What's your favourite film? Text Entry
Now lets say the Rules are:
Rule 1 = If Q1 & Q2 are answered both Yes and the Q3 is No - GOTO Page 2.
Rule 2 = If Q1 & Q3 Are Answered Yes And Q2 are No - GOTO Page 3.
There would never be any need to take note of textboxes or anything like that, just Yes/No Radio buttons which to me just means it's a case of having a lot of 1's & 0's saved.
My question is really how would this be displayed in a front end actionable system and how would it be saved in a MySQL Database nicely so that it's retrievable later. I know it's really broad question.
I was going to have a table where you had a set of "Pages" that were given a start question value and an end question value eg:
http://imgur.com/sBtC8TV
But that denormalizes the rule data and means I'll have to split it whenever I want to edit. I don't mind that too much as it's not really data to start with and it seems simple enough but I just wanted some input on this as I don't want to jump in for it to suddenly dawn on me that there's a better way!
Cheers in advance
The questions are stored in the database and pulled from it, I feel like I could do the same for the rules. In all of the prototypes I've been hard coding these rules but I wanted to move to a more user friendly dynamic method.
For example you do a review on What Movies You've Seen?:
Q1) Godfather Y/N
Q2) Journey To The Center Of The Earth Y/N
Q3) Snow White Y/N
Q4) What's your favourite film? Text Entry
Now lets say the Rules are:
Rule 1 = If Q1 & Q2 are answered both Yes and the Q3 is No - GOTO Page 2.
Rule 2 = If Q1 & Q3 Are Answered Yes And Q2 are No - GOTO Page 3.
There would never be any need to take note of textboxes or anything like that, just Yes/No Radio buttons which to me just means it's a case of having a lot of 1's & 0's saved.
My question is really how would this be displayed in a front end actionable system and how would it be saved in a MySQL Database nicely so that it's retrievable later. I know it's really broad question.
I was going to have a table where you had a set of "Pages" that were given a start question value and an end question value eg:
http://imgur.com/sBtC8TV
But that denormalizes the rule data and means I'll have to split it whenever I want to edit. I don't mind that too much as it's not really data to start with and it seems simple enough but I just wanted some input on this as I don't want to jump in for it to suddenly dawn on me that there's a better way!
Cheers in advance