Skip to content
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 apps/backend/src/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

//const mongoUrl = `mongodb+srv://${uname}:${pw}@cluster0.oypxwnq.mongodb.net/?retryWrites=true&w=majority`;
//const mongoUrl = "mongodb://127.0.0.1:27017/counting";
const mongoUrl = process.env.MONGODB_URL;
const mongoUrl = "mongodb://127.0.0.1:27017/counting";
//const mongoUrl = process.env.MONGODB_URL;

async function connectToDb(){
try {
Expand Down
3 changes: 2 additions & 1 deletion apps/frontend/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ export default {
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }]
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: 'test-output/jest/coverage'
coverageDirectory: 'test-output/jest/coverage',
passWithNoTests: true // added this line to pass the CI test run
};
2 changes: 1 addition & 1 deletion apps/frontend/src/components/animationNoCircleDraw.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import '../styles/animation.css';
// AnimationNoCircle component to handle animation logic without circleDraw function
function AnimationNoCircle({ onAnimationFinish }) {
const [percent, setPercent] = useState(0); // track progress
const [animationFinished, setAnimationFinished] = useState(false); // track if animation finished
//const [animationFinished, setAnimationFinished] = useState(false); // track if animation finished

// useEffect hook to handle animation progress
useEffect(() => {
Expand Down
42 changes: 33 additions & 9 deletions apps/frontend/src/components/circleDraw.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,45 @@ function Canvas({ onAnimationFinish }) {


const isCircle = () => {
if (circlePath.length < 10) {
if (circlePath.length < 20) {
console.log('Too few points to form a circle');
return false; // Not enough points to form a circle
}

const start = circlePath[0];
//const start = circlePath[0];
const end = circlePath[circlePath.length - 1];

// Check if the start and end points are close enough
const distance = Math.sqrt((start.x - end.x) ** 2 + (start.y - end.y) ** 2);
console.log('Start-End Distance:', distance);
if (distance > 20) { // Adjust the threshold as needed
console.log('Start and end points are too far apart');
return false;
let isClosed = false;

// Define how many of the initial points to check against.
// Let's check against the first 25% of the path, up to a max of 30 points.
const checkZoneLength = Math.min(40, Math.floor(circlePath.length * 0.5));

// Check if the path closes on itself
// Loop through the first few points of the path and see if the
// endpoint is close to any of them.
for (let i = 0; i < checkZoneLength; i++) {
const pointNearStart = circlePath[i];
const distance = Math.sqrt((pointNearStart.x - end.x) ** 2 + (pointNearStart.y - end.y) ** 2);

if (distance < 25) { // Threshold for considering the loop "closed"
isClosed = true;
console.log('Path is considered closed.');
break; // Exit the loop once we find a close point
}
}

if (!isClosed) {
console.log('Start and end points are too far apart');
return false;
}

// // Check if the start and end points are close enough
// const distance = Math.sqrt((start.x - end.x) ** 2 + (start.y - end.y) ** 2);
// console.log('Start-End Distance:', distance);
// if (distance > 20) { // Adjust the threshold as needed
// console.log('Start and end points are too far apart');
// return false;
// }

// Calculate the center of the path
const centerX = (Math.min(...circlePath.map((p) => p.x)) + Math.max(...circlePath.map((p) => p.x))) / 2;
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/components/profile.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Link, useNavigate } from "react-router-dom";
import { useNavigate } from "react-router-dom";
import '../styles/profile.css';
import profileicon from '../assests/profileicon.png';

Expand Down
6 changes: 3 additions & 3 deletions apps/frontend/src/data/practiceData.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ animals: [
top: "70%",
left: "5%",
height: "150px"
},,
},
{
id: 8,
name:"horse8",
Expand Down Expand Up @@ -402,7 +402,7 @@ animals: [
top: "60%",
left: "35%",
height: "150px"
},,
},
{
id: 8,
name:"hippo8",
Expand Down Expand Up @@ -469,7 +469,7 @@ animals: [
top: "60%",
left: "70%",
height: "250px"
},,
},
{
id: 8,
name:"octopus8",
Expand Down
15 changes: 10 additions & 5 deletions apps/frontend/src/helpers/SaveAnswers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ export async function saveAnswers(pageType) {

try {
let answersKey;
let answersData;
const answersData = {
answers: [],
pageType: ''
};

switch (pageType) {
case 'baselineTraining':
Expand Down Expand Up @@ -44,10 +47,12 @@ export async function saveAnswers(pageType) {
return;
}

answersData = {
answers : answers,
pageType: answersKey
};
// answersData = {
// answers : answers,
// pageType: answersKey
// };
answersData.answers = answers;
answersData.pageType = answersKey;

console.log("answerData:", answersData)

Expand Down
3 changes: 2 additions & 1 deletion apps/frontend/src/helpers/trayGenerators.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ const cookiePositions = {

for (let i = 0; i < numCookies; i++) {
let newCookie;
let tries = 0, maxTries = 100;
let tries = 0;
const maxTries = 100;

while (tries < maxTries) {
newCookie = {
Expand Down
24 changes: 23 additions & 1 deletion apps/frontend/src/pages/TouchTrainingPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const TouchTrainingPage = () => {
speakUtterance();
spokenRef.current = true;
}
}, [currentPage]);
}, [currentPage, speakUtterance]);

useEffect(() => {
if(!once.current){
Expand Down Expand Up @@ -183,6 +183,10 @@ const TouchTrainingPage = () => {
allCookies.forEach(cookie => {
cookie.style.pointerEvents = 'auto';
});
const instruction = `Great job! Now draw a circle with your finger by following the yellow line.`;
setTimeout(() => {
textToSpeech(instruction);
}, 3000);
}
} else {
console.error("SpeechSynthesis API is not supported in this browser.");
Expand Down Expand Up @@ -242,6 +246,22 @@ const TouchTrainingPage = () => {

const handleTrayClick = (trayType) => {
setSelectedTray(trayType);
// if the correct tray has been clicked
if (trayType === "greenTray" && sectionTrainData.pages[currentPage].greenTray[0].biscuits.length === sectionTrainData.pages[currentPage].cookies.length) {
textToSpeech("Green is correct, Good job!");
}
else if (trayType === "purpleTray" && sectionTrainData.pages[currentPage].purpleTray[0].biscuits.length === sectionTrainData.pages[currentPage].cookies.length){
textToSpeech("Purple is correct, Well done!");
}
// if the wrong tray has been clicked
else if (trayType === "greenTray" && sectionTrainData.pages[currentPage].greenTray[0].biscuits.length !== sectionTrainData.pages[currentPage].cookies.length) {
const explanation = `No, ${trayType} has ${sectionTrainData.pages[currentPage].greenTray[0].biscuits.length} cookies. Try again!`;
textToSpeech(explanation);
}
else{
const explanation = `Wrong answer, ${trayType} has ${sectionTrainData.pages[currentPage].purpleTray[0].biscuits.length} cookies. Try again!`;
textToSpeech(explanation);
}
storeAnswer(currentPage, trayType);
};

Expand Down Expand Up @@ -300,6 +320,7 @@ const TouchTrainingPage = () => {
src={biscuit.img}
id={biscuit.id}
className="biscuits"
alt=""
style={{
position: "absolute",
top: biscuit.top,
Expand Down Expand Up @@ -331,6 +352,7 @@ const TouchTrainingPage = () => {
src={biscuit.img}
id={biscuit.id}
className="biscuits"
alt=""
style={{
position: "absolute",
top: biscuit.top,
Expand Down
2 changes: 2 additions & 0 deletions apps/frontend/src/pages/animationTrainingPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ const AnimationTrainingPage = () => {
src={biscuit.img}
id={biscuit.id}
className="biscuits"
alt=""
style={{
position: "absolute",
top: biscuit.top,
Expand Down Expand Up @@ -275,6 +276,7 @@ const AnimationTrainingPage = () => {
src={biscuit.img}
id={biscuit.id}
className="biscuits"
alt=""
style={{
position: "absolute",
top: biscuit.top,
Expand Down
4 changes: 3 additions & 1 deletion apps/frontend/src/pages/animationpage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const AnimationPage = () => {
speakUtterance();
spokenRef.current = true;
}
}, [currentPage]);
}, [currentPage, speakUtterance]);

useEffect(() => {
if (!once.current) {
Expand Down Expand Up @@ -235,6 +235,7 @@ const AnimationPage = () => {
src={biscuit.img}
id={biscuit.id}
className="biscuits"
alt=""
style={{
position: "absolute",
top: biscuit.top,
Expand Down Expand Up @@ -265,6 +266,7 @@ const AnimationPage = () => {
src={biscuit.img}
id={biscuit.id}
className="biscuits"
alt=""
style={{
position: "absolute",
top: biscuit.top,
Expand Down
6 changes: 4 additions & 2 deletions apps/frontend/src/pages/basePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { textToSpeech } from '../helpers/textToSpeech';
import {handleInteraction, handleNextClickTouchData} from '../helpers/imageTouchData';
import { saveAnswers } from "../helpers/SaveAnswers";

function basePage() {
function BasePage() {
const { baseData, selectedOption } = useAppData();
const { page } = useParams();
const currentPage = parseInt(page);
Expand Down Expand Up @@ -191,6 +191,7 @@ function basePage() {
src={biscuit.img}
id={biscuit.id}
className="biscuits"
alt=""
style={{
position: "absolute",
top: biscuit.top,
Expand Down Expand Up @@ -221,6 +222,7 @@ function basePage() {
src={biscuit.img}
id={biscuit.id}
className="biscuits"
alt=""
style={{
position: "absolute",
top: biscuit.top,
Expand Down Expand Up @@ -279,4 +281,4 @@ function basePage() {
);
}

export default basePage;
export default BasePage;
6 changes: 4 additions & 2 deletions apps/frontend/src/pages/basePage2.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { textToSpeech } from '../helpers/textToSpeech';
import { handleInteraction, handleNextClickTouchData } from '../helpers/imageTouchData';
import { saveAnswers } from "../helpers/SaveAnswers";

function BasePage() {
function BasePage2() {
const { baseData, selectedOption } = useAppData();
const { page } = useParams();
const currentPage = parseInt(page);
Expand Down Expand Up @@ -165,6 +165,7 @@ function BasePage() {
src={biscuit.img}
id={biscuit.id}
className="biscuits"
alt=""
style={{
position: "absolute",
top: biscuit.top,
Expand Down Expand Up @@ -195,6 +196,7 @@ function BasePage() {
src={biscuit.img}
id={biscuit.id}
className="biscuits"
alt=""
style={{
position: "absolute",
top: biscuit.top,
Expand Down Expand Up @@ -246,4 +248,4 @@ function BasePage() {
);
}

export default BasePage;
export default BasePage2;
6 changes: 4 additions & 2 deletions apps/frontend/src/pages/baseTraining.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { textToSpeech } from '../helpers/textToSpeech';
import {handleInteraction, handleNextClickTraining} from '../helpers/imageTouchData';
import { saveAnswers } from "../helpers/SaveAnswers";

function basePage() {
function BaseTrainingPage() {
const { sectionTrainData, selectedOption } = useAppData();
const { page } = useParams();
const currentPage = parseInt(page);
Expand Down Expand Up @@ -181,6 +181,7 @@ function basePage() {
src={biscuit.img}
id={biscuit.id}
className="biscuits"
alt={`Biscuit ${biscuit.id}`}
style={{
position: "absolute",
top: biscuit.top,
Expand Down Expand Up @@ -211,6 +212,7 @@ function basePage() {
src={biscuit.img}
id={biscuit.id}
className="biscuits"
alt=""
style={{
position: "absolute",
top: biscuit.top,
Expand Down Expand Up @@ -269,4 +271,4 @@ function basePage() {
);
}

export default basePage;
export default BaseTrainingPage;
6 changes: 4 additions & 2 deletions apps/frontend/src/pages/baseTraining2.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { textToSpeech } from '../helpers/textToSpeech';
import { handleInteraction, handleNextClickTraining } from '../helpers/imageTouchData';
import { saveAnswers } from "../helpers/SaveAnswers";

function BasePage() {
function BaseTraining2() {
const { sectionTrainData, selectedOption } = useAppData();
const { page } = useParams();
const currentPage = parseInt(page);
Expand Down Expand Up @@ -165,6 +165,7 @@ function BasePage() {
src={biscuit.img}
id={biscuit.id}
className="biscuits"
alt={`Biscuit ${biscuit.id}`}
style={{
position: "absolute",
top: biscuit.top,
Expand Down Expand Up @@ -195,6 +196,7 @@ function BasePage() {
src={biscuit.img}
id={biscuit.id}
className="biscuits"
alt=""
style={{
position: "absolute",
top: biscuit.top,
Expand Down Expand Up @@ -250,4 +252,4 @@ function BasePage() {
);
}

export default BasePage;
export default BaseTraining2;
Loading