开发者

How do I create a schema for a quiz engine?

I am developing a testing tool that will include different modules/categories of questions and wil开发者_运维技巧l allow for different question/problem types (i.e. multiple choice, multiple choice with audio, audio plus a form, others) . A test(quiz) will include multiple choice questions with a variable number of choices.

Below is my initial schema:

Category(Id, Name)

Question (Id, CategoryId)

MultipleChoiceQuestion (Id, QuestionId, Text)

MultipleChoiceWithAudioQuestion (Id, QuestionId, Text, AudioFile, Transcript)

AudioQuestion (Id, QuestionId, AudioFile, Transcript)

Answer (Id, QuestionId, Correct)

MultipleChoiceAnswer (Id, AnswerId, Text)

AudioQuestionAnswers (Id, AnswerId, Field, Value)

Test (Id, UserId, TestDate)

TestQuestions (Id, TestId, QuestionId)

TestAnswers (Id, TestId, QuestionId, AnswerId)

I thought that the best way to allow for different question/problem types was to create a table for each subtype which would contain the additional fields particular to that question type. I got this idea from this article on data modeling: Type, Subtype, and Category Patterns in Logical Data Modeling

A test consists of different categories and each category will consist of a random selection of questions in that particular category. Each test that is taken by a user is saved to the database.

Do you think I'm on the right track? How would I map my tables to classes using an ORM like EntityFramework.

Another schema I thought of seemed to me to be too generic and difficult to query.

Content (Id, Name)

ContentMeta (Id, ContentId, MetaKey, MetaValue)

How would I display the Test which is a hierarchical composite type? Would it still be possible to use Model Binding in an ASP .NET MVC 3 (Razor).


How about:

Survey Id Name Description

QuestionType Id Name Description

Question Id QuestionTypeId Display

Survey has questions and questions have types. When it comes to storing answers, that's a different story. If you are going to have tens of thousands of responds and you'll have to query that data ad-hoc, then I'd write dynamic SQL to create a table for each of your surveys, otherwise I'd store responses in a single table.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜