tasklib_book.js 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  1. //播放音频图片地址
  2. var PicInfo = {
  3. answerPointImgUrl: "file:///android_asset/js/update-answer.png",
  4. yaoshiShowImgUrl: "file:///android_asset/js/yaoshi-show.png",
  5. yaoshiHideImgUrl: "file:///android_asset/js/yaoshi-hide.png",
  6. recordPlayImgUrl: "file:///android_asset/js/play.png",
  7. recordPauseImgUrl: "file:///android_asset/js/pause.png",
  8. audioPlayImgUrl: "file:///android_asset/js/dynaiselaba.gif",
  9. audioPauseImgUrl: "file:///android_asset/js/dynaiselaba.png"
  10. }
  11. //本地调用用的资源
  12. var PicInfo1 = {
  13. answerPointImgUrl: "../Images/update-answer.png",
  14. yaoshiShowImgUrl: "../Images/yaoshi-show.png",
  15. yaoshiHideImgUrl: "../Images/yaoshi-hide.png",
  16. KouYuTagImgUrl: "../Images/KY.png",
  17. recordPlayImgUrl: "../Images/play.png",
  18. recordPauseImgUrl: "../Images/pause.png",
  19. audioPlayImgUrl: "../Images/dynaiselaba.gif",
  20. audioPauseImgUrl: "../Images/dynaiselaba.png"
  21. }
  22. //显示、隐藏答案
  23. function showHideAnswer(flag) {
  24. if (flag) {
  25. //$(".underlineContent").show();
  26. $(".underlineContent").css("color", "#92D050");
  27. $(".yaoshi").attr("src", PicInfo.yaoshiShowImgUrl);
  28. $.each($(".underlineContent"), function (index, item) {
  29. var underlineContentText = $(this).text(); // 获取文本内容
  30. var widthValue = $(item).css("width");
  31. var newClsName = $(item).next().attr("class");
  32. if (newClsName != "underlineContentShow") {
  33. var addHtml = "";
  34. if (hasChineseWorld(underlineContentText)) {
  35. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&emsp;</span>";
  36. }
  37. else {
  38. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&nbsp;</span>";
  39. }
  40. $(item).css("display", "inline-block").after(addHtml);
  41. }
  42. else {
  43. $(item).css("display", "inline-block").next().attr("data-status", "0");
  44. }
  45. if (underlineContentText.indexOf("√") > -1) {
  46. $(this).parent().find(".checkbox").find("input").prop('checked', true);
  47. }
  48. });
  49. }
  50. else {
  51. //$(".underlineContent").hide();
  52. $(".underlineContent").css("color", "#ffffff");
  53. $(".yaoshi").attr("src", PicInfo.yaoshiHideImgUrl);
  54. $.each($(".underlineContent,.underlineContent.no-answer"), function (index, item) {
  55. var underlineContentText = $(this).text(); // 获取文本内容
  56. var widthValue = $(item).css("width");
  57. var newClsName = $(item).next().attr("class");
  58. if (newClsName != "underlineContentShow") {
  59. var addHtml = "";
  60. if (hasChineseWorld(underlineContentText)) {
  61. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&emsp;</span>";
  62. }
  63. else {
  64. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&nbsp;</span>";
  65. }
  66. $(item).css("display", "none").after(addHtml);
  67. $(item).next().attr("data-status", "1");
  68. }
  69. else {
  70. $(item).css("display", "none").next().attr("data-status", "1");
  71. }
  72. if (underlineContentText.indexOf("√") > -1) {
  73. $(this).parent().find(".checkbox").find("input").prop('checked', false);
  74. }
  75. });
  76. }
  77. }
  78. ///显示、隐藏钥匙及答案 isShowYX:显示和隐藏钥匙,isShowAS:显示和隐藏答案
  79. function showHideAnswerEx(isShowYX, isShowAS) {
  80. if (isShowYX) {
  81. $(".yaoshi").show();
  82. }
  83. else {
  84. $(".yaoshi").hide();
  85. }
  86. if (isShowAS) {
  87. $.each($(".underlineContent"), function (index, item) {
  88. var underlineContentText = $(this).text(); // 获取文本内容
  89. var widthValue = $(item).css("width");
  90. var newClsName = $(item).next().attr("class");
  91. if (newClsName != "underlineContentShow") {
  92. var addHtml = "";
  93. if (hasChineseWorld(underlineContentText)) {
  94. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&emsp;</span>";
  95. }
  96. else {
  97. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&nbsp;</span>";
  98. }
  99. $(item).css("display", "inline-block").after(addHtml);
  100. }
  101. else {
  102. $(item).css("display", "inline-block").next().attr("data-status", "0");
  103. }
  104. if (underlineContentText.indexOf("√") > -1) {
  105. $(this).parent().find(".checkbox").find("input").prop('checked', true);
  106. }
  107. //$(item).html($(item).attr("data-text"));
  108. if (!$(item).hasClass("no-answer")) {
  109. $(item).css("color", "#92D050");
  110. }
  111. else {
  112. $(item).css("color", "#989898");
  113. }
  114. $(item).find(".wordStyle").css("color", "#db5d00");
  115. $(item).find(".phraseStyle").css("background-color", "#f2db8b");
  116. });
  117. $(".yaoshi").attr("data-status", "1");
  118. $(".yaoshi").attr("src", PicInfo.yaoshiShowImgUrl);
  119. }
  120. else {
  121. $.each($(".underlineContent,.underlineContent.no-answer"), function (index, item) {
  122. var underlineContentText = $(this).text(); // 获取文本内容
  123. var widthValue = $(item).css("width");
  124. var newClsName = $(item).next().attr("class");
  125. if (newClsName != "underlineContentShow") {
  126. var addHtml = "";
  127. if (hasChineseWorld(underlineContentText)) {
  128. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&emsp;</span>";
  129. }
  130. else {
  131. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&nbsp;</span>";
  132. }
  133. $(item).css("display", "none").after(addHtml);
  134. $(item).next().attr("data-status", "1");
  135. }
  136. else {
  137. $(item).css("display", "none").next().attr("data-status", "1");
  138. }
  139. if (underlineContentText.indexOf("√") > -1) {
  140. $(this).parent().find(".checkbox").find("input").prop('checked', false);
  141. }
  142. $(item).css("color", "#ffffff");
  143. $(item).find(".wordStyle").css("color", "#ffffff");
  144. $(item).find(".phraseStyle").css("background-color", "#ffffff");
  145. });
  146. $(".yaoshi").attr("data-status", "0");
  147. $(".yaoshi").attr("src", PicInfo.yaoshiHideImgUrl);
  148. }
  149. }
  150. //页面加载完,原文 绑定事件
  151. function bindEventTeaOrignalYS() {
  152. var bodyWidth = $(document.body).width();
  153. //处理答题点
  154. $.each($(".yaoshi"), function (index, item) {
  155. $(item).attr('answer-id', index);
  156. });
  157. //给音频绑定一个ID
  158. $.each($(".audioImg"), function (index, item) {
  159. $(item).attr("audiourl", "");
  160. $(item).attr('audio-id', index);
  161. });
  162. //给视频图标处理
  163. $.each($(".videoImg"), function (index, item) {
  164. $(item).attr("audiourl", "");
  165. });
  166. //给口语图标处理
  167. $.each($(".oralLanguageImg"), function (index, item) {
  168. $(item).attr("audiourl", "");
  169. });
  170. //处理参考答案
  171. $.each($(".underlineContent"), function (index, item) {
  172. $(item).attr("data-text", $(item).html());
  173. });
  174. //去除多余的U空标签
  175. $.each($("u"), function (index, item) {
  176. var text = $(item).text();
  177. text = text.replace(/\s+/g, "");
  178. if (text == "") {
  179. $(item).remove();
  180. }
  181. });
  182. //处理暂无参考答案
  183. $.each($(".yaoshi"), function (index, item) {
  184. var parent = $(item).parent();
  185. var prev = $(item).nextUntil(".yaoshi").find(".underlineContent");
  186. if (prev.length == 0) {
  187. var spanHtml = document.createElement("span");
  188. //添加子节点
  189. var uHtml = document.createElement("u");
  190. uHtml.className = "underlineContent no-answer";
  191. uHtml.innerText = "暂无参考答案";
  192. if ($(parent)[0].tagName == 'P') {
  193. if ($(parent).hasClass('correntQue') || $(parent).hasClass('boxQue')) {
  194. uHtml.innerHTML = "&nbsp;&nbsp;&nbsp;";
  195. }
  196. }
  197. uHtml.setAttribute("data-text", uHtml.innerText);
  198. $(spanHtml).html(uHtml.outerHTML);
  199. $(item).after(spanHtml);
  200. }
  201. });
  202. //处理表格宽度
  203. $.each($(".container-table"), function (index, item) {
  204. $(item).css("width", bodyWidth + "px");
  205. });
  206. //一题多空的答题点标注
  207. var checkId = 0;
  208. var headid = -1;
  209. var groupId = -1;
  210. $(".multipleStart").each(function (i, item) {
  211. var $startNode = $(item);
  212. $.merge($(item).nextUntil(".multipleEnd").filter("[class*='group']"), $(item).nextUntil(".multipleEnd").find("[class*='group']")).each(function (index, item) {
  213. checkId = $(item).find('.yaoshi').attr("answer-id");
  214. var gid = $(item).attr('class').replace(/.*group(\d+).*/g, "$1");
  215. if (index == 0 || groupId != gid) {
  216. groupId = gid;
  217. headid = checkId;
  218. }
  219. $(item).find('.yaoshi').attr('parent-anid', headid);
  220. });
  221. });
  222. //显示/隐藏习题答案
  223. $(".yaoshi").on("click", function () {
  224. var curDisplay = $(this).nextUntil(".yaoshi").find(".underlineContent").eq(0).css("display");
  225. if (curDisplay == "undefined" || curDisplay == undefined) return;
  226. if (curDisplay == "none" || $(this).attr("data-status") == "0") {
  227. $(this).attr("data-status", "1");
  228. $(this).attr("src", PicInfo.yaoshiShowImgUrl);
  229. //$(this).nextUntil(".yaoshi").find(".underlineContent").show();
  230. //$(this).nextUntil(".yaoshi").find(".underlineContent").css("color", "#92D050");
  231. $.each($(this).nextUntil(".yaoshi").find(".underlineContent"), function (index, item) {
  232. if (!$(item).hasClass("no-answer")) {
  233. $(item).css("color", "#92D050");
  234. }
  235. else {
  236. $(item).css("color", "#989898");
  237. }
  238. $(item).find(".wordStyle").css("color", "#db5d00");
  239. $(item).find(".phraseStyle").css("background-color", "#f2db8b");
  240. });
  241. //不再存在已隐藏的钥匙,移动端回调
  242. if ($(".yaoshi[data-status='0']").length == 0) {
  243. //添加回调
  244. console.log("全部显示了");
  245. }
  246. } else {
  247. $(this).attr("data-status", "0");
  248. $(this).attr("src", PicInfo.yaoshiHideImgUrl);
  249. //$(this).nextUntil(".yaoshi").find(".underlineContent").hide();
  250. //$(this).nextUntil(".yaoshi").find(".underlineContent").css("color", "#ffffff");
  251. $.each($(this).nextUntil(".yaoshi").filter(".underlineContent"), function (index, item) {
  252. $(item).css("color", "#ffffff");
  253. $(item).find(".wordStyle").css("color", "#ffffff");
  254. $(item).find(".phraseStyle").css("background-color", "#ffffff");
  255. });
  256. //添加回调
  257. onClickKeyHide();
  258. }
  259. });
  260. //点击喇叭事件,音频播放
  261. $(".audioImg").on("click", function () {
  262. audioPlayClick(this);
  263. });
  264. //点击播放事件,视频播放
  265. $(".videoImg").on("click", function () {
  266. var curHtml = $(this).parent().find(".videoUrl").html();
  267. var curAlt = $(this).attr("alt");//播放视频地址
  268. playVisiableAudioCallBack(2, $(this).attr("alt"));
  269. });
  270. //处理表格样式
  271. $("td").attr("style", "");
  272. }
  273. //页面加载完,课件 绑定事件
  274. function bindEventYS() {
  275. var bodyWidth = $(document.body).width();
  276. //不存在underline 属性下有内容,所以全部隐藏,若有就是源头数据有问题
  277. $('.underline').css("display", "none");
  278. $.each($(".yaoshi"), function (index, item) {
  279. $(item).attr('answer-id', index);
  280. });
  281. //给音频绑定一个ID
  282. $.each($(".audioImg"), function (index, item) {
  283. $(item).attr("audiourl", "");
  284. $(item).attr('audio-id', index);
  285. });
  286. //给视频图标处理
  287. $.each($(".videoImg"), function (index, item) {
  288. $(item).attr("audiourl", "");
  289. });
  290. //给口语图标处理
  291. $.each($(".oralLanguageImg"), function (index, item) {
  292. $(item).attr("audiourl", "");
  293. });
  294. //去除多余的U空标签
  295. $.each($("u"), function (index, item) {
  296. var text = $(item).text();
  297. text = text.replace(/\s+/g, "");
  298. if (text == "") {
  299. $(item).remove();
  300. }
  301. });
  302. //处理暂无参考答案
  303. $.each($(".yaoshi"), function (index, item) {
  304. var parent = $(item).parent();
  305. var prev = $(item).nextAll(".underlineContent");
  306. if (prev.length == 0) {
  307. var uHtml = document.createElement("u");
  308. uHtml.className = "underlineContent no-answer";
  309. uHtml.innerText = "暂无参考答案";
  310. if ($(parent)[0].tagName == 'P') {
  311. if ($(parent).hasClass('correntQue') || $(parent).hasClass('boxQue')) {
  312. uHtml.innerHTML = "&nbsp;&nbsp;&nbsp;";
  313. }
  314. }
  315. uHtml.setAttribute("data-text", uHtml.innerText);
  316. $(item).after(uHtml);
  317. }
  318. });
  319. //处理表格宽度
  320. $.each($(".container-table"), function (index, item) {
  321. $(item).css("width", bodyWidth + "px");
  322. });
  323. //一题多空的答题点标注
  324. var checkId = 0;
  325. var headid = -1;
  326. var groupId = -1;
  327. $(".multipleStart").each(function (i, item) {
  328. var $startNode = $(item);
  329. $.merge($(item).nextUntil(".multipleEnd").filter("[class*='group']"), $(item).nextUntil(".multipleEnd").find("[class*='group']")).each(function (index, item) {
  330. checkId = $(item).find('.yaoshi').attr("answer-id");
  331. var gid = $(item).attr('class').replace(/.*group(\d+).*/g, "$1");
  332. if (index == 0 || groupId != gid) {
  333. groupId = gid;
  334. headid = checkId;
  335. }
  336. $(item).find('.yaoshi').attr('parent-anid', headid);
  337. });
  338. });
  339. //显示/隐藏习题答案
  340. $(".yaoshi").on("click", function () {
  341. var parentAnid = $(this).attr("parent-anid");
  342. if ($(this).attr("data-status") == "0") {
  343. // 显示处理
  344. if (parentAnid != undefined) {
  345. $.each($(this).parents().find(".yaoshi[parent-anid='" + parentAnid + "']"), function (index, fItem) {
  346. $(fItem).attr("data-status", "1");
  347. $(fItem).attr("src", PicInfo.yaoshiShowImgUrl);
  348. $.each($(fItem).parent().find(".underlineContent"), function (index, item) {
  349. var underlineContentText = $(this).text(); // 获取文本内容
  350. var widthValue = $(item).css("width");
  351. var newClsName = $(item).next().attr("class");
  352. if (newClsName != "underlineContentShow") {
  353. var addHtml = "";
  354. if (hasChineseWorld(underlineContentText)) {
  355. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&emsp;</span>";
  356. }
  357. else {
  358. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&nbsp;</span>";
  359. }
  360. $(item).css("display", "inline-block").after(addHtml);
  361. }
  362. else {
  363. $(item).css("display", "inline-block").next().attr("data-status", "0");
  364. }
  365. if (underlineContentText.indexOf("√") > -1) {
  366. $(this).parent().find(".checkbox").find("input").prop('checked', true);
  367. }
  368. if (!$(item).hasClass("no-answer")) {
  369. $(item).css("color", "#92D050");
  370. }
  371. else {
  372. $(item).css("color", "#989898");
  373. }
  374. $(item).find(".wordStyle").css("color", "#db5d00");
  375. $(item).find(".phraseStyle").css("background-color", "#f2db8b");
  376. });
  377. });
  378. }
  379. else{
  380. $(this).attr("data-status", "1");
  381. $(this).attr("src", PicInfo.yaoshiShowImgUrl);
  382. //$(this).nextUntil(".yaoshi").filter(".underlineContent").css("color", "#92D050");
  383. $.each($(this).nextUntil(".yaoshi").filter(".underlineContent"), function (index, item) {
  384. var underlineContentText = $(this).text(); // 获取文本内容
  385. var widthValue = $(item).css("width");
  386. var newClsName = $(item).next().attr("class");
  387. if (newClsName != "underlineContentShow") {
  388. var addHtml = "";
  389. if (hasChineseWorld(underlineContentText)) {
  390. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&emsp;</span>";
  391. }
  392. else {
  393. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&nbsp;</span>";
  394. }
  395. $(item).css("display", "inline-block").after(addHtml);
  396. }
  397. else {
  398. $(item).css("display", "inline-block").next().attr("data-status", "0");
  399. }
  400. if (underlineContentText.indexOf("√") > -1) {
  401. $(this).parent().find(".checkbox").find("input").prop('checked', true);
  402. }
  403. if (!$(item).hasClass("no-answer")) {
  404. $(item).css("color", "#92D050");
  405. }
  406. else {
  407. $(item).css("color", "#989898");
  408. }
  409. $(item).find(".wordStyle").css("color", "#db5d00");
  410. $(item).find(".phraseStyle").css("background-color", "#f2db8b");
  411. });
  412. }
  413. //不再存在已隐藏的钥匙,移动端回调
  414. if ($(".yaoshi[data-status='0']").length == 0) {
  415. //添加回调
  416. console.log("全部显示了");
  417. }
  418. }
  419. else {
  420. // 隐藏处理
  421. if (parentAnid != undefined) {
  422. $.each($(this).parents().find(".yaoshi[parent-anid='" + parentAnid + "']"), function (index, fItem) {
  423. $(fItem).attr("data-status", "0");
  424. $(fItem).attr("src", PicInfo.yaoshiHideImgUrl);
  425. $.each($(fItem).parent().find(".underlineContent"), function (index, item) {
  426. var underlineContentText = $(this).text(); // 获取文本内容
  427. var widthValue = $(item).css("width");
  428. var newClsName = $(item).next().attr("class");
  429. if (newClsName != "underlineContentShow") {
  430. var addHtml = "";
  431. if (hasChineseWorld(underlineContentText)) {
  432. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&emsp;</span>";
  433. }
  434. else {
  435. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&nbsp;</span>";
  436. }
  437. $(item).css("display", "none").after(addHtml);
  438. $(item).next().attr("data-status", "1");
  439. }
  440. else {
  441. $(item).css("display", "none").next().attr("data-status", "1");
  442. }
  443. if (underlineContentText.indexOf("√") > -1) {
  444. $(this).parent().find(".checkbox").find("input").prop('checked', false);
  445. }
  446. $(item).css("color", "#ffffff");
  447. $(item).find(".wordStyle").css("color", "#ffffff");
  448. $(item).find(".phraseStyle").css("background-color", "#ffffff");
  449. });
  450. });
  451. }
  452. else {
  453. $(this).attr("data-status", "0");
  454. $(this).attr("src", PicInfo.yaoshiHideImgUrl);
  455. //$(this).nextUntil(".yaoshi").filter(".underlineContent").css("color", "#ffffff");
  456. $.each($(this).nextUntil(".yaoshi").filter(".underlineContent"), function (index, item) {
  457. var underlineContentText = $(this).text(); // 获取文本内容
  458. var widthValue = $(item).css("width");
  459. var newClsName = $(item).next().attr("class");
  460. if (newClsName != "underlineContentShow") {
  461. var addHtml = "";
  462. if (hasChineseWorld(underlineContentText)) {
  463. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&emsp;</span>";
  464. }
  465. else {
  466. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&nbsp;</span>";
  467. }
  468. $(item).css("display", "none").after(addHtml);
  469. $(item).next().attr("data-status", "1");
  470. }
  471. else {
  472. $(item).css("display", "none").next().attr("data-status", "1");
  473. }
  474. if (underlineContentText.indexOf("√") > -1) {
  475. $(this).parent().find(".checkbox").find("input").prop('checked', false);
  476. }
  477. $(item).css("color", "#ffffff");
  478. $(item).find(".wordStyle").css("color", "#ffffff");
  479. $(item).find(".phraseStyle").css("background-color", "#ffffff");
  480. });
  481. }
  482. //添加回调
  483. onClickKeyHide();
  484. }
  485. });
  486. //点击喇叭事件,音频播放
  487. $(".audioImg").on("click", function () {
  488. audioPlayClick(this);
  489. });
  490. //点击播放事件,视频播放
  491. $(".videoImg").on("click", function () {
  492. $(this).attr("audiourl", "");
  493. var curHtml = $(this).parent().find(".videoUrl").html();
  494. var curAlt = $(this).attr("alt");//播放视频地址
  495. playVisiableAudioCallBack(2, $(this).attr("alt"));
  496. });
  497. //处理表格样式
  498. $("td").attr("style", "");
  499. $(".container-table").on("touchstart", function () {
  500. pressTableFlag = true;
  501. }).on("touchend", function () {
  502. pressTableFlag = false;
  503. });
  504. }
  505. var pressTableFlag = false;
  506. // 移动端使用,true:表示点击表格且正在移动,需阻止模块切换
  507. function getPressFlag() {
  508. alert(pressTableFlag);
  509. }
  510. // 判断是否存在中文(true表示存在)
  511. var hasChineseWorld = function (dataStr) {
  512. if (escape(dataStr).indexOf("%u") < 0)
  513. {
  514. return false;
  515. }
  516. else
  517. {
  518. return true;
  519. }
  520. };
  521. //学生端 处理作答区域
  522. var answerData = new Array();
  523. function handleAnswerRange() {
  524. //规范文本格式
  525. var answerId = "";
  526. var tempJson = new Array();
  527. //先处理一题多空的情况,获取两个之间的答题点
  528. $(".multipleStart").each(function (i, item) {
  529. $.merge($(item).nextUntil(".multipleEnd").filter("[class*='group']"), $(item).nextUntil(".multipleEnd").find("[class*='group']")).each(function (index, item) {
  530. var checkId = $(item).find('.yaoshi').attr("answer-id");
  531. var headid = $(item).find('.yaoshi').attr("parent-anid");
  532. var ischecked = $(item).find(".underlineContent").text().indexOf("√") > -1;
  533. var answerText = ischecked ? "√" : "";
  534. //勾选题
  535. if ($(item).hasClass('boxQue')) {
  536. $(item).find('.yaoshi').after("<div class='checkbox' answer-id='" + checkId + "' parent-anid='" + headid + "' answer-isky='2' answer-anstext=" + answerText + "><input id=" + checkId + " type='checkbox'><label for=" + checkId + "></label></div>");
  537. //$(item).find('input').prop('checked', ischecked);
  538. $(item).find('.underlineContent').hide();
  539. }
  540. //点击事件
  541. $(item).find('input').bind("click", function () {
  542. var curObj = new Object();
  543. curObj.Id = $(this).parent().attr("answer-id");//答题点ID
  544. curObj.pId = $(this).parent().attr("parent-anid");//答题点ID
  545. curObj.IsKY = $(this).parent().attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题,2-打勾题
  546. //curObj.Text = $(this).parent().attr("answer-text");//用户作答内容
  547. curObj.Score = $(this).parent().attr("answer-score");//作答评分
  548. curObj.AnsText = $(this).parent().attr("answer-anstext");//参考答案
  549. curObj.Comment = $(this).parent().attr("answer-comment");//评语
  550. curObj.pId = curObj.pId ? curObj.pId : curObj.Id;//组ID
  551. curObj.Text = $(this).prop("checked") ? "√" : "";//用户作答内容
  552. $(this).parent().attr("answer-text", curObj.Text);//用户作答内容
  553. $(".checkbox").removeClass("select-answer");
  554. $(".answer-body").removeClass("select-answer");
  555. $(this).parent().addClass("select-answer");
  556. //已作答,弹出作答答案
  557. if ($(this).parent().data("ans-status") == "1") {
  558. //移动端添加外部处理
  559. onClickAnswerPoint(JSON.stringify(curObj));
  560. }
  561. else {
  562. //移动端添加外部处理,弹出作答操作
  563. onClickAnswerPoint(JSON.stringify(curObj));
  564. }
  565. });
  566. //删除钥匙节点
  567. $(item).find('.yaoshi').hide();
  568. });
  569. });
  570. //所有underline不做处理
  571. $.each($(".yaoshi").nextUntil(".yaoshi").filter(".underline"), function (index, item) {
  572. tempId = $(item).prevAll(".yaoshi").attr("answer-id");
  573. //记录上一次的ID
  574. if (tempId == undefined) {
  575. tempId = answerId;
  576. }
  577. else {
  578. answerId = tempId;
  579. }
  580. var prev = $(item).prev();
  581. if ((prev.length == 0 || $(prev).attr("class") != "tag-span") && $(prev).attr("class") != "underlineContent") {
  582. if ($("span[answer-id='" + tempId + "']").length == 0) {
  583. $(item).prop("outerHTML", "<span answer-id='" + tempId + "' class='tag-span' answer-isky='0'>_</span>");
  584. }
  585. }
  586. $(item).remove();
  587. });
  588. //提取参考答案并规范文本格式
  589. answerId = "";
  590. $.each($(".yaoshi").nextUntil(".yaoshi").filter(".underlineContent"), function (index, item) {
  591. var info = new Object();
  592. info.Id = $(item).prevAll(".yaoshi").attr("answer-id");
  593. info.pId = $(item).prevAll(".yaoshi").attr("parent-anid");
  594. //记录上一次的ID
  595. if (info.Id == undefined) {
  596. info.Id = answerId;
  597. }
  598. else {
  599. answerId = info.Id;
  600. }
  601. if (info.pId == undefined) {
  602. info.pId = answerId;
  603. }
  604. info.AnsText = $(item).text();
  605. tempJson.push(info);
  606. var prev = $(item).prev();
  607. if (!$(prev).hasClass("checkbox")) {
  608. if (prev.length == 0 || $(prev).attr("class") != "tag-span") {
  609. //替换答案
  610. $(item).prop("outerHTML", "<span answer-id='" + info.Id + "' class='tag-span' answer-isky='0'>_</span>");
  611. }
  612. else {
  613. $(item).remove();
  614. }
  615. }
  616. });
  617. //补充空钥匙的处理
  618. $.each($(".yaoshi"), function (index, item) {
  619. var Id = $(item).attr("answer-id");
  620. var prev = $(item).next();
  621. if (!$(prev).hasClass("checkbox")) {
  622. if (prev.length == 0 || $(prev).attr("class") != "tag-span") {
  623. if ($("span[answer-id='" + Id + "']").length == 0) {
  624. var uHtml = document.createElement("span");
  625. uHtml.className = "tag-span";
  626. uHtml.innerText = "_";
  627. uHtml.setAttribute("answer-id", Id);
  628. $(item).after(uHtml);
  629. }
  630. }
  631. }
  632. });
  633. //处理口语试题
  634. $.each($(".oralLanguage").nextUntil(".oralLanguageDone"), function (num, part) {
  635. if (part.tagName != "p") {
  636. $.each($(part).find(".tag-span"), function (index, item) {
  637. $(item).attr("answer-isky", "1");
  638. });
  639. }
  640. else {
  641. if ($(part).hasClass("underlinePart")) {
  642. $.each($(part).find(".tag-span"), function (index, item) {
  643. $(item).attr("answer-isky", "1");
  644. });
  645. }
  646. }
  647. });
  648. //合并参考答案数据
  649. var tempid = "";
  650. var temppid = "";
  651. var temptext = "";
  652. for (var i = 0; i < tempJson.length; i++) {
  653. if (tempid == tempJson[i].Id) {
  654. temptext = temptext + tempJson[i].AnsText;
  655. }
  656. else {
  657. if (tempid != "") {
  658. var info = new Object();
  659. info.Id = tempid;
  660. info.pId = temppid;
  661. info.AnsText = temptext;
  662. answerData.push(info);
  663. //重置
  664. tempid = "";
  665. temptext = "";
  666. }
  667. tempid = tempJson[i].Id;
  668. temppid = tempJson[i].pId;
  669. temptext = tempJson[i].AnsText;
  670. //最后一个存入
  671. if (i == tempJson.length - 1) {
  672. var info = new Object();
  673. info.Id = tempid;
  674. info.pId = temppid;
  675. info.AnsText = temptext;
  676. answerData.push(info);
  677. }
  678. }
  679. }
  680. //补全答题点
  681. var Num = 0;
  682. if (answerData.length > 0) {
  683. //Num = Number.parseInt(answerData[answerData.length - 1].Id);
  684. Num = Number.parseInt($(".yaoshi:last").attr('answer-id'));
  685. for (var i = 0; i < Num + 1; i++) {
  686. if (i < answerData.length) {
  687. var index = Number(answerData[i].Id) - i;
  688. for (var j = 0; j < index; j++) {
  689. var info = new Object();
  690. info.Id = (i + j).toString();
  691. info.pId = info.Id;
  692. info.AnsText = "";
  693. answerData.splice(i, 0, info);
  694. }
  695. }
  696. else {
  697. var info = new Object();
  698. info.Id = (i).toString();
  699. info.pId = info.Id;
  700. info.AnsText = "";
  701. answerData.splice(i, 0, info);
  702. }
  703. }
  704. }
  705. //添加答题点的点击UI及交互
  706. $.each($(".tag-span"), function (index, item) {
  707. var answerText = "";
  708. var isky = $(item).attr('answer-isky');
  709. var answerid = $(item).attr('answer-id');
  710. for (var i = 0; i < answerData.length; i++) {
  711. if (answerid == answerData[i].Id) {
  712. answerText = answerData[i].AnsText;
  713. break;
  714. }
  715. }
  716. $(item).prop("outerHTML", "<div class='answer-body' answer-id='" + answerid + "' answer-anstext='" + answerText + "' answer-isky='" + isky + "' answer-showanswer='0'><div class='answer-audio-range'><img src='" + PicInfo.recordPlayImgUrl + "'/><span class='answer-audio-text'>作答音频</span></div><div class='answer-point-range'><img src='" + PicInfo.answerPointImgUrl + "'/><span class='answer-point-text'>答题点</span></div><buttom class='answer-text'></buttom></div>");
  717. //删除钥匙节点
  718. var prev = $("img[answer-id='" + answerid + "']");
  719. if (prev.length > 0) {
  720. $(prev).remove();
  721. }
  722. });
  723. //添加点击事件
  724. $(".answer-body").on("click", function () {
  725. var curObj = new Object();
  726. curObj.Id = $(this).attr("answer-id");//答题点ID
  727. curObj.pId = $(this).attr("parent-anid");//答题点ID
  728. curObj.IsKY = $(this).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
  729. curObj.Text = $(this).attr("answer-text");//用户作答内容
  730. curObj.Score = $(this).attr("answer-score");//作答评分
  731. curObj.AnsText = $(this).attr("answer-anstext");//参考答案
  732. curObj.Comment = $(this).attr("answer-comment");//评语
  733. curObj.pId = curObj.pId ? curObj.pId : curObj.Id;//组ID
  734. $(".checkbox").removeClass("select-answer");
  735. $(".answer-body").removeClass("select-answer");
  736. $(this).addClass("select-answer");
  737. //已作答,弹出作答答案
  738. if ($(this).data("ans-status") == "1") {
  739. //移动端添加外部处理
  740. onClickAnswerPoint(JSON.stringify(curObj));
  741. }
  742. else {
  743. //移动端添加外部处理,弹出作答操作
  744. onClickAnswerPoint(JSON.stringify(curObj));
  745. }
  746. });
  747. //去除多余的空格横线
  748. $.each($(".underline"), function (index, item) {
  749. var text = $(item).text();
  750. text = text.replace(/\s+/g, "");
  751. if (text == "") {
  752. $(item).remove();
  753. }
  754. });
  755. //删除所有钥匙节点
  756. $("img[class=yaoshi]").remove();
  757. //console.log(JSON.stringify(answerData));
  758. return answerData;
  759. }
  760. //接收学生的作答
  761. function reviewAnswer(answerJson) {
  762. if (answerJson != "" && answerJson) {
  763. var answerObj = JSON.parse(answerJson);
  764. var selectElement = $(".answer-body[answer-id='" + answerObj.Id + "']");
  765. var audioElement = $(selectElement).children(".answer-audio-range").children("img").eq(0);
  766. answerObj.IsKY = $(selectElement).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
  767. //是否为音频作答
  768. if ((answerObj.Type == 3 || answerObj.Type == 4) && answerObj.AudioUrl != "") {
  769. $(selectElement).children(".answer-point-range").hide();
  770. $(selectElement).children(".answer-audio-range").css("display", "inline-block");
  771. $(selectElement).children(".answer-audio-range").children("span").text("作答音频(" + answerObj.AudioLength + "s)");
  772. //填充作答内容
  773. $(selectElement).attr("answer-text", answerObj.Text);
  774. if (answerObj.Text != "") {
  775. answerObj.Text = "(" + answerObj.Text + ")";
  776. $(selectElement).children(".answer-text").show();
  777. $(selectElement).children(".answer-text").text(answerObj.Text);
  778. }
  779. //是否之前存在作答音频
  780. $(selectElement).attr("answer-url", answerObj.AudioUrl);
  781. $(audioElement).attr("src", PicInfo.recordPlayImgUrl);
  782. $(selectElement).children(".answer-audio-range").attr("play-status", "0");
  783. //独立绑定事件
  784. $(audioElement).on("click", function () {
  785. recordAudioClick(this, answerObj.Id, answerObj.AudioUrl);
  786. });
  787. $(selectElement).children(".answer-audio-range").children("span").on("click", function () {
  788. $(".answer-body").removeClass("select-answer");
  789. $(selectElement).addClass("select-answer");
  790. onClickAnswerPoint(JSON.stringify(answerObj));
  791. });
  792. }
  793. else {
  794. $(selectElement).attr("answer-text", answerObj.Text);//填充作答内容
  795. $(selectElement).children(".answer-audio-range").hide();
  796. if (answerObj.Text != "") {
  797. $(selectElement).children(".answer-text").show();
  798. $(selectElement).children(".answer-point-range").hide();
  799. $(selectElement).children(".answer-text").text(answerObj.Text);
  800. }
  801. else {
  802. $(selectElement).children(".answer-text").hide();
  803. $(selectElement).children(".answer-point-range").show();
  804. }
  805. }
  806. }
  807. }
  808. //提交,获取所有作答答案及参考答案
  809. function getAllAnswer() {
  810. //处理作答
  811. $.each($(".answer-body"), function (index, item) {
  812. var mytext = $(item).children(".answer-text").text();
  813. var curDisplay = $(item).children(".answer-audio-range").css("display");
  814. if (mytext == "" && curDisplay == "none") {
  815. mytext = "未作答";
  816. $(item).children(".answer-point-range").hide();
  817. $(item).children(".answer-text").show();
  818. $(item).children(".answer-text").text(mytext);
  819. $(item).children(".answer-text").addClass("no-answer");
  820. }
  821. });
  822. $(".answer-body").removeClass("select-answer");//移除样式
  823. $(".answer-body").unbind("click");//取消点击绑定事件
  824. $(".answer-body").children(".answer-audio-range").children("span").unbind("click");//取消点击绑定事件
  825. //打勾题的还原
  826. $.each($(".checkbox"), function (num, item) {
  827. var answerid = $(item).attr("answer-id");
  828. var parentid = $(item).attr("parent-anid");
  829. //提交直接还原作答现场
  830. var mytext = $(item).attr("answer-text");//我的答案
  831. var ischecked = mytext.indexOf("√") > -1;
  832. var answerText = $(item).attr("answer-anstext");//参考答案
  833. mytext = mytext == "" ? "__" : mytext;
  834. $(item).prop("outerHTML", "<div class='answer-body' answer-id='" + answerid + "' parent-anid='" + parentid + "' answer-anstext='" + answerText + "' answer-isky='2'><div class='answer-audio-range'><img src='" + PicInfo.recordPlayImgUrl + "'/><span class='answer-audio-text'>作答音频</span></div><div class='answer-point-range' style='display:none;'><img src='" + PicInfo.answerPointImgUrl + "'/><span class='answer-point-text'>答题点</span></div><buttom class='answer-text' style='display:block;'>" + mytext + "</buttom></div>");
  835. });
  836. //console.log(JSON.stringify(answerData));
  837. return answerData;
  838. }
  839. //回填所有答案,answerJson:所有作答及参考答案List,statusType:0-可作答,1-已提交,2-查看评阅
  840. function backupAllAnswer(answerJson, statusType) {
  841. if (answerJson != "" && answerJson) {
  842. var answerList = JSON.parse(answerJson);
  843. $.each($(".answer-body"), function (num, item) {
  844. //查找
  845. var index = 0;
  846. var answerid = $(item).attr("answer-id");
  847. for (var i = 0; i < answerList.length; i++) {
  848. if (answerid == answerList[i].Id) {
  849. index = i;
  850. break;
  851. }
  852. }
  853. //提交直接还原作答现场
  854. var mytext = answerList[index].Text;//我的答案
  855. answerList[index].IsKY = $(item).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
  856. //添加音频控制
  857. var audioElement = $(item).children(".answer-audio-range").children("img").eq(0);
  858. if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
  859. $(item).children(".answer-point-range").hide();
  860. $(item).children(".answer-audio-range").css("display", "inline-block");
  861. $(item).children(".answer-audio-range").children("span").text("作答音频(" + answerList[index].AudioLength + "s)");
  862. //填充作答内容
  863. $(item).attr("answer-text", mytext);
  864. if (mytext != "") {
  865. mytext = "(" + mytext + ")";
  866. $(item).children(".answer-text").show();
  867. $(item).children(".answer-text").text(mytext);
  868. }
  869. //音频节点
  870. $(audioElement).attr("src", PicInfo.recordPlayImgUrl);
  871. $(item).attr("answer-url", answerList[index].AudioUrl);
  872. $(item).children(".answer-audio-range").attr("play-status", "0");
  873. //独立绑定事件
  874. $(audioElement).on("click", function () {
  875. recordAudioClick(this, answerList[index].Id, answerList[index].AudioUrl);
  876. });
  877. }
  878. //可作答状态,作答还原
  879. if (statusType == 0) {
  880. //已作答过,还原作答,增加作答后的UI节点
  881. if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
  882. $(item).children(".answer-audio-range").children("span").on("click", function () {
  883. $(".answer-body").removeClass("select-answer");
  884. $(item).addClass("select-answer");
  885. onClickAnswerPoint(JSON.stringify(answerList[index]));
  886. });
  887. }
  888. else {
  889. $(item).attr("answer-text", mytext);//填充作答内容
  890. if (mytext != "") {
  891. $(item).children(".answer-text").show();
  892. $(item).children(".answer-point-range").hide();
  893. $(item).children(".answer-text").text(mytext);
  894. }
  895. }
  896. }
  897. //已提交,作答还原
  898. if (statusType == 1) {
  899. //取消点击绑定事件
  900. $(item).unbind('click');
  901. //填充作答内容
  902. $(item).attr("answer-text", mytext);
  903. if (mytext == "") {
  904. mytext = "未作答";
  905. $(item).children(".answer-text").addClass("no-answer");
  906. }
  907. $(item).children(".answer-text").show();
  908. $(item).children(".answer-text").text(mytext);
  909. $(item).children(".answer-point-range").hide();
  910. }
  911. //已评阅,查看评阅详情
  912. if (statusType == 2) {
  913. $(item).attr("answer-showanswer", "1"); // 修改显示格式
  914. //添加音频控制
  915. if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
  916. //独立绑定事件
  917. $(item).children(".answer-audio-range").children("span").on("click", function () {
  918. $(".answer-body").removeClass("select-answer");
  919. $(item).addClass("select-answer");
  920. onClickAnswerPoint(JSON.stringify(answerList[index]));
  921. });
  922. }
  923. else {
  924. $(item).attr("answer-text", mytext);//填充作答内容
  925. if (mytext == "") {
  926. mytext = "未作答";
  927. $(item).children(".answer-text").addClass("no-answer");
  928. }
  929. $(item).children(".answer-text").show();
  930. $(item).children(".answer-text").text(mytext);
  931. $(item).children(".answer-point-range").hide();
  932. }
  933. //评阅样式
  934. if (answerList[index].Score == 0 && answerList[index].Text != "") {
  935. $(item).children(".answer-text").addClass("bad-answer");
  936. }
  937. if (answerList[index].Score > 0) {
  938. $(item).children(".answer-text").addClass("good-answer");
  939. }
  940. }
  941. });
  942. //打勾题的还原
  943. $.each($(".checkbox"), function (num, item) {
  944. //可作答状态,作答还原
  945. //查找
  946. var index = 0;
  947. var answerid = $(item).attr("answer-id");
  948. var parentid = $(item).attr("parent-anid");
  949. for (var i = 0; i < answerList.length; i++) {
  950. if (answerid == answerList[i].Id) {
  951. index = i;
  952. break;
  953. }
  954. }
  955. //提交直接还原作答现场
  956. var mytext = answerList[index].Text;//我的答案
  957. var ischecked = mytext.indexOf("√") > -1;
  958. var answerText = $(item).attr("answer-anstext");//参考答案
  959. $(item).attr("answer-text", mytext);
  960. $(item).find('input').prop('checked', ischecked);
  961. //已提交,已评阅,还原HTML代码,去除checkbox
  962. if (statusType == 1 || statusType == 2) {
  963. mytext = mytext == "" ? "__" : mytext;
  964. $(item).prop("outerHTML", "<div class='answer-body' answer-id='" + answerid + "' parent-anid='" + parentid + "' answer-anstext='" + answerText + "' answer-isky='2' answer-text='" + mytext + "'><div class='answer-audio-range'><img src='" + PicInfo.recordPlayImgUrl + "'/><span class='answer-audio-text'>作答音频</span></div><div class='answer-point-range' style='display:none;'><img src='" + PicInfo.answerPointImgUrl + "'/><span class='answer-point-text'>答题点</span></div><buttom class='answer-text' style='display:block;'>" + mytext + "</buttom></div>");
  965. }
  966. });
  967. //点击事件重新绑定
  968. if (statusType == 0 || statusType == 2) {
  969. $(".answer-body").unbind("click").on("click", function () {
  970. var curObj = new Object();
  971. curObj.Id = $(this).attr("answer-id");//答题点ID
  972. curObj.pId = $(this).attr("parent-anid");//答题点ID
  973. curObj.IsKY = $(this).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
  974. curObj.Text = $(this).attr("answer-text");//用户作答内容
  975. curObj.Score = $(this).attr("answer-score");//作答评分
  976. curObj.AnsText = $(this).attr("answer-anstext");//参考答案
  977. curObj.Comment = $(this).attr("answer-comment");//评语
  978. curObj.pId = curObj.pId ? curObj.pId : curObj.Id;//组ID
  979. $(".checkbox").removeClass("select-answer");
  980. $(".answer-body").removeClass("select-answer");
  981. $(this).addClass("select-answer");
  982. //已作答,弹出作答答案
  983. if ($(this).data("ans-status") == "1") {
  984. //移动端添加外部处理
  985. onClickAnswerPoint(JSON.stringify(curObj));
  986. }
  987. else {
  988. //移动端添加外部处理,弹出作答操作
  989. onClickAnswerPoint(JSON.stringify(curObj));
  990. }
  991. });
  992. }
  993. }
  994. }
  995. //老师评阅学生作答
  996. function reviewStuAnswer(answerJson) {
  997. if (answerJson != "" && answerJson) {
  998. var answerObj = JSON.parse(answerJson);
  999. var selectElement = $(".answer-body[answer-id='" + answerObj.Id + "']");
  1000. //$(selectElement).attr("answer-text", answerObj.Text);//用户作答内容
  1001. $(selectElement).attr("answer-score", answerObj.Score);//作答评分
  1002. $(selectElement).attr("answer-anstext ", answerObj.AnsText);//参考答案
  1003. $(selectElement).attr("answer-comment", answerObj.Comment);//评语
  1004. //评阅样式
  1005. if (answerObj.Score == 0) {
  1006. $(selectElement).children(".answer-text").removeClass("good-answer");
  1007. $(selectElement).children(".answer-text").addClass("bad-answer");
  1008. }
  1009. if (answerObj.Score > 0) {
  1010. $(selectElement).children(".answer-text").removeClass("bad-answer");
  1011. $(selectElement).children(".answer-text").addClass("good-answer");
  1012. }
  1013. }
  1014. }
  1015. //回填所有评阅信息,answerJson:所有作答及参考答案评阅信息List
  1016. function backupAllReview(answerJson) {
  1017. if (answerJson != "" && answerJson) {
  1018. var answerList = JSON.parse(answerJson);
  1019. $.each($(".answer-body"), function (num, item) {
  1020. //查找
  1021. var index = 0;
  1022. var answerid = $(item).attr("answer-id");
  1023. for (var i = 0; i < answerList.length; i++) {
  1024. if (answerid == answerList[i].Id) {
  1025. index = i;
  1026. break;
  1027. }
  1028. }
  1029. //$(item).attr("answer-id", answerList[index].Id);//答题点ID
  1030. //$(item).attr("answer-text", answerList[index].Text);//用户作答内容
  1031. $(item).attr("answer-score", answerList[index].Score);//作答评分
  1032. $(item).attr("answer-anstext ", answerList[index].AnsText);//参考答案
  1033. $(item).attr("answer-comment", answerList[index].Comment);//评语
  1034. //提交直接还原作答现场
  1035. var mytext = answerList[index].Text;//我的答案
  1036. var audioElement = $(item).children(".answer-audio-range").children("img").eq(0);
  1037. if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
  1038. $(item).children(".answer-point-range").hide();
  1039. $(item).children(".answer-audio-range").css("display", "inline-block");
  1040. $(item).children(".answer-audio-range").children("span").text("作答音频(" + answerList[index].AudioLength + "s)");
  1041. //填充作答内容
  1042. $(item).attr("answer-text", mytext);
  1043. if (mytext != "") {
  1044. mytext = "(" + mytext + ")";
  1045. $(item).children(".answer-text").show();
  1046. $(item).children(".answer-text").text(mytext);
  1047. }
  1048. //是否之前存在作答音频
  1049. $(audioElement).attr("src", PicInfo.recordPlayImgUrl);
  1050. $(item).attr("answer-url", answerList[index].AudioUrl);
  1051. $(item).children(".answer-audio-range").attr("play-status", "0");
  1052. //独立绑定事件
  1053. $(audioElement).on("click", function () {
  1054. recordAudioClick(this, answerList[index].Id, answerList[index].AudioUrl);
  1055. });
  1056. $(item).children(".answer-audio-range").children("span").on("click", function () {
  1057. $(".answer-body").removeClass("select-answer");
  1058. $(item).addClass("select-answer");
  1059. onClickAnswerPoint(JSON.stringify(answerList[index]));
  1060. });
  1061. }
  1062. else {
  1063. $(item).attr("answer-text", mytext);//填充作答内容
  1064. if (mytext == "") {
  1065. mytext = "未作答";
  1066. $(item).children(".answer-text").addClass("no-answer");
  1067. }
  1068. $(item).children(".answer-text").show();
  1069. $(item).children(".answer-text").text(mytext);
  1070. $(item).children(".answer-point-range").hide();
  1071. }
  1072. //评阅样式
  1073. if (answerList[index].Score == 0) {
  1074. $(item).children(".answer-text").addClass("bad-answer");
  1075. }
  1076. if (answerList[index].Score > 0) {
  1077. $(item).children(".answer-text").addClass("good-answer");
  1078. }
  1079. });
  1080. //打勾题的还原
  1081. $.each($(".checkbox"), function (num, item) {
  1082. //查找
  1083. var index = 0;
  1084. var answerid = $(item).attr("answer-id");
  1085. var parentid = $(item).attr("parent-anid");
  1086. for (var i = 0; i < answerList.length; i++) {
  1087. if (answerid == answerList[i].Id) {
  1088. index = i;
  1089. break;
  1090. }
  1091. }
  1092. //提交直接还原作答现场
  1093. var mytext = answerList[index].Text;//我的答案
  1094. var ischecked = mytext.indexOf("√") > -1;
  1095. var answerText = $(item).attr("answer-anstext");//参考答案
  1096. mytext = mytext == "" ? "__" : mytext;
  1097. $(item).prop("outerHTML", "<div class='answer-body' answer-id='" + answerid + "' parent-anid='" + parentid + "' answer-anstext='" + answerText + "' answer-isky='2' answer-text='" + mytext + "'><div class='answer-audio-range'><img src='" + PicInfo.recordPlayImgUrl + "'/><span class='answer-audio-text'>作答音频</span></div><div class='answer-point-range' style='display:none;'><img src='" + PicInfo.answerPointImgUrl + "'/><span class='answer-point-text'>答题点</span></div><buttom class='answer-text' style='display:block;'>" + mytext + "</buttom></div>");
  1098. });
  1099. //点击事件重新绑定
  1100. $(".answer-body").unbind("click").on("click", function () {
  1101. var curObj = new Object();
  1102. curObj.Id = $(this).attr("answer-id");//答题点ID
  1103. curObj.pId = $(this).attr("parent-anid");//答题点ID
  1104. curObj.IsKY = $(this).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
  1105. curObj.Text = $(this).attr("answer-text");//用户作答内容
  1106. curObj.Score = $(this).attr("answer-score");//作答评分
  1107. curObj.AnsText = $(this).attr("answer-anstext");//参考答案
  1108. curObj.Comment = $(this).attr("answer-comment");//评语
  1109. curObj.pId = curObj.pId ? curObj.pId : curObj.Id;//组ID
  1110. $(".checkbox").removeClass("select-answer");
  1111. $(".answer-body").removeClass("select-answer");
  1112. $(this).addClass("select-answer");
  1113. //已作答,弹出作答答案
  1114. if ($(this).data("ans-status") == "1") {
  1115. //移动端添加外部处理
  1116. onClickAnswerPoint(JSON.stringify(curObj));
  1117. }
  1118. else {
  1119. //移动端添加外部处理,弹出作答操作
  1120. onClickAnswerPoint(JSON.stringify(curObj));
  1121. }
  1122. });
  1123. }
  1124. }
  1125. //处理播放录音,answerid:答题点ID,isPlay:是否播放(0-暂停,1-播放)
  1126. function playRecordAudio(answerid, isPlay) {
  1127. //获取其他正在播放的音频
  1128. var playing = $(".answer-body[answer-id='" + answerid + "']").children(".answer-audio-range");
  1129. if (playing.length > 0) {
  1130. if (isPlay == "1") {
  1131. $(playing).attr("play-status", "1");
  1132. $(playing).find("img").attr("src", PicInfo.recordPauseImgUrl);//移动端要根据本地路径替换
  1133. }
  1134. else {
  1135. $(playing).attr("play-status", "0");
  1136. $(playing).find("img").attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
  1137. }
  1138. }
  1139. }
  1140. //滚动到相应DIV
  1141. function scrollAnswer(answerid) {
  1142. //console.log(answerid);
  1143. $(".checkbox").removeClass("select-answer");
  1144. $(".answer-body").removeClass("select-answer");
  1145. var ansDom = $(".answer-body[parent-anid='" + answerid + "']");
  1146. if (ansDom.length == 0) {
  1147. ansDom = $(".checkbox[parent-anid='" + answerid + "']");
  1148. }
  1149. $(ansDom).addClass("select-answer");
  1150. var scroll_offset = $(ansDom).offset(); //得到box这个div层的offset,包含两个值,top和left
  1151. var offset_top = scroll_offset.top;
  1152. if (offset_top > 150) {
  1153. offset_top = offset_top - 200;
  1154. }
  1155. $("body,html").animate({
  1156. scrollTop: offset_top //让body的scrollTop等于pos的top,就实现了滚动
  1157. });
  1158. }
  1159. //暂停播放原文音频
  1160. function pauseTextAudio(audioid) {
  1161. //获取其他正在播放的音频
  1162. var playing = $(".audioImg[audio-id='" + audioid + "']");
  1163. if (playing.length > 0) {
  1164. $(playing).attr("play-status", "0");
  1165. $(playing).attr("src", PicInfo.audioPauseImgUrl);//移动端要根据本地 喇叭 路径替换
  1166. }
  1167. }
  1168. //原文音频播放按钮点击事件
  1169. function audioPlayClick(myobj) {
  1170. var curHtml = $(myobj).parent().find(".audioUrl").html();
  1171. var curAlt = $(myobj).attr("alt");
  1172. //处理当前按钮的状
  1173. if ($(myobj).attr("play-status") == "1") {
  1174. $(myobj).attr("play-status", "0");
  1175. $(myobj).attr("src", PicInfo.audioPauseImgUrl);//移动端要根据本地 喇叭 路径替换
  1176. }
  1177. else {
  1178. //停止其他作答音频播放
  1179. var isRecordPlaying = $(".answer-audio-range[play-status='1']");
  1180. if (isRecordPlaying.length > 0) {
  1181. $(isRecordPlaying).attr("play-status", "0");
  1182. $(isRecordPlaying).find("img").attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
  1183. }
  1184. //停止其他原文音频播放
  1185. var audioPlaying = $(".audioImg[play-status='1']");
  1186. if (audioPlaying.length > 0) {
  1187. $(audioPlaying).attr("play-status", "0");
  1188. $(audioPlaying).attr("src", PicInfo.audioPauseImgUrl);//移动端要根据本地 喇叭 路径替换
  1189. }
  1190. //设置播放状态
  1191. $(myobj).attr("play-status", "1");
  1192. $(myobj).attr("src", PicInfo.audioPlayImgUrl);//移动端要根据本地 喇叭 路径替换
  1193. }
  1194. var info = new Object();
  1195. info.Id = $(myobj).attr("audio-id");
  1196. info.AudioUrl = curAlt;
  1197. //移动端添加外部处理
  1198. playVisiableAudioCallBack(1, JSON.stringify(info));
  1199. }
  1200. //作答录音播放按钮点击事件
  1201. function recordAudioClick(myobj, id, url) {
  1202. //处理当前按钮的状态
  1203. if ($(myobj).parent().attr("play-status") == "0") {
  1204. //停止其他作答音频播放
  1205. var isRecordPlaying = $(".answer-audio-range[play-status='1']");
  1206. if (isRecordPlaying.length > 0) {
  1207. $(isRecordPlaying).attr("play-status", "0");
  1208. $(isRecordPlaying).find("img").attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
  1209. }
  1210. //停止其他原文音频播放
  1211. var audioPlaying = $(".audioImg[play-status='1']");
  1212. if (audioPlaying.length > 0) {
  1213. $(audioPlaying).attr("play-status", "0");
  1214. $(audioPlaying).attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地 喇叭 路径替换
  1215. }
  1216. //设置播放状态
  1217. $(myobj).parent().attr("play-status", "1");
  1218. $(myobj).attr("src", PicInfo.recordPauseImgUrl);//移动端要根据本地路径替换
  1219. }
  1220. else {
  1221. $(myobj).parent().attr("play-status", "0");
  1222. $(myobj).attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
  1223. }
  1224. //移动端添加外部处理,播放录音
  1225. var info = new Object();
  1226. info.Id = id;
  1227. info.AudioUrl = url;
  1228. //移动端添加外部处理,播放录音
  1229. playVisiableAudioCallBack(3, JSON.stringify(info));
  1230. }
  1231. function playVisiableAudioCallBack(type, url) {
  1232. //console.log(url);
  1233. cancelBubble();
  1234. plugin.startPlay(type, url);
  1235. }
  1236. function onClickAnswerPoint(data) {
  1237. //alert(JSON.stringify(data));
  1238. console.log(JSON.stringify(data));
  1239. cancelBubble();
  1240. plugin.onClickAnswerPoint(data);
  1241. }
  1242. function onClickKeyHide() {
  1243. //alert(JSON.stringify(data));
  1244. cancelBubble();
  1245. plugin.onClickKeyHide();
  1246. }
  1247. function cancelBubble(e) {
  1248. var evt = e ? e : window.event;
  1249. if (evt.stopPropagation) { //W3C
  1250. evt.stopPropagation();
  1251. } else { //IE
  1252. evt.cancelBubble = true;
  1253. }
  1254. }
  1255. function getSelectedText(title) {
  1256. var txt;
  1257. if (window.getSelection) {
  1258. txt = window.getSelection().toString();
  1259. } else if (window.document.getSelection) {
  1260. txt = window.document.getSelection().toString();
  1261. } else if (window.document.selection) {
  1262. txt = window.document.selection.createRange().text;
  1263. }
  1264. JSInterface.callback(txt, title);
  1265. }