Solved

Creating a exam page II

Posted on 2003-11-27
13
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 500 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: blockā€¦
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

726 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