⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin_subject.asp

📁 学校在线考试系统
💻 ASP
📖 第 1 页 / 共 2 页
字号:
		if IsNumeric(Trim(request.form("answer5"))) = true then
			intAnswer = intAnswer + CLng(Trim(request.form("answer5")))
		end if
		if IsNumeric(Trim(request.form("answer6"))) = true then
			intAnswer = intAnswer + CLng(Trim(request.form("answer6")))
		end if
		if intAnswer < 1 or intAnswer > 63 then
			strErr = strErr & "<li>答案选择错误!</li>"
		end if
	else
       if intType = 4 then   '主观题
	      intAnswer = 0
	      strAnswer = Trim(request.form("strAnswer"))
	   else
		  intAnswer = CLng(Trim(request.form("answer")))	   
	   end if
		if intAnswer <> 1 and intAnswer <> 0 then
			strErr = strErr & "<li>答案选择错误!</li>"
		end if
	end if
	
	if strErr <> "" then
		call closeConn()
		showErrMsg(strErr)
		response.write "</body></html>"
		exit sub
	end if
	set rsSubject = server.createobject("ADODB.Recordset")
	strSqlSubject = "select * from subject where id=0"
	rsSubject.open strSqlSubject,G_CONN,1,3
	rsSubject.addnew
	rsSubject("content") = strContent
	rsSubject("type") = intType
	rsSubject("option1") = strOption1
	rsSubject("option2") = strOption2
	rsSubject("option3") = strOption3
	rsSubject("option4") = strOption4
	rsSubject("option5") = strOption5
	rsSubject("option6") = strOption6
	rsSubject("answer") = intAnswer
	rsSubject("courseid") = intCourseID
	rsSubject("answer2") = server.HTMLEncode(strAnswer)   '主观题参考答案
	rsSubject.update
	rsSubject.close
	set rsSubject = nothing
	call closeConn()
	if request.form("iscontinue") = "1" then
		response.redirect "admin_subject.asp?action=add"
	else
		response.redirect "admin_subject.asp"
	end if
end sub

sub modify()	'修改试题界面
	dim rsSubject,strSqlSubject,intSubjectID,strErr
	
	strErr = ""
	intSubjectID = CLng(Trim(request.querystring("subjectid")))
	set rsSubject = server.createobject("ADODB.Recordset")
	strSqlSubject = "select * from subject where id=" & intSubjectID
	rsSubject.open strSqlSubject,G_CONN,1,1
	if rsSubject.bof or rsSubject.eof then
		strErr = "<li>试题ID不存在!</li>"
	end if
	if strErr <> "" then
	end if
%>
<form name="frmModify" action="admin_subject.asp" method="post">
<input name="action" type="hidden" value="savemodify">
<input name="subjectid" type="hidden" value="<%=intSubjectID%>">
<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(rsSubject("courseid"))%>
		</td>
	</tr>
	<tr class="tdbg">
		<td width="130" align="right">试题类型:</td>
		<td>
			<input name="type" onClick="chkup(1);" type="radio" <%if rsSubject("type")=1 then Response.Write "checked"%> value="1"> 单选题&nbsp;&nbsp;
			<input name="type" onClick="chkup(2);" type="radio" <%if rsSubject("type")=2 then Response.Write "checked"%> value="2"> 多选题&nbsp;&nbsp;
			<input name="type" onClick="chkup(3);" type="radio" <%if rsSubject("type")=3 then Response.Write "checked"%> value="3"> 是非题&nbsp;&nbsp;
			<input name="type" onClick="chkup(4);" type="radio" <%if rsSubject("type")=4 then Response.Write "checked"%> value="4"> 主观题&nbsp;&nbsp;
		</td>
	</tr>
	<tr class="tdbg">
		<td width="130" align="right">试题内容:</td>
		<td>
			<textarea name="content" class="text" cols="50" rows="6"><%=rsSubject("content")%></textarea>
		</td>
	</tr>
	</table>

   
   
   <%
   if rsSubject("type")=1 or rsSubject("type")=2 then 
      strnone =""
   else
      strnone ="none"
   end if
   %>
    <div name="divAnswer1" id="divAnswer1" style="display:<%=strnone%>;">
    <table width="90%" align="center" cellspacing="1" cellpadding="0" bgcolor="#FFFFFF" class="tborder">	
	<tr class="tdbg">
		<td width="130" align="right">可选项1:</td>
		<td>
			<input name="option1" type="text" class="text" size="50" maxlength="128" value="<%=rsSubject("option1")%>">
		</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="<%=rsSubject("option2")%>">
		</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="<%=rsSubject("option3")%>">
		</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="<%=rsSubject("option4")%>">
		</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="<%=rsSubject("option5")%>">
		</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="<%=rsSubject("option6")%>">
		</td>
	</tr>
	</table>
   </div>	
   
   <%
   dim strnone
   if rsSubject("type")=3 then 
      strnone =""
   else
      strnone ="none"
   end if
   %>
    <div name="divAnswer2" id="divAnswer2" style="display:<%=strnone%>;">
    <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" type="radio" <%if rsSubject("type")=3 and rsSubject("answer")=1 then Response.Write "checked"%> value="1">是&nbsp;&nbsp;
			<input name="answer" type="radio" <%if rsSubject("type")=3 and rsSubject("answer")=0 then Response.Write "checked"%> value="0">否<br>
		</td>
	</tr>
	</table>
   </div>
   
   <%
   if rsSubject("type")=1 or rsSubject("type")=2 then 
      strnone =""
   else
      strnone ="none"
   end if
   %>
    <div name="divAnswer3" id="divAnswer3" style="display:<%=strnone%>;">
    <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" <%if rsSubject("type") < 3 and ((rsSubject("answer") and 1) > 0) then Response.Write "checked"%> value="1"> 选项1&nbsp;&nbsp;
			<input name="answer2" type="checkbox" <%if rsSubject("type") < 3 and ((rsSubject("answer") and 2) > 0) then Response.Write "checked"%> value="2"> 选项2&nbsp;&nbsp;
			<input name="answer3" type="checkbox" <%if rsSubject("type") < 3 and ((rsSubject("answer") and 4) > 0) then Response.Write "checked"%> value="4"> 选项3&nbsp;&nbsp;
			<input name="answer4" type="checkbox" <%if rsSubject("type") < 3 and ((rsSubject("answer") and 8) > 0) then Response.Write "checked"%> value="8"> 选项4&nbsp;&nbsp;
			<input name="answer5" type="checkbox" <%if rsSubject("type") < 3 and ((rsSubject("answer") and 16) > 0) then Response.Write "checked"%> value="16"> 选项5&nbsp;&nbsp;
			<input name="answer6" type="checkbox" <%if rsSubject("type") < 3 and ((rsSubject("answer") and 32) > 0) then Response.Write "checked"%> value="32"> 选项6
		</td>
	</tr>
	</table>
   </div>

   
   <%
   if rsSubject("type")=4 then 
      strnone =""
   else
      strnone ="none"
   end if
   %>
    <div name="divAnswer4" id="divAnswer4" style="display:<%=strnone%>;">
    <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"><%=rsSubject("answer2")%></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="&nbsp;保&nbsp;&nbsp;存&nbsp;">&nbsp;&nbsp;
		</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 saveModify()	'保存修改结果
	dim rsSubject,strSqlSubject,strErr
	dim strContent,intType,intAnswer,intCourseID,intSubjectID,strAnswer
	dim strOption1,strOption2,strOption3,strOption4,strOption5,strOption6
	
	strErr = ""
	if IsNumeric(Trim(Request.Form("subjectid"))) = false then
		strErr = "<li>试题ID错误!</li>"
	else
		intSubjectID = CLng(Trim(Request.Form("subjectid")))
	end if
	strContent = Trim(request.form("content"))
	if strContent = "" then
		strErr = "<li>题目内容为空!</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") = "" 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 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>至少要填写一个选项内容!</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
		if IsNumeric(Trim(request.form("answer5"))) = true then
			intAnswer = intAnswer + CLng(Trim(request.form("answer5")))
		end if
		if IsNumeric(Trim(request.form("answer6"))) = true then
			intAnswer = intAnswer + CLng(Trim(request.form("answer6")))
		end if
		if intAnswer < 1 or intAnswer > 63 then
			strErr = strErr & "<li>答案选择错误!</li>"
		end if
	else
       if intType = 4 then   '主观题
	      intAnswer = 0
	      strAnswer = Trim(request.form("strAnswer"))
	   else
		  intAnswer = CLng(Trim(request.form("answer")))	   
	   end if
		  if intAnswer <> 1 and intAnswer <> 0 then
			 strErr = strErr & "<li>答案选择错误!</li>"
		  end if
	end if
	
	if strErr <> "" then
		call closeConn()
		showErrMsg(strErr)
		response.write "</body></html>"
		exit sub
	end if
	set rsSubject = server.createobject("ADODB.Recordset")
	strSqlSubject = "select * from subject where id=" & intSubjectID
	rsSubject.open strSqlSubject,G_CONN,1,3
	if rsSubject.bof and rsSubject.eof then
		strErr = "<li>此试题不存在!</li>"
		showErrMsg(strErr)
		rsSubject.close
		set rsSubject = nothing
	end if
	rsSubject("content") = strContent
	rsSubject("type") = intType
	rsSubject("option1") =strOption1
	rsSubject("option2") = strOption2
	rsSubject("option3") = strOption3
	rsSubject("option4") = strOption4
	rsSubject("option5") = strOption5
	rsSubject("option6") = strOption6
	rsSubject("answer") = intAnswer
	rsSubject("courseid") = intCourseID
    rsSubject("answer2") = strAnswer   '主观题参考答案
	rsSubject.update
	rsSubject.close
	set rsSubject = nothing
	call closeConn()
	response.redirect "admin_subject.asp"
end sub

sub del()	'删除试题
	dim strSubjectID,strErr
	
	strSubjectID = Trim(request.querystring("subjectid"))
	if strSubjectID = "" then
		strSubjectID = Trim(request.form("subjectid"))
	end if
	if strSubjectID = "" then
		strErr = "<li>请选择要删除的试题!</li>"
		showErrMsg(strErr)
		response.write "</body></html>"
		call closeConn()
		exit sub
	end if
	if G_CONN.execute("select count(*) as reccount from prj_process where subid in (" & strSubjectID & ")")("reccount") > 0 then
		strErr = "<li>此试题正在使用中,不能被删除!</li>"
		call closeConn()
		showErrMsg(strErr)
		response.write "</body></html>"
		exit sub
	end if
	G_CONN.execute "delete from subject where id in (" & strSubjectID & ")"
	call closeConn()
	response.redirect "admin_subject.asp"
end sub
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -