Skip to content

Commit 0319988

Browse files
committed
Clean up
1 parent 6287fba commit 0319988

File tree

2 files changed

+28
-42
lines changed

2 files changed

+28
-42
lines changed

client/components/Tests/ReadingTest/ReadingTest.js

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ const ReadingTest = ({ setCycle, setShowCyclePopup }) => {
296296

297297
useEffect(() => {
298298
if (!currentReadingTestQuestion) {
299-
console.log('no currentReadingTestQuestion')
300299
return
301300
}
302301

@@ -305,7 +304,6 @@ const ReadingTest = ({ setCycle, setShowCyclePopup }) => {
305304
previousStatus?.is_correct &&
306305
previousStatus.last_question_id === currentReadingTestQuestion.question_id
307306
) {
308-
console.log('nextQuestion called 1')
309307
nextQuestion()
310308
return
311309
}
@@ -314,7 +312,6 @@ const ReadingTest = ({ setCycle, setShowCyclePopup }) => {
314312
previousStatus.last_question_id === currentReadingTestQuestion.question_id &&
315313
previousStatus.responses.length === 1
316314
) {
317-
console.log('setAttempts called')
318315
setAttempts(prev => prev + 1)
319316
return
320317
}
@@ -323,15 +320,24 @@ const ReadingTest = ({ setCycle, setShowCyclePopup }) => {
323320
previousStatus.last_question_id === currentReadingTestQuestion.question_id &&
324321
previousStatus?.responses?.length > 1
325322
) {
326-
console.log('nextQuestion called 2')
327323
nextQuestion()
328324
return
329325
}
330326
}
331327

332328
if (in_experimental_grp) {
333-
if (previousStatus?.is_correct) {
334-
console.log('nextQuestion called 3')
329+
if (
330+
previousStatus?.is_correct &&
331+
previousStatus.last_question_id === currentReadingTestQuestion.question_id
332+
) {
333+
nextQuestion()
334+
return
335+
}
336+
337+
if (
338+
previousStatus.last_question_id === currentReadingTestQuestion.question_id &&
339+
previousStatus?.responses?.length > 3
340+
) {
335341
nextQuestion()
336342
}
337343
}
@@ -356,13 +362,6 @@ const ReadingTest = ({ setCycle, setShowCyclePopup }) => {
356362
}
357363
}, [testDone])
358364

359-
/* useEffect(() => {
360-
dispatch(getGroups());
361-
if (learningLanguage && readingTestSessionId && testDone && readingHistory == {}) {
362-
dispatch(getReadingHistory(learningLanguage, readingTestSessionId));
363-
}
364-
}, [testDone]); */
365-
366365
useEffect(() => {
367366
let experimental = false;
368367
let control = false;
@@ -388,9 +387,7 @@ const ReadingTest = ({ setCycle, setShowCyclePopup }) => {
388387
}, [groups]);
389388

390389
useEffect(() => {
391-
console.log('about to mark question as seen')
392390
if (currentReadingTestQuestion && !currentReadingTestQuestion?.seen) {
393-
console.log('marking question as seen: ', currentReadingTestQuestion)
394391
dispatch(
395392
markQuestionAsSeen(
396393
learningLanguage,
@@ -456,10 +453,6 @@ const ReadingTest = ({ setCycle, setShowCyclePopup }) => {
456453
timer.start()
457454
}, [])
458455

459-
/* if (!currentReadingTestQuestion) {
460-
return null
461-
} */
462-
463456
const testContainerOverflow = displaySpinner ? { overflow: "hidden" } : { overflowY: "auto" };
464457

465458
if (showStats) {
@@ -556,18 +549,18 @@ const ReadingTest = ({ setCycle, setShowCyclePopup }) => {
556549
)}
557550
</div>
558551
{/* This button used to be in hiddenFeatures, now visible to all */}
559-
<div className="test-top-info space-between" style={{ marginBottom: '0.2em' }}>
560-
<Button
561-
className="restart-reading-test-button btn-secondary"
562-
style={{ marginRight: 'auto', marginTop: '1rem' }}
563-
onClick={() => restartTest()}
564-
disabled={showFeedbacks}
565-
>
566-
<span>
567-
<FormattedMessage id="restart-reading-test" />
568-
</span>
569-
</Button>
570-
</div>
552+
<div className="test-top-info space-between" style={{ marginBottom: '0.2em' }}>
553+
<Button
554+
className="restart-reading-test-button btn-secondary"
555+
style={{ marginRight: 'auto', marginTop: '1rem' }}
556+
onClick={() => restartTest()}
557+
disabled={showFeedbacks}
558+
>
559+
<span>
560+
<FormattedMessage id="restart-reading-test" />
561+
</span>
562+
</Button>
563+
</div>
571564
</div>
572565
</div>
573566
</Segment>

client/components/Tests/ReadingTest/index.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,28 @@ import { getReadingTestQuestions, resetTests } from 'Utilities/redux/testReducer
77

88
import { useLearningLanguage } from 'Utilities/common'
99
import Spinner from 'Components/Spinner'
10-
import ReadingTest from './ReadingTest'
11-
12-
// import ReadingPracticeChatbot from 'Components/ChatBot/ReadingPracticeChatbot'
1310
import DDLangIntroductory from 'Components/Tests/ReadingTest/ReadingTestIntroductory'
11+
import ReadingTest from './ReadingTest'
1412

1513
import './index.css'
1614

1715
const ReadingTestView = () => {
1816
const dispatch = useDispatch()
1917
const learningLanguage = useLearningLanguage()
20-
// const bigScreen = useWindowDimension().width >= 650
2118
const [showDDLangIntroductory, setShowDDLangIntroductory] = useState(false)
2219
const [showCyclePopup, setShowCyclePopup] = useState(false)
2320
const [cycle, setCycle] = useState(null)
2421

25-
const { readingTestSessionId, pending, testDone, readingTestQuestions, allCycles, currentCycle } = useSelector(
26-
({ tests }) => tests
27-
)
22+
const { readingTestSessionId, pending, testDone, readingTestQuestions, allCycles, currentCycle } =
23+
useSelector(({ tests }) => tests)
2824

2925
useEffect(() => {
3026
if (testDone === undefined && readingTestQuestions.length === 0) {
31-
console.log('getting reading test questions 1')
3227
dispatch(getReadingTestQuestions(learningLanguage, true))
3328
} else if (testDone === false && currentCycle) {
34-
console.log('getting reading test questions 2')
3529
dispatch(getReadingTestQuestions(learningLanguage, true, Number(currentCycle)))
3630
}
37-
}, [dispatch, learningLanguage /* , testDone */])
31+
}, [dispatch, learningLanguage])
3832

3933
const handleCycleSubmit = () => {
4034
dispatch(resetTests())
@@ -94,7 +88,6 @@ const ReadingTestView = () => {
9488
</Button>
9589
</div>
9690
</div>
97-
{/* <ReadingPracticeChatbot /> */}
9891
</div>
9992
)
10093
}

0 commit comments

Comments
 (0)