javascript
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课群在线测试自动答题解决方案(十九)强制重做的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C#——《C#语言程序设计》实验报告——
- 下一篇: JavaScript——易班优课YOOC