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
078418bb
Commit
078418bb
authored
Sep 21, 2021
by
Hasitha Samarasekara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Filter add for rating and reviews. both backend and frontend done for above filters.
parent
6e5c87ee
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
965 additions
and
310 deletions
+965
-310
BackEnd/WebBackEnd/models/TutorRatingAndReviews.model.js
BackEnd/WebBackEnd/models/TutorRatingAndReviews.model.js
+2
-2
BackEnd/WebBackEnd/models/createClass.model.js
BackEnd/WebBackEnd/models/createClass.model.js
+28
-0
BackEnd/WebBackEnd/package-lock.json
BackEnd/WebBackEnd/package-lock.json
+13
-0
BackEnd/WebBackEnd/package.json
BackEnd/WebBackEnd/package.json
+1
-0
BackEnd/WebBackEnd/routes/createClass.route.js
BackEnd/WebBackEnd/routes/createClass.route.js
+80
-0
BackEnd/WebBackEnd/routes/filteredList.route.js
BackEnd/WebBackEnd/routes/filteredList.route.js
+123
-132
BackEnd/WebBackEnd/routes/filteredListNew.route.js
BackEnd/WebBackEnd/routes/filteredListNew.route.js
+163
-0
BackEnd/WebBackEnd/routes/tutor.route.js
BackEnd/WebBackEnd/routes/tutor.route.js
+2
-2
BackEnd/WebBackEnd/server.js
BackEnd/WebBackEnd/server.js
+3
-1
WebFrontEnd/smartcoach-frontend/package-lock.json
WebFrontEnd/smartcoach-frontend/package-lock.json
+8
-0
WebFrontEnd/smartcoach-frontend/package.json
WebFrontEnd/smartcoach-frontend/package.json
+1
-0
WebFrontEnd/smartcoach-frontend/src/Components/Admin/Dashboard.js
...End/smartcoach-frontend/src/Components/Admin/Dashboard.js
+1
-1
WebFrontEnd/smartcoach-frontend/src/Components/Admin/add_class_details.js
...tcoach-frontend/src/Components/Admin/add_class_details.js
+258
-56
WebFrontEnd/smartcoach-frontend/src/Components/Home.js
WebFrontEnd/smartcoach-frontend/src/Components/Home.js
+281
-115
WebFrontEnd/smartcoach-frontend/src/Components/HomePage/TutorCard.js
.../smartcoach-frontend/src/Components/HomePage/TutorCard.js
+1
-1
No files found.
BackEnd/WebBackEnd/models/TutorRatingAndReviews.model.js
View file @
078418bb
...
...
@@ -3,8 +3,8 @@ const mongoose = require('mongoose');
const
Schema
=
mongoose
.
Schema
;
const
TutorRatingSchema
=
new
Schema
({
tutor_id
:{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
ref
:
'
Post
'
},
student_id
:{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
ref
:
'
Pos
t
'
},
tutor_id
:{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
ref
:
'
tutor
'
},
student_id
:{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
ref
:
'
studen
t
'
},
rating
:
{
type
:
String
},
review
:{
type
:
String
},
version
:{
type
:
String
},
...
...
BackEnd/WebBackEnd/models/createClass.model.js
View file @
078418bb
const
mongoose
=
require
(
'
mongoose
'
);
const
Schema
=
mongoose
.
Schema
;
const
CreateClassSchema
=
new
Schema
({
tutor_id
:{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
ref
:
'
tutor
'
},
class_method
:{
type
:
String
},
class_type
:
{
type
:
String
},
institute_id
:{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
ref
:
'
institute
'
},
batch_no
:
{
type
:
String
},
class_startingDate
:{
type
:
Date
},
subject
:{
type
:
String
},
class_fee
:{
type
:
String
},
student_list
:[{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
ref
:
'
student
'
}],
isActiveClass
:
{
type
:
Boolean
,
default
:
true
},
isActiveForStudent
:
{
type
:
Boolean
,
default
:
true
}
});
const
Classes
=
mongoose
.
model
(
'
Classes
'
,
CreateClassSchema
);
module
.
exports
=
Classes
;
\ No newline at end of file
BackEnd/WebBackEnd/package-lock.json
View file @
078418bb
...
...
@@ -85,6 +85,14 @@
"integrity"
:
"sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA=="
,
"dev"
:
true
},
"axios"
:
{
"version"
:
"0.21.4"
,
"resolved"
:
"https://registry.npmjs.org/axios/-/axios-0.21.4.tgz"
,
"integrity"
:
"sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg=="
,
"requires"
:
{
"follow-redirects"
:
"^1.14.0"
}
},
"bcrypt-pbkdf"
:
{
"version"
:
"1.0.2"
,
"resolved"
:
"https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz"
,
...
...
@@ -335,6 +343,11 @@
"unpipe"
:
"~1.0.0"
}
},
"follow-redirects"
:
{
"version"
:
"1.14.4"
,
"resolved"
:
"https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.4.tgz"
,
"integrity"
:
"sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g=="
},
"forever-agent"
:
{
"version"
:
"0.6.1"
,
"resolved"
:
"https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz"
,
...
...
BackEnd/WebBackEnd/package.json
View file @
078418bb
...
...
@@ -10,6 +10,7 @@
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"axios"
:
"^0.21.4"
,
"cors"
:
"^2.8.5"
,
"dotenv"
:
"^10.0.0"
,
"express"
:
"^4.17.1"
,
...
...
BackEnd/WebBackEnd/routes/createClass.route.js
0 → 100644
View file @
078418bb
const
router
=
require
(
'
express
'
).
Router
();
let
classes
=
require
(
'
../models/createClass.model
'
);
const
mongoose
=
require
(
"
mongoose
"
);
router
.
route
(
'
/add
'
).
post
(
async
(
req
,
res
)
=>
{
console
.
log
(
"
Inside Create Class
"
)
console
.
log
(
res
.
body
)
if
(
req
.
body
.
institute_id
!==
""
){
const
tutor_id
=
mongoose
.
Types
.
ObjectId
(
req
.
body
.
tutor_id
);
const
class_method
=
req
.
body
.
class_method
;
const
class_type
=
req
.
body
.
class_type
;
const
institute_id
=
mongoose
.
Types
.
ObjectId
(
req
.
body
.
institute_id
);
const
batch_no
=
req
.
body
.
batch_no
;
const
class_startingDate
=
req
.
body
.
class_startingDate
;
const
subject
=
req
.
body
.
subject
;
const
class_fee
=
req
.
body
.
class_fee
;
const
isActiveClass
=
req
.
body
.
isActiveClass
;
const
isActiveForStudent
=
req
.
body
.
isActiveForStudent
;
const
newClass
=
new
classes
({
tutor_id
,
class_method
,
class_type
,
batch_no
,
class_startingDate
,
subject
,
class_fee
,
isActiveClass
,
isActiveForStudent
,
institute_id
});
console
.
log
(
newClass
)
newClass
.
save
().
then
(()
=>
{
res
.
json
(
'
Class Created!
'
);
}).
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error:
'
+
err
));
}
else
{
const
tutor_id
=
mongoose
.
Types
.
ObjectId
(
req
.
body
.
tutor_id
);
const
class_method
=
req
.
body
.
class_method
;
const
class_type
=
req
.
body
.
class_type
;
const
batch_no
=
req
.
body
.
batch_no
;
const
class_startingDate
=
req
.
body
.
class_startingDate
;
const
subject
=
req
.
body
.
subject
;
const
class_fee
=
req
.
body
.
class_fee
;
const
isActiveClass
=
req
.
body
.
isActiveClass
;
const
isActiveForStudent
=
req
.
body
.
isActiveForStudent
;
const
newClass
=
new
classes
({
tutor_id
,
class_method
,
class_type
,
batch_no
,
class_startingDate
,
subject
,
class_fee
,
isActiveClass
,
isActiveForStudent
,
});
console
.
log
(
newClass
)
newClass
.
save
().
then
(()
=>
{
res
.
json
(
'
Class Created!
'
);
}).
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error:
'
+
err
));
}
});
module
.
exports
=
router
;
\ No newline at end of file
BackEnd/WebBackEnd/routes/filteredList.route.js
View file @
078418bb
...
...
@@ -9,7 +9,7 @@ const request = require('request');
router
.
route
(
'
/getFilteredList
'
).
post
((
req
,
res
)
=>
{
let
tutorReviewResults
=
[];
tutor
.
find
({
...
...
@@ -21,138 +21,129 @@ router.route('/getFilteredList').post((req,res) =>{
"
tutor_class_type
"
:
{
'
$regex
'
:
req
.
body
.
selectedClassType
,
'
$options
'
:
'
i
'
},
})
.
then
(
async
tutors
=>
{
// async function getTutorData(tutor) {
// for (let i = 0; i < tutor.length; i++) {
// // var docregistrationnumber = arr[i].docregistrationnumber
// // var registrationAuthority = arr[i].docregistrationauthority
// // var data = await doctorData.getDoctorByRegNumber(docregistrationnumber, registrationAuthority);
// tutorRating.find(()=>{
// tutor_id : tutor._id
// })
// .then(reviews => {
// let reviewsList = [];
//
// reviewsList = await Get
// for (const oneReview of reviews){
// reviewsList.push(oneReview.review);
// //console.log("oneReview review");
// //console.log(oneReview.review);
// }
// console.log("Reviews : " + reviewsList)
//
//
// let options = {
// uri: 'http://localhost:5000/review_prediction_for_tutor',
// body: JSON.stringify(reviewsList),
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json'
// }
// }
// request(options, function (error, response) {
// // console.log(error, response.body);
// //tutor.tutor_main_district = "Test";
// //tutorReviewResults.tutor_reviewValue = response.body;
// let payload = {
// "tutor_id" : tutor._id,
// "tutor_name" : tutor.tutor_name,
// "tutor_nic" : tutor.tutor_nic,
// "tutor_email" : tutor.tutor_email,
// "tutor_phone" : tutor.tutor_phone,
// "tutor_address" : tutor.tutor_address,
// "tutor_password" : tutor.tutor_password,
// "tutor_gender" : tutor.tutor_gender,
// "tutor_status" : tutor.tutor_status,
// "tutor_image" : tutor.tutor_image,
// "tutor_Stream" : tutor.tutor_Stream,
// "tutor_subjects" : tutor.tutor_subjects,
// "tutor_class_type" : tutor.tutor_class_type,
// "tutor_main_district" : tutor.tutor_main_district,
// "tutor_main_city" : tutor.tutor_main_city,
// "tutor_medium" : tutor.tutor_medium,
// "tutor_qualification" : tutor.tutor_qualification,
// "tutor_reviewValue" : JSON.parse(response.body).result,
//
// };
// tutorReviewResults.push(payload);
// console.log(tutorReviewResults.length)
// });
// reviewsList = [];
// })
//
// arra.push(data);
// }
//
// return arra;
// }
let
reviewFinalResults
=
[]
for
(
let
tutor
of
tutors
){
tutorRating
.
find
(()
=>
{
tutor_id
:
tutor
.
_id
})
.
then
(
reviews
=>
{
let
reviewsList
=
[];
for
(
const
oneReview
of
reviews
){
reviewsList
.
push
(
oneReview
.
review
);
//console.log("oneReview review");
//console.log(oneReview.review);
}
console
.
log
(
"
Reviews :
"
+
reviewsList
)
let
options
=
{
uri
:
'
http://localhost:5000/review_prediction_for_tutor
'
,
body
:
JSON
.
stringify
(
reviewsList
),
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
}
}
request
(
options
,
function
(
error
,
response
)
{
// console.log(error, response.body);
//tutor.tutor_main_district = "Test";
//tutorReviewResults.tutor_reviewValue = response.body;
let
payload
=
{
"
tutor_id
"
:
tutor
.
_id
,
"
tutor_name
"
:
tutor
.
tutor_name
,
"
tutor_nic
"
:
tutor
.
tutor_nic
,
"
tutor_email
"
:
tutor
.
tutor_email
,
"
tutor_phone
"
:
tutor
.
tutor_phone
,
"
tutor_address
"
:
tutor
.
tutor_address
,
"
tutor_password
"
:
tutor
.
tutor_password
,
"
tutor_gender
"
:
tutor
.
tutor_gender
,
"
tutor_status
"
:
tutor
.
tutor_status
,
"
tutor_image
"
:
tutor
.
tutor_image
,
"
tutor_Stream
"
:
tutor
.
tutor_Stream
,
"
tutor_subjects
"
:
tutor
.
tutor_subjects
,
"
tutor_class_type
"
:
tutor
.
tutor_class_type
,
"
tutor_main_district
"
:
tutor
.
tutor_main_district
,
"
tutor_main_city
"
:
tutor
.
tutor_main_city
,
"
tutor_medium
"
:
tutor
.
tutor_medium
,
"
tutor_qualification
"
:
tutor
.
tutor_qualification
,
"
tutor_reviewValue
"
:
JSON
.
parse
(
response
.
body
).
result
,
};
tutorReviewResults
.
push
(
payload
);
console
.
log
(
tutorReviewResults
.
length
)
});
reviewsList
=
[];
})
// console.log(reviewFinalResults)
}
.
then
(
async
tutors
=>
{
let
tutorReviewResultsFinal
let
tutorReviewResults
=
[];
async
function
processData
(
callback
)
{
async
function
forLoopRun
(
callback6
)
{
let
payload
let
options
const
promises
=
tutors
.
map
(
async
(
tutor
)
=>
{
await
tutorRating
.
find
({
"
tutor_id
"
:
tutor
.
_id
}).
populate
(
'
tutor_id
'
).
then
(
async
reviews01
=>
{
//console.log("Review Count " + reviews01.length);
if
(
reviews01
.
length
>
0
)
{
let
reviewsList01
=
[];
const
reviewPromises
=
reviews01
.
map
(
async
function
(
oneReview
)
{
reviewsList01
.
push
(
oneReview
.
review
);
return
oneReview
.
review
})
const
reviewsForTutor
=
await
Promise
.
all
(
reviewPromises
);
await
console
.
log
(
reviewsForTutor
);
async
function
getPrevMatches
(
cb
)
{
options
=
{
uri
:
'
http://localhost:5000/review_prediction_for_tutor
'
,
body
:
JSON
.
stringify
(
reviewsList01
),
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
}
}
request
(
options
,
async
function
(
error
,
response
)
{
// console.log(error, response.body);
//tutor.tutor_main_district = "Test";
//tutorReviewResults.tutor_reviewValue = response.body;
payload
=
{
"
tutor_id
"
:
tutor
.
_id
,
"
tutor_name
"
:
tutor
.
tutor_name
,
"
tutor_nic
"
:
tutor
.
tutor_nic
,
"
tutor_email
"
:
tutor
.
tutor_email
,
"
tutor_phone
"
:
tutor
.
tutor_phone
,
"
tutor_address
"
:
tutor
.
tutor_address
,
"
tutor_password
"
:
tutor
.
tutor_password
,
"
tutor_gender
"
:
tutor
.
tutor_gender
,
"
tutor_status
"
:
tutor
.
tutor_status
,
"
tutor_image
"
:
tutor
.
tutor_image
,
"
tutor_Stream
"
:
tutor
.
tutor_Stream
,
"
tutor_subjects
"
:
tutor
.
tutor_subjects
,
"
tutor_class_type
"
:
tutor
.
tutor_class_type
,
"
tutor_main_district
"
:
tutor
.
tutor_main_district
,
"
tutor_main_city
"
:
tutor
.
tutor_main_city
,
"
tutor_medium
"
:
tutor
.
tutor_medium
,
"
tutor_qualification
"
:
tutor
.
tutor_qualification
,
"
tutor_reviewValue
"
:
JSON
.
parse
(
response
.
body
).
result
,
};
await
tutorReviewResults
.
push
(
payload
);
//console.log(payload)
if
(
response
.
statusCode
===
200
){
cb
(
payload
);
}
});
}
await
getPrevMatches
(
function
(
message777
)
{
console
.
log
(
message777
);
// callback("Done : ProcessData");
});
// module.exports = {
// getPrevMatches: getPrevMatches
// }
//console.log(getPrevMatches);
}
})
return
payload
;
})
tutorReviewResultsFinal
=
await
Promise
.
all
(
promises
);
callback6
(
"
Get Return :
"
+
tutorReviewResultsFinal
);
}
await
forLoopRun
(
async
function
(
message2
)
{
console
.
log
(
message2
);
callback
(
"
Done : ProcessData
"
);
});
}
console
.
log
(
"
Last
"
+
tutorReviewResults
.
length
)
//res.json(tutorReviewResults)
}).
then
(()
=>
{
console
.
log
(
"
Then
"
+
tutorReviewResults
.
length
)
res
.
json
(
tutorReviewResults
)
})
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Eroor:
'
+
err
));
await
processData
(
async
function
(
message
)
{
console
.
log
(
message
);
//console.log("Inside return Fuction");
}).
then
(
async
r
=>
{
console
.
log
(
"
Inside return Function
"
);
//await res.json(tutorReviewResults)
})
;
console
.
log
(
"
End
"
+
tutorReviewResults
.
length
)
res
.
json
(
tutorReviewResults
)
})
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error:
'
+
err
));
});
module
.
exports
=
router
;
BackEnd/WebBackEnd/routes/filteredListNew.route.js
0 → 100644
View file @
078418bb
const
router
=
require
(
'
express
'
).
Router
();
let
tutor
=
require
(
'
../models/tutor.user.model
'
);
let
tutorRating
=
require
(
'
../models/TutorRatingAndReviews.model
'
);
const
axios
=
require
(
'
axios
'
);
const
request
=
require
(
'
request
'
);
router
.
route
(
'
/getFilteredList
'
).
post
((
req
,
res
)
=>
{
let
teacherReviewList
=
[];
let
reviewListWithScore
=
[];
tutor
.
find
({
"
tutor_Stream
"
:
{
'
$regex
'
:
req
.
body
.
selectedStream
,
'
$options
'
:
'
i
'
},
"
tutor_subjects
"
:
{
'
$regex
'
:
req
.
body
.
selectedSubject
,
'
$options
'
:
'
i
'
},
"
tutor_main_district
"
:
{
'
$regex
'
:
req
.
body
.
selectedDistrict
,
'
$options
'
:
'
i
'
},
"
tutor_main_city
"
:
{
'
$regex
'
:
req
.
body
.
selectedCity
,
'
$options
'
:
'
i
'
},
"
tutor_medium
"
:
{
'
$regex
'
:
req
.
body
.
selectedLanguage
,
'
$options
'
:
'
i
'
},
"
tutor_class_type
"
:
{
'
$regex
'
:
req
.
body
.
selectedClassType
,
'
$options
'
:
'
i
'
},
})
.
then
(
tutors
=>
{
//console.log(tutors);
tutors
.
reduce
(
async
(
promise
,
tutor
,
idx
)
=>
{
await
promise
;
await
tutorRating
.
find
({
"
tutor_id
"
:
tutor
.
_id
}).
then
((
reviews
)
=>
{
//console.log("i : " + JSON.stringify(reviews));
console
.
log
(
"
idx :
"
+
idx
);
// console.log("tutor : " + tutors);
const
teacherReview
=
{
"
teacher
"
:
tutor
.
_id
,
"
tutor_name
"
:
tutor
.
tutor_name
,
"
tutor_nic
"
:
tutor
.
tutor_nic
,
"
tutor_email
"
:
tutor
.
tutor_email
,
"
tutor_phone
"
:
tutor
.
tutor_phone
,
"
tutor_address
"
:
tutor
.
tutor_address
,
"
tutor_password
"
:
tutor
.
tutor_password
,
"
tutor_gender
"
:
tutor
.
tutor_gender
,
"
tutor_status
"
:
tutor
.
tutor_status
,
"
tutor_image
"
:
tutor
.
tutor_image
,
"
tutor_Stream
"
:
tutor
.
tutor_Stream
,
"
tutor_subjects
"
:
tutor
.
tutor_subjects
,
"
tutor_class_type
"
:
tutor
.
tutor_class_type
,
"
tutor_main_district
"
:
tutor
.
tutor_main_district
,
"
tutor_main_city
"
:
tutor
.
tutor_main_city
,
"
tutor_medium
"
:
tutor
.
tutor_medium
,
"
tutor_qualification
"
:
tutor
.
tutor_qualification
,
"
review
"
:
reviews
.
map
(
review
=>
review
.
review
),
"
ratings
"
:
reviews
.
map
(
review
=>
review
.
rating
)
}
//teacherReviewList.indexOf(teacherReview) === -1 ? teacherReviewList.push(teacherReview) : null;
let
index
=
teacherReviewList
.
findIndex
(
x
=>
x
.
teacher
===
tutor
.
_id
);
if
(
index
===
-
1
)
{
teacherReviewList
.
push
(
teacherReview
);
}
if
(
idx
===
tutors
.
length
-
1
)
{
//console.log(teacherReviewList);
teacherReviewList
.
reduce
(
async
(
promise
,
teacherReview
,
idx
,
teacherReviewList
)
=>
{
await
promise
;
console
.
log
(
"
length
"
+
teacherReview
.
review
.
length
);
if
(
teacherReview
.
review
.
length
>
0
)
{
let
options
=
{
uri
:
'
http://localhost:5000/review_prediction_for_tutor
'
,
body
:
JSON
.
stringify
(
teacherReview
.
review
),
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
}
}
let
response
=
await
axios
.
post
(
options
.
uri
,
options
.
body
);
let
TotalRating
=
0
;
teacherReview
.
ratings
.
map
(
rate
=>
{
TotalRating
=
TotalRating
+
Number
(
rate
)
})
const
temp
=
{
"
teacher
"
:
teacherReview
.
teacher
,
"
tutor_name
"
:
teacherReview
.
tutor_name
,
"
tutor_nic
"
:
teacherReview
.
tutor_nic
,
"
tutor_email
"
:
teacherReview
.
tutor_email
,
"
tutor_phone
"
:
teacherReview
.
tutor_phone
,
"
tutor_address
"
:
teacherReview
.
tutor_address
,
"
tutor_password
"
:
teacherReview
.
tutor_password
,
"
tutor_gender
"
:
teacherReview
.
tutor_gender
,
"
tutor_status
"
:
teacherReview
.
tutor_status
,
"
tutor_image
"
:
teacherReview
.
tutor_image
,
"
tutor_Stream
"
:
teacherReview
.
tutor_Stream
,
"
tutor_subjects
"
:
teacherReview
.
tutor_subjects
,
"
tutor_class_type
"
:
teacherReview
.
tutor_class_type
,
"
tutor_main_district
"
:
teacherReview
.
tutor_main_district
,
"
tutor_main_city
"
:
teacherReview
.
tutor_main_city
,
"
tutor_medium
"
:
teacherReview
.
tutor_medium
,
"
tutor_qualification
"
:
teacherReview
.
tutor_qualification
,
"
tutor_reviewValue
"
:
response
.
data
.
result
,
"
tutor_avg_rating
"
:
Number
(
TotalRating
/
teacherReview
.
ratings
.
length
)
}
let
index
=
await
reviewListWithScore
.
findIndex
(
x
=>
x
.
teacher
===
teacherReview
.
teacher
);
if
(
index
===
-
1
)
{
reviewListWithScore
.
push
(
temp
);
}
console
.
log
(
response
.
data
.
result
);
}
else
{
const
temp
=
{
"
teacher
"
:
teacherReview
.
teacher
,
"
tutor_name
"
:
teacherReview
.
tutor_name
,
"
tutor_nic
"
:
teacherReview
.
tutor_nic
,
"
tutor_email
"
:
teacherReview
.
tutor_email
,
"
tutor_phone
"
:
teacherReview
.
tutor_phone
,
"
tutor_address
"
:
teacherReview
.
tutor_address
,
"
tutor_password
"
:
teacherReview
.
tutor_password
,
"
tutor_gender
"
:
teacherReview
.
tutor_gender
,
"
tutor_status
"
:
teacherReview
.
tutor_status
,
"
tutor_image
"
:
teacherReview
.
tutor_image
,
"
tutor_Stream
"
:
teacherReview
.
tutor_Stream
,
"
tutor_subjects
"
:
teacherReview
.
tutor_subjects
,
"
tutor_class_type
"
:
teacherReview
.
tutor_class_type
,
"
tutor_main_district
"
:
teacherReview
.
tutor_main_district
,
"
tutor_main_city
"
:
teacherReview
.
tutor_main_city
,
"
tutor_medium
"
:
teacherReview
.
tutor_medium
,
"
tutor_qualification
"
:
teacherReview
.
tutor_qualification
,
"
tutor_reviewValue
"
:
0
,
"
tutor_avg_rating
"
:
0
}
//reviewListWithScore.push(temp);
//reviewListWithScore.indexOf(temp) === -1 ? reviewListWithScore.push(temp) : null;
let
index
=
reviewListWithScore
.
findIndex
(
x
=>
x
.
teacher
===
teacherReview
.
teacher
);
if
(
index
===
-
1
)
{
reviewListWithScore
.
push
(
temp
);
}
}
if
(
idx
===
teacherReviewList
.
length
-
1
)
{
res
.
json
(
reviewListWithScore
)
// console.log(reviewListWithScore);
}
},
Promise
.
resolve
())
}
});
},
Promise
.
resolve
())
//console.log("Return from here");
})
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error:
'
+
err
));
});
module
.
exports
=
router
;
\ No newline at end of file
BackEnd/WebBackEnd/routes/tutor.route.js
View file @
078418bb
...
...
@@ -40,9 +40,9 @@ router.route('/').get((req,res) =>{
router
.
route
(
'
/:id
'
).
get
(
function
(
req
,
res
)
{
let
id
=
req
.
params
.
id
;
console
.
log
(
"
TutorId :
"
+
id
)
//
console.log("TutorId : " + id)
tutor
.
findById
(
id
).
populate
([
'
tutor_instituteIDList
'
]).
then
(
tutor
=>
{
console
.
log
(
tutor
);
///
console.log(tutor);
res
.
json
(
tutor
);
}).
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Eroor:
'
+
err
));
});
...
...
BackEnd/WebBackEnd/server.js
View file @
078418bb
...
...
@@ -30,7 +30,8 @@ const questionManage = require('./routes/question.route');
const
financeRouter
=
require
(
'
./routes/finance.route
'
);
const
studentResult
=
require
(
'
./routes/studentALResult.route
'
);
const
tutorRating
=
require
(
'
./routes/tutorRatings.route
'
);
const
filteredList
=
require
(
'
./routes/filteredList.route
'
);
const
filteredList
=
require
(
'
./routes/filteredListNew.route
'
);
const
createClassRoute
=
require
(
'
./routes/createClass.route
'
);
app
.
use
(
'
/studentSingUp
'
,
studentRouter
);
app
.
use
(
'
/tutorSingUp
'
,
tutorRouter
);
...
...
@@ -41,6 +42,7 @@ app.use('/admin/finance', financeRouter);
app
.
use
(
'
/studentResults
'
,
studentResult
);
app
.
use
(
'
/tutorRatings
'
,
tutorRating
);
app
.
use
(
'
/filteredList
'
,
filteredList
);
app
.
use
(
'
/createClass
'
,
createClassRoute
);
app
.
listen
(
port
,
()
=>
{
console
.
log
(
`Server is running on Port:
${
port
}
`
);
...
...
WebFrontEnd/smartcoach-frontend/package-lock.json
View file @
078418bb
...
...
@@ -12344,6 +12344,14 @@
"whatwg-fetch"
:
"^3.4.1"
}
},
"react-bootstrap-icons"
:
{
"version"
:
"1.5.0"
,
"resolved"
:
"https://registry.npmjs.org/react-bootstrap-icons/-/react-bootstrap-icons-1.5.0.tgz"
,
"integrity"
:
"sha512-QC5q4meHQG0cO9RJzeDLSqZ1gbVa9jxFCpONCE3GYl2FkbAKSyJAEsONlzTApbZ8/oG87gPWq0xAyn5SZ/Jafw=="
,
"requires"
:
{
"prop-types"
:
"^15.7.2"
}
},
"react-dev-utils"
:
{
"version"
:
"11.0.4"
,
"resolved"
:
"https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-11.0.4.tgz"
,
...
...
WebFrontEnd/smartcoach-frontend/package.json
View file @
078418bb
...
...
@@ -8,6 +8,7 @@
"@testing-library/user-event"
:
"^12.8.3"
,
"bootstrap"
:
"^4.6.0"
,
"react"
:
"^17.0.2"
,
"react-bootstrap-icons"
:
"^1.5.0"
,
"react-dom"
:
"^17.0.2"
,
"react-dropdown"
:
"^1.9.2"
,
"react-icons"
:
"^4.2.0"
,
...
...
WebFrontEnd/smartcoach-frontend/src/Components/Admin/Dashboard.js
View file @
078418bb
...
...
@@ -25,7 +25,7 @@ export default class Dashboard extends Component {
<
div
className
=
"
logo-src
"
/>
<
div
className
=
"
header__pane ml-auto
"
>
<
div
>
<
button
type
=
"
button
"
className
=
"
hamburger close-sidebar-btn hamburger--elastic
"
data
-
class
=
"
closed-sidebar
"
>
<
button
type
=
"
button
"
className
=
"
hamburger close-sidebar-btn hamburger--elastic
"
data
-
class
=
"
closed-sidebar
"
>
<
span
className
=
"
hamburger-box
"
>
<
span
className
=
"
hamburger-inner
"
/>
<
/span
>
...
...
WebFrontEnd/smartcoach-frontend/src/Components/Admin/add_class_details.js
View file @
078418bb
import
React
,
{
Component
}
from
"
react
"
;
import
axios
from
"
axios
"
;
import
SelectSearch
,
{
fuzzySearch
}
from
'
react-select-search
'
;
import
*
as
configs
from
"
../../Config/config
"
;
import
swal
from
"
sweetalert
"
;
const
options
=
[
{
name
:
'
Hasitha
'
,
value
:
'
1
'
},
{
name
:
'
Devinda
'
,
value
:
'
2
'
},
{
name
:
'
Hansaka
'
,
value
:
'
3
'
},
{
name
:
'
Gihan
'
,
value
:
'
4
'
},
];
export
default
class
AddClassDetails
extends
Component
{
constructor
(
props
)
{
...
...
@@ -22,13 +16,31 @@ export default class AddClassDetails extends Component{
selectedClassMethod
:
''
,
isSelectInstitute
:
false
,
HomeClassType
:
[
"
Group Class
"
,
"
Individual Class
"
],
OtherClassTypes
:
[
"
Group Class
"
,
"
Mass Class
"
,
"
Revision Class
"
,
"
Paper Class
"
,
"
Individual Class
"
]
OtherClassTypes
:
[
"
Group Class
"
,
"
Mass Class
"
,
"
Revision Class
"
,
"
Paper Class
"
,
"
Individual Class
"
],
ClassTypes
:[],
selectedClassType
:
''
,
selectedInstitute
:
''
,
batchName
:
''
,
classStartingDate
:
Date
,
selectedSubject
:
''
,
ClassFee
:
''
,
isActiveClass
:
false
,
isActiveForStudent
:
false
,
}
this
.
onChangeClassMethod
=
this
.
onChangeClassMethod
.
bind
(
this
);
this
.
onChangeClassTypeDropDown
=
this
.
onChangeClassTypeDropDown
.
bind
(
this
);
this
.
onChangeInstituteDropDown
=
this
.
onChangeInstituteDropDown
.
bind
(
this
);
this
.
onChangeBatchName
=
this
.
onChangeBatchName
.
bind
(
this
);
this
.
onChangeClassStartingDate
=
this
.
onChangeClassStartingDate
.
bind
(
this
);
this
.
onChangeSubjectDropDown
=
this
.
onChangeSubjectDropDown
.
bind
(
this
);
this
.
onChangeClassFee
=
this
.
onChangeClassFee
.
bind
(
this
);
this
.
onChangeIsActiveClass
=
this
.
onChangeIsActiveClass
.
bind
(
this
);
this
.
onChangeIsActiveForStudent
=
this
.
onChangeIsActiveForStudent
.
bind
(
this
);
this
.
onSubmitCreateClass
=
this
.
onSubmitCreateClass
.
bind
(
this
);
}
// this.onChangeInstituteDropDown = this.onChangeInstituteDropDown.bind(this);
componentDidMount
()
{
axios
.
get
(
configs
.
BASE_URL
+
'
/tutorSingUp/
'
+
this
.
state
.
tutorID
)
...
...
@@ -52,12 +64,70 @@ export default class AddClassDetails extends Component{
})
}
onChangeInstituteDropDown
(
value
)
{
onChangeInstituteDropDown
(
e
)
{
this
.
setState
({
selectedInstitute
:
e
.
target
.
value
})
}
onChangeClassTypeDropDown
(
e
)
{
this
.
setState
({
selectedClassType
:
e
})
}
onChangeBatchName
(
e
)
{
this
.
setState
({
batchName
:
e
.
target
.
value
})
}
onChangeClassStartingDate
(
e
)
{
this
.
setState
({
classStartingDate
:
e
.
target
.
value
})
}
onChangeSubjectDropDown
(
e
)
{
this
.
setState
({
selectedSubject
:
e
})
}
onChangeClassFee
(
e
)
{
this
.
setState
({
newInstitute
:
valu
e
.
target
.
value
ClassFee
:
e
.
target
.
value
})
}
onChangeIsActiveClass
(
e
)
{
if
(
this
.
state
.
isActiveClass
){
this
.
setState
({
isActiveClass
:
false
})
}
else
{
this
.
setState
({
isActiveClass
:
true
})
}
}
onChangeIsActiveForStudent
(
e
)
{
if
(
this
.
state
.
isActiveForStudent
){
this
.
setState
({
isActiveForStudent
:
false
})
}
else
{
this
.
setState
({
isActiveForStudent
:
true
})
}
}
onChangeClassMethod
(
e
)
{
console
.
log
(
e
);
console
.
log
(
e
.
target
.
value
);
...
...
@@ -66,17 +136,63 @@ export default class AddClassDetails extends Component{
},()
=>
{
if
(
e
.
target
.
value
===
"
Institute
"
){
this
.
setState
({
isSelectInstitute
:
true
isSelectInstitute
:
true
,
ClassTypes
:
this
.
state
.
OtherClassTypes
})
}
else
{
this
.
setState
({
isSelectInstitute
:
false
})
if
(
e
.
target
.
value
===
"
Home Visit
"
){
this
.
setState
({
isSelectInstitute
:
false
,
ClassTypes
:
this
.
state
.
HomeClassType
})
}
else
{
this
.
setState
({
isSelectInstitute
:
false
,
ClassTypes
:
this
.
state
.
OtherClassTypes
})
}
}
})
}
onSubmitCreateClass
=
e
=>
{
e
.
preventDefault
();
let
instituteID
=
''
;
this
.
state
.
instituteList
.
map
(
name
=>
{
if
(
this
.
state
.
selectedInstitute
===
name
.
institute_name
){
instituteID
=
name
.
_id
;
}
})
const
newClass
=
{
tutor_id
:
this
.
state
.
tutorID
,
class_method
:
this
.
state
.
selectedClassMethod
,
class_type
:
this
.
state
.
selectedClassType
,
institute_id
:
instituteID
,
batch_no
:
this
.
state
.
batchName
,
class_startingDate
:
this
.
state
.
classStartingDate
,
subject
:
this
.
state
.
selectedSubject
,
class_fee
:
this
.
state
.
ClassFee
,
isActiveClass
:
this
.
state
.
isActiveClass
,
isActiveForStudent
:
this
.
state
.
isActiveForStudent
,
}
axios
.
post
(
configs
.
BASE_URL
+
'
/createClass/add
'
,
newClass
)
.
then
(
res
=>
{
swal
(
"
success!!!
"
,
res
,
"
success
"
).
then
(()
=>
{
//e.target.reset();
//window.location.reload();
});
window
.
location
.
reload
();
})
}
render
()
{
return
(
...
...
@@ -114,38 +230,27 @@ export default class AddClassDetails extends Component{
<
/select
>
<
/div
>
{
this
.
state
.
selectedClassMethod
===
"
Home Visit
"
?
<
div
className
=
"
position-relative form-group
"
>
<
label
>
Class
Type
<
/label
>
<
select
name
=
"
select
"
className
=
"
form-control
"
>
<
option
value
=
""
disabled
selected
>
Select
Class
Type
<
/option
>
{
this
.
state
.
HomeClassType
.
map
((
dis
)
=>
<
option
value
=
{
dis
}
>
{
dis
}
<
/option>
)
}
<
/select
>
<
/div
>
:
<
div
className
=
"
position-relative form-group
"
>
<
label
>
Class
Type
<
/label
>
<
select
name
=
"
select
"
className
=
"
form-control
"
>
<
option
value
=
""
disabled
selected
>
Select
Class
Type
<
/option
>
{
this
.
state
.
OtherClassTypes
.
map
((
dis
)
=>
<
option
value
=
{
dis
}
>
{
dis
}
<
/option>
)
}
<
/select
>
<
/div
>
}
<
div
className
=
"
position-relative form-group
"
>
<
label
>
Class
Type
<
/label
>
<
select
name
=
"
select
"
className
=
"
form-control
"
onChange
=
{
e
=>
this
.
onChangeClassTypeDropDown
(
e
.
target
.
value
)}
>
<
option
value
=
""
disabled
selected
>
Select
Class
Type
<
/option
>
{
this
.
state
.
ClassTypes
.
map
((
dis
)
=>
<
option
value
=
{
dis
}
>
{
dis
}
<
/option>
)
}
<
/select
>
<
/div
>
{
this
.
state
.
isSelectInstitute
===
true
?
<
div
className
=
"
position-relative form-group
"
>
<
label
>
Institute
<
/label
>
<
select
name
=
"
select
"
className
=
"
form-control
"
>
onChange
=
{
e
=>
this
.
onChangeInstituteDropDown
(
e
)}
<
select
name
=
"
select
"
className
=
"
form-control
"
onChange
=
{
e
=>
this
.
onChangeInstituteDropDown
(
e
)}
>
<
option
value
=
""
disabled
selected
>
Select
the
Institute
<
/option
>
{
this
.
state
.
instituteList
.
map
((
dis
)
=>
<
option
value
=
{
dis
}
>
<
option
value
=
{
dis
.
institute_name
}
>
{
dis
.
institute_name
}
<
/option>
)
}
...
...
@@ -157,15 +262,16 @@ export default class AddClassDetails extends Component{
<
div
className
=
"
position-relative form-group
"
>
<
label
>
Batch
Name
<
/label
>
<
input
type
=
"
text
"
className
=
"
form-control
"
/>
<
input
type
=
"
text
"
className
=
"
form-control
"
onChange
=
{
this
.
onChangeBatchName
}
/
>
<
/div
>
<
div
className
=
"
position-relative form-group
"
>
<
label
>
Class
Starting
Date
<
/label
>
<
input
type
=
"
date
"
className
=
"
form-control
"
/>
<
input
type
=
"
date
"
className
=
"
form-control
"
onChange
=
{
this
.
onChangeClassStartingDate
}
/
>
<
/div
>
<
div
className
=
"
position-relative form-group
"
>
<
label
>
Subject
<
/label
>
<
select
name
=
"
select
"
className
=
"
form-control
"
>
<
select
name
=
"
select
"
className
=
"
form-control
"
onChange
=
{
e
=>
this
.
onChangeSubjectDropDown
(
e
.
target
.
value
)}
>
<
option
value
=
""
disabled
selected
>
Select
the
Subject
<
/option
>
{
this
.
state
.
subjectList
.
map
((
dis
)
=>
<
option
value
=
{
dis
}
>
...
...
@@ -175,30 +281,126 @@ export default class AddClassDetails extends Component{
<
/div
>
<
div
className
=
"
position-relative form-group
"
>
<
label
>
Class
Fee
<
/label
>
<
input
type
=
"
text
"
className
=
"
form-control
"
/>
<
input
type
=
"
text
"
className
=
"
form-control
"
onChange
=
{
this
.
onChangeClassFee
}
/
>
<
/div
>
<
div
className
=
"
position-relative form-group
"
>
<
input
type
=
"
checkbox
"
id
=
"
onlineClass
"
className
=
"
form-control
"
onChange
=
{
this
.
onChangeIsActiveClass
}
defaultChecked
=
{
this
.
state
.
isActiveClass
}
style
=
{{
width
:
'
20px
'
,
height
:
'
20px
'
,
float
:
'
left
'
,
marginLeft
:
'
25px
'
,
marginTop
:
'
15px
'
}}
/
>
<
label
style
=
{{
marginTop
:
'
15px
'
,
float
:
'
left
'
,
marginLeft
:
'
20px
'
}}
>
Active
Class
<
/label
>
<
input
type
=
"
checkbox
"
id
=
"
onlineClass
"
className
=
"
form-control
"
onChange
=
{
this
.
onChangeIsActiveForStudent
}
defaultChecked
=
{
this
.
state
.
isActiveForStudent
}
style
=
{{
width
:
'
20px
'
,
height
:
'
20px
'
,
float
:
'
left
'
,
marginLeft
:
'
25px
'
,
marginTop
:
'
15px
'
}}
/
>
<
label
style
=
{{
marginTop
:
'
15px
'
,
float
:
'
left
'
,
marginLeft
:
'
20px
'
}}
>
Active
for
Students
<
/label
>
<
/div
>
<
/div
>
<
div
className
=
"
position-relative form-group
"
>
<
button
className
=
"
form-control
"
style
=
{{
background
:
"
#8D4433
"
,
color
:
"
white
"
,
margin
:
'
50px
'
,
width
:
'
50%
'
}}
onClick
=
{
this
.
onSubmitCreateClass
}
><
b
>
Create
Class
<
/b></
button
>
<
/div
>
<
/div
>
<
div
className
=
"
col-md-6
"
>
<
div
className
=
"
card-body
"
>
<
div
className
=
"
position-relative form-group
"
>
{
/*<label htmlFor="exampleEmail" className>Students</label>*/
}
{
/*<SelectSearch*/
}
{
/* options={options}*/
}
{
/* multiple*/
}
{
/* search*/
}
{
/* filterOptions={fuzzySearch}*/
}
{
/* placeholder="Select students"*/
}
{
/*/>*/
}
<
label
><
h5
>
Classes
<
/h5></
label
>
<
/div
>
<
div
className
=
"
card-border
"
style
=
{{
background
:
'
lightgray
'
,
padding
:
'
15px
'
}}
>
<
div
className
=
"
row
"
>
<
h5
style
=
{{
marginLeft
:
'
10px
'
}}
>
Filters
<
/h5
>
<
/div
>
<
div
className
=
"
row
"
>
<
div
className
=
"
col
"
>
<
select
name
=
"
select
"
className
=
"
form-control
"
style
=
{{
width
:
'
100%
'
}}
onChange
=
{
e
=>
this
.
onChangeClassMethod
(
e
)}
>
<
option
value
=
""
disabled
selected
>
Class
Method
<
/option
>
{
this
.
state
.
ClassMethods
.
map
((
dis
)
=>
<
option
value
=
{
dis
}
>
{
dis
}
<
/option>
)
}
<
/select
>
<
/div
>
<
div
className
=
"
col
"
>
<
select
name
=
"
select
"
className
=
"
form-control
"
style
=
{{
width
:
'
100%
'
}}
onChange
=
{
e
=>
this
.
onChangeClassTypeDropDown
(
e
.
target
.
value
)}
>
<
option
value
=
""
disabled
selected
>
Class
Type
<
/option
>
{
this
.
state
.
ClassTypes
.
map
((
dis
)
=>
<
option
value
=
{
dis
}
>
{
dis
}
<
/option>
)
}
<
/select
>
<
/div
>
<
div
className
=
"
col
"
>
<
select
name
=
"
select
"
className
=
"
form-control
"
onChange
=
{
e
=>
this
.
onChangeSubjectDropDown
(
e
.
target
.
value
)}
>
<
option
value
=
""
disabled
selected
>
Subject
<
/option
>
{
this
.
state
.
subjectList
.
map
((
dis
)
=>
<
option
value
=
{
dis
}
>
{
dis
}
<
/option>
)
}
<
/select
>
<
/div
>
<
div
className
=
"
col
"
>
<
select
name
=
"
select
"
className
=
"
form-control
"
onChange
=
{
e
=>
this
.
onChangeSubjectDropDown
(
e
.
target
.
value
)}
>
<
option
value
=
""
disabled
selected
>
Status
<
/option
>
<
option
value
=
""
>
Active
Class
<
/option
>
<
option
value
=
""
>
Active
For
Students
<
/option
>
<
/select
>
<
/div
>
<
/div
>
<
div
className
=
"
row
"
style
=
{{
marginTop
:
'
10px
'
}}
>
<
div
className
=
"
col-6
"
>
<
input
type
=
"
text
"
placeholder
=
"
Search
"
className
=
"
form-control
"
/>
<
/div
>
<
div
className
=
"
col
"
>
<
button
className
=
"
form-control
"
style
=
{{
background
:
"
#8D4433
"
,
color
:
"
white
"
}}
onClick
=
{
this
.
ResetFilters
}
><
b
>
Reset
<
/b></
button
>
<
/div
>
<
div
className
=
"
col
"
>
<
button
className
=
"
form-control
"
style
=
{{
background
:
"
#086232
"
,
color
:
"
white
"
}}
onClick
=
{
this
.
FindTutor
}
><
b
>
Search
<
/b></
button
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"
row
"
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"
position-relative row form-group
"
>
<
div
className
=
"
col-sm-12
"
>
<
button
className
=
"
btn btn-primary
"
style
=
{{
width
:
"
150px
"
}}
type
=
"
submit
"
>
Create
Class
<
/button
>
<
/div
>
{
/*<div className="col-sm-12">*/
}
{
/* <button className="btn btn-primary" style={{width:"150px"}} onClick={this.onSubmitCreateClass}>Create Class</button>*/
}
{
/*</div>*/
}
<
/div
>
<
/form
>
...
...
WebFrontEnd/smartcoach-frontend/src/Components/Home.js
View file @
078418bb
...
...
@@ -12,6 +12,7 @@ import Location from "../Images/location.png";
import
Star
from
"
../Images/star.png
"
;
import
ReviewImg
from
"
../Images/note.png
"
;
import
Calender
from
"
../Images/calender.png
"
;
import
*
as
Icon
from
'
react-bootstrap-icons
'
;
import
axios
from
"
axios
"
;
import
*
as
configs
from
"
../Config/config
"
;
import
TutorCard
from
"
./HomePage/TutorCard
"
;
...
...
@@ -44,6 +45,7 @@ export default class Home extends Component{
selectedClassType
:
''
,
selectedLanguage
:
''
,
TutorFilteredList
:
[],
TutorFilteredListFinal
:
[],
RVPastResults
:
25
,
RVRatings
:
25
,
RVReviews
:
25
,
...
...
@@ -54,6 +56,7 @@ export default class Home extends Component{
isStudentCount
:
true
,
TotalRecommendationCount
:
0
,
passResultsSubCategory
:
2
,
isClickFilterArrow
:
false
,
};
this
.
FindCities
=
this
.
FindCities
.
bind
(
this
);
...
...
@@ -75,6 +78,9 @@ export default class Home extends Component{
this
.
OnChangeCRStudentCount
=
this
.
OnChangeCRStudentCount
.
bind
(
this
);
this
.
calculateTotalRecommendationCount
=
this
.
calculateTotalRecommendationCount
.
bind
(
this
);
this
.
onChangeRadioButton
=
this
.
onChangeRadioButton
.
bind
(
this
);
this
.
getRecommendation
=
this
.
getRecommendation
.
bind
(
this
);
this
.
onClickFilterArrow
=
this
.
onClickFilterArrow
.
bind
(
this
);
this
.
onClickAddFilter
=
this
.
onClickAddFilter
.
bind
(
this
);
}
componentDidMount
()
{
...
...
@@ -90,6 +96,23 @@ export default class Home extends Component{
this
.
calculateTotalRecommendationCount
();
}
onClickAddFilter
(){
if
(
this
.
state
.
TutorFilteredList
.
length
>
0
){
if
(
this
.
state
.
TotalRecommendationCount
<=
100
){
this
.
getRecommendation
();
}
else
{
swal
(
"
Sorry
"
,
"
Total Filter value Count is not correct.
\n
Please Set Total Filter Value as less than or equal to 100.
"
,
"
warning
"
);
}
}
else
{
swal
(
"
Sorry
"
,
"
No Results Founded
\n
Please Find Tutor First.
"
,
"
warning
"
);
}
}
onChangeRadioButton
(
e
){
if
(
e
.
target
.
value
===
"
By pass rate
"
){
...
...
@@ -104,6 +127,19 @@ export default class Home extends Component{
}
}
onClickFilterArrow
(){
if
(
this
.
state
.
isClickFilterArrow
){
this
.
setState
({
isClickFilterArrow
:
false
})
}
else
{
this
.
setState
({
isClickFilterArrow
:
true
})
}
}
calculateTotalRecommendationCount
(){
let
finalResult
=
this
.
state
.
RVPastResults
+
this
.
state
.
RVRatings
+
this
.
state
.
RVReviews
+
this
.
state
.
RVStudentCount
;
this
.
setState
({
...
...
@@ -237,14 +273,17 @@ export default class Home extends Component{
passResultsSubCategory
:
this
.
state
.
passResultsSubCategory
,
}
if
(
this
.
state
.
selectedStream
!=
""
&&
this
.
state
.
selectedSubject
!
=
""
){
if
(
this
.
state
.
selectedStream
!=
=
""
&&
this
.
state
.
selectedSubject
!=
=
""
){
axios
.
post
(
configs
.
BASE_URL
+
'
/filteredList/getFilteredList
'
,
Filters
)
.
then
(
res
=>
{
console
.
log
(
res
.
data
);
this
.
setState
({
TutorFilteredList
:
res
.
data
},()
=>
{
this
.
getRecommendation
();
})
console
.
log
(
res
.
data
);
})
...
...
@@ -258,6 +297,55 @@ export default class Home extends Component{
}
getRecommendation
(){
const
TutorFinalList
=
[]
this
.
state
.
TutorFilteredList
.
map
(
tutor
=>
{
let
finalReviewScore
=
(
Number
(
tutor
.
tutor_reviewValue
)
*
Number
(
this
.
state
.
RVReviews
))
/
100
;
let
valueForRating
=
0
;
if
(
Number
(
tutor
.
tutor_avg_rating
)
===
5
){
valueForRating
=
100
}
else
if
(
Number
(
tutor
.
tutor_avg_rating
)
>
4.75
){
valueForRating
=
75
}
else
if
(
Number
(
tutor
.
tutor_avg_rating
)
>
4
){
valueForRating
=
60
}
else
if
(
Number
(
tutor
.
tutor_avg_rating
)
>
2
){
valueForRating
=
40
}
else
{
valueForRating
=
0
}
let
FinalRatingScore
=
(
valueForRating
*
Number
(
this
.
state
.
RVRatings
))
/
100
;
let
FinalScore
=
finalReviewScore
+
FinalRatingScore
;
const
temp
=
{
tutor_id
:
tutor
.
teacher
,
tutor_name
:
tutor
.
tutor_name
,
tutor_subjects
:
tutor
.
tutor_subjects
,
tutor_class_type
:
tutor
.
tutor_class_type
,
tutor_main_district
:
tutor
.
tutor_main_district
,
tutor_main_city
:
tutor
.
tutor_main_city
,
tutor_medium
:
tutor
.
tutor_medium
,
tutor_qualification
:
tutor
.
tutor_qualification
,
tutor_reviewValue
:
tutor
.
tutor_reviewValue
,
tutor_avg_rating
:
tutor
.
tutor_avg_rating
,
tutor_finalScore
:
FinalScore
}
TutorFinalList
.
push
(
temp
);
})
this
.
setState
({
TutorFilteredListFinal
:
TutorFinalList
})
}
render
()
{
return
(
...
...
@@ -368,142 +456,220 @@ export default class Home extends Component{
<
/div
>
<
div
className
=
"
row
"
style
=
{{
marginRight
:
'
50px
'
,
marginLeft
:
'
50px
'
,
marginTop
:
'
10px
'
,
padding
:
'
10px
'
,
background
:
'
#1E4258
'
}}
>
<
h5
style
=
{{
color
:
"
white
"
,
float
:
'
left
'
}}
>
Customized
Recommendation
<
/h5
>
<
/div
>
<
div
className
=
"
row
"
style
=
{{
marginRight
:
'
50px
'
,
marginLeft
:
'
50px
'
,
marginTop
:
'
5px
'
,
padding
:
'
5px
'
,
background
:
'
#1E4258
'
}}
>
<
div
className
=
"
col
"
style
=
{{
margin
:
'
5px
'
,
border
:
'
solid
'
,
padding
:
'
10px
'
,
borderColor
:
'
#216E9B
'
}}
>
<
div
className
=
"
row
"
>
<
div
className
=
"
col
"
>
<
div
className
=
"
row
"
>
<
input
type
=
"
checkbox
"
id
=
"
PastResults
"
className
=
"
form-control
"
defaultChecked
=
{
this
.
state
.
isRVPastResults
}
onChange
=
{
this
.
OnChangeIsCRPastResults
}
style
=
{{
width
:
'
20px
'
,
height
:
'
20px
'
,
float
:
'
left
'
,
marginLeft
:
'
25px
'
,
marginTop
:
'
15px
'
}}
/
>
<
label
style
=
{{
marginTop
:
'
15px
'
,
float
:
'
left
'
,
marginLeft
:
'
20px
'
,
color
:
"
white
"
}}
>
Past
Results
<
/label
>
<
/div
>
<
div
className
=
"
row
"
>
<
input
type
=
"
number
"
id
=
"
pastResultsTxt
"
className
=
"
form-control
"
value
=
{
this
.
state
.
RVPastResults
}
onChange
=
{
this
.
OnChangeCRPastResults
}
style
=
{{
width
:
'
30%
'
,
marginLeft
:
'
20px
'
}}
required
/>
<
label
style
=
{{
marginTop
:
'
10px
'
,
float
:
'
left
'
,
marginLeft
:
'
10px
'
,
color
:
"
white
"
}}
>%<
/label
>
<
/div
>
<
div
className
=
"
row
"
>
<
div
style
=
{{
color
:
'
white
'
,
padding
:
'
8px
'
}}
onChange
=
{
this
.
onChangeRadioButton
}
>
<
input
type
=
"
radio
"
value
=
"
By pass rate
"
name
=
"
results
"
style
=
{{
marginLeft
:
'
11px
'
}}
checked
=
{
this
.
state
.
passResultsSubCategory
===
1
}
/> By pass rat
e
<
br
/>
<
input
type
=
"
radio
"
value
=
"
By grade A
"
name
=
"
results
"
style
=
{{
marginLeft
:
'
12px
'
}}
checked
=
{
this
.
state
.
passResultsSubCategory
===
2
}
/> By grade 'A
'
<
/div
>
{
this
.
state
.
isClickFilterArrow
?
<
div
className
=
"
row
"
style
=
{{
marginRight
:
'
50px
'
,
marginLeft
:
'
50px
'
,
marginTop
:
'
5px
'
,
padding
:
'
5px
'
,
background
:
'
#1E4258
'
}}
>
<
div
className
=
"
col
"
style
=
{{
margin
:
'
5px
'
,
border
:
'
solid
'
,
padding
:
'
10px
'
,
borderColor
:
'
#216E9B
'
}}
>
<
div
className
=
"
row
"
>
<
div
className
=
"
col
"
>
<
div
className
=
"
row
"
>
<
input
type
=
"
checkbox
"
id
=
"
PastResults
"
className
=
"
form-control
"
defaultChecked
=
{
this
.
state
.
isRVPastResults
}
onChange
=
{
this
.
OnChangeIsCRPastResults
}
style
=
{{
width
:
'
20px
'
,
height
:
'
20px
'
,
float
:
'
left
'
,
marginLeft
:
'
25px
'
,
marginTop
:
'
15px
'
}}
/
>
<
label
style
=
{{
marginTop
:
'
15px
'
,
float
:
'
left
'
,
marginLeft
:
'
20px
'
,
color
:
"
white
"
}}
>
Past
Results
<
/label
>
<
/div
>
<
/div
>
<
div
className
=
"
row
"
>
<
div
className
=
"
row
"
>
<
input
type
=
"
number
"
id
=
"
pastResultsTxt
"
className
=
"
form-control
"
value
=
{
this
.
state
.
RVPastResults
}
onChange
=
{
this
.
OnChangeCRPastResults
}
style
=
{{
width
:
'
30%
'
,
marginLeft
:
'
20px
'
}}
required
/>
<
label
style
=
{{
marginTop
:
'
10px
'
,
float
:
'
left
'
,
marginLeft
:
'
10px
'
,
color
:
"
white
"
}}
>%<
/label
>
<
/div
>
<
div
className
=
"
row
"
>
<
div
style
=
{{
color
:
'
white
'
,
padding
:
'
8px
'
}}
onChange
=
{
this
.
onChangeRadioButton
}
>
<
input
type
=
"
radio
"
value
=
"
By pass rate
"
name
=
"
results
"
style
=
{{
marginLeft
:
'
11px
'
}}
checked
=
{
this
.
state
.
passResultsSubCategory
===
1
}
/> By pass rat
e
<
br
/>
<
input
type
=
"
radio
"
value
=
"
By grade A
"
name
=
"
results
"
style
=
{{
marginLeft
:
'
12px
'
}}
checked
=
{
this
.
state
.
passResultsSubCategory
===
2
}
/> By grade 'A
'
<
/div
>
<
/div
>
<
div
className
=
"
row
"
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"
col
"
>
<
div
className
=
"
row
"
>
<
input
type
=
"
checkbox
"
id
=
"
PastResults
"
className
=
"
form-control
"
defaultChecked
=
{
this
.
state
.
isRVRatings
}
onChange
=
{
this
.
OnChangeIsCRRatings
}
style
=
{{
width
:
'
20px
'
,
height
:
'
20px
'
,
float
:
'
left
'
,
marginLeft
:
'
25px
'
,
marginTop
:
'
15px
'
}}
/
>
<
label
style
=
{{
marginTop
:
'
15px
'
,
float
:
'
left
'
,
marginLeft
:
'
20px
'
,
color
:
"
white
"
}}
>
Ratings
<
/label
>
<
/div
>
<
div
className
=
"
row
"
>
<
input
type
=
"
number
"
id
=
"
pastResultsTxt
"
className
=
"
form-control
"
value
=
{
this
.
state
.
RVRatings
}
onChange
=
{
this
.
OnChangeCRRatings
}
style
=
{{
width
:
'
30%
'
,
marginLeft
:
'
20px
'
}}
required
/>
<
label
style
=
{{
marginTop
:
'
10px
'
,
float
:
'
left
'
,
marginLeft
:
'
10px
'
,
color
:
"
white
"
}}
>%<
/label
>
<
/div
>
<
div
className
=
"
row
"
>
<
div
className
=
"
col
"
>
<
div
className
=
"
row
"
>
<
input
type
=
"
checkbox
"
id
=
"
PastResults
"
className
=
"
form-control
"
defaultChecked
=
{
this
.
state
.
isRVRatings
}
onChange
=
{
this
.
OnChangeIsCRRatings
}
style
=
{{
width
:
'
20px
'
,
height
:
'
20px
'
,
float
:
'
left
'
,
marginLeft
:
'
25px
'
,
marginTop
:
'
15px
'
}}
/
>
<
label
style
=
{{
marginTop
:
'
15px
'
,
float
:
'
left
'
,
marginLeft
:
'
20px
'
,
color
:
"
white
"
}}
>
Ratings
<
/label
>
<
/div
>
<
div
className
=
"
row
"
>
<
input
type
=
"
number
"
id
=
"
pastResultsTxt
"
className
=
"
form-control
"
value
=
{
this
.
state
.
RVRatings
}
onChange
=
{
this
.
OnChangeCRRatings
}
style
=
{{
width
:
'
30%
'
,
marginLeft
:
'
20px
'
}}
required
/>
<
label
style
=
{{
marginTop
:
'
10px
'
,
float
:
'
left
'
,
marginLeft
:
'
10px
'
,
color
:
"
white
"
}}
>%<
/label
>
<
/div
>
<
div
className
=
"
row
"
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"
col
"
>
<
div
className
=
"
row
"
>
<
input
type
=
"
checkbox
"
id
=
"
PastResults
"
className
=
"
form-control
"
defaultChecked
=
{
this
.
state
.
isRVReviews
}
onChange
=
{
this
.
OnChangeIsCRReviews
}
style
=
{{
width
:
'
20px
'
,
height
:
'
20px
'
,
float
:
'
left
'
,
marginLeft
:
'
25px
'
,
marginTop
:
'
15px
'
}}
/
>
<
label
style
=
{{
marginTop
:
'
15px
'
,
float
:
'
left
'
,
marginLeft
:
'
20px
'
,
color
:
"
white
"
}}
>
Reviews
<
/label
>
<
/div
>
<
div
className
=
"
row
"
>
<
input
type
=
"
number
"
id
=
"
pastResultsTxt
"
className
=
"
form-control
"
value
=
{
this
.
state
.
RVReviews
}
onChange
=
{
this
.
OnChangeCRReviews
}
style
=
{{
width
:
'
30%
'
,
marginLeft
:
'
20px
'
}}
required
/>
<
label
style
=
{{
marginTop
:
'
10px
'
,
float
:
'
left
'
,
marginLeft
:
'
10px
'
,
color
:
"
white
"
}}
>%<
/label
>
<
/div
>
<
div
className
=
"
row
"
>
<
div
className
=
"
col
"
>
<
div
className
=
"
row
"
>
<
input
type
=
"
checkbox
"
id
=
"
PastResults
"
className
=
"
form-control
"
defaultChecked
=
{
this
.
state
.
isRVReviews
}
onChange
=
{
this
.
OnChangeIsCRReviews
}
style
=
{{
width
:
'
20px
'
,
height
:
'
20px
'
,
float
:
'
left
'
,
marginLeft
:
'
25px
'
,
marginTop
:
'
15px
'
}}
/
>
<
label
style
=
{{
marginTop
:
'
15px
'
,
float
:
'
left
'
,
marginLeft
:
'
20px
'
,
color
:
"
white
"
}}
>
Reviews
<
/label
>
<
/div
>
<
div
className
=
"
row
"
>
<
input
type
=
"
number
"
id
=
"
pastResultsTxt
"
className
=
"
form-control
"
value
=
{
this
.
state
.
RVReviews
}
onChange
=
{
this
.
OnChangeCRReviews
}
style
=
{{
width
:
'
30%
'
,
marginLeft
:
'
20px
'
}}
required
/>
<
label
style
=
{{
marginTop
:
'
10px
'
,
float
:
'
left
'
,
marginLeft
:
'
10px
'
,
color
:
"
white
"
}}
>%<
/label
>
<
/div
>
<
div
className
=
"
row
"
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"
col
"
>
<
div
className
=
"
row
"
>
<
input
type
=
"
checkbox
"
id
=
"
PastResults
"
className
=
"
form-control
"
defaultChecked
=
{
this
.
state
.
isStudentCount
}
onChange
=
{
this
.
OnChangeIsCRStudentCount
}
style
=
{{
width
:
'
20px
'
,
height
:
'
20px
'
,
float
:
'
left
'
,
marginLeft
:
'
25px
'
,
marginTop
:
'
15px
'
}}
/
>
<
label
style
=
{{
marginTop
:
'
15px
'
,
float
:
'
left
'
,
marginLeft
:
'
20px
'
,
color
:
"
white
"
}}
>
Student
Count
<
/label
>
<
/div
>
<
div
className
=
"
row
"
>
<
input
type
=
"
number
"
id
=
"
pastResultsTxt
"
className
=
"
form-control
"
value
=
{
this
.
state
.
RVStudentCount
}
onChange
=
{
this
.
OnChangeCRStudentCount
}
style
=
{{
width
:
'
30%
'
,
marginLeft
:
'
20px
'
}}
required
/>
<
label
style
=
{{
marginTop
:
'
10px
'
,
float
:
'
left
'
,
marginLeft
:
'
10px
'
,
color
:
"
white
"
}}
>%<
/label
>
<
/div
>
<
div
className
=
"
row
"
>
<
div
className
=
"
col
"
>
<
div
className
=
"
row
"
>
<
input
type
=
"
checkbox
"
id
=
"
PastResults
"
className
=
"
form-control
"
defaultChecked
=
{
this
.
state
.
isStudentCount
}
onChange
=
{
this
.
OnChangeIsCRStudentCount
}
style
=
{{
width
:
'
20px
'
,
height
:
'
20px
'
,
float
:
'
left
'
,
marginLeft
:
'
25px
'
,
marginTop
:
'
15px
'
}}
/
>
<
label
style
=
{{
marginTop
:
'
15px
'
,
float
:
'
left
'
,
marginLeft
:
'
20px
'
,
color
:
"
white
"
}}
>
Student
Count
<
/label
>
<
/div
>
<
div
className
=
"
row
"
>
<
input
type
=
"
number
"
id
=
"
pastResultsTxt
"
className
=
"
form-control
"
value
=
{
this
.
state
.
RVStudentCount
}
onChange
=
{
this
.
OnChangeCRStudentCount
}
style
=
{{
width
:
'
30%
'
,
marginLeft
:
'
20px
'
}}
required
/>
<
label
style
=
{{
marginTop
:
'
10px
'
,
float
:
'
left
'
,
marginLeft
:
'
10px
'
,
color
:
"
white
"
}}
>%<
/label
>
<
/div
>
<
div
className
=
"
row
"
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"
col
"
>
<
div
className
=
"
row
"
>
<
label
>
<
span
style
=
{{
marginTop
:
'
15px
'
,
float
:
'
left
'
,
marginLeft
:
'
20px
'
,
color
:
"
white
"
}}
>
<
div
className
=
"
col
"
>
<
div
className
=
"
row
"
>
<
label
>
<
span
style
=
{{
marginTop
:
'
15px
'
,
float
:
'
left
'
,
marginLeft
:
'
20px
'
,
color
:
"
white
"
}}
>
{
this
.
state
.
TotalRecommendationCount
}
/ 100</
span
>
<
/label
>
<
/div
>
<
div
className
=
"
row
"
>
<
/label
>
<
/div
>
<
div
className
=
"
row
"
>
<
button
className
=
"
form-control
"
style
=
{{
background
:
"
#216E9B
"
,
color
:
"
white
"
,
margin
:
'
10px
'
,
width
:
'
50%
'
}}
onClick
=
{
this
.
onClickAddFilter
}
><
b
>
Add
Filter
<
/b></
button
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
:
<
div
className
=
"
row
"
style
=
{{
marginRight
:
'
50px
'
,
marginLeft
:
'
50px
'
,
marginTop
:
'
5px
'
,
padding
:
'
5px
'
,
background
:
'
#1E4258
'
}}
>
<
span
><
/span
>
<
/div
>
}
<
div
className
=
"
row
"
style
=
{{
justifyContent
:
'
center
'
}}
>
{
this
.
state
.
isClickFilterArrow
?
<
button
className
=
"
form-control
"
style
=
{{
width
:
'
5%
'
,
height
:
'
50px
'
}}
onClick
=
{
this
.
onClickFilterArrow
}
>
<
span
style
=
{{
margin
:
'
20px
'
,
cursor
:
'
pointer
'
}}
><
Icon
.
ArrowBarUp
color
=
"
#444444
"
size
=
{
35
}
/></
span
>
<
/button
>
:
<
button
className
=
"
form-control
"
style
=
{{
width
:
'
5%
'
,
height
:
'
50px
'
}}
onClick
=
{
this
.
onClickFilterArrow
}
>
<
span
style
=
{{
margin
:
'
20px
'
,
cursor
:
'
pointer
'
}}
><
Icon
.
ArrowBarDown
color
=
"
#444444
"
size
=
{
35
}
/></
span
>
<
/button
>
}
<
/div
>
<
div
className
=
"
row
"
style
=
{{
background
:
'
#F5F4ED
'
,
marginLeft
:
'
50px
'
,
marginRight
:
'
50px
'
,
marginTop
:
'
10px
'
}}
>
<
h5
style
=
{{
margin
:
'
10px
'
}}
>
{
this
.
state
.
TutorFilteredList
.
length
}
Results
<
/h5
>
<
/div
>
<
div
className
=
""
>
{
this
.
state
.
TutorFilteredList
.
length
>
0
?
this
.
state
.
TutorFilteredList
.
map
(
(
card
)
=>
{
return
(
<
TutorCard
data
=
{
card
}
/>
)
}
)
: <div>No Result Found
</
div
>
}
{
this
.
state
.
TutorFilteredList
Final
.
length
>
0
?
this
.
state
.
TutorFilteredListFinal
.
map
(
(
card
)
=>
{
return
(
<
TutorCard
data
=
{
card
}
/>
)
}
)
: <div>
</
div
>
}
<
/div
>
<
div
className
=
"
app-main__outer
"
>
...
...
WebFrontEnd/smartcoach-frontend/src/Components/HomePage/TutorCard.js
View file @
078418bb
...
...
@@ -23,7 +23,7 @@ export default class TutorCard extends Component{
<
img
src
=
{
TestTeacher
}
style
=
{{
width
:
'
90px
'
,
height
:
'
80px
'
}}
/
>
<
div
className
=
"
row
"
style
=
{{
width
:
'
80%
'
,
background
:
'
#216E9B
'
,
marginLeft
:
'
10px
'
,
marginTop
:
'
5px
'
,
justifyContent
:
'
center
'
}}
>
<
h5
style
=
{{
color
:
'
white
'
,
float
:
'
center
'
,
marginBottom
:
'
10px
'
,
marginTop
:
'
5px
'
}}
>
98.5
%
<
/h5
>
<
h5
style
=
{{
color
:
'
white
'
,
float
:
'
center
'
,
marginBottom
:
'
10px
'
,
marginTop
:
'
5px
'
}}
>
<
span
>
{
this
.
props
.
data
.
tutor_finalScore
.
toFixed
(
2
)}
%<
/span>
</
h5
>
<
/div
>
<
/div
>
<
div
className
=
"
col-6
"
style
=
{{
margin
:
'
0px
'
}}
>
...
...
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