Skip to content

Commit

Permalink
update ddlang reading test self reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
advu committed Oct 1, 2024
1 parent 50778e7 commit 14162de
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
32 changes: 18 additions & 14 deletions client/components/Tests/ReadingTest/ReadingTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const ReadingTest = () => {
const [showFeedbacks, setShowFeedbacks] = useState(false)

const [currentReadingSetLength, setCurrentReadingSetLength] = useState(0)
const [firstMediationSelfReflectionDone, setFirstMediationSelfReflectionDone] = useState(false)
// const [firstMediationSelfReflectionDone, setFirstMediationSelfReflectionDone] = useState(false)
const [showSelfReflect, setShowSelfReflect] = useState(false)

const [showElicitDialog, setShowElicitDialog] = useState(false)
Expand Down Expand Up @@ -73,6 +73,7 @@ const ReadingTest = () => {
answerPending,
answerFailure,
resumedTest,
readingTestSetDict,
} = useSelector(({ tests }) => tests)
const learningLanguage = useSelector(learningLanguageSelector)
const { groups } = useSelector(({ groups }) => groups)
Expand Down Expand Up @@ -129,16 +130,16 @@ const ReadingTest = () => {

const submitSelfReflectionResponse = (response_json) => {
dispatch(sendReadingTestQuestionnaireResponses(response_json, learningLanguage))
if (response_json.is_end_set_questionair !== true){
setFirstMediationSelfReflectionDone(true)
}
else {
if (response_json.is_end_set_questionair == true){
if (currentReadingQuestionIndex === readingTestQuestions.length - 1){
goToHomePage()
} else {
setShowNextSetDialog(true)
}
}
// else {
// setFirstMediationSelfReflectionDone(true)
// }
setShowSelfReflect(false)
if (currentReadingSet !== prevReadingSet && prevReadingSet !== null && currentReadingSet !== null) {
setReceivedFeedback(0)
Expand Down Expand Up @@ -309,14 +310,17 @@ const ReadingTest = () => {
useEffect(() => {
setShowFeedbacks(false)
if (currentReadingSet !== null && prevReadingSet !== null && currentReadingSet !== prevReadingSet) {
if (in_experimental_grp && receivedFeedback > 0) {
setShowSelfReflect(!resumedTest)
}
if (in_control_grp && receivedFeedback == 0) {
setShowSelfReflect(!resumedTest)
const currentSet = readingTestSetDict[currentReadingSet]
if (currentSet && currentSet.collect_final_reflection) {
if (in_experimental_grp && receivedFeedback > 0) {
setShowSelfReflect(!resumedTest)
}
if (in_control_grp && receivedFeedback == 0) {
setShowSelfReflect(!resumedTest)
}
}
}
setFirstMediationSelfReflectionDone(resumedTest)
// setFirstMediationSelfReflectionDone(resumedTest)
}, [currentReadingSet])

useEffect(() => {
Expand Down Expand Up @@ -370,9 +374,9 @@ const ReadingTest = () => {
showFeedbacks={showFeedbacks}
closeFeedbacks={() => {
setShowFeedbacks(false)
if (firstMediationSelfReflectionDone === false && receivedFeedback > 0 && in_experimental_grp && currentQuestionIdxinSet < currentReadingSetLength && questionDone) {
setShowSelfReflect(true)
}
// if (firstMediationSelfReflectionDone === false && receivedFeedback > 0 && in_experimental_grp && currentQuestionIdxinSet < currentReadingSetLength && questionDone) {
// setShowSelfReflect(true)
// }
}}
/>
<ReadingTestSelfReflect
Expand Down
4 changes: 3 additions & 1 deletion client/util/redux/testReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const initialState = {
prevReadingSet: null,
readingSetLength: 0,
readingTestQuestions: [],
readingTestSetDict: {},

exhaustiveTestSessionId: null,
currentExhaustiveQuestionIndex: 0,
Expand Down Expand Up @@ -208,7 +209,7 @@ export default (state = initialState, action) => {
language: action.language,
}
case 'GET_READING_TEST_QUESTIONS_SUCCESS':
const { question_list, session_id } = response;
const { question_list, session_id, question_set_dict } = response;

// Split questions by set
const questionsBySet = question_list.reduce((acc, question) => {
Expand Down Expand Up @@ -263,6 +264,7 @@ export default (state = initialState, action) => {

return {
...state,
readingTestSetDict: question_set_dict,
readingTestQuestions: tempreadingTestQuestions,
currentReadingTestQuestion: tmpcurrentReadingTestQuestion,
currentReadingSet: currentSet,
Expand Down

0 comments on commit 14162de

Please sign in to comment.