Travis6876874
Posts: 0
Joined: Sat May 17, 2014 1:27 am

Inputting questions/answers into database, not using boolean

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)))

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Inputting questions/answers into database, not using boolean

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.

Travis6876874
Posts: 0
Joined: Sat May 17, 2014 1:27 am

Inputting questions/answers into database, not using boolean

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.

Travis6876874
Posts: 0
Joined: Sat May 17, 2014 1:27 am

Inputting questions/answers into database, not using boolean

Ive never had customer assistant as good as this in my life!

Travis6876874
Posts: 0
Joined: Sat May 17, 2014 1:27 am

Inputting questions/answers into database, not using boolean

Talk to you next week.....!

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Inputting questions/answers into database, not using boolean

So, here is more to learn :)

To store

  1. 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

  2. To retrieve the column with answers import Database Service http://docs.appery.io/documentation/b... for this Database (for example Read Service).

  3. 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.

  1. After you create Generic security context please use this context in your service.

    Image

Return to “Issues”