<% if session("admid")="" or Session("pwd")="" then response.redirect "default.asp"%>
<!--#include file="conn.asp"-->
<html>
<%

tclass=request("txtclass")
tname=trim(request("txtname"))
Teacher=request("Teacher")
tSemester=request("Semester")


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 

 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/t.css" type="text/css">

<title>CIC School Report</title>

</head>
<body bgcolor="#D6D3CE">
<%
if tname="" or tname=" " then 
%>
<center>
<table width="60%" border="1" cellpadding="4" cellspacing="0" bordercolorlight="#848284" bordercolordark="#FFFFFF">
  <tr>
    <td width="100%" height="25"><p align="center"></td>
  </tr>
  <tr>
    <td align="center" class="altbg1">&nbsp;                                                                       
	<a href="search.asp">Please input name , click here and back main page.</a>                                                                       
	</td>
  </tr>
  <tr>
    <td width="100%" align="center" height="25">　</td>
  </tr>
</table>
</center>


<%
response.end
end if
%>
<%
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
%>

<%
if rs.eof and rs.bof then 
%>
<center>
<table width="60%" border="1" cellpadding="4" cellspacing="0" bordercolorlight="#848284" bordercolordark="#FFFFFF">
  <tr>
    <td width="100%" height="25"><p align="center"></td>
  </tr>
  <tr>
    <td align="center" class="altbg1">&nbsp;                                                                       
	<a href="search.asp">Please input right name , click here and back main page.</a>                                                                       
	</td>
  </tr>
  <tr>
    <td width="100%" align="center" height="25">　</td>
  </tr>
</table>
</center>


<%
response.end
end if
%>

<p align="center" class=header	><b><font size="3">CIC School Report<br>                                                                       
上海师范大学剑桥国际中心学生学期报告 </font></b></p>
<div align="center">
  <center>

  <table border="0" width="61%" bordercolorlight="#000000" cellspacing="0" cellpadding="4" bordercolordark="#FFFFFF">
    <tr>
      <td width="98%">
        <p align="right">Date of Issue：<%=rs1("issue")%></td>                                                                                  
    </tr>
    <tr>
      <td width="98%" align="left" class="altbg1">● Semester <%if tSemester="Semester1" then response.write "1" else  response.write "2"%> of&nbsp;<%=rs1("academic")%>&nbsp;Academic Year<br>                                                                                  
        　</td>
    </tr>
	<%
	rs1.close
	set rs1=nothing
	%>
    <tr>
      <td width="98%" align="left"  class="altbg1">● Personal Information&nbsp;&nbsp;                                                                                   
		个人信息：<table border="1" width="733" id="table2" 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>
		<br>
		</td>
    </tr>
    <tr>
      <td width="98%" align="left"  class="altbg1">● Attendance Record&nbsp;                                                                                   
		出勤记录<table border="1" width="99%" 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></td>
    </tr>
		
	
	<tr>
    <td width="98%" align="left" height="23"  class="altbg1">● <%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="99%" 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>

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


for i=0 to ubound(course)  
tsum=0
m=0 '已经有的考试次数
n=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
			m=0
			tsum=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>
      (如果周考缺考则计算已经输入的周考平均成绩，
	期<%if tSemester="Semester1" then response.write "中" else response.write "末"%>考试缺考将无法自动期<%if tSemester="Semester1" then response.write "中" else response.write "末"%>综合总评成绩)
	
 </tr>
 <%
' 去除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
 
'===============================================
 %>
  
    
    <tr>
    <td width="98%" align="left" height="23"  class="altbg1">
	
	<br><hr align="center" size="1">
	
	<%if teacher="Supervisor" then%>
	<form action="reportsave.asp" method="post">
	<table width="736" height="72" border="0">
	<tr>
      <td height="26"  class="altbg1">
	  
	   ●Merit Awards 本学期所获奖项<br>	
	    <table width="600" border="0">
          <tr>
            <td height="80"><textarea name="merit" cols="141" rows="5"><%if tSemester="Semester1" then response.write inHTML(rs("merit1")) else response.write inHTML(rs("merit2"))%>
            </textarea></td>
          </tr>
        </table></td>
	  </tr>
	
	
      <tr>
        <td>●Teachers Comments 教师评价 <br>General Comments 总体评价: <br>                                                                                  
          <textarea rows="10" name="pingjia" cols="141"><%if tSemester="Semester1" then response.write inHTML(rs("general1")) else response.write inHTML(rs("general2"))%></textarea></td>
      </tr>
    </table>
	 <input name="teacher" type="hidden" value="Supervisor">
	 <input name="Semester" type="hidden" value="<%=tSemester%>">
	 <input name="id" type="hidden" value="<%=rs("id")%>">
	 <input name="txtclass" type="hidden" value="<%=tclass%>">
	 <center><input type="submit" value="Submit" name="B1"></center>
	</form>
	<%end if%>
	
	
	
	<%if teacher="BusinessStudies" then%>
	<form action="reportsave.asp" method="post">
	<table width="736" height="72" border="0">
	  
      <tr>
        <td>●Teachers Comments 教师评价 <br>Business Studies 商务: <br>                                                                                  
          <textarea rows="10" name="pingjia" cols="141"><%if tSemester="Semester1" then response.write inHTML(rs("BusinessStudies1")) else response.write inHTML(rs("BusinessStudies2"))%></textarea></td>
      </tr>
	  <input name="teacher" type="hidden" value="BusinessStudies">
	  <input name="Semester" type="hidden" value="<%=tSemester%>">
	  <input name="id" type="hidden" value="<%=rs("id")%>">
	  <input name="txtclass" type="hidden" value="<%=tclass%>">
    </table>
	<center><input type="submit" value="Submit" name="B1"></center>
	</form>
	<%end if%>
	
	
	<%if teacher="Chemistry" then%>
	<form action="reportsave.asp" method="post">
	<table width="736" height="72" border="0">
	  
      <tr>
        <td>●Teachers Comments 教师评价 <br>Chemistry 化学: <br>                                                                                  
          <textarea rows="10" name="pingjia" cols="141"><%if tSemester="Semester1" then response.write inHTML(rs("Chemistry1")) else response.write inHTML(rs("Chemistry2"))%></textarea></td>
      </tr>
	  <input name="teacher" type="hidden" value="Chemistry">
	  <input name="Semester" type="hidden" value="<%=tSemester%>">
	  <input name="id" type="hidden" value="<%=rs("id")%>">
	  <input name="txtclass" type="hidden" value="<%=tclass%>">
    </table>
	<center><input type="submit" value="Submit" name="B1"></center>
	</form>
	<%end if%>
	
	
		<%if teacher="Economics" then%>
	<form action="reportsave.asp" method="post">
	<table width="736" height="72" border="0">
	  
      <tr>
        <td>●Teachers Comments 教师评价 <br>Economics 经济: <br>                                                                                  
          <textarea rows="10" name="pingjia" cols="141"><%if tSemester="Semester1" then response.write inHTML(rs("Economics1")) else response.write inHTML(rs("Economics2"))%></textarea></td>
      </tr>
	  <input name="teacher" type="hidden" value="Economics">
	  <input name="Semester" type="hidden" value="<%=tSemester%>">
	  <input name="id" type="hidden" value="<%=rs("id")%>">
	  <input name="txtclass" type="hidden" value="<%=tclass%>">
    </table>
	<center><input type="submit" value="Submit" name="B1"></center>
	</form>
	<%end if%>
	
	
		<%if teacher="English" then%>
	<form action="reportsave.asp" method="post">
	<table width="736" height="72" border="0">
	  
      <tr>
        <td>●Teachers Comments 教师评价 <br>English 英语: <br>                                                                                  
          <textarea rows="10" name="pingjia" cols="141"><%if tSemester="Semester1" then response.write inHTML(rs("English1")) else response.write inHTML(rs("English2"))%></textarea></td>
      </tr>
	  <input name="teacher" type="hidden" value="English">
	  <input name="Semester" type="hidden" value="<%=tSemester%>">
	  <input name="id" type="hidden" value="<%=rs("id")%>">
	  <input name="txtclass" type="hidden" value="<%=tclass%>">
    </table>
	<center><input type="submit" value="Submit" name="B1"></center>
	</form>
	<%end if%>
	
	
		<%if teacher="Physics" then%>
	<form action="reportsave.asp" method="post">
	<table width="736" height="72" border="0">
	  
      <tr>
        <td>●Teachers Comments 教师评价 <br>Physics 物理: <br>                                                                                  
          <textarea rows="10" name="pingjia" cols="141"><%if tSemester="Semester1" then response.write inHTML(rs("Physics1")) else response.write inHTML(rs("Physics2"))%></textarea></td>
      </tr>
	  <input name="teacher" type="hidden" value="Physics">
	  <input name="Semester" type="hidden" value="<%=tSemester%>">
	  <input name="id" type="hidden" value="<%=rs("id")%>">
	  <input name="txtclass" type="hidden" value="<%=tclass%>">
    </table>
	<center><input type="submit" value="Submit" name="B1"></center>
	</form>
	<%end if%>
	
			<%if teacher="Maths" or teacher="FurtherMaths" then%>
	<form action="reportsave.asp" method="post">
	<table width="736" height="72" border="0">
	  
      <tr>
        <td>●Teachers Comments 教师评价 <br>(Further) Mathematics(进阶) 数学:: <br>                                                                                  
          <textarea rows="10" name="pingjia" cols="141"><%if tSemester="Semester1" then response.write inHTML(rs("Maths1")) else response.write inHTML(rs("Maths2"))%></textarea></td>
      </tr>
	  <input name="teacher" type="hidden" value="Maths">
	  <input name="Semester" type="hidden" value="<%=tSemester%>">
	  <input name="txtclass" type="hidden" value="<%=tclass%>">
	  <input name="id" type="hidden" value="<%=rs("id")%>">
    </table>
	<center><input type="submit" value="Submit" name="B1"></center>
	</form>
	<%end if
	
	
	
	rs.close
	set rs=nothing
	%>
	
	
	
	
     <br>
    
	</td>
    </tr>

  </table>

  </center>
</div>


</body>

</html>