Sp26 Badges:
@beautyjoy/BJC-Teacher-Tracker Status:
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.
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")
}
- 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.
- We are not using
application.yml(rails env framework). Instead, we use a.envfile at directory root to load all env vars. Use.env.exampleas 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.
brew install postgresql chromedriver- Start postgres if necessary.
brew services start postgresql
sudo apt install postgresql- Create a postgres user.
sudo su - postgres(to get into postgres shell)createuser --interactive --pwprompt(in postgres shell)- Save
DB_USERandDB_PASSWORDfields in the.envfile.
- 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
- Note: if you are using WSL2 on windows, the command to start postgres is
rvm use 3.3.13# Double-check.ruby-versionbundlebin/rails db:setup(Run this after setting up Postgres)nvm install 14Node v14 is neededyarn installYarn is needed
- Use tools like overmind or foreman to boot up server with env vars loaded.
- If you are using
overmind, you can simplynpm run dev.
- For RSpec tests run
bundle exec rspec - For Cucumber tests run
bundle exec cucumber - For Rubocop check run
bundle exec rubocop(Autocorrect all withbundle exec rubocop -a) - To make someone an admin use db console access
- Using psql
- First run
heroku pg:psql(for Heroku) orpsql bjc_teachers_dev(for local) to get into psql - Alternatively, you can use
rails dbto get into psql - Then
Of course, you can swap in the email of your choice.
UPDATE teachers SET admin = true WHERE Email LIKE '%@berkeley.edu%' ;
- First run
- Using rails console
- First run
heroku run rails console(for Heroku) orrails console(for local) to get into rails console - Then
Teacher.where("email LIKE '%@berkeley.edu%'").update_all(admin: true)
- First run
- Using psql
stylesheet_pack_tagdoesn'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.
- ... 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/rubyheroku addons:create heroku-postgresqlheroku 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 inProcfilefor 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:loadheroku run bin/rails db:seedheroku config:set ...for each of the environment variables.heroku open
bin/rails db:seedloads 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_datarunsdb:seed, then adds a dozen demo schools and teachers for local development. All addresses use reserved.exampledomains. It refuses to run in production unlessALLOW_SAMPLE_DATA=trueis set.
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).
export BACKEND_MAPS_API_KEY="your-key"
bin/rails "db:staging_seed[/path/to/schools.csv,500]"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-appInside 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.
The app integrates with MailBluster for email marketing and newsletter management.
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- 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, andbouncedstatus
# 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:statusStatus: the webhook is deployed but not active in production yet — no SNS topic is subscribed and
SNS_ALLOWED_TOPIC_ARNSis 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:
- Create an SNS topic (e.g.
bjc-ses-events) in the same region as SES. - Send SES events to it. Either:
- Preferred: create an SES configuration set with an SNS event destination for
Send,Delivery,Bounce, andComplaint, then set it as the default configuration set of the sending identity (domain or address). The app sends over SMTP and does not set anX-SES-CONFIGURATION-SETheader, 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
Sendevents in this mode, soemails_sentwon't move.)
- Preferred: create an SES configuration set with an SNS event destination for
- Set the allowlist on Heroku before subscribing. Without it, every message gets a 401, including the subscription confirmation:
(Comma-separated if there's more than one.)
heroku config:set SNS_ALLOWED_TOPIC_ARNS=arn:aws:sns:us-west-2:123456789012:bjc-ses-events
- 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. - 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 checkheroku 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.
TODO: Link to download CodeClimate binaries for macOS.
https://codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64