GithubHelp home page GithubHelp logo

inwonakng / surveygenerator Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 121.88 MB

Semantic web application in collaboration with IBM that extended MIT’s moral machine by allowing users to create and answer ethical questions with the utilization of machine learning microservices

Python 34.18% HTML 1.63% CSS 10.62% JavaScript 52.85% Dockerfile 0.72%
machine-learning django react mit rpi ibm watson moral ethical pwa

surveygenerator's Introduction

Survey Generator

Development setup

Requirements:

  • MySQL (docker is fine)
  • python3 (venv usage is heavily encouraged)
  • npm

VSCode is the recommended editor for this project.

please DO NOT use git through the command line. This will be painful for everyone

Installation (backend only)

Backend only

Since custom package and specific package version are used in this project, we recommend using venv for development so your local python env won't be polluted.

Configure MySQL

Using Docker (recommended)

docker build -t reactapp -f Dockerfile . 
docker-compose -f docker-compose.dev.yml up -d

This command will run a latest mysql w/ combination root/password on 127.0.0.1:3306 and phpmyadmin on 127.0.0.1:8088. You may use this web interface to manage the database.

Remove/Recreate Mysql

docker-compose -f docker-compose.dev.yml down

And recreate using the first command.

Manually installing and setting up MySQL

linux:

sudo apt install mysql-server

If you install the server any other way and are prompted with a password, leave the field blank. If you set the password, you may not need to do the step below.

Fixing privilege

After running MySQL with admin priveges (sudo), run the following queries to reset the root password.

DROP USER 'root'@'%';
CREATE USER 'root'@'%' IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
CREATE DATABASE mysqldb

venv

You should always use venv! This will help us isolate the dependencies of our project to make for easier installation

Before you start the setup, make sure you are inside the 'backend/' directory. If not, make sure to add your venv directory to the gitignore file.

python3 -m venv venv

The above command will generate venv under current directory

Enter Virtualenv

source venv/bin/activate
<venv>\Scripts\activate.bat
<venv>\Scripts\Activate.ps1

On windows, try to stick to powershell, which is the default vscode terminal.

You should now see (venv) in front of your command ine

Exit Virtualenv

deactivate

Dependencies

python3 -m pip install -r requirements.txt

before you runs this commmand, run which python3 (bash) or where python3 (windows) to make sure that you are installing to your venv!

Add new dependency

After adding new dependency, run the following command to lock requirements.txt

pip freeze > requirements.txt

Database setup (backend only)

After model changes (backend changes that need to be reflected in the database)

  • migrate the latest model changes to the database by running the following commands
python manage.py makemigrations
python manage.py migrate
  • If you run in to errors, either go in the docker shell or command line and run the following query to reset the database
DROP DATABASE surgey_generator_db; CREATE DATABASE surgey_generator_db;

Migration & Start Server

cd ethicssite
python3 manage.py migrate
python3 manage.py createcachetable

and start server by

python3 manage.py runserver

Installation & Run (frontend only)

Frontend only

Head to the root of the project and run the following:

npm install
cd src
npm run start

surveygenerator's People

Contributors

amontes261 avatar chris32101 avatar goulet-coder avatar inwonakng avatar nishi7409 avatar vincentqchen avatar

Watchers

 avatar  avatar

surveygenerator's Issues

Survey Taking page

Page for the user to take a survey.

Each page contains a question and the following options.

For score inputs to the survey, use slider bars for now
(this should be a separate component. We want to allow the user to change different inputs later on)

Logo

I can splurge some $$ on a logo b/c why not?

My Survey Details page

This is the page that a user is taken to when they pick a survey from My Surveys page.

Will have statistics about the page, as well as downloadable information.

ChartJS goes here! (again, should be separate components, we want user to be able to switch to different types of charts/data)

POST - Create Survey

When a survey is submitted, create the model object in the backend.

The response that'd be received from the frontend looks like this:
(can also be viewed here)

{
        "prompt": "This is a test",
        "survey_title": "Test Survey",
        "user": {
            "username": "user",
            "email": null,
            "creation_time": "2021-06-17T01:55:02.146779Z"
        },
        "number_of_answers": 0,
        "creation_time": "2021-06-17T01:59:37.595032Z",
        "questions": [
            {
                "question": "Assign scores to the options",
                "options": [
                    {
                        "name": "Option 1",
                        "text": "A car",
                        "score": null
                    },
                    {
                        "name": "Option 2",
                        "text": "A boat",
                        "score": null
                    }
                ]
            }
        ]
    }

Settings

User settings can be changed here

For now:
Allow user to change/choose which information to share with the application

  • Name
  • Institution
  • Email
  • Phone (?)

View taken surveys

Example for old app:

Screenshot from 2021-06-09 21-58-35

This functions the same as the 'surveys' or 'my surveys' page. For now clicking each survey does not have to lead to anything

Surveys

View all surveys

  • Green - Surveys that haven't been completed by the logged in user
  • Red - Surveys that have been completed by the logged in user
  • Black - Surveys that have been hidden by the logged in user

Survey Creation Page

Page for creating survey!
First finish vanilla text input
i.e.:
Question 1: 'What car?'
Option 1: 'Black car'
Option 2: 'Red car'
..
Question 2: 'What food?'
....

etc

Then do 'feature based' input
This is a bit more complicated

First input: list of features an option should have
Using this list of features, create input for each feature value

ex:
list of features: 'Age' 'Gender' 'Height' ...

Q1: Who would you hire?
Option1: 'Age':14, 'Gender':'Male', 'Height':71
Option2: 'Age':54, 'Gender':'Female','Height':60
....

Data Example

Containerized version of Postgresql on Docker

Generative Functions

Not too sure what the purpose of this is right now, but the original source code has it

REST API

  • Fetching (GET)
  • Storing (POST)
  • Updating (PATCH)
  • Deleting (DELETE)

Get Surveys

  • Get all surveys
  • Get all user-made surveys (for /mysurveys)

Create Survey page

Page for creating survey
Necessary inputs:

  • Title
  • Description
  • Option inputs -> Allow adding more options

Screenshot from 2021-06-09 22-00-47

The buttons on above title (generate/set my own) are not needed

Dashboard

When you're authenticated, all pages should look similar... hence the dashboard design.

Example:
image

Left column:

  • Home
  • My Surveys
  • Forum
  • Settings

Middle column:
Contains the content of a specific page (home/my surveys/forum/settings)

Right column:

  • Trending questions
  • Ask your question
  • Help us improve
  • System notifications

Job Queue

  • Data compression
  • Monthly emails
  • SMS texts

Documentation

As more developers come in or if we need to pass this onto some other entity, it'd be beneficial for the other party to have some form of documentation to setup the server and frontend instances

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.