<% if session("admid")="" or Session("pwd")="" then response.redirect "default.asp"%>
<!--#include file="conn.asp"-->
<%
tclass=request("txtclass")
tcourse=request("txtcourse")
tweek=request("txtweek")
tname=trim(request("txtname"))
'weekinfo=request("weekinfo")

function tograde(tgrade)
if  tgrade>=85 and tgrade<=100 then ttgrade="A"
		if tgrade>=70 and tgrade<85 then ttgrade="B"
		if  tgrade>=60 and tgrade<70 then ttgrade="C"
		if tgrade>=50 and tgrade<60 then ttgrade="D"
		if tgrade>=40 and tgrade<50 then ttgrade="E"
		if tgrade <40 then ttgrade="U"
tograde=ttgrade
end function 
%>

<html>

<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Test Results</title>
<link rel="stylesheet" href="style/t.css" type="text/css">
</head>
<body bgcolor="#D6D3CE">
<p align="center" class=header	><b><font size="3">Periodic Test Results</font> &nbsp;&nbsp;(<%=tclass%>)</b>  </p>
<%if (tname="" or tname=" ") then%>
<div align="center">
  <center>
<%
'response.Write tcourse
'course=split("BusinessStudies,Chemistry,Economics,English,Maths,FurtherMaths,Physics",",")

if tcourse="AllCourse" then
	course=split("BusinessStudies,Chemistry,Economics,English,Maths,FurtherMaths,Physics",",")
else
	'course=split(""&tcourse&"",",")
	course=ARRAY(tcourse)
	'course(1)=tcourse
end if
'for j=0 to ubound(course)
'	response.Write course(j)&"<br>"
'next
'response.Write tclass
'response.End()
   dim t(10)
   dim  selCourse(10)
   for j=0 to 10
       t(j)=false
   next
   coursenum=0
   weekm=0  '每周平均计数
   weektotal=0  '每周分数和
set rstmp=server.createobject("ADODB.Recordset") 
   sqltmp="select * from student where class='"&tclass&"'"
   rstmp.open sqltmp,conntmp,1,1

   do while not rstmp.eof
   '------------------------------------------------------------------
   for j=4 to 10
   		if t(j)=false then
   			if rstmp(j)=true then
			t(j)=true 
			coursenum=coursenum+1
			'redim selCourse(coursenum)
			selCourse(coursenum)=rstmp(j).name
			end if
		end if
   next
   rstmp.movenext
   loop
   
   if tcourse<>"AllCourse" then  '如果只选择一门课程-------------
    coursenum=1 
    selCourse(1)=tcourse
	set rsw=server.createobject("ADODB.Recordset") 
   sqlw="select * from student where class='"&tclass&"' and "&tcourse&"=true "
   rsw.open sqlw,conntmp,1,1
       if rsw.bof and rsw.eof then response.Write "<b><font size=3 color=red>"&tclass& "&nbsp;&nbsp;no&nbsp;&nbsp;" &tcourse&" !!!</font></b>"
   rsw.close
   set rsw=nothing
	
	end if 
  'response.Write coursenum
  'response.End()
   
'一个星期考试情况：一门课 or 多门课-------------------------
if tweek<>"allweeks" then

%>

<table width="60%" border="1" class="altbg1" align="center"  bordercolorlight="#848284" cellspacing="0" cellpadding="1" bordercolordark="#FFFFFF">
  <tr>
    <td rowspan="3" align="center">Chinese Name </td>
    <td rowspan="3" align="center">English Name </td>
    <td colspan=<%=coursenum*2%> align="center">
	<%set rsw=server.createobject("ADODB.Recordset") 
   sqlw="select * from weeks where weekname='"&tweek&"'"
   rsw.open sqlw,conntmp,1,1
   response.Write rsw("weekinfo")
   rsw.close
   set rsw=nothing
   
   %>	</td>
  </tr>
  <tr>
  <%for c=1 to coursenum%>
    <td colspan="2" align="center"><%=selCourse(c)%></td>
   <%next%> 
  </tr>
  <tr>
  <%for c=1 to coursenum%>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <%next%> 
  </tr>
  <%
  rstmp.movefirst
  do while not  rstmp.eof
  %>
  <tr>
    <td align="center"><%=rstmp("name_cn")%></td>
    <td align="center"><%=rstmp("name_en")%></td>
	
    <%for c=1 to coursenum
	set rscj=server.createobject("ADODB.Recordset") 
    sqlcj="select * from "&selCourse(c)&"  where name_CN='"&rstmp("name_cn")&"'  and name_eN='"&rstmp("name_en")&"' "
	rscj.open sqlcj,conntmp,1,1
	'response.Write sqlcj
	'response.end
	if rscj.bof and rscj.eof  then
	%>
	<td align="center"><%="ERROR"%></td>
    <td align="center"><%="ERROR"%></td>
	<%else
		if rscj(tweek)="" or rscj(tweek)=" " or IsNull(rscj(tweek)) then
		response.Write "<td align=center>&nbsp;</td>"
		response.Write "<td align=center>&nbsp;</td>"
		else
		
		set rst=server.createobject("ADODB.Recordset") 
        sqlt="select * from "&selCourse(c)&"  where class='"&tclass&"total' "
        rst.open sqlt,conntmp,1,1	
				totalscore=rst(tweek)
				'response.Write sqlt&rst(tweek)
		rst.close
		set rst=nothing 
		
		'response.Write totalscore&"+++++++++++++++++++"&tweek
	'response.end
		tscore=round(csng(rscj(tweek))*(100/totalscore),1)
	%>
	
	<td align="center"><%=tscore%></td>
    <td align="center"><%=tograde(round(Csng(tscore),1))%></td>
	
	<%
		end if
	end if
	rscj.close
	set rscj=nothing
	%>
	    
    <%next%> 
  </tr>
  
 <%
 rstmp.movenext
 loop
 %> 
 <tr>
    <td colspan="2" align="center"><b>Average Score</b></td>
	
	<%for c=1 to coursenum
	'获取基本总分
	set rst=server.createobject("ADODB.Recordset") 
        sqlt="select * from "&selCourse(c)&"  where class='"&tclass&"total' "
        rst.open sqlt,conntmp,1,1	
				totalscore=rst(tweek)
		rst.close
		set rst=nothing 
	'获取平均分	
	weektotal=0
	weekm=0
	
	
	set rstotal=server.createobject("ADODB.Recordset") 
    sqltotal="select * from "&selCourse(c)&"  where class='"&tclass&"'"
	rstotal.open sqltotal,conntmp,1,1
	do while not rstotal.eof
		if rstotal(tweek)="" or rstotal(tweek)=" " or IsNull(rstotal(tweek)) then
		else
			weekm=weekm+1
			weektotal=weektotal+round(csng(rstotal(tweek)*(100/totalscore)),1)
			'on error resume next 
			 'response.Write rstotal(tweek)&"+++"
		end if
	rstotal.movenext
	loop
	rstotal.close
	set rstotal=nothing
	
	%>
    <td align="center"><%
	if weektotal<>0 then response.Write round(csng(weektotal/weekm),1) else response.Write "&nbsp;"
	%></td>
    <td align="center">&nbsp;</td>
    <%next%>
  </tr>
</table>


<%



rstmp.close
   set rstmp=nothing
   '----------------------------rstmp------------------

else


   

for i=0 to ubound(course)  
set rs=server.createobject("ADODB.Recordset") 
   sql="select * from "&course(i)&",student  where student.class='"&tclass&"'  and "&course(i)&".name_CN=student.name_CN  and "&course(i)&".name_eN=student.name_eN and  student."&course(i)&"=true"
   
   'if (tname<>"" and tname<>" ") then sql=sql & " and (student.name_cn like '%"&tname&"%' or student.name_en like '%"&tname&"%')" else sql=sql
   
'response.Write sql
'response.End()

     rs.open sql,conntmp,1,1
	 if rs.eof or rs.bof then 'xx班级没有XX课程
	   else
	  
	  %>



	  
	  
	  
  <table border="1" width="100%" bordercolorlight="#848284" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF">
 	<tr>
      <td colspan="2" height="20">
	 <%response.Write "<font size=3><b>"&course(i)&"</b></font>"%>
	  </td>
    </tr>
    <tr>
      <td colspan="2" align="center" class="altbg1">

	  
<table border="1" class="altbg1" align="center"  bordercolorlight="#848284" cellspacing="0" cellpadding="1" bordercolordark="#FFFFFF">
  <tr>
    <td rowspan="5" align="center">Chinese Name</td>
    <td rowspan="5" align="center">English Name</td>
    <td colspan="36" align="center">2007-2008 Academic Record</td>
    </tr>
  <tr>
    <td colspan="36" align="center">1st Semester</td>
    </tr>
  <tr>
    <td colspan="10" align="center">Weekly Test  Results ( Week1-9)</td>
    <td colspan="2" align="center">Mid Term Periodic Test  Average</td>
    <td colspan="2" align="center">Mid Term Homework </td>
    <td colspan="2" align="center">Mid Term Exam</td>
    <td colspan="2" align="center">Mid Term Final </td>
    <td colspan="10" align="center">Weekly Test  Results ( Week 11-19 )</td>
    <td colspan="2" align="center">End Term Periodic Test  Average</td>
    <td colspan="2" align="center">End Term Homework</td>
    <td colspan="2" align="center">End Term Exam</td>
    <td colspan="2" align="center">End Term Final </td>
    </tr>
  <tr>
    <td colspan="2" align="center">Week 1-2(3-16 Sept.)</td>
    <td colspan="2" align="center">Week 3-4(17-30 Sept.)</td>
    <td colspan="2" align="center">Week 5-6(1-14 Oct.)</td>
    <td colspan="2" align="center">Week 7-8(15-28 Oct.)</td>
    <td colspan="2" align="center">Week 9(29 Oct.-4 Nov.)</td>
    <td colspan="2" align="center">Week 1-9(3 Sept.-4 Nov.)</td>
    <td colspan="2" align="center">Week 1-9(3 Sept.-4 Nov.)</td>
    <td colspan="2" align="center">Week 10(5-11 Nov.)</td>
    <td colspan="2" align="center">Week 1-10(3 Sept.-11 Nov.)</td>
    <td colspan="2" align="center">Week 11-12(12-25 Nov.)</td>
    <td colspan="2" align="center">Week 13-14(26 Nov.-9 Dec.)</td>
    <td colspan="2" align="center">Week 15-16(10-23 Dec.)</td>
    <td colspan="2" align="center">Week 17-18(24 Dec.-6 Jan.)</td>
    <td colspan="2" align="center">Week 19(7-20 Jan.)</td>
    <td colspan="2" align="center">Week 1-19 (3 Sept. -20 Jan.)</td>
    <td colspan="2" align="center">Week 1-19 (3 Sept. -20 Jan.)</td>
    <td colspan="2" align="center">Week 20(21-26 Jan.)</td>
    <td colspan="2" align="center">Week 1-20(3 Sept.-26 Jan.)</td>
  </tr>
  <tr>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
  </tr>


<%
		do while not rs.eof
		tgrade=""
		ttgrade=""
		qzavg=""
		qmavg=""
		tfinal=""
		qmFinal=""
		totalscore=100
		zycj=0
		kscj=0
		qmzycj=0
		qmkscj=0
	 '-------------------读取总分---------------------
	 set rst=server.createobject("ADODB.Recordset") 
     sqlt="select * from "&course(i)&"  where class='"&tclass&"total' "
     rst.open sqlt,conntmp,1,1	 
	 
	 '--------------------------------------------
		
		response.Write "<tr>"
		response.Write "<td align=center>"&rs("name_cn")&"</td>"
		response.Write "<td align=center>"&rs("name_en")&"</td>"
		
		tsum=0   '其中成绩
		qmsum=0 '期末成绩
		m=0 '已经有的考试次数
		
		
			for j=4 to 8
			
			if rs(j)="" or rs(j)=" " or IsNull(rs(j)) then
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"
  
	  else
	  m=m+1

	 totalscore=rst(j)
		
	  tsum=tsum+round(csng(rs(j))*(100/totalscore),1)
	  
	  if m=0 then tavg="" else qzavg=round(tsum/m,1)   '其中平均周成绩
	  
	  tgrade=round(csng(rs(j))*(100/totalscore),1)
	  response.Write "<td align=center>"&tgrade&"</td>"
	  
	  	  
	  	if Isnumeric(tgrade)=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
	  	else
	
		response.Write "<td align=center>"&tograde(round(Csng(tgrade),1))&"</td>"
		end if	
		
	  end if 

			next
	    
		if qzavg="" or qzavg=" " or IsNull(qzavg) then
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"
		else		
		
		response.Write "<td align=center>"&qzavg&"</td>"
		
		if Isnumeric(qzavg)=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
	  	else
		response.Write "<td align=center>"&tograde(round(Csng(qzavg),1))&"</td>"
		end if	
	    end if
		
		'------期中作业g
		
		if rs("g")="" or rs("g")=" " or IsNull(rs("g")) then
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"
		else	
		zycj=trim(rs("g"))	
	  	if Isnumeric(zycj)=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
		response.Write "<td align=center>&nbsp;</td>"
	  	else
		zycj=round(csng(zycj)*(100/rst("g")),1)
		response.Write "<td align=center>"&zycj&"</td>"
		response.Write "<td align=center>"&tograde(zycj)&"</td>"
		end if		
		end if
		
		'------------其中成绩h
		if rs("h")="" or rs("h")=" " or IsNull(rs("h")) then
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"
		else		
	    kscj=trim(rs("h"))	
		if Isnumeric(rs("h"))=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
		response.Write "<td align=center>&nbsp;</td>"
	  	else
		kscj=round(csng(kscj)*(100/rst("h")),1)
		response.Write "<td align=center>"&kscj&"</td>"
		response.Write "<td align=center>"&tograde(kscj)&"</td>"
		
		end if			
		end if
		
				'------------其中zong成绩
		if  qzavg="" or IsNull(qzavg) or zycj=0 or kscj=0   then
			tFinal=""
					response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"	
			else
			tFinal= round(kscj*0.5+qzavg*0.3+zycj*0.2,1)
		

		
	    response.Write "<td align=center>"&tFinal&"</td>"
		if Isnumeric(tFinal)=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
	  	else
		response.Write "<td align=center>"&tograde(tFinal)&"</td>"
		end if		
		end if

	
%>	

 </td>
	  
	  <%'qmsum=tsum
	  qmsum=0
	  m=0
	  for j=13 to 17
	  if rs(j)="" or rs(j)=" " or IsNull(rs(j)) then
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"
  
	  else
	  	m=m+1
		
				'----------分数转换----------------
		 totalscore=rst(j)
	
				'----------------------------------
				qmsum=qmsum+round(csng(rs(j))*(100/totalscore),1)
				'response.write CSng(rs2(j))&","	
	  tgrade=round(csng(rs(j))*(100/totalscore),1)
	  response.Write "<td align=center>"&tgrade&"</td>"

	  	if Isnumeric(tgrade)=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
	  	else
		response.Write "<td align=center>"&tograde(round(Csng(tgrade),1))&"</td>"
		end if		
	
			
		end if 
			next
	if m=0 then qmavg="" else qmavg=round(qmsum/m,1)   '其末平均周成绩
	  
	  '-----------期末周成绩－－－－－－－－－－－－－－－－－－－－
	  
	  if qmavg="" or qmavg=" " or IsNull(qmavg) then
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"
		else		
		
		response.Write "<td align=center>"&qmavg&"</td>"
		
		if Isnumeric(qmavg)=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
	  	else
		response.Write "<td align=center>"&tograde(round(Csng(qmavg),1))&"</td>"
		end if	
	    end if
		
		'------期末作业g
		if rs("p")="" or rs("p")=" " or IsNull(rs("p")) then
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"
		else		
	    qmzycj=trim(rs("p"))	
		if Isnumeric(rs("p"))=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
		response.Write "<td align=center>&nbsp;</td>"
	  	else
		qmkscj=round(csng(qmzycj)*(100/rst("p")),1)
		response.Write "<td align=center>"&qmzycj&"</td>"
		response.Write "<td align=center>"&tograde(qmzycj)&"</td>"
		
		end if			
		end if
		
		
		
		
		'------------其mo成绩h
		if rs("q")="" or rs("q")=" " or IsNull(rs("q")) then
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"
		else		
	    qmkscj=trim(rs("q"))	
		if Isnumeric(rs("q"))=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
		response.Write "<td align=center>&nbsp;</td>"
	  	else
		qmkscj=round(csng(qmkscj)*(100/rst("q")),1)
		response.Write "<td align=center>"&qmkscj&"</td>"
		response.Write "<td align=center>"&tograde(qmkscj)&"</td>"
		
		end if			
		end if
		
				'------------其中zong成绩
		if  qmavg="" or IsNull(qmavg) or qmkscj=0 or qmzycj=0   then
			qmFinal=qmavg
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"	
			else
			qmFinal= round(qmkscj*0.5+qmavg*0.3+qmzycj*0.2,1)
		

		
	    response.Write "<td align=center>"&qmFinal&"</td>"
		if Isnumeric(qmFinal)=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
	  	else
		response.Write "<td align=center>"&tograde(qmFinal)&"</td>"
		end if		
		end if
	  
	  rst.close
	  set rst=nothing
	  
	  response.Write "</tr> "
		rs.movenext
		loop
	response.Write "</table>"	
	  
	  
	  rs.close
	 set rs=nothing
	
	 %>
    
  <tr>
    <td colspan="2" align="center" height="25">　</td>
  </tr>
  </table>
<%

end if 

 next
 end  if '-----------------tweek=allweeks
%>
  </center>
</div>


<%else%>

 <%
	 set rs3=server.createobject("ADODB.Recordset") 
     sql3="select * from student where student.class='"&tclass&"' and (student.name_cn like '%"&tname&"%' or student.name_en like '%"&tname&"%')"
     rs3.open sql3,conntmp,1,1 
	 if rs3.eof or rs3.bof then 
	 response.Write "<b>No this student,please check the class and name again.</b>"
	 else
	 do while not rs3.eof
	  %>
	 
<table border="1" width="100%" bordercolorlight="#848284" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF">
 	<tr>
      <td colspan="2" height="20">
	  
	
<%response.Write "<font size=3>Class:<b>"&tclass&"</b> &nbsp;&nbsp;Chinese Name:<b>"&rs3("name_cn")&"</b> &nbsp;&nbsp;English Name:<b>"&rs3("name_en")&"</b></font>"%>
	
	  </td>
    </tr>
    <tr>
      <td colspan="2" align="center" class="altbg1" valign="top">
  
      
	  <table border="1" class="altbg1" align="center"  bordercolorlight="#848284" cellspacing="0" cellpadding="1" bordercolordark="#FFFFFF">
  <tr>
    <td colspan="2" rowspan="5" align="middle">Course</td>
    <td colspan="36" align="center">2007-2008 Academic Record</td>
    </tr>
  <tr>
    <td colspan="36" align="center">1st Semester</td>
    </tr>
  <tr>
    <td colspan="10" align="center">Weekly Test  Results ( Week1-9)</td>
    <td colspan="2" align="center">Mid Term Periodic Test  Average</td>
    <td colspan="2" align="center">Mid Term Homework </td>
    <td colspan="2" align="center">Mid Term Exam</td>
    <td colspan="2" align="center">Mid Term Final </td>
    <td colspan="10" align="center">Weekly Test  Results ( Week 11-19 )</td>
    <td colspan="2" align="center">End Term Periodic Test  Average</td>
    <td colspan="2" align="center">End Term Homework</td>
    <td colspan="2" align="center">End Term Exam</td>
    <td colspan="2" align="center">End Term Final </td>
    </tr>
  <tr>
    <td colspan="2" align="center">Week 1-2(3-16 Sept.)</td>
    <td colspan="2" align="center">Week 3-4(17-30 Sept.)</td>
    <td colspan="2" align="center">Week 5-6(1-14 Oct.)</td>
    <td colspan="2" align="center">Week 7-8(15-28 Oct.)</td>
    <td colspan="2" align="center">Week 9(29 Oct.-4 Nov.)</td>
    <td colspan="2" align="center">Week 1-9(3 Sept.-4 Nov.)</td>
    <td colspan="2" align="center">Week 1-9(3 Sept.-4 Nov.)</td>
    <td colspan="2" align="center">Week 10(5-11 Nov.)</td>
    <td colspan="2" align="center">Week 1-10(3 Sept.-11 Nov.)</td>
    <td colspan="2" align="center">Week 11-12(12-25 Nov.)</td>
    <td colspan="2" align="center">Week 13-14(26 Nov.-9 Dec.)</td>
    <td colspan="2" align="center">Week 15-16(10-23 Dec.)</td>
    <td colspan="2" align="center">Week 17-18(24 Dec.-6 Jan.)</td>
    <td colspan="2" align="center">Week 19(7-20 Jan.)</td>
    <td colspan="2" align="center">Week 1-19 (3 Sept. -20 Jan.)</td>
    <td colspan="2" align="center">Week 1-19 (3 Sept. -20 Jan.)</td>
    <td colspan="2" align="center">Week 20(21-26 Jan.)</td>
    <td colspan="2" align="center">Week 1-20(3 Sept.-26 Jan.)</td>
  </tr>
  <tr>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
    <td align="center">Score</td>
    <td align="center">Grade</td>
  </tr>

<%
course=split("BusinessStudies,Chemistry,Economics,English,Maths,FurtherMaths,Physics",",")
for i=0 to ubound(course)
set rs=server.createobject("ADODB.Recordset") 
   sql="select * from "&course(i)&",student  where student.class='"&tclass&"'  and "&course(i)&".name_CN=student.name_CN  and "&course(i)&".name_eN=student.name_eN and student."&course(i)&"=true and student.id="&rs3("id")&" "
     rs.open sql,conntmp,1,1
	 
	 
	 
	 do while not rs.eof
	
	tgrade=""
		ttgrade=""
		qzavg=""
		qmavg=""
		tfinal=""
		qmFinal=""
		totalscore=100
		zycj=0
		kscj=0
		qmzycj=0
		qmkscj=0
	 '-------------------读取总分---------------------
	 set rst=server.createobject("ADODB.Recordset") 
     sqlt="select * from "&course(i)&"  where class='"&tclass&"total' "
     rst.open sqlt,conntmp,1,1	 
	 
	 '--------------------------------------------
		
		response.Write "<tr>"
		 response.Write "<td colspan=2 align=center>"&course(i)&"</td>"
		
		tsum=0   '其中成绩
		qmsum=0 '期末成绩
		m=0 '已经有的考试次数
		
		
			for j=4 to 8
			
			if rs(j)="" or rs(j)=" " or IsNull(rs(j)) then
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"
  
	  else
	  m=m+1

	 totalscore=rst(j)
		
	  tsum=tsum+round(csng(rs(j))*(100/totalscore),1)
	  
	  if m=0 then tavg="" else qzavg=round(tsum/m,1)   '其中平均周成绩
	  
	  tgrade=round(csng(rs(j))*(100/totalscore),1)
	  response.Write "<td align=center>"&tgrade&"</td>"
	  
	  	  
	  	if Isnumeric(tgrade)=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
	  	else
	
		response.Write "<td align=center>"&tograde(round(Csng(tgrade),1))&"</td>"
		end if	
		
	  end if 

			next
	    
		if qzavg="" or qzavg=" " or IsNull(qzavg) then
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"
		else		
		
		response.Write "<td align=center>"&qzavg&"</td>"
		
		if Isnumeric(qzavg)=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
	  	else
		response.Write "<td align=center>"&tograde(round(Csng(qzavg),1))&"</td>"
		end if	
	    end if
		
		'------期中作业g
		
		if rs("g")="" or rs("g")=" " or IsNull(rs("g")) then
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"
		else	
		zycj=trim(rs("g"))	
	  	if Isnumeric(zycj)=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
		response.Write "<td align=center>&nbsp;</td>"
	  	else
		zycj=round(csng(zycj)*(100/rst("g")),1)
		response.Write "<td align=center>"&zycj&"</td>"
		response.Write "<td align=center>"&tograde(zycj)&"</td>"
		end if		
		end if
		
		'------------其中成绩h
		if rs("h")="" or rs("h")=" " or IsNull(rs("h")) then
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"
		else		
	    kscj=trim(rs("h"))	
		if Isnumeric(rs("h"))=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
		response.Write "<td align=center>&nbsp;</td>"
	  	else
		kscj=round(csng(kscj)*(100/rst("h")),1)
		response.Write "<td align=center>"&kscj&"</td>"
		response.Write "<td align=center>"&tograde(kscj)&"</td>"
		
		end if			
		end if
		
				'------------其中zong成绩
		if  qzavg="" or IsNull(qzavg) or zycj=0 or kscj=0   then
			tFinal=""
					response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"	
			else
			tFinal= round(kscj*0.5+qzavg*0.3+zycj*0.2,1)
		

		
	    response.Write "<td align=center>"&tFinal&"</td>"
		if Isnumeric(tFinal)=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
	  	else
		response.Write "<td align=center>"&tograde(tFinal)&"</td>"
		end if		
		end if

	
%>	

 </td>
	  
	  <%'qmsum=tsum
	  qmsum=0
	  m=0
	  for j=13 to 17
	  if rs(j)="" or rs(j)=" " or IsNull(rs(j)) then
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"
  
	  else
	  	m=m+1
		
				'----------分数转换----------------
		 totalscore=rst(j)
	
				'----------------------------------
				qmsum=qmsum+round(csng(rs(j))*(100/totalscore),1)
				'response.write CSng(rs2(j))&","	
	  tgrade=round(csng(rs(j))*(100/totalscore),1)
	  response.Write "<td align=center>"&tgrade&"</td>"

	  	if Isnumeric(tgrade)=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
	  	else
		response.Write "<td align=center>"&tograde(round(Csng(tgrade),1))&"</td>"
		end if		
	
			
		end if 
			next
	if m=0 then qmavg="" else qmavg=round(qmsum/m,1)   '其末平均周成绩
	  
	  '-----------期末周成绩－－－－－－－－－－－－－－－－－－－－
	  
	  if qmavg="" or qmavg=" " or IsNull(qmavg) then
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"
		else		
		
		response.Write "<td align=center>"&qmavg&"</td>"
		
		if Isnumeric(qmavg)=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
	  	else
		response.Write "<td align=center>"&tograde(round(Csng(qmavg),1))&"</td>"
		end if	
	    end if
		
		'------期末作业g
		if rs("p")="" or rs("p")=" " or IsNull(rs("p")) then
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"
		else		
	    qmzycj=trim(rs("p"))	
		if Isnumeric(rs("p"))=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
		response.Write "<td align=center>&nbsp;</td>"
	  	else
		qmkscj=round(csng(qmzycj)*(100/rst("p")),1)
		response.Write "<td align=center>"&qmzycj&"</td>"
		response.Write "<td align=center>"&tograde(qmzycj)&"</td>"
		
		end if			
		end if
		
		
		
		
		'------------其mo成绩h
		if rs("q")="" or rs("q")=" " or IsNull(rs("q")) then
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"
		else		
	    qmkscj=trim(rs("q"))	
		if Isnumeric(rs("q"))=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
		response.Write "<td align=center>&nbsp;</td>"
	  	else
		qmkscj=round(csng(qmkscj)*(100/rst("q")),1)
		response.Write "<td align=center>"&qmkscj&"</td>"
		response.Write "<td align=center>"&tograde(qmkscj)&"</td>"
		
		end if			
		end if
		
				'------------其中zong成绩
		if  qmavg="" or IsNull(qmavg) or qmkscj=0 or qmzycj=0   then
			qmFinal=qmavg
			response.Write "<td align=center>&nbsp;</td>"
			response.Write "<td align=center>&nbsp;</td>"	
			else
			qmFinal= round(qmkscj*0.5+qmavg*0.3+qmzycj*0.2,1)
		

		
	    response.Write "<td align=center>"&qmFinal&"</td>"
		if Isnumeric(qmFinal)=false then 
	  	response.Write "<td align=center>&nbsp;</td>"
	  	else
		response.Write "<td align=center>"&tograde(qmFinal)&"</td>"
		end if		
		end if
	  
	  rst.close
	  set rst=nothing
	  
	  response.Write "</tr> "
		rs.movenext
		loop
	 next
response.Write "</table>"	
	

	
%>	


	  </td>
      </tr>
	  <% 
	  
	  rs.close
	 set rs=nothing
	
	 %>
    
  <tr>
    <td colspan="2" align="center" height="25">　</td>
  </tr>
  </table>


<%


rs3.movenext
loop
end if 

rs3.close
set rs3=nothing
end if%>
<p>　</p>
</body>

</html>
