Skip to content

Commit bc861d4

Browse files
committed
feat[practice]should show problem after completed
1 parent b9251c0 commit bc861d4

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

src/views/problems/Practice/PracticeTip/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<span>
33
<el-button type="text" @click="$emit('update:showTip',!showTip)">{{ showTip ? '隐藏帮助' : '查看帮助' }}</el-button>
44
<span v-if="showTip" style="font-size:0.8rem;font-weight:600">
5+
<p>题目做完以后将会继续显示,直到下一题也做完了。</p>
56
<p>【Ctrl+Shift+↑】键返回上一题,【Ctrl+Shift+↓】键进入下一题</p>
67
<p>题目内按【Ctrl+Alt+Enter】提交答案</p>
78
<p>【Ctrl+Alt+数字】选中选项</p>

src/views/problems/Practice/Train/ProblemList/index.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export default {
137137
beforeLeave,
138138
problem_show (d) {
139139
if (!d) return
140-
return !this.kill_problem || !d.completed
140+
return !this.kill_problem || (!d.completed || d.completed > new Date().getTime() - 1e3)
141141
},
142142
onKeyUp (v) {
143143
const { ctrlKey, shiftKey, key } = v
@@ -174,6 +174,7 @@ export default {
174174
this.handle_focus({ id: filtered_data[new_index].id, is_manual })
175175
},
176176
onSubmit ({ problem, is_right }) {
177+
console.log('onsubmit to status', problem)
177178
this.$refs.completion_tip.update_status({ problem, is_right })
178179
this.focus_next({ focus_move_step: 1 })
179180
},
@@ -323,7 +324,7 @@ export default {
323324
return null // 如果id重复,则标记题目为待删除
324325
}
325326
id_dict[r.id] = 1 // 将题目加入重复判断字典中
326-
r.completed = false
327+
r.completed = null
327328
return r
328329
})
329330
prblems = this.do_filter_problems(prblems)

src/views/problems/Practice/Train/index.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
22
<div v-if="name" v-loading="loading">
3+
34
<div v-if="database">
45
<el-card class="right-hover-panel flashing-layout-right">
56
<span>
@@ -10,6 +11,7 @@
1011
<div class="train-container">
1112
<div class="train">
1213
<h1>题库:{{ database.alias || database.description }}</h1>
14+
<PracticeTip :show-tip.sync="show_tip" />
1315
<ProblemList :data="database.problems" @onStatus="v => problem_status = v" @requireInit="show_options=true" />
1416
</div>
1517
</div>
@@ -43,6 +45,7 @@ export default {
4345
ProblemList: () => import('./ProblemList'),
4446
TrainOptions: () => import('./TrainOptions'),
4547
TrainStatus: () => import('./TrainStatus'),
48+
PracticeTip: () => import('../PracticeTip')
4649
},
4750
props: {
4851
name: { type: String, default: null }
@@ -53,7 +56,8 @@ export default {
5356
problem_focus: null,
5457
problem_status: null,
5558
show_options: false,
56-
current_option_focus: '1'
59+
current_option_focus: '1',
60+
show_tip: false
5761
}),
5862
computed: {
5963
...mapState({

src/views/problems/Problem/ProblemBase/index.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default {
6363
watch: {
6464
userAnswerConfirmResult: {
6565
handler (val) {
66-
this.$emit('update:completed', val)
66+
this.$emit('update:completed', val ? new Date() : null)
6767
}
6868
}
6969
},
@@ -102,9 +102,11 @@ export default {
102102
if (!is_right) this.update_problem({ is_right: false, is_manual })
103103
},
104104
onAnswerResult ({ is_right, is_manual, answer }) {
105+
console.log('onAnswerResult', is_right, is_manual, answer)
105106
this.userAnswerConfirmResult = true
106107
if (this.userAnswerResult === false) return
107108
this.showAnswer = false
109+
console.log('update_problem', is_right, is_manual, answer)
108110
this.update_problem({ is_right, is_manual, answer })
109111
},
110112
update_problem ({ is_right, is_manual, answer }) {

src/views/problems/Problem/index.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default {
3434
},
3535
data: () => ({
3636
ProblemType: api.ProblemType,
37-
completed: false,
37+
completed: null,
3838
submitted: false
3939
}),
4040
computed: {
@@ -57,7 +57,9 @@ export default {
5757
},
5858
methods: {
5959
handle_submit ({ is_right, is_manual, answer }) {
60+
console.log('handle_submit', is_right, is_manual, answer)
6061
if (this.submitted) return
62+
console.log('handle_submit_true', is_right, is_manual, answer)
6163
this.submitted = true
6264
return this.$emit('onSubmit', { is_right, is_manual, answer })
6365
},
@@ -74,7 +76,7 @@ export default {
7476
c && c.onSubmit({ is_right, is_manual, answer })
7577
},
7678
reset () {
77-
this.completed = false
79+
this.completed = null
7880
this.submitted = false
7981
const c = this.$refs.base
8082
c && c.reset()

0 commit comments

Comments
 (0)