WEB开发网
开发学院WEB开发ASP ASP生成静态网页,学习CASE的用法,以及“权限”的... 阅读

ASP生成静态网页,学习CASE的用法,以及“权限”的一种控制方法

 2009-01-20 10:39:32 来源:WEB开发网   
核心提示:<form action="calscore.asp?action=do" method="post" name=form1> ... </form> <!--#include file="connect.asp"--> &

<form action="calscore.asp?action=do" method="post" name=form1> ... </form>

<!--#include file="connect.asp"-->
<% if session("logstatus")<>1 then %>
<p align="center">
<font size="5" ><b>你还没有登录,没有权利浏览本页,请先<a href="login.asp">登录</a>!</b></font></p>
<%
else
读取login.htm附带的subjectno、studentid及name参数值
subject=request("subject")
studentid=request("studentid")
name=request("name")

******** 路径和文件的建立 ********************************************************************
格式化日期
function format(date)
format=datepart("yyyy",date)&"年"&datepart("m",date)&"月"&datepart("d",date)&"日 "&formatdatetime(date,vbshorttime)
end function
dim fmonth,fday,fhour,fminute,fsecond
fmonth=month(date)
if len(month(date))<2 then fmonth="0"&month(date) end if
fday=day(date)
if len(day(date))<2 then fday="0"&day(date) end if
fhour=hour(now())
if len(hour(now()))<2 then fhour="0"&hour(now()) end if
fminute=minute(now())
if len(minute(now()))<2 then fminute="0"&minute(now()) end if
fsecond=second(now())
if len(second(now()))<2 then fsecond="0"&second(now()) end if
newspath=year(date)&fmonth&fday
newsurl=fhour&fminute&fsecond
putdate=format(now())

if request("action")="do" then

path=server.mappath("kaoshi") /.定义的一个文件
set fso=server.createobject("scripting.filesystemobject")
if fso.folderexists(path)=false then
fso.createfolder(path)
end if
path=path&"/"&newspath
if fso.folderexists(path)=false then
fso.createfolder(path)
end if
path=path&"/"&newsurl&".shtml" /.生成shtml页面

set ts=fso.opentextfile(path,2,true,-2)

******** 生成html页面 ***********************************************************************
ts.writeline"<html>"
ts.writeline"<head>"
ts.writeline"<title>"&name&""
ts.writeline","&subject&""
ts.writeline" - 成绩结果</title>"
ts.writeline"<meta http-equiv=""content-type"" content=""text/html; charset=gb2312"">"
ts.writeline"<link rel=""stylesheet"" href=""CSS.css"" type=""text/css"">"
ts.writeline"</head>"
ts.writeline""

ts.writeline"<body bgcolor=""#ffffff"" text=""#000000"">"
ts.writeline"<table width=""100%"">"
ts.writeline"<tr>"
ts.writeline"<td width=""100%"">"
ts.writeline"<h2>"
ts.writeline""&name&""
ts.writeline",你的考试成绩如下表:</h2>"

dim score
score=0
sqlt="select * from 考题类型"
rst.open sqlt,conn,1,1
do while not rst.eof
tn=rst("id")
tname=rst("name")

ts.writeline"<b>"
ts.writeline""&tname&""
ts.writeline"</b><br><br>"

sql="select * from "&subject&" where 题目类型="&tn&" order by 题目序号"
rs.open sql,conn,2,2
while not rs.eof
answer=rs("正确答案")
select case rs("题目类型")
case 1:
selection=request("no"&rs("题目序号"))
ts.writeline rs("题目序号")
ts.writeline"、"&selection&"<br>"
case 2:
selection=""
for n=1 to 4
if not request("no"&rs("题目序号")&"-"&n)="" then
selection=selection&request("no"&rs("题目序号")&"-"&n)
end if
next
ts.writeline rs("题目序号")
ts.writeline" 、"&selection&"<br>"
case 3:
selection=request(rs("选择项1"))
ts.writeline rs("题目序号")
ts.writeline"、"&selection&"<br>"
case else:
selection=request(rs("选择项1"))
ts.writeline rs("题目序号")
ts.writeline"、"
ts.writeline"<font color=red>未确定评分规则!</font><br>"
ts.writeline""&selection&"<br>"
end select
if answer=selection then
score=score+rs("本题分数")
end if
rs.movenext
wend

rs.close
ts.writeline"<br>"
rst.movenext
loop
response.write score
response.end

ts.writeline"<br>"
ts.writeline"<font color=red>评分:</font>"
ts.writeline""&score&""
ts.writeline"<br>"
ts.writeline"</td></tr></table>"
ts.writeline"</body>"
ts.writeline"</html>"
end if
%>

Tags:ASP 生成 静态

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接