81 | );
82 | }
--------------------------------------------------------------------------------
/client/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `yarn start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13 |
14 | The page will reload if you make edits.\
15 | You will also see any lint errors in the console.
16 |
17 | ### `yarn test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `yarn build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31 |
32 | ### `yarn eject`
33 |
34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35 |
36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37 |
38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39 |
40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41 |
42 | ## Learn More
43 |
44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45 |
46 | To learn React, check out the [React documentation](https://reactjs.org/).
47 |
48 | ### Code Splitting
49 |
50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51 |
52 | ### Analyzing the Bundle Size
53 |
54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55 |
56 | ### Making a Progressive Web App
57 |
58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59 |
60 | ### Advanced Configuration
61 |
62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63 |
64 | ### Deployment
65 |
66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67 |
68 | ### `yarn build` fails to minify
69 |
70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
71 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at . All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/client/src/components/add_question.js:
--------------------------------------------------------------------------------
1 | import React, {useState, useEffect} from "react";
2 | import {useHistory} from "react-router-dom";
3 | import {makeStyles} from "@material-ui/core/styles";
4 | import Typography from "@material-ui/core/Typography";
5 | import TextField from "@material-ui/core/TextField";
6 | import Button from "@material-ui/core/Button";
7 | import {getSessionCookie, setSessionCookie} from "./session_manager";
8 |
9 | const useStyles = makeStyles({
10 | mb: {
11 | marginBottom: "20px",
12 | width: "100%"
13 | },
14 | button: {
15 | marginBottom: "40px"
16 | }
17 | });
18 |
19 | export default function AddQuestion(props) {
20 | const session = getSessionCookie();
21 | const history = useHistory();
22 | const [title, setTitle] = useState("");
23 | const [description, setDescription] = useState("");
24 | const [userId, setUserId] = useState("");
25 | const [userName, setUserName] = useState("");
26 | const [error, setError] = useState("");
27 | const classes = useStyles();
28 |
29 | useEffect(() => {
30 | if(!session) {
31 | history.push("/login");
32 | } else {
33 | setUserId(session._id);
34 | setUserName(session.name);
35 | }
36 | }, [session, history]);
37 |
38 | function handleTitleChange(event) {
39 | setTitle(event.target.value);
40 | }
41 | function handleDescriptionChange(event) {
42 | setDescription(event.target.value);
43 | }
44 | function handleClick() {
45 | fetch("http://localhost:5000/", {
46 | method: "POST",
47 | mode: "cors",
48 | headers: {
49 | "Content-type": "application/json"
50 | },
51 | body: JSON.stringify({author: userName, title: title, description: description})
52 | }).then(response => response.json())
53 | .then(data => {
54 | if(data.msg) {
55 | setError(data.msg);
56 | } else {
57 | var questions = session.questions;
58 | questions.push(data._id);
59 | fetch("http://localhost:5000/user", {
60 | method: "POST",
61 | mode: "cors",
62 | headers: {
63 | "Content-type": "application/json"
64 | },
65 | body: JSON.stringify({questions: questions, userId: userId})
66 | }).then(response => response.json())
67 | .then(user => {
68 | if(user.msg) {
69 | setError(user.msg);
70 | } else {
71 | setSessionCookie(user);
72 | history.push("/questions/"+data._id);
73 | }
74 | })
75 | .catch(err => console.log(err));
76 | }
77 | }).catch(err => console.log(err));
78 | }
79 | return (
80 |
115 | );
116 | }
--------------------------------------------------------------------------------
/server/index.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const mongoose = require("mongoose");
3 | const cors = require("cors");
4 |
5 | const app = express();
6 | app.use(express.urlencoded({extended: true}));
7 | app.use(express.json());
8 | app.use(cors());
9 |
10 | /* Mongoose server link needs to be changed before deployment */
11 | mongoose.connect("mongodb://localhost: 27017/CollegeAadaDB", {useNewUrlParser: true, useUnifiedTopology: true, useFindAndModify: false});
12 |
13 | /* Mongoose Schemas */
14 | const questionSchema = new mongoose.Schema({
15 | title: String,
16 | description: String,
17 | no_comments: Number,
18 | author: String,
19 | timeStamp: Date,
20 | comments: [{
21 | author: String,
22 | authorId: String,
23 | comment: String,
24 | time: Date
25 | }]
26 | });
27 |
28 | const userSchema = new mongoose.Schema({
29 | _id: String,
30 | name: String,
31 | email: String,
32 | password: String,
33 | type: String,
34 | questions: [String],
35 | answers: [String]
36 | });
37 |
38 | /* Mongoose Models */
39 | const Question = mongoose.model("Question", questionSchema);
40 | const User = mongoose.model("User", userSchema);
41 |
42 | app.route("/").get((req, res)=> {
43 | if(req.query.questions) {
44 | const questionsQuery = JSON.parse(req.query.questions);
45 | Question.find({_id: {$in: questionsQuery}}, (error, questions) => {
46 | if(error) {
47 | console.log(error);
48 | res.sendStatus(500);
49 | } else {
50 | res.send(questions);
51 | }
52 | });
53 | } else {
54 | Question.find({}, (error, questions) => {
55 | if(error) {
56 | console.log(error);
57 | res.sendStatus(500).send({msg: "Bad Request."});
58 | } else {
59 | res.send(questions);
60 | }
61 | });
62 | }
63 | })
64 | .post((req, res) => {
65 | const {author, title, description} = req.body;
66 | const question = new Question({
67 | title: title,
68 | description: description,
69 | author: author,
70 | no_comments: 0,
71 | timeStamp: new Date(),
72 | comments: []
73 | });
74 | question.save((err, question) => {
75 | if(err) {
76 | res.send({msg: err});
77 | } else {
78 | res.send(question);
79 | }
80 | });
81 | });
82 |
83 | app.route("/login").get((req, res) => {
84 | const {userName, password} = req.query;
85 | User.findById(userName, (err, user) => {
86 | if(err) {
87 | console.log(err);
88 | res.send({msg: "Some Error Occured."});
89 | } else if(user) {
90 | if(user.password === password) {
91 | res.send({msg: "User present"});
92 | } else {
93 | res.send({msg: "Password invalid"});
94 | }
95 | } else {
96 | res.send({msg: "User not found"});
97 | }
98 | });
99 | });
100 |
101 | app.route("/register").post((req, res) => {
102 | const {userId, name, type, email, password, questions, answers} = req.body;
103 | User.findById(userId, (err, user) => {
104 | if(err) {
105 | res.send(err);
106 | } else if(user) {
107 | res.send({msg: "This username already exists"});
108 | } else {
109 | const user = new User({
110 | _id: userId,
111 | name: name,
112 | email: email,
113 | password: password,
114 | type: type,
115 | questions: questions,
116 | answers: answers
117 | });
118 | user.save();
119 | res.send({msg: "User Registered"});
120 | }
121 | })
122 | });
123 |
124 | app.route("/user")
125 | .get((req, res) => {
126 | const {userName} = req.query;
127 | User.findById(userName, (err, user) => {
128 | if(err) {
129 | res.send({msg: "Some Error Occured"});
130 | } else {
131 | res.send(user);
132 | }
133 | })
134 | })
135 | .post((req, res) => {
136 | const {questions, userId} = req.body;
137 | User.findByIdAndUpdate(userId, {$set: {questions: questions}}, {new: true}, (err, user) => {
138 | if(err) {
139 | res.send({msg: err});
140 | } else {
141 | res.send(user);
142 | }
143 | });
144 | });
145 |
146 | app.route("/question")
147 | .get((req, res) => {
148 | const questionId = req.query.id;
149 | Question.findById(questionId, (err, question) => {
150 | if(err) {
151 | console.log(err);
152 | } else {
153 | res.send(question);
154 | }
155 | });
156 | }).post((req, res) => {
157 | const questionId = req.body._id;
158 | const updatedComments = req.body.comments;
159 | const no_comments = req.body.no_comments;
160 | Question.findByIdAndUpdate(questionId, {$set: {comments: updatedComments, no_comments: no_comments}}, {new: true}, (err, question) => {
161 | if(err) {
162 | console.log(err);
163 | } else {
164 | res.send(question);
165 | }
166 | });
167 | });
168 |
169 | app.listen(process.env.PORT || 5000, () => console.log("Server started at port 5000"));
--------------------------------------------------------------------------------
/CONTRIBUTION.md:
--------------------------------------------------------------------------------
1 | # Contributing Guidelines
2 |
3 | 👍🎉 First off, thanks for taking the time to contribute! 🎉👍
4 |
5 | When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.
6 |
7 | This documentation contains a set of guidelines to help you during the contribution process.
8 | We are happy to welcome all the contributions from anyone willing to improve/add new scripts to this project. Thank you for helping out and remember, **no contribution is too small.**
9 |
10 | #### Table Of Contents
11 |
12 | * [Code of Conduct](#code-of-conduct)
13 | * [Submitting Contributions](#submitting-contributions)
14 | * [Find An Issue](#step-0--find-an-issue--)
15 | * [Fork The Project](#step-1--fork-the-project-)
16 | * [Branch](#step-2--branch--)
17 | * [Work on the issue assigned](#step-3--work-on-the-issue-assigned--)
18 | * [Commit](#step-4--commit)
19 | * [Work Remotely](#step-5--work-remotely)
20 | * [Pull Request](#step-6--pull-request--)
21 | * [Need more help?](#need-more-help)
22 | * [Tip from us](#tip-from-us)
23 |
24 | ## Code of Conduct
25 | This project and everyone participating in it is governed by the Contributor Covenant, version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html.
26 | Make sure to read it here: [CODE_OF_CONDUCT.md](https://github.com/Tejas1510/CollegeAada/blob/main/CODE_OF_CONDUCT.md)
27 |
28 | By participating, you are expected to uphold this code. For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq
29 |
30 | ## Submitting Contributions👩💻👨💻
31 | Below you will find the process and workflow used to review and merge your changes.
32 |
33 | ### Step 0 : Find an issue 🔍
34 | - Take a look at the Existing Issues or create your **own** Issues!
35 | - Wait for the Issue to be assigned to you after which you can start working on it.
36 | - Note : Every change in this project should/must have an associated issue.
37 | 
38 |
39 | ### Step 1 : Fork the Project 🍴
40 | - Fork this Repository. This will create a Local Copy of this Repository on your Github Profile. Keep a reference to the original project in `upstream` remote.
41 | ```
42 | $ git clone https://github.com//CollegeAada
43 | # Navigate to the project directory.
44 | $ cd CollegeAada
45 | $ git remote add upstream https://github.com/Tejas1510/CollegeAada
46 | ```
47 | 
48 | - If you have already forked the project, update your copy before working.
49 | ```
50 | $ git remote update
51 | $ git checkout
52 | $ git rebase upstream/
53 | ```
54 |
55 | ### Step 2 : Branch 🔖
56 | Create a new branch. Use its name to identify the issue your addressing.
57 | ```
58 | # It will create a new branch with name Branch_Name and switch to that branch
59 | $ git checkout -b Branch_Name
60 | ```
61 |
62 | ### Step 3 : Work on the issue assigned 📕
63 | - Work on the issue(s) assigned to you.
64 | - Add all the files/folders needed.
65 | - After you've made changes or made your contribution to the project add changes to the branch you've just created by:
66 | ```
67 | # To add all new files to branch Branch_Name
68 | $ git add .
69 | ```
70 | ```
71 | # To add only a few files to Branch_Name
72 | $ git add
73 | ```
74 |
75 | ### Step 4 : Commit
76 | - To commit give a descriptive message for the convenience of reviewer by:
77 | ```
78 | # This message get associated with all files you have changed
79 | $ git commit -m "message"
80 | ```
81 | - **NOTE**: A PR should have only one commit. Multiple commits should be squashed.
82 |
83 | ### Step 5 : Work Remotely
84 | - Now you are ready to your work to the remote repository.
85 | - When your work is ready and complies with the project conventions, upload your changes to your fork:
86 |
87 | ```
88 | # To push your work to your remote repository
89 | $ git push -u origin Branch_Name
90 | ```
91 | - Here is how your branch will look.
92 | 
93 |
94 | ### Step 6 : Pull Request 🎣
95 | - Go to your repository in browser and click on compare and pull requests. Then add a title and description to your pull request that explains your contribution.
96 | 
97 | - Voila! Your Pull Request has been submitted and will be reviewed by the moderators and merged.🥳
98 |
99 | ## Need more help?🤔
100 | You can refer to the following articles on basics of Git and Github and also contact the Project Mentors, in case you are stuck:
101 | - [Forking a Repo](https://help.github.com/en/github/getting-started-with-github/fork-a-repo)
102 | - [Cloning a Repo](https://help.github.com/en/desktop/contributing-to-projects/creating-an-issue-or-pull-request)
103 | - [How to create a Pull Request](https://opensource.com/article/19/7/create-pull-request-github)
104 | - [Getting started with Git and GitHub](https://towardsdatascience.com/getting-started-with-git-and-github-6fcd0f2d4ac6)
105 | - [Learn GitHub from Scratch](https://lab.github.com/githubtraining/introduction-to-github)
106 |
107 |
108 | ## Tip from us😇
109 | It always takes time to understand and learn. So, do not worry at all. We know **you have got this**!💪
110 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | ## 📢 Join Slack channel for Discussion about the project : [CollegeAada](https://join.slack.com/t/rknecworkspace/shared_invite/zt-m1yqj68k-tsZYt_rHP4_I22gV~kFhYQ)
4 |
5 | ## 📌 Motive of the Project
6 |
7 | CollegeAda is a full-stack MERN tool built which is a unified platform which connects seniors and juniors at a single place allowing the seniors to share books, question paper, notes, blogs and guidance which will help students and is the need of the hour
8 |
9 | ## 💡 Project Background
10 |
11 | The Project is built will be build help of Reactjs and Material-Ui at Frontend and backed by Nodejs and Expressjs at Backend using MongoDB as a Database. The user has the following
12 | ability
13 |
14 | - Signup as a senior,junior
15 | - Share/Lend Books
16 | - Upload Stationary items like Workshop Aapron, costly ED stationaries
17 | - Post Solution/Queries to solve problem of juniors
18 | - Gives Well Writen Notes and Question Paper
19 | - Community Blogs/Chat feature
20 |
21 |
22 |
Technologies Used
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | ## ⭐ Getting Started
36 |
37 | Refer to the following articles on the basics of Git and Github and can also contact the Project Mentors, in case you are stuck:
38 |
39 | - [Watch this video to get started, if you have no clue about open source](https://youtu.be/SL5KKdmvJ1U)
40 | - [Forking a Repo](https://help.github.com/en/github/getting-started-with-github/fork-a-repo)
41 | - [Cloning a Repo](https://help.github.com/en/desktop/contributing-to-projects/creating-a-pull-request)
42 | - [How to create a Pull Request](https://opensource.com/article/19/7/create-pull-request-github)
43 | - [Getting started with Git and GitHub](https://towardsdatascience.com/getting-started-with-git-and-github-6fcd0f2d4ac6)
44 |
45 | ## 💥 A guide for Contribution
46 |
47 | [](http://makeapullrequest.com)
48 | [](https://github.com/ellerbrock/open-source-badges/)
49 |
50 | - Take a look at the Existing [Issues](https://github.com/Tejas1510/CollegeAada/issues) or create your own Issues!
51 | - Wait for the Issue to be assigned to you after which you can start working on it.
52 | - Fork the Repo and create a Branch for any Issue that you are working upon.
53 | - Read the [Code of Conduct](https://github.com/Tejas1510/Hacking-Scripts/blob/main/CODE_OF_CONDUCT.md)
54 | - Create a Pull Request which will be promptly reviewed and suggestions would be added to improve it.
55 | - Add Screenshots to help us know what this Script is all about.
56 | - For more details visit the [Contribution Guide](https://github.com/Tejas1510/CollegeAada/blob/master/CONTRIBUTING.md)
57 |
58 |
59 | ## ⭐ Contribution:
60 | **1.** Fork [this](https://github.com/Tejas1510/CollegeAada/) repository.
61 | Click on the symbol at the top right corner.
62 |
63 | **2.** Clone the forked repository.
64 |
65 | ```bash
66 | git clone https://github.com//CollegeAada
67 | ```
68 |
69 | **3.** Navigate to the project directory.
70 |
71 | ```bash
72 | cd CollegeAada
73 | ```
74 |
75 | **4.** Make changes in source code.
76 |
77 | **5.** Stage your changes and commit
78 |
79 | ```bash
80 | #Add changes to Index
81 | git add .
82 |
83 | #Commit to the local repo
84 | git commit -m ""
85 | ```
86 |
87 | **7.** Push your local commits to the remote repo.
88 |
89 | ```bash
90 | git push
91 | ```
92 |
93 | **8.** Create a [PR](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request) !
94 |
95 | **9.** **Congratulations!** Sit and relax, you've made your contribution to [CollegeAada](https://github.com/Tejas1510/CollegeAada) project.
96 |
97 | ## ▶️ How to Run the Project
98 |
99 | **1.** Navigate to the project directory.
100 |
101 | ```bash
102 | cd CollegeAada
103 | ```
104 |
105 | **2.** Navigate to the Client directory.
106 |
107 | ```bash
108 | cd client
109 | npm install
110 | npm start / yarn start
111 | ```
112 |
113 | **3.** Navigate to the Server directory.
114 |
115 | ```bash
116 | cd server
117 | npm install
118 | npm start
119 | ```
120 | 🛈**IMPORTANT**🛈
121 |
122 | To open the webapp directly from CLI use:-
123 | ```explorer "https://memoriestejastapas.netlify.app/"```
124 |
125 | if you have cloned this repo, then open git in this directory and use
126 | ``` ./script.sh ```
127 |
128 | ## 📢 Open Source Program
129 |
130 | ### This Project is a part of the following Open Source Program
131 |
132 |
133 |
134 | ## ⭐ Issues:
135 | For major changes, you are welcomed to open an issue and discuss what you would like to contribute. Enhancements will be appreciated.
136 |
137 | ## ❤️ Project Admin
138 |