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
c5533a40
Commit
c5533a40
authored
Sep 04, 2023
by
janithgamage1.ed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update
desc : update project
parent
0c28d5b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
Project/Backend/Server_Node/controllers/userProgress.controller.js
...ackend/Server_Node/controllers/userProgress.controller.js
+8
-3
No files found.
Project/Backend/Server_Node/controllers/userProgress.controller.js
View file @
c5533a40
...
@@ -27,7 +27,10 @@ export const subscribeCurriculum = async (req, res) => {
...
@@ -27,7 +27,10 @@ export const subscribeCurriculum = async (req, res) => {
}
}
// Update the totalCurriculumsMarks based on curriculum marks
// Update the totalCurriculumsMarks based on curriculum marks
const
totalCurriculumsMarks
=
userProgress
.
curriculums
.
reduce
((
total
,
curriculum
)
=>
total
+
curriculum
.
curriculumMark
,
0
);
const
totalCurriculumsMarks
=
userProgress
.
curriculums
.
reduce
((
total
,
curriculum
)
=>
{
const
curriculumMark
=
typeof
curriculum
.
curriculumMark
===
'
string
'
?
parseFloat
(
curriculum
.
curriculumMark
)
:
curriculum
.
curriculumMark
;
return
total
+
(
isNaN
(
curriculumMark
)
?
0
:
curriculumMark
);
},
0
);
userProgress
.
totalCurriculumsMarks
=
totalCurriculumsMarks
;
userProgress
.
totalCurriculumsMarks
=
totalCurriculumsMarks
;
// Save the user progress record
// Save the user progress record
...
@@ -86,8 +89,9 @@ export const updateTaskItemProgress = async (req, res) => {
...
@@ -86,8 +89,9 @@ export const updateTaskItemProgress = async (req, res) => {
}
}
// Update task item progress
// Update task item progress
userProgress
.
curriculums
[
curriculumIndex
].
tutorials
[
tutorialIndex
].
taskItems
[
taskItemIndex
].
taskItemMarkUser
=
taskItemMarkUser
;
const
taskItem
=
userProgress
.
curriculums
[
curriculumIndex
].
tutorials
[
tutorialIndex
].
taskItems
[
taskItemIndex
];
userProgress
.
curriculums
[
curriculumIndex
].
tutorials
[
tutorialIndex
].
taskItems
[
taskItemIndex
].
taskItemSpentTime
=
taskItemSpentTime
;
taskItem
.
taskItemMarkUser
=
typeof
taskItemMarkUser
===
'
string
'
?
parseFloat
(
taskItemMarkUser
)
:
taskItemMarkUser
;
taskItem
.
taskItemSpentTime
=
taskItemSpentTime
;
// Calculate total task marks and spent time for the tutorial
// Calculate total task marks and spent time for the tutorial
const
tutorial
=
userProgress
.
curriculums
[
curriculumIndex
].
tutorials
[
tutorialIndex
];
const
tutorial
=
userProgress
.
curriculums
[
curriculumIndex
].
tutorials
[
tutorialIndex
];
...
@@ -112,3 +116,4 @@ export const updateTaskItemProgress = async (req, res) => {
...
@@ -112,3 +116,4 @@ export const updateTaskItemProgress = async (req, res) => {
res
.
status
(
500
).
json
({
error
:
'
Internal server error
'
});
res
.
status
(
500
).
json
({
error
:
'
Internal server 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