Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All 1.3 feedback change #247

Merged
merged 5 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/Assesment/Assesment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ const Assesment = ({ discoverStart }) => {
}

localStorage.setItem("lang", lang || "ta");
if (localStorage.getItem("contentSessionId") !== null) {
if (process.env.REACT_APP_IS_APP_IFRAME !== "true" && localStorage.getItem("contentSessionId") !== null) {
const getPointersDetails = await axios.get(
`${process.env.REACT_APP_LEARNER_AI_ORCHESTRATION_HOST}/${config.URLS.GET_POINTER}/${usernameDetails?.data?.result?.virtualID}/${session_id}?language=${lang}`
);
Expand Down Expand Up @@ -637,7 +637,7 @@ const Assesment = ({ discoverStart }) => {
localStorage.setItem("sessionId", sessionId);
}

if (virtualId && localStorage.getItem("contentSessionId") !== null) {
if (process.env.REACT_APP_IS_APP_IFRAME !== "true" && virtualId && localStorage.getItem("contentSessionId") !== null) {
const getPointersDetails = await axios.get(
`${process.env.REACT_APP_LEARNER_AI_ORCHESTRATION_HOST}/${config.URLS.GET_POINTER}/${virtualId}/${sessionId}?language=${lang}`
);
Expand Down
3 changes: 1 addition & 2 deletions src/components/AssesmentEnd/AssesmentEnd.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ const AssesmentEnd = () => {
sessionId = uniqueId();
localStorage.setItem("sessionId", sessionId);
}

if (localStorage.getItem("contentSessionId") !== null) {
if (process.env.REACT_APP_IS_APP_IFRAME !== "true" && localStorage.getItem("contentSessionId") !== null) {
const getPointersDetails = await axios.get(
`${process.env.REACT_APP_LEARNER_AI_ORCHESTRATION_HOST}/${config.URLS.GET_POINTER}/${virtualId}/${sessionId}?language=${lang}`
);
Expand Down
8 changes: 6 additions & 2 deletions src/components/Practice/Mechanics3.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import VoiceAnalyser from "../../utils/VoiceAnalyser";
import { Modal } from "@mui/material";
import ZoomInIcon from "@mui/icons-material/ZoomIn";
import CloseIcon from "@mui/icons-material/Close";
import usePreloadAudio from "../../hooks/usePreloadAudio";

// TODO: update it as per File name OR update file name as per export variable name
const Mechanics2 = ({
Expand Down Expand Up @@ -64,6 +65,9 @@ const Mechanics2 = ({
const [shake, setShake] = useState(false);
const [wordToFill, setWordToFill] = useState("");
const [disabledWords, setDisabledWords] = useState(false);
const correctSoundAudio = usePreloadAudio(correctSound);
const wrongSoundAudio = usePreloadAudio(wrongSound);
const removeSoundAudio = usePreloadAudio(removeSound);
const [answer, setAnswer] = useState({
text: "",
audio_url: "",
Expand All @@ -85,7 +89,7 @@ const Mechanics2 = ({
setAnswer(word);

const isSoundCorrect = word.isAns;
let audio = new Audio(isSoundCorrect ? correctSound : wrongSound);
let audio = new Audio(isSoundCorrect ? correctSoundAudio : wrongSoundAudio);
if (!isSoundCorrect) {
setEnableNext(false);
}
Expand All @@ -97,7 +101,7 @@ const Mechanics2 = ({
};

const handleRemoveWord = () => {
let audio = new Audio(removeSound);
let audio = new Audio(removeSoundAudio);
setAnswer({ text: "", audio_url: "", image_url: "", isAns: false });
audio.play();
setEnableNext(false);
Expand Down
11 changes: 8 additions & 3 deletions src/components/Practice/Mechanics4.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import wrongSound from "../../assets/audio/wrong.wav";
import addSound from "../../assets/audio/add.mp3";
import removeSound from "../../assets/audio/remove.wav";
import { splitGraphemes } from "split-graphemes";
import usePreloadAudio from "../../hooks/usePreloadAudio";

const Mechanics4 = ({
page,
Expand Down Expand Up @@ -51,6 +52,10 @@ const Mechanics4 = ({
const [words, setWords] = useState(
type === "word" ? [] : ["Friend", "She is", "My"]
);
const correctSoundAudio = usePreloadAudio(correctSound);
const wrongSoundAudio = usePreloadAudio(wrongSound);
const addSoundAudio = usePreloadAudio(addSound);
const removeSoundAudio = usePreloadAudio(removeSound);
const [wordsAfterSplit, setWordsAfterSplit] = useState([]);

useEffect(() => {
Expand Down Expand Up @@ -114,7 +119,7 @@ const Mechanics4 = ({
}, 3000);
// audioPlay[word]();
if (selectedWords?.length + 1 !== wordsAfterSplit?.length || isSelected) {
let audio = new Audio(isSelected ? removeSound : addSound);
let audio = new Audio(isSelected ? removeSoundAudio : addSoundAudio);
audio.play();
setEnableNext(false);
}
Expand All @@ -134,8 +139,8 @@ const Mechanics4 = ({
if (selectedWords?.length + 1 === wordsAfterSplit?.length) {
let audio = new Audio(
[...selectedWords, word]?.join(" ") === parentWords
? correctSound
: wrongSound
? correctSoundAudio
: wrongSoundAudio
);
audio.play();
}
Expand Down
5 changes: 4 additions & 1 deletion src/utils/VoiceAnalyser.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import config from "./urlConstants.json";
import { filterBadWords } from "./Badwords";
import S3Client from "../config/awsS3";
import { PutObjectCommand } from "@aws-sdk/client-s3";
import usePreloadAudio from "../hooks/usePreloadAudio";
/* eslint-disable */

const AudioPath = {
Expand Down Expand Up @@ -77,6 +78,8 @@ function VoiceAnalyser(props) {
process.env.REACT_APP_IS_AUDIOPREPROCESSING === "true"
);
const [isMatching, setIsMatching] = useState(false);
const livesAddAudio = usePreloadAudio(livesAdd);
const livesCutAudio = usePreloadAudio(livesCut);

//console.log('audio', recordedAudio, isMatching);

Expand Down Expand Up @@ -628,7 +631,7 @@ function VoiceAnalyser(props) {
} else {
isLiveLost = false;
}
const audio = new Audio(isLiveLost ? livesCut : livesAdd);
const audio = new Audio(isLiveLost ? livesCutAudio : livesAddAudio);
audio.play();

// Update the state or data structure with the new lives data.
Expand Down
2 changes: 1 addition & 1 deletion src/views/Practice/Practice.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ const Practice = () => {

// TODO: Handle Error for lessons - no lesson progress - starting point should be P1

if (localStorage.getItem("contentSessionId") !== null) {
if (process.env.REACT_APP_IS_APP_IFRAME !== "true" && localStorage.getItem("contentSessionId") !== null) {
const getPointersDetails = await axios.get(
`${process.env.REACT_APP_LEARNER_AI_ORCHESTRATION_HOST}/${config.URLS.GET_POINTER}/${virtualId}/${sessionId}?language=${lang}`
);
Expand Down
Loading