Coder Social home page Coder Social logo

gamification-platform's Introduction

Gamification Platform

This project aims to provide a platform where students can give feedback to their classmates' presentation assignments, with specially designed gamification elements to encourage students' engagement. It is based on Django 3.2 and PostgreSQL server database.

Developer Environment Setup

  1. Install required python packages

    It is suggested to create a brand-new virtual environment then pip install -r requirements.txt.

    Deprecated

    For Mac users, replace mysqlclient==2.1.0 with PyMySQL==1.0.2 in requirements.txt file. Then add the following lines to config/__init__.py

    import pymysql
    pymysql.install_as_MySQLdb()

    Note: Don't forget to add config/__init__.py to your local 'ignore' file list so as not to mess up the repo. Follow instructions in this link for how to ignore files locally.

    What we are doing here is essentially changing the MySQL driver for Django, since mysqlclient seems to have some compatiblity issues on Mac while PyMySQL is purely based on Python and will work on any platform. But mysqlclient is officially supported by Django in this list, so we will stick with it on other platforms.

  2. Install PostgreSQL server locally

    Follow the instructions here to install PostgreSQL compatible with your platform. PostgreSQL server's version should be >= 9.6, as is required by Django 3.2.

  3. Configure PostgreSQL server

    • Start PostgreSQL server

      Follow the instructions here to start the local postgres server.

    • Create a database dev

      Run sudo -u postgres psql to get into psql shell as postgres user. Then execute the following SQL statement to add a new database called dev.

      CREATE DATABASE dev;

      You can view all available psql commands by tying \?. Some common commands are:

      • \l: list all databases;
      • \c <DATABASE_NAME>: connect to a database;
      • \dt: list all tables in current database;
      • \d <TABLE_NAME>: describe table info;
      • \q: quit the shell;
    • Add a user dbuser

      Run sudo -u postgres psql to get into psql shell. Then execute the following SQL statements to add a user named dbuser with password as dbuser, and grant all privileges on table dev to dbuser.

      CREATE USER dbuser WITH PASSWORD 'dbuser';
      GRANT ALL PRIVILEGES ON DATABASE dev TO dbuser;
      ```python manage.py makemigrations
      
      Afterwards, you can modify a few of the connection parameters for the
      `dbuser` you just created. This will speed up database operations so that
      the correct values do not have to be queried and set each time a
      connection is established.
      
      ```sql
      ALTER ROLE dbuser SET client_encoding TO 'utf8';
      ALTER ROLE dbuser SET default_transaction_isolation TO 'read committed';
      ALTER ROLE dbuser SET timezone TO 'US/Pacific';

      After creating new user dbuser, we can login into psql shell as this new user with command psql -h localhost -d dev -U dbuser and then enter the password.

  4. Configure environment variables

    Add a .env file at the project directory (the same level as manage.py) with the following environment variables:

    SECRET_KEY='django-insecure-2-mg5vw^&skma(kxqan1_7^2acwc74pb54g6&ea&&a=0g=!!0g'
    DEBUG=True
    ALLOWED_HOSTS='localhost 127.0.0.1'
    

    In production environment,

    • SECRET_KEY should be kept as a real secret and not exposed to users.
    • DEBUG should be set to False.
    • ALLOWED_HOSTS should be added with the IP address or the domain name of the production server.

    You can also customize your environment by setting different database related variables like:

    • DB_NAME: default to dev, the name of the database
    • DB_USER: default to dbuser, the username used to access the database
    • DB_PASSWORD: default to dbuser, the password for DB_USER
    • DB_HOST: default to localhost, the host for the database
    • DB_PORT: default to 3306, the port where MySQL server is on
  5. Test if everything is working

    Run command python manage.py runserver

  6. Install fixtures

    Run command python manage.py loaddata assignments courses entities membership registration survey users artifact constraint rule rule_constraint

  7. Django Migration

    After each time you make changes on the models, migrate the database run : python manage.py makemigrations (make migration) python manage.py migrate (migrate the database to the new changes)

How to Run

After setting up the environment, run python manage.py runserver to start the server. Here are a few pages implemented at the moment:

  • Sign in page 127.0.0.1:8000/signin/

    The sign in page is where you input your andrew ID and password to login into the system. If the andrew ID doesn't exist or the password is incorrect, an error message will be displayed to ask you to enter again.
    After successful sign in, you will be redirected to your profile page.

  • Sign up page 127.0.0.1:8000/signup/

    The sign up page is where you register an account. You will be asked to enter your andrew ID (required), email (required), password (required), and enter the password one more time for confirmation. The password should be at least 8 characters, irrelavant to your personal information (andrew ID or email), not too common or entirely numeric. If any of the field above doesn't meet the requirement, you will be asked to input the information again.
    After successful sign up, you will be redirected to your profile page.

  • Profile page 127.0.0.1:8000/profile/

    The profile page is where you can view your personal information. You can edit your account information (andrew ID, email address, first name, last name and profile image) by filling in the form on this page. Currently, only the 'edit' tab is clickable and all other tabs are not implemented yet.

Contributing

Pull requests and branches

There will be mainly 3 types of branches while developing:

  • main: Always be deployable and the most stable version. Never commit directly on main branch. All code changes on main should come from merging with pull requests.
  • dev: The branch for evolving the development. Once a major set of features has been implemented, a version tag like x.0.0 will be added, and this branch will be merged into main for release.
  • {new_feat}: A type of branch for developing different features. Whenever a new feature is to be developed, checkout a feature branch from dev, name it after the feature description, and write code on that branch. After finishing developing, merge this branch into dev.

Developers are free to add as many {new_feat} branches as needed, but code changes in dev and main branch should always be done through pull requests and code reviews.

Python formatter

We use autopep8 to format our code. Properly set your IDE to automatically format the python file before saving.

Commit message convention

The commit message should be structured as follows, quoted from here:

<type>(optional scope): <description>

[optional body]

[optional footer(s)]

The types are specified as followed:

  • fix: patches a bug in the codebase.
  • feat: introduces a new feature to the codebase.
  • style: codebase changes related to code format problems
  • test: add test code
  • doc
  • chore
  • refactor
  • ......

Commit as often as possible

Break down the code you implemented into small parts and commit as soon as you finish a small part.

DO NOT squash all the work into one commit!

Multiple authors for a commit

If there are multiple authors for a commit (for example, pair-programming), follow the instructions from this link here to add co-authors.

gamification-platform's People

Contributors

prime51 avatar alexhe0131 avatar tonyrays avatar yunshan111 avatar bettsongy avatar

Watchers

Leonardo avatar

gamification-platform's Issues

User Interface

Need to implement an interface that instructor should be able to ADD, EDIT, DELETE rule and constraint.

Assignment Page

Issues on assignment list page:

  • Users (including both instructors and students) should not be able to view assignments of a course for which they are not registered in.
  • Column names in the table should be more user-friendly.
  • Some columns that display long text should be removed from the table.
  • Students, TAs and Instructors should be able to view different columns that are specific to their permission.
  • Add a 'back' button to navigate back to the course.

Issues on assignment detail page:

  • Cannot access detail page in merge_test branch

Issues on assignment edit page:

  • Course name is an object, not a readable text.

Course List Page

Issues on course list page:

  • Students and TAs cannot view courses they have registered for.
  • Instructors, TAs and students should be able to see different number of buttons for each course. For example, instructors have 'delete' button that TAs and students don't have, TAs have 'edit' button that students dont' have.

Next semester TODO list

  • Add relationship to the database to connect URI to constraints or rules
  • Remove the duplication of the ActionConstraintDetail methods, add a new field to represent the point received by the action
  • Filter only the rules that are still open instead of returning all of the rules, modify the *or404 to throw exception
  • Modify the rule_constraint in the database to be composite keys
  • UI to be more descriptive to unlock badges
  • More source code reviews to learn and improve programming

Course Member Page

Issues on course memeber list page:

  • Adding an instructor or a TA will also create an instance in Entity table. This should only happen when adding new students.
  • Delete student membership in a team when changing his role from Student to TA.

Course Page

Issues on course list page:

  • Students and TAs cannot view courses they didn't register for.
  • Instructors, TAs and students should be able to see different number of buttons for each course. For example, instructors have 'delete' button that TAs and students don't have, TAs have 'edit' button that students dont' have.

Issues on course edit page:

  • Return 404 when input wrong URL

Issues on course detail page:

  • Web page is too narrow in view page.
  • may add a line between header and syllabus in view page.(like Canvas)
  • MAY make it possible to add hyperlink in syllabus in the future.(like Canvas)
  • add a Back button on course view page

Issues on course member page:

  • Adding an instructor or a TA will also create an instance in Entity table. This should only happen when adding new students.
  • Delete student membership in a team when changing his role from Student to TA.

Models:

  • Refactor Course.teams property.
  • Add tests for Course.teams property.
  • In Course.get_query helper function, add checks for parameter role.
  • Add tests for Course.get_query function.

Note: The naming convention of constant values is all capital letters like INSTRUCTOR instead of Instructor.

Instructor profile - multiple buttons do not perform any action in edit survey vue

When I try to modify an existing survey, some of the buttons do not perform an expected action:

  • "+" at the section level doesn't add a new question to the section
  • edit button at the question level doesn't open a modification window
  • "bin" button at the question level doesn't remove a question
  • "bin" button at the section level doesn't remove a section
    The only operation that seems to work is modifying a title of a section.

Value error when trying to create a new survey template

In instructor view, when trying to edit a survey selecting -> new template and saving (see screenshot attached) causes a value error. The release/due date fields were not modified.

Error stack:
Screenshot 2022-09-21 at 16 39 56

Environment:

Request Method: POST
Screenshot 2022-09-21 at 16 37 10

Request URL: https://127.0.0.1:8000/course/1/assignment/1/template/edit_survey_template/

Django Version: 3.2
Python Version: 3.10.5
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.sites',
'django.contrib.staticfiles',
'widget_tweaks',
'rest_framework',
'storages',
'app.gamification',
'django_cleanup.apps.CleanupConfig']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/app/.heroku/python/lib/python3.10/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/app/.heroku/python/lib/python3.10/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/app/app/gamification/decorators.py", line 32, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/app/app/gamification/views/pages/survey_views.py", line 101, in edit_survey_template
feedback_survey_date_released = parse_datetime(
File "/app/app/gamification/utils.py", line 12, in parse_datetime
raise ValueError('Invalid datetime string')

Exception Type: ValueError at /course/1/assignment/1/template/edit_survey_template/
Exception Value: Invalid datetime string

Badge Assets to Backend

Current Badge assets are hard-coded in the front-end, which is not ideal for extendability. Need to move the badge assets such as icon images to the backend.

Progress Not showing full pictures when there are multiple constraints

If a badge is unlocked through 2 constraints. When the user is only progress only 1 of them, the progress will only show the unlocking condition of the progressing constraint, leaving the other constraint unknown to the user. In the future, we want the user to see all of the constraints once the user is making progressing on any of the unlocking constraints.

Test code issues

Tasks needs to be done in test code

  • Create some commonly used base TestCase classes, for example, CreateAndLoginInUser, CourseList, etc.
    In these base test classes, some fixture data are created, so that we don't have to write code to populate the database with some data repetitively.

Development Environment Setup Issues

Development environment setup has some issues:

  • Add postgres installation prior to installing requirements.txt (Steps 1 and 2 should be swapped)
  • Connection to postgres database achieved via psql postgres not sudo -u postgres psql
  • Python virtual environment required psycopg2-binary (2.9.5) and spacy (3.5.0)
  • node_modules should be included in .gitignore

Profile Page

Issues in profile page:

  • Remove inactive buttons and unused fields.
  • Use full_name in greetings in top navbar.
  • When uploading an image with incorrect file extensions, the profile image url will be updated.

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.