Skip to content

Commit

Permalink
fix ddlang tst
Browse files Browse the repository at this point in the history
  • Loading branch information
ducvugithub committed Oct 2, 2024
1 parent 14162de commit 58bd5e9
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions client/components/Tests/ReadingTest/ReadingTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
markAnsweredChoice,
sendReadingTestQuestionnaireResponses,
} from 'Utilities/redux/testReducer'
import { getGroups } from 'Utilities/redux/groupsReducer'
import {
learningLanguageSelector,
confettiRain,
Expand Down Expand Up @@ -60,6 +61,10 @@ const ReadingTest = () => {
const [timeSpent, setTimeSpent] = useState(0)
const [showStats, setShowStats] = useState(false)

// State for experimental and control groups
const [in_experimental_grp, setInExperimentalGrp] = useState(false);
const [in_control_grp, setInControlGrp] = useState(false);

const {
feedbacks,
currentReadingTestQuestion,
Expand All @@ -80,23 +85,6 @@ const ReadingTest = () => {

const history = useHistory()

let in_experimental_grp = false;
let in_control_grp = false;


groups.forEach(group => {
if (group.group_type === "experimental") {
in_experimental_grp = true;
}
if (group.group_type === "control") {
in_control_grp = true;
}
});

if (in_control_grp == true) {
in_experimental_grp = false;
}

const dispatch = useDispatch()

const nextQuestion = () => {
Expand Down Expand Up @@ -284,11 +272,39 @@ const ReadingTest = () => {
if (in_control_grp) {
if (attempts >= 1) {
setQuestionDone(true)
setShowCorrect(true)
return
}
}
}

useEffect(() => {
dispatch(getGroups());
}, []);

useEffect(() => {
let experimental = false;
let control = false;

if (groups && groups.length) {
groups.forEach((group) => {
if (group.group_type === 'experimental') {
experimental = true;
}
if (group.group_type === 'control') {
control = true;
}
});

// If in control group, don't set experimental group
if (control) {
experimental = false;
}
}

setInExperimentalGrp(experimental);
setInControlGrp(control);
}, [groups]);

useEffect(() => {
if (currentReadingQuestionIndex === readingTestQuestions.length - 1) {
Expand Down

0 comments on commit 58bd5e9

Please sign in to comment.