如何在PHP中创建具有多个选项的在线测验 [英] How to create online quiz in php with multiple options

查看:88
本文介绍了如何在PHP中创建具有多个选项的在线测验的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建具有多个选项的在线测验,问题将来自db.Question,相应的选项将一次显示一页................

How to create online quiz having multiple options, questions will come from db.Question and coresponding options will show one page at a time ................

推荐答案

嗨Rupal,



创建一个包含以下表格的数据库



Hi Rupal,

Create a database with following tables

Table1: dbo.Questions

QuestionID int (PK)
QuestionText nvarchar(max)
CorrectAnswerID int (FK)

Table2: dbo.Answers

AnswerID int (PK)
AnswerText nvarchar(max) 
QuestionID int (FK)


Table3: dbo.AnswerOptionType

OptionID int (PK)
AnswerID int (FK)
OptionType nvarchar(max) --TextBox, RadioButton, CheckBox, Multiline TextBox

Table4: dbo.UserAnswers

UserAnswerID int (PK)
QuestionID int (FK)
AnswerID int (FK)





我希望你能拥有了解上表之间的关系。



在您的表示层(winforms或webforms)中,请按照以下步骤操作:



步骤1:查询数据库以获取所有问题和答案集。数据查询结果如下:



I hope you would have understood the relationship between the above tables.

In your presentation layer (winforms or webforms), follow the following steps:

Step 1: Query the database to get all the questions and set of answers. The data query result would look like:

QuestionID, AnswerID, QuestionText, AnswerText, OptionType





步骤2:将上述数据结果(我想它可以是数据表)存储为会话变量



步骤3:在一个问题中循环用户单击开始或下一个或上一个的时间



步骤4:根据步骤1中结果中的选项类型,生成动态控件并提供其ID控件作为选项的答案ID



步骤5:当用户点击下一步时,将所选答案保存到表4中的数据库



我希望这会给你一些编码方向。当然这不是一个完美的解决方案,但你可以调整一下。



希望它有所帮助。快乐的编码.. !!



干杯,

Nayan



Step2: Store the above data result (I suppose it would be datatable) as a session variable

Step 3: Loop through one question at a time when the user clicks start or next or previous

Step 4: Based on the option type in the result in step 1, generate dynamic controls and give the ID of those controls as Answer ID for the options

Step 5: When the user clicks next, save the selected answer to the database in Table4

I hope this would give you some direction in coding. Of course this isn''t a perfect solution, but you an tweak around.

Hope it helps. Happy coding..!!

Cheers,
Nayan


这篇关于如何在PHP中创建具有多个选项的在线测验的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆