Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2023-029
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
2023-029
2023-029
Commits
a88a10df
Commit
a88a10df
authored
Sep 03, 2023
by
janithgamage1.ed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update
Desc : update project
parent
2d00907a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
164 additions
and
18 deletions
+164
-18
Project/Backend/Server_Node/controllers/marksCalculator.controller.js
...end/Server_Node/controllers/marksCalculator.controller.js
+14
-10
Project/Frontend/SignConnectPlus/src/pages/learning-management/learning-curriculums-subscribed/tutorial/tutorial.tsx
...ent/learning-curriculums-subscribed/tutorial/tutorial.tsx
+142
-5
Project/Frontend/SignConnectPlus/src/pages/learning-management/learning-curriculums-subscribed/tutorial/types/types.tsx
.../learning-curriculums-subscribed/tutorial/types/types.tsx
+5
-0
Project/Frontend/SignConnectPlus/src/store/reducers/marksCalculator.ts
...end/SignConnectPlus/src/store/reducers/marksCalculator.ts
+3
-3
No files found.
Project/Backend/Server_Node/controllers/marksCalculator.controller.js
View file @
a88a10df
import
{
exec
}
from
"
child_process
"
;
export
const
marksCalculator
=
async
(
req
,
res
)
=>
{
const
imageData
=
req
.
file
.
buffer
.
toString
(
'
base64
'
);
const
targetClass
=
req
.
body
.
class
;
const
{
curriculumIndex
,
tutorialIndex
}
=
req
.
params
;
try
{
// console.log(req.file);
const
status
=
""
;
// if (!req.file || !req.body.class || !req.params.curriculumIndex || !req.params.tutorialIndex) {
// return res.status(400).json({ code: "02", message: "Missing required data" });
// }
// console.log(curriculumIndex, tutorialIndex);
try
{
const
imageData
=
req
.
file
.
buffer
.
toString
(
'
base64
'
);
const
targetClass
=
req
.
body
.
class
;
const
{
curriculumIndex
,
tutorialIndex
}
=
req
.
params
;
if
(
curriculumIndex
==
1
&&
tutorialIndex
==
1
)
{
// Run Python script to perform prediction
const
pythonProcess
=
exec
(
'
python prediction_config/C1T1/predict.py
'
,
(
error
,
stdout
,
stderr
)
=>
{
if
(
error
)
{
console
.
error
(
error
);
return
res
.
status
(
500
).
json
({
error
:
'
An error occurred
'
});
return
res
.
status
(
500
).
json
({
code
:
'
03
'
,
message
:
'
An error occurred while running the prediction script
'
});
}
const
[
predicted_class_name
,
confidence
]
=
stdout
.
trim
().
split
(
'
,
'
);
...
...
@@ -42,9 +45,10 @@ export const marksCalculator = async (req, res) => {
pythonProcess
.
stdin
.
write
(
`
${
imageData
}
\n
${
targetClass
}
`
);
pythonProcess
.
stdin
.
end
();
}
else
{
return
res
.
status
(
400
).
json
({
code
:
"
02
"
,
message
:
"
Curriculum Index or Tutorial Index Invalid
"
})
return
res
.
status
(
400
).
json
({
code
:
"
02
"
,
message
:
"
Curriculum Index or Tutorial Index Invalid
"
})
;
}
}
catch
(
error
)
{
res
.
status
(
500
).
json
({
code
:
"
00
"
,
message
:
"
Something went wrong
"
})
console
.
error
(
error
);
res
.
status
(
500
).
json
({
code
:
"
00
"
,
message
:
"
Something went wrong
"
});
}
}
\ No newline at end of file
}
Project/Frontend/SignConnectPlus/src/pages/learning-management/learning-curriculums-subscribed/tutorial/tutorial.tsx
View file @
a88a10df
...
...
@@ -16,9 +16,13 @@ import { CheckCircleOutlined, CheckOutlined, ClockCircleOutlined, FileImageOutli
import
{
PopupTransition
}
from
"
components/@extended/Transitions
"
;
import
ReportCard
from
"
components/cards/statistics/ReportCard
"
;
import
{
userProgress
}
from
"
data/userProgress
"
;
import
{
selectedCommonDataProps
,
selectedItemContentProps
}
from
"
./types/types
"
;
import
{
itemResultProps
,
selectedCommonDataProps
,
selectedItemContentProps
}
from
"
./types/types
"
;
import
CircularWithPath
from
"
components/@extended/progress/CircularWithPath
"
;
import
Webcam
from
'
react-webcam
'
;
import
{
useDispatch
,
useSelector
}
from
"
store
"
;
import
{
CalculateMarks
,
toInitialState
}
from
"
store/reducers/marksCalculator
"
;
import
{
openSnackbar
}
from
"
store/reducers/snackbar
"
;
// action style
const
actionSX
=
{
...
...
@@ -42,6 +46,8 @@ function convertMinutesToHMS(minutes: number) {
const
Tutorial
=
()
=>
{
const
theme
=
useTheme
();
const
dispatch
=
useDispatch
();
const
{
marksCalculator
,
error
,
success
,
isLoading
}
=
useSelector
(
state
=>
state
.
marksCalculator
);
const
[
data
,
setData
]
=
useState
<
tutorialTypeUserProgress
>
()
const
[
selectedItem
,
setSelectedItem
]
=
useState
<
{
selectedCommonData
:
selectedCommonDataProps
|
null
,
backgroundColor
:
any
|
null
}
>
({
...
...
@@ -54,6 +60,10 @@ const Tutorial = () => {
const
[
itemDesc
,
setItemDesc
]
=
useState
(
""
)
const
[
itemReadMore
,
setItemReadMore
]
=
useState
(
false
)
const
[
itemReferenceData
,
setItemReferenceData
]
=
useState
<
"
image
"
|
"
video
"
>
(
"
image
"
)
const
[
itemResult
,
setItemResult
]
=
useState
<
itemResultProps
>
({
itemMarkUser
:
0
,
status
:
"
Pending
"
})
const
handleItemClick
=
(
item
:
selectedCommonDataProps
,
backgroundColor
:
any
)
=>
{
setSelectedItem
({
...
...
@@ -96,6 +106,17 @@ const Tutorial = () => {
}
},
[
selectedItem
]);
useEffect
(()
=>
{
setItemResult
({
itemMarkUser
:
((
selectedItemContent
?.
taskItemMark
!
*
parseInt
(
marksCalculator
?.
confidence
!
))
/
100
)
!
,
status
:
marksCalculator
?.
status
!
})
},
[
marksCalculator
])
useEffect
(()
=>
{
console
.
log
(
itemResult
);
},
[
itemResult
])
//alert model
const
[
openModel
,
setOpenModel
]
=
useState
(
false
);
...
...
@@ -114,6 +135,122 @@ const Tutorial = () => {
}
};
const
PracticeTask
=
(
imgData
:
any
,
title
:
string
)
=>
{
if
(
typeof
imgData
===
'
string
'
&&
imgData
.
trim
()
!==
''
)
{
const
curriculumIndex
:
number
=
1
;
const
tutorialIndex
:
number
=
1
;
const
imageData
:
any
=
imgData
;
// Your image data
let
targetClass
:
string
=
""
;
// Your target class
switch
(
title
)
{
case
"
Learn Number One
"
:
targetClass
=
"
One
"
;
break
;
case
"
Learn Number Two
"
:
targetClass
=
"
Two
"
;
break
;
case
"
Learn Number Three
"
:
targetClass
=
"
Three
"
;
break
;
case
"
Learn Number Four
"
:
targetClass
=
"
Four
"
;
break
;
case
"
Learn Number Five
"
:
targetClass
=
"
Five
"
;
break
;
case
"
Learn Number Six
"
:
targetClass
=
"
Six
"
;
break
;
case
"
Learn Number Seven
"
:
targetClass
=
"
Seven
"
;
break
;
case
"
Learn Number Eight
"
:
targetClass
=
"
Eight
"
;
break
;
case
"
Learn Number Nine
"
:
targetClass
=
"
Nine
"
;
break
;
case
"
Learn Number Ten
"
:
targetClass
=
"
Ten
"
;
break
;
default
:
targetClass
=
"
Initial
"
;
break
;
}
// Assuming imageData is a base64-encoded image
const
base64Image
=
imageData
;
// Replace with your actual base64 data
const
byteCharacters
=
atob
(
base64Image
.
split
(
'
,
'
)[
1
]);
const
byteNumbers
=
new
Array
(
byteCharacters
.
length
);
for
(
let
i
=
0
;
i
<
byteCharacters
.
length
;
i
++
)
{
byteNumbers
[
i
]
=
byteCharacters
.
charCodeAt
(
i
);
}
const
byteArray
=
new
Uint8Array
(
byteNumbers
);
const
blob
=
new
Blob
([
byteArray
],
{
type
:
'
image/jpeg
'
});
const
file
=
new
File
([
blob
],
'
image.jpg
'
,
{
type
:
'
image/jpeg
'
});
dispatch
(
CalculateMarks
(
curriculumIndex
,
tutorialIndex
,
file
,
targetClass
));
}
else
{
dispatch
(
openSnackbar
({
open
:
true
,
//@ts-ignore
message
:
"
Invalid Image Data
"
,
variant
:
'
alert
'
,
alert
:
{
color
:
'
warning
'
},
close
:
true
})
);
}
}
/**
* API Config
* Marks Calculator API
*/
// handel error
useEffect
(()
=>
{
if
(
error
!=
null
)
{
dispatch
(
openSnackbar
({
open
:
true
,
//@ts-ignore
message
:
error
?
error
.
Message
:
"
Something went wrong ...
"
,
variant
:
'
alert
'
,
alert
:
{
color
:
'
error
'
},
close
:
true
})
);
dispatch
(
toInitialState
())
}
},
[
error
])
// handel success
useEffect
(()
=>
{
if
(
success
!=
null
)
{
dispatch
(
openSnackbar
({
open
:
true
,
message
:
success
,
variant
:
'
alert
'
,
alert
:
{
color
:
'
success
'
},
close
:
true
})
);
dispatch
(
toInitialState
())
}
},
[
success
])
return
(
<>
<
Grid
container
spacing=
{
2
}
>
...
...
@@ -445,17 +582,17 @@ const Tutorial = () => {
<
Grid
container
spacing=
{
2
}
>
<
Grid
item
md=
{
12
}
>
<
ReportCard
primary=
{
`Result :
N/A
`
}
primary=
{
`Result :
${itemResult.itemMarkUser ? itemResult.itemMarkUser : "N/A"}
`
}
secondary=
"To Complete the task you should get 85% or higher of the task mark"
color=
{
theme
.
palette
.
success
.
dark
}
/>
</
Grid
>
<
Grid
item
md=
{
12
}
>
<
ReportCard
primary=
{
`Status :
N/A
`
}
primary=
{
`Status :
${itemResult.status ? itemResult.status : 'N/A'}
`
}
secondary=
"To Complete the task you should get 85% or higher of the task mark"
color=
{
theme
.
palette
.
success
.
dark
}
/>
</
Grid
>
<
Grid
item
md=
{
12
}
>
<
Button
variant=
"contained"
color=
"success"
onClick=
{
()
=>
{
}
}
fullWidth
>
Get Result
<
Button
variant=
"contained"
color=
"success"
onClick=
{
()
=>
{
PracticeTask
(
webcamRef
.
current
?.
getScreenshot
(),
selectedItemContent
?.
title
!
)
}
}
fullWidth
disabled=
{
isLoading
}
>
{
isLoading
?
<
CircularWithPath
/>
:
<>
Get Result
</>
}
</
Button
>
</
Grid
>
</
Grid
>
...
...
Project/Frontend/SignConnectPlus/src/pages/learning-management/learning-curriculums-subscribed/tutorial/types/types.tsx
View file @
a88a10df
...
...
@@ -11,4 +11,9 @@ export interface selectedCommonDataProps {
curriculumCode
:
string
tutorialCode
:
string
title
:
string
}
export
interface
itemResultProps
{
itemMarkUser
:
number
status
:
string
}
\ No newline at end of file
Project/Frontend/SignConnectPlus/src/store/reducers/marksCalculator.ts
View file @
a88a10df
...
...
@@ -63,7 +63,7 @@ export function toInitialState() {
dispatch
(
slice
.
actions
.
hasInitialState
())
}
}
/**
* POST Marks Calculator
* @param curriculumIndex
...
...
@@ -72,7 +72,7 @@ export function toInitialState() {
* @param targetClass
* @returns
*/
export
function
marksCalculator
(
curriculumIndex
:
number
,
tutorialIndex
:
number
,
imageData
:
any
,
targetClass
:
string
)
{
export
function
CalculateMarks
(
curriculumIndex
:
number
,
tutorialIndex
:
number
,
imageData
:
any
,
targetClass
:
string
)
{
return
async
()
=>
{
dispatch
(
slice
.
actions
.
startLoading
());
...
...
@@ -82,7 +82,7 @@ export function marksCalculator(curriculumIndex: number, tutorialIndex: number,
formData
.
append
(
'
image
'
,
imageData
);
formData
.
append
(
'
class
'
,
targetClass
);
const
response
=
await
axiosServices
.
post
(
`/marks-calculator/curriculum/
${
curriculumIndex
}
/tutorial/
${
tutorialIndex
}
`
,
formData
);
const
response
=
await
axiosServices
.
post
(
`/
rest_node/
marks-calculator/curriculum/
${
curriculumIndex
}
/tutorial/
${
tutorialIndex
}
`
,
formData
);
dispatch
(
slice
.
actions
.
marksCalculatorSuccess
(
response
.
data
));
}
catch
(
error
)
{
dispatch
(
slice
.
actions
.
hasError
(
error
));
...
...
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