tasklib_book.js 66 KB

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