1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
<html>
<head>
<title>Multiplication Practice Test Results</title>
</head>
<body bgcolor="#ffffff">
<%@ page language="javascript" %>
<h1>Multiplication Drill Score</h1>
<hr>
<div align="center">
<table border="1">
<tr><th>Problem</th><th>Correct Answer</th><th>Your Answer</th></tr>
<%
var total_score = 0;
function score (current, pos1, pos2) {
var multiplier = current.substring(pos1 + 1, pos2);
var multiplicand = current.substring(pos2 + 1, current.length());
var your_product = request.getParameterValues(current)[0];
var true_product = multiplier * multiplicand;
out.println("<tr>");
out.println("<td>" + multiplier + " x " + multiplicand + " = </td>");
out.println("<td>" + true_product + "</td>");
if (your_product == true_product) {
total_score++;
out.print("<td bgcolor=\"\#00ff00\">");
}
else {
out.print("<td bgcolor=\"\#ff0000\">");
}
out.println(your_product + "</td>");
out.println("</tr>");
}
var equations = request.getParameterNames();
while(equations.hasMoreElements()) {
var currElt = equations.nextElement();
var splitPos1 = currElt.indexOf("|");
var splitPos2 = currElt.indexOf(":");
if (splitPos1 >=0 && splitPos2 >= 0) score(currElt, splitPos1, splitPos2);
}
%>
</table>
<h2>Total Score: <%= total_score %></h2>
<h3><a href="multiplication_test.jsp">Try again?</a></h3>
</div>
</body>
</html>
|