Denis Thiessen
6 months ago
27 changed files with 841 additions and 547 deletions
-
181src/App.js
-
6src/App.test.js
-
25src/components/DownloadButton.jsx
-
12src/components/InfoPageComponent.jsx
-
21src/components/RandomIDComponent.jsx
-
41src/components/questionnaire/QuestionComponent.jsx
-
6src/components/questionnaire/QuestionData.jsx
-
10src/components/questionnaire/QuestionnaireData.jsx
-
11src/components/webpage_container/StudySite.jsx
-
7src/components/webpage_container/WebpageBanner.jsx
-
9src/core/audio/AudioHandler.jsx
-
20src/core/audio/ChordHelper.jsx
-
8src/core/i18n/i18n.js
-
6src/core/log/RouteTracker.jsx
-
16src/core/log/SensorLogger.jsx
-
15src/index.js
-
6src/interfaces/DataComponent.jsx
-
4src/interfaces/ResetableComponent.jsx
-
3src/pages/NoPageFound.jsx
-
6src/pages/TestEndPage.jsx
-
18src/pages/TestInfoPage.jsx
-
18src/pages/TestInfoPage2.jsx
-
22src/pages/TestPage.jsx
-
21src/pages/TestPage2.jsx
-
28src/pages/TestQuestionnaire.jsx
-
130src/pages/study_site_1/StartPage1.jsx
@ -1,7 +1,7 @@ |
|||
import { render, screen } from '@testing-library/react'; |
|||
import App from './App'; |
|||
import { render, screen } from "@testing-library/react"; |
|||
import App from "./App"; |
|||
|
|||
test('renders learn react link', () => { |
|||
test("renders learn react link", () => { |
|||
render(<App />); |
|||
const linkElement = screen.getByText(/learn react/i); |
|||
expect(linkElement).toBeInTheDocument(); |
|||
|
@ -1,42 +1,41 @@ |
|||
import React from "react"; |
|||
import { getTranslation } from "../core/i18n/I18NHandler"; |
|||
import { getSensorLog } from "../core/log/SensorLogger"; |
|||
import { Button } from '@geist-ui/core'; |
|||
import { Button } from "@geist-ui/core"; |
|||
import { getUserID } from "./RandomIDComponent"; |
|||
import { PARTICIPANT_NUMBER } from "../core/Constants"; |
|||
|
|||
function DownloadButton() { |
|||
const downloadFile = ({ data, fileName, fileType }) => { |
|||
const blob = new Blob([data], { type: fileType }); |
|||
const a = document.createElement('a'); |
|||
const a = document.createElement("a"); |
|||
a.download = fileName; |
|||
a.href = window.URL.createObjectURL(blob); |
|||
const clickEvt = new MouseEvent('click', { |
|||
const clickEvt = new MouseEvent("click", { |
|||
view: window, |
|||
bubbles: true, |
|||
cancelable: true, |
|||
}); |
|||
a.dispatchEvent(clickEvt); |
|||
a.remove(); |
|||
} |
|||
|
|||
}; |
|||
|
|||
const userData = { |
|||
participantId: getUserID(), |
|||
sensorLog: getSensorLog(), |
|||
participantNumber: PARTICIPANT_NUMBER |
|||
} |
|||
participantNumber: PARTICIPANT_NUMBER, |
|||
}; |
|||
|
|||
const exportToJson = e => { |
|||
const exportToJson = (e) => { |
|||
e.preventDefault(); |
|||
downloadFile({ |
|||
data: JSON.stringify(userData), |
|||
fileName: 'sensorData.json', |
|||
fileType: 'text/json', |
|||
}) |
|||
} |
|||
fileName: "sensorData.json", |
|||
fileType: "text/json", |
|||
}); |
|||
}; |
|||
|
|||
return (<Button onClick={exportToJson}>{getTranslation("download")}</Button>); |
|||
return <Button onClick={exportToJson}>{getTranslation("download")}</Button>; |
|||
} |
|||
|
|||
export default DownloadButton; |
@ -1,7 +1,5 @@ |
|||
import React from 'react'; |
|||
import React from "react"; |
|||
|
|||
export default class ResetableComponent extends React.Component { |
|||
|
|||
reset() {} |
|||
|
|||
} |
@ -1,8 +1,7 @@ |
|||
import React from "react"; |
|||
|
|||
export default class NoPageFound extends React.Component { |
|||
|
|||
render() { |
|||
return (<p>No Page Found</p>); |
|||
return <p>No Page Found</p>; |
|||
} |
|||
} |
@ -1,17 +1,31 @@ |
|||
import React from "react"; |
|||
import { getTranslation } from "../core/i18n/I18NHandler"; |
|||
import WebpageBanner from "../components/webpage_container/WebpageBanner"; |
|||
import { StudySite, getHeatmapData } from "../components/webpage_container/StudySite"; |
|||
import { |
|||
StudySite, |
|||
getHeatmapData, |
|||
} from "../components/webpage_container/StudySite"; |
|||
import { pushToMouseLog, getSensorLog } from "../core/log/SensorLogger"; |
|||
import { Button } from '@geist-ui/core'; |
|||
|
|||
import { Button } from "@geist-ui/core"; |
|||
|
|||
function TestPage({ redirectLoc }) { |
|||
var clickFunction = function () { |
|||
pushToMouseLog(getHeatmapData()); |
|||
window.location.href = "./" + redirectLoc; |
|||
}; |
|||
return (<StudySite><WebpageBanner translationKey="hello_world" /><p onClick={() => {clickFunction()}}>{getTranslation("hello_world")}</p><Button onClick={clickFunction}>Ye</Button></StudySite>); |
|||
return ( |
|||
<StudySite> |
|||
<WebpageBanner translationKey="hello_world" /> |
|||
<p |
|||
onClick={() => { |
|||
clickFunction(); |
|||
}} |
|||
> |
|||
{getTranslation("hello_world")} |
|||
</p> |
|||
<Button onClick={clickFunction}>Ye</Button> |
|||
</StudySite> |
|||
); |
|||
} |
|||
|
|||
export default TestPage; |
@ -1,16 +1,31 @@ |
|||
import React from "react"; |
|||
import { getTranslation } from "../core/i18n/I18NHandler"; |
|||
import WebpageBanner from "../components/webpage_container/WebpageBanner"; |
|||
import { StudySite, getHeatmapData } from "../components/webpage_container/StudySite"; |
|||
import { |
|||
StudySite, |
|||
getHeatmapData, |
|||
} from "../components/webpage_container/StudySite"; |
|||
import { pushToMouseLog } from "../core/log/SensorLogger"; |
|||
import { Button } from '@geist-ui/core'; |
|||
import { Button } from "@geist-ui/core"; |
|||
|
|||
function TestPage2({ redirectLoc }) { |
|||
var clickFunction = function () { |
|||
pushToMouseLog(getHeatmapData()); |
|||
window.location.href = "./" + redirectLoc; |
|||
}; |
|||
return (<StudySite><WebpageBanner translationKey="hello_world" /><p>{getTranslation("hello_world")}</p><Button onClick={() => {clickFunction()}}>Go on...</Button></StudySite>); |
|||
return ( |
|||
<StudySite> |
|||
<WebpageBanner translationKey="hello_world" /> |
|||
<p>{getTranslation("hello_world")}</p> |
|||
<Button |
|||
onClick={() => { |
|||
clickFunction(); |
|||
}} |
|||
> |
|||
Go on... |
|||
</Button> |
|||
</StudySite> |
|||
); |
|||
} |
|||
|
|||
export default TestPage2; |
@ -1,21 +1,35 @@ |
|||
import React from "react"; |
|||
import { useParams } from 'react-router-dom'; |
|||
import { useParams } from "react-router-dom"; |
|||
import QuestionComponent from "../components/questionnaire/QuestionComponent"; |
|||
import { useQuestionComponent } from "../components/questionnaire/QuestionnaireData"; |
|||
|
|||
|
|||
export default function TestQuestionnaire() { |
|||
const { id } = useParams() |
|||
const { id } = useParams(); |
|||
|
|||
const q1Props = useQuestionComponent("checkbox", 4, "Lorem Ipsum", "/info", "./q2"); |
|||
const q2Props = useQuestionComponent("slider", 8, "Lorem Ipsum Ye", "./q1", "/info"); |
|||
const q1Props = useQuestionComponent( |
|||
"checkbox", |
|||
4, |
|||
"Lorem Ipsum", |
|||
"/info", |
|||
"./q2" |
|||
); |
|||
const q2Props = useQuestionComponent( |
|||
"slider", |
|||
8, |
|||
"Lorem Ipsum Ye", |
|||
"./q1", |
|||
"/info" |
|||
); |
|||
|
|||
const questionProperties = {"q1": q1Props, "q2": q2Props}; |
|||
const questionProperties = { q1: q1Props, q2: q2Props }; |
|||
const questionProperty = questionProperties[id]; |
|||
|
|||
return ( |
|||
<div> |
|||
<QuestionComponent {...questionProperty} onUpdateAnswerData={questionProperty.handleUpdateAnswerData} /> |
|||
<QuestionComponent |
|||
{...questionProperty} |
|||
onUpdateAnswerData={questionProperty.handleUpdateAnswerData} |
|||
/> |
|||
<p>Current Answer Data: {JSON.stringify(questionProperty.answerData)}</p> |
|||
</div> |
|||
); |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue