The Forum has been Updated
The code has been upgraded to the latest .NET core version. Please check instructions in the Community Announcements about migrating your account.
Hi everybody,
I'm currently writing a piece of code to compare the answers of 10 multiple questions with the answers. The optional answers to the questions have values of w, x, y and z. These then get compared to an array, for example:
x,x,x,x,x,x,x,x,x,x
On the quiz page the values get send to the results page.
However, when all 10 answers are correct, the outcome is 9 out of 10 points. The answer from the first question is ignored. Here's the code:
MyArray2 = Split(answer_string, ",", -1, 1)
answer1 = MyArray2(0)
answer2 = MyArray2(1)
answer3 = MyArray2(2)
answer4 = MyArray2(3)
answer5 = MyArray2(4)
answer6 = MyArray2(5)
answer7 = MyArray2(6)
answer8 = MyArray2(7)
answer9 = MyArray2(8)
answer10 = MyArray2(9)
quizscore_final = 0
if q1 = answer1 then
quizscore_final = quizscore_final + 1
end if
if q2 = answer2 then
quizscore_final = quizscore_final + 1
end if
if q3 = answer3 then
quizscore_final = quizscore_final + 1
end if
if q4 = answer4 then
quizscore_final = quizscore_final + 1
end if
if q5 = answer5 then
quizscore_final = quizscore_final + 1
end if
if q6 = answer6 then
quizscore_final = quizscore_final + 1
end if
if q7 = answer7 then
quizscore_final = quizscore_final + 1
end if
if q8 = answer8 then
quizscore_final = quizscore_final + 1
end if
if q9 = answer9 then
quizscore_final = quizscore_final + 1
end if
if q10 = answer10 then
quizscore_final = quizscore_final + 1
end if
I'm not that familiar with arrays, but is there any reason why the first question answer is not correctly calculated?
I have tried "response.write" to display the selected answers as well as the given answers and these get listed correctly. However, the score result has a maximum of 9 max instead of 10.
Anybody has any suggestions?
With kind regards,
Dominic
****Edit****
I noticed that the in predetermined answers that get pulled from the array, a space is added before the variable of answer1. This seems to cause the issue, as "X" is not equal to " X".
answer1 = X
answer2 =X
answer3 =X
answer4 =X
Why is this space added when the array is split?
I'm currently writing a piece of code to compare the answers of 10 multiple questions with the answers. The optional answers to the questions have values of w, x, y and z. These then get compared to an array, for example:
x,x,x,x,x,x,x,x,x,x
On the quiz page the values get send to the results page.
However, when all 10 answers are correct, the outcome is 9 out of 10 points. The answer from the first question is ignored. Here's the code:
MyArray2 = Split(answer_string, ",", -1, 1)
answer1 = MyArray2(0)
answer2 = MyArray2(1)
answer3 = MyArray2(2)
answer4 = MyArray2(3)
answer5 = MyArray2(4)
answer6 = MyArray2(5)
answer7 = MyArray2(6)
answer8 = MyArray2(7)
answer9 = MyArray2(8)
answer10 = MyArray2(9)
quizscore_final = 0
if q1 = answer1 then
quizscore_final = quizscore_final + 1
end if
if q2 = answer2 then
quizscore_final = quizscore_final + 1
end if
if q3 = answer3 then
quizscore_final = quizscore_final + 1
end if
if q4 = answer4 then
quizscore_final = quizscore_final + 1
end if
if q5 = answer5 then
quizscore_final = quizscore_final + 1
end if
if q6 = answer6 then
quizscore_final = quizscore_final + 1
end if
if q7 = answer7 then
quizscore_final = quizscore_final + 1
end if
if q8 = answer8 then
quizscore_final = quizscore_final + 1
end if
if q9 = answer9 then
quizscore_final = quizscore_final + 1
end if
if q10 = answer10 then
quizscore_final = quizscore_final + 1
end if
I'm not that familiar with arrays, but is there any reason why the first question answer is not correctly calculated?
I have tried "response.write" to display the selected answers as well as the given answers and these get listed correctly. However, the score result has a maximum of 9 max instead of 10.
Anybody has any suggestions?
With kind regards,
Dominic
****Edit****
I noticed that the in predetermined answers that get pulled from the array, a space is added before the variable of answer1. This seems to cause the issue, as "X" is not equal to " X".
answer1 = X
answer2 =X
answer3 =X
answer4 =X
Why is this space added when the array is split?