Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-049
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
2021-049
2021-049
Commits
ae8ae3e9
Commit
ae8ae3e9
authored
Aug 06, 2021
by
Hasitha Samarasekara
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'IT18050240' into 'master'
upload Web UI See merge request
!7
parents
5ca7d3f7
f503a3fd
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
779 additions
and
13 deletions
+779
-13
BackEnd/WebBackEnd/.env
BackEnd/WebBackEnd/.env
+1
-1
BackEnd/WebBackEnd/routes/question.route.js
BackEnd/WebBackEnd/routes/question.route.js
+15
-12
WebFrontEnd/smartcoach-frontend/package-lock.json
WebFrontEnd/smartcoach-frontend/package-lock.json
+19
-0
WebFrontEnd/smartcoach-frontend/package.json
WebFrontEnd/smartcoach-frontend/package.json
+1
-0
WebFrontEnd/smartcoach-frontend/src/App.js
WebFrontEnd/smartcoach-frontend/src/App.js
+9
-0
WebFrontEnd/smartcoach-frontend/src/Components/IT18050240/admin_question_management.js.js
...src/Components/IT18050240/admin_question_management.js.js
+352
-0
WebFrontEnd/smartcoach-frontend/src/Components/IT18050240/question_bank.js
...coach-frontend/src/Components/IT18050240/question_bank.js
+161
-0
WebFrontEnd/smartcoach-frontend/src/Components/IT18050240/question_details.js
...ch-frontend/src/Components/IT18050240/question_details.js
+46
-0
WebFrontEnd/smartcoach-frontend/src/Components/IT18050240/question_layout.js
...ach-frontend/src/Components/IT18050240/question_layout.js
+175
-0
No files found.
BackEnd/WebBackEnd/.env
View file @
ae8ae3e9
ATLAS_URI = mongodb+srv://admin:admin@cluster0.wmb3b.mongodb.net/myFirstDatabase?retryWrites=true&w=majority
\ No newline at end of file
ATLAS_URI = mongodb+srv://admin:admin@cluster0.wmb3b.mongodb.net/SmartCoach?retryWrites=true&w=majority
\ No newline at end of file
BackEnd/WebBackEnd/routes/question.route.js
View file @
ae8ae3e9
const
questionRouter
=
require
(
'
express
'
).
Router
();
let
Question
=
require
(
'
../models/question.model
.js
'
);
let
Question
=
require
(
'
../models/question.model
'
);
const
mongoose
=
require
(
'
mongoose
'
);
questionRouter
.
route
(
'
/
'
).
get
(
function
(
req
,
res
)
{
...
...
@@ -76,25 +76,28 @@ questionRouter.route('/update/:id').post((req, res) => {
Question
.
findById
(
req
.
params
.
id
,
function
(
err
,
question
){
if
(
!
question
)
req
.
status
(
404
).
send
(
"
data is not found
"
);
else
question
.
category
=
req
.
body
.
category
;
question
.
name
=
req
.
body
.
name
;
question
.
question_text
=
req
.
body
.
question_text
;
question
.
defult_mark
=
req
.
body
.
defult_mark
;
question
.
q_type
=
req
.
body
.
q_type
;
question
.
time_createdby
=
req
.
body
.
time_createdby
;
question
.
time_modifiedby
=
req
.
body
.
time_modifiedby
;
question
.
general_feedback
=
req
.
body
.
general_feedback
;
else
{
question
.
category
=
req
.
body
.
category
;
question
.
name
=
req
.
body
.
name
;
question
.
question_text
=
req
.
body
.
question_text
;
question
.
question_answer
=
req
.
body
.
question_answer
;
question
.
defult_mark
=
req
.
body
.
defult_mark
;
question
.
q_type
=
req
.
body
.
q_type
;
question
.
time_modifiedby
=
req
.
body
.
time_modifiedby
;
question
.
general_feedback
=
req
.
body
.
general_feedback
;
}
question
.
save
().
then
(
question
=>
{
res
.
json
(
'
Item update!
'
);
})
res
.
json
(
'
Item update!
'
);
})
.
catch
(
err
=>
{
res
.
status
(
400
).
send
(
"
Update not possible
"
);
});
});
});
questionRouter
.
route
(
'
/delete/:id
'
).
delete
((
req
,
res
)
=>
{
Question
.
findByIdAndDelete
(
req
.
params
.
id
)
.
then
(()
=>
res
.
json
(
'
Product Deleted.
'
))
...
...
WebFrontEnd/smartcoach-frontend/package-lock.json
View file @
ae8ae3e9
...
...
@@ -5437,6 +5437,11 @@
"es6-symbol"
:
"^3.1.1"
}
},
"es6-object-assign"
:
{
"version"
:
"1.1.0"
,
"resolved"
:
"https://registry.npmjs.org/es6-object-assign/-/es6-object-assign-1.1.0.tgz"
,
"integrity"
:
"sha1-wsNYJlYkfDnqEHyx5mUrb58kUjw="
},
"es6-symbol"
:
{
"version"
:
"3.1.3"
,
"resolved"
:
"https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz"
,
...
...
@@ -12126,6 +12131,11 @@
"resolved"
:
"https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz"
,
"integrity"
:
"sha1-mEcocL8igTL8vdhoEputEsPAKeM="
},
"promise-polyfill"
:
{
"version"
:
"6.1.0"
,
"resolved"
:
"https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-6.1.0.tgz"
,
"integrity"
:
"sha1-36lpQ+qcEh/KTem1hoyznTRy4Fc="
},
"prompts"
:
{
"version"
:
"2.4.0"
,
"resolved"
:
"https://registry.npmjs.org/prompts/-/prompts-2.4.0.tgz"
,
...
...
@@ -14334,6 +14344,15 @@
"util.promisify"
:
"~1.0.0"
}
},
"sweetalert"
:
{
"version"
:
"2.1.2"
,
"resolved"
:
"https://registry.npmjs.org/sweetalert/-/sweetalert-2.1.2.tgz"
,
"integrity"
:
"sha512-iWx7X4anRBNDa/a+AdTmvAzQtkN1+s4j/JJRWlHpYE8Qimkohs8/XnFcWeYHH2lMA8LRCa5tj2d244If3S/hzA=="
,
"requires"
:
{
"es6-object-assign"
:
"^1.1.0"
,
"promise-polyfill"
:
"^6.0.2"
}
},
"symbol-tree"
:
{
"version"
:
"3.2.4"
,
"resolved"
:
"https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz"
,
...
...
WebFrontEnd/smartcoach-frontend/package.json
View file @
ae8ae3e9
...
...
@@ -13,6 +13,7 @@
"react-router-dom"
:
"^5.2.0"
,
"react-scripts"
:
"4.0.3"
,
"react-star-rating-component"
:
"^1.4.1"
,
"sweetalert"
:
"^2.1.2"
,
"web-vitals"
:
"^1.1.1"
},
"scripts"
:
{
...
...
WebFrontEnd/smartcoach-frontend/src/App.js
View file @
ae8ae3e9
...
...
@@ -9,6 +9,10 @@ import ItemNav from "./Components/Navbar";
import
Home
from
"
./Components/Home
"
;
import
SignUp
from
"
./Components/SignUp
"
;
import
Dashboard
from
"
./Components/Admin/Dashboard
"
;
import
QuestionDetails
from
"
./Components/IT18050240/question_details
"
import
QuestionLayout
from
"
./Components/IT18050240/question_layout
"
import
AdminQuestionManagement
from
"
./Components/IT18050240/admin_question_management.js
"
import
QuestionBank
from
"
./Components/IT18050240/question_bank
"
function
App
()
{
return
(
...
...
@@ -22,6 +26,11 @@ function App() {
{
/*<Route path="/" exact component={Dashboard}/>*/
}
<
Switch
>
<
Route
path
=
"
/admin
"
><
Dashboard
/><
/Route
>
<
Route
path
=
"
/questiondetails
"
exact
component
=
{
QuestionDetails
}
/
>
<
Route
path
=
"
/question
"
exact
component
=
{
QuestionLayout
}
/
>
<
Route
path
=
"
/questionmanagement
"
exact
component
=
{
AdminQuestionManagement
}
/
>
<
Route
path
=
"
/questionbank
"
exact
component
=
{
QuestionBank
}
/
>
<
Route
path
=
"
/edititem/:id
"
exact
component
=
{
AdminQuestionManagement
}
/
>
<
/Switch
>
<
/div
>
<
/Router
>
...
...
WebFrontEnd/smartcoach-frontend/src/Components/IT18050240/admin_question_management.js.js
0 → 100644
View file @
ae8ae3e9
This diff is collapsed.
Click to expand it.
WebFrontEnd/smartcoach-frontend/src/Components/IT18050240/question_bank.js
0 → 100644
View file @
ae8ae3e9
import
React
,
{
Component
}
from
'
react
'
;
import
axios
from
'
axios
'
;
import
{
Link
}
from
"
react-router-dom
"
;
import
swal
from
'
sweetalert
'
;
const
Quantity
=
props
=>
(
<
tr
>
{
/*<td>{props.quantity.item_id}</td>*/
}
<
td
>
{
props
.
quantity
.
question_text
}
<
/td
>
<
td
>
{
props
.
quantity
.
question_answer
}
<
/td
>
<
td
>
{
props
.
quantity
.
time_modifiedby
}
<
/td
>
<
td
>
<
div
>
<
Link
className
=
"
mx-1 text-success fas fa-pen text-decoration-none
"
to
=
{
"
/edititem/
"
+
props
.
quantity
.
_id
}
><
/Link> <span className=" mx-1 text-danger fas fa-trash" href='#' onClick={
()
=>{props.deleteProduct
(
props.quantity._id
)
}} ></
span
>
<
/div
>
<
/td
>
<
/tr
>
);
export
default
class
QuestionBankUI
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
onChangeQType
=
this
.
onChangeQType
.
bind
(
this
);
this
.
deleteProduct
=
this
.
deleteProduct
.
bind
(
this
);
this
.
onSubmit
=
this
.
onSubmit
.
bind
(
this
);
this
.
state
=
{
q_type
:
''
,
quantity
:
[]
}
}
quantityList
()
{
return
this
.
state
.
quantity
.
map
(
currentTodo
=>
{
return
<
Quantity
quantity
=
{
currentTodo
}
deleteProduct
=
{
this
.
deleteProduct
}
key
=
{
currentTodo
.
_id
}
/
>
});
}
componentDidUpdate
()
{
axios
.
get
(
'
http://localhost:5000/questions/
'
)
.
then
(
response
=>
{
this
.
setState
({
quantity
:
response
.
data
});
})
.
catch
(
function
(
error
)
{
console
.
log
(
error
);
})
}
componentDidMount
()
{
axios
.
get
(
'
http://localhost:5000/questions/
'
)
.
then
(
response
=>
{
this
.
setState
({
quantity
:
response
.
data
});
})
.
catch
(
function
(
error
)
{
console
.
log
(
error
);
})
}
onChangeQType
(
e
)
{
this
.
setState
({
q_type
:
e
.
target
.
value
});
}
onSubmit
(
e
)
{
e
.
preventDefault
();
console
.
log
(
`Question type:
${
this
.
state
.
q_type
}
`
);
if
(
this
.
state
.
q_type
==
"
Multiple_choice
"
)
{
window
.
location
=
'
/questionmanagement/
'
;
}
else
{
}
//window.location = '/admin/pcategory';
}
deleteProduct
(
pid
){
axios
.
delete
(
'
http://localhost:5000/questions/delete/
'
+
pid
)
.
then
(
res
=>
console
.
log
(
res
.
data
));
this
.
setState
({
quantity
:
this
.
state
.
quantity
.
filter
(
el
=>
el
.
pid
!==
pid
)
});
}
render
()
{
return
(
<
div
className
=
"
container text-left
"
>
<
div
className
=
"
col-sm-10
"
>
<
h4
>
Business
Studies
<
/h4
>
<
h6
>
Dashboard
/
My
courses
/
Business
Studies
/
Question
bank
/
Questions
<
/h6
>
<
hr
/>
<
/div
>
<
form
onSubmit
=
{
this
.
onSubmit
}
>
<
div
className
=
"
col-sm-10
"
>
<
div
className
=
"
row
"
>
<
div
className
=
"
col-sm-1 mt-1
"
><
label
>
Category
:
<
/label
>
<
/div
>
<
div
className
=
"
col-sm-5
"
>
<
div
style
=
{{
padding
:
'
0px
'
}}
>
<
select
style
=
{{
width
:
'
100%
'
}}
className
=
"
browser-default custom-select
"
onChange
=
{(
e
)
=>
this
.
onChangeQType
(
e
)}
>
<
option
>
Select
Question
Type
<
/option
>
<
option
key
=
"
Multiple_choice
"
value
=
"
Multiple_choice
"
>
Multiple
choice
<
/option
>
<
option
key
=
"
True_False
"
value
=
"
True_False
"
>
True
/
False
<
/option>
)
<
/select
>
<
/div
>
<
/div
>
<
div
className
=
"
col-sm-3
"
>
<
button
className
=
"
btn btn-block btn btn-secondary
"
type
=
"
submit
"
value
=
"
Submit
"
style
=
{{
color
:
"
white
"
}}
>
Create
new
Question
<
/button
>
<
/div
>
<
div
className
=
"
col-sm-3
"
>
<
button
className
=
"
btn btn-block btn btn-info
"
type
=
"
submit
"
value
=
"
Submit
"
style
=
{{
color
:
"
white
"
}}
>
Auto
Genarate
Question
<
/button
>
<
/div
>
<
/div></
div
>
<
/form
>
<
br
/>
<
div
className
=
"
col-sm-10
"
>
<
table
className
=
"
table
"
>
<
thead
>
<
tr
>
<
th
><
h6
>
Question
Text
<
/h6></
th
>
<
th
><
h6
>
Question
Answer
<
/h6></
th
>
<
th
><
h6
>
Last
modified
by
<
/h6></
th
>
<
th
className
=
"
col-sm-1
"
><
h6
>
Action
<
/h6></
th
>
<
/tr
>
<
/thead
>
<
tbody
>
{
this
.
quantityList
()}
<
/tbody
>
<
/table
>
<
/div
>
<
/div
>
)
}
}
\ No newline at end of file
WebFrontEnd/smartcoach-frontend/src/Components/IT18050240/question_details.js
0 → 100644
View file @
ae8ae3e9
import
React
,
{
Component
}
from
'
react
'
;
import
axios
from
'
axios
'
;
//import swal from 'sweetalert';
import
{
Link
}
from
"
react-router-dom
"
;
export
default
class
AddEditItem
extends
Component
{
render
()
{
return
(
<
div
className
=
"
container
"
>
<
div
class
=
"
border
"
>
<
div
style
=
{{
margin
:
"
15px
"
}}
>
<
h5
className
=
"
text-left
"
>
1
st
Term
Examination
<
/h5
>
<
p
className
=
"
text-center
"
>
Attempts
allowed
:
1
<
/p
>
<
p
className
=
"
text-center
"
>
This
quiz
closed
on
Sunday
,
02
May
2021
,
7
:
10
PM
<
/p
>
<
p
className
=
"
text-center
"
>
time
limit
:
1
hour
30
mins
<
/p
>
<
p
className
=
"
text-center
"
>
Grading
method
:
highest
grade
<
/p
>
<
h5
className
=
"
text-left
"
>
Summary
of
your
pervious
attempts
<
/h5
>
<
table
class
=
"
table table-striped
"
>
<
thead
>
<
tr
>
<
th
>
Attempt
<
/th
>
<
th
>
State
<
/th
>
<
th
>
Review
<
/th
>
<
/tr
>
<
/thead
>
<
tbody
>
<
tr
>
<
td
>
Preview
<
/td
>
<
td
>
In
progress
<
/td
>
<
td
><
/td
>
<
/tr
>
<
/tbody
>
<
/table
>
<
p
className
=
"
text-center
"
>
This
quiz
is
not
currently
available
<
/p
>
<
button
className
=
"
text-center
"
type
=
"
button
"
class
=
"
btn btn-secondary btn-sm
"
>
Back
to
the
course
<
/button
>
<
/div
>
<
/div></
div
>
)
}
}
\ No newline at end of file
WebFrontEnd/smartcoach-frontend/src/Components/IT18050240/question_layout.js
0 → 100644
View file @
ae8ae3e9
import
React
,
{
Component
}
from
'
react
'
;
import
axios
from
'
axios
'
;
//import swal from 'sweetalert';
import
{
Link
}
from
"
react-router-dom
"
;
export
default
class
QuestionLayout
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
onChangeCategory
=
this
.
onChangeCategory
.
bind
(
this
);
this
.
onChangeName
=
this
.
onChangeName
.
bind
(
this
);
this
.
onChangeQuestionText
=
this
.
onChangeQuestionText
.
bind
(
this
);
this
.
onChangeDefultMark
=
this
.
onChangeDefultMark
.
bind
(
this
);
this
.
onChangeQType
=
this
.
onChangeQType
.
bind
(
this
);
this
.
onChangeGeneralFeedback
=
this
.
onChangeGeneralFeedback
.
bind
(
this
);
this
.
onChangeNext
=
this
.
onChangeNext
.
bind
(
this
);
this
.
state
=
{
question_id
:
''
,
category
:
''
,
name
:
''
,
question_text
:
''
,
defult_mark
:
''
,
q_type
:
''
,
general_feedback
:
''
,
categoryArray
:
[],
nextvalue
:
0
,
}
}
onChangeCategory
(
e
){
this
.
setState
({
category
:
e
.
target
.
value
});
}
onChangeName
(
e
){
this
.
setState
({
name
:
e
.
target
.
value
});
}
onChangeQuestionText
(
e
){
this
.
setState
({
question_text
:
e
.
target
.
value
});
}
onChangeDefultMark
(
e
){
this
.
setState
({
defult_mark
:
e
.
target
.
value
});
}
onChangeQType
(
e
){
this
.
setState
({
q_type
:
e
.
target
.
value
});
}
onChangeGeneralFeedback
(
e
){
this
.
setState
({
general_feedback
:
e
.
target
.
value
});
}
onChangeNext
(
e
){
if
(
this
.
state
.
nextvalue
<
this
.
state
.
categoryArray
.
length
-
1
){
this
.
setState
({
nextvalue
:
this
.
state
.
nextvalue
+
1
});
}
else
console
.
log
(
"
press
"
);
}
componentDidMount
()
{
// axios.get('http://localhost:5000/questions/60d9c51296f586320087e10f')
// .then(response =>{
// this.setState({
// category : response.data.category,
// name : response.data.name,
// question_text : response.data.question_text,
// defult_mark : response.data.defult_mark,
// q_type : response.data.q_type,
// time_createdby: response.data.currentTime,
// time_modifiedby: response.data.currentTime,
// general_feedback : response.data.general_feedback
// })
// })
// .catch(function (error) {
// console.log(error)
// })
// if (this.state.item_id != null) {
axios
.
get
(
'
http://localhost:5000/questions/
'
)
.
then
(
response
=>
{
//this.setState({productQuantities: response.data});
let
CategoryList
=
[];
for
(
let
i
=
0
;
i
<
response
.
data
.
length
;
i
++
)
{
CategoryList
.
push
(
response
.
data
[
i
].
question_text
);
}
this
.
setState
({
categoryArray
:
CategoryList
,
})
})
.
catch
(
function
(
error
)
{
console
.
log
(
error
);
})
// } else {
// this.setState({categoryArray: []});
// }
}
render
()
{
return
(
<
div
className
=
"
container
"
>
<
div
class
=
"
border border-primary
"
>
<
div
style
=
{{
margin
:
"
15px
"
}}
>
<
div
style
=
{{
margin
:
"
5px
"
}}
>
<
h6
>
Question
{
this
.
state
.
nextvalue
+
1
}
<
/h6
>
<
p
>
Not
yet
answered
Mark
out
of
5.00
<
/p
>
<
/div
>
<
div
class
=
"
p-3 mb-2 bg-light text-dark
"
>
<
div
className
=
"
text-left
"
style
=
{{
margin
:
"
10px
"
}}
>
{
this
.
state
.
categoryArray
[
this
.
state
.
nextvalue
]}
<
textarea
className
=
"
form-control
"
required
value
=
{
this
.
state
.
general_feedback
}
onChange
=
{
this
.
onChangeGeneralFeedback
}
/
>
<
/div
>
<
/div
>
<
br
/>
<
div
style
=
{{
display
:
'
flex
'
,
justifyContent
:
'
flex-end
'
}}
>
<
button
className
=
"
text-center
"
type
=
"
button
"
onClick
=
{
this
.
onChangeNext
}
class
=
"
btn btn-secondary btn-sm
"
>
Next
<
/button
>
<
/div
>
<
/div
>
<
/div> </
div
>
)
}
}
\ 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