inst_grades.asp
来自「A java project in e-bussiness module.」· ASP 代码 · 共 193 行
ASP
193 行
<HTML>
<HEAD>
<% help_location = "grades" %>
<!-- Author: Brad Pierce -->
<TITLE>View Student Grades</TITLE>
<link href="../instructor/inst_basics.css" rel="stylesheet" type="text/css">
<table border='0'><tr><td><img src="../images/netest.png"></td><td width='5%'></td><td width='100%'><br><h2>View Grades</h2></td></tr>
<!-- #include file="../inst_navbar/teacher_navbar_print.inc" -->
<%
If not Session("inst_authenticated") Then
Response.Redirect("inst_login.asp")
End If
%>
</head>
<TD valign='top'><br>
<BODY>
<%
dim oConn ' Connection Object
dim oRS ' Record Set Object
dim oRS2
dim oRS3
Set oConn=Server.CreateObject("ADODB.connection")
set oRS=Server.CreateObject("ADODB.recordset")
set oRS2=Server.CreateObject("ADODB.recordset")
set oRS3=Server.CreateObject("ADODB.recordset")
oConn.Open "DSN=sd2db; UserID=Admin; pwd=netest"
' ensure that they selected an option
IF request("selected_tests") <> "" THEN
session("selected_tests") = " " & replace(request("selected_tests"), ", ", " ") & " "
' check for view entire class
IF left(request("selected_tests"), 1) = 0 THEN
sqltext = "SELECT Test_Code FROM Test " & _
"WHERE Section_Code ='" & Session("section") & "' AND Course_Code = '" & Session("course") & "' ORDER BY Test_Code"
oRS.Open sqltext, oConn
' clear tests list
session("selected_tests") = " "
DO WHILE NOT oRS.EOF
session("selected_tests") = session("selected_tests") & oRS("Test_Code") & " "
oRS.MoveNext
LOOP
oRS.Close
END IF
sqltext = "SELECT * FROM Enroll,Student WHERE Enroll.Student_Code = Student.Student_Code AND " & _
"Enroll.Course_Code='" & session("course") & "' AND Enroll.Section_Code='" & session("section") & "' " & _
"ORDER BY Student_LastName"
oRS.CursorLocation = 3 'adUseClient
oRS.Open sqltext, oConn
student_count = oRS.RecordCount
FoundSpace = instr(session("selected_tests"), " ")
selected_count = 0
DO WHILE FoundSpace < len(session("selected_tests"))
NextSpace = instr(FoundSpace + 1, session("selected_tests"), " ")
FoundSpace = NextSpace
if NextSpace then
selected_count = selected_count + 1
end if
LOOP
dim grades()
redim grades(student_count, selected_count, 1)
' check for students in class
IF student_count <> 0 THEN
oRS.MoveFirst
ELSE
response.write "<table><tr><td><img src='../images/warning.gif'></td><td><div id=warning>There are no students in this class!</div></td></tr>"
response.write "<tr><td></td><td><div id=warning><u>Hit the back button on your browser to select another class.</u></div></td></tr></table>"
ProgramEnd
response.end
END IF
' fill student into array
for x=1 to student_count
grades(x, 0, 0) = oRS("Student_Code")
oRS.MoveNext
next
oRS.Close
FoundSpace = instr(session("selected_tests"), " ")
selected_count = 1
DO WHILE FoundSpace < len(session("selected_tests"))
NextSpace = instr(FoundSpace + 1, session("selected_tests"), " ")
sqltext2 = "SELECT * FROM Test WHERE Test.Test_Code = " & mid(session("selected_tests"), FoundSpace + 1, NextSpace - FoundSpace - 1) & ""
oRS2.Open sqltext2, oConn
IF NextSpace THEN
for x=1 to student_count
grades(x, selected_count, 0) = oRS2("Test_Code")
next
end if
selected_count = selected_count + 1
FoundSpace = NextSpace
oRS2.Close
LOOP
sqltext3 = "SELECT * FROM Student,CompletedTests,Test WHERE CompletedTests.Test_Code = Test.Test_Code " & _
"AND Test.Course_Code='" & session("course") & "' AND Test.Section_Code='" & session("section") & "' " & _
"AND CompletedTests.Student_Code = Student.Student_Code ORDER BY Student_LastName"
oRS3.CursorLocation = 3
oRS3.Open sqltext3, oConn
completed_count = oRS3.RecordCount
for x=1 to completed_count
for y=1 to student_count
if grades(y, 0, 0) = oRS3("Student_Code") then
for z=1 to selected_count - 1
if grades(y, z, 0) = oRS3("Test_Code") then
grades(y, z, 1) = oRS3("Correct_Answers") & "/" & oRS3("Total_Questions")
end if
next
end if
next
oRS3.MoveNext
next
oRS3.Close
'-----------------------------------------------
' PRINT OUT TABLE OF STUDENTS, TESTS, AND GRADES
'-----------------------------------------------
response.write "<h3>Student Grades for Selected Test(s)</h3>"
response.write "<table border='1'>"
response.write "<table border=1><tr><td></td>"
' print test names
for x=1 to selected_count - 1
sqltext = "SELECT * FROM Test WHERE Test.Test_Code=" & grades(1,x,0) & ""
oRS.Open sqltext, oConn
test_name = oRS("Test_Name")
FoundChar = instr(test_name, " (created ")
test_name = left(test_name, FoundChar - 1)
response.write "<th>" & test_name & "</th>"
oRS.Close
next
response.write "</tr>"
' print students and test grades
for x=1 to student_count
printed = false
for y=1 to selected_count - 1
if printed = false then
sqltext = "SELECT * FROM Student WHERE Student_Code='" & grades(x,0,0) & "'"
oRS.Open sqltext, oConn
response.write "<tr><td>" & oRS("Student_LastName") & ", " & oRS("Student_FirstName") & "</td>"
printed = true
oRS.Close
end if
if grades(x,y,1) = "" then
response.write "<td><center>N/A</center></td>"
else
response.write "<td><center>" & grades(x,y,1) & "</center></td>"
end if
next
response.write "</tr>"
next
%>
</table><br><hr><br>
<table border='0'><tr><td><img src="../images/question.gif"></td><td><font color='#003333'><b>Finished?</b></font></td><td><a href='inst_home.asp'>Return to teacher home page.</a></td></tr>
<tr><td><img src="../images/question.gif"></td><td><font color='#003333'><b>View other Grades?</b></font></td><td><a href="inst_view_graded.asp">View Test Grades page.</a></td></tr></table>
<%
ProgramEnd
ELSE
response.write "<div id=warning><img src='../images/warning.gif'>You must select a test for which to view grades!</div><br>"
response.write "<div id=warning><u>Hit the back button on your browser to make corrections.</div>"
ProgramEnd
END IF
Sub ProgramEnd
%>
</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>
<%
End Sub
%>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?