Page 1 of 1

Database steady variable

Posted: Fri Apr 11, 2014 5:42 pm
by Emily Theophilou

Hi! I want to create an app were a student will have to answer different questions which they will be saved in the database. However I want the teacher to know which student answered the questions.
I would like to ask if its possible to have a text input at the beginning of the app that will stay in the database and will show it each time the user answers a question. It will be something like a login page but i dont want to create a login page.

Are there any relevant tutorials?


Database steady variable

Posted: Fri Apr 11, 2014 6:42 pm
by Kateryna Grynko

Dear Emily,

You would need just a service that saves data in Database:
http://docs.appery.io/documentation/b...

This tutorial may be helpful:
http://docs.appery.io/tutorials/build...


Database steady variable

Posted: Sat Apr 12, 2014 11:34 pm
by Emily Theophilou

Hi Katya,
I decided to use the login/signup tutorial and create a sign up page.
I managed to connect my data and show which user inputs something in the database. However I cant figure out how to get the actual username to be shown. I can only see the user id numbers which are really long.
These are my mappings

Image

I created a username local storage variable as well but when i connected it nothing was showing.


Database steady variable

Posted: Sun Apr 13, 2014 6:07 am
by Igor

How do you save username to localstorage variable? Could you show us response mapping tab screenshot?


Database steady variable

Posted: Sun Apr 13, 2014 6:57 pm
by Emily Theophilou

Hi Igor, thanks for the reply.
Here is the response tab. I didnt reallly do anything on it :P Image


Database steady variable

Posted: Mon Apr 14, 2014 2:16 am
by Illya Stepanov

Hi Emily,

There is at least two ways to obtain a user name.
ol type="I"
liGet it by request to the user info(after loged on). Not recomended now cause of second way is easier. See details about this way here: http://docs.appery.io/documentation/b.../li

liStore userName on in the localStorageVariable on success login service event. To do it please follow steps below:/li
/ol
ol
liOpen your login service in data tab. http://prntscr.com/39sqap/direct/li

liCreate JS "success" event handler for your login service(datasource). And fill it with following code: http://prntscr.com/39sr4g/direct
precode
var userName = Appery("input_login").val();

localStorage.setItem("userName", userName);/code/pre/li
liNow you can use following code to get all current userName.
precode
localStorage.getItem("userName");/code/pre/li
/ol
Also you can map you LSV "userName" to the request field directly.

For this way please open mappings for your service.
Create localStorage variable. http://prntscr.com/39ss4y/direct

Mapp appearing LSV into your request parameter. http://prntscr.com/39ssic/direct

That's all.

Regards.


Database steady variable

Posted: Mon Apr 14, 2014 5:21 am
by Emily Theophilou

Thank you Illya!!!
It works! :D
It was a nice tutorial aswell :)