Skip to content

Commit

Permalink
fix ddlang
Browse files Browse the repository at this point in the history
  • Loading branch information
advu committed Oct 22, 2024
1 parent a6f2735 commit d4e749b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
27 changes: 20 additions & 7 deletions client/components/Tests/ReadingTest/ReadingTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
updateReadingTestElicitation,
nextReadingTestQuestion,
finishReadingTest,
finishLastReadingTestQuestion,
markAnsweredChoice,
sendReadingTestQuestionnaireResponses,
} from 'Utilities/redux/testReducer'
Expand Down Expand Up @@ -90,15 +91,21 @@ const ReadingTest = () => {
dispatch(getReadingTestQuestions(learningLanguage, false));
};

const goToHomePage = () => {
history.push('/home')
}
// const goToHomePage = () => {
// history.push('/home')
// }

const submitSelfReflectionResponse = (response_json) => {
console.log("submitSelfReflectionResponse", response_json)
console.log("currentReadingQuestionIndex", currentReadingQuestionIndex)
console.log("readingTestQuestions.length", readingTestQuestions.length)
dispatch(sendReadingTestQuestionnaireResponses(response_json, learningLanguage))
if (response_json.is_end_set_questionair == true) {
if (currentReadingQuestionIndex === readingTestQuestions.length - 1) {
goToHomePage()
// goToHomePage()
console.log("AAAAAAAAA")
dispatch(finishReadingTest())
dispatch(getReadingHistory(learningLanguage, readingTestSessionId));
}
// else {
// // the self reflection does not show after every set - need to move this is to somewhere else
Expand Down Expand Up @@ -255,8 +262,7 @@ const ReadingTest = () => {

if (currentReadingQuestionIndex === readingTestQuestions.length - 1) {
console.log("finish")
dispatch(finishReadingTest())
dispatch(getReadingHistory(learningLanguage, readingTestSessionId));
dispatch(finishLastReadingTestQuestion())
} else {
console.log("next")
dispatch(nextReadingTestQuestion())
Expand All @@ -277,6 +283,13 @@ const ReadingTest = () => {
}
}, []);

useEffect(() => {
dispatch(getGroups());
if (learningLanguage && readingTestSessionId && testDone && readingHistory == {}) {
dispatch(getReadingHistory(learningLanguage, readingTestSessionId));
}
}, [testDone]);

useEffect(() => {
let experimental = false;
let control = false;
Expand Down Expand Up @@ -341,7 +354,7 @@ const ReadingTest = () => {
useEffect(() => {
if (!readingTestSessionId) return
if (!currentReadingTestQuestion) {
dispatch(finishReadingTest(learningLanguage, readingTestSessionId))
dispatch(finishReadingTest())
}
setCurrentElicatedConstruct(currentReadingTestQuestion ? currentReadingTestQuestion.eliciated_construct : null)
}, [currentReadingTestQuestion])
Expand Down
12 changes: 9 additions & 3 deletions client/util/redux/testReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ export const nextTestQuestion = () => ({ type: 'NEXT_TEST_QUESTION' })

export const nextReadingTestQuestion = () => ({ type: 'NEXT_READING_TEST_QUESTION' })

export const finishLastReadingTestQuestion = () => ({ type: 'FINISH_LAST_READING_TEST_QUESTION' })

export const finishReadingTest = () => ({ type: 'FINISH_READING_TEST' })

export const markAnsweredChoice = (answer) => ({ type: 'MARK_ANSWERED_CHOICE', answer })
Expand Down Expand Up @@ -368,14 +370,18 @@ export default (state = initialState, action) => {
feedbacks: [],
}

case 'FINISH_READING_TEST':
case 'FINISH_LAST_READING_TEST_QUESTION':
let _lastSet = readingTestQuestions[currentReadingQuestionIndex]?.set;
let _finishedSet = _lastSet + 1;
return {
...state,
currentReadingSet: _finishedSet,
currentReadingSet: "-1",
prevReadingSet: _lastSet,
lastReadingSessionFinished: true,
}

case 'FINISH_READING_TEST':
return {
...state,
testDone: true
}

Expand Down

0 comments on commit d4e749b

Please sign in to comment.