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
826cba1c
Commit
826cba1c
authored
Sep 03, 2023
by
janithgamage1.ed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update
desc : update project
parent
588053fb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
503 additions
and
14 deletions
+503
-14
Project/Backend/Server_Node/controllers/curriculum.controller.js
.../Backend/Server_Node/controllers/curriculum.controller.js
+1
-1
Project/Backend/Server_Node/controllers/tutorial.controller.js
...ct/Backend/Server_Node/controllers/tutorial.controller.js
+28
-13
Project/Frontend/SignConnectPlus/src/store/reducers/curriculum.ts
...Frontend/SignConnectPlus/src/store/reducers/curriculum.ts
+193
-0
Project/Frontend/SignConnectPlus/src/store/reducers/tutorial.ts
...t/Frontend/SignConnectPlus/src/store/reducers/tutorial.ts
+193
-0
Project/Frontend/SignConnectPlus/src/types/curriculum.ts
Project/Frontend/SignConnectPlus/src/types/curriculum.ts
+45
-0
Project/Frontend/SignConnectPlus/src/types/tutorial.ts
Project/Frontend/SignConnectPlus/src/types/tutorial.ts
+43
-0
No files found.
Project/Backend/Server_Node/controllers/curriculum.controller.js
View file @
826cba1c
...
@@ -71,7 +71,7 @@ export const deleteCurriculum = async (req, res) => {
...
@@ -71,7 +71,7 @@ export const deleteCurriculum = async (req, res) => {
const
{
id
}
=
req
.
params
;
const
{
id
}
=
req
.
params
;
try
{
try
{
await
Curriculum
.
findByIdAndDelete
(
id
);
await
Curriculum
.
findByIdAndDelete
(
id
);
res
.
status
(
200
).
json
({
message
:
'
Curriculum deleted successfully
'
});
res
.
status
(
200
).
json
({
_id
:
id
,
message
:
'
Curriculum deleted successfully
'
});
}
catch
(
error
)
{
}
catch
(
error
)
{
res
.
status
(
404
).
json
({
message
:
'
Curriculum not found
'
});
res
.
status
(
404
).
json
({
message
:
'
Curriculum not found
'
});
}
}
...
...
Project/Backend/Server_Node/controllers/tutorial.controller.js
View file @
826cba1c
...
@@ -21,42 +21,57 @@ export const getTutorialById = async (req, res) => {
...
@@ -21,42 +21,57 @@ export const getTutorialById = async (req, res) => {
export
const
createTutorial
=
async
(
req
,
res
)
=>
{
export
const
createTutorial
=
async
(
req
,
res
)
=>
{
const
tutorialData
=
req
.
body
;
const
tutorialData
=
req
.
body
;
// Calculate total tutorial marks based on task item marks
// Calculate total tutorial marks based on task item marks
const
totalTaskMarks
=
tutorialData
.
taskItems
.
reduce
((
total
,
task
)
=>
total
+
(
task
.
taskItemMark
||
0
),
0
);
const
totalTaskMarks
=
tutorialData
.
taskItems
.
reduce
((
total
,
task
)
=>
total
+
(
task
.
taskItemMark
||
0
),
0
);
tutorialData
.
tutorialMarks
=
totalTaskMarks
;
tutorialData
.
tutorialMarks
=
totalTaskMarks
;
try
{
try
{
const
newTutorial
=
new
Tutorial
(
tutorialData
);
const
newTutorial
=
new
Tutorial
(
tutorialData
);
await
newTutorial
.
save
();
await
newTutorial
.
save
();
res
.
status
(
201
).
json
(
newTutorial
);
res
.
status
(
201
).
json
(
newTutorial
);
}
catch
(
error
)
{
}
catch
(
error
)
{
res
.
status
(
400
).
json
({
message
:
error
.
message
});
res
.
status
(
500
).
json
({
message
:
'
Failed to create tutorial
'
,
error
:
error
.
message
});
}
}
}
}
;
export
const
updateTutorial
=
async
(
req
,
res
)
=>
{
export
const
updateTutorial
=
async
(
req
,
res
)
=>
{
const
{
id
}
=
req
.
params
;
const
{
id
}
=
req
.
params
;
const
updatedTutorialData
=
req
.
body
;
const
updatedTutorialData
=
req
.
body
;
// Calculate total tutorial marks based on updated task item marks
// Calculate total tutorial marks based on updated task item marks
const
totalTaskMarks
=
updatedTutorialData
.
taskItems
.
reduce
((
total
,
task
)
=>
total
+
(
task
.
taskItemMark
||
0
),
0
);
const
totalTaskMarks
=
updatedTutorialData
.
taskItems
.
reduce
((
total
,
task
)
=>
total
+
(
task
.
taskItemMark
||
0
),
0
);
updatedTutorialData
.
tutorialMarks
=
totalTaskMarks
;
updatedTutorialData
.
tutorialMarks
=
totalTaskMarks
;
try
{
try
{
const
result
=
await
Tutorial
.
findByIdAndUpdate
(
id
,
updatedTutorialData
,
{
new
:
true
});
const
tutorial
=
await
Tutorial
.
findById
(
id
);
res
.
status
(
200
).
json
(
result
);
if
(
!
tutorial
)
{
return
res
.
status
(
404
).
json
({
message
:
'
Tutorial not found
'
});
}
// Update the tutorial with the new data
const
updatedTutorial
=
await
Tutorial
.
findByIdAndUpdate
(
id
,
updatedTutorialData
,
{
new
:
true
});
res
.
status
(
200
).
json
(
updatedTutorial
);
}
catch
(
error
)
{
}
catch
(
error
)
{
res
.
status
(
404
).
json
({
message
:
'
Tutorial not found
'
});
res
.
status
(
500
).
json
({
message
:
error
.
message
});
}
}
}
};
export
const
deleteTutorial
=
async
(
req
,
res
)
=>
{
export
const
deleteTutorial
=
async
(
req
,
res
)
=>
{
const
{
id
}
=
req
.
params
;
const
{
id
}
=
req
.
params
;
try
{
try
{
const
tutorial
=
await
Tutorial
.
findById
(
id
);
if
(
!
tutorial
)
{
return
res
.
status
(
404
).
json
({
message
:
'
Tutorial not found
'
});
}
await
Tutorial
.
findByIdAndDelete
(
id
);
await
Tutorial
.
findByIdAndDelete
(
id
);
res
.
status
(
200
).
json
({
message
:
'
Tutorial deleted successfully
'
});
res
.
status
(
200
).
json
({
_id
:
id
,
message
:
'
Tutorial deleted successfully
'
});
}
catch
(
error
)
{
}
catch
(
error
)
{
res
.
status
(
404
).
json
({
message
:
'
Tutorial not found
'
});
res
.
status
(
500
).
json
({
message
:
error
.
message
});
}
}
}
};
Project/Frontend/SignConnectPlus/src/store/reducers/curriculum.ts
0 → 100644
View file @
826cba1c
// third-party
import
{
createSlice
}
from
'
@reduxjs/toolkit
'
;
// project imports
import
{
axiosServices
}
from
'
utils/axios
'
;
import
{
dispatch
}
from
'
../index
'
;
// types
import
{
Curriculum
,
DefaultRootStateProps
}
from
'
types/curriculum
'
;
// ----------------------------------------------------------------------
const
initialState
:
DefaultRootStateProps
[
'
curriculum
'
]
=
{
error
:
null
,
success
:
null
,
curriculums
:
[],
curriculum
:
null
,
isLoading
:
false
};
const
slice
=
createSlice
({
name
:
'
curriculum
'
,
initialState
,
reducers
:
{
// TO INITIAL STATE
hasInitialState
(
state
)
{
state
.
error
=
null
;
state
.
success
=
null
;
state
.
isLoading
=
false
;
},
// HAS ERROR
hasError
(
state
,
action
)
{
state
.
error
=
action
.
payload
;
},
startLoading
(
state
)
{
state
.
isLoading
=
true
;
},
finishLoading
(
state
)
{
state
.
isLoading
=
false
;
},
// POST CURRICULUM
addCurriculumSuccess
(
state
,
action
)
{
state
.
curriculums
.
push
(
action
.
payload
);
state
.
success
=
"
Curriculum created successfully.
"
},
// GET CURRICULUM
fetchCurriculumSuccess
(
state
,
action
)
{
state
.
curriculum
=
action
.
payload
;
state
.
success
=
null
},
// GET ALL CURRICULUM
fetchCurriculumsSuccess
(
state
,
action
)
{
state
.
curriculums
=
action
.
payload
;
state
.
success
=
null
},
// UPDATE CURRICULUM
updateCurriculumSuccess
(
state
,
action
)
{
const
updatedCurriculumIndex
=
state
.
curriculums
.
findIndex
(
curriculum
=>
curriculum
.
_id
===
action
.
payload
.
_id
);
if
(
updatedCurriculumIndex
!==
-
1
)
{
state
.
curriculums
[
updatedCurriculumIndex
]
=
action
.
payload
;
}
state
.
success
=
"
Curriculum updated successfully.
"
},
// DELETE CURRICULUM
deleteCurriculumSuccess
(
state
,
action
)
{
state
.
curriculums
=
state
.
curriculums
.
filter
(
curriculum
=>
curriculum
.
_id
!==
action
.
payload
.
_id
);
state
.
success
=
"
Curriculum deleted successfully.
"
},
}
});
// Reducer
export
default
slice
.
reducer
;
// ----------------------------------------------------------------------
/**
* TO INITIAL STATE
* @returns
*/
export
function
toInitialState
()
{
return
async
()
=>
{
dispatch
(
slice
.
actions
.
hasInitialState
())
}
}
/**
* POST CURRICULUM
* @param newCurriculum
* @returns
*/
export
function
addCurriculum
(
newCurriculum
:
Curriculum
)
{
return
async
()
=>
{
dispatch
(
slice
.
actions
.
startLoading
());
try
{
const
response
=
await
axiosServices
.
post
(
'
/rest_node/curriculum
'
,
newCurriculum
);
dispatch
(
slice
.
actions
.
addCurriculumSuccess
(
response
.
data
));
}
catch
(
error
)
{
dispatch
(
slice
.
actions
.
hasError
(
error
));
}
finally
{
dispatch
(
slice
.
actions
.
finishLoading
());
}
};
}
/**
* GET CURRICULUM
* @param id
* @returns
*/
export
function
fetchCurriculum
(
id
:
number
)
{
return
async
()
=>
{
dispatch
(
slice
.
actions
.
startLoading
());
try
{
const
response
=
await
axiosServices
.
get
(
`/rest_node/curriculum/
${
id
}
`
);
dispatch
(
slice
.
actions
.
fetchCurriculumSuccess
(
response
.
data
));
}
catch
(
error
)
{
dispatch
(
slice
.
actions
.
hasError
(
error
));
}
finally
{
dispatch
(
slice
.
actions
.
finishLoading
());
}
};
}
/**
* GET ALL CURRICULUMS
* @returns
*/
export
function
fetchCurriculums
()
{
return
async
()
=>
{
dispatch
(
slice
.
actions
.
startLoading
());
try
{
const
response
=
await
axiosServices
.
get
(
'
/rest_node/curriculum
'
);
dispatch
(
slice
.
actions
.
fetchCurriculumsSuccess
(
response
.
data
));
}
catch
(
error
)
{
dispatch
(
slice
.
actions
.
hasError
(
error
));
}
finally
{
dispatch
(
slice
.
actions
.
finishLoading
());
}
};
}
/**
* UPDATE CURRICULUM
* @param updatedCurriculum
* @returns
*/
export
function
updateCurriculum
(
updatedCurriculum
:
Curriculum
)
{
return
async
()
=>
{
dispatch
(
slice
.
actions
.
startLoading
());
try
{
const
response
=
await
axiosServices
.
put
(
`/rest_node/curriculum/
${
updatedCurriculum
.
_id
}
`
,
updatedCurriculum
);
dispatch
(
slice
.
actions
.
updateCurriculumSuccess
(
response
.
data
));
}
catch
(
error
)
{
dispatch
(
slice
.
actions
.
hasError
(
error
));
}
finally
{
dispatch
(
slice
.
actions
.
finishLoading
());
}
};
}
/**
* DELETE CURRICULUM
* @param curriculumId
* @returns
*/
export
function
deleteCurriculum
(
curriculumId
:
number
)
{
return
async
()
=>
{
dispatch
(
slice
.
actions
.
startLoading
());
try
{
await
axiosServices
.
delete
(
`/rest_node/curriculum/
${
curriculumId
}
`
);
dispatch
(
slice
.
actions
.
deleteCurriculumSuccess
(
curriculumId
));
}
catch
(
error
)
{
dispatch
(
slice
.
actions
.
hasError
(
error
));
}
finally
{
dispatch
(
slice
.
actions
.
finishLoading
());
}
};
}
Project/Frontend/SignConnectPlus/src/store/reducers/tutorial.ts
0 → 100644
View file @
826cba1c
// third-party
import
{
createSlice
}
from
'
@reduxjs/toolkit
'
;
// project imports
import
{
axiosServices
}
from
'
utils/axios
'
;
import
{
dispatch
}
from
'
../index
'
;
// types
import
{
DefaultRootStateProps
,
Tutorial
}
from
'
types/tutorial
'
;
// ----------------------------------------------------------------------
const
initialState
:
DefaultRootStateProps
[
'
tutorial
'
]
=
{
error
:
null
,
success
:
null
,
tutorials
:
[],
tutorial
:
null
,
isLoading
:
false
};
const
slice
=
createSlice
({
name
:
'
tutorial
'
,
initialState
,
reducers
:
{
// TO INITIAL STATE
hasInitialState
(
state
)
{
state
.
error
=
null
;
state
.
success
=
null
;
state
.
isLoading
=
false
;
},
// HAS ERROR
hasError
(
state
,
action
)
{
state
.
error
=
action
.
payload
;
},
startLoading
(
state
)
{
state
.
isLoading
=
true
;
},
finishLoading
(
state
)
{
state
.
isLoading
=
false
;
},
// POST TUTORIAL
addTutorialSuccess
(
state
,
action
)
{
state
.
tutorials
.
push
(
action
.
payload
);
state
.
success
=
"
Tutorial created successfully.
"
},
// GET TUTORIAL
fetchTutorialSuccess
(
state
,
action
)
{
state
.
tutorial
=
action
.
payload
;
state
.
success
=
null
},
// GET ALL TUTORIAL
fetchTutorialsSuccess
(
state
,
action
)
{
state
.
tutorials
=
action
.
payload
;
state
.
success
=
null
},
// UPDATE TUTORIAL
updateTutorialSuccess
(
state
,
action
)
{
const
updatedTutorialIndex
=
state
.
tutorials
.
findIndex
(
tutorial
=>
tutorial
.
_id
===
action
.
payload
.
_id
);
if
(
updatedTutorialIndex
!==
-
1
)
{
state
.
tutorials
[
updatedTutorialIndex
]
=
action
.
payload
;
}
state
.
success
=
"
Tutorial updated successfully.
"
},
// DELETE TUTORIAL
deleteTutorialSuccess
(
state
,
action
)
{
state
.
tutorials
=
state
.
tutorials
.
filter
(
tutorial
=>
tutorial
.
_id
!==
action
.
payload
.
_id
);
state
.
success
=
"
Tutorial deleted successfully.
"
},
}
});
// Reducer
export
default
slice
.
reducer
;
// ----------------------------------------------------------------------
/**
* TO INITIAL STATE
* @returns
*/
export
function
toInitialState
()
{
return
async
()
=>
{
dispatch
(
slice
.
actions
.
hasInitialState
())
}
}
/**
* POST TUTORIAL
* @param newTutorial
* @returns
*/
export
function
addTutorial
(
newTutorial
:
Tutorial
)
{
return
async
()
=>
{
dispatch
(
slice
.
actions
.
startLoading
());
try
{
const
response
=
await
axiosServices
.
post
(
'
/rest_node/tutorial
'
,
newTutorial
);
dispatch
(
slice
.
actions
.
addTutorialSuccess
(
response
.
data
));
}
catch
(
error
)
{
dispatch
(
slice
.
actions
.
hasError
(
error
));
}
finally
{
dispatch
(
slice
.
actions
.
finishLoading
());
}
};
}
/**
* GET TUTORIAL
* @param id
* @returns
*/
export
function
fetchTutorial
(
id
:
number
)
{
return
async
()
=>
{
dispatch
(
slice
.
actions
.
startLoading
());
try
{
const
response
=
await
axiosServices
.
get
(
`/rest_node/tutorial/
${
id
}
`
);
dispatch
(
slice
.
actions
.
fetchTutorialSuccess
(
response
.
data
));
}
catch
(
error
)
{
dispatch
(
slice
.
actions
.
hasError
(
error
));
}
finally
{
dispatch
(
slice
.
actions
.
finishLoading
());
}
};
}
/**
* GET ALL TUTORIALS
* @returns
*/
export
function
fetchTutorials
()
{
return
async
()
=>
{
dispatch
(
slice
.
actions
.
startLoading
());
try
{
const
response
=
await
axiosServices
.
get
(
'
/rest_node/tutorial
'
);
dispatch
(
slice
.
actions
.
fetchTutorialsSuccess
(
response
.
data
));
}
catch
(
error
)
{
dispatch
(
slice
.
actions
.
hasError
(
error
));
}
finally
{
dispatch
(
slice
.
actions
.
finishLoading
());
}
};
}
/**
* UPDATE TUTORIAL
* @param updatedTutorial
* @returns
*/
export
function
updateTutorial
(
updatedTutorial
:
Tutorial
)
{
return
async
()
=>
{
dispatch
(
slice
.
actions
.
startLoading
());
try
{
const
response
=
await
axiosServices
.
put
(
`/rest_node/tutorial/
${
updatedTutorial
.
_id
}
`
,
updatedTutorial
);
dispatch
(
slice
.
actions
.
updateTutorialSuccess
(
response
.
data
));
}
catch
(
error
)
{
dispatch
(
slice
.
actions
.
hasError
(
error
));
}
finally
{
dispatch
(
slice
.
actions
.
finishLoading
());
}
};
}
/**
* DELETE TUTORIAL
* @param tutorialId
* @returns
*/
export
function
deleteTutorial
(
tutorialId
:
number
)
{
return
async
()
=>
{
dispatch
(
slice
.
actions
.
startLoading
());
try
{
await
axiosServices
.
delete
(
`/rest_node/tutorial/
${
tutorialId
}
`
);
dispatch
(
slice
.
actions
.
deleteTutorialSuccess
(
tutorialId
));
}
catch
(
error
)
{
dispatch
(
slice
.
actions
.
hasError
(
error
));
}
finally
{
dispatch
(
slice
.
actions
.
finishLoading
());
}
};
}
Project/Frontend/SignConnectPlus/src/types/curriculum.ts
View file @
826cba1c
...
@@ -14,4 +14,49 @@ export interface curriculumType {
...
@@ -14,4 +14,49 @@ export interface curriculumType {
createdAt
:
Date
createdAt
:
Date
updatedBy
?:
string
updatedBy
?:
string
updatedAt
?:
Date
updatedAt
?:
Date
}
export
type
Curriculum
=
{
_id
?:
string
curriculumCode
:
string
curriculumLevel
:
number
curriculumTitle
:
string
curriculumDescription
:
string
curriculumImage
:
string
curriculumMark
:
number
tutorials
:
tutorialType
[],
status
:
number
createdBy
:
string
createdAt
:
Date
updatedBy
?:
string
updatedAt
?:
Date
};
export
type
Curriculums
=
{
_id
?:
string
curriculumCode
:
string
curriculumLevel
:
number
curriculumTitle
:
string
curriculumDescription
:
string
curriculumImage
:
string
curriculumMark
:
number
tutorials
:
tutorialType
[],
status
:
number
createdBy
:
string
createdAt
:
Date
updatedBy
?:
string
updatedAt
?:
Date
};
export
interface
CurriculumStateProps
{
curriculums
:
Curriculums
[];
curriculum
:
Curriculum
|
null
;
error
:
object
|
string
|
null
;
success
:
object
|
string
|
null
;
isLoading
:
boolean
}
export
interface
DefaultRootStateProps
{
curriculum
:
CurriculumStateProps
;
}
}
\ No newline at end of file
Project/Frontend/SignConnectPlus/src/types/tutorial.ts
View file @
826cba1c
...
@@ -13,4 +13,47 @@ export interface tutorialType {
...
@@ -13,4 +13,47 @@ export interface tutorialType {
createdAt
:
Date
createdAt
:
Date
updatedBy
?:
string
updatedBy
?:
string
updatedAt
?:
Date
updatedAt
?:
Date
}
export
type
Tutorial
=
{
_id
?:
string
tutorialCode
?:
string
tutorialTitle
?:
string
tutorialDescription
?:
string
tutorialImage
?:
string
tutorialMark
:
number
taskItems
:
taskItemType
[]
status
:
number
createdBy
:
string
createdAt
:
Date
updatedBy
?:
string
updatedAt
?:
Date
};
export
type
Tutorials
=
{
_id
?:
string
tutorialCode
?:
string
tutorialTitle
?:
string
tutorialDescription
?:
string
tutorialImage
?:
string
tutorialMark
:
number
taskItems
:
taskItemType
[]
status
:
number
createdBy
:
string
createdAt
:
Date
updatedBy
?:
string
updatedAt
?:
Date
};
export
interface
TutorialStateProps
{
tutorials
:
Tutorials
[];
tutorial
:
Tutorial
|
null
;
error
:
object
|
string
|
null
;
success
:
object
|
string
|
null
;
isLoading
:
boolean
}
export
interface
DefaultRootStateProps
{
tutorial
:
TutorialStateProps
;
}
}
\ No newline at end of file
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