Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Online Examination App  RSS feed

 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to build a basic online exam app.

But not able to find out how to do that.

So user will log in , click on start exam
That will be handled by servlet , servlet should call Model class that will fetch questions from database and make a list of those questions and return it to servlet.
Than servlet will set that list as an attribute.

and redirect to jsp , which will have three buttons previous ,next ,finish.

on clicking on finish I will call servlet wichich will calla model class which returns users score and then servlet redirects to result.jsp.

Is this way is right ?

 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would strongly recommend this excellent article to get you thinking on the correct path
http://www.javaranch.com/journal/200603/Journal200603.jsp#a5
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a number of online exam practice applications - here is my distilled wisdom

1. Model / View / Controller architecture works best for maximum flexibility. Especially now that there are so many ways to "view",

2. Any conventional "database" structure will end up being inflexible and annoying.

3. Think about who is going to author the questions and how to allow corrections and additions to a given exam.

4. An XML representation of the exam script will be must flexible but don't make your author write XML.

Bill

 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Under each question I am showing three buttons ( previous ,next , finish) below the question after options.

On first question previous button is disabled , how can I enable it on second and all other question

Do I have to do a if-else in jsp page , to track it like if its first question previous button is disabled else enable.

How to achieve this.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On first question previous button is disabled , how can I enable it on second and all other question


You have to track the "state" of the user - this is more complicated than a simple if / else - consider the following.

1. where the user is in the question sequence ... initial instructions, first question, mid, last question
2. has the test been graded - obviously you can't go changing answers after the test is graded

No, this is NOT something you do in a JSP page, this is decision making and belongs in servlet logic.

Bill
 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought of saving the questions in database , on request of new exam I will fetch all the questions from DB and then save it into user`s session.

But How do to that using Files , I think I have to use regex for splitting of question and options of that question , should i also save answer of question in that same file.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mahtab Alam wrote:I thought of saving the questions in database , on request of new exam I will fetch all the questions from DB and then save it into user`s session.

But How do to that using Files , I think I have to use regex for splitting of question and options of that question , should i also save answer of question in that same file.


Thats why I suggest using an XML formatted document to hold questions instead of a database. XML is flexible so in addition to the question and options you can store answers, references, explanations, links to images etc. Furthermore, with a little thought you can add new question types to a test without having to reformat all of the questions.

Bill

 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I can save questions like this



Do I have to create a Model class for representation of a Question .
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do I have to create a Model class for representation of a Question .


Here is how I did it:

1. An instance of the Model class is created for each question in the exam
2. the instance is initialized by giving it a reference to the base question Element - in your case <item>
3. the model class has methods for extracting question data from the Element as needed - there is no reason to extract anything from the XML element until / unless it is needed. This is the virtue of working with the DOM Element, you can change /add more data to the basic structure without having to rewrite everything. Furthermore, only the Model class needs to know anything about the underlying XML representation.

There is also a Test model class that holds everything related to a single user taking a single test, the questions, the current state, etc etc.

Bill
 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to read the xml file every time I want to show next question.
So when use clicks on next button I have to call some method , how can i do that .

My Model class QuizQuestion will be somewhat like

class QuizQuestion
{

String question;
String [] answer;
int correctAnswerIndex;

public int getAnswerIndex(int questionNumber){}
public boolean checkUserAnswer(int questionNumber){}

}
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to read the xml file every time I want to show next question.


Where did you get that idea?

Once you have the XML document that defines all the questions in memory as a DOM, you keep it in memory. One DOM of the question set can handle any number of "simultaneous" users because the DOM is not modified.

Sure, a DOM is not particularly memory efficient, but who cares, it does a great job of encapsulating the question script.

The Model object for a single question provides access methods to the question data so that the View functions can create the question display and Controller functions can record answers, decide what the next thing to present is, and all that sort of logic.

Bill
 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The certpal site uses following hidden fields for their online exam app


I think one servlet that will manage all events and set up question for view , one Model class and a jsp is all that is needed.

What I am still not able to understand is , like on first question i don`t have to show previous button and on last question i don`t have to show next button.
Where & what i should write to achieve this.

 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see the use of another model class Exam that keeps track of individual exam.
Otherwise differentiating between two concurrent exams will be almost impossible.

What will be the probable members of Exam class.
1. An int that marks the current question in an individual exam.
2. Result of the exam

Is it required to have QuizQuestion as a member of Exam class ?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To quote my previous post:
There is also a Test model class that holds everything related to a single user taking a single test, the questions, the current state, etc etc.


I am sure you will discover what is required in this Test model class as you work out the total design.

I suggest doing Use Case diagrams to help you figure out the various possible "states" the user can be in. I have always found diagrams like this to be very helpful.

Bill
 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you bill.

I will work on it and post here if I need some help.
 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where I should create a new Exam class instance , I have to create a new Exam instance for each new exam.

I can not put it inside doGet or doPost of ExamHandlerServlet class , and I can not make it a member of ExamHandlerServlet class ( which is the servlet handling all the exams).

How ExamHandlerServlet class will know on which Exam instance it is currently working.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Obviously you would create a new Exam object when you get a new user entering the application.

Hidden variables are a great way to identify how to handle each request.

I get the feeling you are working too close to the problem and have not yet diagrammed out the various use cases. You will know you have an adequate set of diagrams when you can show another person how they would progress through a test.

Bill
 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you William . I have created the app where I am reading questions from xml file.
I want users to get different set of questions , So I was thinking of making different exam set say 10 xml files.

So I will randomly select the xml file when I will create DOM object.
So what I will do is I will generate a random number between 1 to 10.

int i=//assign a random number between 1 to 10;
File file=new File("examset"+i+".xml");


I want to confirm from you that , this is the way to go or something else.


 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That approach would have the virtue of simplicity of operation at the cost of some extra effort to edit the questions.

For ease in maintaining the question set, I preferred to keep all questions for subject in a single XML file and build an exam by selecting from that file. However, my criteria for selecting questions could get quite complex, adaptive testing, etc. - something you don't need to get into to get started.

Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!