Skip to content

About

Access Portal and Dashboards for BJC Teachers

Resources

Security policy

Stars

4 stars

Watchers

2 watching

Forks

 
 

Latest commit

 

History

3,027 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BJC Teacher Tracker

Sp26 Badges:

Bluejay Dashboard • All Specs • RuboCop • Maintainability • Code Coverage


@beautyjoy/BJC-Teacher-Tracker Status:

All Specs • RuboCop • CodeQL • codecov • Maintainability • Test Coverage

Description

The Beauty and Joy of Computing (BJC) is an introductory computer science curriculum developed at UC Berkeley meant for high school freshmen up to college freshmen. The program has a teacher guide and a newly generated password that is to be given to any teacher who signs up for the program as a volunteer educator in the Bay Area - there are plans to expand the program to other states in late 2020. This pilot application is designed as a dashboard to track the workflow of teachers who run the program and provide high-level, descriptive statistics on the courses taught and participating schools. The BJC Teacher Tracker is a NEW project started in Fall 2019 by a group of 5 student developers in UC Berkeley's CS 169: Software Engineering.

Features

C4Context
  title BJC Curriculum Management Dashboard

  Boundary(b1, "Dashboard System") {
    Person(teacher, "Teacher", "Signs up and manages own information")
    System(curriculumSystem, "Curriculum Dashboard", "Central platform for curriculum management")
    Person(admin, "Admin", "Administers systems and oversees communications")

    System(teacherInfoSystem, "Teacher Management System", "Manages teacher profiles")

    System(emailSystem, "Email System", "Handles all email communications")
   
    System(workshopSystem, "Workshop System", "Coordinates workshop registrations")

    Rel(admin, curriculumSystem, "Administers", "HTTPS", "left")
    Rel(admin, teacherInfoSystem, "Administers", "HTTPS", "left")
    Rel(admin, emailSystem, "Sends Emails", "SMTP", "down")
    Rel(admin, workshopSystem, "Organizes Workshops", "HTTPS", "up")
    Rel(teacher, curriculumSystem, "Accesses if approved", "HTTPS", "right")
    Rel(teacher, teacherInfoSystem, "Manages own profile", "HTTPS", "left")

    UpdateElementStyle(admin, $bgColor="#F9D648FF", $fontColor="#000000", $borderColor="#C4972F")
    UpdateElementStyle(teacher, $bgColor="#8ABAD3FF", $fontColor="#000000", $borderColor="#045D75")
    UpdateElementStyle(curriculumSystem, $bgColor="#F0F0F0", $fontColor="#000000", $borderColor="#707070")
    UpdateElementStyle(teacherInfoSystem, $bgColor="#B8DEE6", $fontColor="#000000", $borderColor="#76A5AF")
    UpdateElementStyle(emailSystem, $bgColor="#F7E0B5", $fontColor="#000000", $borderColor="#DDBE7E")
    UpdateElementStyle(workshopSystem, $bgColor="#D1F4C9", $fontColor="#000000", $borderColor="#95C896")

    UpdateRelStyle(teacher, curriculumSystem, $textColor="#046307", $lineColor="#0D4006")
    UpdateRelStyle(teacher, teacherInfoSystem, $textColor="#046307", $lineColor="#0D4006")
    UpdateRelStyle(admin, curriculumSystem, $textColor="#860136", $lineColor="#540229")
    UpdateRelStyle(admin, teacherInfoSystem, $textColor="#860136", $lineColor="#540229")
    UpdateRelStyle(admin, emailSystem, $textColor="#860136", $lineColor="#540229")
    UpdateRelStyle(admin, workshopSystem, $textColor="#860136", $lineColor="#540229")
 }

Loading
  • Teachers can sign up at https://teachers.bjc.berkeley.edu
    • For homeschoolers, they need to upload additional support documents.
  • Admins can log in to approve, deny, or request more information for each request.
  • Admins can merge duplicate teacher records.
  • Admins can create and modify workshops and relevant registrations.
  • Admins can see a dashboard of teacher stats.
  • Teachers can log in to view protected solutions content.
  • Admins can create and modify email templates.

Installation:

Environmental Variable

  • We are not using application.yml (rails env framework). Instead, we use a .env file at directory root to load all env vars. Use .env.example as a reference for env format.
  • Use tools like overmind or foreman to load in the env vars.
  • You probably need to configure your own oauth keys and database name/passwords.

Postgres Installation

MacOS:

  • brew install postgresql chromedriver
  • Start postgres if necessary. brew services start postgresql

Linux/WSL:

  • sudo apt install postgresql
  • Create a postgres user.
    • sudo su - postgres (to get into postgres shell)
    • createuser --interactive --pwprompt (in postgres shell)
    • Save DB_USER and DB_PASSWORD fields in the .env file.
  • Start postgres if necessary. pg_ctlcluster 12 main start
    • Note: if you are using WSL2 on windows, the command to start postgres is sudo service postgresql start

Framework/Gem Installation

  • rvm use 3.3.13 # Double-check .ruby-version
  • bundle
  • bin/rails db:setup (Run this after setting up Postgres)
  • nvm install 14 Node v14 is needed
  • yarn install Yarn is needed

Spin Up Server

  • Use tools like overmind or foreman to boot up server with env vars loaded.
  • If you are using overmind, you can simply npm run dev.

Available Commands

  • For RSpec tests run bundle exec rspec
  • For Cucumber tests run bundle exec cucumber
  • For Rubocop check run bundle exec rubocop (Autocorrect all with bundle exec rubocop -a)
  • To make someone an admin use db console access
    • Using psql
      • First run heroku pg:psql (for Heroku) or psql bjc_teachers_dev (for local) to get into psql
      • Alternatively, you can use rails db to get into psql
      • Then
        UPDATE teachers
        SET admin = true
        WHERE Email LIKE '%@berkeley.edu%'
        ;
        
        Of course, you can swap in the email of your choice.
    • Using rails console
      • First run heroku run rails console (for Heroku) or rails console (for local) to get into rails console
      • Then
        Teacher.where("email LIKE '%@berkeley.edu%'").update_all(admin: true)
        

JavaScript and CSS with Webpack

  • stylesheet_pack_tag doesn't work. :(
  • Use `import '*.scss' in a _JavaScript file, and webpack will compile correctly
  • If you need a new CSS-only import, make a new CSS and a new JS file.

Deployed Site:

Steps to Deploying on Heroku

  • ... create a heroku app, the default heroku-22 stack should work.
  • heroku buildpacks:set heroku/nodejs # this must be the first buildpack.
  • heroku buildpacks:add --index 2 heroku/ruby
  • heroku addons:create heroku-postgresql
  • heroku git -a [app-name]
  • Make your local changes and start the commit process
  • git add .
  • git commit -m "<Message>"
  • git push heroku master (If this fails, try commenting the release command in Procfile for this first deployment only and go on to the next step. After you are done with the deployment, uncomment back the release command again. For more information, see this PR.)

If bundler install runs successfully, continue with the following commands to correctly setup the PostgreSQL database on Heroku:

  • heroku run bin/rails db:drop (if this fails, you can skip this step)
  • heroku run bin/rails db:schema:load
  • heroku run bin/rails db:seed
  • heroku config:set ... for each of the environment variables.
  • heroku open

Seed Data

  • bin/rails db:seed loads only production-safe data: email templates, UC Berkeley, and the core admin accounts. It is safe to run on production, and is how email template changes get there.
  • bin/rails db:seed:sample_data runs db:seed, then adds a dozen demo schools and teachers for local development. All addresses use reserved .example domains. It refuses to run in production unless ALLOW_SAMPLE_DATA=true is set.

Staging Data

Populates a staging database with realistic sample data (~500 schools, ~700 teachers, PD events, and registrations). Run after db:seed. Refuses to run in production unless ALLOW_SAMPLE_DATA=true is set, which should only ever be set on a staging app. Note that rows with invalid/missing data will not be seeded.

Requires: BACKEND_MAPS_API_KEY with the Geocoding API enabled, and a CSV export of schools (Name, Location, Country, URL, Teachers, Grade Level, Actions).

Local

export BACKEND_MAPS_API_KEY="your-key"
bin/rails "db:staging_seed[/path/to/schools.csv,500]"

Heroku

db:seed is not run automatically (only db:prepare runs on deploy), so seed admins first:

heroku config:set BACKEND_MAPS_API_KEY=your-key --app your-app
heroku run bin/rails db:seed --app your-app
heroku run bash --app your-app

Inside the dyno, download the CSV. Any hosting works — Google Drive, Dropbox, S3, transfer.sh, or committed directly to the repo. Google Drive example (share as "Anyone with link", copy the file ID):

ID=YOUR_FILE_ID
OUT=/tmp/schools.csv
curl -L "https://drive.google.com/uc?export=download&id=$ID" -o $OUT
bin/rails "db:staging_seed[/tmp/schools.csv,500]"

Revoke the Google Drive link after seeding.

MailBluster Integration

The app integrates with MailBluster for email marketing and newsletter management.

Configuration

Set the MAILBLUSTER_API_KEY environment variable:

# Local development
export MAILBLUSTER_API_KEY=your_api_key_here

# Heroku
heroku config:set MAILBLUSTER_API_KEY=your_api_key_here

Features

  • Auto-sync on approval: When a teacher is validated, their info is synced to MailBluster as a lead
  • Auto-sync on status change: Updating a teacher's application status triggers a MailBluster sync
  • Auto-sync on email add: Adding a new email address to a validated teacher triggers sync
  • Manual sync: Admins can sync individual teachers or all validated teachers from the UI
  • Lead cleanup: Deleting a teacher removes their lead from MailBluster
  • Delivery tracking: Email addresses track emails_sent, emails_delivered, and bounced status

Rake Tasks

# Sync all validated teachers to MailBluster
bundle exec rake mailbluster:sync_all

# Sync a single teacher by ID
bundle exec rake mailbluster:sync_teacher[123]

# Check sync status
bundle exec rake mailbluster:status

SES bounce tracking (setup)

Status: the webhook is deployed but not active in production yet — no SNS topic is subscribed and SNS_ALLOWED_TOPIC_ARNS is unset, so it rejects everything.

POST /webhooks/ses receives Amazon SES events via SNS and updates the emails_sent, emails_delivered, soft_bounce_count, hard_bounce_count, and bounced fields on EmailAddress. Every event is also stored in ses_delivery_events. Messages are checked against an SNS topic allowlist and their AWS signature before anything is processed.

To turn it on:

  1. Create an SNS topic (e.g. bjc-ses-events) in the same region as SES.
  2. Send SES events to it. Either:
    • Preferred: create an SES configuration set with an SNS event destination for Send, Delivery, Bounce, and Complaint, then set it as the default configuration set of the sending identity (domain or address). The app sends over SMTP and does not set an X-SES-CONFIGURATION-SET header, so the default is the only way the configuration set gets applied.
    • Or: on the identity, enable feedback notifications to the topic for Bounce, Complaint, and Delivery. (No Send events in this mode, so emails_sent won't move.)
  3. Set the allowlist on Heroku before subscribing. Without it, every message gets a 401, including the subscription confirmation:
    heroku config:set SNS_ALLOWED_TOPIC_ARNS=arn:aws:sns:us-west-2:123456789012:bjc-ses-events
    (Comma-separated if there's more than one.)
  4. Subscribe the app to the topic: protocol HTTPS, endpoint https://<your-host>/webhooks/ses. Leave raw message delivery off. The app confirms the subscription by itself.
  5. Check it works: the subscription should show Confirmed in the SNS console. Send an email (or use the SES mailbox simulator, e.g. bounce@simulator.amazonses.com), then check heroku run bin/rails runner 'p SesDeliveryEvent.last' or the teacher's Email Delivery Stats. Webhook problems are logged with the [SES Webhook] prefix.

For local development, bin/rails "ses:simulate[teacher@example.com,hard_bounce]" fires a fixture event without AWS, and bin/rails ses:reset clears the counters. Both refuse to run outside development and test.

CodeClimate Local Test

TODO: Link to download CodeClimate binaries for macOS.

https://codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64

Contributions

Hagen Haeussler

About

Access Portal and Dashboards for BJC Teachers

Resources

Security policy

Stars

4 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages