我正在使用发布here
的JavaScript测验脚本我有50个测验,其中包含一个结果
但是我希望每10次测验或者15次测验都有特定的结果
我该怎么做?
这是javascript源代码
//Enter total number of questions:
var totalquestions=50
//Enter the solutions corresponding to each question:
var correctchoices=new Array()
correctchoices[1]='c' //question 1 solution
correctchoices[2]='a' //question 2 solution, and so on.
correctchoices[3]='c'
correctchoices[4]='c'
correctchoices[5]='c'
correctchoices[6]='c'
correctchoices[7]='b'
correctchoices[8]='b'
correctchoices[9]='c'
correctchoices[10]='b'
correctchoices[11]='c'
correctchoices[12]='a'
correctchoices[13]='c'
correctchoices[14]='c'
correctchoices[15]='c'
correctchoices[16]='c'
correctchoices[17]='b'
correctchoices[18]='b'
correctchoices[19]='c'
correctchoices[20]='b'
correctchoices[21]='c'
correctchoices[22]='a'
correctchoices[23]='c'
correctchoices[24]='c'
correctchoices[25]='c'
correctchoices[26]='c'
correctchoices[27]='b'
correctchoices[28]='b'
correctchoices[29]='c'
correctchoices[30]='b'
correctchoices[31]='c' //question 1 solution
correctchoices[32]='a' //question 2 solution, and so on.
correctchoices[33]='c'
correctchoices[34]='c'
correctchoices[35]='c'
correctchoices[36]='c'
correctchoices[37]='b'
correctchoices[38]='b'
correctchoices[39]='c'
correctchoices[40]='b'
correctchoices[41]='c'
correctchoices[42]='a'
correctchoices[43]='c'
correctchoices[44]='c'
correctchoices[45]='c'
correctchoices[46]='c'
correctchoices[47]='b'
correctchoices[48]='b'
correctchoices[49]='c'
correctchoices[50]='b'
/////Don't edit beyond here//////////////////////////
function gradeit(){
var incorrect=null
for (q=1;q<=totalquestions;q++){
var thequestion=eval("document.myquiz.question"+q)
for (c=0;c<thequestion.length;c++){
if (thequestion[c].checked==true)
actualchoices[q]=thequestion[c].value
}
if (actualchoices[q]!=correctchoices[q]){ //process an incorrect choice
if (incorrect==null)
incorrect=q
else
incorrect+="/"+q
}
}
if (incorrect==null)
incorrect="a/b"
document.cookie='q='+incorrect
if (document.cookie=='')
alert("Your browser does not accept cookies. Please adjust your browser
settings.")
else
window.location="results.htm"
}
function showsolution(){
var win2=window.open("","win2","width=200,height=350, scrollbars")
win2.focus()
win2.document.open()
win2.document.write('<title>Solution</title>')
win2.document.write('<body bgcolor="#FFFFFF">')
win2.document.write('<center><h3>Solution to Quiz</h3></center>')
win2.document.write('<center><font face="Arial">')
for (i=1;i<=totalquestions;i++){
for (temp=0;temp<incorrect.length;temp++){
if (i==incorrect[temp])
wrong=1
}
if (wrong==1){
win2.document.write("Question "+i+"="+correctchoices[i].fontcolor("red")+"
<br>")
wrong=0
}
else
win2.document.write("Question "+i+"="+correctchoices[i]+"<br>")
}
win2.document.write('</center></font>')
win2.document.write("<h5>Note: The solutions in red are the ones to the
questions you had incorrectly answered.</h5><p align='center'><small><a
href='http://www.javascriptkit.com' target='_new'>JavaScript Kit quiz
script</a></small>")
win2.document.close()
}