Skip to content

Commit

Permalink
feat(core): 新增自动答题选项:强制提交
Browse files Browse the repository at this point in the history
  • Loading branch information
enncy committed May 21, 2022
1 parent c2c1c3d commit e0ff3a2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
35 changes: 22 additions & 13 deletions packages/core/src/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,29 @@ export function createWorkerSetting (
: [
{
label: '关闭自动答题',
value: 'close'
value: 'close',
title: '关闭自动答题后, 脚本将忽略答题, 自动进入下一节。'
},
{
label: '完成后自动保存',
value: 'save'
value: 'save',
title: '完成后自动保存答案, 注意如果你开启了随机作答, 有可能分辨不出答案是否正确。'
},
{
label: '完成后不做任何动作',
value: 'nomove'
value: 'nomove',
title: '完成后既不保存也不提交, 等待时间过后将会自动下一节, 适合在测试脚本时使用。'
},
{
label: '强制自动提交',
value: 'force',
title: '不管答案是否正确直接强制自动提交,如需开启,请配合随机作答谨慎使用。'

},
...[10, 20, 30, 40, 50, 60, 70, 80, 90].map((rate) => ({
label: `查到大于${rate}%的题目则自动提交`,
value: rate,
attrs: {
title: `例如: 100题, 搜索到大于 ${rate} 的题, 则会自动提交答案。`
}
title: `例如: 100题, 搜索到大于 ${rate} 的题, 则会自动提交答案。`
})),
{
label: '每个题目都查到答案才自动提交',
Expand All @@ -91,13 +98,15 @@ export function createWorkerSetting (
<>
<label>{label}</label>
<div>
<select title="答题设置" onChange={changeHandler}>
{options.map((option) => (
<option value={option.value} selected={option.selected}>
{option.label}
</option>
))}
</select>
<Tooltip title="答题设置, 鼠标悬浮在选项上可以查看每个选项的具体解释。">
<select onChange={changeHandler}>
{options.map((option) => (
<option title={option.title} value={option.value} selected={option.selected}>
{option.label}
</option>
))}
</select>
</Tooltip>
</div>

<label>题库配置</label>
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/core/worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ export class OCSWorker<E extends RawElements = RawElements> {
}
const rate = results.length === 0 ? 0 : (finished / results.length) * 100;
if (uploadRate !== 'nomove') {
await callback(rate, uploadRate === 'save' ? false : rate >= parseFloat(uploadRate));
if (uploadRate === 'force') {
await callback(rate, true);
} else {
await callback(rate, uploadRate === 'save' ? false : rate >= parseFloat(uploadRate));
}
}
}
}
2 changes: 1 addition & 1 deletion packages/core/src/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface CXSetting {
/** 复习模式 */
restudy: boolean,
/** 章节测试自动答题 */
upload: 'close'
upload: string
/** 播放路线列表 */
playlines: string[]
/** 播放路线 */
Expand Down

0 comments on commit e0ff3a2

Please sign in to comment.