Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-158
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
2
Merge Requests
2
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
2022-158
2022-158
Commits
63737548
Commit
63737548
authored
Oct 03, 2022
by
Thiwanka K.A.T
🎯
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'IT19076362' into 'master'
It19076362 See merge request
!80
parents
69e8391d
16bfceb2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
38 deletions
+50
-38
backend/database.db
backend/database.db
+0
-0
backend/routes/module_routes.py
backend/routes/module_routes.py
+19
-2
frontend/src/pages/ManageModules.js
frontend/src/pages/ManageModules.js
+29
-34
frontend/src/routes/Routes.js
frontend/src/routes/Routes.js
+2
-2
No files found.
backend/database.db
View file @
63737548
No preview for this file type
backend/routes/module_routes.py
View file @
63737548
...
...
@@ -25,6 +25,23 @@ def create_module():
}}),
HTTP_201_CREATED
@
module
.
get
(
'/'
)
def
get_modules
():
module_obj
=
Module
.
query
.
all
()
modules
=
[]
print
(
module_obj
)
for
module
in
module_obj
:
modules
.
append
({
"id"
:
module
.
id
,
"name"
:
module
.
name
,
"code"
:
module
.
code
,
"created_at"
:
module
.
created_at
,
"updated_at"
:
module
.
updated_at
})
print
(
modules
)
if
module_obj
is
None
:
return
jsonify
({
'err'
:
"Module does not exist"
}),
HTTP_400_BAD_REQUEST
return
jsonify
({
'msg'
:
'Module found'
,
'modules'
:
modules
}),
HTTP_200_OK
@
module
.
get
(
'/<module_id>'
)
def
get_module
(
module_id
):
if
not
module_id
:
...
...
@@ -33,9 +50,9 @@ def get_module(module_id):
module_obj
=
Module
.
query
.
filter_by
(
id
=
module_id
)
.
first
()
if
module_obj
is
None
:
return
jsonify
({
'err'
:
"Module does not exist"
}),
HTTP_400_BAD_REQUEST
return
jsonify
({
'err'
:
"Module
s
does not exist"
}),
HTTP_400_BAD_REQUEST
return
jsonify
({
'msg'
:
'Module found'
,
'module'
:
{
return
jsonify
({
'msg'
:
'Module
s
found'
,
'module'
:
{
'name'
:
module_obj
.
name
,
'code'
:
module_obj
.
code
,
'created_at'
:
module_obj
.
created_at
,
...
...
frontend/src/pages/Manage
Class
es.js
→
frontend/src/pages/Manage
Modul
es.js
View file @
63737548
import
React
,
{
useEffect
,
useState
}
from
"
react
"
;
import
{
Link
}
from
"
react-router-dom
"
;
import
axios
from
"
axios
"
;
import
{
RiDeleteBinLine
}
from
"
react-icons/ri
"
;
import
axios
from
"
axios
"
;
import
Sidebar
from
"
../components/sidebar/Sidebar
"
;
import
Spinner
from
"
../components/loading/Spinner
"
;
...
...
@@ -10,21 +10,16 @@ import TopNav from "../components/topnav/TopNav";
import
"
../assets/css/Usercreate.css
"
;
const
Manage
Class
es
=
()
=>
{
const
Manage
Modul
es
=
()
=>
{
const
[
btnState
,
setBtnState
]
=
useState
(
false
);
const
[
error
,
setError
]
=
useState
(
""
);
const
[
isLoading
,
setIsLoading
]
=
useState
(
true
);
const
[
m
aterial
,
setMaterial
]
=
useState
({
code
:
""
,
name
:
""
});
const
[
m
aterials
,
setMaterial
s
]
=
useState
([]);
const
[
m
odule
,
setModule
]
=
useState
({
code
:
""
,
name
:
""
});
const
[
m
odules
,
setModule
s
]
=
useState
([]);
const
fields
=
[
""
,
"
Module Code
"
,
"
Module Name
"
,
"
Created At
"
,
"
Actions
"
];
const
renderOrderHead
=
(
item
,
index
)
=>
<
th
key
=
{
index
}
>
{
item
}
<
/th>
;
const
classes
=
[
{
code
:
"
A001
"
,
name
:
"
CTSE
"
,
createdAt
:
"
2022-04-05
"
},
{
code
:
"
A002
"
,
name
:
"
CTSE
"
,
createdAt
:
"
2022-04-05
"
},
{
code
:
"
A003
"
,
name
:
"
CTSE
"
,
createdAt
:
"
2022-04-05
"
},
];
const
renderOrderBody
=
(
item
,
index
)
=>
(
<
tr
key
=
{
index
}
>
<
td
>
{
index
+
1
}
<
/td
>
...
...
@@ -40,7 +35,7 @@ const ManageClasses = () => {
className
=
"
action-btn x
"
style
=
{{
marginLeft
:
"
2rem
"
}}
onClick
=
{()
=>
{
if
(
window
.
confirm
(
"
Are you sure to delete this
class
?
"
))
{
if
(
window
.
confirm
(
"
Are you sure to delete this
module
?
"
))
{
deleteHandler
(
item
.
_id
,
item
.
username
);
}
}}
...
...
@@ -56,37 +51,35 @@ const ManageClasses = () => {
e
.
preventDefault
();
setBtnState
(
true
);
for
(
let
key
of
Object
.
keys
(
m
aterial
))
{
if
(
!
m
aterial
[
key
])
{
for
(
let
key
of
Object
.
keys
(
m
odule
))
{
if
(
!
m
odule
[
key
])
{
setBtnState
(
false
);
return
setError
(
"
Please fill all the fields
"
);
}
}
try
{
const
res
=
await
axios
.
post
(
"
materials
"
,
material
);
const
res
=
await
axios
.
post
(
"
/modules/create
"
,
module
);
console
.
log
(
res
);
setMaterial
({
code
:
""
,
name
:
""
,
});
getAllMaterial
();
setModule
({
code
:
""
,
name
:
""
});
getAllModules
();
setError
(
""
);
window
.
alert
(
"
Class
added successfully
"
);
window
.
alert
(
"
Module
added successfully
"
);
setBtnState
(
false
);
setIsLoading
(
true
);
}
catch
(
err
)
{
setBtnState
(
false
);
setError
(
err
.
response
.
data
.
message
);
console
.
log
(
err
.
response
);
}
};
const
deleteHandler
=
async
(
id
,
username
)
=>
{
try
{
const
res
=
await
axios
.
delete
(
`m
aterial
s/
${
id
}
`
);
const
res
=
await
axios
.
delete
(
`m
odule
s/
${
id
}
`
);
if
(
res
.
statusText
===
"
OK
"
)
{
getAllM
aterial
();
getAllM
odules
();
setError
(
""
);
window
.
alert
(
"
Class has been successfully deleted
"
);
setIsLoading
(
true
);
...
...
@@ -96,17 +89,19 @@ const ManageClasses = () => {
}
};
const
getAllMaterial
=
async
()
=>
{
const
getAllModules
=
async
()
=>
{
setIsLoading
(
true
);
try
{
const
res
=
await
axios
.
get
(
`materials`
);
setMaterials
(
res
.
data
.
materials
);
const
res
=
await
axios
.
get
(
"
modules
"
);
console
.
log
(
res
);
setModules
(
res
.
data
.
modules
);
setIsLoading
(
false
);
}
catch
(
err
)
{
console
.
log
(
err
.
response
);
}
};
useEffect
(()
=>
getAllM
aterial
(),
[]);
useEffect
(()
=>
getAllM
odules
(),
[]);
return
(
<
div
>
...
...
@@ -129,10 +124,10 @@ const ManageClasses = () => {
<
input
type
=
"
text
"
placeholder
=
"
Module Code
"
value
=
{
m
aterial
.
code
}
value
=
{
m
odule
.
code
}
onChange
=
{
e
=>
setM
aterial
({
...
m
aterial
,
setM
odule
({
...
m
odule
,
code
:
e
.
target
.
value
,
})
}
...
...
@@ -145,10 +140,10 @@ const ManageClasses = () => {
<
input
type
=
"
text
"
placeholder
=
"
Module Name
"
value
=
{
m
aterial
.
name
}
value
=
{
m
odule
.
name
}
onChange
=
{
e
=>
setM
aterial
({
...
m
aterial
,
setM
odule
({
...
m
odule
,
name
:
e
.
target
.
value
,
})
}
...
...
@@ -167,14 +162,14 @@ const ManageClasses = () => {
<
/div
>
<
div
className
=
"
card col-12
"
>
<
h2
>
Created
Modules
<
/h2
>
{
false
?
(
{
isLoading
?
(
<
Spinner
/>
)
:
(
<
Table
limit
=
"
5
"
headData
=
{
fields
}
renderHead
=
{(
item
,
index
)
=>
renderOrderHead
(
item
,
index
)}
bodyData
=
{
class
es
}
bodyData
=
{
modul
es
}
renderBody
=
{(
item
,
index
)
=>
renderOrderBody
(
item
,
index
)}
/
>
)}
...
...
@@ -185,4 +180,4 @@ const ManageClasses = () => {
);
};
export
default
Manage
Class
es
;
export
default
Manage
Modul
es
;
frontend/src/routes/Routes.js
View file @
63737548
...
...
@@ -13,7 +13,7 @@ import ManagerApprovedOrders from "../pages/ManagerApprovedOrders";
import
TeacherDashboard
from
"
../pages/TeacherDashboard
"
;
import
ManageServices
from
"
../pages/ManageServices
"
;
import
ManageStudents
from
"
../pages/ManageStudents
"
;
import
Manage
Classes
from
"
../pages/ManageClass
es
"
;
import
Manage
Modules
from
"
../pages/ManageModul
es
"
;
import
OfficerDashboard
from
"
../pages/OfficerDashboard
"
;
import
OfficerOrders
from
"
../pages/OfficerOrders
"
;
import
Register
from
"
../pages/Register
"
;
...
...
@@ -38,7 +38,7 @@ const Routes = () => {
<
Route
exact
path
=
"
/auth/teacher/dashboard
"
component
=
{
TeacherDashboard
}
/
>
<
Route
exact
path
=
"
/auth/teacher/students
"
component
=
{
ManageStudents
}
/
>
<
Route
exact
path
=
"
/auth/teacher/modules
"
component
=
{
Manage
Class
es
}
/
>
<
Route
exact
path
=
"
/auth/teacher/modules
"
component
=
{
Manage
Modul
es
}
/
>
<
Route
exact
path
=
"
/auth/teacher/assignments
"
component
=
{
ManageAssignments
}
/
>
<
Route
exact
path
=
"
/auth/teacher/assignments/:id
"
component
=
{
ViewAssignment
}
/
>
<
Route
exact
path
=
"
/auth/teacher/assignments/:id/diagrams
"
component
=
{
GeneratedDiagrams
}
/
>
...
...
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