📄 queseditor.jsp
字号:
<%-- * CyberTester - J2EE Web application for creating, delivering and managing tests/exams/surveys. * Copyright (C) 2004 CyberDemia Research and Services Pty Ltd * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, write to the * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * See the COPYING file located in the top-level-directory of * the archive of this program for complete text of license.--%><%@ page language="java" import="com.cyberdemia.school.*, com.cyberdemia.util.StringUtils" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %><%@ taglib uri="/WEB-INF/c.tld" prefix="c" %><%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt" %><%@ taglib uri="/WEB-INF/cd_core.tld" prefix="cyberdemia" %><%@ taglib uri="/WEB-INF/cd_cybertester.tld" prefix="cybertester" %><html:html xhtml="true"> <head> <title><fmt:message key="title.queseditor" /></title> <meta http-equiv="pragmas" content="no-cache" /> <meta http-equiv="cache-control" content="no-cache" /> <meta http-equiv="expires" content="0" /> <link rel="stylesheet" href="<%= request.getContextPath() %>/cybertester.css" type="text/css" /> <link rel="stylesheet" href="<%= request.getContextPath() %>/admin/admin.css" type="text/css" /> <script type="text/javascript" src="<%= request.getContextPath() %>/utils.js" ></script> <script type="text/javascript" > <!-- var cancelling = false; function difficultySelected( code ) { var form = document.getElementById('questionForm'); // Just default the score to the same as the difficulty code form.elements["score"].value = String(code); } function cancelClicked() { cancelling = true; } function validateForm(form ) { if (cancelling) { return true; } if (form.elements["title"].value.trim().length ==0) { alert("<cyberdemia:jsString><fmt:message key="jstext.queseditor.questionForm.error.missingTitle" /></cyberdemia:jsString>"); return false; } if (form.elements["questionText"].value.trim().length ==0) { alert("<cyberdemia:jsString><fmt:message key="jstext.queseditor.questionForm.error.missingQuestionText" /></cyberdemia:jsString>"); return false; } if (form.elements["score"].value.trim().length ==0) { alert("<cyberdemia:jsString><fmt:message key="jstext.queseditor.questionForm.error.invalidScore" /></cyberdemia:jsString>"); return false; } var scoreInt = parseInt( form.elements["score"].value ); if ( isNaN(scoreInt) || (scoreInt<=0) ) { alert("<cyberdemia:jsString><fmt:message key="jstext.queseditor.questionForm.error.invalidScore" /></cyberdemia:jsString>"); return false; } if (form.elements["timeLimitSeconds"].value.trim().length ==0) { alert("<cyberdemia:jsString><fmt:message key="jstext.queseditor.questionForm.error.invalidTimeLimit" /></cyberdemia:jsString>"); return false; } var timeLimitInt = parseInt( form.elements["timeLimitSeconds"].value ); if ( isNaN(timeLimitInt) || (timeLimitInt<0) ) { alert("<cyberdemia:jsString><fmt:message key="jstext.queseditor.questionForm.error.invalidTimeLimit" /></cyberdemia:jsString>"); return false; } <c:if test="${adminQuestionForm.typeDecided}" > <c:choose> <c:when test="${adminQuestionForm.singleChoiceType}" > <c:forEach items="${adminQuestionForm.answerChoicesList}" varStatus="status" > if (form.elements["answerChoiceIndexed[<c:out value="${status.index}" />]"].value.trim().length ==0) { alert("<cyberdemia:jsString><fmt:message key="jstext.queseditor.questionForm.error.missingAnswerChoiceText" ><fmt:param value="${status.index}" /></fmt:message></cyberdemia:jsString>"); return false; } </c:forEach> </c:when> <c:when test="${adminQuestionForm.multipleChoiceType}" > var hasCorrect = false; <c:forEach items="${adminQuestionForm.answerChoicesList}" varStatus="status" > if (form.elements["answerChoiceIndexed[<c:out value="${status.index}" />]"].value.trim().length ==0) { alert("<cyberdemia:jsString><fmt:message key="jstext.queseditor.questionForm.error.missingAnswerChoiceText" ><fmt:param value="${status.index}" /></fmt:message></cyberdemia:jsString>"); return false; } if (form.elements["answerCorrectIndexed[<c:out value="${status.index}" />]"].checked) { hasCorrect = true; } </c:forEach> if (!hasCorrect) { alert("<cyberdemia:jsString><fmt:message key="jstext.queseditor.questionForm.error.missingMultipleChoiceCorrect" /></cyberdemia:jsString>"); return false; } </c:when> <c:when test="${adminQuestionForm.keywordsType}" > <c:forEach items="${adminQuestionForm.keywordsList}" varStatus="status" > if (form.elements["keywordIndexed[<c:out value="${status.index}" />]"].value.trim().length ==0) { alert("<cyberdemia:jsString><fmt:message key="jstext.queseditor.questionForm.error.missingKeywordText" ><fmt:param value="${status.index}" /></fmt:message></cyberdemia:jsString>"); return false; } if (form.elements["keywordIndexed[<c:out value="${status.index}" />]"].value.indexOf(",")>=0) { alert("<cyberdemia:jsString><fmt:message key="jstext.queseditor.questionForm.error.invalidCommaKeywordText" ><fmt:param value="${status.index}" /></fmt:message></cyberdemia:jsString>"); return false; } </c:forEach> </c:when> </c:choose> </c:if> return true; } // --> </script> <html:base/> </head> <body onload="parent.disableHierarchyTree()"> <%@ include file="/include/header.jsp" %> <h1><html:img page="/images/adminques_big.gif" alt="Questions admin" /> <fmt:message key="h1.queseditor" /></h1> <html:errors/> <cybertester:hierarchyNode /> <hr /> <html:form action="/admin/saveQuestion" method="post" styleId="questionForm" onsubmit="return validateForm(this);" > <html:hidden property="mode" /> <html:hidden property="typeDecided" /> <c:if test="${not empty testId}"> <input type="hidden" name="testId" value="<c:out value="${testId}" />" /> </c:if> <html:hidden property="quesId" /> <table width="90%" class="editor" > <tr> <th align="right" width="1%" nowrap="nowrap"><fmt:message key="label.queseditor.questionForm.title" /></th> <td align="left" width="99%"> <html:text property="title" size="40" maxlength="40"/><span class="superscript">*</span> </td> </tr> <tr> <th align="right" width="1%" nowrap="nowrap"><fmt:message key="label.queseditor.questionForm.question" /></th> <td align="left" width="99%"> <html:textarea property="questionText" cols="40" rows="5" /><span class="superscript">*</span> </td> </tr> <tr> <th align="right" width="1%" nowrap="nowrap"><fmt:message key="label.queseditor.questionForm.hint" /></th> <td align="left" width="99%"> <html:textarea property="hintText" cols="40" rows="3" /> </td> </tr> <tr> <th align="right" width="1%" nowrap="nowrap"><fmt:message key="label.queseditor.questionForm.explanation" /></th> <td align="left" width="99%"> <html:textarea property="explanationText" cols="40" rows="5" /> </td> </tr> <tr> <th align="right" width="1%" nowrap="nowrap"><fmt:message key="label.queseditor.questionForm.difficulty" /></th> <td align="left" width="99%"> <% DifficultyEnum[] diffs = DifficultyEnum.getEnums(); for (int didx=0; didx<diffs.length; didx++) { final DifficultyEnum diff = diffs[didx]; final String clickHandler = "difficultySelected("+diff.getCode()+")"; %> <div><label><html:radio property="difficultyStr" value="<%= StringUtils.escapeHTML(diff.getStr(),false) %>" onclick="<%= clickHandler %>" /><%= StringUtils.escapeHTML(diff.getName(),false) %></label></div> <% } %> </td> </tr> <tr> <th align="right" width="1%" nowrap="nowrap"><fmt:message key="label.queseditor.questionForm.score" /></th> <td align="left" width="99%"> <html:text property="score" size="3" maxlength="4" /> </td> </tr> <tr> <th align="right" width="1%" nowrap="nowrap"><fmt:message key="label.queseditor.questionForm.timeLimit" /></th> <td align="left" width="99%"> <html:text property="timeLimitSeconds" size="4" maxlength="6" /><span class="superscript">**</span> </td> </tr> </table> <table width="90%" class="editor" > <c:choose> <c:when test="${not adminQuestionForm.typeDecided}" > <tr> <th align="right" width="1%" nowrap="nowrap"><fmt:message key="label.queseditor.questionForm.type" /></th> <td align="left" width="99%"> <html:select property="type" > <html:option value="0" key="label.queseditor.questionForm.typeOption.singleChoice" /> <html:option value="1" key="label.queseditor.questionForm.typeOption.multipleChoices" /> <html:option value="2" key="label.queseditor.questionForm.typeOption.keywords" /> </html:select> </td> </tr> <tr> <th align="right" width="1%" nowrap="nowrap"><fmt:message key="label.queseditor.questionForm.answerChoicesOrKeywordsCount" /></th> <td align="left" width="99%"> <html:select property="choicesOrKeywordsCount" > <html:option value="2" >2</html:option> <html:option value="3" >3</html:option> <html:option value="4" >4</html:option> <html:option value="5" >5</html:option> <html:option value="6" >6</html:option> <html:option value="8" >8</html:option> <html:option value="10" >10</html:option> <html:option value="15" >15</html:option> <html:option value="20" >20</html:option> <html:option value="25" >25</html:option> <html:option value="30" >30</html:option> </html:select> </td> </tr> </c:when> <c:when test="${adminQuestionForm.singleChoiceType}" > <html:hidden property="type" /> <tr> <th width="1%" nowrap="nowrap"><fmt:message key="label.queseditor.questionForm.index" /></th> <th width="1%" nowrap="nowrap"><fmt:message key="label.queseditor.questionForm.singleChoiceType.correctAnswer" /></th> <th width="98%"><fmt:message key="label.queseditor.questionForm.answerText" /></th> </tr> <logic:iterate id="choice" name="adminQuestionForm" property="answerChoicesList" indexId="cnt" > <tr> <td><c:out value="${cnt}" /></td> <td><html:radio property="answer" value="<%= cnt.toString() %>" /></td> <td><html:textarea property="<%= "answerChoiceIndexed["+cnt+"]" %>" rows="2" cols="50"/><span class="superscript">*</span></td> </tr> </logic:iterate> </c:when> <c:when test="${adminQuestionForm.multipleChoiceType}" > <html:hidden property="type" /> <tr> <th width="1%" nowrap="nowrap"><fmt:message key="label.queseditor.questionForm.index" /></th> <th width="1%" nowrap="nowrap"><fmt:message key="label.queseditor.questionForm.multipleChoiceType.correctAnswers" /></th> <th width="98%"><fmt:message key="label.queseditor.questionForm.answerText" /></th> </tr> <logic:iterate id="choice" name="adminQuestionForm" property="answerChoicesList" indexId="cnt" > <tr> <td><c:out value="${cnt}" /></td> <td><html:checkbox property="<%= "answerCorrectIndexed["+cnt+"]" %>" /></td> <td><html:textarea property="<%= "answerChoiceIndexed["+cnt+"]" %>" rows="2" cols="50"/><span class="superscript">*</span></td> </tr> </logic:iterate> </c:when> <c:when test="${adminQuestionForm.keywordsType}" > <html:hidden property="type" /> <tr> <td colspan="2"> <label><html:checkbox property="mustMatchAllKeywords" /><fmt:message key="label.queseditor.questionForm.mustMatchAllKeywords" /></label> </td> </tr> <tr> <th width="1%" nowrap="nowrap"><fmt:message key="label.queseditor.questionForm.index" /></th> <th width="99%"><fmt:message key="label.queseditor.questionForm.keywordsType.keywords" /></th> </tr> <logic:iterate id="keyword" name="adminQuestionForm" property="keywordsList" indexId="cnt" > <tr> <td><c:out value="${cnt}" /></td> <td><html:text property="<%= "keywordIndexed["+cnt+"]" %>" size="50"/><span class="superscript">*</span></td> </tr> </logic:iterate> </c:when> </c:choose> </table> <div> <html:submit><fmt:message key="label.button.submit" /></html:submit> <%-- If adding new answers, do not allow cancellation as this will result in an inactive, half-completed question. --%> <c:if test="${not adminQuestionForm.newAnswers}" > <html:cancel onclick="cancelClicked()" ><fmt:message key="label.button.cancel" /></html:cancel> </c:if> </div> </html:form> <p class="footnotes">* <fmt:message key="text.queseditor.questionForm.footnote.required" /></p> <p class="footnotes">** <fmt:message key="text.queseditor.questionForm.footnote.timeLimit" /></p> <p class="footnotes"> <fmt:message key="text.queseditor.questionForm.footnote.insertLineBreaks" /> </p> </body></html:html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -