<% if session("admid")="" or Session("pwd")="" then response.redirect "default.asp"%>
<!--#include file="conn.asp"-->
<%
tclass=request("txtclass")
tcourse=request("course")
tweek=request("weeks")


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 rsweek=server.createobject("ADODB.Recordset") 
     sqlweek="select * from weeks  where weekname='"&tweek&"' "
     rsweek.open sqlweek,conntmp,1,1
	 weekinfo=rsweek("weekinfo")
	 rsweek.close
	 set rsweek=nothing
%>	  

<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><%=tcourse%> - <%=weekinfo%></title>
<link rel="stylesheet" href="style/t.css" type="text/css">
<style type="text/css">
<!--
.STYLE2 {color: #0000FF}
.STYLE3 {color: #FF0000}
-->
</style>
</head>
<body bgcolor="#D6D3CE">
<p align="center" class=header	><b><font size="3">2007-2008 Academic Record</font></b></p>

<div align="center">
  <center>
  <table width="100%" border="0">
  <tr>
    <td width="20%">กก</td>
    <td width="60%">
	<center>
	 <form method="POST" action="registersave.asp" name="form1">
  <table border="1" width="90%" bordercolorlight="#848284" cellspacing="0" cellpadding="4" bordercolordark="#FFFFFF">
    <tr>
      <td colspan="5">
        <p align="center"><b><font size="3"><%=tcourse%> - <%=weekinfo%></font></b><br>
		<%
		set rst=server.createobject("ADODB.Recordset") 
     sqlt="select * from "&tcourse&"  where class='"&tclass&"total' "
	 'response.Write sqlt
	 'response.End()
     rst.open sqlt,conntmp,1,1	 
	 totalscore=rst(tweek)
	 rst.close
	 set rst=nothing
		
		%><font size="2"> </font>
		
		
          <span class="altbg2 STYLE2">
          <font size="2">Total Score:
		 
          <input name="txttotal" type="text" id="txtscore" value="<%=totalscore%>" size="15">

(Please input the total score of this test/exam)</font><br>
		<b>
<span class="STYLE3"><font size="3">Attention: Please leave the column blank if 
		the student is absent from the test/exam</font></span></b>.</span>        </td>
    </tr>
    <tr>
      <td  align="center" class="altbg1">Class</td>
      <td  align="center" class="altbg2">Chinese Name</td>   
      <td align="center" class="altbg2">English Name</td>
      <td  align="center" class="altbg2">Score</td>
      <td  align="center" class="altbg2">Grade</td>
	  <input name="course" type="hidden" value="<%=tcourse%>">
    </tr>
	  <%
	  dim tsum,n,courseavg
	  tsum=0
	  n=0
	  courseavg=0
	 set rs=server.createobject("ADODB.Recordset") 
     sql="select "&tcourse&".id,"&tcourse&".name_cn,"&tcourse&".name_en,"&tcourse&".class,"&tweek&" from "&tcourse&",student  where "&tcourse&".class=student.class and "&tcourse&".class='"&tclass&"' and "&tcourse&".name_cn=student.name_cn and student."&tcourse&"=true  "
     rs.open sql,conntmp,3,3
		do while not rs.eof 
		%>
		<tr>
      <td  align="center" class="altbg1"><%=rs("class")%></td>
      <td align="center" class="altbg2"><%=rs("name_cn")%></td>   
      <td align="center" class="altbg2"><%=rs("name_en")%></td>
      <td align="center" class="altbg2">
	  <INPUT type="text" id=text1 name="cj" size="10"  onFocus="javascript:this.focus();this.select();" value=<%=rs(""&tweek&"")%> >
	  
	  <input name="xuehao" type="hidden" value=<%=rs("id")%>>
	  <input name="txtname_cn" type="hidden" value="<%=rs("name_cn")%>">
	  <input name="txtname_en" type="hidden" value="<%=rs("name_en")%>">	  </td>
	  <td  align="center" class="altbg2">
	  <% 
	  if rs(""&tweek&"")="" or rs(""&tweek&"")=" " or IsNull(rs(""&tweek&"")) then
	  response.Write "&nbsp;&nbsp;&nbsp;"
	  else
	  tgrade=trim(rs(""&tweek&""))
	  	if Isnumeric(tgrade)=false then 
	  	response.Write "Change socre to number"
	  	else
		n=n+1
		tsum=tsum+tgrade
	  	tgrade=round(csng(tgrade)*(100/totalscore),1)
	  	if  tgrade>=85 and tgrade<=100 then response.Write "A"
		if tgrade>=70 and tgrade<85 then response.Write "B"
		if  tgrade>=60 and tgrade<70 then response.Write "C"
		if tgrade>=50 and tgrade<60 then response.Write "D"
		if tgrade>=40 and tgrade<50 then response.Write "E"
		if tgrade<40 then response.Write "U"
		end if	
	  end if 
	 
	  %>	  </td>
      </tr>
		
		
		<%
		num=num+1
		rs.movenext
		loop
		'response.Write tsum&"+++"&n&"+++"&num
		
		if n=0 or tsum=0 then 
		else
				courseavg=round(tsum/n,1)
		end if
		rs.close
		set rs=nothing
	  session("num")=num
	  %>
	  
	   <input name="tclass" type="hidden" value="<%=tclass%>">
	  <input name="tcourse" type="hidden" value="<%=tcourse%>">
	  <input name="tweek" type="hidden" value="<%=tweek%>">
	  <input name="weekinfo" type="hidden" value="<%=weekinfo%>">
	  
	  
	    <tr>
      <td colspan="3"  align="right" class="altbg1"><strong>Average Score:&nbsp;&nbsp; </strong></td>
      <td  align="center" class="altbg2"><%=courseavg%></td>
      <td  align="center" class="altbg2">กก</td>
	  <input name="course" type="hidden" value="<%=tcourse%>">
    </tr>  
	  
  <tr>
    <td colspan="5" align="center" height="25">
	<input type="hidden" value="<%=totalscore%>" name="txtscore">
	<input type="submit" value="Submit" name="B1"> </td>
  </tr>
  </table>
  </form>
  <br>

<input type=button name=fanhui value="Go to select menu" onClick="window.location.href='search.asp'">
  </center>
	
	
	</td>
    <td width="20%">Tips:<p>Grading System: A: 100-85 B: 84-70 C: 69-60 D: 
	59-50 E: 49-40 U: 39-0</p>
	<p>Please input the score and the system will change it to grade 
	automatically.</p>
	<p>E.g. If you input score 75, grade B will appear in the grade column.</td>
  </tr>
</table>

  
 
  </center>
</div>


</body>

</html>
