| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858 |
- //播放音频图片地址
- var PicInfo = {
- answerPointImgUrl: "file:///android_asset/js/update-answer.png", //../Images/update-answer.png
- yaoshiShowImgUrl: "file:///android_asset/js/yaoshi-show.png",
- yaoshiHideImgUrl: "file:///android_asset/js/yaoshi-hide.png",
- recordPlayImgUrl: "file:///android_asset/js/play.png",
- recordPauseImgUrl: "file:///android_asset/js/pause.png",
- audioPlayImgUrl: "file:///android_asset/js/dynaiselaba.gif",
- audioPauseImgUrl: "file:///android_asset/js/dynaiselaba.png"
- }
- //显示、隐藏答案
- function showHideAnswer(flag) {
- if (flag) {
- //$(".underlineContent").show();
- $(".underlineContent").css("color", "#92D050");
- $(".yaoshi").attr("src", PicInfo.yaoshiShowImgUrl);
- }
- else {
- //$(".underlineContent").hide();
- $(".underlineContent").css("color", "#ffffff");
- $(".yaoshi").attr("src", PicInfo.yaoshiHideImgUrl);
- }
- }
- ///显示、隐藏钥匙及答案 isShowYX:显示和隐藏钥匙,isShowAS:显示和隐藏答案
- function showHideAnswerEx(isShowYX, isShowAS) {
- if (isShowYX) {
- $(".yaoshi").show();
- }
- else {
- $(".yaoshi").hide();
- }
- if (isShowAS) {
- $.each($(".underlineContent"), function (index, item) {
- //$(item).html($(item).attr("data-text"));
- if (!$(item).hasClass("no-answer")) {
- $(item).css("color", "#92D050");
- }
- else {
- $(item).css("color", "#989898");
- }
- $(item).find(".wordStyle").css("color", "#db5d00");
- $(item).find(".phraseStyle").css("background-color", "#f2db8b");
- });
- $(".yaoshi").attr("data-status", "1");
- $(".yaoshi").attr("src", PicInfo.yaoshiShowImgUrl);
- }
- else {
- $.each($(".underlineContent,.underlineContent.no-answer"), function (index, item) {
- $(item).css("color", "#ffffff");
- $(item).find(".wordStyle").css("color", "#ffffff");
- $(item).find(".phraseStyle").css("background-color", "#ffffff");
- });
- $(".yaoshi").attr("data-status", "0");
- $(".yaoshi").attr("src", PicInfo.yaoshiHideImgUrl);
- }
- }
- //页面加载完,原文 绑定事件
- function bindEventTeaOrignalYS() {
- var bodyWidth = $(document.body).width();
- //显示/隐藏习题答案
- $(".yaoshi").on("click", function () {
- var curDisplay = $(this).nextUntil(".yaoshi").find(".underlineContent").eq(0).css("display");
- if (curDisplay == "undefined" || curDisplay == undefined) return;
- if (curDisplay == "none" || $(this).attr("data-status") == "0") {
- $(this).attr("data-status", "1");
- $(this).attr("src", PicInfo.yaoshiShowImgUrl);
- //$(this).nextUntil(".yaoshi").find(".underlineContent").show();
- //$(this).nextUntil(".yaoshi").find(".underlineContent").css("color", "#92D050");
- $.each($(this).nextUntil(".yaoshi").find(".underlineContent"), function (index, item) {
- if (!$(item).hasClass("no-answer")) {
- $(item).css("color", "#92D050");
- }
- else {
- $(item).css("color", "#989898");
- }
- $(item).find(".wordStyle").css("color", "#db5d00");
- $(item).find(".phraseStyle").css("background-color", "#f2db8b");
- });
- //不再存在已隐藏的钥匙,移动端回调
- if ($(".yaoshi[data-status='0']").length == 0) {
- //添加回调
- console.log("全部显示了");
- }
- } else {
- $(this).attr("data-status", "0");
- $(this).attr("src", PicInfo.yaoshiHideImgUrl);
- //$(this).nextUntil(".yaoshi").find(".underlineContent").hide();
- //$(this).nextUntil(".yaoshi").find(".underlineContent").css("color", "#ffffff");
- $.each($(this).nextUntil(".yaoshi").filter(".underlineContent"), function (index, item) {
- $(item).css("color", "#ffffff");
- $(item).find(".wordStyle").css("color", "#ffffff");
- $(item).find(".phraseStyle").css("background-color", "#ffffff");
- });
- //添加回调
- onClickKeyHide();
- }
- });
- //处理答题点
- $.each($(".underlineContent"), function (index, item) {
- $(item).attr("data-text", $(item).html());
- });
- //给音频绑定一个ID
- $.each($(".audioImg"), function (index, item) {
- $(item).attr("audiourl", "");
- $(item).attr('audio-id', index);
- });
- //给视频图标处理
- $.each($(".videoImg"), function (index, item) {
- $(item).attr("audiourl", "");
- });
- //给口语图标处理
- $.each($(".oralLanguageImg"), function (index, item) {
- $(item).attr("audiourl", "");
- });
- //去除多余的U空标签
- $.each($("u"), function (index, item) {
- var text = $(item).text();
- text = text.replace(/\s+/g, "");
- if (text == "") {
- $(item).remove();
- }
- });
- //处理暂无参考答案
- $.each($(".yaoshi"), function (index, item) {
- var prev = $(item).nextUntil(".yaoshi").find(".underlineContent");
- if (prev.length == 0) {
- var spanHtml = document.createElement("span");
- //添加子节点
- var uHtml = document.createElement("u");
- uHtml.className = "underlineContent no-answer";
- uHtml.innerText = "暂无参考答案";
- uHtml.setAttribute("data-text", uHtml.innerText);
- $(spanHtml).html(uHtml.outerHTML);
- $(item).after(spanHtml);
- }
- });
- //处理表格宽度
- $.each($(".wordTable"), function (index, item) {
- $(item).css("width", bodyWidth + "px");
- });
- //点击喇叭事件,音频播放
- $(".audioImg").on("click", function () {
- audioPlayClick(this);
- });
- //点击播放事件,视频播放
- $(".videoImg").on("click", function () {
- var curHtml = $(this).parent().find(".videoUrl").html();
- var curAlt = $(this).attr("alt");//播放视频地址
- playVisiableAudioCallBack(2, $(this).attr("alt"));
- });
- //处理表格样式
- $("td").attr("style", "");
- }
- //页面加载完,课件 绑定事件
- function bindEventYS() {
- var bodyWidth = $(document.body).width();
- //给每个答题点加上ID
- $.each($(".yaoshi"), function (index, item) {
- $(item).attr('answer-id', index);
- });
- //给音频绑定一个ID
- $.each($(".audioImg"), function (index, item) {
- $(item).attr("audiourl", "");
- $(item).attr('audio-id', index);
- });
- //给视频图标处理
- $.each($(".videoImg"), function (index, item) {
- $(item).attr("audiourl", "");
- });
- //给口语图标处理
- $.each($(".oralLanguageImg"), function (index, item) {
- $(item).attr("audiourl", "");
- });
- //去除多余的U空标签
- $.each($("u"), function (index, item) {
- var text = $(item).text();
- text = text.replace(/\s+/g, "");
- if (text == "") {
- $(item).remove();
- }
- });
- //处理暂无参考答案
- $.each($(".yaoshi"), function (index, item) {
- var prev = $(item).nextAll(".underlineContent");
- if (prev.length == 0) {
- var uHtml = document.createElement("u");
- uHtml.className = "underlineContent no-answer";
- uHtml.innerText = "暂无参考答案";
- uHtml.setAttribute("data-text", uHtml.innerText);
- $(item).after(uHtml);
- }
- });
- //处理表格宽度
- $.each($(".wordTable"), function (index, item) {
- $(item).css("width", bodyWidth + "px");
- });
- //显示/隐藏习题答案
- $(".yaoshi").on("click", function () {
- if ($(this).attr("data-status") == "0") {
- $(this).attr("data-status", "1");
- $(this).attr("src", PicInfo.yaoshiShowImgUrl);
- //$(this).nextUntil(".yaoshi").filter(".underlineContent").css("color", "#92D050");
- $.each($(this).nextUntil(".yaoshi").filter(".underlineContent"), function (index, item) {
- if (!$(item).hasClass("no-answer")) {
- $(item).css("color", "#92D050");
- }
- else {
- $(item).css("color", "#989898");
- }
- $(item).find(".wordStyle").css("color", "#db5d00");
- $(item).find(".phraseStyle").css("background-color", "#f2db8b");
- });
- //不再存在已隐藏的钥匙,移动端回调
- if ($(".yaoshi[data-status='0']").length == 0) {
- //添加回调
- console.log("全部显示了");
- }
- }
- else {
- $(this).attr("data-status", "0");
- $(this).attr("src", PicInfo.yaoshiHideImgUrl);
- //$(this).nextUntil(".yaoshi").filter(".underlineContent").css("color", "#ffffff");
- $.each($(this).nextUntil(".yaoshi").filter(".underlineContent"), function (index, item) {
- $(item).css("color", "#ffffff");
- $(item).find(".wordStyle").css("color", "#ffffff");
- $(item).find(".phraseStyle").css("background-color", "#ffffff");
- });
- //添加回调
- onClickKeyHide();
- }
- });
- //点击喇叭事件,音频播放
- $(".audioImg").on("click", function () {
- audioPlayClick(this);
- });
- //点击播放事件,视频播放
- $(".videoImg").on("click", function () {
- $(this).attr("audiourl", "");
- var curHtml = $(this).parent().find(".videoUrl").html();
- var curAlt = $(this).attr("alt");//播放视频地址
- playVisiableAudioCallBack(2, $(this).attr("alt"));
- });
- //处理表格样式
- $("td").attr("style", "");
- }
- //学生端 处理作答区域
- var answerData = new Array();
- function handleAnswerRange() {
- //规范文本格式
- var answerId = "";
- var tempJson = new Array();
- $.each($(".yaoshi").nextUntil(".yaoshi").filter(".underline"), function (index, item) {
- tempId = $(item).prevAll(".yaoshi").attr("answer-id");
- //记录上一次的ID
- if (tempId == undefined) {
- tempId = answerId;
- }
- else {
- answerId = tempId;
- }
- var prev = $(item).prev();
- if ((prev.length == 0 || $(prev).attr("class") != "tag-span") && $(prev).attr("class") != "underlineContent") {
- if ($("span[answer-id='" + tempId + "']").length == 0) {
- $(item).prop("outerHTML", "<span answer-id='" + tempId + "' class='tag-span' answer-isky='0'>_</span>");
- }
- }
- $(item).remove();
- });
- //提取参考答案并规范文本格式
- answerId = "";
- $.each($(".yaoshi").nextUntil(".yaoshi").filter(".underlineContent"), function (index, item) {
- var info = new Object();
- info.Id = $(item).prevAll(".yaoshi").attr("answer-id");
- //记录上一次的ID
- if (info.Id == undefined) {
- info.Id = answerId;
- }
- else {
- answerId = info.Id;
- }
- info.AnsText = $(item).text();
- tempJson.push(info);
- var prev = $(item).prev();
- if (prev.length == 0 || $(prev).attr("class") != "tag-span") {
- //替换答案
- $(item).prop("outerHTML", "<span answer-id='" + info.Id + "' class='tag-span' answer-isky='0'>_</span>");
- }
- else {
- $(item).remove();
- }
- });
- //补充空钥匙的处理
- $.each($(".yaoshi"), function (index, item) {
- var Id = $(item).attr("answer-id");
- var prev = $(item).next();
- if (prev.length == 0 || $(prev).attr("class") != "tag-span") {
- if ($("span[answer-id='" + Id + "']").length == 0) {
- var uHtml = document.createElement("span");
- uHtml.className = "tag-span";
- uHtml.innerText = "_";
- uHtml.setAttribute("answer-id", Id);
- $(item).after(uHtml);
- }
- }
- });
- //处理口语试题
- $.each($(".oralLanguage").nextUntil(".oralLanguageDone"), function (num, part) {
- if (part.tagName != "p") {
- $.each($(part).find(".tag-span"), function (index, item) {
- $(item).attr("answer-isky", "1");
- });
- }
- else {
- if ($(part).hasClass("underlinePart")) {
- $.each($(part).find(".tag-span"), function (index, item) {
- $(item).attr("answer-isky", "1");
- });
- }
- }
- });
- //合并参考答案数据
- var tempid = "";
- var temptext = "";
- for (var i = 0; i < tempJson.length; i++) {
- if (tempid == tempJson[i].Id) {
- temptext = temptext + tempJson[i].AnsText;
- }
- else {
- if (tempid != "") {
- var info = new Object();
- info.Id = tempid;
- info.AnsText = temptext;
- answerData.push(info);
- //重置
- tempid = "";
- temptext = "";
- }
- tempid = tempJson[i].Id;
- temptext = tempJson[i].AnsText;
- //最后一个存入
- if (i == tempJson.length - 1) {
- var info = new Object();
- info.Id = tempid;
- info.AnsText = temptext;
- answerData.push(info);
- }
- }
- }
- //补全答题点
- var Num = 0;
- if (answerData.length > 0) {
- //Num = Number.parseInt(answerData[answerData.length - 1].Id);
- Num = Number.parseInt($(".yaoshi:last").attr('answer-id'));
- for (var i = 0; i < Num + 1; i++) {
- if (i < answerData.length) {
- var index = Number(answerData[i].Id) - i;
- for (var j = 0; j < index; j++) {
- var info = new Object();
- info.Id = (i + j).toString();
- info.AnsText = "";
- answerData.splice(i, 0, info);
- }
- }
- else {
- var info = new Object();
- info.Id = (i).toString();
- info.AnsText = "";
- answerData.splice(i, 0, info);
- }
- }
- }
- //添加答题点的点击UI及交互
- $.each($(".tag-span"), function (index, item) {
- var answerText = "";
- var isky = $(item).attr('answer-isky');
- var answerid = $(item).attr('answer-id');
- for (var i = 0; i < answerData.length; i++) {
- if (answerid == answerData[i].Id) {
- answerText = answerData[i].AnsText;
- break;
- }
- }
- $(item).prop("outerHTML", "<div class='answer-range' answer-id='" + answerid + "' answer-anstext='" + answerText + "' answer-isky='" + isky + "'><img src='" + PicInfo.answerPointImgUrl + "'/><span class='answertext'>答题点</span></div>");
- //删除钥匙节点
- var prev = $("img[answer-id='" + answerid + "']");
- if (prev.length > 0) {
- $(prev).remove();
- }
- });
- //添加点击事件
- $(".answer-range").on("click", function () {
- var curObj = new Object();
- curObj.Id = $(this).attr("answer-id");//答题点ID
- curObj.IsKY = $(this).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
- curObj.Text = $(this).attr("answer-text");//用户作答内容
- curObj.Score = $(this).attr("answer-score");//作答评分
- curObj.AnsText = $(this).attr("answer-anstext");//参考答案
- curObj.Comment = $(this).attr("answer-comment");//评语
- $(".answer-range").removeClass("select-answer");
- $(this).addClass("select-answer");
- //已作答,弹出作答答案
- if ($(this).data("ans-status") == "1") {
- //移动端添加外部处理
- onClickAnswerPoint(JSON.stringify(curObj));
- }
- else {
- //移动端添加外部处理,弹出作答操作
- onClickAnswerPoint(JSON.stringify(curObj));
- }
- });
- //去除多余的空格横线
- $.each($(".underline"), function (index, item) {
- var text = $(item).text();
- text = text.replace(/\s+/g, "");
- if (text == "") {
- $(item).remove();
- }
- });
- return answerData;
- }
- //接收学生的作答
- function reviewAnswer(answerJson) {
- if (answerJson != "" && answerJson) {
- var answerObj = JSON.parse(answerJson);
- var selectElement = $(".answer-range[answer-id='" + answerObj.Id + "']");
- var audioElement = $(selectElement).children("img").eq(0);
- answerObj.IsKY = $(selectElement).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
- //有内容时,要动态处理单词长度
- if (answerObj.Text != "") {
- $(selectElement).addClass("break-word");
- }
- else {
- $(selectElement).removeClass("break-word");
- }
- //是否是音频作答
- if ((answerObj.Type == 3 || answerObj.Type == 4) && answerObj.AudioUrl != "") {
- $(selectElement).attr("answer-text", answerObj.Text);//填充作答内容
- answerObj.Text = answerObj.Text == "" ? "作答音频[" + answerObj.AudioLength + "s]" : "作答音频[" + answerObj.AudioLength + "s]" + "(" + answerObj.Text + ")";
- $(selectElement).children("span").text(answerObj.Text);
- //是否之前存在作答音频
- $(selectElement).attr("play-status", "0");
- $(audioElement).attr("src", PicInfo.recordPlayImgUrl);
- var curDisplay = $(audioElement).css("display");
- if (curDisplay == "none") {
- $(audioElement).show();
- }
- $(selectElement).attr("answer-url", answerObj.AudioUrl);
- //独立绑定事件
- $(audioElement).on("click", function () {
- recordAudioClick(this, answerObj.Id, answerObj.AudioUrl);
- });
- $(selectElement).children("span").on("click", function () {
- $(".answer-range").removeClass("select-answer");
- $(item).addClass("select-answer");
- onClickAnswerPoint(JSON.stringify(answerObj));
- });
- }
- else {
- $(selectElement).attr("answer-text", answerObj.Text);//填充作答内容
- if (answerObj.Text == "") {
- answerObj.Text = "答题点";
- $(audioElement).show();
- $(audioElement).attr("src", PicInfo.answerPointImgUrl);
- }
- else {
- //之前作答存在音频,但是现在没有音频传入,要隐藏音频节点
- $(audioElement).hide();
- }
- $(selectElement).children("span").text(answerObj.Text);
- }
- }
- }
- //提交,获取所有作答答案及参考答案
- function getAllAnswer() {
- //处理作答
- $.each($(".answer-range"), function (index, item) {
- var mytext = $(item).children("span").text();
- if (mytext == "答题点") {
- mytext = "未作答";
- $(item).children("span").addClass("no-answer");
- $(item).children("img").hide();
- $(item).children("span").text(mytext);
- }
- });
- $(".answer-range").unbind('click');//取消点击绑定事件
- $(".answer-range>span").unbind('click');//取消点击绑定事件
- return answerData;
- }
- //回填所有答案,answerJson:所有作答及参考答案List,statusType:0-可作答,1-已提交,2-查看评阅
- function backupAllAnswer(answerJson, statusType) {
- if (answerJson != "" && answerJson) {
- var answerList = JSON.parse(answerJson);
- //answerList = JSON.parse(answerList);
- //获取Dom一个个回填
- $.each($(".answer-range"), function (index, item) {
- //提交直接还原作答现场
- var mytext = answerList[index].Text;//我的答案
- answerList[index].IsKY = $(item).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
- //有内容时,要动态处理单词长度
- if (mytext != "") {
- $(item).addClass("break-word");
- }
- //添加音频控制
- var audioElement = $(item).children("img").eq(0);
- if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
- $(item).attr("answer-text", mytext);//填充作答内容
- mytext = mytext == "" ? "作答音频[" + answerList[index].AudioLength + "s]" : "作答音频[" + answerList[index].AudioLength + "s]" + "(" + mytext + ")";
- $(item).children("span").text(mytext);
- $(item).attr("play-status", "0");
- $(item).attr("answer-url", answerList[index].AudioUrl);
- $(audioElement).attr("src", PicInfo.recordPlayImgUrl);
- }
- //可作答状态,作答还原
- if (statusType == 0) {
- //已作答过,还原作答,增加作答后的UI节点
- if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
- //独立绑定事件
- $(item).children("img").on("click", function () {
- recordAudioClick(this, answerList[index].Id, answerList[index].AudioUrl);
- });
- $(item).children("span").on("click", function () {
- $(".answer-range").removeClass("select-answer");
- $(item).addClass("select-answer");
- onClickAnswerPoint(JSON.stringify(answerList[index]));
- });
- }
- else {
- $(item).attr("answer-text", mytext);//填充作答内容
- if (mytext == "") {
- mytext = "答题点";
- $(audioElement).attr("src", PicInfo.answerPointImgUrl);
- }
- else {
- //之前作答存在音频,但是现在没有音频传入,要隐藏音频节点
- $(audioElement).hide();
- }
- $(item).children("span").text(mytext);
- }
- }
- //已提交,作答还原
- if (statusType == 1) {
- //取消点击绑定事件
- $(item).unbind('click');
- //添加音频控制
- if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
- //独立绑定事件
- $(item).children("img").on("click", function () {
- recordAudioClick(this, answerList[index].Id, answerList[index].AudioUrl);
- });
- }
- else {
- $(item).attr("answer-text", mytext);//填充作答内容
- if (mytext == "") {
- mytext = "未作答";
- $(item).children("span").addClass("no-answer");
- }
- $(audioElement).hide();
- $(item).children("span").text(mytext);
- }
- }
- //已评阅,查看评阅详情
- if (statusType == 2) {
- //添加音频控制
- if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
- //独立绑定事件
- $(item).children("img").on("click", function () {
- recordAudioClick(this, answerList[index].Id, answerList[index].AudioUrl);
- });
- $(item).children("span").on("click", function () {
- $(".answer-range").removeClass("select-answer");
- $(item).addClass("select-answer");
- onClickAnswerPoint(JSON.stringify(answerList[index]));
- });
- }
- else {
- $(item).attr("answer-text", mytext);//填充作答内容
- if (mytext == "") {
- mytext = "未作答";
- $(item).children("span").addClass("no-answer");
- }
- $(audioElement).hide();
- $(item).children("span").text(mytext);
- }
- //评阅样式
- if (answerList[index].Score == 0 && answerList[index].Text != "") {
- $(item).children("span").addClass("bad-answer");
- }
- if (answerList[index].Score > 0) {
- $(item).children("span").addClass("good-answer");
- }
- }
- });
- }
- }
- //老师评阅学生作答
- function reviewStuAnswer(answerJson) {
- if (answerJson != "" && answerJson) {
- var answerObj = JSON.parse(answerJson);
- var selectElement = $(".answer-range[answer-id='" + answerObj.Id + "']");
- //$(selectElement).attr("answer-text", answerObj.Text);//用户作答内容
- $(selectElement).attr("answer-score", answerObj.Score);//作答评分
- $(selectElement).attr("answer-anstext ", answerObj.AnsText);//参考答案
- $(selectElement).attr("answer-comment", answerObj.Comment);//评语
- //评阅样式
- if (answerObj.Score == 0) {
- $(selectElement).children("span").removeClass("good-answer");
- $(selectElement).children("span").addClass("bad-answer");
- }
- if (answerObj.Score > 0) {
- $(selectElement).children("span").removeClass("bad-answer");
- $(selectElement).children("span").addClass("good-answer");
- }
- }
- }
- //回填所有评阅信息,answerJson:所有作答及参考答案评阅信息List
- function backupAllReview(answerJson) {
- if (answerJson != "" && answerJson) {
- var answerList = JSON.parse(answerJson);
- $.each($(".answer-range"), function (index, item) {
- //$(item).attr("answer-id", answerList[index].Id);//答题点ID
- //$(item).attr("answer-text", answerList[index].Text);//用户作答内容
- $(item).attr("answer-score", answerList[index].Score);//作答评分
- $(item).attr("answer-anstext ", answerList[index].AnsText);//参考答案
- $(item).attr("answer-comment", answerList[index].Comment);//评语
- //提交直接还原作答现场
- var mytext = answerList[index].Text;//我的答案
- var audioElement = $(item).children("img").eq(0);
- if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
- $(item).attr("answer-text", mytext);//填充作答内容
- mytext = mytext == "" ? "作答音频[" + answerList[index].AudioLength + "s]" : "作答音频[" + answerList[index].AudioLength + "s]" + "(" + mytext + ")";
- $(item).children("span").text(mytext);
- $(item).attr("play-status", "0");
- $(item).attr("answer-url", answerList[index].AudioUrl);
- $(audioElement).attr("src", PicInfo.recordPlayImgUrl);
- //独立绑定事件
- $(item).children("img").on("click", function () {
- recordAudioClick(this, answerList[index].Id, answerList[index].AudioUrl);
- });
- $(item).children("span").on("click", function () {
- $(".answer-range").removeClass("select-answer");
- $(item).addClass("select-answer");
- onClickAnswerPoint(JSON.stringify(answerList[index]));//移动端的修改
- });
- }
- else {
- $(item).attr("answer-text", mytext);//填充作答内容
- if (mytext == "") {
- mytext = "未作答";
- $(item).children("span").addClass("no-answer");
- }
- $(audioElement).hide();
- $(item).children("span").text(mytext);
- }
- //评阅样式
- if (answerList[index].Score == 0) {
- $(item).children("span").addClass("bad-answer");
- }
- if (answerList[index].Score > 0) {
- $(item).children("span").addClass("good-answer");
- }
- });
- }
- }
- //处理播放录音,answerid:答题点ID,isPlay:是否播放(0-暂停,1-播放)
- function playRecordAudio(answerid, isPlay) {
- //获取其他正在播放的音频
- var playing = $(".answer-range[answer-id='" + answerid + "']");
- if (playing.length > 0) {
- if (isPlay == "1") {
- $(playing).attr("play-status", "1");
- $(playing).find("img").attr("src", PicInfo.recordPauseImgUrl);//移动端要根据本地路径替换
- }
- else {
- $(playing).attr("play-status", "0");
- $(playing).find("img").attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
- }
- }
- }
- //滚动到相应DIV
- function scrollAnswer(answerid) {
- //console.log(answerid);
- $(".answer-range").removeClass("select-answer");
- var ansDom = $(".answer-range[answer-id='" + answerid + "']");
- $(ansDom).addClass("select-answer");
- var scroll_offset = $(ansDom).offset(); //得到box这个div层的offset,包含两个值,top和left
- var offset_top = scroll_offset.top;
- if (offset_top > 150) {
- offset_top = offset_top - 200;
- }
- $("body,html").animate({
- scrollTop: offset_top //让body的scrollTop等于pos的top,就实现了滚动
- });
- }
- //暂停播放原文音频
- function pauseTextAudio(audioid) {
- //获取其他正在播放的音频
- var playing = $(".audioImg[audio-id='" + audioid + "']");
- if (playing.length > 0) {
- $(playing).attr("play-status", "0");
- $(playing).attr("src", PicInfo.audioPauseImgUrl);//移动端要根据本地 喇叭 路径替换
- }
- }
- //原文音频播放按钮点击事件
- function audioPlayClick(myobj) {
- var curHtml = $(myobj).parent().find(".audioUrl").html();
- var curAlt = $(myobj).attr("alt");
- //处理当前按钮的状
- if ($(myobj).attr("play-status") == "1") {
- $(myobj).attr("play-status", "0");
- $(myobj).attr("src", PicInfo.audioPauseImgUrl);//移动端要根据本地 喇叭 路径替换
- }
- else {
- //停止其他作答音频播放
- var isRecordPlaying = $(".answer-range[play-status='1']");
- if (isRecordPlaying.length > 0) {
- $(isRecordPlaying).attr("play-status", "0");
- $(isRecordPlaying).find("img").attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
- }
- //停止其他原文音频播放
- var audioPlaying = $(".audioImg[play-status='1']");
- if (audioPlaying.length > 0) {
- $(audioPlaying).attr("play-status", "0");
- $(audioPlaying).attr("src", PicInfo.audioPauseImgUrl);//移动端要根据本地 喇叭 路径替换
- }
- //设置播放状态
- $(myobj).attr("play-status", "1");
- $(myobj).attr("src", PicInfo.audioPlayImgUrl);//移动端要根据本地 喇叭 路径替换
- }
- var info = new Object();
- info.Id = $(myobj).attr("audio-id");
- info.AudioUrl = curAlt;
- //移动端添加外部处理
- playVisiableAudioCallBack(1, JSON.stringify(info));
- }
- //作答录音播放按钮点击事件
- function recordAudioClick(myobj, id, url) {
- //处理当前按钮的状态
- if ($(myobj).parent().attr("play-status") == "0") {
- //停止其他作答音频播放
- var isRecordPlaying = $(".answer-range[play-status='1']");
- if (isRecordPlaying.length > 0) {
- $(isRecordPlaying).attr("play-status", "0");
- $(isRecordPlaying).find("img").attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
- }
- //停止其他原文音频播放
- var audioPlaying = $(".audioImg[play-status='1']");
- if (audioPlaying.length > 0) {
- $(audioPlaying).attr("play-status", "0");
- $(audioPlaying).attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地 喇叭 路径替换
- }
- //设置播放状态
- $(myobj).parent().attr("play-status", "1");
- $(myobj).attr("src", PicInfo.recordPauseImgUrl);//移动端要根据本地路径替换
- }
- else {
- $(myobj).parent().attr("play-status", "0");
- $(myobj).attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
- }
- //移动端添加外部处理,播放录音
- var info = new Object();
- info.Id = id;
- info.AudioUrl = url;
- //移动端添加外部处理,播放录音
- playVisiableAudioCallBack(3, JSON.stringify(info));
- }
- function playVisiableAudioCallBack(type, url) {
- //console.log(url);
- cancelBubble();
- plugin.startPlay(type, url);
- }
- function onClickAnswerPoint(data) {
- //alert(JSON.stringify(data));
- //console.log(JSON.stringify(data));
- cancelBubble();
- plugin.onClickAnswerPoint(data);
- }
- function onClickKeyHide() {
- //alert(JSON.stringify(data));
- cancelBubble();
- plugin.onClickKeyHide();
- }
- function cancelBubble(e) {
- var evt = e ? e : window.event;
- if (evt.stopPropagation) { //W3C
- evt.stopPropagation();
- } else { //IE
- evt.cancelBubble = true;
- }
- }
- function getSelectedText(title) {
- var txt;
- if (window.getSelection) {
- txt = window.getSelection().toString();
- } else if (window.document.getSelection) {
- txt = window.document.getSelection().toString();
- } else if (window.document.selection) {
- txt = window.document.selection.createRange().text;
- }
- JSInterface.callback(txt, title);
- }
|