我如何在在线考试(MVC)中每页管理一个问题 [英] How I manage one question per page in online exam (MVC)

查看:85
本文介绍了我如何在在线考试(MVC)中每页管理一个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在线考试:假设在db中有100个问题。



在客户端每页一个问题必须显示..在上一个和下一个按钮单击问题显示。



我应该使用什么逻辑?





!? >每个按钮点击调用数据库得到1个新问题??

!? >如果超过100 ..30随机问题如果需要得到30问题(同一页1问题)



我尝试了什么:



目前没有得到任何解决方案。

online exam : suppose having 100 question in db.

in client side one question per page have to display..on previous and next button click question display.

what logic i should use ?


!? > every button click call db to get 1 new question ??
!? > what if out of 100 ..30 random question get if required 30 question (same one page one question)

What I have tried:

currently not get any solution.

i don't know how to start.

推荐答案

您应该将 x 问题加载到DataTable [ ^ ]或 DataSet [ ^ ]对象,其中 x 表示:和你一样多希望或要求。

如果您想获得30个随机问题,可以使用 Take() [ ^ ] Linq方法:

You should load x questions into DataTable[^] or DataSet[^] object, where x means: as many as you wish or requires.
If you want to get 30 random questions, you may use Take()[^] Linq method:
var rand = new Random();   
var result = yourDataTable.AsEnumerable().OrderBy(r => rand.Next()).Take(30); //get 30 records from datatable



或服务器端解决方案:从大表中随机选择行 [ ^ ]



如果您有一组问题,可以使用跳过() [ ^ ]和一起Take()




or server side solution: Selecting Rows Randomly from a Large Table[^]

When you've got a set of questions, you may go to the next question by using Skip()[^] and Take() together:

var nextQuestion = yourDataTable.AsEnumerable().Skip(currentIndex).Take(1);
//currentIndex -> currently displayed question





现在,您已经了解了如何实现目标。我们去上班吧!

祝你好运!



Now, you,ve got an idea how to achieve your goals. Let's go to work!
Good luck!


这篇关于我如何在在线考试(MVC)中每页管理一个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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