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
9a75fd43
Commit
9a75fd43
authored
Aug 06, 2021
by
Hasitha Samarasekara
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
# Conflicts: # BackEnd/WebBackEnd/.env
parents
08898267
ae8ae3e9
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
778 additions
and
12 deletions
+778
-12
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/routes/question.route.js
View file @
9a75fd43
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 @
9a75fd43
...
...
@@ -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"
,
...
...
@@ -14344,6 +14354,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 @
9a75fd43
...
...
@@ -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 @
9a75fd43
...
...
@@ -11,6 +11,10 @@ import SignUp from "./Components/SignUp";
import
beforeConfirmation
from
"
./Components/beforeConfirmation
"
;
import
VerifiedAccount
from
"
./Components/AccountVerified
"
;
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
(
...
...
@@ -26,6 +30,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 @
9a75fd43
import
React
,
{
Component
}
from
'
react
'
;
import
axios
from
'
axios
'
;
import
{
Link
}
from
"
react-router-dom
"
;
import
swal
from
'
sweetalert
'
;
export
default
class
AdminUI
extends
Component
{
constructor
(
props
){
super
(
props
);
var
today
=
new
Date
(),
time
=
today
.
getFullYear
()
+
'
-
'
+
(
"
0
"
+
(
today
.
getMonth
()
+
1
)).
slice
(
-
2
)
+
'
-
'
+
today
.
getDate
()
+
'
T
'
+
today
.
getHours
()
+
'
:
'
+
today
.
getMinutes
()
+
'
:
'
+
today
.
getSeconds
()
+
'
Z
'
;
this
.
onChangeCategory
=
this
.
onChangeCategory
.
bind
(
this
);
this
.
onChangeName
=
this
.
onChangeName
.
bind
(
this
);
this
.
onChangeQuestionText
=
this
.
onChangeQuestionText
.
bind
(
this
);
this
.
onChangeQuestionAnswer
=
this
.
onChangeQuestionAnswer
.
bind
(
this
);
this
.
onChangeDefultMark
=
this
.
onChangeDefultMark
.
bind
(
this
);
this
.
onChangeQType
=
this
.
onChangeQType
.
bind
(
this
);
this
.
onChangeGeneralFeedback
=
this
.
onChangeGeneralFeedback
.
bind
(
this
);
this
.
addQuestion
=
this
.
addQuestion
.
bind
(
this
);
this
.
editQuestion
=
this
.
editQuestion
.
bind
(
this
);
this
.
state
=
{
question_id
:
''
,
category
:
''
,
name
:
''
,
question_text
:
''
,
question_answer
:
''
,
defult_mark
:
''
,
q_type
:
''
,
general_feedback
:
''
,
submitStatus
:
false
,
currentTime
:
time
,
editItem
:
false
}
}
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
});
}
onChangeQuestionAnswer
(
e
){
this
.
setState
({
question_answer
:
e
.
target
.
value
});
}
addQuestion
(
e
){
e
.
preventDefault
();
//if(this.state.item_name != null && this.state.item_description != null && this.state.item_category != null && this.state.item_quantity != null && this.state.item_price){
console
.
log
(
`Form submitted:`
);
console
.
log
(
`Category:
${
this
.
state
.
category
}
`
);
console
.
log
(
`Name:
${
this
.
state
.
name
}
`
);
console
.
log
(
`Question Text:
${
this
.
state
.
question_text
}
`
);
console
.
log
(
`Defualt mark:
${
this
.
state
.
defult_mark
}
`
);
console
.
log
(
`Question type:
${
this
.
state
.
q_type
}
`
);
console
.
log
(
`Genaral Feedback:
${
this
.
state
.
general_feedback
}
`
);
const
newQuestion
=
{
category
:
this
.
state
.
category
,
name
:
this
.
state
.
name
,
question_text
:
this
.
state
.
question_text
,
defult_mark
:
this
.
state
.
defult_mark
,
q_type
:
this
.
state
.
q_type
,
time_createdby
:
this
.
state
.
currentTime
,
time_modifiedby
:
this
.
state
.
currentTime
,
general_feedback
:
this
.
state
.
general_feedback
,
};
axios
.
post
(
'
http://localhost:5000/questions/add
'
,
newQuestion
)
.
then
(
res
=>
{
this
.
setState
({
question_id
:
res
.
data
.
question_id
})
})
.
catch
(
//swal("Good job!", "You clicked the button!", "warning"
);
swal
(
"
Data Saved Successfully!
"
,
"
Your Details has been Saved Successfully!
"
,
"
success
"
);
// this.setState({
// nextStep : true
// });
// } else{
// alert("You must fill in all of the fields.");
// }
// window.location = 'https://senosafrontend.herokuapp.com/admin/itemlist';
}
componentDidMount
()
{
if
(
this
.
props
.
match
.
params
.
id
!=
null
){
axios
.
get
(
'
http://localhost:5000/questions/
'
+
this
.
props
.
match
.
params
.
id
)
.
then
(
response
=>
{
this
.
setState
({
category
:
response
.
data
.
category
,
name
:
response
.
data
.
name
,
question_text
:
response
.
data
.
question_text
,
question_answer
:
response
.
data
.
question_answer
,
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
,
submitStatus
:
true
,
})
})
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
})
}
else
{
this
.
setState
({
submitStatus
:
false
});
}
}
editQuestion
(
e
){
e
.
preventDefault
();
//if(this.state.item_name != null && this.state.item_description != null && this.state.item_category != null && this.state.item_quantity != null && this.state.item_price){
console
.
log
(
`Form Update submitted:`
);
console
.
log
(
`Category:
${
this
.
state
.
category
}
`
);
console
.
log
(
`Name:
${
this
.
state
.
name
}
`
);
console
.
log
(
`Question Text:
${
this
.
state
.
question_text
}
`
);
console
.
log
(
`Defualt mark:
${
this
.
state
.
defult_mark
}
`
);
console
.
log
(
`Question type:
${
this
.
state
.
q_type
}
`
);
console
.
log
(
`Genaral Feedback:
${
this
.
state
.
general_feedback
}
`
);
const
editQuestion
=
{
category
:
this
.
state
.
category
,
name
:
this
.
state
.
name
,
question_text
:
this
.
state
.
question_text
,
question_answer
:
this
.
state
.
question_answer
,
defult_mark
:
this
.
state
.
defult_mark
,
q_type
:
this
.
state
.
q_type
,
time_modifiedby
:
this
.
state
.
currentTime
,
general_feedback
:
this
.
state
.
general_feedback
,
};
// axios.post('https://senosaonlineshoppingwebsite.herokuapp.com/products/update/'+this.props.match.params.id,editItem)
// .then(res => console.log(res.data))
// .catch(swal("Good job!", "You clicked the button!", "warning"));
axios
.
post
(
'
http://localhost:5000/questions/update/
'
+
this
.
props
.
match
.
params
.
id
,
editQuestion
)
.
then
(
res
=>
console
.
log
(
res
.
data
))
.
catch
(
swal
(
"
Good job!
"
,
"
You clicked the button!
"
,
"
warning
"
));
swal
(
"
Good job!
"
,
"
Your Details has been Update Successfully!
"
,
"
success
"
);
//this.props.history.push('/');
// }else{
// alert("You must fill in all of the fields.");
// }
}
render
(){
return
(
<
div
>
<
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
.
state
.
submitStatus
?
this
.
editQuestion
:
this
.
addQuestion
}
>
<
div
className
=
"
col-sm-10
"
>
<
br
/>
<
h5
>
{
this
.
state
.
submitStatus
?
"
EDIT QUESTION
"
:
"
ADD QUESTION
"
}
<
/h5
>
<
/div
>
<
div
className
=
"
col-sm-10
"
>
<
br
/>
<
h4
className
=
"
text-left
"
>
<
b
>
Genaral
<
/b></
h4
>
<
div
className
=
"
row
"
>
<
div
className
=
"
col-sm-5
"
>
<
label
>
Category
:
<
/label
>
<
div
style
=
{{
padding
:
'
0px
'
}}
>
<
select
style
=
{{
width
:
'
100%
'
}}
className
=
"
browser-default custom-select
"
onChange
=
{(
e
)
=>
this
.
onChangeCategory
(
e
)}
>
<
option
>
Select
Category
<
/option
>
<
/select
>
<
/div
>
<
/div
>
<
div
className
=
"
col-sm-5
"
>
<
label
>
Lesson
name
:
<
/label
>
<
div
style
=
{{
padding
:
'
0px
'
}}
>
<
input
type
=
"
text
"
required
className
=
"
form-control
"
value
=
{
this
.
state
.
name
}
onChange
=
{
this
.
onChangeName
}
/
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"
row
"
>
<
div
className
=
"
col-sm-10
"
>
<
label
>
Question
text
:
<
/label
>
<
textarea
className
=
"
form-control
"
required
value
=
{
this
.
state
.
question_text
}
onChange
=
{
this
.
onChangeQuestionText
}
/
>
<
/div
>
<
/div
>
<
div
className
=
"
row
"
>
<
div
className
=
"
col-sm-10
"
>
<
label
>
Answer
:
<
/label
>
<
textarea
className
=
"
form-control
"
required
value
=
{
this
.
state
.
question_answer
}
onChange
=
{
this
.
onChangeQuestionAnswer
}
/
>
<
/div
>
<
/div
>
<
div
className
=
"
row
"
>
<
div
className
=
"
col-sm-5
"
>
<
label
>
Default
mark
:
<
/label
>
<
input
type
=
"
text
"
className
=
"
form-control
"
value
=
{
this
.
state
.
defult_mark
}
onChange
=
{
this
.
onChangeDefultMark
}
/
>
<
/div
>
<
div
className
=
"
col-sm-5
"
>
<
label
>
Question
type
:
<
/label
>
<
input
type
=
"
text
"
className
=
"
form-control
"
value
=
{
this
.
state
.
q_type
}
onChange
=
{
this
.
onChangeQType
}
/
>
<
/div
>
<
/div
>
<
div
className
=
"
row
"
>
<
div
className
=
"
col-sm-10
"
>
<
label
>
Genaral
feedback
:
<
/label
>
<
textarea
className
=
"
form-control
"
required
value
=
{
this
.
state
.
general_feedback
}
onChange
=
{
this
.
onChangeGeneralFeedback
}
/
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"
col-sm-10
"
>
<
br
/>
<
div
className
=
"
row
"
>
<
div
className
=
"
col-sm-4
"
>
<
/div
>
<
div
className
=
"
col-sm- mt-3
"
>
<
Link
style
=
{{
textDecoration
:
"
none
"
}}
to
=
{
"
/admin/itemlist
"
}
><
button
className
=
"
btn btn-block btn-warning
"
style
=
{{
width
:
"
159px
"
,
color
:
"
white
"
}}
>
BACK
<
/button></
Link
>
<
/div
>
<
div
className
=
"
col-sm-4
"
>
<
button
style
=
{{
marginTop
:
10
}}
type
=
"
submit
"
value
=
"
Submit
"
className
=
{
this
.
state
.
submitStatus
?
"
btn btn-block btn-success mt-3
"
:
"
btn btn-block btn-primary mt-3
"
}
>
{
this
.
state
.
submitStatus
?
"
EDIT
"
:
"
ADD
"
}
<
/button
>
<
/div
>
<
/div
>
<
/div
>
<
/form
>
<
br
/>
<
br
/>
<
br
/>
<
/div
>
<
/div
>
)
}
}
\ No newline at end of file
WebFrontEnd/smartcoach-frontend/src/Components/IT18050240/question_bank.js
0 → 100644
View file @
9a75fd43
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 @
9a75fd43
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 @
9a75fd43
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