Commit 799ef536 authored by Hasitha Samarasekara's avatar Hasitha Samarasekara

Add New Classses and Add students to classes

parent 10fcdd4e
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const ClassStudentSchema = new Schema({
class_id:{type:mongoose.Schema.Types.ObjectId,ref: 'Classes'},
student_id:{type:mongoose.Schema.Types.ObjectId,ref: 'student'},
},{
timestamps:true,
});
const ClassStudentList = mongoose.model('ClassStudentList',ClassStudentSchema);
module.exports = ClassStudentList;
\ No newline at end of file
...@@ -12,6 +12,11 @@ const CreateClassSchema = new Schema({ ...@@ -12,6 +12,11 @@ const CreateClassSchema = new Schema({
subject:{type:String}, subject:{type:String},
class_fee:{type:String}, class_fee:{type:String},
student_list:[{type:mongoose.Schema.Types.ObjectId,ref: 'student'}], student_list:[{type:mongoose.Schema.Types.ObjectId,ref: 'student'}],
class_fee_option : {type:String},
class_conduct_day : {type:String},
class_conduct_time : {type:String},
AdmissionFee : {type:String},
batchYear : {type:String},
isActiveClass: { isActiveClass: {
type: Boolean, type: Boolean,
default: true default: true
...@@ -20,6 +25,8 @@ const CreateClassSchema = new Schema({ ...@@ -20,6 +25,8 @@ const CreateClassSchema = new Schema({
type: Boolean, type: Boolean,
default: true default: true
} }
},{
timestamps:true,
}); });
......
...@@ -23,7 +23,7 @@ const userSchema = new Schema({ ...@@ -23,7 +23,7 @@ const userSchema = new Schema({
}, { }, {
timestamps:true, timestamps:true,
}); });
//const institute = mongoose.model('institute',userSchema);
const User = mongoose.model('tutor',userSchema); const User = mongoose.model('tutor',userSchema);
module.exports = User; module.exports = User;
\ No newline at end of file
const router = require('express').Router(); const router = require('express').Router();
let classes = require('../models/createClass.model'); let classes = require('../models/createClass.model');
let student = require('../models/student.user.model');
let studentList = require('../models/ClassStudentList.model');
const mongoose = require("mongoose"); const mongoose = require("mongoose");
router.route('/add').post(async(req,res) =>{ router.route('/add').post(async(req,res) =>{
console.log("Inside Create Class") console.log("Inside Create Class")
console.log(res.body)
if(req.body.institute_id !== ""){ if(req.body.institute_id !== ""){
...@@ -16,8 +17,13 @@ router.route('/add').post(async(req,res) =>{ ...@@ -16,8 +17,13 @@ router.route('/add').post(async(req,res) =>{
const class_startingDate = req.body.class_startingDate; const class_startingDate = req.body.class_startingDate;
const subject = req.body.subject; const subject = req.body.subject;
const class_fee = req.body.class_fee; const class_fee = req.body.class_fee;
const class_fee_option = req.body.class_fee_option;
const isActiveClass = req.body.isActiveClass; const isActiveClass = req.body.isActiveClass;
const isActiveForStudent = req.body.isActiveForStudent; const isActiveForStudent = req.body.isActiveForStudent;
const class_conduct_day = req.body.class_conduct_day;
const class_conduct_time = req.body.class_conduct_time;
const AdmissionFee = req.body.AdmissionFee;
const batchYear = req.body.batchYear;
const newClass = new classes({ const newClass = new classes({
tutor_id, tutor_id,
...@@ -29,8 +35,12 @@ router.route('/add').post(async(req,res) =>{ ...@@ -29,8 +35,12 @@ router.route('/add').post(async(req,res) =>{
class_fee, class_fee,
isActiveClass, isActiveClass,
isActiveForStudent, isActiveForStudent,
institute_id institute_id,
class_fee_option,
class_conduct_day,
class_conduct_time,
AdmissionFee,
batchYear
}); });
console.log(newClass) console.log(newClass)
...@@ -47,8 +57,13 @@ router.route('/add').post(async(req,res) =>{ ...@@ -47,8 +57,13 @@ router.route('/add').post(async(req,res) =>{
const class_startingDate = req.body.class_startingDate; const class_startingDate = req.body.class_startingDate;
const subject = req.body.subject; const subject = req.body.subject;
const class_fee = req.body.class_fee; const class_fee = req.body.class_fee;
const class_fee_option = req.body.class_fee_option;
const isActiveClass = req.body.isActiveClass; const isActiveClass = req.body.isActiveClass;
const isActiveForStudent = req.body.isActiveForStudent; const isActiveForStudent = req.body.isActiveForStudent;
const class_conduct_day = req.body.class_conduct_day;
const class_conduct_time = req.body.class_conduct_time;
const AdmissionFee = req.body.AdmissionFee;
const batchYear = req.body.batchYear;
const newClass = new classes({ const newClass = new classes({
tutor_id, tutor_id,
...@@ -60,7 +75,11 @@ router.route('/add').post(async(req,res) =>{ ...@@ -60,7 +75,11 @@ router.route('/add').post(async(req,res) =>{
class_fee, class_fee,
isActiveClass, isActiveClass,
isActiveForStudent, isActiveForStudent,
class_fee_option,
class_conduct_day,
class_conduct_time,
AdmissionFee,
batchYear
}); });
console.log(newClass) console.log(newClass)
...@@ -70,11 +89,75 @@ router.route('/add').post(async(req,res) =>{ ...@@ -70,11 +89,75 @@ router.route('/add').post(async(req,res) =>{
}).catch(err =>res.status(400).json('Error: '+err)); }).catch(err =>res.status(400).json('Error: '+err));
} }
});
router.route('/tutorClass/:id').get(function (req, res) {
let id = req.params.id;
//console.log("TutorId : " + id)
classes.find({"tutor_id": id}).populate('institute_id').then(tutorsClasses => {
///console.log(tutor);
res.json(tutorsClasses);
}).catch(err => res.status(400).json('Eroor: '+ err));
});
router.route('/studentList/update').post((req, res) => {
const class_id = req.body._id;
const student_nic = req.body.student_nic;
console.log("classID: " + class_id);
console.log("student_nic: " + student_nic);
classes.findById(class_id,function(err, tutorsClass){
if(!tutorsClass)
req.status(404).send("Sorry Class Could not Found.");
else {
student.find({"student_nic": student_nic}).then(student => {
console.log(student)
console.log(student[0]._id)
if(student[0].student_nic === ""){
req.status(500).send("Sorry, This Student Not Registered");
}else{
const student_id = student[0]._id;
const newClassStudent = new studentList({
class_id,
student_id,
});
newClassStudent.save().then(result =>{
res.json('Student added to the Class!');
})
.catch(err =>{
res.status(500).send("Update not possible");
});
}
}).catch(err => res.status(500).json('Eroor: '+ err));
}
});
}); });
router.route('/studentList/:id').get(function (req, res) {
let id = req.params.id;
console.log("Class ID : " + id)
studentList.find({"class_id": id}).populate('student_id').then(StudentList => {
console.log(StudentList);
res.json(StudentList);
}).catch(err => {
console.log(err);
res.status(400).json('Error: ' + err)
});
});
module.exports = router; module.exports = router;
\ No newline at end of file
...@@ -99,7 +99,8 @@ router.route('/getFilteredList').post((req, res) => { ...@@ -99,7 +99,8 @@ router.route('/getFilteredList').post((req, res) => {
"tutor_medium": teacherReview.tutor_medium, "tutor_medium": teacherReview.tutor_medium,
"tutor_qualification": teacherReview.tutor_qualification, "tutor_qualification": teacherReview.tutor_qualification,
"tutor_reviewValue": response.data.result, "tutor_reviewValue": response.data.result,
"tutor_avg_rating" : Number(TotalRating/teacherReview.ratings.length) "tutor_avg_rating" : Number(TotalRating/teacherReview.ratings.length),
"tutor_review_count" : teacherReview.review.length
} }
let index = await reviewListWithScore.findIndex(x => x.teacher === teacherReview.teacher); let index = await reviewListWithScore.findIndex(x => x.teacher === teacherReview.teacher);
......
...@@ -89,68 +89,68 @@ router.route('/add').post( async(req,res) =>{ ...@@ -89,68 +89,68 @@ router.route('/add').post( async(req,res) =>{
.then(newUser =>{ .then(newUser =>{
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
// const content = ` const content = `
// Hi ${student_name},\n Hi ${student_name},\n
// You are Create a Student Account on SmartCoach.\n You are Create a Student Account on SmartCoach.\n
// You can verify your email address click on 'http://localhost:3000/AccountVerified/${newUser.id}' You can verify your email address click on 'http://localhost:3000/AccountVerified/${newUser.id}'
//
// Used your email address as the username : ${user_email} Used your email address as the username : ${user_email}
// Used given password as the password Used given password as the password
// Thank You, Thank You,
// Team SmartCoach Team SmartCoach
// `; `;
//
// var mail = { var mail = {
// from: student_name, from: student_name,
// to: user_email, to: user_email,
// subject: 'Email Verification - Student', subject: 'Email Verification - Student',
// text: content text: content
// } }
//
// transporter.sendMail(mail, (err, data) => { transporter.sendMail(mail, (err, data) => {
// if (err) { if (err) {
// res.json({ res.json({
// msg: 'fail' msg: 'fail'
// }) })
// } else { } else {
// res.json({ res.json({
// msg: 'success' msg: 'success'
// }) })
// } }
// }) })
// ; ;
//
//
// const content_guardian = ` const content_guardian = `
// Hi ${guardian_name},\n Hi ${guardian_name},\n
// Your student ${student_name} is Create a Student Account on SmartCoach.\n Your student ${student_name} is Create a Student Account on SmartCoach.\n
//
// You can know student progress through the email. You can know student progress through the email.
// We will send Student attendance, Quiz marks, Assignment Marks and other details through this email. We will send Student attendance, Quiz marks, Assignment Marks and other details through this email.
//
// Thank You, Thank You,
// Team SmartCoach Team SmartCoach
// `; `;
//
// var mail_guardian = { var mail_guardian = {
// from: guardian_name, from: guardian_name,
// to: guardian_email, to: guardian_email,
// subject: 'Student Information on SmartCoach', subject: 'Student Information on SmartCoach',
// text: content_guardian text: content_guardian
// } }
//
// transporter.sendMail(mail_guardian, (err, data) => { transporter.sendMail(mail_guardian, (err, data) => {
// if (err) { if (err) {
// res.json({ res.json({
// msg: 'fail' msg: 'fail'
// }) })
// } else { } else {
// res.json({ res.json({
// msg: 'success' msg: 'success'
// }) })
// } }
// }) })
// ; ;
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
}) })
......
...@@ -3660,6 +3660,11 @@ ...@@ -3660,6 +3660,11 @@
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.6.0.tgz", "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.6.0.tgz",
"integrity": "sha512-Io55IuQY3kydzHtbGvQya3H+KorS/M9rSNyfCGCg9WZ4pyT/lCxIlpJgG1GXW/PswzC84Tr2fBYi+7+jFVQQBw==" "integrity": "sha512-Io55IuQY3kydzHtbGvQya3H+KorS/M9rSNyfCGCg9WZ4pyT/lCxIlpJgG1GXW/PswzC84Tr2fBYi+7+jFVQQBw=="
}, },
"bootstrap-icons": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/bootstrap-icons/-/bootstrap-icons-1.5.0.tgz",
"integrity": "sha512-44feMc7DE1Ccpsas/1wioN8ewFJNquvi5FewA06wLnqct7CwMdGDVy41ieHaacogzDqLfG8nADIvMNp9e4bfbA=="
},
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
...@@ -10176,6 +10181,11 @@ ...@@ -10176,6 +10181,11 @@
"minimist": "^1.2.5" "minimist": "^1.2.5"
} }
}, },
"moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
},
"move-concurrently": { "move-concurrently": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
"@testing-library/react": "^11.2.6", "@testing-library/react": "^11.2.6",
"@testing-library/user-event": "^12.8.3", "@testing-library/user-event": "^12.8.3",
"bootstrap": "^4.6.0", "bootstrap": "^4.6.0",
"bootstrap-icons": "^1.5.0",
"moment": "^2.29.1",
"react": "^17.0.2", "react": "^17.0.2",
"react-bootstrap-icons": "^1.5.0", "react-bootstrap-icons": "^1.5.0",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
......
...@@ -6,6 +6,7 @@ import AddFinance from './add_financial_details'; ...@@ -6,6 +6,7 @@ import AddFinance from './add_financial_details';
import ViewFinance from './view_financial_details'; import ViewFinance from './view_financial_details';
import EditFinance from './edit_financial_details'; import EditFinance from './edit_financial_details';
import AddClass from './add_class_details'; import AddClass from './add_class_details';
import studentRequest from './StudentRequestForClass';
export default class Dashboard extends Component { export default class Dashboard extends Component {
render() { render() {
...@@ -358,10 +359,10 @@ export default class Dashboard extends Component { ...@@ -358,10 +359,10 @@ export default class Dashboard extends Component {
</NavLink> </NavLink>
</li> </li>
<li> <li>
<a href="#"> <NavLink to={"/admin/classes/studentRequests/"}>
<i className="metismenu-icon"></i> <i className="metismenu-icon"></i>
Schedule Student Requests
</a> </NavLink>
</li> </li>
<li> <li>
<a href="#"> <a href="#">
...@@ -452,6 +453,7 @@ export default class Dashboard extends Component { ...@@ -452,6 +453,7 @@ export default class Dashboard extends Component {
<Route path="/admin/finance/add" exact component={AddFinance} /> <Route path="/admin/finance/add" exact component={AddFinance} />
<Route path={"/admin/finance/edit/:id"} exact component={EditFinance}/> <Route path={"/admin/finance/edit/:id"} exact component={EditFinance}/>
<Route path="/admin/classes/add" exact component={AddClass}/> <Route path="/admin/classes/add" exact component={AddClass}/>
<Route path="/admin/classes/studentRequests" exact component={studentRequest}/>
</div> </div>
{/* Footer */} {/* Footer */}
......
import React, {Component} from "react"; import React, {Component} from "react";
import Dropdown from 'react-dropdown';
import StarRatingComponent from 'react-star-rating-component';
import 'react-dropdown/style.css'; import 'react-dropdown/style.css';
import MianImage from "../Images/mainimage2.jpg"; import MianImage from "../Images/mainimage2.jpg";
import RecommendIcon from "../Images/recomended.png"; import RecommendIcon from "../Images/recomended.png";
...@@ -100,11 +98,11 @@ export default class Home extends Component{ ...@@ -100,11 +98,11 @@ export default class Home extends Component{
if(this.state.TutorFilteredList.length > 0){ if(this.state.TutorFilteredList.length > 0){
if(this.state.TotalRecommendationCount <= 100){ if(this.state.TotalRecommendationCount === 100){
this.getRecommendation(); this.getRecommendation();
} }
else{ else{
swal("Sorry", "Total Filter value Count is not correct. \nPlease Set Total Filter Value as less than or equal to 100.", "warning"); swal("Sorry", "Total Filter value Count is not correct. \nPlease Set Total Filter Value as equal to 100.", "warning");
} }
} }
else { else {
...@@ -186,24 +184,72 @@ export default class Home extends Component{ ...@@ -186,24 +184,72 @@ export default class Home extends Component{
}); });
} }
OnChangeIsCRPastResults(e) { OnChangeIsCRPastResults(e) {
this.setState({ if(this.state.isRVPastResults){
isRVPastResults: e.target.value this.setState({
}); isRVPastResults: false,
RVPastResults : 0
},()=>{
this.calculateTotalRecommendationCount();
});
}
else {
this.setState({
isRVPastResults: true
});
}
} }
OnChangeIsCRRatings(e) { OnChangeIsCRRatings(e) {
this.setState({ if(this.state.isRVRatings){
isRVRatings: e.target.value this.setState({
}); isRVRatings: false,
RVRatings : 0
},()=>{
this.calculateTotalRecommendationCount();
});
}
else {
this.setState({
isRVRatings: true
});
}
} }
OnChangeIsCRReviews(e) { OnChangeIsCRReviews(e) {
this.setState({ if(this.state.isRVReviews){
isRVReviews: e.target.value this.setState({
}); isRVReviews: false,
RVReviews : 0
},()=>{
this.calculateTotalRecommendationCount();
});
}
else {
this.setState({
isRVReviews: true
});
}
} }
OnChangeIsCRStudentCount(e) { OnChangeIsCRStudentCount(e) {
this.setState({ if(this.state.isStudentCount){
isStudentCount: e.target.value this.setState({
}); isStudentCount: false,
RVStudentCount : 0
},()=>{
this.calculateTotalRecommendationCount();
});
}
else {
this.setState({
isStudentCount: true
});
}
} }
OnChangeStream(e) { OnChangeStream(e) {
...@@ -336,13 +382,19 @@ export default class Home extends Component{ ...@@ -336,13 +382,19 @@ export default class Home extends Component{
tutor_qualification: tutor.tutor_qualification, tutor_qualification: tutor.tutor_qualification,
tutor_reviewValue: tutor.tutor_reviewValue, tutor_reviewValue: tutor.tutor_reviewValue,
tutor_avg_rating : tutor.tutor_avg_rating, tutor_avg_rating : tutor.tutor_avg_rating,
tutor_finalScore : FinalScore tutor_finalScore : FinalScore,
tutor_review_count : tutor.tutor_review_count
} }
TutorFinalList.push(temp); TutorFinalList.push(temp);
}) })
TutorFinalList.sort((a,b) => b.tutor_finalScore - a.tutor_finalScore);
this.setState({ this.setState({
TutorFilteredListFinal : TutorFinalList TutorFilteredListFinal : TutorFinalList
},()=>{
if(this.state.TotalRecommendationCount === 0){
swal("Ops!!!", "You are not added any Filters...\nPlease add filters to get correct recommendation", "warning");
}
}) })
} }
...@@ -455,7 +507,7 @@ export default class Home extends Component{ ...@@ -455,7 +507,7 @@ export default class Home extends Component{
</div> </div>
</div> </div>
<div className="row" style={{marginRight:'50px', marginLeft:'50px',marginTop:'10px', padding:'10px',background:'#1E4258'}}> <div className="row" style={{marginRight:'50px', marginLeft:'50px',marginTop:'10px', padding:'10px',background:'#1E4258'}}>
<h5 style={{color:"white", float:'left'}}>Customized Recommendation</h5> <h5 style={{color:"white", float:'left'}}>Customized Your Recommendation</h5>
</div> </div>
{this.state.isClickFilterArrow ? {this.state.isClickFilterArrow ?
...@@ -655,13 +707,11 @@ export default class Home extends Component{ ...@@ -655,13 +707,11 @@ export default class Home extends Component{
<div className="row" style={{justifyContent:'center'}}> <div className="row" style={{justifyContent:'center'}}>
{this.state.isClickFilterArrow ? {this.state.isClickFilterArrow ?
<button className="form-control" style={{width:'5%',height:'50px'}} onClick={this.onClickFilterArrow}> <button className="form-control" style={{width:'5%',height:'50px'}} onClick={this.onClickFilterArrow}>
<span style={{margin: '20px', cursor: 'pointer'}} ><Icon.ArrowBarUp color="#444444" <span style={{margin: '5px', cursor: 'pointer'}} ><Icon.ArrowBarUp color="#444444" size={35}/></span>
size={35}/></span>
</button> </button>
: :
<button className="form-control" style={{width:'5%',height:'50px'}} onClick={this.onClickFilterArrow}> <button className="form-control" style={{width:'5%',height:'50px'}} onClick={this.onClickFilterArrow}>
<span style={{margin: '20px', cursor: 'pointer'}}><Icon.ArrowBarDown color="#444444" <span style={{margin: '5px', cursor: 'pointer'}}><Icon.ArrowBarDown color="#444444" size={35}/></span>
size={35}/></span>
</button> </button>
} }
</div> </div>
......
...@@ -64,7 +64,7 @@ export default class TutorCard extends Component{ ...@@ -64,7 +64,7 @@ export default class TutorCard extends Component{
<img src={Star} style={{width:'20px', height:'20px'}}/> <img src={Star} style={{width:'20px', height:'20px'}}/>
</div> </div>
<div className="col" > <div className="col" >
<h5 style={{float:"left"}}>5</h5> <h5 style={{float:"left"}}>{this.props.data.tutor_avg_rating.toFixed(1)}</h5>
</div> </div>
</div> </div>
<div className="row"> <div className="row">
...@@ -72,7 +72,7 @@ export default class TutorCard extends Component{ ...@@ -72,7 +72,7 @@ export default class TutorCard extends Component{
<img src={ReviewImg} style={{width:'20px', height:'20px'}}/> <img src={ReviewImg} style={{width:'20px', height:'20px'}}/>
</div> </div>
<div className="col"> <div className="col">
<h5 style={{float:"left"}}>23 reviews</h5> <h5 style={{float:"left"}}>{this.props.data.tutor_review_count} reviews</h5>
</div> </div>
</div> </div>
<div className="row"> <div className="row">
...@@ -84,7 +84,8 @@ export default class TutorCard extends Component{ ...@@ -84,7 +84,8 @@ export default class TutorCard extends Component{
</div> </div>
</div> </div>
<div className="row"> <div className="row">
<button className="form-control" style={{background:"#216E9B", color:"white", marginLeft:'15px', marginRight:'15px'}}><b>View Profile</b></button> <button className="form-control" value={this.props.data._id}
style={{background:"#216E9B", color:"white", marginLeft:'15px', marginRight:'15px'}}><b>View Profile</b></button>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment