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
f15726d6
Commit
f15726d6
authored
Aug 24, 2023
by
janithGamage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update
Desc : curriculum , tutorial backend config
parent
cbd507de
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
183 additions
and
0 deletions
+183
-0
Project/Backend/Server_Node/controllers/curriculum.controller.js
.../Backend/Server_Node/controllers/curriculum.controller.js
+52
-0
Project/Backend/Server_Node/controllers/tutorial.controller.js
...ct/Backend/Server_Node/controllers/tutorial.controller.js
+52
-0
Project/Backend/Server_Node/models/curriculum.model.js
Project/Backend/Server_Node/models/curriculum.model.js
+21
-0
Project/Backend/Server_Node/models/tutorial.model.js
Project/Backend/Server_Node/models/tutorial.model.js
+22
-0
Project/Backend/Server_Node/routes/curriculum.routes.js
Project/Backend/Server_Node/routes/curriculum.routes.js
+18
-0
Project/Backend/Server_Node/routes/tutorial.routes.js
Project/Backend/Server_Node/routes/tutorial.routes.js
+18
-0
No files found.
Project/Backend/Server_Node/controllers/curriculum.controller.js
0 → 100644
View file @
f15726d6
import
Curriculum
from
'
../models/curriculum.model.js
'
;
export
const
getAllCurriculums
=
async
(
req
,
res
)
=>
{
try
{
const
curriculums
=
await
Curriculum
.
find
();
res
.
status
(
200
).
json
(
curriculums
);
}
catch
(
error
)
{
res
.
status
(
500
).
json
({
message
:
error
.
message
});
}
}
export
const
getCurriculumById
=
async
(
req
,
res
)
=>
{
const
{
id
}
=
req
.
params
;
try
{
const
curriculum
=
await
Curriculum
.
findById
(
id
);
res
.
status
(
200
).
json
(
curriculum
);
}
catch
(
error
)
{
res
.
status
(
404
).
json
({
message
:
'
Curriculum not found
'
});
}
}
export
const
createCurriculum
=
async
(
req
,
res
)
=>
{
const
curriculumData
=
req
.
body
;
try
{
const
newCurriculum
=
new
Curriculum
(
curriculumData
);
await
newCurriculum
.
save
();
res
.
status
(
201
).
json
(
newCurriculum
);
}
catch
(
error
)
{
res
.
status
(
400
).
json
({
message
:
error
.
message
});
}
}
export
const
updateCurriculum
=
async
(
req
,
res
)
=>
{
const
{
id
}
=
req
.
params
;
const
updatedCurriculum
=
req
.
body
;
try
{
const
result
=
await
Curriculum
.
findByIdAndUpdate
(
id
,
updatedCurriculum
,
{
new
:
true
});
res
.
status
(
200
).
json
(
result
);
}
catch
(
error
)
{
res
.
status
(
404
).
json
({
message
:
'
Curriculum not found
'
});
}
}
export
const
deleteCurriculum
=
async
(
req
,
res
)
=>
{
const
{
id
}
=
req
.
params
;
try
{
await
Curriculum
.
findByIdAndDelete
(
id
);
res
.
status
(
200
).
json
({
message
:
'
Curriculum deleted successfully
'
});
}
catch
(
error
)
{
res
.
status
(
404
).
json
({
message
:
'
Curriculum not found
'
});
}
}
Project/Backend/Server_Node/controllers/tutorial.controller.js
0 → 100644
View file @
f15726d6
import
Tutorial
from
'
../models/tutorial.model
'
;
export
const
getAllTutorials
=
async
(
req
,
res
)
=>
{
try
{
const
tutorials
=
await
Tutorial
.
find
();
res
.
status
(
200
).
json
(
tutorials
);
}
catch
(
error
)
{
res
.
status
(
500
).
json
({
message
:
error
.
message
});
}
}
export
const
getTutorialById
=
async
(
req
,
res
)
=>
{
const
{
id
}
=
req
.
params
;
try
{
const
tutorial
=
await
Tutorial
.
findById
(
id
);
res
.
status
(
200
).
json
(
tutorial
);
}
catch
(
error
)
{
res
.
status
(
404
).
json
({
message
:
'
Tutorial not found
'
});
}
}
export
const
createTutorial
=
async
(
req
,
res
)
=>
{
const
tutorialData
=
req
.
body
;
try
{
const
newTutorial
=
new
Tutorial
(
tutorialData
);
await
newTutorial
.
save
();
res
.
status
(
201
).
json
(
newTutorial
);
}
catch
(
error
)
{
res
.
status
(
400
).
json
({
message
:
error
.
message
});
}
}
export
const
updateTutorial
=
async
(
req
,
res
)
=>
{
const
{
id
}
=
req
.
params
;
const
updatedTutorial
=
req
.
body
;
try
{
const
result
=
await
Tutorial
.
findByIdAndUpdate
(
id
,
updatedTutorial
,
{
new
:
true
});
res
.
status
(
200
).
json
(
result
);
}
catch
(
error
)
{
res
.
status
(
404
).
json
({
message
:
'
Tutorial not found
'
});
}
}
export
const
deleteTutorial
=
async
(
req
,
res
)
=>
{
const
{
id
}
=
req
.
params
;
try
{
await
Tutorial
.
findByIdAndDelete
(
id
);
res
.
status
(
200
).
json
({
message
:
'
Tutorial deleted successfully
'
});
}
catch
(
error
)
{
res
.
status
(
404
).
json
({
message
:
'
Tutorial not found
'
});
}
}
Project/Backend/Server_Node/models/curriculum.model.js
0 → 100644
View file @
f15726d6
import
mongoose
from
"
mongoose
"
;
const
tutorialSchema
=
new
mongoose
.
Schema
({
tutorialCode
:
String
,
tutorialTitle
:
String
,
tutorialImage
:
String
,
// Additional fields for tutorial content
});
const
curriculumSchema
=
new
mongoose
.
Schema
({
curriculumCode
:
String
,
curriculumLevel
:
String
,
curriculumName
:
String
,
curriculumImage
:
String
,
tutorials
:
[
tutorialSchema
],
// Embed tutorials as subdocuments
// Additional fields for curriculum details
});
const
Curriculum
=
mongoose
.
model
(
"
Curriculum
"
,
curriculumSchema
);
export
default
Curriculum
;
Project/Backend/Server_Node/models/tutorial.model.js
0 → 100644
View file @
f15726d6
import
mongoose
from
"
mongoose
"
;
const
taskItemSchema
=
new
mongoose
.
Schema
({
title
:
String
,
description
:
String
,
howToDo
:
String
,
referenceImage
:
String
,
referenceVideo
:
String
,
// Additional fields for task items
});
const
tutorialSchema
=
new
mongoose
.
Schema
({
tutorialCode
:
String
,
tutorialTitle
:
String
,
tutorialImage
:
String
,
taskItems
:
[
taskItemSchema
],
// Embed task items as subdocuments
// Additional fields for tutorial details
});
const
Tutorial
=
mongoose
.
model
(
"
Tutorial
"
,
tutorialSchema
);
export
default
Tutorial
;
Project/Backend/Server_Node/routes/curriculum.routes.js
0 → 100644
View file @
f15726d6
import
express
from
"
express
"
;
import
{
createCurriculum
,
deleteCurriculum
,
getAllCurriculums
,
getCurriculumById
,
updateCurriculum
}
from
"
../controllers/curriculum.controller.js
"
;
const
router
=
express
.
Router
();
router
.
get
(
'
/
'
,
getAllCurriculums
);
router
.
get
(
'
/:id
'
,
getCurriculumById
);
router
.
post
(
'
/
'
,
createCurriculum
);
router
.
put
(
'
/:id
'
,
updateCurriculum
);
router
.
delete
(
'
/:id
'
,
deleteCurriculum
);
export
default
router
;
Project/Backend/Server_Node/routes/tutorial.routes.js
0 → 100644
View file @
f15726d6
import
express
from
"
express
"
;
import
{
getAllTutorials
,
getTutorialById
,
createTutorial
,
updateTutorial
,
deleteTutorial
}
from
"
../controllers/tutorial.controller.js
"
;
const
router
=
express
.
Router
();
router
.
get
(
'
/
'
,
getAllTutorials
);
router
.
get
(
'
/:id
'
,
getTutorialById
);
router
.
post
(
'
/
'
,
createTutorial
);
router
.
put
(
'
/:id
'
,
updateTutorial
);
router
.
delete
(
'
/:id
'
,
deleteTutorial
);
export
default
router
;
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