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
17009258
Commit
17009258
authored
Sep 01, 2023
by
janithgamage1.ed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix; update
Desc : update project
parent
603a830f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
235 additions
and
128 deletions
+235
-128
Project/Backend/Server_Node/controllers/userProgress.controller.js
...ackend/Server_Node/controllers/userProgress.controller.js
+83
-77
Project/Backend/Server_Node/models/userProgress.model.js
Project/Backend/Server_Node/models/userProgress.model.js
+66
-46
Project/Backend/Server_Node/routes/userProgress.routes.js
Project/Backend/Server_Node/routes/userProgress.routes.js
+4
-4
Project/Frontend/SignConnectPlus/src/menu-items/application.tsx
...t/Frontend/SignConnectPlus/src/menu-items/application.tsx
+6
-0
Project/Frontend/SignConnectPlus/src/pages/learning-management/learning-curriculums-subscribed/tutorial/tutorial.tsx
...ent/learning-curriculums-subscribed/tutorial/tutorial.tsx
+21
-0
Project/Frontend/SignConnectPlus/src/routes/MainRoutes.tsx
Project/Frontend/SignConnectPlus/src/routes/MainRoutes.tsx
+6
-1
Project/Frontend/SignConnectPlus/src/types/userProgress.ts
Project/Frontend/SignConnectPlus/src/types/userProgress.ts
+49
-0
No files found.
Project/Backend/Server_Node/controllers/userProgress.controller.js
View file @
17009258
import
UserProgress
from
"
../models/userProgress.model.js
"
;
export
const
getUserSubscribedCurriculums
=
async
(
req
,
res
)
=>
{
const
userId
=
req
.
params
.
userId
;
try
{
const
userProgress
=
await
UserProgress
.
find
({
userId
})
.
populate
(
'
curriculumProgress.curriculumId
'
)
.
populate
(
'
curriculumProgress.tutorialProgress.tutorialId
'
)
res
.
status
(
200
).
json
(
userProgress
);
}
catch
(
error
)
{
res
.
status
(
500
).
json
({
message
:
"
Error fetching user progress
"
,
error
});
}
};
export
const
subscribeToCurriculum
=
async
(
req
,
res
)
=>
{
const
{
userId
,
curriculumId
}
=
req
.
body
;
// Logic to subscribe to a curriculum for a user
export
const
subscribeCurriculum
=
async
(
req
,
res
)
=>
{
const
{
userId
,
curriculum
}
=
req
.
body
;
try
{
let
userProgress
=
await
UserProgress
.
findOne
({
userId
});
if
(
!
userProgress
)
{
// If there is no user progress record for this user, create a new one
userProgress
=
new
UserProgress
({
userId
,
curriculumProgress
:
[],
totalMarks
:
0
curriculums
:
[
curriculum
],
// Add the curriculum to the curriculums array
});
}
else
{
// If there is an existing user progress record, check if the curriculum already exists
const
existingCurriculumIndex
=
userProgress
.
curriculums
.
findIndex
(
c
=>
c
.
curriculumCode
===
curriculum
.
curriculumCode
);
if
(
existingCurriculumIndex
!==
-
1
)
{
// If the curriculum exists, update it
userProgress
.
curriculums
[
existingCurriculumIndex
]
=
curriculum
;
}
else
{
// If the curriculum doesn't exist, add it to the array
userProgress
.
curriculums
.
push
(
curriculum
);
}
}
const
curriculumProgressIndex
=
userProgress
.
curriculumProgress
.
findIndex
(
progress
=>
progress
.
curriculumId
.
toString
()
===
curriculumId
)
;
// Update the totalCurriculumsMarks based on curriculum marks
const
totalCurriculumsMarks
=
userProgress
.
curriculums
.
reduce
((
total
,
curriculum
)
=>
total
+
curriculum
.
curriculumMark
,
0
);
userProgress
.
totalCurriculumsMarks
=
totalCurriculumsMarks
;
if
(
curriculumProgressIndex
===
-
1
)
{
userProgress
.
curriculumProgress
.
push
({
curriculumId
,
tutorialProgress
:
[]
});
// Save the user progress record
await
userProgress
.
save
();
res
.
status
(
200
).
json
({
message
:
'
Curriculum subscription successful
'
});
}
catch
(
error
)
{
console
.
error
(
error
);
res
.
status
(
500
).
json
({
error
:
'
Internal server error
'
});
}
};
// Get user's curriculum subscriptions and progress
export
const
getUserProgress
=
async
(
req
,
res
)
=>
{
const
userId
=
req
.
params
.
userId
;
try
{
const
userProgress
=
await
UserProgress
.
findOne
({
userId
});
if
(
!
userProgress
)
{
return
res
.
status
(
404
).
json
({
message
:
'
User progress not found
'
});
}
await
userProgress
.
save
();
res
.
status
(
201
).
json
({
message
:
"
User subscribed to curriculum
"
,
userProgress
});
res
.
status
(
200
).
json
({
userProgress
});
}
catch
(
error
)
{
res
.
status
(
500
).
json
({
message
:
"
Error subscribing to curriculum
"
,
error
});
console
.
error
(
error
);
res
.
status
(
500
).
json
({
error
:
'
Internal server error
'
});
}
};
export
const
updateUserProgress
=
async
(
req
,
res
)
=>
{
const
{
userId
,
curriculumId
,
tutorialId
,
taskId
,
taskMarks
}
=
req
.
body
;
// Update task item progress and calculate overall progress
export
const
updateTaskItemProgress
=
async
(
req
,
res
)
=>
{
const
{
userId
,
curriculumCode
,
tutorialCode
,
taskItemTitle
,
taskItemMarkUser
,
taskItemSpentTime
}
=
req
.
body
;
try
{
const
userProgress
=
await
UserProgress
.
findOne
({
userId
});
if
(
!
userProgress
)
{
return
res
.
status
(
404
).
json
({
message
:
"
User progress not found
"
});
return
res
.
status
(
404
).
json
({
message
:
'
User progress not found
'
});
}
const
curriculumProgressIndex
=
userProgress
.
curriculumProgress
.
findIndex
(
progress
=>
progress
.
curriculumId
.
toString
()
===
curriculumId
);
if
(
curriculumProgressIndex
!==
-
1
)
{
const
curriculumProgress
=
userProgress
.
curriculumProgress
[
curriculumProgressIndex
];
const
tutorialProgressIndex
=
curriculumProgress
.
tutorialProgress
.
findIndex
(
tutorialProgress
=>
tutorialProgress
.
tutorialId
.
toString
()
===
tutorialId
);
if
(
tutorialProgressIndex
!==
-
1
)
{
const
tutorialProgress
=
curriculumProgress
.
tutorialProgress
[
tutorialProgressIndex
];
const
taskProgressIndex
=
tutorialProgress
.
taskProgress
.
findIndex
(
taskProgress
=>
taskProgress
.
taskId
.
toString
()
===
taskId
);
if
(
taskProgressIndex
!==
-
1
)
{
const
taskProgress
=
tutorialProgress
.
taskProgress
[
taskProgressIndex
];
taskProgress
.
completed
=
true
;
taskProgress
.
marks
=
taskMarks
;
// Update tutorial completion status
const
tutorialTotalMarks
=
tutorialProgress
.
tutorialId
.
totalTutorialMarks
;
// You'll need to populate this field
if
(
tutorialTotalMarks
>
0
)
{
tutorialProgress
.
completed
=
(
tutorialProgress
.
marks
/
tutorialTotalMarks
)
>
0.85
;
}
// Update curriculum completion status
const
curriculumTotalMarks
=
curriculumProgress
.
curriculumId
.
totalCurriculumMarks
;
// You'll need to populate this field
if
(
curriculumTotalMarks
>
0
)
{
curriculumProgress
.
completed
=
(
curriculumProgress
.
marks
/
curriculumTotalMarks
)
>
0.85
;
}
// Update user total marks
userProgress
.
totalMarks
=
userProgress
.
curriculumProgress
.
reduce
(
(
total
,
curriculumProgress
)
=>
total
+
curriculumProgress
.
marks
,
0
);
}
}
// Find the curriculum, tutorial, and task item to update
const
curriculumIndex
=
userProgress
.
curriculums
.
findIndex
(
c
=>
c
.
curriculumCode
===
curriculumCode
);
if
(
curriculumIndex
===
-
1
)
{
return
res
.
status
(
404
).
json
({
message
:
'
Curriculum not found
'
});
}
const
tutorialIndex
=
userProgress
.
curriculums
[
curriculumIndex
].
tutorials
.
findIndex
(
t
=>
t
.
tutorialCode
===
tutorialCode
);
if
(
tutorialIndex
===
-
1
)
{
return
res
.
status
(
404
).
json
({
message
:
'
Tutorial not found
'
});
}
const
taskItemIndex
=
userProgress
.
curriculums
[
curriculumIndex
].
tutorials
[
tutorialIndex
].
taskItems
.
findIndex
(
item
=>
item
.
title
===
taskItemTitle
);
if
(
taskItemIndex
===
-
1
)
{
return
res
.
status
(
404
).
json
({
message
:
'
Task item not found
'
});
}
// Update task item progress
userProgress
.
curriculums
[
curriculumIndex
].
tutorials
[
tutorialIndex
].
taskItems
[
taskItemIndex
].
taskItemMarkUser
=
taskItemMarkUser
;
userProgress
.
curriculums
[
curriculumIndex
].
tutorials
[
tutorialIndex
].
taskItems
[
taskItemIndex
].
taskItemSpentTime
=
taskItemSpentTime
;
// Calculate total task marks and spent time for the tutorial
const
tutorial
=
userProgress
.
curriculums
[
curriculumIndex
].
tutorials
[
tutorialIndex
];
tutorial
.
tutorialMarkUser
=
tutorial
.
taskItems
.
reduce
((
total
,
item
)
=>
total
+
item
.
taskItemMarkUser
,
0
);
tutorial
.
tutorialSpentTime
=
tutorial
.
taskItems
.
reduce
((
total
,
item
)
=>
total
+
item
.
taskItemSpentTime
,
0
);
// Calculate total tutorial marks and spent time for the curriculum
const
curriculum
=
userProgress
.
curriculums
[
curriculumIndex
];
curriculum
.
curriculumMarkUser
=
curriculum
.
tutorials
.
reduce
((
total
,
t
)
=>
total
+
t
.
tutorialMarkUser
,
0
);
curriculum
.
curriculumSpentTime
=
curriculum
.
tutorials
.
reduce
((
total
,
t
)
=>
total
+
t
.
tutorialSpentTime
,
0
);
// Calculate total curriculum marks and spent time for the user
userProgress
.
totalCurriculumsMarks
=
userProgress
.
curriculums
.
reduce
((
total
,
c
)
=>
total
+
c
.
curriculumMarkUser
,
0
);
userProgress
.
totalCurriculumSpentTime
=
userProgress
.
curriculums
.
reduce
((
total
,
c
)
=>
total
+
c
.
curriculumSpentTime
,
0
);
// Save the updated user progress
await
userProgress
.
save
();
res
.
status
(
200
).
json
({
message
:
"
User progress updated
"
,
userProgress
});
res
.
status
(
200
).
json
({
message
:
'
Task item progress updated successfully
'
});
}
catch
(
error
)
{
res
.
status
(
500
).
json
({
message
:
"
Error updating user progress
"
,
error
});
console
.
error
(
error
);
res
.
status
(
500
).
json
({
error
:
'
Internal server error
'
});
}
};
\ No newline at end of file
};
Project/Backend/Server_Node/models/userProgress.model.js
View file @
17009258
import
mongoose
from
"
mongoose
"
;
const
commonFields
=
{
createdBy
:
String
,
updatedBy
:
String
,
createdAt
:
{
type
:
Date
,
default
:
new
Date
(),
const
taskItemSchema
=
new
mongoose
.
Schema
({
title
:
{
type
:
String
,
required
:
true
,
},
updatedAt
:
{
type
:
Date
,
default
:
new
Date
()
,
description
:
{
type
:
String
,
required
:
true
,
},
};
const
taskProgressSchema
=
new
mongoose
.
Schema
({
taskI
d
:
{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
ref
:
'
Task
'
howToDo
:
[
String
],
referenceImage
:
String
,
referenceVideo
:
String
,
taskI
temMark
:
{
type
:
Number
,
default
:
0
},
completed
:
{
type
:
Boolean
,
default
:
false
taskItemMarkUser
:
{
type
:
Number
,
default
:
0
},
task
MarkUser
:
{
task
ItemSpentTime
:
{
type
:
Number
,
default
:
0
}
});
}
,
}
,
{
_id
:
false
}
);
const
tutorialProgressSchema
=
new
mongoose
.
Schema
({
tutorialId
:
{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
ref
:
'
Tutorial
'
const
tutorialTypeUserProgressSchema
=
new
mongoose
.
Schema
({
tutorialCode
:
String
,
tutorialTitle
:
String
,
tutorialDescription
:
String
,
tutorialImage
:
String
,
tutorialMark
:
{
type
:
Number
,
default
:
0
},
taskProgress
:
[
taskProgressSchema
],
completed
:
{
type
:
Boolean
,
default
:
false
},
tutorialMarkUser
:
{
type
:
Number
,
default
:
0
}
});
const
curriculumProgressSchema
=
new
mongoose
.
Schema
({
curriculumId
:
{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
ref
:
'
Curriculum
'
},
tutorialProgress
:
[
tutorialProgressSchema
],
completed
:
{
type
:
Boolean
,
default
:
false
tutorialSpentTime
:
{
type
:
Number
,
default
:
0
},
taskItems
:
[
taskItemSchema
],
},
{
_id
:
false
});
const
curriculumTypeUserProgressSchema
=
new
mongoose
.
Schema
({
curriculumCode
:
String
,
curriculumLevel
:
Number
,
curriculumTitle
:
String
,
curriculumDescription
:
String
,
curriculumImage
:
String
,
curriculumMark
:
{
type
:
Number
,
default
:
0
},
curriculumMarkUser
:
{
type
:
Number
,
default
:
0
}
});
},
curriculumSpentTime
:
{
type
:
Number
,
default
:
0
},
tutorials
:
[
tutorialTypeUserProgressSchema
],
},
{
_id
:
false
});
const
userProgressSchema
=
new
mongoose
.
Schema
({
userId
:
{
...
...
@@ -66,16 +73,29 @@ const userProgressSchema = new mongoose.Schema({
required
:
true
,
ref
:
'
User
'
},
curriculum
Progress
:
[
curriculum
ProgressSchema
],
curriculum
s
:
[
curriculumTypeUser
ProgressSchema
],
totalCurriculumsMarks
:
{
type
:
Number
,
default
:
0
},
totalCurriculum
sMarksUser
:
{
totalCurriculum
SpentTime
:
{
type
:
Number
,
default
:
0
},
...
commonFields
status
:
{
type
:
Number
,
default
:
1
,
},
createdBy
:
String
,
createdAt
:
{
type
:
Date
,
default
:
new
Date
(),
},
updatedBy
:
String
,
updatedAt
:
{
type
:
Date
,
default
:
new
Date
(),
},
});
const
UserProgress
=
mongoose
.
model
(
"
UserProgress
"
,
userProgressSchema
);
...
...
Project/Backend/Server_Node/routes/userProgress.routes.js
View file @
17009258
import
express
from
"
express
"
;
import
{
getUser
SubscribedCurriculums
,
subscribeToCurriculum
,
updateUser
Progress
}
from
"
../controllers/userProgress.controller.js
"
;
import
{
getUser
Progress
,
subscribeCurriculum
,
updateTaskItem
Progress
}
from
"
../controllers/userProgress.controller.js
"
;
const
router
=
express
.
Router
();
router
.
get
(
'
/:userId
'
,
getUserSubscribedCurriculums
);
router
.
post
(
'
/
'
,
subscribeToCurriculum
);
router
.
put
(
'
/
:userId
'
,
updateUserProgress
);
router
.
post
(
'
/subscribe-curriculum
'
,
subscribeCurriculum
);
router
.
get
(
'
/:userId
'
,
getUserProgress
);
router
.
put
(
'
/
update-task-item-progress
'
,
updateTaskItemProgress
);
export
default
router
;
Project/Frontend/SignConnectPlus/src/menu-items/application.tsx
View file @
17009258
...
...
@@ -136,6 +136,12 @@ const application: NavItemType = {
title
:
<
FormattedMessage
id=
"learning-curriculums-subscribed"
/>,
type
:
'
item
'
,
url
:
'
/learning-management/curriculums-subscribed
'
,
},
{
id
:
'
learning-curriculums-subscribed-tutorial
'
,
title
:
<
FormattedMessage
id=
"learning-curriculums-subscribed-tutorial"
/>,
type
:
'
item
'
,
url
:
'
/learning-management/curriculums-subscribed-tutorial
'
,
},
{
id
:
'
learning-lead-board
'
,
...
...
Project/Frontend/SignConnectPlus/src/pages/learning-management/learning-curriculums-subscribed/tutorial/tutorial.tsx
0 → 100644
View file @
17009258
// material-ui
// project import
// types
// assets
// ==============================|| Tutorial ||============================== //
const
Tutorial
=
()
=>
{
return
(
<>
</>
)
}
export
default
Tutorial
;
Project/Frontend/SignConnectPlus/src/routes/MainRoutes.tsx
View file @
17009258
...
...
@@ -27,7 +27,7 @@ const Dashboard = Loadable(lazy(() => import('pages/home/dashboard')));
const
MemberManagementList
=
Loadable
(
lazy
(()
=>
import
(
'
pages/member-management/list/list
'
)));
// render - user management page
const
UserManagementList
=
Loadable
(
lazy
(()
=>
import
(
'
pages/user-management/list/list
'
)));
const
UserManagementList
=
Loadable
(
lazy
(()
=>
import
(
'
pages/user-management/list/list
'
)));
// render - ssl translate process page
const
SSLTranslateProcess
=
Loadable
(
lazy
(()
=>
import
(
'
pages/ssl-translate/process/process
'
)));
...
...
@@ -36,6 +36,7 @@ const SSLTranslateProcess = Loadable(lazy(() => import('pages/ssl-translate/proc
const
LearningDashboard
=
Loadable
(
lazy
(()
=>
import
(
'
pages/learning-management/dashboard
'
)));
const
LearningCurriculums
=
Loadable
(
lazy
(()
=>
import
(
'
pages/learning-management/learning-curriculums/list/list
'
)));
const
LearningCurriculumsSubscribed
=
Loadable
(
lazy
(()
=>
import
(
'
pages/learning-management/learning-curriculums-subscribed/list/list
'
)));
const
LearningCurriculumsSubscribedTutorial
=
Loadable
(
lazy
(()
=>
import
(
'
pages/learning-management/learning-curriculums-subscribed/tutorial/tutorial
'
)));
const
LearningLeadBoard
=
Loadable
(
lazy
(()
=>
import
(
'
pages/learning-management/learning-lead-board/list/list
'
)));
const
LearningFeedBack
=
Loadable
(
lazy
(()
=>
import
(
'
pages/learning-management/learning-feedback/list/list
'
)));
...
...
@@ -134,6 +135,10 @@ const MainRoutes = {
path
:
'
curriculums-subscribed
'
,
element
:
<
LearningCurriculumsSubscribed
/>
},
{
path
:
'
curriculums-subscribed-tutorial
'
,
element
:
<
LearningCurriculumsSubscribedTutorial
/>
},
{
path
:
'
lead-board
'
,
element
:
<
LearningLeadBoard
/>
...
...
Project/Frontend/SignConnectPlus/src/types/userProgress.ts
0 → 100644
View file @
17009258
export
interface
userProgressType
{
userId
:
string
curriculums
?:
curriculumTypeUserProgress
[]
totalCurriculumsMarks
:
number
totalCurriculumSpentTime
:
number
status
:
number
createdBy
:
string
createdAt
:
Date
updatedBy
?:
string
updatedAt
?:
Date
}
export
interface
curriculumTypeUserProgress
{
_id
?:
string
curriculumCode
:
string
curriculumLevel
:
number
curriculumTitle
:
string
curriculumDescription
:
string
curriculumImage
:
string
curriculumMark
:
number
curriculumMarkUser
:
number
curriculumSpentTime
:
number
tutorials
:
tutorialTypeUserProgress
[],
}
export
interface
tutorialTypeUserProgress
{
_id
?:
string
tutorialCode
?:
string
tutorialTitle
?:
string
tutorialDescription
?:
string
tutorialImage
?:
string
tutorialMark
:
number
tutorialMarkUser
:
number
tutorialSpentTime
:
number
taskItems
:
taskItemTypeUserProgress
[]
}
export
interface
taskItemTypeUserProgress
{
_id
?:
string
title
:
string
,
description
:
string
,
howToDo
:
string
[],
referenceImage
:
string
,
referenceVideo
:
string
,
taskItemMark
:
number
taskItemMarkUser
:
number
taskItemSpentTime
:
number
}
\ 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