?
Solved

Creating a exam page II

Posted on 2003-11-27
13
Medium Priority
?
230 Views
Last Modified: 2010-04-09
I would like to have it check against answers on the QFinal.html or what ever it would take to
do it. Sorry this is a after thought.

Example:

RESULTS

1. A         Correct ( Have this text in green)
2. B         Wrong ( Have this in red ) A is the correct answer



At the bottom of the QFinal page have a box like a " Next " box for each question, where I could click to go to that question or would it be best to just add a link. So, it would then go to Q2 and I could review, then I guess I could click the back button in the browser and it would take me back to the QFinal page. What would it take to get it to score a %.
0
Comment
Question by:CMILLER
  • 7
  • 6
13 Comments
 
LVL 15

Expert Comment

by:Timbo87
ID: 9835368
Hi Chris,

Here is the new modified QFinal.html. For now the answers are in the document. Tell me if this is what you want and I'll try to hide the answers for the final product.

<html>
<head>
<title>Results</title>
</head>
<body>
<center>
<h2>Results</h2>
</center>
<br>
<script language="JavaScript" type="text/javascript">
var anCheck = new Array();
anCheck[0] = "A"
anCheck[1] = "B"
anCheck[2] = "C"
anCheck[3] = "D"
anCheck[4] = "C"
anCheck[5] = "B"
anCheck[6] = "A"
anCheck[7] = "B"
anCheck[8] = "C"
anCheck[9] = "D"
anCheck[10] = "ACD"
wn = window.location+""
var answers = new Array()
var astring = wn.substring(wn.indexOf("html") + 5,wn.length)
var ancnt = 0
var corcnt = 0

for(i=0;i<astring.length;i++)
{
if(astring.charAt(i) == ",")
{
ancnt++
continue;
}
if(answers[ancnt] == null) answers[ancnt] = ""
answers[ancnt] += astring.charAt(i)
}
document.write("<table border=0>")
for(j=0;j<answers.length;j++)
{
if(answers[j] == anCheck[j])
{
followup = "<font color=green>Correct</font>"
corcnt++
}
else
followup = "<font color=red>Wrong " + anCheck[j] + " is the correct answer.</font> <a href='Q" + eval(j+1) + ".html'>View Question</a>"
document.write("<tr><td>" + eval(j+1) + ".</td>" + "<td>" + answers[j] + "</td>" + "<td>" + followup + "</td></tr>")
}
document.write("</table><br><br><center>" + corcnt + " out of " + answers.length + " correct. <br><h3>" + Math.round((corcnt/answers.length*100)) + "%</h3>")

</script>
<input type="button" value="Print Results" onClick="window.print()">
</center>
</body>
</html>

You can view it online at: http://timbo87.home.comcast.net/temp/quiz/Q1.html
0
 

Author Comment

by:CMILLER
ID: 9838599
Yes, That looks good!!
0
 
LVL 15

Expert Comment

by:Timbo87
ID: 9838802
How "encrypted" do you want the answers to be? I could just change them so 0 is A, 1 is B, 2 is C, 3 is D. Or I could mix them up so A is $, B is @, C is #, and D is !. It really depends on how concerned you are about the users trying to cheat and grab the answers out of the code.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:CMILLER
ID: 9838919
I would say use the $, @, # !, good idea
0
 
LVL 15

Expert Comment

by:Timbo87
ID: 9839048
I had to make one change. ~ is A. So the pattern is:

~ = A
@ = B
# = C
! = D

Here is the final code:

<html>
<head>
<title>Results</title>
</head>
<body>
<center>
<h2>Results</h2>
</center>
<br>
<script language="JavaScript" type="text/javascript">
var anCheck = new Array();
anCheck[0] = "~"
anCheck[1] = "@"
anCheck[2] = "#"
anCheck[3] = "!"
anCheck[4] = "#"
anCheck[5] = "@"
anCheck[6] = "~"
anCheck[7] = "@"
anCheck[8] = "#"
anCheck[9] = "!"
anCheck[10] = "~#!"
wn = window.location+""
var answers = new Array()
var astring = wn.substring(wn.indexOf("html") + 5,wn.length)
var ancnt = 0
var corcnt = 0

for(i=0;i<astring.length;i++)
{
if(astring.charAt(i) == ",")
{
ancnt++
continue;
}
if(answers[ancnt] == null) answers[ancnt] = ""
answers[ancnt] += astring.charAt(i)
}
document.write("<table border=0>")
var t
var s
for(t=0;t<anCheck.length;t++)
{
rD = /~/gi;rC = /@/gi;rB = /#/gi;rA = /!/gi;
anCheck[t] = anCheck[t].replace(rD,"A");anCheck[t] = anCheck[t].replace(rC,"B");
anCheck[t] = anCheck[t].replace(rB,"C");anCheck[t] = anCheck[t].replace(rA,"D");
}
for(j=0;j<answers.length;j++)
{
if(answers[j] == anCheck[j])
{
followup = "<font color=green>Correct</font>"
corcnt++
}
else
followup = "<font color=red>Wrong " + anCheck[j] + " is the correct answer.</font> <a href='Q" + eval(j+1) + ".html'>View Question</a>"
document.write("<tr><td>" + eval(j+1) + ".</td>" + "<td>" + answers[j] + "</td>" + "<td>" + followup + "</td></tr>")
}
document.write("</table><br><br><center>" + corcnt + " out of " + answers.length + " correct. <br><h3>" + Math.round((corcnt/answers.length*100)) + "%</h3>")

</script>
<input type="button" value="Print Results" onClick="window.print()">
</center>
</body>
</html>

You can view it online at: http://timbo87.home.comcast.net/temp/quiz/Q1.html
0
 
LVL 15

Accepted Solution

by:
Timbo87 earned 2000 total points
ID: 9839057
Made one small change:

QFinal.html

<html>
<head>
<title>Results</title>
</head>
<body>
<center>
<h2>Results</h2>
Do NOT click "Next" when reviewing questions. Click Back instead to return to this page.
</center>
<br>
<script language="JavaScript" type="text/javascript">
var anCheck = new Array();
anCheck[0] = "~"
anCheck[1] = "@"
anCheck[2] = "#"
anCheck[3] = "!"
anCheck[4] = "#"
anCheck[5] = "@"
anCheck[6] = "~"
anCheck[7] = "@"
anCheck[8] = "#"
anCheck[9] = "!"
anCheck[10] = "~#!"
wn = window.location+""
var answers = new Array()
var astring = wn.substring(wn.indexOf("html") + 5,wn.length)
var ancnt = 0
var corcnt = 0

for(i=0;i<astring.length;i++)
{
if(astring.charAt(i) == ",")
{
ancnt++
continue;
}
if(answers[ancnt] == null) answers[ancnt] = ""
answers[ancnt] += astring.charAt(i)
}
document.write("<table border=0>")
var t
var s
for(t=0;t<anCheck.length;t++)
{
rD = /~/gi;rC = /@/gi;rB = /#/gi;rA = /!/gi;
anCheck[t] = anCheck[t].replace(rD,"A");anCheck[t] = anCheck[t].replace(rC,"B");
anCheck[t] = anCheck[t].replace(rB,"C");anCheck[t] = anCheck[t].replace(rA,"D");
}
for(j=0;j<answers.length;j++)
{
if(answers[j] == anCheck[j])
{
followup = "<font color=green>Correct</font>"
corcnt++
}
else
followup = "<font color=red>Wrong " + anCheck[j] + " is the correct answer.</font> <a href='Q" + eval(j+1) + ".html'>View Question</a>"
document.write("<tr><td>" + eval(j+1) + ".</td>" + "<td>" + answers[j] + "</td>" + "<td>" + followup + "</td></tr>")
}
document.write("</table><br><br><center>" + corcnt + " out of " + answers.length + " correct. <br><h3>" + Math.round((corcnt/answers.length*100)) + "%</h3>")

</script>
<input type="button" value="Print Results" onClick="window.print()">
</center>
</body>
</html>
0
 
LVL 15

Expert Comment

by:Timbo87
ID: 9839233
Found a little leftover unused code. You can delete these two lines:

var t
var s
0
 

Author Comment

by:CMILLER
ID: 9839288
Great Job, It All Works
0
 

Author Comment

by:CMILLER
ID: 9839427
Well I spoke to soon, I found a problem.

anCheck[1] = "~"
anCheck[2] = "@"
anCheck[3] = "#"
anCheck[4] = "!"
anCheck[5] = "#"
anCheck[6] = "@"
anCheck[7] = "~"
anCheck[8] = "@"
anCheck[9] = "#"
anCheck[10] = "!"
anCheck[11] = "~@"

I changed it from starting with anCheck[0] = "~",
to anCheck[1] = "~", because It is tied to the Q#,
But after I changed to [1], it will not work. I can leave it as [0]
but it throws all the Q#'s off by "1".
0
 
LVL 15

Expert Comment

by:Timbo87
ID: 9839434
Sorry, I'll fix it shortly.
0
 

Author Comment

by:CMILLER
ID: 9839435
Well, wait a min, let me change some things, I think I am wrong
0
 
LVL 15

Expert Comment

by:Timbo87
ID: 9839439
Ah, I see what you're talking about. The array is actually 1 behind the questions. Q1.html refers to anCheck[0]. It's the nature of arrays to start at 0.
0
 

Author Comment

by:CMILLER
ID: 9839446
I fixed it, I changed it back to start with [0], and reformated all the questions to point to the next one.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question