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
c7af3456
Commit
c7af3456
authored
Oct 02, 2021
by
Devinda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update question create function
parent
cc6ec4b4
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
844 additions
and
133 deletions
+844
-133
BackEnd/WebBackEnd/config.js
BackEnd/WebBackEnd/config.js
+3
-0
BackEnd/WebBackEnd/models/pdf.model.js
BackEnd/WebBackEnd/models/pdf.model.js
+33
-0
BackEnd/WebBackEnd/models/question.model.js
BackEnd/WebBackEnd/models/question.model.js
+4
-7
BackEnd/WebBackEnd/package-lock.json
BackEnd/WebBackEnd/package-lock.json
+341
-0
BackEnd/WebBackEnd/package.json
BackEnd/WebBackEnd/package.json
+6
-1
BackEnd/WebBackEnd/routes/pdf.route.js
BackEnd/WebBackEnd/routes/pdf.route.js
+234
-0
BackEnd/WebBackEnd/routes/question.route.js
BackEnd/WebBackEnd/routes/question.route.js
+17
-33
BackEnd/WebBackEnd/server.js
BackEnd/WebBackEnd/server.js
+64
-10
WebFrontEnd/smartcoach-frontend/public/index.html
WebFrontEnd/smartcoach-frontend/public/index.html
+3
-1
WebFrontEnd/smartcoach-frontend/src/App.js
WebFrontEnd/smartcoach-frontend/src/App.js
+6
-4
WebFrontEnd/smartcoach-frontend/src/Components/IT18050240/admin_question_management.js.js
...src/Components/IT18050240/admin_question_management.js.js
+42
-62
WebFrontEnd/smartcoach-frontend/src/Components/IT18050240/lessonandexampage.js
...h-frontend/src/Components/IT18050240/lessonandexampage.js
+77
-0
WebFrontEnd/smartcoach-frontend/src/Components/IT18050240/question_bank.js
...coach-frontend/src/Components/IT18050240/question_bank.js
+13
-14
WebFrontEnd/smartcoach-frontend/src/Components/IT18050240/question_layout.js
...ach-frontend/src/Components/IT18050240/question_layout.js
+1
-1
WebFrontEnd/smartcoach-frontend/src/Images/exam.png
WebFrontEnd/smartcoach-frontend/src/Images/exam.png
+0
-0
WebFrontEnd/smartcoach-frontend/src/Images/lesson.png
WebFrontEnd/smartcoach-frontend/src/Images/lesson.png
+0
-0
No files found.
BackEnd/WebBackEnd/config.js
0 → 100644
View file @
c7af3456
module
.
exports
=
{
mongoURI
:
'
mongodb+srv://admin:admin@cluster0.wmb3b.mongodb.net/SmartCoach?retryWrites=true&w=majority
'
,
};
BackEnd/WebBackEnd/models/pdf.model.js
0 → 100644
View file @
c7af3456
const
mongoose
=
require
(
'
mongoose
'
);
const
Schema
=
mongoose
.
Schema
;
const
ImageSchema
=
new
Schema
({
caption
:
{
required
:
true
,
type
:
String
,
},
lessonname
:
{
required
:
true
,
type
:
String
,
},
lessonno
:
{
required
:
true
,
type
:
String
,
},
filename
:
{
required
:
true
,
type
:
String
,
},
fileId
:
{
required
:
true
,
type
:
String
,
},
createdAt
:
{
default
:
Date
.
now
(),
type
:
Date
,
},
});
const
Image
=
mongoose
.
model
(
'
Image
'
,
ImageSchema
);
module
.
exports
=
Image
;
\ No newline at end of file
BackEnd/WebBackEnd/models/question.model.js
View file @
c7af3456
...
...
@@ -4,10 +4,10 @@ const Schema = mongoose.Schema;
let
Question
=
new
Schema
({
question_id
:
mongoose
.
Schema
.
Types
.
ObjectId
,
category
:{
type
:
String
lesson_no
:{
type
:
Number
},
name
:{
lesson_
name
:{
type
:
String
},
question_text
:{
...
...
@@ -17,10 +17,7 @@ let Question = new Schema({
type
:
String
},
defult_mark
:{
type
:
Number
},
q_type
:{
type
:
String
type
:
Number
},
time_createdby
:{
type
:
Date
...
...
BackEnd/WebBackEnd/package-lock.json
View file @
c7af3456
This diff is collapsed.
Click to expand it.
BackEnd/WebBackEnd/package.json
View file @
c7af3456
...
...
@@ -10,10 +10,15 @@
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"cookie-parser"
:
"^1.4.5"
,
"cors"
:
"^2.8.5"
,
"dotenv"
:
"^10.0.0"
,
"express"
:
"^4.17.1"
,
"mongoose"
:
"^5.12.15"
"method-override"
:
"^3.0.0"
,
"mongoose"
:
"^5.12.15"
,
"morgan"
:
"^1.10.0"
,
"multer"
:
"^1.4.3"
,
"multer-gridfs-storage"
:
"^5.0.1"
},
"devDependencies"
:
{
"nodemailer"
:
"^6.6.2"
...
...
BackEnd/WebBackEnd/routes/pdf.route.js
0 → 100644
View file @
c7af3456
const
express
=
require
(
'
express
'
);
const
imageRouter
=
express
.
Router
();
const
mongoose
=
require
(
'
mongoose
'
);
const
Image
=
require
(
'
../models/pdf.model
'
);
const
config
=
require
(
'
../config
'
);
module
.
exports
=
(
upload
)
=>
{
const
url
=
config
.
mongoURI
;
const
connect
=
mongoose
.
createConnection
(
url
,
{
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
});
let
gfs
;
connect
.
once
(
'
open
'
,
()
=>
{
// initialize stream
gfs
=
new
mongoose
.
mongo
.
GridFSBucket
(
connect
.
db
,
{
bucketName
:
"
uploads
"
});
});
/*
POST: Upload a single image/file to Image collection
*/
imageRouter
.
route
(
'
/
'
)
.
post
(
upload
.
single
(
'
file
'
),
(
req
,
res
,
next
)
=>
{
console
.
log
(
req
.
body
);
// check for existing images
Image
.
findOne
({
caption
:
req
.
body
.
caption
})
.
then
((
image
)
=>
{
console
.
log
(
image
);
if
(
image
)
{
return
res
.
status
(
200
).
json
({
success
:
false
,
message
:
'
Image already exists
'
,
});
}
let
newImage
=
new
Image
({
lessonname
:
req
.
body
.
lessonname
,
lessonno
:
req
.
body
.
lessonno
,
caption
:
req
.
body
.
caption
,
filename
:
req
.
file
.
filename
,
fileId
:
req
.
file
.
id
,
});
newImage
.
save
()
.
then
((
image
)
=>
{
res
.
status
(
200
).
json
({
success
:
true
,
image
,
});
})
.
catch
(
err
=>
res
.
status
(
500
).
json
(
err
));
})
.
catch
(
err
=>
res
.
status
(
500
).
json
(
err
));
})
.
get
((
req
,
res
,
next
)
=>
{
Image
.
find
({})
.
then
(
images
=>
{
res
.
status
(
200
).
json
({
success
:
true
,
images
,
});
})
.
catch
(
err
=>
res
.
status
(
500
).
json
(
err
));
});
/*
GET: Delete an image from the collection
*/
imageRouter
.
route
(
'
/delete/:id
'
)
.
get
((
req
,
res
,
next
)
=>
{
Image
.
findOne
({
_id
:
req
.
params
.
id
})
.
then
((
image
)
=>
{
if
(
image
)
{
Image
.
deleteOne
({
_id
:
req
.
params
.
id
})
.
then
(()
=>
{
return
res
.
status
(
200
).
json
({
success
:
true
,
message
:
`File with ID:
${
req
.
params
.
id
}
deleted`
,
});
})
.
catch
(
err
=>
{
return
res
.
status
(
500
).
json
(
err
)
});
}
else
{
res
.
status
(
200
).
json
({
success
:
false
,
message
:
`File with ID:
${
req
.
params
.
id
}
not found`
,
});
}
})
.
catch
(
err
=>
res
.
status
(
500
).
json
(
err
));
});
/*
GET: Fetch most recently added record
*/
imageRouter
.
route
(
'
/recent
'
)
.
get
((
req
,
res
,
next
)
=>
{
Image
.
findOne
({},
{},
{
sort
:
{
'
_id
'
:
-
1
}})
.
then
((
image
)
=>
{
res
.
status
(
200
).
json
({
success
:
true
,
image
,
});
})
.
catch
(
err
=>
res
.
status
(
500
).
json
(
err
));
});
/*
POST: Upload multiple files upto 3
*/
imageRouter
.
route
(
'
/multiple
'
)
.
post
(
upload
.
array
(
'
file
'
,
3
),
(
req
,
res
,
next
)
=>
{
res
.
status
(
200
).
json
({
success
:
true
,
message
:
`
${
req
.
files
.
length
}
files uploaded successfully`
,
});
});
/*
GET: Fetches all the files in the uploads collection
*/
imageRouter
.
route
(
'
/
'
)
.
get
((
req
,
res
,
next
)
=>
{
gfs
.
find
().
toArray
((
err
,
files
)
=>
{
if
(
!
files
||
files
.
length
===
0
)
{
return
res
.
status
(
200
).
json
({
success
:
false
,
message
:
'
No files available
'
});
}
files
.
map
(
file
=>
{
if
(
file
.
contentType
===
'
image/jpeg
'
||
file
.
contentType
===
'
image/png
'
||
file
.
contentType
===
'
image/svg
'
)
{
file
.
isImage
=
true
;
}
else
{
file
.
isImage
=
false
;
}
});
res
.
status
(
200
).
json
({
success
:
true
,
files
,
});
});
});
/*
GET: Fetches a particular file by filename
*/
imageRouter
.
route
(
'
/file/:filename
'
)
.
get
((
req
,
res
,
next
)
=>
{
gfs
.
find
({
filename
:
req
.
params
.
filename
}).
toArray
((
err
,
files
)
=>
{
if
(
!
files
[
0
]
||
files
.
length
===
0
)
{
return
res
.
status
(
200
).
json
({
success
:
false
,
message
:
'
No files available
'
,
});
}
res
.
status
(
200
).
json
({
success
:
true
,
file
:
files
[
0
],
});
});
});
/*
GET: Fetches a particular image and render on browser
*/
imageRouter
.
route
(
'
/image/:filename
'
)
.
get
((
req
,
res
,
next
)
=>
{
gfs
.
find
({
filename
:
req
.
params
.
filename
}).
toArray
((
err
,
files
)
=>
{
if
(
!
files
[
0
]
||
files
.
length
===
0
)
{
return
res
.
status
(
200
).
json
({
success
:
false
,
message
:
'
No files available
'
,
});
}
if
(
files
[
0
].
contentType
===
'
image/jpeg
'
||
files
[
0
].
contentType
===
'
image/png
'
||
files
[
0
].
contentType
===
'
image/svg+xml
'
)
{
// render image to browser
gfs
.
openDownloadStreamByName
(
req
.
params
.
filename
).
pipe
(
res
);
}
else
{
res
.
status
(
404
).
json
({
err
:
'
Not an image
'
,
});
}
});
});
/*
GET: Fetches a particular PDF and render on browser
*/
imageRouter
.
route
(
'
/pdf/:filename
'
)
.
get
((
req
,
res
,
next
)
=>
{
gfs
.
find
({
filename
:
req
.
params
.
filename
}).
toArray
((
err
,
files
)
=>
{
if
(
!
files
[
0
]
||
files
.
length
===
0
)
{
return
res
.
status
(
200
).
json
({
success
:
false
,
message
:
'
No files available
'
,
});
}
if
(
files
[
0
].
contentType
===
'
application/pdf
'
||
files
[
0
].
contentType
===
'
application/vnd.ms-powerpoint
'
||
files
[
0
].
contentType
===
'
application/vnd.openxmlformats-officedocument.presentationml.presentation
'
)
{
// render PDF to browser
gfs
.
openDownloadStreamByName
(
req
.
params
.
filename
).
pipe
(
res
);
}
else
{
res
.
status
(
404
).
json
({
err
:
'
Not a PDF
'
,
});
}
});
});
/*
DELETE: Delete a particular file by an ID
*/
imageRouter
.
route
(
'
/file/del/:id
'
)
.
post
((
req
,
res
,
next
)
=>
{
console
.
log
(
req
.
params
.
id
);
gfs
.
delete
(
new
mongoose
.
Types
.
ObjectId
(
req
.
params
.
id
),
(
err
,
data
)
=>
{
if
(
err
)
{
return
res
.
status
(
404
).
json
({
err
:
err
});
}
res
.
status
(
200
).
json
({
success
:
true
,
message
:
`File with ID
${
req
.
params
.
id
}
is deleted`
,
});
});
});
return
imageRouter
;
};
\ No newline at end of file
BackEnd/WebBackEnd/routes/question.route.js
View file @
c7af3456
...
...
@@ -32,43 +32,20 @@ questionRouter.route('/questionId/:id').get(function (req, res) {
questionRouter
.
route
(
'
/add
'
).
post
(
function
(
req
,
res
)
{
const
question
=
new
Question
({
question_id
:
new
mongoose
.
Types
.
ObjectId
(),
category
:
req
.
body
.
category
,
name
:
req
.
body
.
name
,
lesson_no
:
req
.
body
.
lesson_no
,
lesson_name
:
req
.
body
.
lesson_
name
,
question_text
:
req
.
body
.
question_text
,
question_answer
:
req
.
body
.
question_answer
,
defult_mark
:
req
.
body
.
defult_mark
,
q_type
:
req
.
body
.
q_type
,
time_createdby
:
req
.
body
.
time_createdby
,
time_modifiedby
:
req
.
body
.
time_modifiedby
,
general_feedback
:
req
.
body
.
general_feedback
});
question
.
save
()
.
then
(
result
=>
{
res
.
json
(
result
);
console
.
log
(
result
);
res
.
status
(
201
).
json
({
message
:
"
Created product successfully
"
,
createdProduct
:
{
category
:
result
.
category
,
name
:
result
.
name
,
question_text
:
result
.
question_text
,
defult_mark
:
result
.
defult_mark
,
q_type
:
result
.
q_type
,
time_createdby
:
req
.
body
.
time_createdby
,
time_modifiedby
:
req
.
body
.
time_modifiedby
,
general_feedback
:
req
.
body
.
general_feedback
,
question_id
:
result
.
question_id
,
request
:
{
type
:
'
GET
'
,
url
:
"
http://localhost:5000/questions/
"
+
result
.
_id
}
}
});
})
.
catch
(
err
=>
{
console
.
log
(
err
);
res
.
status
(
500
).
json
({
error
:
err
});
question
.
save
().
then
(
question
=>
{
res
.
json
(
'
Item update!
'
);
})
.
catch
(
err
=>
{
res
.
status
(
400
).
send
(
"
Update not possible
"
);
});
});
...
...
@@ -77,8 +54,8 @@ questionRouter.route('/update/:id').post((req, res) => {
if
(
!
question
)
req
.
status
(
404
).
send
(
"
data is not found
"
);
else
{
question
.
category
=
req
.
body
.
category
;
question
.
name
=
req
.
body
.
name
;
question
.
lesson_no
=
req
.
body
.
lesson_no
;
question
.
lesson_name
=
req
.
body
.
lesson_
name
;
question
.
question_text
=
req
.
body
.
question_text
;
question
.
question_answer
=
req
.
body
.
question_answer
;
question
.
defult_mark
=
req
.
body
.
defult_mark
;
...
...
@@ -96,7 +73,14 @@ questionRouter.route('/update/:id').post((req, res) => {
});
});
questionRouter
.
route
(
'
/lessonNo/:id
'
).
get
(
function
(
req
,
res
)
{
console
.
log
(
"
Product Item ID
"
);
console
.
log
(
req
.
params
.
id
);
let
id
=
req
.
params
.
id
;
Question
.
find
({
"
lesson_no
"
:
id
},
function
(
err
,
product
)
{
res
.
json
(
product
);
});
});
questionRouter
.
route
(
'
/delete/:id
'
).
delete
((
req
,
res
)
=>
{
Question
.
findByIdAndDelete
(
req
.
params
.
id
)
...
...
BackEnd/WebBackEnd/server.js
View file @
c7af3456
const
createError
=
require
(
'
http-errors
'
);
const
express
=
require
(
'
express
'
);
const
path
=
require
(
'
path
'
);
const
cookieParser
=
require
(
'
cookie-parser
'
);
const
logger
=
require
(
'
morgan
'
);
const
methodOverride
=
require
(
'
method-override
'
);
const
config
=
require
(
'
./config
'
);
const
multer
=
require
(
'
multer
'
);
const
{
GridFsStorage
}
=
require
(
'
multer-gridfs-storage
'
);
const
crypto
=
require
(
'
crypto
'
);
const
cors
=
require
(
'
cors
'
);
const
bodyParser
=
require
(
'
body-parser
'
);
const
mongoose
=
require
(
'
mongoose
'
);
...
...
@@ -6,22 +15,65 @@ require('dotenv').config();
const
app
=
express
();
const
port
=
process
.
env
.
PORT
||
5000
;
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
app
.
use
(
cors
());
// view engine setup
app
.
set
(
'
views
'
,
path
.
join
(
__dirname
,
'
views
'
));
app
.
set
(
'
view engine
'
,
'
jade
'
);
app
.
use
(
cors
({
origin
:
'
*
'
,
}));
app
.
use
(
logger
(
'
dev
'
));
app
.
use
(
express
.
json
());
app
.
use
(
express
.
urlencoded
({
extended
:
false
}));
app
.
use
(
cookieParser
());
app
.
use
(
methodOverride
(
'
_method
'
));
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
'
public
'
)));
mongoose
.
Promise
=
require
(
'
bluebird
'
);
const
ur
i
=
process
.
env
.
ATLAS_
URI
;
mongoose
.
connect
(
uri
,{
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
,
useCreateIndex
:
true
,
useFindAndModify
:
false
});
const
ur
l
=
config
.
mongo
URI
;
const
connect
=
mongoose
.
connect
(
url
,
{
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
,
useCreateIndex
:
true
,
useFindAndModify
:
false
});
const
connection
=
mongoose
.
connection
;
connection
.
once
(
'
open
'
,()
=>
{
console
.
log
(
"
MongoDB database connection established successfully
"
);
}).
catch
(
err
=>
{
console
.
error
(
'
App starting error:
'
,
err
.
stack
);
process
.
exit
(
1
);
connect
.
then
(()
=>
{
console
.
log
(
'
Connected to database: GridApp
'
);
},
(
err
)
=>
console
.
log
(
err
));
// create storage engine
const
storage
=
new
GridFsStorage
({
url
:
config
.
mongoURI
,
file
:
(
req
,
file
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
crypto
.
randomBytes
(
16
,
(
err
,
buf
)
=>
{
if
(
err
)
{
return
reject
(
err
);
}
const
filename
=
buf
.
toString
(
'
hex
'
)
+
path
.
extname
(
file
.
originalname
);
const
fileInfo
=
{
filename
:
filename
,
bucketName
:
'
uploads
'
};
resolve
(
fileInfo
);
});
});
}
});
const
upload
=
multer
({
storage
});
// const connection = mongoose.connection;
// connection.once('open',() => {
// console.log("MongoDB database connection established successfully");
// }).catch(err => {
// console.error('App starting error:', err.stack);
// process.exit(1);
// });
const
studentRouter
=
require
(
'
./routes/student.route
'
);
const
tutorRouter
=
require
(
'
./routes/tutor.route
'
);
const
instituteRouter
=
require
(
'
./routes/institute.route
'
);
...
...
@@ -29,6 +81,7 @@ const userAccount = require('./routes/userAccount.route');
const
questionManage
=
require
(
'
./routes/question.route
'
);
const
financeRouter
=
require
(
'
./routes/finance.route
'
);
const
studentResult
=
require
(
'
./routes/studentALResult.route
'
);
const
imageRouter
=
require
(
'
./routes/pdf.route
'
);
app
.
use
(
'
/studentSingUp
'
,
studentRouter
);
app
.
use
(
'
/tutorSingUp
'
,
tutorRouter
);
...
...
@@ -37,7 +90,8 @@ app.use('/userAccount',userAccount);
app
.
use
(
'
/questions
'
,
questionManage
);
app
.
use
(
'
/admin/finance
'
,
financeRouter
);
app
.
use
(
'
/studentResults
'
,
studentResult
);
app
.
use
(
'
/
'
,
imageRouter
(
upload
));
app
.
listen
(
port
,
()
=>
{
console
.
log
(
`Server is running on Port:
${
port
}
`
);
});
\ No newline at end of file
});
WebFrontEnd/smartcoach-frontend/public/index.html
View file @
c7af3456
...
...
@@ -11,7 +11,9 @@
<link
rel=
"stylesheet"
href=
"DashboardAssets/css/dashboard.css"
>
<link
rel=
"stylesheet"
href=
"DashboardAssets/css/custom.css"
>
<!-- fa fa icons cdn -->
<link
rel=
"stylesheet"
href=
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
>
<link
rel=
"stylesheet"
href=
"https://use.fontawesome.com/releases/v5.0.7/css/all.css"
>
</head>
<body>
...
...
WebFrontEnd/smartcoach-frontend/src/App.js
View file @
c7af3456
...
...
@@ -14,8 +14,9 @@ import Dashboard from "./Components/Admin/Dashboard";
import
StudentDashboard
from
"
./Components/Student/StudentDashboard
"
;
import
QuestionDetails
from
"
./Components/IT18050240/question_details
"
import
QuestionLayout
from
"
./Components/IT18050240/question_layout
"
//
import AdminQuestionManagement from "./Components/IT18050240/admin_question_management.js"
import
AdminQuestionManagement
from
"
./Components/IT18050240/admin_question_management.js
"
import
QuestionBank
from
"
./Components/IT18050240/question_bank
"
import
LessonAndExam
from
"
./Components/IT18050240/lessonandexampage
"
;
function
App
()
{
return
(
...
...
@@ -35,10 +36,11 @@ function App() {
<
Route
path
=
"
/admin
"
><
Dashboard
/><
/Route
>
<
Route
path
=
"
/studentDashboard
"
><
StudentDashboard
/><
/Route
>
<
Route
path
=
"
/questiondetails
"
exact
component
=
{
QuestionDetails
}
/
>
<
Route
path
=
"
/question
"
exact
component
=
{
QuestionLayout
}
/
>
{
/*<Route path="/questionmanagement" exact component={AdminQuestionManagement}/>*/
}
<
Route
path
=
"
/question
/:id
"
exact
component
=
{
QuestionLayout
}
/
>
<
Route
path
=
"
/questionmanagement/:id
"
exact
component
=
{
AdminQuestionManagement
}
/
>
<
Route
path
=
"
/questionbank
"
exact
component
=
{
QuestionBank
}
/
>
{
/*<Route path="/edititem/:id" exact component={AdminQuestionManagement}/>*/
}
<
Route
path
=
"
/questionmanagement
"
exact
component
=
{
AdminQuestionManagement
}
/
>
<
Route
path
=
"
/lesson
"
exact
component
=
{
LessonAndExam
}
/
>
<
/Switch
>
...
...
WebFrontEnd/smartcoach-frontend/src/Components/IT18050240/admin_question_management.js.js
View file @
c7af3456
This diff is collapsed.
Click to expand it.
WebFrontEnd/smartcoach-frontend/src/Components/IT18050240/lessonandexampage.js
0 → 100644
View file @
c7af3456
import
React
,
{
Component
}
from
'
react
'
;
import
axios
from
'
axios
'
;
import
{
Link
}
from
"
react-router-dom
"
;
import
EX
from
'
../../Images/exam.png
'
;
import
LS
from
'
../../Images/lesson.png
'
;
export
default
class
LessonAndExam
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
lessonList
:[]
}
}
componentDidMount
=
()
=>
{
let
quizLessonTemp
=
[]
axios
.
get
(
'
http://localhost:5000/
'
)
.
then
(
response
=>
{
this
.
setState
({
lessonList
:
response
.
data
.
images
});
console
.
log
(
this
.
state
.
lessonList
.
length
)
})
.
catch
(
err
=>
alert
(
err
));
}
render
(){
return
(
<
div
className
=
"
container
"
>
<
div
className
=
"
p-3 mb-2 bg-light text-dark text-left
"
>
Accounting
Lecture
<
/div
>
<
div
className
=
"
text-left ml-3
"
>
<
p
>
First
lab
session
will
be
started
from
10
/
02
/
2021
at
4.00
pm
<
/p
>
<
/div
>
{
this
.
state
.
lessonList
.
map
((
file
)
=>
(
<
div
className
=
""
>
<
div
className
=
"
p-3 mb-2 bg-light text-dark text-left
"
>
Accounting
Lecture
{
file
.
lessonno
}
<
/div
>
<
div
className
=
"
text-left ml-3
"
>
<
p
>
First
lab
session
will
be
started
from
10
/
02
/
2021
at
4.00
pm
<
/p
>
<
/div
>
<
div
className
=
"
row
"
>
<
div
className
=
"
col-1
"
>
<
div
style
=
{{
padding
:
'
0px
'
}}
>
<
img
src
=
{
EX
}
alt
=
"
upload-image
"
style
=
{{
width
:
'
35px
'
}}
/
>
<
hr
/>
<
img
src
=
{
LS
}
alt
=
"
upload-image
"
style
=
{{
width
:
'
35px
'
}}
/
>
<
/div
>
<
/div
>
<
div
style
=
{{
padding
:
'
0px
'
}}
>
<
a
href
=
{
'
http://localhost:5000/pdf/
'
+
file
.
filename
}
><
p
style
=
{{
marginTop
:
'
7px
'
}}
>
{
file
.
lessonname
}
<
/p></
a
>
<
br
/>
<
a
href
=
{
'
/question/
'
+
file
.
lessonno
}
><
p
style
=
{{
marginTop
:
'
7px
'
}}
>
Exam
{
file
.
lessonno
}
<
/p></
a
>
<
/div
>
<
/div
>
<
/div
>
))
}
<
/div
>
)
}
}
\ No newline at end of file
WebFrontEnd/smartcoach-frontend/src/Components/IT18050240/question_bank.js
View file @
c7af3456
...
...
@@ -6,13 +6,12 @@ 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
>
{
props
.
questions
.
lesson_name
}
<
/td
>
<
td
>
{
props
.
questions
.
question_text
}
<
/td
>
<
td
>
{
props
.
questions
.
question_answer
}
<
/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
>
<
Link
className
=
"
text-success fas fa-edit
"
to
=
{
"
/questionmanagement/
"
+
props
.
questions
.
_id
}
><
/Link> <span className=" mx-1 text-danger fas fa-trash" href='#' onClick={
()
=>{props.deleteProduct
(
props.questions
._id
)
}} ></
span
>
<
/div
>
<
/td
>
<
/tr
>
...
...
@@ -29,13 +28,13 @@ export default class QuestionBankUI extends Component {
this
.
state
=
{
q_type
:
''
,
qu
antity
:
[]
qu
estions
:
[]
}
}
quantityList
()
{
return
this
.
state
.
qu
antity
.
map
(
currentTodo
=>
{
return
<
Quantity
qu
antity
=
{
currentTodo
}
deleteProduct
=
{
this
.
deleteProduct
}
key
=
{
currentTodo
.
_id
}
/
>
return
this
.
state
.
qu
estions
.
map
(
currentTodo
=>
{
return
<
Quantity
qu
estions
=
{
currentTodo
}
deleteProduct
=
{
this
.
deleteProduct
}
key
=
{
currentTodo
.
_id
}
/
>
});
}
...
...
@@ -43,7 +42,7 @@ export default class QuestionBankUI extends Component {
axios
.
get
(
'
http://localhost:5000/questions/
'
)
.
then
(
response
=>
{
this
.
setState
({
qu
antity
:
response
.
data
});
this
.
setState
({
qu
estions
:
response
.
data
});
})
.
catch
(
function
(
error
)
{
console
.
log
(
error
);
...
...
@@ -56,7 +55,7 @@ export default class QuestionBankUI extends Component {
axios
.
get
(
'
http://localhost:5000/questions/
'
)
.
then
(
response
=>
{
this
.
setState
({
qu
antity
:
response
.
data
});
this
.
setState
({
qu
estions
:
response
.
data
});
})
.
catch
(
function
(
error
)
{
console
.
log
(
error
);
...
...
@@ -88,7 +87,7 @@ export default class QuestionBankUI extends Component {
axios
.
delete
(
'
http://localhost:5000/questions/delete/
'
+
pid
)
.
then
(
res
=>
console
.
log
(
res
.
data
));
this
.
setState
({
qu
antity
:
this
.
state
.
quantity
.
filter
(
el
=>
el
.
pid
!==
pid
)
qu
estions
:
this
.
state
.
questions
.
filter
(
el
=>
el
.
pid
!==
pid
)
});
}
...
...
@@ -144,9 +143,9 @@ export default class QuestionBankUI extends Component {
<
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
><
h6
>
Lesson
<
/h6></
th
>
<
th
><
h6
>
Question
<
/h6></
th
>
<
th
><
h6
>
Answer
<
/h6></
th
>
<
th
className
=
"
col-sm-1
"
><
h6
>
Action
<
/h6></
th
>
<
/tr
>
<
/thead
>
...
...
WebFrontEnd/smartcoach-frontend/src/Components/IT18050240/question_layout.js
View file @
c7af3456
...
...
@@ -99,7 +99,7 @@ export default class QuestionLayout extends Component {
// if (this.state.item_id != null) {
axios
.
get
(
'
http://localhost:5000/questions/
'
)
axios
.
get
(
'
http://localhost:5000/questions/
lessonNo/1
'
)
.
then
(
response
=>
{
//this.setState({productQuantities: response.data});
let
CategoryList
=
[];
...
...
WebFrontEnd/smartcoach-frontend/src/Images/exam.png
0 → 100644
View file @
c7af3456
18.9 KB
WebFrontEnd/smartcoach-frontend/src/Images/lesson.png
0 → 100644
View file @
c7af3456
14.3 KB
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