任何人都可以帮我用mvc代码,情况是我有一个问题,它有4个选项,其中一个是正确的。 [英] Can any one please help me with mvc code, situation is i have a question and it has 4 options out of which one is correct .

查看:67
本文介绍了任何人都可以帮我用mvc代码,情况是我有一个问题,它有4个选项,其中一个是正确的。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我使用MVC代码,情况是我有一个问题,它有4个选项,其中一个是正确的。



例如

1.什么是2 + 2?

a)2

b)3

c)4

d)5



保存 下一步 关闭





在帖子中我如何获得问题文本,正确的选项ID,和选择的选项ID。



请帮帮我



我尝试了什么:



Can any one please help me with MVC code, situation is I have a question and it has 4 options out of which one is correct .

Eg
1. What is 2 +2 ?
a) 2
b) 3
c) 4
d) 5

Save Next Close


in post how do i get question text , correct option ID, and selected option ID.

please help me

What I have tried:

var evalVM = new Evaluation();
var q1 = new QuestionVM { ID = 1, QuestionText = "What is your favourite language" };
q1.OptionVMs.Add(new OptionVM { ID = 12, AnswerText = "PHP" });
q1.OptionVMs.Add(new OptionVM { ID = 13, AnswerText = "ASP.NET" });
q1.OptionVMs.Add(new OptionVM { ID = 14, AnswerText = "Java" });
evalVM.QuestionsVMs.Add(q1);

var q2 = new QuestionVM { ID = 2, QuestionText = "What is your favourite DB" };
q2.OptionVMs.Add(new OptionVM { ID = 16, AnswerText = "SQL Server" });
q2.OptionVMs.Add(new OptionVM { ID = 17, AnswerText = "MyQL" });
q2.OptionVMs.Add(new OptionVM { ID = 18, AnswerText = "Oracle" });
evalVM.QuestionsVMs.Add(q2);

return View(evalVM);

推荐答案

您好Rahul Yadav,

似乎您的问题需要更多细节。

1.您是从任何数据库加载数据吗?

2.如何控制用户选择答案?



如果是单选按钮列表单击发布按钮时,可以在JavaScript中添加单击事件,您可以阅读所选选项。从JavaScript函数中,您可以调用控制器并传递数据。



在该方法中,您可以通过将QuestionNo传递给DB来获得答案。



这里我的示例带有一个复选框列表(因为我对MVC也不太了解):



Hi Rahul Yadav,
Seems your question needs more details.
1. Are you loading data from any DB?
2. How you are giving a control to the user to select the answer?

If it is a Radio Button list While on click of Post button you can add a click event in JavaScript and you can read the selected option. From JavaScript function you can call controller and pass the data.

In that method you can get the answer by passing QuestionNo to DB.

Here my Example with a Check Box list (as i also don't have much idea about MVC):


(#PostAnswer)。click(function(){//< pre> PostAnswer是Button ID

var questionlist = [], counter = 0;
("#PostAnswer").click(function () { //<pre>PostAnswer is Button ID var questionlist = [], counter = 0;


('。chkbox1')。each(function(){
if(
('.chkbox1').each(function () { if (


这篇关于任何人都可以帮我用mvc代码,情况是我有一个问题,它有4个选项,其中一个是正确的。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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