Commit 5fdf3eef authored by Hasitha Samarasekara's avatar Hasitha Samarasekara

Add class view popup and student request to class with db request

parent 7bc7617b
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();
let classes = require('../models/createClass.model');
let student = require('../models/student.user.model');
let studentList = require('../models/ClassStudentList.model');
let studentRequestList = require('../models/ClassStudentRquestList.model');
const mongoose = require("mongoose");
router.route('/add').post(async(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;
\ No newline at end of file
......@@ -27,9 +27,9 @@ export default class AdvertisementTopSmall extends Component{
<div className="row">
<div className="col">
<Carousel style={{width:'100%',height:'100px', marginLeft:'20px'}} nextLabel={false} prevLabel={false} indicators={false} >
<Carousel style={{width:'100%',height:'100px', margin:'10px'}} nextLabel={false} prevLabel={false} indicators={false} >
<Carousel.Item>
<img
<img style={{width:'90%'}}
className="toast-bottom-full-width"
src={AddR1}
alt="First slide"
......@@ -39,7 +39,7 @@ export default class AdvertisementTopSmall extends Component{
</Carousel.Caption>
</Carousel.Item>
<Carousel.Item>
<img
<img style={{width:'90%'}}
className="d-block w-100"
src={AddR1}
alt="Second slide"
......@@ -64,9 +64,9 @@ export default class AdvertisementTopSmall extends Component{
</div>
<div className="col">
<Carousel style={{width:'100%',height:'100px', marginLeft:'20px'}} nextLabel={false} prevLabel={false} indicators={false} >
<Carousel style={{width:'100%',height:'100px', margin:'10px'}} nextLabel={false} prevLabel={false} indicators={false} >
<Carousel.Item>
<img
<img style={{width:'90%'}}
className="toast-bottom-full-width"
src={AddR1}
alt="First slide"
......@@ -76,7 +76,7 @@ export default class AdvertisementTopSmall extends Component{
</Carousel.Caption>
</Carousel.Item>
<Carousel.Item>
<img
<img style={{width:'90%'}}
className="d-block w-100"
src={AddR1}
alt="Second slide"
......
......@@ -65,8 +65,9 @@ export default class NavBar extends Component {
top: '15px',
right: '120px',
color: '#EAE4E4',
marginRight: '50px'
}}><h5>{this.state.user_name !== null ? <span style={{cursor:'pointer'}} onClick={()=>{ window.location.replace("/studentDashboard");}}> {this.state.user_name}</span> : <label onClick={() => {
marginRight: '50px',
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 = '/UserLogin';
}}>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