📄 student_submit_test.asp
字号:
<html>
<head>
<% help_location = "submit_test" %>
<!-- Author: Brad Pierce -->
<title>Student Take Test</title>
<link href="../student/student_basics.css" rel="stylesheet" type="text/css">
<table border='0'><tr><td><img src="../images/student_netest.gif"></td><td width='5%'></td><td width='100%'><br><h2>Student Take Test</h2></td></tr>
<!-- #include file="../student_navbar/student_navbar_print.inc" -->
<%
If not Session("student_authenticated") Then
Response.Redirect("student_login.asp")
End If
IF Session("test_completed") = TRUE THEN
response.write "<td valign='top'><br>"
Response.Write "<p><div id=warning><img src='../images/warning.gif'> You cannot resubmit the test.</div><br>"
Response.Write "<a href='student_home.asp'>Click here to return to the home page.</a></p>"
%>
</table><br><br><table width='86%' align='right' border='0'><tr><td>
<hr size='2' color='#000000'>
<font size='1'>Powered by Netest</font>
</td></tr></table>
<%
Response.End
END IF
%>
</head>
<TD valign='top'><br>
<body>
<%
'-------------------------------------------------
' ERROR CHECK THE INFORMATION THAT STUDENT ENTERED
'-------------------------------------------------
question_counter = 1
return_previous = FALSE
for question_counter=1 to session("mc_count")
if request("mc_answer_" & question_counter) = "null" then
error_message = "Question #" & question_counter & " ANSWER must be selected"
call DisplayError()
end if
next
for question_counter=question_counter to (question_counter + session("tf_count") - 1)
if request("tf_answer_" & question_counter) = "" then
error_message = "Question #" & question_counter & " ANSWER must be selected"
call DisplayError()
end if
next
for question_counter=question_counter to (question_counter + session("mtf_count") - 1)
if request("mtf_answer_" & question_counter) = "" then
error_message = "Question #" & question_counter & " ANSWER must be selected"
call DisplayError()
end if
if request("mtf_answer_" & question_counter) = "FALSE" then
if trim(request("mtf_correction_" & question_counter)) = "" then
error_message = "Question #" & question_counter & " CORRECTION cannot be blank if the ANSWER is false"
call DisplayError()
end if
end if
if request("mtf_answer_" & question_counter) = "TRUE" then
if trim(request("mtf_correction_" & question_counter)) <> "" then
error_message = "Question #" & question_counter & " CORRECTION must be blank if the ANSWER is true"
call DisplayError()
end if
end if
next
for question_counter=question_counter to (question_counter + session("match_count") - 1)
if trim(request("match_answer_" & question_counter)) = "" then
error_message = "Question #" & question_counter & " ANSWER cannot be blank"
call DisplayError()
end if
next
for question_counter=question_counter to (question_counter + session("comp_count") - 1)
if trim(request("comp_answer_" & question_counter)) = "" then
error_message = "Question #" & question_counter & " ANSWER cannot be blank"
call DisplayError()
end if
next
for question_counter=question_counter to (question_counter + session("sa_count") - 1)
if trim(request("sa_answer_" & question_counter)) = "" then
error_message = "Question #" & question_counter & " ANSWER cannot be blank"
call DisplayError()
end if
next
' don't process essay questions...error check for answer, but don't count as part of test
for question_counter=question_counter to (question_counter + session("essay_count") - 1)
if trim(request("essay_answer_" & question_counter)) = "" then
error_message = "Question #" & question_counter & " ANSWER cannot be blank"
call DisplayError()
end if
next
sub DisplayError()
Response.Write "<div id=warning><img src='../images/warning.gif'> " & error_message & "</div>"
return_previous = TRUE
end sub
'----------------------------------------------------------------
' COUNT CORRECT ANSWERS, SUBMIT SCORE AND INCORRECT ANSWERS TO DB
'----------------------------------------------------------------
IF return_previous = FALSE THEN
dim oConn ' Connection Object
dim oRS ' Record Set Object
Set oConn=Server.CreateObject("ADODB.connection")
set oRS=Server.CreateObject("ADODB.recordset")
oConn.Open "DSN=sd2db; UserID=Admin; pwd=netest"
question_counter = 1
correct_answer_count = 0
incorrect_answers = ""
for question_counter=1 to session("mc_count")
sqltext = "SELECT * FROM Question WHERE Test_Code=" & session("selected_test") & " AND Question_Number=" & question_counter & ""
oRS.Open sqltext, oConn
if request("mc_answer_" & question_counter) = oRS("Question_Answer") then
correct_answer_count = correct_answer_count + 1
else
incorrect_answers = incorrect_answers & question_counter & "|" & request("mc_answer_" & question_counter) & "|"
end if
oRS.Close
next
for question_counter=question_counter to (question_counter + session("tf_count") - 1)
sqltext = "SELECT * FROM Question WHERE Test_Code=" & session("selected_test") & " AND Question_Number=" & question_counter & ""
oRS.Open sqltext, oConn
if request("tf_answer_" & question_counter) = oRS("Question_Answer") then
correct_answer_count = correct_answer_count + 1
else
incorrect_answers = incorrect_answers & question_counter & "|" & request("tf_answer_" & question_counter) & "|"
end if
oRS.Close
next
for question_counter=question_counter to (question_counter + session("mtf_count") - 1)
sqltext = "SELECT * FROM Question WHERE Test_Code=" & session("selected_test") & " AND Question_Number=" & question_counter & ""
oRS.Open sqltext, oConn
answer = oRS("Question_Answer")
if answer = "TRUE" then
if request("mtf_answer_" & question_counter) = "TRUE" then
correct_answer_count = correct_answer_count + 1
else
incorrect_answers = incorrect_answers & question_counter & "|" & request("mtf_answer_" & question_counter) & ", " & request("mtf_correction_" & question_counter) & "|"
end if
else
if request("mtf_answer_" & question_counter) = "FALSE" then
correct_answer_count = correct_answer_count + 0.5
FoundPos = instr(answer, "|")
if lcase(request("mtf_correction_" & question_counter)) = lcase(Right(answer, Len(answer) - FoundPos)) then
correct_answer_count = correct_answer_count + 0.5
else
incorrect_answers = incorrect_answers & question_counter & "|" & request("mtf_answer_" & question_counter) & ", " & request("mtf_correction_" & question_counter) & "|"
end if
else
incorrect_answers = incorrect_answers & question_counter & "|" & request("mtf_answer_" & question_counter) & "|"
end if
end if
oRS.Close
next
for question_counter=question_counter to (question_counter + session("match_count") - 1)
sqltext = "SELECT * FROM Question WHERE Test_Code=" & session("selected_test") & " AND Question_Number=" & question_counter & ""
oRS.Open sqltext, oConn
if lcase(request("match_answer_" & question_counter)) = lcase(oRS("Question_Answer")) then
correct_answer_count = correct_answer_count + 1
else
incorrect_answers = incorrect_answers & question_counter & "|" & request("match_answer_" & question_counter) & "|"
end if
oRS.Close
next
for question_counter=question_counter to (question_counter + session("comp_count") - 1)
sqltext = "SELECT * FROM Question WHERE Test_Code=" & session("selected_test") & " AND Question_Number=" & question_counter & ""
oRS.Open sqltext, oConn
if lcase(request("comp_answer_" & question_counter)) = lcase(oRS("Question_Answer")) then
correct_answer_count = correct_answer_count + 1
else
incorrect_answers = incorrect_answers & question_counter & "|" & request("comp_answer_" & question_counter) & "|"
end if
oRS.Close
next
for question_counter=question_counter to (question_counter + session("sa_count") - 1)
sqltext = "SELECT * FROM Question WHERE Test_Code=" & session("selected_test") & " AND Question_Number=" & question_counter & ""
oRS.Open sqltext, oConn
if lcase(request("sa_answer_" & question_counter)) = lcase(oRS("Question_Answer")) then
correct_answer_count = correct_answer_count + 1
else
incorrect_answers = incorrect_answers & question_counter & "|" & request("sa_answer_" & question_counter) & "|"
end if
oRS.Close
next
if incorrect_answers = "" then
incorrect_answers = 0
else
incorrect_answers = left(incorrect_answers, len(incorrect_answers) - 1)
end if
sqltext = "SELECT * FROM CompletedTests"
oRS.Open sqltext, oConn, 2, 2
oRS.AddNew
oRS.Fields("Student_Code") = session("username")
oRS.Fields("Test_Code") = session("selected_test")
oRS.Fields("Correct_Answers") = correct_answer_count
oRS.Fields("Total_Questions") = question_counter - 1
oRS.Fields("Incorrect_Answers") = incorrect_answers
oRS.Update
oRS.Close
session("test_completed") = TRUE
response.write "<h3>Test Grade: " & correct_answer_count & "/" & question_counter - 1 & "</h3>"
response.write "<br><b>If you have any questions concerning your test, please contact your instructor.</b>"
ELSE
Response.Write "<br><div id=warning><u>Your test contained errors. "
Response.Write "Hit the back button on your browser to make corrections.</u></div>"
END IF
%>
</td></tr>
<tr><td></td><td colspan='2'><br><br><hr size='2' color='#000000'>
<font size='1'>Powered by Netest</font>
</td></tr></table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -