开发者

How to persist student online quiz data in case of power failure

I need a suggestion about a scenario. E.g. if a student is taking assessment quiz online from his home and during this quiz ...the elecricity failure happens in the middle of quiz. so in that开发者_JAVA技巧 scenario, how would we manage the state. I mean what could be the possible solution for that.. the solution can be in any form. Please give ur suggestions about how would you handle that situation. Previously, the states are being stored using sessions and cache.

Thanks in advance.


Electricity failure on student's side

Your quiz probably flows from page to page where each page POSTs data to the server. You should just save posted data to some persistent medium (database would be best).

Identifying users after restart

  1. Users are anonymous

    If your users don't need to login before taking the quiz you have to identify them somehow. Give them a persistent cookie with some identifier that you use in your DB to store their answers, so if power goes down and when they come back you will still be able to know who they are, because cookie will be sent to you automatically. The problem here is of course what happens when multiple students use the same machine. You'd have to solve that too. The easiest way is to let your users login to your quiz app.

  2. Users are logged in

    This is the simple case where you simply save their answers along with their ID. It works similar to first example but with the difference, that you know who they are exactly (know their name etc.)

What if you have several quizzes?

If that's the case you probably don't want to create a separate table for each one to store answers in. Th best way in this case would be to have a single table schema:

UserID, QuizID, CurrentStep, Answers
-------------------------------------

This will give you all the information about where users are in the quiz (so you they can continue after power failure) and save answers as XML data. Current step may help you when quiz is a stepped process and users return to existing unfinished quiz. This will help you display the first unfinished step to them, so they can easily continue where they left.

This will give you enough possibilities to store several different quizzes in the same table. XML data can provide simple straightforward answers or branched ones. Depends what your quizzes are like.

What kind of DB should you choose?

You can either choose schematic database like MySql, Oracle or SQL Server or you can go with a document-oriented database that may be much more suited to your needs. Depending on the platform you use you will find a suitable doc-type DB.

Assessment based on pool of questions

As you say you have a pool of questions and I suspect a DB schema like this should support the business process. You'd have these tables:

  • Subject - this table is needed in case you'd have a centralized application for various study subjects
  • Group - has defined question groups and relates to Subject table; groups may be semester 1, semester 2 or similar; These groups will make it possible to select a set of assessment questions that are related to some subject and are part of the group that should be assessed
  • Question - this is the actual pool of questions; Every question has related data to table Group; this table could have additional metadata that would have information about question level which could count toward result question/answer points
  • Student - your students must most likely login into this application and as pointed out by several answerers here it's also recommended approach especially since I suspect students will be using common facility workstations which means that multiple students may be using the same computer
  • Assessment - this is one of the central tables, that holds data about students taking assessment test; it's related to Student table, has timestamp when assessment started etc.
  • AssessmentQuestion - a relational table that's used to record student's answers; When assessment starts an X number of records within this table are created, that actually point to particular questions that were selected for a student out of the appropriate question pool; it has at least three columns: StudentID, QuestionID and answer (nullable); additional columns are needed in case students are allowed to set an answer of don't know or similar; in this case an additional column AnswerState would be added and would relate to a lookup table with predefined states.

When a student starts an assessment and in the meantime a power failure occurs, you can always know which questions student already answered and which ones should still be answered.

You could also have additional tables with correct answers so assessment would be automated, giving results immediately after assessment questions are all completed.

Algorithm that chooses questions could be done in a way so questions are equally distributed on the long run.

But you could make the system even more complicated with even more administrative data that would automate as much tasks as possible and make them configurable so it would be more widely useful.


Sessions are volatile and are only designed for storing data that is OK to be lost. If you want to persist some data, you should store it in a database.


  • Store the data in a database, based on login.
  • Break the questionnaire into small chunks (no more than 10 questions) and save between each chunk
    • This means the user can lose up to 10 answered questions if the power fails, if this is unacceptable, you can save the temporary answers into cookie as the user answers each question (clear the cookie as the information is saved to the db)
      • This assumes you can use cookies; if you're not allowed to rely on cookies, you would need to use AJAX to periodically post the answers to the server.


Simply, you should store data to database. If you care about unexcpected power off in any moment of time, you should store data "frequently". Means, information about current state is stored for each step. The progress information is updated with each step (Not started, In progress, Finished). If user tries to start same quiz again you are checking the Status, if it still in progress (means he did not finished it, because of failure) you allow to go on.

It is not so difficult to accomplish such model. Taking into account that test data is already in database, you have to extend your db with several tables like Steps, Status and keep data there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜