*
The moose likes JSP and the fly likes How to restrict user marking same events in multiple times.    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to restrict user marking same events in multiple times.    " Watch "How to restrict user marking same events in multiple times.    " New topic
Author

How to restrict user marking same events in multiple times.

Harshal Gurav
Ranch Hand

Joined: May 29, 2008
Posts: 151
Hi,
In my online exam system, I am displaying the questions and related answer in jsp page. Once user fill all this questions, the result of these stored in final table containing column questonNo, userid, answer, testname.
Now in my application if any user goes back to the question displaying page after submitting same questions, he can change the answer selected in first attempt and submitting again the test, the result are stored in final table. I.e. for same question no. user is now able to answer in two times. I want to restrict user for answering test in second times.
How can I achieve this?
Any suggestion is highly appreciated?
Thanks and Regards
Harshal
Sripathi Krishnamurthy
Ranch Hand

Joined: Mar 07, 2005
Posts: 232
You can make the question number and the userid as a composite primary key in the database table. Before inserting the data into the table, check whether a row already exists in the table. If it already exists, do not allow another insert, rather allow an update.
Harshal Gurav
Ranch Hand

Joined: May 29, 2008
Posts: 151
Hi Sripathi,
Thanks for your reply.
Can i use javascript function disabled with my form so that restructuring of thr database will be avoided.
Thanks and regards
Harshal
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

Using Javascript, you can take care of the back button, but the user will still be able to re-answer using the reload button and refreshing the page.

So I think the server must take care of this.


Hope this helps


SCJP, SCWCD.
|Asking Good Questions|
Harshal Gurav
Ranch Hand

Joined: May 29, 2008
Posts: 151
Hi amit,
Thank you for your valuable help.Thus Sripathi idea is the best ways to to solve this problem. As i had done lot of work with my current database structure ,changing database structure will couse some trouble in application.
Whether you have any other idea?
Thanks and Regards
Harshal
[ August 20, 2008: Message edited by: Harshal Gurav ]
Harshal Gurav
Ranch Hand

Joined: May 29, 2008
Posts: 151
Hi,
Can anyone have solution for above issue?

Any help is highly appreciated.
Thanks and Regards
Harshal
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

How about maintaining flags for marked questions and storing them in the session complemented with Javascript on the client side.
Thats the only think on my mind now.

Hope this helps
Danny Carson
Greenhorn

Joined: Aug 05, 2008
Posts: 18
have a look at javascript, window.history.forward(1);

add this in the head of your next page and the user cannot go back to that page.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

Originally posted by Danny Carson:
add this in the head of your next page and the user cannot go back to that page.

Very non-user-friendly, and not a tactic that serious web developers should employ. Rather, use good patterns on the server to make sure that the web application behaves well rather than hobbling the user's browser.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

P.S. You may find this this recent related post helpful.
Danny Carson
Greenhorn

Joined: Aug 05, 2008
Posts: 18
Originally posted by Bear Bibeault:

Very non-user-friendly, and not a tactic that serious web developers should employ. Rather, use good patterns on the server to make sure that the web application behaves well rather than hobbling the user's browser.


I dont see it as much of a problem if the developer has a good navigation tool on each page. If the user wants to go back to that page then they click the menu item. Thats my opinion anyway.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18712
    
    8

Originally posted by Danny Carson:
I dont see it as much of a problem if the developer has a good navigation tool on each page. If the user wants to go back to that page then they click the menu item. Thats my opinion anyway.
It's not my opinion. I've used applications that don't let you go back. Quite often I'm done with looking at that application and I want to go back to where I was earlier. Usually the Google search page where I found the link to the application. It's extremely annoying if I can't do that.
Danny Carson
Greenhorn

Joined: Aug 05, 2008
Posts: 18
Originally posted by Paul Clapham:
It's not my opinion. I've used applications that don't let you go back. Quite often I'm done with looking at that application and I want to go back to where I was earlier. Usually the Google search page where I found the link to the application. It's extremely annoying if I can't do that.


Yes on second thoughts I agree. I was looking at it from an internal web app point of view.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18712
    
    8

Originally posted by Danny Carson:
Yes on second thoughts I agree. I was looking at it from an internal web app point of view.
Exactly! I think you'll find that everybody else who wants to do these "stupid browser tricks" is looking at it from that point of view too.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

That's a really good point, Danny.

I think there are a lot of web developers who tend to think that the browser is theirs to do with as they please. This is evidenced by the number of questions like "How do I change the browser settings from my site?", "How do I close the browser when the user logs off?", "How do I disable the refresh and back button?" and so on.

All of these indicate a myopia regarding what a well-behaved web application should do. This has been captured in this FAQ entry.
Danny Carson
Greenhorn

Joined: Aug 05, 2008
Posts: 18
Keep up the good work guys!
You're doing your part to educate the inexperienced developers.

Cracking Forum by the way.

DC
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to restrict user marking same events in multiple times.