Page 2 of 3
Inputting questions/answers into database, not using boolean
Posted: Sat May 17, 2014 6:36 am
by Travis6876874
I took a quick look, but have alot of looking to do. The last thing I needed is very important, when I set up the the columns for the answers , will I later be able to shuffle Ans1 Ans2 and correctAns for users to take the quiz so that that third answer isnt always the correct answer.. Thanks)))
Inputting questions/answers into database, not using boolean
Posted: Sat May 17, 2014 6:38 am
by Travis6876874
Inputting questions/answers into database, not using boolean
Posted: Sat May 17, 2014 7:10 am
by Travis6876874
Inputting questions/answers into database, not using boolean
Posted: Sat May 17, 2014 7:11 am
by Travis6876874
Inputting questions/answers into database, not using boolean
Posted: Sat May 17, 2014 7:16 am
by Alena Prykhodko
After you retrieve answer values from DB you will need to store them in localStorage and then shuffle with JavaScript.
I'll update asap what is the better solution in this case. Probably you will need to store answers in one cell separated by comma. Please let me check this.
Inputting questions/answers into database, not using boolean
Posted: Sat May 17, 2014 7:40 am
by Travis6876874
She knows Ill need more answers and goes out of her way to help me. Thats always been the case with appery.io, your service is rich and unique.
Inputting questions/answers into database, not using boolean
Posted: Sat May 17, 2014 7:43 am
by Travis6876874
Ive never had customer assistant as good as this in my life!
Inputting questions/answers into database, not using boolean
Posted: Sat May 17, 2014 7:44 am
by Travis6876874
Talk to you next week.....!
Inputting questions/answers into database, not using boolean
Posted: Sat May 17, 2014 7:47 am
by Travis6876874
Inputting questions/answers into database, not using boolean
Posted: Sat May 17, 2014 8:42 am
by Alena Prykhodko
So, here is more to learn 
To store
It's better to store data in database as follows:
one column - question (String)
second column - answers (Array) http://docs.appery.io/documentation/b...
The structure of answer cell:
pre
[{"answer": "Answer one", "correct": true}, {"answer": "Answer two", "correct": false}, {"answer": "Answer Tree", "correct": false}]
/pre
In case you would like to add additional answers or more than one correct answer, hints, just transfer the cell to:
pre
[{"answer": "Answer one", "correct": true}, {"answer": "Answer two", "correct": false}, {"answer": "Answer Tree", "correct": false}, {"answer": "Answer four", "correct": true}]
/pre
How to retrieve and shuffle
To retrieve the column with answers import Database Service http://docs.appery.io/documentation/b... for this Database (for example Read Service).
To modify your service response you need to use Generic security context and use it with your service.
3.1 Create custom Security context service. Here is how to do this http://docs.appery.io/documentation/g...
3.2 Use next code to wrap answer and make custome logic (Shuffling with JavaScript).
pre
Appery.MySecurityGeneric = Appery.createClass(SecurityContext, {
invoke: function(service, settings) {
var oldSuccess = settings.success;
Code: Select all
var onSuccess = function(value, other){
//here you need to use JavaScript shuffle function:
//To see what stored in the value variable please use following code:
Code: Select all
console.log("value = ");
console.log(value);
oldSuccess.call(this, value, other);
};
settings.success = onSuccess;
Appery.MySecurityGeneric.$super.invoke.call(this, service, settings);
}
});
/pre
Note: You should replace "MySecurityGeneric" with your Security generic context name.
After you create Generic security context please use this context in your service.