Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-073
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-073
2022-073
Commits
37a939b6
Commit
37a939b6
authored
Oct 10, 2022
by
randi480
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mental chronometry changes
parent
cf133f23
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
5 deletions
+69
-5
web-app/backend/server.py
web-app/backend/server.py
+26
-0
web-app/frontend/src/components/activities/mentalChronometryEval/coding/CodingContainer.jsx
...tivities/mentalChronometryEval/coding/CodingContainer.jsx
+43
-5
No files found.
web-app/backend/server.py
View file @
37a939b6
...
...
@@ -331,6 +331,32 @@ def predictShapePattern():
return
jsonify
(
response
)
@
app
.
route
(
'/mentalChromScores'
,
methods
=
[
'POST'
])
@
cross_origin
()
def
mentalChromScores
():
body
=
request
.
json
activityName
=
body
[
'activityName'
]
score
=
body
[
'score'
]
actualResult
=
body
[
'actualResult'
]
predResult
=
body
[
'predResult'
]
createdTime
=
body
[
'createdTime'
]
totalTime
=
body
[
'totalTime'
]
# db.users.insert_one({
db
.
db
[
'mentalChronomrtryScore'
]
.
insert_one
({
"activityName"
:
activityName
,
"score"
:
score
,
"actualResult"
:
actualResult
,
"predResult"
:
predResult
,
"createdTime"
:
createdTime
,
"totalTime"
:
totalTime
,
})
return
jsonify
({
'status'
:
'MentalCrom scores are added to the system successfully!'
,
})
# @app.route("/testDB")
# def test():
# db.db.collection.insert_one({"name": "John"})
...
...
web-app/frontend/src/components/activities/mentalChronometryEval/coding/CodingContainer.jsx
View file @
37a939b6
...
...
@@ -3,6 +3,7 @@ import axios from "axios";
import
"
./CodingDrawingPad.css
"
;
import
SignaturePad
from
"
react-signature-canvas
"
;
import
DeleteForeverIcon
from
"
@mui/icons-material/DeleteForever
"
;
import
API
from
"
../../../../config/api
"
;
const
CodingContainer
=
()
=>
{
const
sigCanvas
=
useRef
({});
...
...
@@ -19,7 +20,7 @@ const CodingContainer = () => {
const
[
activityCompleted
,
setActivityCompleted
]
=
useState
(
false
);
const
[
finalScore
,
setFinalScore
]
=
useState
(
0
);
const
[
letterPatternANswers
,
setLetterPatternANswers
]
=
useState
([]);
const
[
actualResul
,
setActualResul
]
=
useState
([
const
[
actualResul
t
,
setActualResul
]
=
useState
([
"
square
"
,
"
circle
"
,
"
triangle
"
,
...
...
@@ -52,6 +53,41 @@ const CodingContainer = () => {
"
s
"
,
]);
var
finalResult
=
0
;
const
[
activityName
]
=
useState
(
"
Coding
"
);
let
saveScore
=
async
()
=>
{
const
headerConfig
=
{
headers
:
{
"
Access-Control-Allow-Origin
"
:
"
*
"
,
"
Content-Type
"
:
"
application/json
"
,
},
};
try
{
const
payload
=
{
activityName
:
activityName
,
score
:
finalResult
,
actualResult
:
actualResult
,
predResult
:
letterPatternANswers
,
totalTime
:
time
,
createdTime
:
Date
(),
};
await
API
.
post
(
"
mentalChromScores
"
,
JSON
.
stringify
(
payload
),
headerConfig
)
.
then
((
res
)
=>
{
if
(
res
.
status
===
200
)
{
console
.
log
(
res
);
}
})
.
catch
((
err
)
=>
{
console
.
log
(
err
);
});
}
catch
(
err
)
{
console
.
log
(
err
);
}
};
useEffect
(()
=>
{
const
calculateTime
=
()
=>
{
setTimeout
(()
=>
{
...
...
@@ -82,15 +118,16 @@ const CodingContainer = () => {
const
generateScore
=
()
=>
{
let
result
=
0
;
for
(
let
i
=
0
;
i
<=
actualResul
.
length
;
i
++
)
{
console
.
log
(
actualResul
[
i
]);
for
(
let
i
=
0
;
i
<=
actualResul
t
.
length
;
i
++
)
{
console
.
log
(
actualResul
t
[
i
]);
console
.
log
(
letterPatternANswers
[
i
]);
if
(
actualResul
[
i
]
===
letterPatternANswers
[
i
])
{
if
(
actualResul
t
[
i
]
===
letterPatternANswers
[
i
])
{
result
+=
1
;
setFinalScore
(
result
);
}
}
finalResult
=
result
;
console
.
log
(
result
);
};
...
...
@@ -141,6 +178,7 @@ const CodingContainer = () => {
setIsCancelled
(
true
);
generateScore
();
setActivityCompleted
(
true
);
saveScore
();
}
};
return
(
...
...
@@ -273,7 +311,7 @@ const CodingContainer = () => {
alt=
"pattern"
/>
<
h1
className=
"text-black"
>
Final Score
{
finalScore
&&
finalScore
}
/
{
actualResul
.
length
}
Final Score
{
finalScore
&&
finalScore
}
/
{
actualResul
t
.
length
}
</
h1
>
<
h1
className=
"text-black"
>
Total Time
{
time
.
hours
<
10
?
"
0
"
+
time
.
hours
:
time
.
hours
}
:
{
"
"
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment