Skip to content

Commit 7773962

Browse files
authored
Merge pull request #6 from sytraore/version2
Version2 fixed CI/CD pipeline errors and test
2 parents 881745a + 699e165 commit 7773962

24 files changed

Lines changed: 138 additions & 55 deletions

apps/backend/src/db.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const __filename = fileURLToPath(import.meta.url);
1010
const __dirname = path.dirname(__filename);
1111

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

1616
async function connectToDb(){
1717
try {

apps/frontend/jest.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ export default {
66
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }]
77
},
88
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
9-
coverageDirectory: 'test-output/jest/coverage'
9+
coverageDirectory: 'test-output/jest/coverage',
10+
passWithNoTests: true // added this line to pass the CI test run
1011
};

apps/frontend/src/components/animationNoCircleDraw.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import '../styles/animation.css';
44
// AnimationNoCircle component to handle animation logic without circleDraw function
55
function AnimationNoCircle({ onAnimationFinish }) {
66
const [percent, setPercent] = useState(0); // track progress
7-
const [animationFinished, setAnimationFinished] = useState(false); // track if animation finished
7+
//const [animationFinished, setAnimationFinished] = useState(false); // track if animation finished
88

99
// useEffect hook to handle animation progress
1010
useEffect(() => {

apps/frontend/src/components/circleDraw.jsx

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,45 @@ function Canvas({ onAnimationFinish }) {
4343

4444

4545
const isCircle = () => {
46-
if (circlePath.length < 10) {
46+
if (circlePath.length < 20) {
4747
console.log('Too few points to form a circle');
4848
return false; // Not enough points to form a circle
4949
}
5050

51-
const start = circlePath[0];
51+
//const start = circlePath[0];
5252
const end = circlePath[circlePath.length - 1];
53-
54-
// Check if the start and end points are close enough
55-
const distance = Math.sqrt((start.x - end.x) ** 2 + (start.y - end.y) ** 2);
56-
console.log('Start-End Distance:', distance);
57-
if (distance > 20) { // Adjust the threshold as needed
58-
console.log('Start and end points are too far apart');
59-
return false;
53+
let isClosed = false;
54+
55+
// Define how many of the initial points to check against.
56+
// Let's check against the first 25% of the path, up to a max of 30 points.
57+
const checkZoneLength = Math.min(40, Math.floor(circlePath.length * 0.5));
58+
59+
// Check if the path closes on itself
60+
// Loop through the first few points of the path and see if the
61+
// endpoint is close to any of them.
62+
for (let i = 0; i < checkZoneLength; i++) {
63+
const pointNearStart = circlePath[i];
64+
const distance = Math.sqrt((pointNearStart.x - end.x) ** 2 + (pointNearStart.y - end.y) ** 2);
65+
66+
if (distance < 25) { // Threshold for considering the loop "closed"
67+
isClosed = true;
68+
console.log('Path is considered closed.');
69+
break; // Exit the loop once we find a close point
70+
}
71+
}
72+
73+
if (!isClosed) {
74+
console.log('Start and end points are too far apart');
75+
return false;
6076
}
77+
78+
// // Check if the start and end points are close enough
79+
// const distance = Math.sqrt((start.x - end.x) ** 2 + (start.y - end.y) ** 2);
80+
// console.log('Start-End Distance:', distance);
81+
// if (distance > 20) { // Adjust the threshold as needed
82+
// console.log('Start and end points are too far apart');
83+
// return false;
84+
// }
6185

6286
// Calculate the center of the path
6387
const centerX = (Math.min(...circlePath.map((p) => p.x)) + Math.max(...circlePath.map((p) => p.x))) / 2;

apps/frontend/src/components/profile.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { Link, useNavigate } from "react-router-dom";
2+
import { useNavigate } from "react-router-dom";
33
import '../styles/profile.css';
44
import profileicon from '../assests/profileicon.png';
55

apps/frontend/src/data/practiceData.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ animals: [
327327
top: "70%",
328328
left: "5%",
329329
height: "150px"
330-
},,
330+
},
331331
{
332332
id: 8,
333333
name:"horse8",
@@ -402,7 +402,7 @@ animals: [
402402
top: "60%",
403403
left: "35%",
404404
height: "150px"
405-
},,
405+
},
406406
{
407407
id: 8,
408408
name:"hippo8",
@@ -469,7 +469,7 @@ animals: [
469469
top: "60%",
470470
left: "70%",
471471
height: "250px"
472-
},,
472+
},
473473
{
474474
id: 8,
475475
name:"octopus8",

apps/frontend/src/helpers/SaveAnswers.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ export async function saveAnswers(pageType) {
33

44
try {
55
let answersKey;
6-
let answersData;
6+
const answersData = {
7+
answers: [],
8+
pageType: ''
9+
};
710

811
switch (pageType) {
912
case 'baselineTraining':
@@ -44,10 +47,12 @@ export async function saveAnswers(pageType) {
4447
return;
4548
}
4649

47-
answersData = {
48-
answers : answers,
49-
pageType: answersKey
50-
};
50+
// answersData = {
51+
// answers : answers,
52+
// pageType: answersKey
53+
// };
54+
answersData.answers = answers;
55+
answersData.pageType = answersKey;
5156

5257
console.log("answerData:", answersData)
5358

apps/frontend/src/helpers/trayGenerators.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ const cookiePositions = {
8484

8585
for (let i = 0; i < numCookies; i++) {
8686
let newCookie;
87-
let tries = 0, maxTries = 100;
87+
let tries = 0;
88+
const maxTries = 100;
8889

8990
while (tries < maxTries) {
9091
newCookie = {

apps/frontend/src/pages/TouchTrainingPage.jsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const TouchTrainingPage = () => {
9393
speakUtterance();
9494
spokenRef.current = true;
9595
}
96-
}, [currentPage]);
96+
}, [currentPage, speakUtterance]);
9797

9898
useEffect(() => {
9999
if(!once.current){
@@ -183,6 +183,10 @@ const TouchTrainingPage = () => {
183183
allCookies.forEach(cookie => {
184184
cookie.style.pointerEvents = 'auto';
185185
});
186+
const instruction = `Great job! Now draw a circle with your finger by following the yellow line.`;
187+
setTimeout(() => {
188+
textToSpeech(instruction);
189+
}, 3000);
186190
}
187191
} else {
188192
console.error("SpeechSynthesis API is not supported in this browser.");
@@ -242,6 +246,22 @@ const TouchTrainingPage = () => {
242246

243247
const handleTrayClick = (trayType) => {
244248
setSelectedTray(trayType);
249+
// if the correct tray has been clicked
250+
if (trayType === "greenTray" && sectionTrainData.pages[currentPage].greenTray[0].biscuits.length === sectionTrainData.pages[currentPage].cookies.length) {
251+
textToSpeech("Green is correct, Good job!");
252+
}
253+
else if (trayType === "purpleTray" && sectionTrainData.pages[currentPage].purpleTray[0].biscuits.length === sectionTrainData.pages[currentPage].cookies.length){
254+
textToSpeech("Purple is correct, Well done!");
255+
}
256+
// if the wrong tray has been clicked
257+
else if (trayType === "greenTray" && sectionTrainData.pages[currentPage].greenTray[0].biscuits.length !== sectionTrainData.pages[currentPage].cookies.length) {
258+
const explanation = `No, ${trayType} has ${sectionTrainData.pages[currentPage].greenTray[0].biscuits.length} cookies. Try again!`;
259+
textToSpeech(explanation);
260+
}
261+
else{
262+
const explanation = `Wrong answer, ${trayType} has ${sectionTrainData.pages[currentPage].purpleTray[0].biscuits.length} cookies. Try again!`;
263+
textToSpeech(explanation);
264+
}
245265
storeAnswer(currentPage, trayType);
246266
};
247267

@@ -300,6 +320,7 @@ const TouchTrainingPage = () => {
300320
src={biscuit.img}
301321
id={biscuit.id}
302322
className="biscuits"
323+
alt=""
303324
style={{
304325
position: "absolute",
305326
top: biscuit.top,
@@ -331,6 +352,7 @@ const TouchTrainingPage = () => {
331352
src={biscuit.img}
332353
id={biscuit.id}
333354
className="biscuits"
355+
alt=""
334356
style={{
335357
position: "absolute",
336358
top: biscuit.top,

apps/frontend/src/pages/animationTrainingPage.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ const AnimationTrainingPage = () => {
245245
src={biscuit.img}
246246
id={biscuit.id}
247247
className="biscuits"
248+
alt=""
248249
style={{
249250
position: "absolute",
250251
top: biscuit.top,
@@ -275,6 +276,7 @@ const AnimationTrainingPage = () => {
275276
src={biscuit.img}
276277
id={biscuit.id}
277278
className="biscuits"
279+
alt=""
278280
style={{
279281
position: "absolute",
280282
top: biscuit.top,

0 commit comments

Comments
 (0)