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
6c637833
Commit
6c637833
authored
Nov 12, 2022
by
Randika Monarawila
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'Randika-FInal-Changes' into 'master'
Randika final changes See merge request
!39
parents
5133ac3c
b8422f8c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
29 deletions
+95
-29
web-app/backend/server.py
web-app/backend/server.py
+18
-6
web-app/frontend/src/components/activities/mentalChronometryEval/coding/CodingContainer.jsx
...tivities/mentalChronometryEval/coding/CodingContainer.jsx
+20
-9
web-app/frontend/src/components/activities/mentalChronometryEval/letterPattern/LetterPattern.jsx
...ies/mentalChronometryEval/letterPattern/LetterPattern.jsx
+10
-1
web-app/frontend/src/components/activities/mentalChronometryEval/letterPattern/LetterPatternContainer.jsx
...lChronometryEval/letterPattern/LetterPatternContainer.jsx
+27
-4
web-app/frontend/src/components/activities/mentalChronometryEval/pairCancerlation/PairCancerlationContainer.jsx
...ometryEval/pairCancerlation/PairCancerlationContainer.jsx
+20
-9
No files found.
web-app/backend/server.py
View file @
6c637833
...
...
@@ -344,7 +344,9 @@ def predictShapePattern():
return
jsonify
(
response
)
# Reasoning IQ evaluation
@
app
.
route
(
'/predictPictureConcept'
,
methods
=
[
'POST'
,
'GET'
])
@
app
.
route
(
'/predictPictureConcept'
,
methods
=
[
'POST'
,
'GET'
])
@
cross_origin
()
def
predictPictureConcept
():
if
request
.
method
==
'POST'
:
...
...
@@ -356,7 +358,7 @@ def predictPictureConcept():
return
jsonify
({
'error: no file'
})
try
:
file
.
save
(
"./"
+
file
.
filename
)
prediction
=
transform_audio
(
file
.
filename
)
data
=
{
'prediction'
:
prediction
}
...
...
@@ -371,7 +373,8 @@ def predictPictureConcept():
return
jsonify
({
'error: Error during pipeline execution'
})
return
jsonify
({
'result: test'
})
@
app
.
route
(
'/predictArithmetic'
,
methods
=
[
'POST'
,
'GET'
])
@
app
.
route
(
'/predictArithmetic'
,
methods
=
[
'POST'
,
'GET'
])
@
cross_origin
()
def
predictArithmetic
():
if
request
.
method
==
'POST'
:
...
...
@@ -383,7 +386,7 @@ def predictArithmetic():
return
jsonify
({
'error: no file'
})
try
:
file
.
save
(
"./"
+
file
.
filename
)
prediction
=
transform_audio
(
file
.
filename
)
data
=
{
'prediction'
:
prediction
}
...
...
@@ -398,9 +401,11 @@ def predictArithmetic():
return
jsonify
({
'error: Error during pipeline execution'
})
return
jsonify
({
'result: test'
})
@
app
.
route
(
'/mentalChromScores'
,
methods
=
[
'POST'
])
@
cross_origin
()
def
mentalChromScores
():
body
=
request
.
json
activityName
=
body
[
'activityName'
]
score
=
body
[
'score'
]
...
...
@@ -408,6 +413,8 @@ def mentalChromScores():
predResult
=
body
[
'predResult'
]
createdTime
=
body
[
'createdTime'
]
totalTime
=
body
[
'totalTime'
]
candidateID
=
body
[
'candidateID'
]
answerImage
=
body
[
'answerImage'
]
# db.users.insert_one({
db
.
db
[
'mentalChronomrtryScore'
]
.
insert_one
({
"activityName"
:
activityName
,
...
...
@@ -416,13 +423,17 @@ def mentalChromScores():
"predResult"
:
predResult
,
"createdTime"
:
createdTime
,
"totalTime"
:
totalTime
,
"candidateID"
:
candidateID
,
"answerImage"
:
answerImage
})
return
jsonify
({
'status'
:
'MentalCrom scores are added to the system successfully!'
,
})
# Knowledge IQ evaluation
@
app
.
route
(
'/predictKnowledgeIq'
,
methods
=
[
'POST'
,
'GET'
])
@
app
.
route
(
'/predictKnowledgeIq'
,
methods
=
[
'POST'
,
'GET'
])
@
cross_origin
()
def
predictKnowledgeIq
():
if
request
.
method
==
'POST'
:
...
...
@@ -437,7 +448,8 @@ def predictKnowledgeIq():
file
.
save
(
"./"
+
file
.
filename
)
prediction
=
transform_audio
(
file
.
filename
)
data
=
{
'prediction'
:
prediction
}
score
=
calKnowledgeIqActivityScore
(
activityName
,
questionIndex
,
prediction
)
score
=
calKnowledgeIqActivityScore
(
activityName
,
questionIndex
,
prediction
)
db
.
db
[
'knowledgeIQScore'
]
.
insert_one
({
"activityName"
:
activityName
,
"questionIndex"
:
questionIndex
,
...
...
web-app/frontend/src/components/activities/mentalChronometryEval/coding/CodingContainer.jsx
View file @
6c637833
...
...
@@ -20,18 +20,19 @@ const CodingContainer = () => {
const
[
activityCompleted
,
setActivityCompleted
]
=
useState
(
false
);
const
[
finalScore
,
setFinalScore
]
=
useState
(
0
);
const
[
letterPatternANswers
,
setLetterPatternANswers
]
=
useState
([]);
const
[
answerImage
]
=
useState
([]);
const
[
actualResult
,
setActualResul
]
=
useState
([
"
square
"
,
// "circle",
"
triangle
"
,
//
"triangle",
// "circle",
"
circle
"
,
// "triangle",
"
circle
"
,
//
"circle",
// "square",
"
circle
"
,
// "circle",
"
square
"
,
//
"square",
// "triangle",
"
triangle
"
,
]);
...
...
@@ -40,15 +41,15 @@ const CodingContainer = () => {
const
[
drawingPad
,
setDrawingPad
]
=
useState
([
"
c
"
,
// "s",
"
c
"
,
//
"c",
// "r",
"
s
"
,
// "c",
"
r
"
,
//
"r",
// "c",
"
c
"
,
// "s",
"
c
"
,
//
"c",
// "s",
"
s
"
,
]);
...
...
@@ -64,6 +65,10 @@ const CodingContainer = () => {
"
Content-Type
"
:
"
application/json
"
,
},
};
let
candidateID
=
null
;
if
(
localStorage
)
{
candidateID
=
localStorage
.
getItem
(
"
candidateID
"
);
}
try
{
const
payload
=
{
activityName
:
activityName
,
...
...
@@ -72,6 +77,8 @@ const CodingContainer = () => {
predResult
:
letterPatternANswers
,
totalTime
:
time
,
createdTime
:
Date
(),
candidateID
:
candidateID
,
answerImage
:
answerImage
,
};
await
API
.
post
(
"
mentalChromScores
"
,
JSON
.
stringify
(
payload
),
headerConfig
)
...
...
@@ -139,6 +146,10 @@ const CodingContainer = () => {
.
toDataURL
(
"
image/png
"
)
.
replace
(
"
data:image/png;base64,
"
,
""
);
answerImage
.
push
(
sigCanvas
.
current
.
getTrimmedCanvas
().
toDataURL
(
"
image/png
"
)
);
let
message
=
{
image
:
image
};
sigCanvas
.
current
.
clear
();
await
API
.
post
(
"
predicthanddrwnshapes
"
,
JSON
.
stringify
(
message
))
...
...
@@ -153,15 +164,15 @@ const CodingContainer = () => {
var
codingURLS
=
[
"
https://i.ibb.co/9cwf5x2/image.png
"
,
// "https://i.ibb.co/JFNZwCz/1.png",
"
https://i.ibb.co/ykdhHM6/2.png
"
,
//
"https://i.ibb.co/ykdhHM6/2.png",
// "https://i.ibb.co/KL9JDkB/3.png",
"
https://i.ibb.co/9Y13xQ9/6.png
"
,
// "https://i.ibb.co/b5B7js8/7.png",
"
https://i.ibb.co/2SzzMCz/8.png
"
,
//
"https://i.ibb.co/2SzzMCz/8.png",
// "https://i.ibb.co/tc7dPJ0/9.png",
"
https://i.ibb.co/3kSQzMM/13.png
"
,
// "https://i.ibb.co/HPPMv94/14.png",
"
https://i.ibb.co/KLbgtTx/19.png
"
,
//
"https://i.ibb.co/KLbgtTx/19.png",
// "https://i.ibb.co/kKBgmB2/18.png",
"
https://i.ibb.co/93DNN1q/17.png
"
,
];
...
...
web-app/frontend/src/components/activities/mentalChronometryEval/letterPattern/LetterPattern.jsx
View file @
6c637833
import
React
from
"
react
"
;
import
React
,
{
useEffect
}
from
"
react
"
;
import
LetterPatternContainer
from
"
./LetterPatternContainer
"
;
const
LetterPattern
=
({
nextActivity
})
=>
{
// useEffect(() => {
// var candidateID = null;
// if (localStorage) {
// candidateID = localStorage.getItem("candidateID");
// }
// alert(candidateID);
// });
return
(
<
div
className=
"h-full "
>
<
LetterPatternContainer
/>
...
...
web-app/frontend/src/components/activities/mentalChronometryEval/letterPattern/LetterPatternContainer.jsx
View file @
6c637833
...
...
@@ -16,7 +16,9 @@ const LetterPatternContainer = ({ nextActivity }) => {
const
[
activityCompleted
,
setActivityCompleted
]
=
useState
(
false
);
const
[
finalScore
,
setFinalScore
]
=
useState
(
0
);
const
[
letterPatternANswers
]
=
useState
([]);
const
[
actualResult
]
=
useState
([
"
B
"
,
"
R
"
,
"
U
"
,
"
Y
"
,
"
B
"
,
"
P
"
,
"
D
"
]);
const
[
answerImage
]
=
useState
([]);
// const [actualResult] = useState(["B", "R", "U", "Y", "B", "P", "D"]);
const
[
actualResult
]
=
useState
([
"
B
"
,
"
U
"
,
"
B
"
,
"
D
"
]);
const
[
isCancelled
,
setIsCancelled
]
=
useState
(
false
);
var
finalResult
=
0
;
...
...
@@ -30,6 +32,11 @@ const LetterPatternContainer = ({ nextActivity }) => {
"
Content-Type
"
:
"
application/json
"
,
},
};
let
candidateID
=
null
;
if
(
localStorage
)
{
candidateID
=
localStorage
.
getItem
(
"
candidateID
"
);
}
try
{
const
payload
=
{
activityName
:
activityName
,
...
...
@@ -38,6 +45,8 @@ const LetterPatternContainer = ({ nextActivity }) => {
predResult
:
letterPatternANswers
,
totalTime
:
time
,
createdTime
:
Date
(),
candidateID
:
candidateID
,
answerImage
:
answerImage
,
};
await
API
.
post
(
"
mentalChromScores
"
,
JSON
.
stringify
(
payload
),
headerConfig
)
...
...
@@ -105,6 +114,10 @@ const LetterPatternContainer = ({ nextActivity }) => {
.
toDataURL
(
"
image/png
"
)
.
replace
(
"
data:image/png;base64,
"
,
""
);
answerImage
.
push
(
sigCanvas
.
current
.
getTrimmedCanvas
().
toDataURL
(
"
image/png
"
)
);
let
message
=
{
image
:
image
};
sigCanvas
.
current
.
clear
();
await
API
.
post
(
"
predictletters
"
,
JSON
.
stringify
(
message
))
...
...
@@ -116,13 +129,23 @@ const LetterPatternContainer = ({ nextActivity }) => {
console
.
log
(
err
);
});
};
// var patternURLS = [
// "https://i.ibb.co/XV9RV1M/letter-Pattern-1.png",
// "https://i.ibb.co/4Y3WdDW/letter-Pattern-2.png",
// "https://i.ibb.co/D4VGM7J/letter-Pattern-3.png",
// "https://i.ibb.co/xsVbwyw/letter-Pattern-4.png",
// "https://i.ibb.co/c3wVB5Z/letter-Pattern-5.png",
// "https://i.ibb.co/1K0YCvz/letter-Pattern-6.png",
// "https://i.ibb.co/wYqYDjb/letter-Pattern-7.png",
// ];
var
patternURLS
=
[
"
https://i.ibb.co/XV9RV1M/letter-Pattern-1.png
"
,
"
https://i.ibb.co/4Y3WdDW/letter-Pattern-2.png
"
,
//
"https://i.ibb.co/4Y3WdDW/letter-Pattern-2.png",
"
https://i.ibb.co/D4VGM7J/letter-Pattern-3.png
"
,
"
https://i.ibb.co/xsVbwyw/letter-Pattern-4.png
"
,
//
"https://i.ibb.co/xsVbwyw/letter-Pattern-4.png",
"
https://i.ibb.co/c3wVB5Z/letter-Pattern-5.png
"
,
"
https://i.ibb.co/1K0YCvz/letter-Pattern-6.png
"
,
//
"https://i.ibb.co/1K0YCvz/letter-Pattern-6.png",
"
https://i.ibb.co/wYqYDjb/letter-Pattern-7.png
"
,
];
...
...
web-app/frontend/src/components/activities/mentalChronometryEval/pairCancerlation/PairCancerlationContainer.jsx
View file @
6c637833
...
...
@@ -7,7 +7,6 @@ import PCB2 from "./img/PCB2.png";
import
PCB3
from
"
./img/PCB3.png
"
;
import
PCB4
from
"
./img/PCB4.png
"
;
import
PCA1
from
"
./img/PCA1.png
"
;
import
PCA2
from
"
./img/PCA2.png
"
;
import
PCA3
from
"
./img/PCA3.png
"
;
import
PCA4
from
"
./img/PCA4.png
"
;
// import { PCA1, PCB1 } from "./img/";
...
...
@@ -16,19 +15,20 @@ import axios from "axios";
const
PairCancerlationContainer
=
()
=>
{
const
[
src
,
selectFile
]
=
useState
(
null
);
const
[
activityCompleted
,
setActivityCompleted
]
=
useState
(
false
);
const
[
Pair
,
setPair
]
=
useState
([
PCA1
,
PCA
2
,
PCA
3
,
PCA4
]);
const
[
picture
,
setPicture
]
=
useState
([
PCB1
,
PCB
2
,
PCB
3
,
PCB4
]);
const
[
finalScore
,
setFinalScore
]
=
useState
(
[
PCB1
,
PCB2
,
PCB3
,
PCB4
]
);
const
[
Pair
,
setPair
]
=
useState
([
PCA1
,
PCA3
,
PCA4
]);
const
[
picture
,
setPicture
]
=
useState
([
PCB1
,
PCB3
,
PCB4
]);
const
[
finalScore
,
setFinalScore
]
=
useState
(
0
);
const
[
predResult
]
=
useState
([]);
const
[
finalResultInPair
,
setFinalResultInPair
]
=
useState
(
null
);
const
[
actualResult
,
setActualResult
]
=
useState
([
[
"
star
"
,
"
circle
"
],
[
"
triangle
"
,
"
square
"
],
[
"
triangle
"
,
"
star
"
],
[
"
star
"
,
"
star
"
],
]);
let
results
=
0
;
const
[
activityIndex
,
setActivityIndex
]
=
useState
(
0
);
const
[
answerImage
]
=
useState
([]);
const
handleFileChange
=
(
e
)
=>
{
selectFile
(
URL
.
createObjectURL
(
e
.
target
.
files
[
0
]));
};
...
...
@@ -50,14 +50,20 @@ const PairCancerlationContainer = () => {
"
Content-Type
"
:
"
application/json
"
,
},
};
let
candidateID
=
null
;
if
(
localStorage
)
{
candidateID
=
localStorage
.
getItem
(
"
candidateID
"
);
}
try
{
const
payload
=
{
activityName
:
activityName
,
score
:
finalR
esult
,
score
:
r
esult
,
actualResult
:
actualResult
,
predResult
:
r
esult
,
predResult
:
predR
esult
,
totalTime
:
time
,
createdTime
:
Date
(),
candidateID
:
candidateID
,
answerImage
:
answerImage
,
};
await
API
.
post
(
"
mentalChromScores
"
,
JSON
.
stringify
(
payload
),
headerConfig
)
...
...
@@ -109,7 +115,7 @@ const PairCancerlationContainer = () => {
});
const
getCroppedImg
=
async
()
=>
{
if
(
activityIndex
===
3
)
{
if
(
activityIndex
===
2
)
{
setActivityCompleted
(
true
);
setIsCancelled
(
true
);
setTimeout
(()
=>
{
...
...
@@ -140,8 +146,10 @@ const PairCancerlationContainer = () => {
let
imagetoPred
=
base64
.
replace
(
"
data:image/png;base64,
"
,
""
);
answerImage
.
push
(
canvas
.
toDataURL
(
"
image/png
"
));
// console.log(base64);
if
(
activityIndex
<
3
)
{
if
(
activityIndex
<
2
)
{
setActivityIndex
(
activityIndex
+
1
);
}
...
...
@@ -156,15 +164,18 @@ const PairCancerlationContainer = () => {
console
.
log
(
err
);
});
};
let
res
=
0
;
let
count
=
1
;
const
generateScore
=
()
=>
{
for
(
let
i
=
0
;
i
<
actualResult
.
length
;
i
++
)
{
if
(
JSON
.
stringify
(
actualResult
[
i
])
===
JSON
.
stringify
(
predResult
[
i
]))
{
res
+=
1
;
alert
(
res
);
// setFinalScore(result);
}
}
// finalResult = result;
setFinalScore
(
res
);
console
.
log
(
res
);
...
...
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