diff --git a/src/components/DiscoverSentance/DiscoverSentance.jsx b/src/components/DiscoverSentance/DiscoverSentance.jsx index 2ad8adb7..5d26f094 100644 --- a/src/components/DiscoverSentance/DiscoverSentance.jsx +++ b/src/components/DiscoverSentance/DiscoverSentance.jsx @@ -39,6 +39,8 @@ const SpeakSentenceComponent = () => { const [disableScreen, setDisableScreen] = useState(false); const [play] = useSound(LevelCompleteAudio); const [openMessageDialog, setOpenMessageDialog] = useState(""); + const [totalSyllableCount, setTotalSyllableCount] = useState(''); + const callConfettiAndPlay = () => { play(); @@ -159,6 +161,7 @@ const SpeakSentenceComponent = () => { session_id: localStorage.getItem("sessionId"), user_id: localStorage.getItem("virtualId"), collectionId: currentCollectionId, + totalSyllableCount: totalSyllableCount, language: localStorage.getItem("lang"), } ); @@ -269,6 +272,7 @@ const SpeakSentenceComponent = () => { `${process.env.REACT_APP_LEARNER_AI_APP_HOST}/${config.URLS.GET_PAGINATION}?page=1&limit=5&collectionId=${sentences?.content?.[0]?.collectionId}` ); setCurrentContentType("Sentence"); + setTotalSyllableCount(resPagination?.data?.totalSyllableCount) setCurrentCollectionId(sentences?.content?.[0]?.collectionId); setAssessmentResponse(resAssessment); localStorage.setItem("storyTitle", sentences?.name); diff --git a/src/utils/VoiceAnalyser.js b/src/utils/VoiceAnalyser.js index a2a180da..788b45fe 100644 --- a/src/utils/VoiceAnalyser.js +++ b/src/utils/VoiceAnalyser.js @@ -265,7 +265,7 @@ function VoiceAnalyser(props) { ); data = updateLearnerData; responseText = data.responseText; - newThresholdPercentage = data?.targetsPercentage || 0; + newThresholdPercentage = data?.subsessionTargetsCount || 0; handlePercentageForLife(newThresholdPercentage); } @@ -388,21 +388,12 @@ function VoiceAnalyser(props) { }; const handlePercentageForLife = (percentage) => { + percentage = (percentage / livesData.totalTargets) * 100; try { - const THRESHOLD_PERCENTAGE = 30; let newLivesData = {}; if (livesData) { - if (percentage > THRESHOLD_PERCENTAGE) { - let redLivesToShow = 0; - let blackLivesToShow = 5; - newLivesData = { - ...livesData, - blackLivesToShow, - redLivesToShow, - }; - // 5 black , 0 red - } else if (percentage >= 0 && percentage <= 5) { + if (percentage >= 0 && percentage <= 5) { let redLivesToShow = 5; let blackLivesToShow = 0; newLivesData = { @@ -447,6 +438,14 @@ function VoiceAnalyser(props) { redLivesToShow, }; // 1 red , 4 black + }else{ + let redLivesToShow = 0; + let blackLivesToShow = 5; + newLivesData = { + ...livesData, + blackLivesToShow, + redLivesToShow, + }; } var audio = new Audio( diff --git a/src/views/Practice/Practice.jsx b/src/views/Practice/Practice.jsx index 500eefd8..30b07739 100644 --- a/src/views/Practice/Practice.jsx +++ b/src/views/Practice/Practice.jsx @@ -60,6 +60,7 @@ const Practice = () => { const [openMessageDialog, setOpenMessageDialog] = useState(""); const { state } = useLocation(); const lang = getLocalData("lang"); + const [totalSyllableCount, setTotalSyllableCount] = useState(''); const gameOver = (data) => { let userWon = livesData?.redLivesToShow > 0; @@ -223,6 +224,7 @@ const Practice = () => { sessionId: sessionId, subSessionId: sub_session_id, milestoneLevel: getSetData?.data?.currentLevel, + totalSyllableCount: totalSyllableCount, language: localStorage.getItem("lang"), } ); @@ -280,9 +282,10 @@ const Practice = () => { `${process.env.REACT_APP_LEARNER_AI_APP_HOST}/${config.URLS.GET_CONTENT}/${currentGetContent.criteria}/${virtualId}?language=${lang}&contentlimit=${limit}&gettargetlimit=${limit}` ); + setTotalSyllableCount(resGetContent?.data?.totalSyllableCount) setLivesData({ ...livesData, - totalTargets: resGetContent?.data?.totalTargets, + totalTargets: resGetContent?.data?.totalSyllableCount, targetsForLives: resGetContent?.data?.totalTargets * TARGETS_PERCENTAGE, targetPerLive: @@ -413,9 +416,10 @@ const Practice = () => { const resWord = await axios.get( `${process.env.REACT_APP_LEARNER_AI_APP_HOST}/${config.URLS.GET_CONTENT}/${currentGetContent.criteria}/${virtualId}?language=${lang}&contentlimit=${limit}&gettargetlimit=${limit}` ); + setTotalSyllableCount(resGetContent?.data?.totalSyllableCount) setLivesData({ ...livesData, - totalTargets: resWord?.data?.totalTargets, + totalTargets: resWord?.data?.totalSyllableCount, targetsForLives: resWord?.data?.totalTargets * TARGETS_PERCENTAGE, targetPerLive: (resWord?.data?.totalTargets * TARGETS_PERCENTAGE) / LIVES, @@ -502,9 +506,10 @@ const Practice = () => { const resWord = await axios.get( `${process.env.REACT_APP_LEARNER_AI_APP_HOST}/${config.URLS.GET_CONTENT}/${currentGetContent.criteria}/${virtualId}?language=${lang}&contentlimit=${limit}&gettargetlimit=${limit}` ); + setTotalSyllableCount(resGetContent?.data?.totalSyllableCount) setLivesData({ ...livesData, - totalTargets: resWord?.data?.totalTargets, + totalTargets: resWord?.data?.totalSyllableCount, targetsForLives: resWord?.data?.totalTargets * TARGETS_PERCENTAGE, targetPerLive: (resWord?.data?.totalTargets * TARGETS_PERCENTAGE) / LIVES,