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
Show 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
"
;
import
UserProgress
from
"
../models/userProgress.model.js
"
;
export
const
getUserSubscribedCurriculums
=
async
(
req
,
res
)
=>
{
// Logic to subscribe to a curriculum for a user
const
userId
=
req
.
params
.
userId
;
export
const
subscribeCurriculum
=
async
(
req
,
res
)
=>
{
const
{
userId
,
curriculum
}
=
req
.
body
;
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
;
try
{
try
{
let
userProgress
=
await
UserProgress
.
findOne
({
userId
});
let
userProgress
=
await
UserProgress
.
findOne
({
userId
});
if
(
!
userProgress
)
{
if
(
!
userProgress
)
{
// If there is no user progress record for this user, create a new one
userProgress
=
new
UserProgress
({
userProgress
=
new
UserProgress
({
userId
,
userId
,
curriculumProgress
:
[],
curriculums
:
[
curriculum
],
// Add the curriculum to the curriculums array
totalMarks
:
0
});
});
}
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
);
if
(
curriculumProgressIndex
===
-
1
)
{
userProgress
.
curriculumProgress
.
push
({
curriculumId
,
tutorialProgress
:
[]
});
}
}
// Update the totalCurriculumsMarks based on curriculum marks
const
totalCurriculumsMarks
=
userProgress
.
curriculums
.
reduce
((
total
,
curriculum
)
=>
total
+
curriculum
.
curriculumMark
,
0
);
userProgress
.
totalCurriculumsMarks
=
totalCurriculumsMarks
;
// Save the user progress record
await
userProgress
.
save
();
await
userProgress
.
save
();
res
.
status
(
201
).
json
({
message
:
"
User subscribed to curriculum
"
,
userProgress
});
res
.
status
(
200
).
json
({
message
:
'
Curriculum subscription successful
'
});
}
catch
(
error
)
{
}
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
)
=>
{
// Get user's curriculum subscriptions and progress
const
{
userId
,
curriculumId
,
tutorialId
,
taskId
,
taskMarks
}
=
req
.
body
;
export
const
getUserProgress
=
async
(
req
,
res
)
=>
{
const
userId
=
req
.
params
.
userId
;
try
{
try
{
const
userProgress
=
await
UserProgress
.
findOne
({
userId
});
const
userProgress
=
await
UserProgress
.
findOne
({
userId
});
if
(
!
userProgress
)
{
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
(
res
.
status
(
200
).
json
({
userProgress
});
progress
=>
progress
.
curriculumId
.
toString
()
===
curriculumId
}
catch
(
error
)
{
);
console
.
error
(
error
);
res
.
status
(
500
).
json
({
error
:
'
Internal server error
'
});
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
(
// Update task item progress and calculate overall progress
taskProgress
=>
taskProgress
.
taskId
.
toString
()
===
taskId
export
const
updateTaskItemProgress
=
async
(
req
,
res
)
=>
{
)
;
const
{
userId
,
curriculumCode
,
tutorialCode
,
taskItemTitle
,
taskItemMarkUser
,
taskItemSpentTime
}
=
req
.
body
;
if
(
taskProgressIndex
!==
-
1
)
{
try
{
const
taskProgress
=
tutorialProgress
.
taskProgress
[
taskProgressIndex
];
const
userProgress
=
await
UserProgress
.
findOne
({
userId
});
taskProgress
.
completed
=
true
;
taskProgress
.
marks
=
taskMarks
;
// Update tutorial completion status
if
(
!
userProgress
)
{
const
tutorialTotalMarks
=
tutorialProgress
.
tutorialId
.
totalTutorialMarks
;
// You'll need to populate this field
return
res
.
status
(
404
).
json
({
message
:
'
User progress not found
'
});
if
(
tutorialTotalMarks
>
0
)
{
tutorialProgress
.
completed
=
(
tutorialProgress
.
marks
/
tutorialTotalMarks
)
>
0.85
;
}
}
// Update curriculum completion status
// Find the curriculum, tutorial, and task item to update
const
curriculumTotalMarks
=
curriculumProgress
.
curriculumId
.
totalCurriculumMarks
;
// You'll need to populate this field
const
curriculumIndex
=
userProgress
.
curriculums
.
findIndex
(
c
=>
c
.
curriculumCode
===
curriculumCode
);
if
(
curriculumTotalMarks
>
0
)
{
if
(
curriculumIndex
===
-
1
)
{
curriculumProgress
.
completed
=
(
curriculumProgress
.
marks
/
curriculumTotalMarks
)
>
0.85
;
return
res
.
status
(
404
).
json
({
message
:
'
Curriculum not found
'
})
;
}
}
// Update user total marks
const
tutorialIndex
=
userProgress
.
curriculums
[
curriculumIndex
].
tutorials
.
findIndex
(
t
=>
t
.
tutorialCode
===
tutorialCode
);
userProgress
.
totalMarks
=
userProgress
.
curriculumProgress
.
reduce
(
if
(
tutorialIndex
===
-
1
)
{
(
total
,
curriculumProgress
)
=>
total
+
curriculumProgress
.
marks
,
return
res
.
status
(
404
).
json
({
message
:
'
Tutorial not found
'
});
0
);
}
}
}
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
();
await
userProgress
.
save
();
res
.
status
(
200
).
json
({
message
:
"
User progress updated
"
,
userProgress
});
res
.
status
(
200
).
json
({
message
:
'
Task item progress updated successfully
'
});
}
catch
(
error
)
{
}
catch
(
error
)
{
res
.
status
(
500
).
json
({
message
:
"
Error updating user progress
"
,
error
});
console
.
error
(
error
);
res
.
status
(
500
).
json
({
error
:
'
Internal server error
'
});
}
}
};
};
Project/Backend/Server_Node/models/userProgress.model.js
View file @
17009258
import
mongoose
from
"
mongoose
"
;
import
mongoose
from
"
mongoose
"
;
const
commonFields
=
{
const
taskItemSchema
=
new
mongoose
.
Schema
({
createdBy
:
String
,
title
:
{
updatedBy
:
String
,
type
:
String
,
createdAt
:
{
required
:
true
,
type
:
Date
,
default
:
new
Date
(),
},
},
updatedAt
:
{
description
:
{
type
:
Date
,
type
:
String
,
default
:
new
Date
()
,
required
:
true
,
},
},
};
howToDo
:
[
String
],
referenceImage
:
String
,
const
taskProgressSchema
=
new
mongoose
.
Schema
({
referenceVideo
:
String
,
taskI
d
:
{
taskI
temMark
:
{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
type
:
Number
,
ref
:
'
Task
'
default
:
0
},
},
completed
:
{
taskItemMarkUser
:
{
type
:
Boolean
,
type
:
Number
,
default
:
false
default
:
0
},
},
task
MarkUser
:
{
task
ItemSpentTime
:
{
type
:
Number
,
type
:
Number
,
default
:
0
default
:
0
}
});
const
tutorialProgressSchema
=
new
mongoose
.
Schema
({
tutorialId
:
{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
ref
:
'
Tutorial
'
},
},
taskProgress
:
[
taskProgressSchema
],
},
{
_id
:
false
});
completed
:
{
type
:
Boolean
,
const
tutorialTypeUserProgressSchema
=
new
mongoose
.
Schema
({
default
:
false
tutorialCode
:
String
,
tutorialTitle
:
String
,
tutorialDescription
:
String
,
tutorialImage
:
String
,
tutorialMark
:
{
type
:
Number
,
default
:
0
},
},
tutorialMarkUser
:
{
tutorialMarkUser
:
{
type
:
Number
,
type
:
Number
,
default
:
0
default
:
0
}
});
const
curriculumProgressSchema
=
new
mongoose
.
Schema
({
curriculumId
:
{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
ref
:
'
Curriculum
'
},
},
tutorialProgress
:
[
tutorialProgressSchema
],
tutorialSpentTime
:
{
completed
:
{
type
:
Number
,
type
:
Boolean
,
default
:
0
default
:
false
},
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
:
{
curriculumMarkUser
:
{
type
:
Number
,
type
:
Number
,
default
:
0
default
:
0
}
},
});
curriculumSpentTime
:
{
type
:
Number
,
default
:
0
},
tutorials
:
[
tutorialTypeUserProgressSchema
],
},
{
_id
:
false
});
const
userProgressSchema
=
new
mongoose
.
Schema
({
const
userProgressSchema
=
new
mongoose
.
Schema
({
userId
:
{
userId
:
{
...
@@ -66,16 +73,29 @@ const userProgressSchema = new mongoose.Schema({
...
@@ -66,16 +73,29 @@ const userProgressSchema = new mongoose.Schema({
required
:
true
,
required
:
true
,
ref
:
'
User
'
ref
:
'
User
'
},
},
curriculum
Progress
:
[
curriculum
ProgressSchema
],
curriculum
s
:
[
curriculumTypeUser
ProgressSchema
],
totalCurriculumsMarks
:
{
totalCurriculumsMarks
:
{
type
:
Number
,
type
:
Number
,
default
:
0
default
:
0
},
},
totalCurriculum
sMarksUser
:
{
totalCurriculum
SpentTime
:
{
type
:
Number
,
type
:
Number
,
default
:
0
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
);
const
UserProgress
=
mongoose
.
model
(
"
UserProgress
"
,
userProgressSchema
);
...
...
Project/Backend/Server_Node/routes/userProgress.routes.js
View file @
17009258
import
express
from
"
express
"
;
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
();
const
router
=
express
.
Router
();
router
.
get
(
'
/:userId
'
,
getUserSubscribedCurriculums
);
router
.
post
(
'
/subscribe-curriculum
'
,
subscribeCurriculum
);
router
.
post
(
'
/
'
,
subscribeToCurriculum
);
router
.
get
(
'
/:userId
'
,
getUserProgress
);
router
.
put
(
'
/
:userId
'
,
updateUserProgress
);
router
.
put
(
'
/
update-task-item-progress
'
,
updateTaskItemProgress
);
export
default
router
;
export
default
router
;
Project/Frontend/SignConnectPlus/src/menu-items/application.tsx
View file @
17009258
...
@@ -136,6 +136,12 @@ const application: NavItemType = {
...
@@ -136,6 +136,12 @@ const application: NavItemType = {
title
:
<
FormattedMessage
id=
"learning-curriculums-subscribed"
/>,
title
:
<
FormattedMessage
id=
"learning-curriculums-subscribed"
/>,
type
:
'
item
'
,
type
:
'
item
'
,
url
:
'
/learning-management/curriculums-subscribed
'
,
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
'
,
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
...
@@ -36,6 +36,7 @@ const SSLTranslateProcess = Loadable(lazy(() => import('pages/ssl-translate/proc
...
@@ -36,6 +36,7 @@ const SSLTranslateProcess = Loadable(lazy(() => import('pages/ssl-translate/proc
const
LearningDashboard
=
Loadable
(
lazy
(()
=>
import
(
'
pages/learning-management/dashboard
'
)));
const
LearningDashboard
=
Loadable
(
lazy
(()
=>
import
(
'
pages/learning-management/dashboard
'
)));
const
LearningCurriculums
=
Loadable
(
lazy
(()
=>
import
(
'
pages/learning-management/learning-curriculums/list/list
'
)));
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
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
LearningLeadBoard
=
Loadable
(
lazy
(()
=>
import
(
'
pages/learning-management/learning-lead-board/list/list
'
)));
const
LearningFeedBack
=
Loadable
(
lazy
(()
=>
import
(
'
pages/learning-management/learning-feedback/list/list
'
)));
const
LearningFeedBack
=
Loadable
(
lazy
(()
=>
import
(
'
pages/learning-management/learning-feedback/list/list
'
)));
...
@@ -134,6 +135,10 @@ const MainRoutes = {
...
@@ -134,6 +135,10 @@ const MainRoutes = {
path
:
'
curriculums-subscribed
'
,
path
:
'
curriculums-subscribed
'
,
element
:
<
LearningCurriculumsSubscribed
/>
element
:
<
LearningCurriculumsSubscribed
/>
},
},
{
path
:
'
curriculums-subscribed-tutorial
'
,
element
:
<
LearningCurriculumsSubscribedTutorial
/>
},
{
{
path
:
'
lead-board
'
,
path
:
'
lead-board
'
,
element
:
<
LearningLeadBoard
/>
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