Procházet zdrojové kódy

修改勾选题的答题点处理

lujianhong před 4 roky
rodič
revize
94613990ab
2 změnil soubory, kde provedl 30 přidání a 23 odebrání
  1. 29 22
      EBook.Web/Common/tasklib_book.js
  2. 1 1
      EBook.Web/Test.html

+ 29 - 22
EBook.Web/Common/tasklib_book.js

@@ -373,12 +373,14 @@ function handleAnswerRange() {
         tempJson.push(info);
 
         var prev = $(item).prev();
-        if (prev.length == 0 || $(prev).attr("class") != "tag-span") {
-            //替换答案
-            $(item).prop("outerHTML", "<span answer-id='" + info.Id + "' class='tag-span' answer-isky='0'>_</span>");
-        }
-        else {
-            $(item).remove();
+        if (!$(prev).hasClass("checkbox")) {
+            if (prev.length == 0 || $(prev).attr("class") != "tag-span") {
+                //替换答案
+                $(item).prop("outerHTML", "<span answer-id='" + info.Id + "' class='tag-span' answer-isky='0'>_</span>");
+            }
+            else {
+                $(item).remove();
+            }
         }
     });
 
@@ -386,13 +388,15 @@ function handleAnswerRange() {
     $.each($(".yaoshi"), function (index, item) {
         var Id = $(item).attr("answer-id");
         var prev = $(item).next();
-        if (prev.length == 0 || $(prev).attr("class") != "tag-span") {
-            if ($("span[answer-id='" + Id + "']").length == 0) {
-                var uHtml = document.createElement("span");
-                uHtml.className = "tag-span";
-                uHtml.innerText = "_";
-                uHtml.setAttribute("answer-id", Id);
-                $(item).after(uHtml);
+        if (!$(prev).hasClass("checkbox")) {
+            if (prev.length == 0 || $(prev).attr("class") != "tag-span") {
+                if ($("span[answer-id='" + Id + "']").length == 0) {
+                    var uHtml = document.createElement("span");
+                    uHtml.className = "tag-span";
+                    uHtml.innerText = "_";
+                    uHtml.setAttribute("answer-id", Id);
+                    $(item).after(uHtml);
+                }
             }
         }
     });
@@ -471,16 +475,19 @@ function handleAnswerRange() {
     var index = 1;
     var checkId = 0;
     $.each($(".multipleStart").nextUntil(".multipleEnd").filter("[class*='group']"), function (index, item) {
-        checkId = $(item).find('.yaoshi').attr("answer-id") ;
-        var index = $(item).attr('class').replace(/.*group(\d+).*/g, "$1");
-        var ischecked = $(item).find(".underlineContent").text().indexOf("√") > -1;
-            //勾选题
-        if ($(item).hasClass('boxQue')) {
-            $(item).find('.yaoshi').after("<div class='checkbox'><input id=" + checkId + " type='checkbox' onclick=this.checked=!this.checked><label for=" + checkId + "></label></div>");
-            $(item).find('input').prop('checked', ischecked);
-            $(item).find('.underlineContent').hide();
-        }
+        //checkId = $(item).find('.yaoshi').attr("answer-id");
+        //var index = $(item).attr('class').replace(/.*group(\d+).*/g, "$1");
+        //var ischecked = $(item).find(".underlineContent").text().indexOf("√") > -1;
+        ////勾选题
+        //if ($(item).hasClass('boxQue')) {
+        //    $(item).find('.yaoshi').after("<div class='checkbox'><input id=" + checkId + " type='checkbox' onclick=this.checked=!this.checked><label for=" + checkId + "></label></div>");
+        //    $(item).find('input').prop('checked', ischecked);
+        //    $(item).find('.underlineContent').hide();
+        //}
+        //删除钥匙节点
+        $(item).find('.yaoshi').remove();
     });
+    
     //添加答题点的点击UI及交互
     $.each($(".tag-span"), function (index, item) {
         var answerText = "";

+ 1 - 1
EBook.Web/Test.html

@@ -47,7 +47,7 @@
         }
         //加载听说课文
         $("#load-text").on("click", function () {
-            var data = $.ajax({ url: "lghp/BGGX.lghp", async: false }).responseText;
+            var data = $.ajax({ url: "lghp/gouxuan.lghp", async: false }).responseText;
             $("#data").html(data);
 
             //Fill(JSON.parse(hightcodejson));