Skip to content

Commit

Permalink
fix(script): 修复重新答题按钮点击后,答题完成后的一些操作依然在进行的BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
ennnncy committed Mar 27, 2024
1 parent 978d927 commit e7148a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
11 changes: 9 additions & 2 deletions packages/scripts/src/projects/icourse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,16 @@ function workAndExam(
worker
.doWork()
.then(async (results) => {
if (worker.isClose) {
return;
}
if (type === 'chapter-test') {
$message('info', { content: `答题完成,将等待 ${stopSecondWhenFinish} 秒后进行保存或提交。` });
$console.info(`答题完成,将等待 ${stopSecondWhenFinish} 秒后进行保存或提交。`);
await $.sleep(stopSecondWhenFinish * 1000);

if (worker.isClose) {
return;
}
// 处理提交
await worker.uploadHandler({
type: upload,
Expand All @@ -507,7 +512,9 @@ function workAndExam(
$message('success', { content: content, duration: 0 });

await $.sleep(3000);

if (worker.isClose) {
return;
}
if (uploadable) {
const sumbit = document.querySelector('.j-submit');
if (sumbit) {
Expand Down
13 changes: 12 additions & 1 deletion packages/scripts/src/projects/zhs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -912,13 +912,24 @@ function gxkWorkAndExam(
worker
.doWork()
.then(async () => {
// 如果被强制关闭,则不进行保存操作
if (worker.isClose === true) {
return;
}
$message('success', { content: `答题完成,将等待 ${stopSecondWhenFinish} 秒后进行保存或提交。` });
await $.sleep(stopSecondWhenFinish * 1000);

// @ts-ignore
if (worker.isClose === true) {
return;
}
/**
* 保存题目,不在选择答案后保存的原因是,如果答题线程大于3会导致题目错乱,因为 resolverIndex 并不是顺序递增的
*/
for (let index = 0; index < worker.totalQuestionCount; index++) {
// @ts-ignore
if (worker.isClose === true) {
return;
}
const modal = $modal('alert', {
content: '正在保存题目中(必须保存,否则填写的答案无效),<br>请勿操作...',
confirmButton: null
Expand Down

0 comments on commit e7148a3

Please sign in to comment.