
<!--#include file="conn.asp"-->

<html>
<%
response.buffer = true
'告诉浏览器用word来显示文档内容

Response.ContentType = "application/msword" 

'文档设定

response.AddHeader "content-disposition", "inline; filename=report.doc"

tclass=request("txtclass")
tname=trim(request("txtname"))
Teacher=request("Teacher")
tSemester=request("Semester")
'response.write tSemester
'response.end
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格式，用于从数据库中取出值填入输入框时
' 注意：="?"这边一定要用双引号
' ============================================
function inHTML(str)
 Dim sTemp
 sTemp = str
 inHTML = ""
 If IsNull(sTemp) = True Then
  Exit function
 End If
 sTemp = Replace(sTemp, "&lt;","<")
 sTemp = Replace(sTemp,"&gt;",">" )
 sTemp = Replace(sTemp,"&quot;",Chr(34))
 sTemp = Replace(sTemp,"<BR>",CHR(10))  
 sTemp = Replace(sTemp, " ",CHR(13))
 sTemp = Replace(sTemp,"&nbsp;",CHR(32))
 sTemp = Replace(sTemp,"&nbsp;",CHR(9))
 sTemp = Replace(sTemp,"&#39;",CHR(39))
 sTemp = Replace(sTemp,"</P><P>", CHR(10)&CHR(10))
 
 inHTML = sTemp
End function
 
'===============================================


 set rs1=server.createobject("ADODB.Recordset") 
     sql1="select * from dateset"
     rs1.open sql1,conntmp,1,1
%>
<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">
<link rel="stylesheet" href="style/t2.css" type="text/css">

<title>CIC School Report</title>

</head>
<body bgcolor="#ffffff">


<%
set rs=server.createobject("ADODB.Recordset") 
     sql="select * from student  where class='"&tclass&"'  and   (name_CN='"&tname&"' or  name_eN='"&tname&"') "
     rs.open sql,conntmp,1,1
%>



<table width="600" border="0">
  <tr>
    <td>
	<p align="center" class=header><b><font size="3">CIC School Report<br>                                                                       
上海师范大学剑桥国际中心学生学期报告 </font></b></p>
	</td>
  </tr>
  <tr>
    <td align="right"> Date of Issue：<%=rs1("issue")%>&nbsp;</td>
  </tr>
  <tr>
    <td>● Semester <%if tSemester="Semester1" then response.write "1" else  response.write "2"%> of&nbsp;<%=rs1("academic")%>&nbsp;Academic Year<br> </td>
  <%
	rs1.close
	set rs1=nothing
	%>
  </tr>
  <tr>
    <td>
	● Personal Information&nbsp;&nbsp;                                                                                   
		个人信息：<table border="1" id="table2" width=590 bordercolorlight="#000000" cellspacing="0" cellpadding="0" bordercolordark="#000000" style="border-collapse: collapse" bordercolor="#000000">
		<tr>
			<td>Class 班级：&nbsp; <%=RS("class")%></td>                                                                                  
			<td>Student Name 学生姓名：&nbsp; <%=rs("name_CN")%>(<%=rs("name_eN")%>)</td>                                                                                  
		</tr>
		</table>
	
	</td>
  </tr>
  <tr>
    <td>● Attendance Record&nbsp;                                                                                   
		出勤记录<table border="1" width="590" id="table1" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolorlight="#000000" bordercolordark="#000000">
		<tr>
			<td align="center">Late 迟到</td>                                                                                  
			<td align="center">Absences 旷课</td>                                                                                  
			<td align="center">Sick Leaves 病假</td>                                                                                  
		</tr>
		<tr>
			<td align="center">&nbsp;<%=rs("late")%></td>
			<td align="center">&nbsp;<%=rs("absences")%></td>
			<td align="center">&nbsp;<%=rs("sick")%></td>
		</tr>
		</table><br>
	</td>
  </tr>
  
  <tr>
      <td height="26"  class="altbg1">
	  
	   ●Merit Awards 本学期所获奖项<br>	
	    <table border="1" width="590" id="table1" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolorlight="#000000" bordercolordark="#000000">
          <tr>
            <td height="80" align="left" valign="top"><%if tSemester="Semester1" then response.write inHTML(rs("merit1")) else response.write inHTML(rs("merit2"))%>
            </td>
          </tr>
        </table></td>
	  </tr>
  
  
  <tr>
    <td>
	● <%if tSemester="Semester1" then response.write "Mid-term Final" else response.write "End-term Final"%>                                                                                   
	Results&nbsp;&nbsp; 期<%if tSemester="Semester1" then response.write "中" else response.write "末"%>综合总评成绩：<table border="1" width="590" id="table3" bordercolorlight="#000000" cellspacing="0" cellpadding="0" bordercolordark="#000000" style="border-collapse: collapse">                                                                                  
		<tr>
			<td>　</td>
			<td align="center">                                                                                  
<%if tSemester="Semester1" then response.write "Mid-term Periodic Test Average<br>期中周考平均成绩" else response.write "End-term Periodic Test Average<br>期末周考平均成绩"%></td>
			<td align="center">                                                                                  
<%if tSemester="Semester1" then response.write "Mid-term Homework Average<br>期中作业平均成绩" else response.write "End-term Homework Average<br>期末作业平均成绩"%></td>

			<td align="center">                                                                                  
<%if tSemester="Semester1" then response.write "Mid-term Exam<br>期中考试成绩" else response.write "End-term Exam<br>期末考试成绩"%></td>

			<td align="center">                                                                                  
<%if tSemester="Semester1" then response.write "Mid-term Final<br>期中综合总评成绩" else response.write "End-term Final<br>期末综合总评成绩"%></td>

		
		</tr>
		
<%
course=split("BusinessStudies,Chemistry,Economics,English,Maths,FurtherMaths,Physics",",")


for i=0 to ubound(course)  
tsum=0
m=0 '已经有的考试次数
zavg=0  ' 周平均成绩
kscj=0 '考试成绩
zycj=0 '作业成绩
tFinal=0 '综合成绩
totalscore=100


set rs2=server.createobject("ADODB.Recordset") 
   sql2="select * from "&course(i)&",student  where student.class='"&tclass&"' and ("&course(i)&".name_CN='"&tname&"' or "&course(i)&".name_eN='"&tname&"') and "&course(i)&".name_CN=student.name_CN and "&course(i)&".name_eN=student.name_eN and student."&course(i)&"=true"
   rs2.open sql2,conntmp,3,3
'response.write   sql2
'response.end

 if rs2.bof and rs2.eof then
   	'response.write "<tr><td colspan=35>No Test Results!"
   else
   
%>
<tr>
<td><%=course(i)%></td>
			<td align="center">
			<%
				 '-------------------读取总分---------------------
	 set rst=server.createobject("ADODB.Recordset") 
     sqlt="select * from "&course(i)&"  where class='"&tclass&"total' "
     rst.open sqlt,conntmp,1,1	 
	 
	 '--------------------------------------------
			
			for j=4 to 8
				if rs2(j)="" or rs2(j)=" " or IsNull(rs2(j)) then 
				'flag=1
				'exit for
				else
				m=m+1
				'----------分数转换----------------
				  totalscore=rst(j)
				'----------------------------------
				tsum=tsum+round(csng(rs2(j))*(100/totalscore),1)
				'response.write CSng(rs2(j))&","&tsum&","
				end if 			
			next
			
			'如果是期末＝＝＝＝＝＝＝＝＝＝＝＝＝
			if tSemester="Semester2" then
				tsum=0
			m=0
			for j=13 to 17
		
				if rs2(j)="" or rs2(j)=" " or IsNull(rs2(j)) then 
				'flag=1
				'exit for
				else
				m=m+1
				'----------分数转换----------------
				totalscore=rst(j)

				'----------------------------------
				tsum=tsum+round(csng(rs2(j))*(100/totalscore),1)
				'response.write CSng(rs2(j))&","
				end if 
			next
			
			
		
			end if
			'====================================
			
			if m<>0 then  
			zavg=round(tsum/m,1)
			response.write zavg&"&nbsp;"&tograde(zavg)
			else
			response.write "&nbsp;"
			end if
			%>                           
</td>
			<td align="center">
			<!--期中作业平均成绩-->  
<%
if tSemester="Semester1" then
'response.Write  rs2("g")
	if rs2("g")="" or rs2("g")=" " or IsNull(rs2("g")) then
  response.Write  "&nbsp;" 
	  else
	 	  
	  zycj=trim(rs2("g"))
	  	if zycj=0 or Isnumeric(zycj)=false then 
	response.Write  "&nbsp;" 
	  	else
			'----------分数转换----------------
	totalscore=rst("g")
	 'response.Write  zycj&totalscore
		zycj=round(csng(zycj)*(100/totalscore),1)
		
		response.Write zycj&"&nbsp;"&tograde(zycj)
		end if			
	  end if 
else
	
	if rs2("p")="" or rs2("p")=" " or IsNull(rs2("p")) then
response.Write  "&nbsp;" 
	  else
	 	  
	  zycj=trim(rs2("p"))
	  	if zycj=0  or Isnumeric(zycj)=false then 
	response.Write  "&nbsp;" 
	  	else
			'----------分数转换----------------
	totalscore=rst("p")
		
		zycj=round(csng(zycj)*(100/totalscore),1)
		
		response.Write zycj&"&nbsp;"&tograde(zycj)
				end if	
		
	  end if 

end if


%>			


                                         
</td>
			<td align="center"> <!--期中考试成绩-->  
			
<%
if tSemester="Semester1" then
if rs2("h")="" or rs2("h")=" " or IsNull(rs2("h")) then
  response.Write  "&nbsp;" 
	  else
	 	  
	  kscj=trim(rs2("h"))
	  	if kscj=0 or Isnumeric(kscj)=false then 
	    response.Write  "&nbsp;" 
	  	else
	  	'----------分数转换----------------
	totalscore=rst("h")
		
		kscj=round(csng(kscj)*(100/totalscore),1)
        response.Write kscj&"&nbsp;"&tograde(kscj)
				end if	
		
	  end if 
	  
	  
else
if rs2("q")="" or rs2("q")=" " or IsNull(rs2("q")) then
 response.Write  "&nbsp;" 
  
	  else
	 	  
	  kscj=trim(rs2("q"))
	  	if kscj=0 or Isnumeric(kscj)=false then 
	 response.Write  "&nbsp;" 
	  	else
	  	'----------分数转换----------------
	totalscore=rst("q")
		'response.Write kscj&totalscore
		kscj=round(csng(kscj)*(100/totalscore),1)
response.Write kscj&"&nbsp;"&tograde(kscj)
				end if	
		
	  end if 

end if


%>
                   
 </td>
			<td align="center"><%
			if zavg=0 or zycj=0 or kscj=0  then
			response.Write  "&nbsp;"
			else
			tFinal=round(kscj*0.5+zavg*0.3+zycj*0.2,1)
			
			'response.write tfinal
			'期综合总评成绩=期中考试成绩×50%+期中周考平均成绩×30%+期中作业平均成绩×20%
			
           response.Write tFinal&"&nbsp;"&tograde(tFinal)
             end if
 


%>
                   
</td>

</tr>

   	
<%  
 rst.close
   set rst=nothing
 
   end if 
   rs2.close
   set rs2=nothing
   next
%>






		
	</table>
	<br>
	注：期<%if tSemester="Semester1" then response.write "中" else response.write "末"%>综合总评成绩=期<%if tSemester="Semester1" then response.write "中" else response.write "末"%>考试成绩×50%+期<%if tSemester="Semester1" then response.write "中" else response.write "末"%>周考平均成绩×30%+期<%if tSemester="Semester1" then response.write "中" else response.write "末"%>作业平均成绩×20%<br></td>
  </tr>
  
  <tr>
    <td>●Teachers Comments 教师评价 <br>General Comments 总体评价: <br>     
<table border="1" id="table5" width=600 bordercolorlight="#000000" cellspacing="0" cellpadding="0" bordercolordark="#000000" style="border-collapse: collapse" bordercolor="#000000">	  
<tr><td>                                                                           
        <%if tSemester="Semester1" then response.write rs("general1") else response.write rs("general2")%>
		</td></tr>
	  </table>
	</td>
  </tr>
  <%
  for j=0 to ubound(course) 
  if rs(course(j))=true then 
  
  %>
  <br>
  <tr>
    <td>
	<%
	if course(j)="BusinessStudies" then response.Write course(j) & "&nbsp;商务"
	if course(j)="Chemistry" then response.Write course(j) & "&nbsp;化学"
	if course(j)="Economics" then response.Write course(j) & "&nbsp;经济"
	if course(j)="English" then response.Write course(j) & "&nbsp;英语"
	if course(j)="Maths" or  course(j)="FurtherMaths" then response.Write "（Further）Mathematics : (进阶) 数学"
	if course(j)="Physics" then response.Write course(j) & "&nbsp;物理"
	%>
	  : <br>     
<table border="1" id="table5" width="600" bordercolorlight="#000000" cellspacing="0" cellpadding="0" bordercolordark="#000000" style="border-collapse: collapse;word-break:break-all" bordercolor="#000000" >	  
<tr><td width="600" style="word-break:break-all">                                                                           
        <%if tSemester="Semester1" then 
        response.write rs(course(j)&"1") 
        else 
        	if course(j)="FurtherMaths" then course(j)="Maths"
        	response.write course(j)
        	response.write rs(course(j)&"2")
        
        end if 
        %>
		</td></tr>
	  </table>
	
	
	</td>
  </tr>
  <%
  end if
  next%>
  <tr>
    <td>　</td>
  </tr>
  
</table>

<%   

   rs.close
   set rs=nothing
 
%>


</body>

</html>