Commit 30549259 authored by Hasitha Samarasekara's avatar Hasitha Samarasekara

Merge branch 'IT18063288' into 'master'

It18063288

See merge request !19
parents 98164579 5fdf3eef
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const ClassStudentRequestSchema = new Schema({
class_id:{type:mongoose.Schema.Types.ObjectId,ref: 'Classes'},
student_id:{type:mongoose.Schema.Types.ObjectId,ref: 'student'},
tutor_id:{type:mongoose.Schema.Types.ObjectId,ref: 'tutor'},
},{
timestamps:true,
});
const ClassStudentRequestList = mongoose.model('ClassStudentRequestList',ClassStudentRequestSchema);
module.exports = ClassStudentRequestList;
\ No newline at end of file
...@@ -2,6 +2,7 @@ const router = require('express').Router(); ...@@ -2,6 +2,7 @@ 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 student = require('../models/student.user.model');
let studentList = require('../models/ClassStudentList.model'); let studentList = require('../models/ClassStudentList.model');
let studentRequestList = require('../models/ClassStudentRquestList.model');
const mongoose = require("mongoose"); const mongoose = require("mongoose");
router.route('/add').post(async(req,res) =>{ router.route('/add').post(async(req,res) =>{
...@@ -161,4 +162,64 @@ router.route('/studentList/:id').get(function (req, res) { ...@@ -161,4 +162,64 @@ router.route('/studentList/:id').get(function (req, res) {
}); });
}); });
router.route('/studentRequestList/add').post((req, res) => {
const class_id = req.body._id;
const student_id = req.body.student_id;
const tutor_id = req.body.tutor_id;
console.log("classID: " + class_id);
console.log("student_nic: " + student_id);
classes.findById(class_id,function(err, tutorsClass){
if(!tutorsClass)
res.status(404).send("Sorry Class Could not Found.");
else {
student.find({"_id": student_id}).then(student => {
console.log(student)
console.log(student[0]._id)
if(student[0].student_nic === ""){
res.status(500).send("Sorry, This Student Not Registered");
}else{
const student_id = student[0]._id;
const newClassStudent = new studentRequestList({
class_id,
student_id,
tutor_id
});
studentRequestList.find({"student_id" : student_id, "class_id" : class_id}).then(reqClass =>{
console.log("reqClass : ")
console.log(reqClass)
if(reqClass.length > 0){
res.status(501).send("Already Request to this Class");
}
else{
newClassStudent.save().then(result =>{
res.json('Student Requested is complete!');
})
.catch(err =>{
res.status(500).send("Update not possible");
});
}
})
}
}).catch(err => res.status(500).json('Eroor: '+ err));
}
});
});
module.exports = router; module.exports = router;
\ No newline at end of file
...@@ -14,11 +14,9 @@ import Dashboard from "./Components/Admin/Dashboard"; ...@@ -14,11 +14,9 @@ import Dashboard from "./Components/Admin/Dashboard";
import StudentDashboard from "./Components/Student/StudentDashboard"; import StudentDashboard from "./Components/Student/StudentDashboard";
import QuestionDetails from "./Components/IT18050240/question_details" import QuestionDetails from "./Components/IT18050240/question_details"
import QuestionLayout from "./Components/IT18050240/question_layout" 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 QuestionBank from "./Components/IT18050240/question_bank"
import LessonAndExam from "./Components/IT18050240/lessonandexampage"; import TutorProfileView from "./Components/HomePage/TutorProfileView";
import AutomaticQuestion from "./Components/IT18050240/automatic_question"
import Upload from "./Components/IT18050240/UploadPage";
function App() { function App() {
return ( return (
...@@ -30,7 +28,8 @@ function App() { ...@@ -30,7 +28,8 @@ function App() {
<Route path="/SignUp" exact component={SignUp}/> <Route path="/SignUp" exact component={SignUp}/>
<Route path="/beforeConfirm" exact component={beforeConfirmation}/> <Route path="/beforeConfirm" exact component={beforeConfirmation}/>
<Route path="/AccountVerified/:id" exact component={VerifiedAccount}/> <Route path="/AccountVerified/:id" exact component={VerifiedAccount}/>
{/*<Route path="/studentDashboard" exact component={StudentDashboard}/>*/} <Route path="/Home/ViewProfile/:id" exact component={TutorProfileView}/>
<Route path="/studentDashboard" exact component={StudentDashboard}/>
{/*<Route path="/" exact component={Dashboard}/>*/} {/*<Route path="/" exact component={Dashboard}/>*/}
...@@ -38,13 +37,10 @@ function App() { ...@@ -38,13 +37,10 @@ function App() {
<Route path="/admin"><Dashboard/></Route> <Route path="/admin"><Dashboard/></Route>
<Route path="/studentDashboard"><StudentDashboard/></Route> <Route path="/studentDashboard"><StudentDashboard/></Route>
<Route path="/questiondetails" exact component={QuestionDetails}/> <Route path="/questiondetails" exact component={QuestionDetails}/>
<Route path="/question/:id" exact component={QuestionLayout}/> <Route path="/question" exact component={QuestionLayout}/>
<Route path="/questionmanagement/:id" exact component={AdminQuestionManagement}/> {/*<Route path="/questionmanagement" exact component={AdminQuestionManagement}/>*/}
<Route path="/questionbank" exact component={QuestionBank}/> <Route path="/questionbank" exact component={QuestionBank}/>
<Route path="/questionmanagement" exact component={AdminQuestionManagement}/> {/*<Route path="/edititem/:id" exact component={AdminQuestionManagement}/>*/}
<Route path="/lesson" exact component={LessonAndExam}/>
<Route path="/automaticquestion" exact component={AutomaticQuestion}/>
<Route path="/upload" exact component={Upload}/>
</Switch> </Switch>
......
...@@ -15,6 +15,7 @@ import * as Icon from 'react-bootstrap-icons'; ...@@ -15,6 +15,7 @@ import * as Icon from 'react-bootstrap-icons';
import axios from "axios"; import axios from "axios";
import * as configs from "../Config/config"; import * as configs from "../Config/config";
import TutorCard from "./HomePage/TutorCard"; import TutorCard from "./HomePage/TutorCard";
import RightSideAdd from "./HomePage/AdvertisementRightSide";
import swal from "sweetalert"; import swal from "sweetalert";
import Carousel from "react-bootstrap/Carousel"; import Carousel from "react-bootstrap/Carousel";
...@@ -414,6 +415,16 @@ export default class Home extends Component { ...@@ -414,6 +415,16 @@ export default class Home extends Component {
let FinalStudentCountScore = (valueForStudentCount * Number(this.state.RVStudentCount)) / 100; let FinalStudentCountScore = (valueForStudentCount * Number(this.state.RVStudentCount)) / 100;
let FinalScore = finalReviewScore + FinalRatingScore + FinalStudentCountScore; let FinalScore = finalReviewScore + FinalRatingScore + FinalStudentCountScore;
let oneday = 24 * 60 * 60 * 1000;
let NoOFDays = (todayDate - new Date(tutor.tutor_registered_date));
let NoOFDaysRegistered = Math.ceil(NoOFDays / oneday);
// if((todayDate - tutor.tutor_registered_date.getDate()) > ){
//
// }
if (NoOFDaysRegistered >= 365 && Number(tutor.tutor_review_count) > 10) {
const temp = { const temp = {
tutor_id: tutor.teacher, tutor_id: tutor.teacher,
tutor_name: tutor.tutor_name, tutor_name: tutor.tutor_name,
...@@ -426,19 +437,27 @@ export default class Home extends Component { ...@@ -426,19 +437,27 @@ export default class Home extends Component {
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 tutor_review_count: tutor.tutor_review_count,
recommended_ : true
} }
let oneday = 24 * 60 * 60 * 1000;
let NoOFDays = (todayDate - new Date(tutor.tutor_registered_date));
let NoOFDaysRegistered = Math.ceil(NoOFDays / oneday);
// if((todayDate - tutor.tutor_registered_date.getDate()) > ){
//
// }
if (NoOFDaysRegistered >= 365 && Number(tutor.tutor_review_count) > 10) {
TutorRecommendedFinalList.push(temp); TutorRecommendedFinalList.push(temp);
} else { } else {
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,
tutor_review_count: tutor.tutor_review_count,
recommended_ : false
}
TutorOnlyFilterFinalList.push(temp); TutorOnlyFilterFinalList.push(temp);
} }
...@@ -880,24 +899,26 @@ export default class Home extends Component { ...@@ -880,24 +899,26 @@ export default class Home extends Component {
} }
</div> </div>
<div className="row" <div className="row"
style={{background: '#F5F4ED', marginLeft: '50px', marginRight: '50px', marginTop: '10px'}}> style={{background: '#1E4258', marginLeft: '50px', marginRight: '50px', marginTop: '10px'}}>
<h5 style={{margin: '10px'}}>{this.state.TutorFilteredList.length} Results</h5> <h5 style={{color: "white", float: 'left',margin: '15px'}}>{this.state.TutorFilteredList.length} Results</h5>
</div> </div>
<div className="row">
<div className="col-8">
{this.state.TutorFilteredRecommendedListFinal.length > 0 ? {this.state.TutorFilteredRecommendedListFinal.length > 0 ?
<div className="row" <div className="row"
style={{ style={{
background: '#F5F4ED', background: '#1E4258',
marginLeft: '50px', marginLeft: '50px',
marginRight: '50px', marginRight: '0px',
marginTop: '10px' marginTop: '10px'
}}> }}>
<h4>Recommended List</h4> <h4 style={{color: "white", float: 'left',margin: '15px'}}>Recommended List</h4>
</div> </div>
: :
<div> <div>
</div> </div>
} }
<div className=""> <div className="" style={{marginLeft:'50px',marginRight:'0px'}}>
{this.state.TutorFilteredRecommendedListFinal.length > 0 ? this.state.TutorFilteredRecommendedListFinal.map((card) => { {this.state.TutorFilteredRecommendedListFinal.length > 0 ? this.state.TutorFilteredRecommendedListFinal.map((card) => {
return (<TutorCard data={card}/>) return (<TutorCard data={card}/>)
}) : <div></div>} }) : <div></div>}
...@@ -906,24 +927,35 @@ export default class Home extends Component { ...@@ -906,24 +927,35 @@ export default class Home extends Component {
{this.state.TutorOnlyFilteredListFinal.length > 0 ? {this.state.TutorOnlyFilteredListFinal.length > 0 ?
<div className="row" style={{ <div className="row" style={{
background: '#F5F4ED', background: '#1E4258',
marginLeft: '50px', marginLeft: '50px',
marginRight: '50px', marginRight: '0px',
marginTop: '10px' marginTop: '10px'
}}> }}>
<h4>Filtered List</h4> <h4 style={{color: "white", float: 'left',margin: '15px'}}>Filtered List</h4>
</div> </div>
: :
<div> <div>
</div> </div>
} }
<div className=""> <div className="" style={{marginLeft:'50px',marginRight:'0px'}}>
{this.state.TutorOnlyFilteredListFinal.length > 0 ? this.state.TutorOnlyFilteredListFinal.map((card) => { {this.state.TutorOnlyFilteredListFinal.length > 0 ? this.state.TutorOnlyFilteredListFinal.map((card) => {
return (<TutorCard data={card}/>) return (<TutorCard data={card}/>)
}) : <div></div>} }) : <div></div>}
</div> </div>
</div>
<div className="col-3">
{this.state.TutorOnlyFilteredListFinal.length > 0 ?
<RightSideAdd></RightSideAdd>
:
<div>
</div>
}
</div>
</div>
<div className="app-main__outer"> <div className="app-main__outer">
<HomeFooter/> <HomeFooter/>
......
import React, {Component} from "react";
import Carousel from "react-bootstrap/Carousel";
import AddR1 from "../../Images/ad_r1.jpg";
import AddR2 from "../../Images/ad_r2.jpg";
export default class AdvertisementRightSide extends Component{
constructor(props) {
super(props);
this.state = {
};
//this.FindTutor = this.FindTutor.bind(this);
}
render() {
return(
<div>
<Carousel style={{width:'100%'}} nextLabel={false} prevLabel={false} indicators={false} >
<Carousel.Item>
<img
className="toast-bottom-full-width"
src={AddR1}
alt="First slide"
/>
<Carousel.Caption>
</Carousel.Caption>
</Carousel.Item>
<Carousel.Item>
<img
className="d-block w-100"
src={AddR2}
alt="Second slide"
/>
<Carousel.Caption>
</Carousel.Caption>
</Carousel.Item>
{/*<Carousel.Item>*/}
{/* <img*/}
{/* className="d-block w-100"*/}
{/* src={AddR1}*/}
{/* alt="Third slide"*/}
{/* />*/}
{/* <Carousel.Caption>*/}
{/* </Carousel.Caption>*/}
{/*</Carousel.Item>*/}
</Carousel>
</div>
)
}
}
\ No newline at end of file
import React, {Component} from "react";
import Carousel from "react-bootstrap/Carousel";
import AddR1 from "../../Images/ad_top_s_01.jpg";
import AddR2 from "../../Images/ad_r2.jpg";
export default class AdvertisementTopSmall extends Component{
constructor(props) {
super(props);
this.state = {
};
//this.FindTutor = this.FindTutor.bind(this);
}
render() {
return(
<div className="row">
<div className="col">
<Carousel style={{width:'100%',height:'100px', margin:'10px'}} nextLabel={false} prevLabel={false} indicators={false} >
<Carousel.Item>
<img style={{width:'90%'}}
className="toast-bottom-full-width"
src={AddR1}
alt="First slide"
/>
<Carousel.Caption>
</Carousel.Caption>
</Carousel.Item>
<Carousel.Item>
<img style={{width:'90%'}}
className="d-block w-100"
src={AddR1}
alt="Second slide"
/>
<Carousel.Caption>
</Carousel.Caption>
</Carousel.Item>
{/*<Carousel.Item>*/}
{/* <img*/}
{/* className="d-block w-100"*/}
{/* src={AddR1}*/}
{/* alt="Third slide"*/}
{/* />*/}
{/* <Carousel.Caption>*/}
{/* </Carousel.Caption>*/}
{/*</Carousel.Item>*/}
</Carousel>
</div>
<div className="col">
<Carousel style={{width:'100%',height:'100px', margin:'10px'}} nextLabel={false} prevLabel={false} indicators={false} >
<Carousel.Item>
<img style={{width:'90%'}}
className="toast-bottom-full-width"
src={AddR1}
alt="First slide"
/>
<Carousel.Caption>
</Carousel.Caption>
</Carousel.Item>
<Carousel.Item>
<img style={{width:'90%'}}
className="d-block w-100"
src={AddR1}
alt="Second slide"
/>
<Carousel.Caption>
</Carousel.Caption>
</Carousel.Item>
{/*<Carousel.Item>*/}
{/* <img*/}
{/* className="d-block w-100"*/}
{/* src={AddR1}*/}
{/* alt="Third slide"*/}
{/* />*/}
{/* <Carousel.Caption>*/}
{/* </Carousel.Caption>*/}
{/*</Carousel.Item>*/}
</Carousel>
</div>
</div>
)
}
}
\ No newline at end of file
...@@ -15,8 +15,8 @@ export default class TutorCard extends Component{ ...@@ -15,8 +15,8 @@ export default class TutorCard extends Component{
render() { render() {
return( return(
<div className="main-card mb-3 card"> <div className="main-card mb-3 card">
<div className="row" style={{background:'#F5F4ED', marginLeft:'50px', marginRight:'50px', marginTop:'10px', marginBottom:'10px'}}> <div className="row" style={{background:'#F5F4ED', marginLeft:'10px', marginRight:'10px', marginTop:'10px', marginBottom:'10px'}}>
<div className="col-9"> <div className="col">
<div className="row" style={{background:'#F8F8F8'}}> <div className="row" style={{background:'#F8F8F8'}}>
<div className="col-8" style={{margin:'5px', border:'solid', padding:'10px', borderColor:'#216E9B'}}> <div className="col-8" style={{margin:'5px', border:'solid', padding:'10px', borderColor:'#216E9B'}}>
<div className="row"> <div className="row">
...@@ -60,6 +60,8 @@ export default class TutorCard extends Component{ ...@@ -60,6 +60,8 @@ export default class TutorCard extends Component{
</div> </div>
</div> </div>
<div className="col" style={{margin:'5px', border:'solid', padding:'10px', borderColor:'#216E9B'}}> <div className="col" style={{margin:'5px', border:'solid', padding:'10px', borderColor:'#216E9B'}}>
<div className="row">
<div className="col">
<div className="row"> <div className="row">
<div className="col-1"> <div className="col-1">
<img src={Star} style={{width:'20px', height:'20px'}}/> <img src={Star} style={{width:'20px', height:'20px'}}/>
...@@ -90,15 +92,22 @@ export default class TutorCard extends Component{ ...@@ -90,15 +92,22 @@ export default class TutorCard extends Component{
style={{background:"#216E9B", color:"white", marginLeft:'15px', marginRight:'15px'}}><b>View Profile</b></button></Link> style={{background:"#216E9B", color:"white", marginLeft:'15px', marginRight:'15px'}}><b>View Profile</b></button></Link>
</div> </div>
</div> </div>
<div className="col-">
{this.props.data.recommended_ ?
<img src={RecommendIcon} style={{width:'80px', height:'70px', float:'left', margin:'10px'}}/>
:
<div>
</div> </div>
}
</div> </div>
<div className="col" style={{background:'#F8F8F8'}}>
<div>
<br/>
</div> </div>
<img src={RecommendIcon} style={{width:'100px', height:'90px', float:'left', margin:'10px'}}/>
</div> </div>
</div>
</div>
</div> </div>
</div> </div>
......
...@@ -65,8 +65,9 @@ export default class NavBar extends Component { ...@@ -65,8 +65,9 @@ export default class NavBar extends Component {
top: '15px', top: '15px',
right: '120px', right: '120px',
color: '#EAE4E4', color: '#EAE4E4',
marginRight: '50px' marginRight: '50px',
}}><h5>{this.state.user_name !== null ? <span style={{cursor:'pointer'}} onClick={()=>{ window.location.replace("/studentDashboard");}}> {this.state.user_name}</span> : <label onClick={() => { cursor:'pointer'
}}><h5>{this.state.user_name !== null ? <span style={{cursor:'pointer'}} onClick={()=>{ window.location.replace("/studentDashboard");}}> {this.state.user_name}</span> : <label style={{cursor:'pointer'}} onClick={() => {
// window.location.replace("UserLogin"); // window.location.replace("UserLogin");
window.location = '/UserLogin'; window.location = '/UserLogin';
}}>Login</label>} </h5></label> }}>Login</label>} </h5></label>
......
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