希望创建javascript测验/问卷 [英] looking to create javascript quiz/questionaire

查看:64
本文介绍了希望创建javascript测验/问卷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


这里的第一次海报...我是网站管理员,我想添加一个简单的

脚本到我的网站将允许用户填写一个简短的多个

选择问卷,然后基于

他们的答案提供一个''尽管'的建议。


就实际脚本所涉及的逻辑而言:我已经仔细考虑过了b
$ b并彻底打破了我的大脑,试图设计一个复杂的

''评分系统''(不同的答案给予不同的投票给不同的结果)或消除系统,每个答案

消除一半可能的结果,直到只剩下一个

。所有这些都不可避免地引出一个是的,但是这个案件怎么样?


我终于认定这个可能更简单了更好......只有

会有一些问题,而且我只有少量的b
结果,我想我想要的只是提供我自己的答案,每个

独特的答案组合(我认为会在10-20之间)。


我有点挣扎了与编码。我看过

javascript测验的例子,而且我发现的大部分是这样的东西:


var score = 0;

ans [1] =" b";

ans [2] =" b";

ans [3] =" a" ;;

ans [4] =" c";

ans [5] =" b";


伴随此:


for(i = 1; i< = 5; i ++){

answerText = answerText +" \\\
Question:" + i +" \ n";

if(ans [i]!= yourAns [i]){

answerText = answerText +" \ n正确答案是

" + ans [i] +" \ n" + explainAnswer [i] +" \ n" ;;

}

else {

answerText = answerText +" \\\
Correct! \ n" ;;

得分++;


和:


answerText = answerText +" \ n \ n你的总分是:+得分+\ n" ;;

我完全没有达到这个目的的速度,但我很想学习。

演绎地表示每个问题在这个

特定测验中都有一个正确的答案,然后总计''正确'答案。而不是这个,

我希望每个可能的答案字符串都是一个变量,此时

用户被定向到一个合适的结果页面。

例如,AAAA = 1,AAAB = 2 AAAC = 3等等。


有没有人有任何脚本或任何建议?


谢谢!


克里斯

Hi all,

First time poster here... I''m a webmaster and I''d like to add a simple
script to my website which will allow users to fill in a brief multiple
choice questionaire, and then provide a ''thoughful'' suggestion based on
their answers.

In terms of the logic involved with the actual script: I''ve mulled it
over and thoroughly broken my brain, trying to devise a complicated
''scoring system'' (with different answers giving different votes to
different outcomes) or an elimination system, with each answer
eliminating half of the possible outcomes, until there is only one
left. All of these inevitably elicit a "yeah, but what about this
case..."

I''ve finally decided that simpler is probably better... there are only
going to be a handful of questions, and I only have a handful of
outcomes, and I think I''d like to just provide my own answer, for each
unique combination of answers (there will be between 10-20 I think).

I''m struggling a bit with coding. I''ve looked at examples of
javascript quizzes, and mostly what I''ve found is stuff like this:

var score = 0;
ans[1] = "b";
ans[2] = "b";
ans[3] = "a";
ans[4] = "c";
ans[5] = "b";

accompanying this:

for(i=1;i<=5;i++){
answerText=answerText+"\nQuestion :"+i+"\n";
if(ans[i]!=yourAns[i]){
answerText=answerText+"\nThe correct answer was
"+ans[i]+"\n"+explainAnswer[i]+"\n";
}
else{
answerText=answerText+" \nCorrect! \n";
score++;

and:

answerText=answerText+"\n\nYour total score is : "+score+"\n";
I''m totally not up to speed with this stuff, but I''m eager to learn.
Deductively it looks like each question has a ''correct'' answer in this
particular quiz and then it totals ''correct'' answers. instead of this,
I want each possible string of answers to be a variable, at which point
the user is directed to an appropriate outcome page.
For example, AAAA = 1, AAAB = 2 AAAC = 3 and so on.

Does anyone have any scripts or any suggestions?

Thanks!

Chris

推荐答案

只是一个更新,我''我决定使用我想要使用的方法。


假设我的测验中有6个问题,一些有2个可能的

答案,有些有3或4 ...我给每个答案分配一个6位数字。

然后,我把它们总计。


有意义吗?对于问题1,其中答案是A)或B),

变量将是100,000或200,000 ...然后问题2,使用

a 5位数数字,等等。


例如,


200,000 +

010,000 +

003,000 +

000,200 +

000,040 +

000,003 = 213,243,现在是一个变量,包含信息

关于如何回答6个问题中的每个问题。


看来我将有288种可能的组合,我会分析

我自己并提供一个解决方案。


我仍​​然不确定如何编码。如何为每个可能的答案分配整数

变量,然后将指令

与它们相加,然后将解决方案与每个可能的答案相关联?

任何有关如何入门的建议都将不胜感激。


-Chris

Just an update, I''ve decided on the method I''d like to use.

Assuming there are 6 questions in my quiz, some with 2 possible
answers, some with 3 or 4... I assign each answer a 6 digit number.
then, I total them up.

Make sense? For question 1, in which the answer is either A) or B),
the variables would be 100,000 or 200,000... then for question 2, using
a 5 digit number, and so forth.

For example,

200,000 +
010,000 +
003,000 +
000,200 +
000,040 +
000,003 = 213,243, which is now a variable, that contains information
about how each of 6 questions was answered.

It appears I''ll have 288 possible combinations, which I''ll analyze
myself and offer a ''solution'' for.

I''m still unsure about how to code it. How do I assign integer
variables for each of the possible answers, then give the instruction
to total them, then associate a ''solution'' with each possible answer?
Any advice about how to get started would be greatly appreciated.

-Chris


ad***@stacksback.com 在3/22/2006 8:05 PM说了以下内容:
ad***@stacksback.com said the following on 3/22/2006 8:05 PM:
大家好,

这里的第一次海报...我是网站管理员,我想在我的网站上添加一个简单的
脚本,这将允许用户填写一个简短的多个选择问卷,然后根据他们的答案提供一个''尽管''的建议。


它可能比你想象的更多,取决于你希望它工作的方式



In与实际剧本有关的逻辑术语:我已经仔细研究了它并彻底打破了我的大脑,试图设计一个复杂的评分系统(不同的答案给予不同的选票)
不同的结果)或消除系统,每个答案消除一半可能的结果,直到只剩下一个
。所有这些都不可避免地引出一个是的,但是这个案件怎么样......


这对任何事情都是如此。即使是这种情况:)

我终于决定更简单可能更好......只有少数几个问题,我只有一小撮<结果,我想我只想提供我自己的答案,每个答案的独特组合(我认为会有10到20之间)。


有多少可能的结果取决于有多少问题,以及有多少问题可以解答这些问题。为了获得可能的结果,将每个问题的答案数量乘以

。它变得非常大,很快就会变成
。例如:


问题1:3答案

问题2:2答案

问题3:5答案

问题4:3答案


有多少可能的结果? 3 * 2 * 5 * 3 = 90,这只是4个问题。它可以说是b $ b,实际的结果数是

288,这是基于一个问题仍未得到答复的可能性

提供了额外的答案。使用带有一个默认值的广播按钮

进行检查可以减轻这种情况。或者,选择列表没有选择一个

答案类型选项。


< snip>

我完全没有达到速度,但我很想学习。<演绎地说,看起来每个问题在这个特定的测验中都有一个正确的答案,然后总结出正确的答案。


是的,这就是代码所做的。

而不是这个,我希望每个可能的答案串都是变量,在用户指向一个适当的结果页面。
例如,AAAA = 1,AAAB = 2 AAAC = 3,依此类推。


如果有5个问题,A B C和D作为可能的答案,那么你有可能获得1,024美元b
的结果。不是一个非常讨人喜欢的想法,必须创造许多页面的结果。再添一个问题,你的结果会跳到

4,096。给它一个额外的选择(E)然后你的5个问题现在有3,125

可能的结果。 6个问题,5个可能的答案是15,625

可能的结果。


10个问题,每个答案6个答案? 6 ^ 10 = 60,466,176可能的结果。


您准备为10个问题测验创建超过6,000万个页面吗?

是否有人有任何脚本或任何建议?
Hi all,

First time poster here... I''m a webmaster and I''d like to add a simple
script to my website which will allow users to fill in a brief multiple
choice questionaire, and then provide a ''thoughful'' suggestion based on
their answers.
It might be more involved than you think it is, depending on which way
you want it to work.
In terms of the logic involved with the actual script: I''ve mulled it
over and thoroughly broken my brain, trying to devise a complicated
''scoring system'' (with different answers giving different votes to
different outcomes) or an elimination system, with each answer
eliminating half of the possible outcomes, until there is only one
left. All of these inevitably elicit a "yeah, but what about this
case..."
That''s true with anything. Even this case :)
I''ve finally decided that simpler is probably better... there are only
going to be a handful of questions, and I only have a handful of
outcomes, and I think I''d like to just provide my own answer, for each
unique combination of answers (there will be between 10-20 I think).
How many possible outcomes depends on how many questions, and how many
answers those questions have. To get the possible outcomes, multiply the
number of answers for each question together. It gets quite large
quickly. Example:

Question 1: 3 Answers
Question 2: 2 Answers
Question 3: 5 Answers
Question 4: 3 Answers

How many possible outcomes? 3*2*5*3 = 90 and that''s just 4 questions. It
could be argued that the actual number of outcomes to that is instead
288, based on the possibility that a question remains unanswered which
provides an additional "answer". Using Radio Buttons with one defaulted
to checked would alleviate that. Or, a Select list with no "Choose an
Answer" type options.

<snip>
I''m totally not up to speed with this stuff, but I''m eager to learn.
Deductively it looks like each question has a ''correct'' answer in this
particular quiz and then it totals ''correct'' answers.
Yes, that is what the code did.
instead of this, I want each possible string of answers to
be a variable, at which point the user is directed to an
appropriate outcome page.
For example, AAAA = 1, AAAB = 2 AAAC = 3 and so on.
With 5 questions with A B C and D as possible answers, you have 1,024
possible outcomes. Not a very pleasing thought to have to create that
many pages of outcomes. Add one more question and your outcomes jump to
4,096. Give it an extra choice (E) then your 5 questions now have 3,125
possible outcomes. 6 questions with 5 possible answers is 15,625
possible outcomes.

10 questions with 6 answers each? 6^10 = 60,466,176 possible outcomes.

You ready to create over 60 million pages for a 10 question quiz?
Does anyone have any scripts or any suggestions?




建议:您可能想重新考虑这个项目:)


-

Randy

comp.lang.javascript常见问题 - http:// jibbering。 com / faq &新闻组每周

Javascript最佳实践 - http://www.JavascriptToolbox .com / bestpractices /



Suggestion: You may want to re-think this project :)

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


ad *** @ stacksback.com 在2006年3月22日下午9:58说如下:


请引用您的回复。


如果你想通过groups.google.com发布一个后续内容,不要使用

"回复"链接在文章的底部。点击显示选项在

文章的顶部,然后点击回复。在

文章标题的底部。

< URL: http://www.safalra.com/special/googlegroupsreply/ >
ad***@stacksback.com said the following on 3/22/2006 9:58 PM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don''t use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.
<URL: http://www.safalra.com/special/googlegroupsreply/ >
只是一个更新,我已经决定关于我想要使用的方法。
假设我的测验中有6个问题,一些有2个可能的答案,有些有3个或4个...我给每个答案分配一个6位数字那么,我把它们总结起来了。


好​​了,到目前为止很简单。

有意义吗?对于问题1,其中答案是A)或B),
变量将是100,000或200,000 ......然后对于问题2,使用
5位数字,等等。


虽然这确实很难。输入元素的值

是一个字符串。当你添加字符串时,你得到一个字符串:


" 6" +2 =" 62"

6 + 2 = 8

例如,

200,000 +
010,000 +
003,000 +
000,200 +
000,040 +
000,003 = 213,243,现在是一个变量,其中包含有关如何回答每个问题的信息。


" 2" +1 +3 +2 +4 + 3 =" 213243"这就是你需要的。

如果你试图使用数字,你必须将它转换为

数字(删除逗号后),然后添加它们一起。只需使用

string',你不必担心所有这些。

看来我会有288种可能的组合,我就是我将自己分析并提供一个解决方案。


多少可能的组合取决于每个答案的答案数量多少但是如果你想出288我会相信你知道怎么弄明白。

我仍​​然不确定如何编码。如何为每个可能的答案分配整数
变量,然后给出总计它们的指令,然后将解决方案与每个可能的答案相关联?
关于如何非常感谢开始使用。
Just an update, I''ve decided on the method I''d like to use.
Assuming there are 6 questions in my quiz, some with 2 possible
answers, some with 3 or 4... I assign each answer a 6 digit number.
then, I total them up.
OK, simple so far.
Make sense? For question 1, in which the answer is either A) or B),
the variables would be 100,000 or 200,000... then for question 2, using
a 5 digit number, and so forth.
It does have to be that difficult though. The value of an input element
is a string. When you add strings, you get a string:

"6" + "2" = "62"
6 + 2 = 8
For example,

200,000 +
010,000 +
003,000 +
000,200 +
000,040 +
000,003 = 213,243, which is now a variable, that contains information
about how each of 6 questions was answered.
"2" + "1" + "3" + "2" + "4" + 3" = "213243" which is what you need.
If you try to use numbers for it, you will have to convert it to a
number (after removing the commas), then add them together. Just use
string''s and you don''t have to worry with all of that.
It appears I''ll have 288 possible combinations, which I''ll analyze
myself and offer a ''solution'' for.
How many possible combinations depends on how many answers each has but
if you came up with 288 I will trust that you knew how to figure it out.
I''m still unsure about how to code it. How do I assign integer
variables for each of the possible answers, then give the instruction
to total them, then associate a ''solution'' with each possible answer?
Any advice about how to get started would be greatly appreciated.




不要使用整数,使用输入的自然字符串值:


所有这些都可以在没有客户端脚本的情况下完成。提交

表单到服务器,让服务器总计答案并返回

适当页面。


函数getTotal( ){

answer1 = document.myForm.question1.value;

answer2 = document.myForm.question2.value;

answer3 = document。 myForm.question3.value;

answer4 = document.myForm.question4.value;

answer5 = document.myForm.question5.value;

answer6 = document.myForm.question6.value;

totalAnswer = answer1 + answer2 + answer3 + answer4 + answer5 + answer6;

alert(totalAnswer);

}


使用此HTML:


< form name =" myForm">

< select name =" question1">

< option value =" 1">答案1< / option>

< option value = " 2">答案2< /选项>

< / select>

< select name =" question2">

< option value =&q uot; 1">答案1< /选项>

<选项值=" 2">答案2< /选项>

<选项值= " 3">答案3< /选项>

< / select>

< select name =" question3">

< option value =" 1">答案1< /选项>

< option value =" 2">答案2< /选项>

< option value =" 3">答案3< /选项>

< option value =" 4">答案4< / option>

< / select>

< select name =" question4">

< option value =" 1">答案1< /选项> ;

< option value =" 2">答案2< /选项>

< / select>

< select name =" question5">

< option value =" 1">答案1< / option>

< option value =" 2" >答案2< / option>

< option value =&qu ot; 3">答案3< /选项>

< option value =" 4">答案4< / option>

< option value = 5>答案5< / option>

< / select>

< select name =" question6">

< option value =" 1">答案1< /选项>

< option value =" 2">答案2< /选项>

< / select>


< input type =" button"的onclick = QUOT; getTotal()" value ="获取总额>

< / form>


如上所述,它只会给你总数。将

警报(totalAnswer)行更改为以下内容:

document.location.href = totalAnswer +" .html";


每个可能的组合在哪里?相应地命名页面

页面124236.html是包含1 2 4 2 3

6组合的页面。


-

兰迪

comp.lang.javascript常见问题 - http://jibbering.com/faq &新闻组每周

Javascript最佳实践 - http://www.JavascriptToolbox .com / bestpractices /



Don''t use integers, use the natural string value of inputs:

All of this could be done without client side scripting though. Submit
the form to the server, let the server total the answers and return the
appropriate page.

function getTotal(){
answer1 = document.myForm.question1.value;
answer2 = document.myForm.question2.value;
answer3 = document.myForm.question3.value;
answer4 = document.myForm.question4.value;
answer5 = document.myForm.question5.value;
answer6 = document.myForm.question6.value;
totalAnswer = answer1 + answer2 + answer3 + answer4 + answer5 + answer6;
alert(totalAnswer);
}

With this HTML:

<form name="myForm">
<select name="question1">
<option value="1">Answer 1</option>
<option value="2">Answer 2</option>
</select>
<select name="question2">
<option value="1">Answer 1</option>
<option value="2">Answer 2</option>
<option value="3">Answer 3</option>
</select>
<select name="question3">
<option value="1">Answer 1</option>
<option value="2">Answer 2</option>
<option value="3">Answer 3</option>
<option value="4">Answer 4</option>
</select>
<select name="question4">
<option value="1">Answer 1</option>
<option value="2">Answer 2</option>
</select>
<select name="question5">
<option value="1">Answer 1</option>
<option value="2">Answer 2</option>
<option value="3">Answer 3</option>
<option value="4">Answer 4</option>
<option value="5">Answer 5</option>
</select>
<select name="question6">
<option value="1">Answer 1</option>
<option value="2">Answer 2</option>
</select>

<input type="button" onclick="getTotal()" value="Get the Total">
</form>

As written, it will just give you the total. Change the
alert(totalAnswer) line to something like this:

document.location.href = totalAnswer + ".html";

Where each of your "possible combination" pages are named accordingly so
that page 124236.html is the page that has the combination for 1 2 4 2 3
6 combination.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


这篇关于希望创建javascript测验/问卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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