【发布时间】:2015-10-08 17:33:37
【问题描述】:
我正在 asp.net mvc4 中构建一个在线测试 webapp。我需要让用户在上一个和下一个问题之间导航(一次只有一个问题)。我有一个布局,其中有一个倒数计时器。我在视图中有一个问题和选项列表作为模型,我需要通过上一个和下一个按钮导航列表。布局必须保持不变,因为它有一个计时器。当用户单击“下一个”时,当前问题应与选择的答案一起返回列表(通过单选按钮),并且应显示列表中的下一个问题。上一个按钮也可以完成类似的功能。谁能推荐一个 Ajax、Json 或 Javascript 的解决方案?
视图:StartTest
@model LoginTrial3.Models.QuestionPaper
@{
ViewBag.Title = "StartTest";
Layout = "~/Views/Shared/_LayoutTest.cshtml";
}
<h2>StartTest</h2>
模型:试卷
public class QuestionPaper
{
public List<object> RandomQuestionList = new List<object>();
//generate the maps to hold the answers
public Dictionary<int, string> AptiAnsList = new Dictionary<int, string>();
public Dictionary<int, string> TechAnsList = new Dictionary<int, string>();
//define a ctor
public QuestionPaper(List<object> QList)
{
foreach(var item in QList)
{
RandomQuestionList.Add(item);
}
}
}
QList 中的每个对象都是 AptiQuestionType :
public class AptiQuestion
{
public int Id { get; set; }
public string Question { get; set; }
public string OptionA { get; set; }
public string OptionB { get; set; }
public string OptionC { get; set; }
public string ExpectedAnswer { get; set; }
}
【问题讨论】:
标签: javascript jquery ajax asp.net-mvc asp.net-mvc-4