File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Best way to model an 'exam' web-app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Best way to model an Watch "Best way to model an New topic
Author

Best way to model an 'exam' web-app

Pavan Kumar Dittakavi
Ranch Hand

Joined: Feb 12, 2011
Posts: 104

Hi All,

I'm designing a short web application that poses around 20 questions to the user and evaluates them. I have a query on this. To start off, i have a login screen where the user is required to enter the user name and employee id. Once that is done, I will pose the questions to the user and once he answers them and hits the submit button, the results would be evaluated.

login->questions->evaluate. I wanted to know what is the best way of doing this. Somehow I need to track of who has logged in and is taking the test. So, should I be opting for the cookies approach or is there a better approach for doing this?

Please suggest.

Thanks,
Pavan.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
Speaking from the advantage of having done a bunch of online exams....

Since some people will have cookies turned off on their browser, I use a hidden variable in each HTML form containing a unique user id.

I also use a custom class to hold all of the user's information, current position in the question list, answers so far, etc and eventually the grade. This class is Serializable so I have to option to write a user's state to disk after each question is answered. This allows a user to stop in the middle of the test and resume later or go back later to look at the graded results.

Think carefully about how you are going to create and store the question set. Personally I use XML.

Bill


Thihara Neranjya
Greenhorn

Joined: Oct 12, 2011
Posts: 8
I see someone is stuck with creating an internal app for surveys :-D There are a myriad of approaches to take and using stock Servlets and JSP seem to be a bit backdate because theer are so much frameworks out there that will make your life much easier. That said you may not want to learn them and/or use them in your application if you won't be extending it much. But you never know!!

There are several stacks you can use to make a web application like that. Most of the web apps go the MVC(http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller) way so I'll post the stacks that I'm aware here.

Model - POJOs(http://en.wikipedia.org/wiki/POJO) with an ORM framework like JPA,Hibernate MyBatis/iBatis, you can also use plain JDBC although out of the box it's a bit cumbersome.

View - JSPs is the most basic element but its best served with a framework like JSF, Struts, Spring MVC

Controller - You can do this with a servlets and some java classes with business logic however use of an MVC famrwork mentioned in the View part is highly recommended

And if you are using plain JDBC using Spring built in templates will make your life easier.

Again the choice depends on your plans and/or expectations for the application. If you are not familiar with the frameworks mentioned and you don't expect the application to evolve to do anything other than whats mentioned here(if it's a class project ) then you are best off with Servlets and JSP with JDBC or an ORM. However learning the frameworks wil only help you in the long run!
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
What if it is not a class project? Servlet,jsp and Hibernate will do?


kunal
Thihara Neranjya
Greenhorn

Joined: Oct 12, 2011
Posts: 8
It would yes. But if you used on of the frameworks extension will be faster. But if you design it properly and use good coding practices servlets and JSPs would serve you well.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61768
    
  67

Thihara Neranjya wrote:It would yes. But if you used on of the frameworks extension will be faster.

I disagree. If the framework is not something someone is already familiar with it will take much much longer. And even then, the frameworks frequently get in the way more than they help -- especially for smaller projects


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
Thanks Thihara Neranjya. i am working on such app and i don't have much time to use framework like Spring. Later on, will convert the codes to Spring, that's for sure
Thihara Neranjya
Greenhorn

Joined: Oct 12, 2011
Posts: 8
Bear Bibeault wrote:
Thihara Neranjya wrote:It would yes. But if you used on of the frameworks extension will be faster.

I disagree. If the framework is not something someone is already familiar with it will take much much longer. And even then, the frameworks frequently get in the way more than they help -- especially for smaller projects


I agree with you... That's why I said if he's not planing on extending it as a large scale application he should use JSPs and Servlets. Actually Kunal if you are not planing on extending the application and/or want to learn some of the frameworks it would be a waste of effort.
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
Thanks Thihara Neranjya, Bear Bibeault.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Best way to model an 'exam' web-app