ITOO学生端—动态拼接试卷(2)

接着上篇博客!

        拼接完题干之后,通过 试题类的id去查询该类型下的小题。同时把大题干,和试卷的描述传过去(干嘛使,不知道!)

htmlType = queryComponent(
<span style="white-space:pre">	</span>htmlType,
<span style="white-space:pre">	</span>questionTypeId,
<span style="white-space:pre">	</span>paperDetailList[i].lstQuestionMain);

调用queryComponent方法()

//根据题型,查询组件信息
	function queryComponent(htmlType, questionTypeId, questionMainList) {

		var htmlCourse = "";
		var b;
		$.ajax({
			type : "POST",
			async : false,
			dataType : "text",
			url : "${pageContext.request.contextPath}/queryComponent?questionTypeId="
			  + questionTypeId,
			success : function(data) {
			var componentList = eval(data);
			htmlType = onlineEdit(htmlType, componentList,
				questionMainList, questionTypeId);
					}
				});
		return htmlType;
	}

查询出小提信息之后调用 onlineEdit方法()


//根据试题拼接组件
	function onlineEdit(htmlType, componentList, questionMainList,
			questionTypeId) {
		for (var j = 0; j < questionMainList.length; j++) {

			for (var i = 0; i < componentList.length; i++) {
				var unit = eval(componentList[i]);
				var questionContent = "";
				switch (unit.field) {
				//大题干
				case "bigTGTag":
					questionContent = questionMainList[j].questionContent;
					if (questionContent == null) {
						questionContent = " ";
					}
					//大小题型的大题干
					if (questionMainList[j].isParentQuestion == 1) {
						htmlType += "</div>";
						htmlType += "<div class='itoo-question' id='"+questionMainList[j].id+"'>"
								+ "<br>";
						htmlType += "<div class='questionRequire' name='questionContent' "+ "value=''>"
								+ (questionMainList[j].typeOrder + 1)
								+ "、"
								+ questionContent + "</div>";

						//不区分大小题型
					} else if (questionMainList[j].isParentQuestion == 0
					&& (questionMainList[j].parentQuestionId == "" || questionMainList[j].parentQuestionId == null)) {
						htmlType += "<div class='itoo-question' id='"+questionMainList[j].id+"'>"
								+ "<br>";
						htmlType += "<div class='questionRequire' name='questionContent' "+ "value=''>"
								+ (questionMainList[j].typeOrder + 1)
								+ "、"
								+ questionContent + "</div>";
					}

					break;

				//选项
				case "optionTag":
					var optionLength = questionMainList[j].options.length;
					if (optionLength != 0) {
						for (var count = 0; count < questionMainList[j].options.length; count++) {
							optionContent = questionMainList[j].options[count].optionsContent;
							if (optionContent == null) {
								optionContent == "";
							}
							var questionId = questionMainList[j].id;
							var id = questionMainList[j].options[count].id;

							var studentAnswer = getNumber(count);

							htmlType += "<div id='"
									+ questionMainList[j].options[count].id
									+ "' class='optionBox' οnclick='submitId(this,""
									+ questionMainList[j].answer
									+ "",""
									+ questionMainList[j].score
									+ "","" + studentAnswer
									+ """ + ")' value='" + questionId;
						htmlType += "'><label class='optionBox'><input  type='radio' value='0' name='option"
									+ j + questionTypeId;
							if (questionMainList[j].studentAnswer == questionMainList[j].options[count].id) {
								htmlType += "' checked>";
							} else {
								htmlType += "'>";
							}

							htmlType += " " + getNumber(count) + "、"
									+ optionContent + "</input></label></div>";

						}

						htmlType += "</div>";

					}

					break;

				//小题干
				case "littleTGTag":

					if (questionMainList[j].isParentQuestion == 0
							&& questionMainList[j].parentQuestionId != "") {
						questionContent = questionMainList[j].questionContent;
						htmlType += "<div class='itoo-question' id='"+questionMainList[j].id+"'>";
			                        htmlType += "<div id='"+questionMainList[j].id+"' class='questionRequire' name='questionContent' "+ "value=''>"
								+ "("
								+ (questionMainList[j].typeOrder + 1)
								+ ")" + "、" + questionContent + "</div>";
					}

					break;

				//填空题
				case "fillLineTag":

					htmlType += "<textarea id='"
							+ questionMainList[j].id
							+ "' class='fillLineText' οnclick='submitId(this)' value='' ></textarea><br>";
					htmlType += "</div>";
					break;

				case "answerTextTag":
					var answerTextTagID = questionMainList[j].id;
					var answerScore = questionMainList[j].score;
					var answerCount = j;

					htmlType += "<input id='"
							+ "answer"
							+ answerCount
							+ "' class='areaText' οnblur='blurEvent(this,""
							+ answerTextTagID + "","" + answerScore
							+ """
							+ ")' type='text' value='enter'></input><br></div>";

					break;

				}

			}

		}
		htmlType += "</div>";

		return htmlType;
	}

          通过一个星期对ITOO学生端的维护,对其中的需求和代码算是有了点了解,也增加了自己对java的信心,这次总结只是对代码的调用和逻辑进行解释。日后通过深入的学习,了解些里面的原理,然后再次总结。在代码走查的时候听师哥、师姐说什么远程调用、APO容器、日志等技术,这次我们都要使用和学习了,期待,同志们加油了!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 18
    评论
评论 18
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值