|
@@ -8,22 +8,25 @@ export default function useAutoChooseFirstQuestion() {
|
|
|
const markStore = useMarkStore();
|
|
|
const { showRejectedReason } = useTaskRejection();
|
|
|
|
|
|
- watch(
|
|
|
- () => markStore.currentTask,
|
|
|
- () => {
|
|
|
- // 重置当前选择的quesiton和score
|
|
|
- markStore.currentQuestion = undefined;
|
|
|
- markStore.currentScore = undefined;
|
|
|
+ // 监听currentTask的变化,自动选择第一题
|
|
|
+ function watchCurrentTaskChooseQuestion() {
|
|
|
+ watch(
|
|
|
+ () => markStore.currentTask,
|
|
|
+ () => {
|
|
|
+ // 重置当前选择的quesiton和score
|
|
|
+ markStore.currentQuestion = undefined;
|
|
|
+ markStore.currentScore = undefined;
|
|
|
|
|
|
- // FIXed ME: 此时取到的还是score:null,但是 chooseQuestion之后就变成了score:0
|
|
|
- const firstQuestion = markStore.currentTask?.questionList.find(
|
|
|
- (question) => question.selfMark
|
|
|
- );
|
|
|
- if (firstQuestion) {
|
|
|
- chooseQuestion(firstQuestion);
|
|
|
+ // FIXed ME: 此时取到的还是score:null,但是 chooseQuestion之后就变成了score:0
|
|
|
+ const firstQuestion = markStore.currentTask?.questionList.find(
|
|
|
+ (question) => !isDisabledQuestion(question)
|
|
|
+ );
|
|
|
+ if (firstQuestion) {
|
|
|
+ chooseQuestion(firstQuestion);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- );
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
const scrollToQuestionOfBoard = async (question: Question) => {
|
|
|
const node = document.querySelector(
|
|
@@ -60,8 +63,15 @@ export default function useAutoChooseFirstQuestion() {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ function isDisabledQuestion(question: Question) {
|
|
|
+ return (
|
|
|
+ (!markStore.historyOpen && !question.selfMark) ||
|
|
|
+ (markStore.historyOpen && question.problem)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
function chooseQuestion(question: Question) {
|
|
|
- if (!question.selfMark) return;
|
|
|
+ if (isDisabledQuestion(question)) return;
|
|
|
|
|
|
markStore.currentQuestion = question;
|
|
|
// FIXME: maybe should be an async function, temp fix for eslint
|
|
@@ -74,5 +84,5 @@ export default function useAutoChooseFirstQuestion() {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- return { chooseQuestion };
|
|
|
+ return { watchCurrentTaskChooseQuestion, chooseQuestion, isDisabledQuestion };
|
|
|
}
|