I have a website which is a maths tutorial. In short, there are addition,subtraction,multiply and division. One servlet generates a problem and sends it to the client.Now, when the user enters the answer another ajax request is sent to a different servlet. This servlet, maintains the score for CORRECT answers and WRONG answers in sessions. I though it wud be better to create an array for CORRECT and WRONG since, there will be too many variables each for correct/wrong addition,subtraction etc.
I have 2 arrays:
I am storing these arrays in sessions. heres the rest of the code..
Similarly for subtraction,mul,div. The problem is, the values dont get added!. I WANT them to be replaced with the new ADDED values. Like a counter.. Can anyone help me out??
Please read this for more information.
Originally posted by William Brogden:
I see code like:
but it looks like correctScoreArray is an instance variable and is thus used for all requests. It is always there and does not need to be put in the user's session.
I see local variable creation like:
but I dont understand what you are trying to do with it.
getCorrectScoreSessVar is the variable used to collect the value of the session. I am incrementing that and storing the new value in the session. I've removed the correctScoreArray usage in the code. Just trying to implement multiple counters based on the option(if else). Can you tell me a better way to do it?
[ December 21, 2008: Message edited by: Udayaditya Barua ]
I wrote a class which represents EVERYTHING about a single user's test taking process.
Each user gets an instance so only one reference needs to be saved and recovered from the session.
This class is Serializable so the servlet container can manage it correctly and I can save tests in progress to be resumed later.