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
163c73e9
Commit
163c73e9
authored
Aug 31, 2023
by
janithgamage1.ed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update
Desc : update project
parent
9d40242e
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
213 additions
and
50 deletions
+213
-50
Project/Backend/Server_Node/controllers/curriculum.controller.js
.../Backend/Server_Node/controllers/curriculum.controller.js
+22
-0
Project/Backend/Server_Node/controllers/tutorial.controller.js
...ct/Backend/Server_Node/controllers/tutorial.controller.js
+12
-2
Project/Backend/Server_Node/controllers/userProgress.controller.js
...ackend/Server_Node/controllers/userProgress.controller.js
+85
-22
Project/Backend/Server_Node/models/curriculum.model.js
Project/Backend/Server_Node/models/curriculum.model.js
+7
-3
Project/Backend/Server_Node/models/tutorial.model.js
Project/Backend/Server_Node/models/tutorial.model.js
+8
-0
Project/Backend/Server_Node/models/userProgress.model.js
Project/Backend/Server_Node/models/userProgress.model.js
+69
-20
Project/Backend/Server_Node/routes/userProgress.routes.js
Project/Backend/Server_Node/routes/userProgress.routes.js
+4
-3
Project/Frontend/SignConnectPlus/src/sections/learning-management/learning-curriculums/CurriculumCard.tsx
...arning-management/learning-curriculums/CurriculumCard.tsx
+6
-0
No files found.
Project/Backend/Server_Node/controllers/curriculum.controller.js
View file @
163c73e9
...
@@ -26,17 +26,39 @@ export const createCurriculum = async (req, res) => {
...
@@ -26,17 +26,39 @@ export const createCurriculum = async (req, res) => {
const
curriculumData
=
req
.
body
;
const
curriculumData
=
req
.
body
;
try
{
try
{
const
newCurriculum
=
new
Curriculum
(
curriculumData
);
const
newCurriculum
=
new
Curriculum
(
curriculumData
);
// Calculate total tutorial mark
let
totalTutorialMark
=
0
;
for
(
const
tutorialId
of
curriculumData
.
tutorials
)
{
const
tutorial
=
await
Tutorial
.
findById
(
tutorialId
);
totalTutorialMark
+=
tutorial
.
tutorialMark
;
}
newCurriculum
.
curriculumMark
=
totalTutorialMark
;
await
newCurriculum
.
save
();
await
newCurriculum
.
save
();
res
.
status
(
201
).
json
(
newCurriculum
);
res
.
status
(
201
).
json
(
newCurriculum
);
}
catch
(
error
)
{
}
catch
(
error
)
{
res
.
status
(
400
).
json
({
message
:
error
.
message
});
res
.
status
(
400
).
json
({
message
:
error
.
message
});
}
}
}
}
export
const
updateCurriculum
=
async
(
req
,
res
)
=>
{
export
const
updateCurriculum
=
async
(
req
,
res
)
=>
{
const
{
id
}
=
req
.
params
;
const
{
id
}
=
req
.
params
;
const
updatedCurriculum
=
req
.
body
;
const
updatedCurriculum
=
req
.
body
;
try
{
try
{
const
curriculum
=
await
Curriculum
.
findById
(
id
);
// Calculate total tutorial mark
let
totalTutorialMark
=
0
;
for
(
const
tutorialId
of
updatedCurriculum
.
tutorials
)
{
const
tutorial
=
await
Tutorial
.
findById
(
tutorialId
);
totalTutorialMark
+=
tutorial
.
tutorialMark
;
}
updatedCurriculum
.
curriculumMark
=
totalTutorialMark
;
const
result
=
await
Curriculum
.
findByIdAndUpdate
(
id
,
updatedCurriculum
,
{
new
:
true
});
const
result
=
await
Curriculum
.
findByIdAndUpdate
(
id
,
updatedCurriculum
,
{
new
:
true
});
res
.
status
(
200
).
json
(
result
);
res
.
status
(
200
).
json
(
result
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
Project/Backend/Server_Node/controllers/tutorial.controller.js
View file @
163c73e9
...
@@ -21,6 +21,11 @@ export const getTutorialById = async (req, res) => {
...
@@ -21,6 +21,11 @@ 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
const
totalTaskMarks
=
tutorialData
.
taskItems
.
reduce
((
total
,
task
)
=>
total
+
(
task
.
taskItemMark
||
0
),
0
);
tutorialData
.
tutorialMarks
=
totalTaskMarks
;
try
{
try
{
const
newTutorial
=
new
Tutorial
(
tutorialData
);
const
newTutorial
=
new
Tutorial
(
tutorialData
);
await
newTutorial
.
save
();
await
newTutorial
.
save
();
...
@@ -32,9 +37,14 @@ export const createTutorial = async (req, res) => {
...
@@ -32,9 +37,14 @@ export const createTutorial = async (req, res) => {
export
const
updateTutorial
=
async
(
req
,
res
)
=>
{
export
const
updateTutorial
=
async
(
req
,
res
)
=>
{
const
{
id
}
=
req
.
params
;
const
{
id
}
=
req
.
params
;
const
updatedTutorial
=
req
.
body
;
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
);
updatedTutorialData
.
tutorialMarks
=
totalTaskMarks
;
try
{
try
{
const
result
=
await
Tutorial
.
findByIdAndUpdate
(
id
,
updatedTutorial
,
{
new
:
true
});
const
result
=
await
Tutorial
.
findByIdAndUpdate
(
id
,
updatedTutorial
Data
,
{
new
:
true
});
res
.
status
(
200
).
json
(
result
);
res
.
status
(
200
).
json
(
result
);
}
catch
(
error
)
{
}
catch
(
error
)
{
res
.
status
(
404
).
json
({
message
:
'
Tutorial not found
'
});
res
.
status
(
404
).
json
({
message
:
'
Tutorial not found
'
});
...
...
Project/Backend/Server_Node/controllers/userProgress.controller.js
View file @
163c73e9
import
UserProgress
from
'
../models/userProgress.model.js
'
;
import
UserProgress
from
"
../models/userProgress.model.js
"
;
export
const
getUser
Progres
s
=
async
(
req
,
res
)
=>
{
export
const
getUser
SubscribedCurriculum
s
=
async
(
req
,
res
)
=>
{
const
userId
=
req
.
params
.
userId
;
const
userId
=
req
.
params
.
userId
;
try
{
try
{
const
userProgress
=
await
UserProgress
.
findOne
({
userId
}).
populate
(
'
curriculumId tutorialProgress.tutorialId
'
);
const
userProgress
=
await
UserProgress
.
find
({
userId
})
.
populate
(
'
curriculumProgress.curriculumId
'
)
.
populate
(
'
curriculumProgress.tutorialProgress.tutorialId
'
)
.
populate
(
'
curriculumProgress.tutorialProgress.taskProgress.taskId
'
);
res
.
status
(
200
).
json
(
userProgress
);
res
.
status
(
200
).
json
(
userProgress
);
}
catch
(
error
)
{
}
catch
(
error
)
{
res
.
status
(
500
).
json
({
message
:
error
.
message
});
res
.
status
(
500
).
json
({
message
:
"
Error fetching user progress
"
,
error
});
}
}
}
}
;
export
const
updateUserProgress
=
async
(
req
,
res
)
=>
{
export
const
subscribeToCurriculum
=
async
(
req
,
res
)
=>
{
const
userId
=
req
.
params
.
userId
;
const
{
userId
,
curriculumId
}
=
req
.
body
;
const
{
curriculumId
,
tutorialId
,
completed
,
marks
}
=
req
.
body
;
try
{
try
{
let
userProgress
=
await
UserProgress
.
findOne
({
userId
});
let
userProgress
=
await
UserProgress
.
findOne
({
userId
});
if
(
!
userProgress
)
{
if
(
!
userProgress
)
{
userProgress
=
new
UserProgress
({
userId
});
userProgress
=
new
UserProgress
({
userId
,
curriculumProgress
:
[],
totalMarks
:
0
});
}
}
const
curriculumProgress
=
userProgress
.
curriculumId
.
find
(
prog
=>
prog
.
curriculumId
.
equals
(
curriculumId
));
const
curriculumProgressIndex
=
userProgress
.
curriculumProgress
.
findIndex
(
progress
=>
progress
.
curriculumId
.
toString
()
===
curriculumId
);
if
(
!
curriculumProgress
)
{
if
(
curriculumProgressIndex
===
-
1
)
{
userProgress
.
curriculumId
.
push
({
curriculumId
});
userProgress
.
curriculumProgress
.
push
({
curriculumId
,
tutorialProgress
:
[]
});
}
}
const
tutorialProgress
=
curriculumProgress
.
tutorialProgress
.
find
(
prog
=>
prog
.
tutorialId
.
equals
(
tutorialId
));
await
userProgress
.
save
();
res
.
status
(
201
).
json
({
message
:
"
User subscribed to curriculum
"
,
userProgress
});
}
catch
(
error
)
{
res
.
status
(
500
).
json
({
message
:
"
Error subscribing to curriculum
"
,
error
});
}
};
if
(
!
tutorialProgress
)
{
export
const
updateUserProgress
=
async
(
req
,
res
)
=>
{
curriculumProgress
.
tutorialProgress
.
push
({
tutorialId
,
completed
});
const
{
userId
,
curriculumId
,
tutorialId
,
taskId
,
taskMarks
}
=
req
.
body
;
}
else
{
tutorialProgress
.
completed
=
completed
;
try
{
const
userProgress
=
await
UserProgress
.
findOne
({
userId
});
if
(
!
userProgress
)
{
return
res
.
status
(
404
).
json
({
message
:
"
User progress not found
"
});
}
}
userProgress
.
marks
=
marks
;
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
);
}
}
}
await
userProgress
.
save
();
await
userProgress
.
save
();
res
.
status
(
200
).
json
(
userProgress
);
res
.
status
(
200
).
json
(
{
message
:
"
User progress updated
"
,
userProgress
}
);
}
catch
(
error
)
{
}
catch
(
error
)
{
res
.
status
(
500
).
json
({
message
:
error
.
message
});
res
.
status
(
500
).
json
({
message
:
"
Error updating user progress
"
,
error
});
}
}
}
}
;
\ No newline at end of file
Project/Backend/Server_Node/models/curriculum.model.js
View file @
163c73e9
...
@@ -22,6 +22,10 @@ const curriculumSchema = new mongoose.Schema({
...
@@ -22,6 +22,10 @@ const curriculumSchema = new mongoose.Schema({
curriculumTitle
:
String
,
curriculumTitle
:
String
,
curriculumDescription
:
String
,
curriculumDescription
:
String
,
curriculumImage
:
String
,
curriculumImage
:
String
,
curriculumMark
:
{
type
:
Number
,
default
:
0
},
tutorials
:
[{
tutorials
:
[{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
ref
:
"
Tutorial
"
,
ref
:
"
Tutorial
"
,
...
...
Project/Backend/Server_Node/models/tutorial.model.js
View file @
163c73e9
...
@@ -19,6 +19,10 @@ const taskItemSchema = new mongoose.Schema({
...
@@ -19,6 +19,10 @@ const taskItemSchema = new mongoose.Schema({
howToDo
:
String
,
howToDo
:
String
,
referenceImage
:
String
,
referenceImage
:
String
,
referenceVideo
:
String
,
referenceVideo
:
String
,
taskItemMark
:
{
type
:
Number
,
default
:
0
}
// Additional fields for task items
// Additional fields for task items
});
});
...
@@ -30,6 +34,10 @@ const tutorialSchema = new mongoose.Schema({
...
@@ -30,6 +34,10 @@ const tutorialSchema = new mongoose.Schema({
tutorialTitle
:
String
,
tutorialTitle
:
String
,
tutorialDescription
:
String
,
tutorialDescription
:
String
,
tutorialImage
:
String
,
tutorialImage
:
String
,
tutorialMarks
:
{
type
:
Number
,
default
:
0
},
taskItems
:
[
taskItemSchema
],
// Embed task items as subdocuments
taskItems
:
[
taskItemSchema
],
// Embed task items as subdocuments
// Additional fields for tutorial details
// Additional fields for tutorial details
status
:
{
status
:
{
...
...
Project/Backend/Server_Node/models/userProgress.model.js
View file @
163c73e9
import
mongoose
from
"
mongoose
"
;
import
mongoose
from
"
mongoose
"
;
const
userProgressSchema
=
new
mongoose
.
Schema
({
const
commonFields
=
{
userId
:
{
createdBy
:
String
,
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
updatedBy
:
String
,
required
:
true
,
createdAt
:
{
ref
:
'
User
'
// Reference to the User model
type
:
Date
,
default
:
new
Date
(),
},
},
curriculumId
:
{
updatedAt
:
{
type
:
Date
,
default
:
new
Date
(),
},
};
const
taskProgressSchema
=
new
mongoose
.
Schema
({
taskId
:
{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
required
:
true
,
ref
:
'
Task
'
ref
:
'
Curriculum
'
// Reference to the Curriculum model
},
completed
:
{
type
:
Boolean
,
default
:
false
},
},
tutorialProgress
:
[
taskMarkUser
:
{
{
type
:
Number
,
default
:
0
}
});
const
tutorialProgressSchema
=
new
mongoose
.
Schema
({
tutorialId
:
{
tutorialId
:
{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
ref
:
'
Tutorial
'
// Reference to the Tutorial model
ref
:
'
Tutorial
'
},
},
taskProgress
:
[
taskProgressSchema
],
completed
:
{
completed
:
{
type
:
Boolean
,
type
:
Boolean
,
default
:
false
default
:
false
},
tutorialMarkUser
:
{
type
:
Number
,
default
:
0
}
}
}
});
],
marks
:
{
const
curriculumProgressSchema
=
new
mongoose
.
Schema
({
curriculumId
:
{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
ref
:
'
Curriculum
'
},
tutorialProgress
:
[
tutorialProgressSchema
],
completed
:
{
type
:
Boolean
,
default
:
false
},
curriculumMarkUser
:
{
type
:
Number
,
type
:
Number
,
default
:
0
default
:
0
}
}
});
});
const
userProgressSchema
=
new
mongoose
.
Schema
({
userId
:
{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
required
:
true
,
ref
:
'
User
'
},
curriculumProgress
:
[
curriculumProgressSchema
],
totalCurriculumsMarks
:
{
type
:
Number
,
default
:
0
},
totalCurriculumsMarksUser
:
{
type
:
Number
,
default
:
0
},
...
commonFields
});
const
UserProgress
=
mongoose
.
model
(
"
UserProgress
"
,
userProgressSchema
);
const
UserProgress
=
mongoose
.
model
(
"
UserProgress
"
,
userProgressSchema
);
export
default
UserProgress
;
export
default
UserProgress
;
Project/Backend/Server_Node/routes/userProgress.routes.js
View file @
163c73e9
import
express
from
"
express
"
;
import
express
from
"
express
"
;
import
{
getUser
Progress
,
updateUserProgress
}
from
"
../controllers/userProgress.controller.js
"
;
import
{
getUser
SubscribedCurriculums
,
subscribeToCurriculum
,
updateUserProgress
}
from
"
../controllers/userProgress.controller.js
"
;
const
router
=
express
.
Router
();
const
router
=
express
.
Router
();
router
.
get
(
'
/:userId
'
,
getUserProgress
);
router
.
get
(
'
/:userId
'
,
getUserSubscribedCurriculums
);
router
.
post
(
'
/:userId
'
,
updateUserProgress
);
router
.
post
(
'
/:userId
'
,
subscribeToCurriculum
);
router
.
put
(
'
/:userId
'
,
updateUserProgress
);
export
default
router
;
export
default
router
;
Project/Frontend/SignConnectPlus/src/sections/learning-management/learning-curriculums/CurriculumCard.tsx
View file @
163c73e9
...
@@ -231,11 +231,17 @@ const CurriculumCard = ({ curriculum }: { curriculum: curriculumCardProps }) =>
...
@@ -231,11 +231,17 @@ const CurriculumCard = ({ curriculum }: { curriculum: curriculumCardProps }) =>
<
Typography
variant=
"caption"
color=
"secondary"
>
<
Typography
variant=
"caption"
color=
"secondary"
>
Updated in
{
curriculum
.
createdAt
?.
toLocaleTimeString
()
}
Updated in
{
curriculum
.
createdAt
?.
toLocaleTimeString
()
}
</
Typography
>
</
Typography
>
<
Button
variant=
"outlined"
size=
"small"
onClick=
{
()
=>
{
<
Button
variant=
"outlined"
size=
"small"
onClick=
{
()
=>
{
handleClickOpen
()
handleClickOpen
()
}
}
>
}
}
>
Preview
Preview
</
Button
>
</
Button
>
<
Button
variant=
"outlined"
size=
"small"
color=
'success'
onClick=
{
()
=>
{
// handleClickOpen()
}
}
>
Subscribe
</
Button
>
</
Stack
>
</
Stack
>
</
MainCard
>
</
MainCard
>
...
...
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