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
0c28d5b5
Commit
0c28d5b5
authored
Sep 04, 2023
by
janithgamage1.ed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update
Desc : update project
parent
9fe76f9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
Project/Backend/Server_Node/controllers/curriculum.controller.js
.../Backend/Server_Node/controllers/curriculum.controller.js
+4
-2
Project/Backend/Server_Node/controllers/tutorial.controller.js
...ct/Backend/Server_Node/controllers/tutorial.controller.js
+9
-2
No files found.
Project/Backend/Server_Node/controllers/curriculum.controller.js
View file @
0c28d5b5
...
...
@@ -32,7 +32,8 @@ export const createCurriculum = async (req, res) => {
let
totalTutorialMark
=
0
;
for
(
const
tutorialId
of
curriculumData
.
tutorials
)
{
const
tutorial
=
await
Tutorial
.
findById
(
tutorialId
);
totalTutorialMark
+=
tutorial
.
tutorialMarks
;
const
tutorialMarks
=
typeof
tutorial
.
tutorialMarks
===
'
string
'
?
parseFloat
(
tutorial
.
tutorialMarks
)
:
tutorial
.
tutorialMarks
;
totalTutorialMark
+=
isNaN
(
tutorialMarks
)
?
0
:
tutorialMarks
;
}
newCurriculum
.
curriculumMark
=
totalTutorialMark
;
...
...
@@ -55,7 +56,8 @@ export const updateCurriculum = async (req, res) => {
let
totalTutorialMark
=
0
;
for
(
const
tutorialId
of
updatedCurriculum
.
tutorials
)
{
const
tutorial
=
await
Tutorial
.
findById
(
tutorialId
);
totalTutorialMark
+=
tutorial
.
tutorialMarks
;
const
tutorialMarks
=
typeof
tutorial
.
tutorialMarks
===
'
string
'
?
parseFloat
(
tutorial
.
tutorialMarks
)
:
tutorial
.
tutorialMarks
;
totalTutorialMark
+=
isNaN
(
tutorialMarks
)
?
0
:
tutorialMarks
;
}
updatedCurriculum
.
curriculumMark
=
totalTutorialMark
;
...
...
Project/Backend/Server_Node/controllers/tutorial.controller.js
View file @
0c28d5b5
...
...
@@ -23,7 +23,11 @@ export const createTutorial = async (req, res) => {
const
tutorialData
=
req
.
body
;
// 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
)
=>
{
const
taskItemMark
=
typeof
task
.
taskItemMark
===
'
string
'
?
parseFloat
(
task
.
taskItemMark
)
:
task
.
taskItemMark
;
return
total
+
(
isNaN
(
taskItemMark
)
?
0
:
taskItemMark
);
},
0
);
tutorialData
.
tutorialMarks
=
totalTaskMarks
;
try
{
...
...
@@ -40,7 +44,10 @@ export const updateTutorial = async (req, res) => {
const
updatedTutorialData
=
req
.
body
;
// 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
)
=>
{
const
taskItemMark
=
typeof
task
.
taskItemMark
===
'
string
'
?
parseFloat
(
task
.
taskItemMark
)
:
task
.
taskItemMark
;
return
total
+
(
isNaN
(
taskItemMark
)
?
0
:
taskItemMark
);
},
0
);
updatedTutorialData
.
tutorialMarks
=
totalTaskMarks
;
try
{
...
...
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