Skip to content

Repository files navigation

Asyad El Code

Badges

MongoDBExpress.jsJWTMUINodeJSGitHubRedux

Table of Contents

Motiviation 🔥

The project itself aims to be a valuable resource for people looking to improve their skills and knowledge. It provides a convenient and accessible way for people to learn new things and achieve their goals through online courses and exercises. By offering the opportunity to practice and apply what they have learned, the project helps students not only learn new information, but also test their understanding and retain it for longer periods of time. The project strives to be the best it can be and continues to work towards this goal.

Build Status 🦾

Build Status

  • The project is currently in development.
  • Unit tests will be added.

Code Style ✍️

Code Style

  • Camel Case in variable names used

You can then run Prettier on your code by using the prettier command in your terminal. For example:

prettier --write "src/**/*.js"

Project Description

Course

Advanced Computer Lab (CSEN 704/ DMET 706), Winter 2022

Theme

Our project is an online learning platform that allows both individual and corporate trainees to enroll in a variety of courses and track their progress as they work towards earning a certificate of completion. The platform features a range of courses taught by experienced instructors who have created engaging lectures and quizzes to help students master the material. In addition to providing a convenient and flexible way for learners to gain new skills and knowledge, the platform also offers tools for instructors to manage their courses and for admins to track and address any issues that may arise, such as requests for refunds or reports of problems. Whether you're looking to advance your career, learn a new hobby, or simply expand your horizons, our platform is a great resource for anyone looking to learn and grow.

Overview

Our project was developed using the Agile Methodology, which involves breaking the project into shorter time periods called "Sprints." Each Sprint has a specific set of goals, and at the end of each Sprint, a fully functional version of the project is delivered and evaluated based on the specified system requirements. This approach allows for a more flexible and responsive development process, as it allows for ongoing adjustments and improvements to be made based on feedback and changing needs.

Objectives

  • Gain an understanding of how to effectively utilize the Agile Methodology for project planning and software development
  • Learn the process of following a given set of System Requirements to develop a software.
  • Learn to research and master the use of the MERN Stack.
  • Learn how to work together as a team on GitHub.

Tech and Framework used 🧰

Features

Feature🔰 Status
Authentiation✔️
Authorization✔️
User Roles✔️
Payments✔️
User Email Notifications✔️
User Password Reset✔️
REST API✔️
Validation using JOI✔️

LICENSE

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Screenshots 📗

  • Home Page

Screenshot 2023-01-05 at 3 44 10 AM

Screenshot 2023-01-05 at 3 47 04 AM

Individual Trainee

  • Sign up and enter their details in a form including first name, last name, email, password and gender.

Screenshot 2023-01-01 at 5 08 57 PM

  • Sign in using his email and password.

Screenshot 2023-01-02 at 3 39 15 AM

  • Send email in case of forgetting password.

Screenshot 2023-01-02 at 3 41 42 AM

  • Change password

Screenshot 2023-01-02 at 3 42 41 AM

  • View your profile

Screenshot 2023-01-02 at 3 43 24 AM

  • View Course

Screenshot 2023-01-05 at 3 24 15 AM

  • View Course Content

  • Watching Video

Screenshot 2023-01-05 at 8 57 42 PM

Screenshot 2023-01-05 at 3 22 00 AM

Screenshot 2023-01-05 at 3 22 51 AM

  • See Your Certificate

Screenshot 2023-01-05 at 3 23 02 AM

  • Rating The Course

Screenshot 2023-01-05 at 3 23 51 AM

  • See Resolved Problems

Screenshot 2023-01-05 at 3 25 15 AM

  • Solving Exercise

Screenshot 2023-01-05 at 3 36 47 AM

Instructor

  • Creating Course

Screenshot 2023-01-05 at 3 27 20 AM

Screenshot 2023-01-05 at 3 27 39 AM

Screenshot 2023-01-05 at 3 28 44 AM

Screenshot 2023-01-05 at 3 28 56 AM

Admin Dashboard

Screenshot 2023-01-05 at 3 44 34 AM

Meet our team

Team

Configuration and Setup 🔓

In order to run this project locally, simply fork and clone the repository or download as zip and unzip on your machine.

  • Open the project in your prefered code editor.
  • Go to terminal -> New terminal (If you are using VS code)
  • Split your terminal into two (run the client on one terminal and the server on the other terminal)

In order to use ES6 MODULE in node js.

>cd server
> find `package.json`> below `main` enter a new key-value pair called `type = module`

In the first terminal

> git clone https://github.com/Advanced-Computer-Lab-2022/Asyad-El-Code.git
>cd Asyad-El-Code/
>cd server & npm i & cd..
>cd client & npm i

Backend

cd server && npm start

Frontend

cd client && npm start

Environment Variables

Add this keys to .env file to run project

PORT

MONGO_URI

TOKEN_KEY

HOST

USER

PASS

SERVICE

STRIPE_PRIVATE_KEY

Code Example 💻


exportconstRatingAndReviewPopup=({
ratingOpen,
handleCancelRating,
handleSubmit,})=>{constdispatch=useDispatch();const[ratingValue,setRatingValue]=useState(0);const[review,setReview]=useState("");//update RatingOpen to false when cancel button is clickedconsthandleCancel=()=>{handleCancelRating();};consthandleClick=()=>{handleSubmit(ratingValue,review);};return(<><Dialogopen={ratingOpen}><DialogTitle>Add a rating and review for the course</DialogTitle><DialogContent><DialogContentText>Add a rating from 1 to 5</DialogContentText><Ratingname="simple-controlled-rating"value={ratingValue}onChange={(event,newValue)=>{setRatingValue(newValue);}}/><DialogContentText>Add a review</DialogContentText><TextFieldid="outlined-multiline-static"label="Review"multilinerows={4}defaultValue=""variant="outlined"onChange={(e)=>setReview(e.target.value)}/></DialogContent><DialogActions><Buttonvariant="outlined"color="primary"onClick={handleClick}>
Submit
</Button><Buttonvariant="outlined"color="primary"onClick={handleCancel}>
Cancel
</Button></DialogActions></Dialog></>);
exportconstupdateRating=async(req,res)=>{try{constid=mongoose.Types.ObjectId(req.params.id);const{ rating }=req.body;constinstructor=awaitInstructor.findById(id);if(!instructor)returnres.status(404).send("instructor not found");constupdatedInstructor=awaitInstructor.findByIdAndUpdate(id,{rating: rating},{new: true});res.status(200).send(updatedInstructor);}catch(error){res.status(400).send(error.message);}};

END POINTS

Authentication Routes

Create User

POST /signup
HeadersTypeDescription
AuthorizationstringRequired. Bearer token is added.
BodyTypeDescription
firstNamestringRequired. firstName of trainee
lastNamestringRequired. lastName of the trainee
emailstringRequired. email of trainee
passwordstringRequired. password of trainee
genderstringRequired. gender of the trainee
Response
{
"result":{"firstName":"Roberto",
"lastName":"joseph",
"gender":"Male",
"password":"hashedPassword",
"_id":"63b19f456422dcc9bbca8c35",
"courses":[],
"grades":[],
"notes":[],
},
"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"type":"indivdualTrainee"
}

Sign in

POST /signin
HeadersTypeDescription
AuthorizationstringRequired. Bearer token is added.
BodyTypeDescription
emailstringRequired. email of trainee
passwordstringRequired. password of the trainee
Response
{
"result": {
"firstName":"Roberto",
"lastName":"Joseph",
"email":"robertojoseph@gmail.com",
"password":"hashedPassword",
"gender":"Male"
},
"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c","type":"individualTrainee"
}

Forgot Password

POST /sendemail
BodyTypeDescription
emailstringRequired. user email.
 {"email":"robertojoseph@gmail.com"}

Change Password

POST /confirmPassword/:id
ParameterTypeDescription
idstringRequired. user id.
BodyTypeDescription
passwordstringRequired. user new password.
Response
{
"message":"success"
}

Instructor Routes

Filter Instructor Courses
GET /filterInstructorCourses
QueryTypeDescription
idstringRequired. id of instructor
subjectstringRequired. course subject
pricestringRequired. price of course
ratingstringRequired. rating of course
Code Example 💻
exportconstfilterInstructorCourses=async(req,res)=>{try{const{ id, subject, price, rating }=req.query;constsubjectArray=subject.split(/[,]+/);constpriceArray=price.split(/[,]+/);constratingArray=rating.split(/[,]+/);constcourses=awaitCourse.aggregate([{$match: {"instructor.instructorId": mongoose.Types.ObjectId(id)}},{$match: {subject: {$in: subjectArray}}},{$match: {rating: {$lte: parseInt(ratingArray[1])}}},{$match: {rating: {$gte: parseInt(ratingArray[0])}}},{$addFields: {discountedPrice: {$cond: [{$and: [{$lte: ["$promotion.startDate",newDate(Date.now())]},{$gte: ["$promotion.endDate",newDate(Date.now())]},],},{$multiply: ["$price",{$subtract: [1,"$promotion.discount"]},],},"$price",],},},},{$match: {discountedPrice: {$lte: parseInt(priceArray[1])}}},{$match: {discountedPrice: {$gte: parseInt(priceArray[0])}}},]);if(!courses){res.status(404).send("Cannot find Courses for this instructor");}res.status(200).send(courses);}catch(err){res.status(401).send(err);}};
Response
{
"courses":[]
}

Create Instructor

POST /createInstructor
HeaderTypeDescription
AuthorizationstringRequired. role should be admin.
BodyTypeDescription
userNamestringRequired. username of instructor
firstNamestringRequired. firstname of instructor
lastNamestringRequired. lastname of instructor
emailstringRequired. email of instructor
genderstringRequired. gender of instructor
passswordstringRequired. password of instructor
countrystringRequired. country of instructor
phoneNumberstringRequired. phoneNumber of instructor
aboutstringRequired. biography of instructor
dateOfBirthstringRequired. date of birth of instructor
Response
{
"userName": "robertoJoseph",
"firstName": "roberto",
"lastName": "joseph",
"email": "instructor10@gmail.com",
"gender": "Male",
"password": "pass123",
"country": "egypt",
"dateOfBirth": "20/08/2001",
"wallet": "0",
"phoneNumber: "010xxxxxxx","about": "firstInstructor",
}

Get Instructors

GET /instructor
Response
{
"instructors":[]
}

Get Course Titles Given By Instructor

GET /viewTitles/:id
ParameterTypeDescription
idstringRequired. Instructor id.
Response
{
"courses":[]
}

Add Course

POST /addNewCourse
HeaderTypeDescription
AuthorizationstringRequired. Bearer token of the instructor
BodyTypeDescription
titlestringRequired. title of course
summarystringRequired. summary of the course
subjectstringRequired. subject of the course
previewVideostringRequired. preview video of the course
outlinearrayRequired. outline of the course
exercisesarrayRequired. exercises of the course
pricenumberRequired. price of the course
releaseDatestringRequired. releasedate of the course
languagestringRequired. language of the course
imagestringRequired. image of the course
durationnumberRequired. duration of the course
ParameterTypeDescription
idstringRequired. instructor id
Response
{
"title":"course1",
"summary":"This is a nodeJs course",
"price":"500",
"rating":"0",
"previewVideo":"youtube video url",
"outline":{
[
"outline":"Section 1",
"totalHours":"30",
"subtitles":[
{
"subtitle":"lecture1",
"minutes":"13",
"videoUrl":"youtube video url"
}
],
"exercises":[
{
"question":"question1",
"answers":[
{
"answer":"answer1",
"correct":"true",
}
]
}
]
]
},
"price":500,
"instructorId":{ "instructorId":"id", "name": "roberto" },
"ratings":[],
"reviews":[],
"numberOfEnrolledStudents":0,
}

Update Instructor

PATCH /updateInformation/:id
HeaderTypeDescription
AuthorizationstringRequired. Bearer token of the instructor
ParameterTypeDescription
idstringRequired. instructor id
BodyTypeDescription
firstNamestringRequired. first name of the insttrucor
lastNamestringRequired. last name of the instructor
countrystringRequired. country of the instructor
phoneNumberstringRequired. phone number of the instrcutor
Response
{
"firstName":"jannah""lastName":"gabr",
"lastName":"gabr",
"biography":"I teach math",
"phoneNumber":"01092022xxxx",
}

Add Review On Instructor

POST /addReview
QueryTypeDescription
instructorIdstringRequired. id of the instructor
individualTraineeIdstringRequired. id of the trainee
coorporateTraineeIdstringRequired. id of the trainee
reviewstringRequired. review on instrcutor
Response
{
"userName": "robertoJoseph",
"firstName": "roberto",
"lastName": "joseph",
"email": "instructor10@gmail.com",
"gender": "Male",
"password": "pass123",
"country": "egypt",
"dateOfBirth": "20/08/2001",
"wallet": "0",
"phoneNumber": "010xxxxxxx",
"about": "firstInstructor",
"reviews":[
"individualTraineeId":"5f7b11be78b93e73d92366f9",
"review":"el ragel da meya el meya",
]
}

Update Rating

POST /updateRating/:id
HeaderTypeDescription
AuthorizationstringRequired. Bearer token of the instructor
QueryTypeDescription
idstringRequired. id of the instructor
BodyTypeDescription
ratingnumberRequired. rating on the instructor
Response
{
"userName": "robertoJoseph",
"firstName": "roberto",
"lastName": "joseph",
"email": "instructor10@gmail.com",
"gender": "Male",
"password": "pass123",
"country": "egypt",
"dateOfBirth": "20/08/2001",
"wallet": "0",
"phoneNumber: "010xxxxxxx","about": "firstInstructor",
"rating":[
"individualTraineeId":"5f7b11be78b93e73d92366f9",
"rating":5,
]
}

Define Promotion

POST /definePromotion
HeaderTypeDescription
AuthorizationstringRequired. Bearer token of the instructor
ParamTypeDescription
idstringRequired. id of the instructor
BodyTypeDescription
ratingnumberRequired. rating on the instructor
Response
{
"userName": "robertoJoseph",
"firstName": "roberto",
"lastName": "joseph",
"email": "instructor10@gmail.com",
"gender": "Male",
"password": "pass123",
"country": "egypt",
"dateOfBirth": "20/08/2001",
"wallet": "0",
"phoneNumber": "010xxxxxxx",
"about": "firstInstructor",
"rating":[
"individualTraineeId":"5f7b11be78b93e73d92366f9",
"rating":5,
]
}

Get Instructor Courses

GET /getAllInstructorCourses/:id
ParameterTypeDescription
idstringRequired. id of the instructor
Response
{
"courses":[]
}

Trainee Router

Get Notes

GET /getNotes
HeaderTypeDescription
AuthorizationstringRequired. Bearer token of the trainee
QueryTypeDescription
userIdstringRequired. id of trainee
courseIdstringRequired. course id
lectureIdstringRequired. lecture id
Response
 {
"notes": [
{
"subtitleId":"5f7b11be78b93e73d92366f9",
"note": [{ "value": "nice", time: "33" }],
}
]
}

Get Pdf of notes

GET /getPdf
Response
> res,sendFile(`${__dirname}/test.pdf`)

Update Individual Trainee

PUT /:id
ParameterTypeDescription
idstringRequired. Id of trainee
HeaderTypeDescription
AuthorizationstringRequired. Bearer token of trainee
BodyTypeDescription
firstNamestringRequired. first name of trainee
lastNamestringRequired. last name of trainee
phoneNumberstringRequired. phone number of trainee
countrystringRequired. country of trainee
Response { "firstName":"kareem", "lastName":"khedr", "phoneNunber":"010222xxxx", "country":"egypt" }

Enroll in Course

POST /enrollInCourse
HeaderTypeDescription
AuthorizationstringRequired. Bearer token of trainee
BodyTypeDescription
courseIdstringRequired. id of course
Response
 {
"instructor":{
"courses":[
"courseId":"5f7b11be78b93e73d92366f9",
"title":"Course Flutter",
"summary":"yes babe",
"duration":"30",
"releaseDate":"20/8/2019",
"summary":"yes man",
]
}
}

Add Grade

POST /addGrade
HeaderTypeDescription
Authorization stringRequired. Bearer token of trainee
QueryTypeDescription
courseIdstringRequired. id of course
scorenumberRequired. grade of trainee
totalnumberRequired. total grade
individualTraineeIdidRequired. id of trainee
scorenumberRequired. score from the exercise
Response
 {
"grades": [
{
"score": 30,
"total": 50,
"exerciseId": "5f7b11be78b93e73d92366f9",
},
],
}

Add Seen Content

POST /addSeenContent
HeaderTypeDescription
Authorization stringRequired. Bearer token of trainee
QueryTypeDescription
courseIdstringRequired. id of course
outlineIdstringRequired. id of lecture
individualTraineeIdstringRequired. id of trainee
minutesnumberRequired. id of trainee
Response
 {
"seenContent": [
{
"duration": 30,
"contentId": "5f7b11be78b93e73d92366f9",
},
],
}

Add Notes

POST /addNotes
HeaderTypeDescription
Authorization stringRequired. Bearer token of trainee
QueryTypeDescription
courseIdstringRequired. id of course
lectureIdstringRequired. id of lecture
individualTraineeIdstringRequired. id of trainee
notestringRequired. note of trainee
playedMinutesnumberRequired. time of note
Response
 {
"notes": [
{
"subtitleId": "5f7b11be78b93e73d92366f9",
"note": [{ "value": "nice", "time": "33" }],
},
],
}

Get trainee

GET /:id
ParameterTypeDescription
idstringRequired. id of trainee

Create Pdf for notes

```http
GET /getPdf
```
Response
> res,sendFile(`promise.resolve(__dirname)/test.pdf`)

Pay for course

POST /payForCourse
HeaderTypeDescription
Authorization stringRequired. Bearer token of trainee
QueryTypeDescription
coursesarray Required. array of courses to buy
individualTraineeIdstringRequired. id of trainee
instructorIdstringRequired. the instructorId to gain profit
Response
 {
"session":"checkout_session_id"
}

Send Email for certificate

POST /sendEmail
HeaderTypeDescription
Authorization stringRequired. Bearer token of trainee
QueryTypeDescription
courseIdstring Required. id of course
userIdstringRequired. id of trainee
Response
 {
"message":"PDF sent successfully"
}

Get All trainees

GET /
Response
{
"individualTrainees":[]
}

Admin Routes

Applying Authroization Header to all the routes which checks if the user is admin from his token

Get Admins

GET /
Response
{
"admins":[]
}

Get All Refund Requests

GET /refunds
Response
[
{
"individualTraineeId": "5f7b11be78b93e73d92366f9",
"courseId": "5f7b11be78b93e73d92366f9",
"_id": "5f7b11be78b93e73d92366f9",
"refundType": "course",
"refundReason": "reason",
"firstName": "firstName",
"lastName": "lastName",
"courseName": "courseName",
"email":"email",
}
]

Create Admin

POST /
BodyTypeDescription
userNamestringRequired. First name of admin
emailstringRequired. Email of admin
passwordstringRequired. Password of admin
Response
{
"admin": {
"userName": "heidarAdmin",
"email": "admin@gmail.com",
"password": "hashedPassword"","_id": "5f7b11be78b93e73d92366f9",
}
}

Get All Course Requests

GET /courseRequests
Response
[
{
"userId": "5f7b11be78b93e73d92366f9",
"courseId": "5f7b11be78b93e73d92366f9",
"_id": "5f7b11be78b93e73d92366f9",
"userName": "user13333",
"request": "I need this course to be added",
"date": "20/10/2020",
"email":"roo@gmail.com",
"courseName":"first course"
}
]

Get Admin By Id

GET /:id
ParameterTypeDescription
idstringRequired. id of admin
Response
{
"admin": {
"userName": "heidarAdmin",
"email": "admin@gmail.com",
"password": "hashedPassword"","_id": "5f7b11be78b93e73d92366f9",
}
}

Add Instructor

POST /addInstructor
BodyTypeDescription
userNamestringRequired. First name of instructor
emailstringRequired. Email of instructor
passwordstringRequired. Password of instructor
Response
{
"instructor": {
"userName": "heidarAdmin",
"email": "instructor10@gmail.com""password": "hashedPassword"","_id": "5f7b11be78b93e73d92366f9",
}
}

Add Coorporate

POST /addCoorporate
BodyTypeDescription
userNamestringRequired. First name of coorporate
emailstringRequired. Email of coorporate
passwordstringRequired. Password of coorporate
Response
{
"coorporate": {
"userName": "heidarAdmin",
"email": "coor@gmail.com",
"password": "hashedPassword"",
}
}

Accept Course Request

POST /acceptCourseRequest
BodyTypeDescription
emailstringRequired. coorporate email
courseNamestringRequired. name of the course
Response
{
"message": "Course Request Accepted"
}

Reject Course Request

POST /rejectCourseRequest
BodyTypeDescription
emailstringRequired. coorporate email
courseNamestringRequired. name of the course
Response
{
"message": "Course Request Rejected"
}

Provide Course

POST /provideCourse

A table of query

QueryTypeDescription
idstringRequired. id of course
coorporateIdstringRequired. id of coorporate
Response
{
"message": "Course Provided"
}

Accept Refund

POST /acceptRefund
BodyTypeDescription
emailstringRequired. email of user
courseNamestringRequired. name of the course
Response
{
"message":"Refund request has been accepted and email has been sent to ${email}"
}

Reject Refund

POST /rejectRefund

A table of body contain email and courseName

BodyTypeDescription
emailstringRequired. email of user
courseNamestringRequired. name of the course
Response
{
"message":"Refund request has been rejected and email has been sent to ${email}"
}

Delete Refund Request

POST /deleteRefundRequest/:id

A table of params contain id of refund request

ParameterTypeDescription
idstringRequired. id of refund request
Response
{
"message": "Refund Request Deleted"
}

Course Routes

Filter Course Based on price

GET /filter/price

A table of body contains max and min price of the course you wantt o search for

BodyTypeDescription
maxnumberRequired. max price of course
minnumberRequired. min price of course
Response
{
"courses":[
{
"title": "course1",
"description": "course1 description",
"price": 100,
"image": "image1",
"instructor": {
"instructorId": "5f7b11be78b93e73d92366f9",
"name":"jannah"
},
"duration": 40,
"subject":"computer science",
"rating": 4.5,
"language": "english",
"rating": 4.5,
"outlines":[],
"reviews":[],
"promotion":{ "discount": 10,
"startDate": "2020-10-10",
"endDate": "2020-10-10"
},
"ratings":[],
"numberOfEnrolledStudents": 0,
"releasedDate": "2020-10-10",
}
]
}

Get Course

GET /course/

A table of parameter

ParameterTypeDescription
idstringRequired. id of course
Response
{
"course": {
"title": "course1",
"description": "course1 description",
"price": 100,
"image": "image1",
"instructor": {
"instructorId": "5f7b11be78b93e73d92366f9",
"name":"jannah"
},
"duration": 40,
"subject":"computer science",
"rating": 4.5,
"language": "english",
"rating": 4.5,
"outlines":[],
"reviews":[],
"promotion":{ "discount": 10,
"startDate": "2020-10-10",
"endDate": "2020-10-10"
},
"ratings":[],
"numberOfEnrolledStudents": 0,
"releasedDate": "2020-10-10",
}
}

Find Course By Subject And Rating

GET /searchBySubjectAndRating

A table of body consists of rating and subject

BodyTypeDescription
ratingnumberRequired. rating of course
subjectstringRequired. subject of course
Response
{
"courses":[
{
"title": "course1",
"description": "course1 description",
"price": 100,
"image": "image1",
"instructor": {
"instructorId": "5f7b11be78b93e73d92366f9",
"name":"jannah"
},
"duration": 40,
"subject":"computer science",
"rating": 4.5,
"language": "english",
"rating": 4.5,
"outlines":[],
"reviews":[],
"promotion":{ "discount": 10,
"startDate": "2020-10-10",
"endDate": "2020-10-10"
},
"ratings":[],
"numberOfEnrolledStudents": 0,
"releasedDate": "2020-10-10",
}
]
}

Filter Courses By Subject & Price & Rating

GET /filterAllCourses
Code Example
exportconstfilterAllCourses=async(req,res)=>{try{const{ subject, price, rating }=req.query;constsubjectArray=subject.split(/[,]+/);constpriceArray=price.split(/[,]+/);constratingArray=rating.split(/[,]+/);constc=awaitCourse.aggregate([{$match: {subject: {$in: subjectArray},},},{$match: {rating: {$lte: parseInt(ratingArray[1])},},},{$match: {rating: {$gte: parseInt(ratingArray[0])},},},{$addFields: {discountedPrice: {$cond: [{$and: [{$lte: ["$promotion.startDate",newDate(Date.now())]},{$gte: ["$promotion.endDate",newDate(Date.now())]},],},{$multiply: ["$price",{$subtract: [1,"$promotion.discount"]},],},"$price",],},},},{$match: {discountedPrice: {$lte: parseInt(priceArray[1])},},},{$match: {discountedPrice: {$gte: parseInt(priceArray[0])},},},]);if(!c)returnres.status(200).send({message: "No course found"});res.status(200).send(c);}catch(err){res.status(401).send(err);}};
QueryTypeDescription
subjectstringRequired. subject of course
pricestringRequired. price of course
ratingstringRequired. rating of course
Response
{
"courses":[
{
"title": "course1",
"description": "course1 description",
"price": 100,
"image": "image1",
"instructor": {
"instructorId": "5f7b11be78b93e73d92366f9",
"name":"jannah"
},
"duration": 40,
"subject":"computer science",
"rating": 4.5,
"language": "english",
"rating": 4.5,
"outlines":[],
"reviews":[],
"promotion":{ "discount": 10,
"startDate": "2020-10-10",
"endDate": "2020-10-10"
},
"ratings":[],
"numberOfEnrolledStudents": 0,
"releasedDate": "2020-10-10",
}
]
}

Add Rating To Course

POST /addRating

A table of query consists of rating and courseid , traineeId

QueryTypeDescription
ratingnumberRequired. rating of course
courseIdstringRequired. id of course
traineeIdstringRequired. id of trainee
Response
```json
{
"message": "rating added successfully"
}
```

Get Courses With Promotion On It

GET /getCoursesWithPromotion
Code example 💻
exportconstgetCoursesWithPromotion=async(req,res)=>{try{constcourses=awaitCourse.aggregate([{$addFields: {discountedPrice: {$cond: [{$and: [{$lte: ["$promotion.startDate",newDate(Date.now())]},{$gte: ["$promotion.endDate",newDate(Date.now())]},],},{$multiply: ["$price",{$subtract: [1,"$promotion.discount"]},],},"$price",],},},},]);if(!courses)returnres.status(404).send({message: "Courses not found"});res.status(200).send(courses);}catch(error){console.log(error);}};
Response
{
"courses":[
{
"title": "course1",
"description": "course1 description",
"price": 100,
"image": "image1",
"instructor": {
"instructorId": "5f7b11be78b93e73d92366f9",
"name":"jannah"
},
"duration": 40,
"subject":"computer science",
"rating": 4.5,
"language": "english",
"rating": 4.5,
"outlines":[],
"reviews":[],
"promotion":{ "discount": 10,
"startDate": "2020-10-10",
"endDate": "2020-10-10"
},
"ratings":[],
"numberOfEnrolledStudents": 0,
"releasedDate": "2020-10-10",
}
]
}

Request Refund

POST /requestRefund

A table of body consists of course, type, individualTraineeId, coorporateTraineeId, firstName, lastName, email, refundReason, refundType

BodyTypeDescription
coursestringRequired. course of refund
typestringRequired. type of refund
individualTraineeIdstringRequired. id of individual trainee
coorporateTraineeIdstringRequired. id of coorporate trainee
firstNamestringRequired. first name of trainee
lastNamestringRequired. last name of trainee
emailstringRequired. email of trainee
refundReasonstringRequired. reason of refund
refundTypestringRequired. type of refund
Response
{
"message": "refund request sent successfully"
}

Get Popular Courses

GET /getPopularCourses
Code example 💻
try{constcourses=awaitCourse.aggregate([{$addFields: {discountedPrice: {$cond: [{$and: [{$lte: ["$promotion.startDate",newDate(Date.now())]},{$gte: ["$promotion.endDate",newDate(Date.now())]},],},{$multiply: ["$price",{$subtract: [1,"$promotion.discount"]},],},"$price",],},},},]).sort({numberOfTraineesEnrolled: -1}).limit(12);if(!courses)returnres.status(404).send({message: "Courses not found"});res.status(200).send(courses);}catch(error){console.log(error);}};
Response
{
"courses":[
{
"title": "Mern Stack",
"description": "Mern Popular One ",
"price": 100,
"image": "image1",
"instructor": {
"instructorId": "5f7b11be78b93e73d92366f9",
"name":"klllll"
},
"duration": 40,
"subject":"computer science",
"rating": 4.5,
"language": "english",
"rating": 4.5,
"outlines":[],
"reviews":[],
"promotion":{ "discount": 10,
"startDate": "2020-10-10",
"endDate": "2020-10-10"
},
"ratings":[],
"numberOfEnrolledStudents": 15,
"releasedDate": "2020-10-10",
}
]
}

Reported Problems

Create Reported Problem

POST /
BodyTypeDescription
coursestringRequired. course of refund
reporterEmailstringRequired. email of reporter
courseIdstringRequired. id of course
courseNamestringRequired. name of course
typestringRequired. type of problem
detailsstringRequired. details of problem
Response
{
"reporterEmail": "rro@gmail.com",
"courseId": "5f7b11be78b93e73d92366f9",
"courseName": "Mern Stack",
"type": "money",
"details": "money problem"
}

Get All Reported Problems

GET /
Response
{
"reportedProblems": [
{
"reporterEmail": "hm@gmail.com",
"courseId": "5f7b11be78b93e73d92366f9",
"courseName": "Mern Stack",
"type": "money",
"details": "money problem",
"status":"pending",
"date": "2020-10-10",
"response": "",
"date":"2020-10-10"
}
]
}

Get Reported Problem By Email

GET /getReportedProblemByReporterEmail
Response
{
"reporterEmail": "hm@gmail.com",
"courseId": "5f7b11be78b93e73d92366f9",
"courseName": "Mern Stack",
"type": "money",
"details": "money problem",
"status":"pending",
"date": "2020-10-10",
"response": "",
"date":"2020-10-10"
}

Update Reported Problem

PUT /:id
ParameterTypeDescription
idstringRequired. id of the problem

A table of body consists of response and status

BodyTypeDescription
responsestringRequired. response of the problem
statusstringRequired. status of the problem
Response
{
"reporterEmail": "hm@gmail.com",
"courseId": "5f7b11be78b93e73d92366f9",
"courseName": "Mern Stack",
"type": "money",
"details": "money problem",
"status":"resolved",
"date": "2020-10-10",
"response": "I got you friend",
"date":"2020-10-10"
}

Get Resolved Reported Problems

GET /getResolvedProblems
Response
{
"reportedProblems": [
{
"reporterEmail": "hm@gmail.com",
"courseId": "5f7b11be78b93e73d92366f9",
"courseName": "Mern Stack",
"type": "money",
"details": "money problem",
"status":"resolved",
"date": "2020-10-10",
"response": "I got you friend",
"date":"2020-10-10"
}
]
}

About

No description, website, or topics provided.

Resources

Stars

8 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages