?? admin_subject.asp
字號:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
option explicit
Response.expires=-1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","no-store"
%>
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/function.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>試題庫管理</title>
<link href="admin.css" rel="stylesheet" type="text/css">
<style>
body {
font-size:12px;
}
</style>
</head>
<body>
<table width="90%" align="center" cellspacing="1" cellpadding="0" bgcolor="#FFFFFF" class="tborder">
<tr class="tdtbg">
<td align="center">
試 題 庫 管 理
</td>
</tr>
<tr class="tdbg">
<td>
<a href="admin_subject.asp">試題庫管理首頁</a> | <a href="admin_subject.asp?action=add">添加試題</a>
</td>
</tr>
</table>
<br>
<%
dim strAction
if checkAdminLogin() = false then '進(jìn)行管理員登錄驗證
response.redirect "admin_login.asp"
end if
if checkPurview(CONST_PURVIEW_SUBJECT) = false then
response.write "<center><font size=4>你沒有進(jìn)行此操作的權(quán)限,請與系統(tǒng)管理員聯(lián)系!</font></center>"
response.write "</body></html>"
response.end
end if
strAction = trim(request.form("action"))
if strAction = "" then
strAction = trim(request.querystring("action"))
end if
select case strAction
case "del"
call del() '刪除試題
case "saveadd"
call saveadd() '保存添加結(jié)果
case "add" '添加試題界面
call add()
case "savemodify" '保存修改結(jié)果
call saveModify()
case "modify" '修改試題界面
call modify()
case else
call main() '主界面
end select
sub main() '主界面
dim rsSubject,strSqlSubject,intMaxPage,I,intMaxPerPage,intCurPage,intCurRec,intCourseID,intType
%>
<table width="90%" align="center" cellspacing="1" cellpadding="0" bgcolor="#FFFFFF" class="tborder">
<tr class="tdtbg">
<td width="70" align="center">選中</td>
<td width="100" align="center">試題ID</td>
<td width="100" align="center">類型</td>
<td width="150" align="center">所屬課程</td>
<td width="150" align="center">操作</td>
</tr>
<%
intMaxPerPage = 18 '定義每頁顯示多少條題目
if IsNumeric(Trim(request.querystring("page"))) = true then
intCurPage = CLng(Trim(request.querystring("page")))
else
intCurPage = 1
end if
if IsNumeric(Trim(request.querystring("courseid"))) = true then
intCourseID = CLng(Trim(request.querystring("courseid")))
else
intCourseID = 0
end if
if IsNumeric(Trim(request.querystring("type"))) = true then
intType = CLng(Trim(request.querystring("type")))
else
intType = 0
end if
set rsSubject = server.createobject("ADODB.Recordset")
strSqlSubject = "select S.*,C.coursename from subject S,course C where S.courseid=C.courseid"
if intCourseID > 0 then
strSqlSubject = strSqlSubject & " and C.courseid=" & intCourseID
end if
if intType > 0 then
strSqlSubject = strSqlSubject & " and S.type=" & intType
end if
strSqlSubject = strSqlSubject & " order by id desc"
rsSubject.open strSqlSubject,G_CONN,1,1
rsSubject.pagesize = intMaxPerPage
if intCurPage < 1 then
intCurPage = 1
elseif intCurPage > rsSubject.pagecount then
intCurPage = rsSubject.pagecount
end if
intMaxPage = rsSubject.pagecount
if not rsSubject.eof and not rsSubject.bof then
rsSubject.absolutepage = intCurPage
end if
if rsSubject.bof or rsSubject.eof then
response.write "<tr class='tdbg'><td colspan='6' align='center'>沒有試題</td></tr>"
end if
intCurRec = 1
while not rsSubject.eof and intCurRec <= intMaxPerPage
response.write "<tr class='tdbg'>"
response.write "<td align='center'><input name='subjectid" & rsSubject("id") & "' onClick='checkup(this);' type='checkbox' value='" & rsSubject("id") & "'></td>"
response.write "<td align='center'>" & rsSubject("id") & "</td>"
response.write "<td align='center'><a href='admin_subject.asp?courseid=" & intCourseID & "&type=" & rsSubject("type") & "'>"
select case rsSubject("type")
case 1
response.write "單選題"
case 2
response.write "多選題"
case 3
response.write "是非題"
case 4
response.write "主觀題"
end select
response.write "</a></td>"
response.write "<td align='center'><a href='admin_subject.asp?courseid=" & rsSubject("courseid") & "'>" & rsSubject("coursename") & "</a></td>"
response.write "<td align='center'>"
response.write "<a href='#' onClick=""if(confirm('即將刪除此試題,確認(rèn)刪除嗎?') == true) window.open('admin_subject.asp?action=del&subjectid=" & rsSubject("id") & "')"">刪除</a> | "
response.write "<a href='admin_subject.asp?action=modify&subjectid=" & rsSubject("id") & "'>修改</a>"
response.write "</td></tr>"
rsSubject.movenext
intCurRec = intCurRec + 1
wend
rsSubject.close
set rsSubject = nothing
call closeConn()
%>
</table>
<center>
<%
call showPageCtrl(intMaxPage,intCurPage,"admin_subject.asp?courseid=" & intCourseID & "&type=" & intType & "&page=")
%>
</center>
<center>
<form name=frmDel>
<input type="hidden" name="action" value="del">
<input type="hidden" name="subjectid" value=",">
<input type="submit" value="刪除選中題目" onClick="delSubject(document.all.frmDel.subjectid);">
</form>
</center>
<script language="JAVAScript">
function delSubject(objSubjectid)
{
if(objSubjectid.value == ",")
objSubjectid.value = "0";
else
objSubjectid.value = objSubjectid.value.substring(1,objSubjectid.value.length - 1);
}
function checkup(objCheckbox)
{
var strId = document.all.frmDel.subjectid.value;
if(objCheckbox.checked == false)
document.all.frmDel.subjectid.value = strId.replace(',' + objCheckbox.value + ',',',');
else
document.all.frmDel.subjectid.value = strId + objCheckbox.value + ',';
}
</script>
</body>
</html>
<%
end sub
sub add() '添加試題界面
%>
<form name="frmAdd" action="admin_subject.asp" method="post">
<input name="action" type="hidden" value="saveadd">
<input name="iscontinue" type="hidden" value="0">
<table width="90%" align="center" cellspacing="1" cellpadding="0" bgcolor="#FFFFFF" class="tborder">
<tr class="tdtbg">
<td colspan="2" align="center"> 添 加 試 題 </td>
</tr>
<tr class="tdbg">
<td width="130" align="right">所屬課程:</td>
<td>
<%call showCourseList(1)%>
</td>
</tr>
<tr class="tdbg">
<td width="130" align="right">試題類型:</td>
<td>
<input name="type" type="radio" onClick="chkup(1);" checked value="1"> 單選題
<input name="type" type="radio" onClick="chkup(2);" value="2"> 多選題
<input name="type" type="radio" onClick="chkup(3);" value="3"> 是非題
<input name="type" type="radio" onClick="chkup(4);" value="4"> 主觀題
</td>
</tr>
<tr class="tdbg">
<td width="130" align="right">試題內(nèi)容:</td>
<td>
<textarea name="content" class="text" cols="50" rows="6"></textarea>
</td>
</tr>
</table>
<div name="divAnswer1" id="divAnswer1">
<table width="90%" align="center" cellspacing="1" cellpadding="0" bgcolor="#FFFFFF" class="tborder">
<tr class="tdbg" name=k1>
<td width="130" align="right">可選項1:</td>
<td>
<input name="option1" type="text" class="text" size="50" maxlength="128" value="">
</td>
</tr>
<tr class="tdbg">
<td width="130" align="right">可選項2:</td>
<td>
<input name="option2" type="text" class="text" size="50" maxlength="128" value="">
</td>
</tr>
<tr class="tdbg">
<td width="130" align="right">可選項3:</td>
<td>
<input name="option3" type="text" class="text" size="50" maxlength="128" value="">
</td>
</tr>
<tr class="tdbg">
<td width="130" align="right">可選項4:</td>
<td>
<input name="option4" type="text" class="text" size="50" maxlength="128" value="">
</td>
</tr>
<tr class="tdbg">
<td width="130" align="right">可選項5:</td>
<td>
<input name="option5" type="text" class="text" size="50" maxlength="128" value="">
</td>
</tr>
<tr class="tdbg">
<td width="130" align="right">可選項6:</td>
<td>
<input name="option6" type="text" class="text" size="50" maxlength="128" value="">
</td>
</tr>
</table>
</div>
<div name="divAnswer2" id="divAnswer2" style="display:none;">
<table width="90%" align="center" cellspacing="1" cellpadding="0" bgcolor="#FFFFFF" class="tborder">
<tr class="tdbg">
<td width="130" align="right">正確答案:</td>
<td>
<input name="answer" id="answer10" type="radio" value="1">是
<input name="answer" id="answer11" type="radio" value="0">否<br>
</td>
</tr>
</table>
</div>
<div name="divAnswer3" id="divAnswer3">
<table width="90%" align="center" cellspacing="1" cellpadding="0" bgcolor="#FFFFFF" class="tborder">
<tr class="tdbg">
<td width="130" align="right">正確答案:</td>
<td>
<input name="answer1" type="checkbox" value="1"> 選項1
<input name="answer2" type="checkbox" value="2"> 選項2
<input name="answer3" type="checkbox" value="4"> 選項3
<input name="answer4" type="checkbox" value="8"> 選項4
<input name="answer5" type="checkbox" value="16"> 選項5
<input name="answer6" type="checkbox" value="32"> 選項6
</td>
</tr>
</table>
</div>
<div name="divAnswer4" id="divAnswer4" style="display:none;">
<table width="90%" align="center" cellspacing="1" cellpadding="0" bgcolor="#FFFFFF" class="tborder">
<tr class="tdbg">
<td width="130" align="right">參考答案:</td>
<td>
<textarea name="strAnswer" class="text" cols="50" rows="6"></textarea>
</td>
</tr>
</table>
</div>
<table width="90%" align="center" cellspacing="1" cellpadding="0" bgcolor="#FFFFFF" class="tborder">
<tr class="tdbg">
<td height="30" colspan="2" align="center">
<input type="submit" value=" 保 存 ">
<input type="submit" onClick="document.all.frmAdd.iscontinue.value='1';" value=" 保存并繼續(xù)添加 ">
</td>
</tr>
</table>
</form>
<script language="JAVAScript">
function chkup(chkinx)
{
//frmAdd.answer10.style.display="none";
switch(chkinx)
{
case 1: //單選題
divAnswer1.style.display="";
divAnswer2.style.display="none";
divAnswer3.style.display="";
divAnswer4.style.display="none";
break;
case 2: //多選題
divAnswer1.style.display="";
divAnswer2.style.display="none";
divAnswer3.style.display="";
divAnswer4.style.display="none";
break;
case 3: //是非題
divAnswer1.style.display="none";
divAnswer2.style.display="";
divAnswer3.style.display="none";
divAnswer4.style.display="none";
break;
case 4: //主觀題
divAnswer1.style.display="none";
divAnswer2.style.display="none";
divAnswer3.style.display="none";
divAnswer4.style.display="";
break;
}
}
</script>
<%
end sub
sub saveAdd() '保存添加結(jié)果
dim rsSubject,strSqlSubject,strErr
dim strContent,intType,intAnswer,intCourseID,strAnswer
dim strOption1,strOption2,strOption3,strOption4,strOption5,strOption6
strErr = ""
strContent = Trim(request.form("content"))
if strContent = "" then
strErr = "<li>題目內(nèi)容為空!</li>"
end if
intType = CLng(Trim(request.form("type")))
if intType < 1 or intType > 4 then
strErr = strErr & "<li>題目類型選擇錯誤!</li>"
end if
intCourseID = CLng(Trim(request.form("courseid")))
if G_CONN.execute("select count(*) as reccount from course where courseid=" & intCourseID)("reccount") = 0 then
strErr = strErr & "<li>課程選擇錯誤!</li>"
end if
strOption1 = Trim(request.form("option1"))
strOption2 = Trim(request.form("option2"))
strOption3 = Trim(request.form("option3"))
strOption4 = Trim(request.form("option4"))
strOption5 = Trim(request.form("option5"))
strOption6 = Trim(request.form("option6"))
if intType = 4 or intType=3 then '主觀題
strOption1 = 1
strOption2 = 1
strOption3 = 1
strOption4 = 1
strOption5 = 1
strOption6 = 1
end if
if strOption1 & strOption2 & strOption3 & strOption4 & strOption5 & strOption6 = "" then
strErr = strErr & "<li>至少要填寫一個選項內(nèi)容!</li>"
end if
if intType < 3 then
if IsNumeric(Trim(request.form("answer1"))) = true then
intAnswer = CLng(Trim(request.form("answer1")))
end if
if IsNumeric(Trim(request.form("answer2"))) = true then
intAnswer = intAnswer + CLng(Trim(request.form("answer2")))
end if
if IsNumeric(Trim(request.form("answer3"))) = true then
intAnswer = intAnswer + CLng(Trim(request.form("answer3")))
end if
if IsNumeric(Trim(request.form("answer4"))) = true then
intAnswer = intAnswer + CLng(Trim(request.form("answer4")))
end if
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -