Skip to content

Commit

Permalink
feat[practice]should show problem after completed
Browse files Browse the repository at this point in the history
  • Loading branch information
serfend committed May 22, 2022
1 parent b9251c0 commit bc861d4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/views/problems/Practice/PracticeTip/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<span>
<el-button type="text" @click="$emit('update:showTip',!showTip)">{{ showTip ? '隐藏帮助' : '查看帮助' }}</el-button>
<span v-if="showTip" style="font-size:0.8rem;font-weight:600">
<p>题目做完以后将会继续显示,直到下一题也做完了。</p>
<p>【Ctrl+Shift+↑】键返回上一题,【Ctrl+Shift+↓】键进入下一题</p>
<p>题目内按【Ctrl+Alt+Enter】提交答案</p>
<p>【Ctrl+Alt+数字】选中选项</p>
Expand Down
5 changes: 3 additions & 2 deletions src/views/problems/Practice/Train/ProblemList/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default {
beforeLeave,
problem_show (d) {
if (!d) return
return !this.kill_problem || !d.completed
return !this.kill_problem || (!d.completed || d.completed > new Date().getTime() - 1e3)
},
onKeyUp (v) {
const { ctrlKey, shiftKey, key } = v
Expand Down Expand Up @@ -174,6 +174,7 @@ export default {
this.handle_focus({ id: filtered_data[new_index].id, is_manual })
},
onSubmit ({ problem, is_right }) {
console.log('onsubmit to status', problem)
this.$refs.completion_tip.update_status({ problem, is_right })
this.focus_next({ focus_move_step: 1 })
},
Expand Down Expand Up @@ -323,7 +324,7 @@ export default {
return null // 如果id重复,则标记题目为待删除
}
id_dict[r.id] = 1 // 将题目加入重复判断字典中
r.completed = false
r.completed = null
return r
})
prblems = this.do_filter_problems(prblems)
Expand Down
6 changes: 5 additions & 1 deletion src/views/problems/Practice/Train/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<div v-if="name" v-loading="loading">

<div v-if="database">
<el-card class="right-hover-panel flashing-layout-right">
<span>
Expand All @@ -10,6 +11,7 @@
<div class="train-container">
<div class="train">
<h1>题库:{{ database.alias || database.description }}</h1>
<PracticeTip :show-tip.sync="show_tip" />
<ProblemList :data="database.problems" @onStatus="v => problem_status = v" @requireInit="show_options=true" />
</div>
</div>
Expand Down Expand Up @@ -43,6 +45,7 @@ export default {
ProblemList: () => import('./ProblemList'),
TrainOptions: () => import('./TrainOptions'),
TrainStatus: () => import('./TrainStatus'),
PracticeTip: () => import('../PracticeTip')
},
props: {
name: { type: String, default: null }
Expand All @@ -53,7 +56,8 @@ export default {
problem_focus: null,
problem_status: null,
show_options: false,
current_option_focus: '1'
current_option_focus: '1',
show_tip: false
}),
computed: {
...mapState({
Expand Down
4 changes: 3 additions & 1 deletion src/views/problems/Problem/ProblemBase/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default {
watch: {
userAnswerConfirmResult: {
handler (val) {
this.$emit('update:completed', val)
this.$emit('update:completed', val ? new Date() : null)
}
}
},
Expand Down Expand Up @@ -102,9 +102,11 @@ export default {
if (!is_right) this.update_problem({ is_right: false, is_manual })
},
onAnswerResult ({ is_right, is_manual, answer }) {
console.log('onAnswerResult', is_right, is_manual, answer)
this.userAnswerConfirmResult = true
if (this.userAnswerResult === false) return
this.showAnswer = false
console.log('update_problem', is_right, is_manual, answer)
this.update_problem({ is_right, is_manual, answer })
},
update_problem ({ is_right, is_manual, answer }) {
Expand Down
6 changes: 4 additions & 2 deletions src/views/problems/Problem/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default {
},
data: () => ({
ProblemType: api.ProblemType,
completed: false,
completed: null,
submitted: false
}),
computed: {
Expand All @@ -57,7 +57,9 @@ export default {
},
methods: {
handle_submit ({ is_right, is_manual, answer }) {
console.log('handle_submit', is_right, is_manual, answer)
if (this.submitted) return
console.log('handle_submit_true', is_right, is_manual, answer)
this.submitted = true
return this.$emit('onSubmit', { is_right, is_manual, answer })
},
Expand All @@ -74,7 +76,7 @@ export default {
c && c.onSubmit({ is_right, is_manual, answer })
},
reset () {
this.completed = false
this.completed = null
this.submitted = false
const c = this.$refs.base
c && c.reset()
Expand Down

0 comments on commit bc861d4

Please sign in to comment.