日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

JavaScript——易班优课YOOC课群在线测试自动答题解决方案(十三)自动答题

發布時間:2024/10/5 javascript 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 JavaScript——易班优课YOOC课群在线测试自动答题解决方案(十三)自动答题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

前文

JavaScript——易班優課YOOC課群在線測試自動答題解決方案(一)答案獲取

Spring Boot——易班優課YOOC課群在線測試自動答題解決方案(二)答案儲存

Spring Boot——易班優課YOOC課群在線測試自動答題解決方案(三)答案查詢

JavaScript——易班優課YOOC課群在線測試自動答題解決方案(四)答案顯示

JavaScript——易班優課YOOC課群在線測試自動答題解決方案(五)簡單腳本

Spring Boot——易班優課YOOC課群在線測試自動答題解決方案(六)后端改造

JavaScript——易班優課YOOC課群在線測試自動答題解決方案(七)隨機答案

JavaScript——易班優課YOOC課群在線測試自動答題解決方案(八)功能面板

JavaScript——易班優課YOOC課群在線測試自動答題解決方案(九)ID標簽

Vue + Element UI + Spring Boot——易班優課YOOC課群在線測試自動答題解決方案(十)問題管理頁面

JavaScript——易班優課YOOC課群在線測試自動答題解決方案(十一)恢復右鍵、選擇和復制

JavaScript——易班優課YOOC課群在線測試自動答題解決方案(十二)腳本整合

輔助工具

正則表達式代碼生成工具?

解決方案

注:需要先從云端加載答案?

加載答案參考:JavaScript——易班優課YOOC課群在線測試自動答題解決方案(四)答案顯示

var ansElements = Array.from(document.getElementsByClassName('the-ans'))let pattern=/\u6b63\u786e\u7b54\u6848\uff1a(.*)/ansElements.forEach(ansEle=>{let ans=ansEle.children[0].innerText.trim()if(pattern.test(ans)){var answers=pattern.exec(ans)[1]console.log(answers)let parentNode=ansEle.parentNodelet question_id=parentNode.id.split('-')[1]answers.split('、').forEach(answer=>{if(/[A-Z]/.test(answer)){let li_Eles=parentNode.getElementsByTagName('li')let li_Ele=li_Eles[answer.charCodeAt(0)-65]let input_id=li_Ele.dataset.questionName+"_"+li_Ele.dataset.questionValuelet Ele=document.getElementById(input_id)if(Ele.type==="radio"){Ele.checked=true;}else if(Ele.type==="checkbox"){Ele.checked=true;}//頁面方法choiceAnswerData($(document.getElementById('question-'+question_id)))}else{let input_id=question_id+"_" + (answers.indexOf(answer) + 1)let Ele=document.getElementById(input_id)Ele.value=answer//頁面方法inputAnswerData($(document.getElementById('question-'+question_id)))}})let questionTag=document.getElementById(question_id)questionTag.classList.add('done')}})

添加一個按鈕?

var question=Array.from(document.getElementsByClassName('question-board'))var autoAnswerButton=document.createElement('a')autoAnswerButton.id="auto-answer-submit"autoAnswerButton.href="javascript:;"autoAnswerButton.innerText="自動答題"autoAnswerButton.style="margin-left: 0px;margin-top: 10px;"autoAnswerButton.title="答案自動選擇"autoAnswerButton.onclick=()=>{autoAnswer()//頁面方法xAlert('提示','答案自動選擇完畢,請自行檢查填空題部分')}releaseButton.appendChild(autoAnswerButton)

運行結果

參考文章?

https://blog.csdn.net/zzti_erlie/article/details/89842391

https://www.runoob.com/regexp/regexp-syntax.html

https://www.cnblogs.com/ChengDong/articles/3771880.html

https://zhuanlan.zhihu.com/p/33335629

https://www.cnblogs.com/tangyongle/p/7499522.html

https://zhidao.baidu.com/question/495418166779664644.html

https://jingyan.baidu.com/article/0320e2c1bd21b25b86507b0d.html

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的JavaScript——易班优课YOOC课群在线测试自动答题解决方案(十三)自动答题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。