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

歡迎訪問 生活随笔!

生活随笔

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

javascript

JavaScript——易班优课YOOC课群在线测试自动答题解决方案(十九)强制重做

發布時間:2024/10/5 javascript 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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課群在線測試自動答題解決方案(十三)自動答題

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

JavaScript——易班優課YOOC課群在線測試自動答題解決方案(十五)整合升級+引入jQuery

JavaScript——易班優課YOOC課群在線測試自動答題解決方案(十六)利用PC端和移動端BUG

JavaScript + Tampermonkey——易班優課YOOC課群在線測試自動答題解決方案(十七)復合型解決方案油猴腳本

JavaScript + Thymeleaf + Spring Boot——易班優課YOOC課群在線測試自動答題解決方案(十八)模板腳本

問題描述

2020年六月底,易班對考試頁JavaScript更新,出現以下BUG。?

?

問題分析

考試列表頁?

重做按鈕?

每次練習以后,重做按鈕的鏈接都會發生改變,這個鏈接可以通過考試頁面一個參數生成。

對整個考試頁面就行正則匹配即可

let examuser=/var AnswerData = JSON.parse\(localStorage.getItem\("exam(.*)"\)\) \|\| {};/.exec(res.responseText)[1] console.log(examuser)

考試頁

提交按鈕事件

?submitAnswer()方法

如果直接使用??submitAnswer()方法,服務端的校驗不能通過。

_AnswerData()方法和AnswerData??

更新前:

更新后:

解決方案

var repeatExam=()=>{$.ajax({url: 'https://www.yooc.me/group/'+groupId+'/exam/'+examId+'/detail',type: 'GET'}).then(res=>{let examuser=/var AnswerData = JSON.parse\(localStorage.getItem\("exam(.*)"\)\) \|\| {.*};/.exec(res)[1];$.ajax({beforeSend: function(xhr){// 取消掉全局loading效果if($('#mask').length>0){$('#mask').hide();}},url:'https://www.yooc.me/group/'+groupId+'/exam/'+examId+'/examuser/'+examuser+'/repeat',type: 'post',data: {'csrfmiddlewaretoken': csrf},success: function(data){if(data.result){window.location.href = data.url;}else{alert(data.message);}}});},ajaxUsualErrorMessage)}let appendsomething=()=>{let releaseButton=document.getElementsByClassName('release-board')[0]let ns=document.createElement('a')ns.id="null-submit"ns.href="javascript:;"ns.innerText="提交白卷"ns.style="margin-left: 0px;margin-top: 10px;"ns.title="隨機答案提交試卷"ns.onclick=()=>{nullSubmit();//頁面方法xAlert('提示','隨機答案選擇完畢,可以提交了');};releaseButton.appendChild(ns);let qa=document.createElement('a');qa.id="query-answer";qa.href="javascript:;";qa.innerText="查詢答案";qa.style="margin-left: 20px;margin-top: 10px;";qa.title="云端題庫查詢答案";qa.onclick=()=>{let ansElements = document.getElementsByClassName('the-ans');let ansNum = ansElements.lengthif(ansNum<=0){showAnswer();addIdTag()}else{//頁面方法xAlert('失敗','已經有答案了哦')}};releaseButton.appendChild(qa);let 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();addIdTag();//頁面方法xAlert('提示','答案自動選擇完畢,請自行檢查填空題部分')}releaseButton.appendChild(autoAnswerButton);let copyAnswerButton=document.createElement('a');copyAnswerButton.id="auto-answer-submit";copyAnswerButton.href="javascript:;";copyAnswerButton.innerText="正確答案";copyAnswerButton.style="margin-left: 20px;margin-top: 10px;";copyAnswerButton.title="利用PC端和移動端之間BUG實現獲取正確答案";let checked_a=false;copyAnswerButton.onclick=()=>{let ansElements = document.getElementsByClassName('the-ans');let ansNum = ansElements.length;if(ansNum<=0){copyMobileAnswer();addIdTag();//頁面方法xAlert('提示','正確答案復制完畢,請自行檢查填空題部分');}else{//頁面方法xAlert('失敗','已經有答案了哦');}};releaseButton.appendChild(copyAnswerButton);var repeatButton=document.createElement('a')repeatButton.id="repeat-exam-submit"repeatButton.href="javascript:;"repeatButton.innerText="強制重做"repeatButton.style="margin-left: 0px;margin-top: 10px;"repeatButton.title="強制申請重做試卷"repeatButton.onclick=()=>{repeatExam();//頁面方法xAlert('提示','強制申請重做試卷成功')}releaseButton.appendChild(repeatButton)var tempButton=document.createElement('a')tempButton.id="temp-submit"tempButton.href="javascript:;"tempButton.innerText="占位按鈕"tempButton.style="margin-left: 20px;margin-top: 10px;"tempButton.title="未定義功能"tempButton.onclick=()=>{//頁面方法xAlert('失敗','占位按鈕:未定義功能')}releaseButton.appendChild(tempButton)};

運行結果

?

參考文章?

https://shentuzhigang.blog.csdn.net/article/details/105878870

總結

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

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