StrangeIB commited on
Commit Β·
4951c88
1
Parent(s): 2fd90c5
Rewrite app copy: friendly ask, skimmable Q&A, detailed consent, CTA
Browse files
app.py
CHANGED
|
@@ -16,92 +16,143 @@ from redactors import engine
|
|
| 16 |
|
| 17 |
PASSPHRASE = os.environ.get("APP_PASSPHRASE", "")
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
st.set_page_config(page_title="STARS Report Redactor", page_icon="π‘οΈ",
|
| 20 |
layout="centered")
|
| 21 |
|
| 22 |
-
|
| 23 |
-
st.
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
with st.expander("
|
| 27 |
st.markdown(
|
| 28 |
-
"
|
| 29 |
-
"
|
| 30 |
-
"
|
| 31 |
-
"
|
| 32 |
-
"- This is redaction, **not perfect anonymization**: your major, terms, and "
|
| 33 |
-
"course list remain, which could be identifying in a small program. "
|
| 34 |
-
"Please share only if you consent."
|
| 35 |
)
|
| 36 |
|
| 37 |
-
with st.expander("How
|
| 38 |
st.markdown(
|
| 39 |
-
"1. Go to **experience.usc.edu**
|
| 40 |
"2. Open your **STARS** (Degree Progress) report.\n"
|
| 41 |
-
"3.
|
| 42 |
-
"4. In the print
|
| 43 |
-
"5. Upload that
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
)
|
| 45 |
|
| 46 |
-
#
|
|
|
|
|
|
|
| 47 |
if not PASSPHRASE:
|
| 48 |
-
st.error("This app isn't
|
| 49 |
-
"Please contact the team.")
|
| 50 |
st.stop()
|
| 51 |
|
| 52 |
-
entered = st.text_input("
|
| 53 |
-
|
|
|
|
| 54 |
if entered.strip() != PASSPHRASE:
|
| 55 |
if entered:
|
| 56 |
-
st.warning("
|
| 57 |
st.stop()
|
| 58 |
|
| 59 |
-
# ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
consent = st.checkbox(
|
| 61 |
-
"I
|
| 62 |
|
| 63 |
uploaded = st.file_uploader(
|
| 64 |
"Upload your STARS report (the PDF you saved from experience.usc.edu)",
|
| 65 |
type=["pdf"], accept_multiple_files=False)
|
| 66 |
|
| 67 |
if uploaded is not None and not consent:
|
| 68 |
-
st.info("
|
| 69 |
|
| 70 |
if uploaded is not None and consent:
|
| 71 |
-
with st.spinner("
|
| 72 |
res, out = engine.redact_bytes(uploaded.getvalue(), {"pii", "grades"})
|
| 73 |
|
| 74 |
status = res["status"]
|
| 75 |
if status in ("REDACTED", "REVIEW") and out:
|
| 76 |
g = res.get("grades", {})
|
| 77 |
-
st.success("Done
|
| 78 |
st.write(
|
| 79 |
-
f"
|
| 80 |
-
f"**{g.get('grades_replaced', 0)}** grade(s), and "
|
| 81 |
-
f"**{g.get('gpa_replaced', 0)}** GPA/points
|
| 82 |
)
|
| 83 |
if res.get("fragments"):
|
| 84 |
-
st.info("Part of your name
|
| 85 |
-
"
|
| 86 |
|
| 87 |
stem = os.path.splitext(uploaded.name)[0]
|
| 88 |
stem = stem.replace("DONOTSHARE_", "").replace("REDACTED_", "")
|
| 89 |
-
st.download_button("β¬οΈ Download redacted
|
| 90 |
file_name=f"REDACTED_{stem}.pdf",
|
| 91 |
mime="application/pdf")
|
| 92 |
-
st.caption("
|
| 93 |
-
"to the team
|
| 94 |
|
| 95 |
elif status == "SKIPPED":
|
| 96 |
-
st.error("This
|
| 97 |
-
"
|
| 98 |
-
"
|
| 99 |
-
"rather than a scanned or photographed copy.")
|
| 100 |
else:
|
| 101 |
-
st.error("
|
| 102 |
-
"
|
| 103 |
-
"original in the meantime.")
|
| 104 |
|
| 105 |
st.divider()
|
| 106 |
-
st.caption("
|
| 107 |
-
"
|
|
|
|
| 16 |
|
| 17 |
PASSPHRASE = os.environ.get("APP_PASSPHRASE", "")
|
| 18 |
|
| 19 |
+
# Where students should send questions / ask to have their report removed.
|
| 20 |
+
# TODO: replace with a real BBH contact email.
|
| 21 |
+
CONTACT = "the BBH team"
|
| 22 |
+
|
| 23 |
st.set_page_config(page_title="STARS Report Redactor", page_icon="π‘οΈ",
|
| 24 |
layout="centered")
|
| 25 |
|
| 26 |
+
# ---------------------------------------------------------------- the ask ----
|
| 27 |
+
st.title("π οΈ Help us build better tools for USC students")
|
| 28 |
+
|
| 29 |
+
st.markdown(
|
| 30 |
+
"BBH (the **BUAI Builder Hub**) is hard at work building tools to make "
|
| 31 |
+
"**degree planning, course registration, and picking classes** way less of "
|
| 32 |
+
"a headache. One thing y'all keep telling us is a pain: actually "
|
| 33 |
+
"**making sense of your STARS report**.\n\n"
|
| 34 |
+
"**You can help.** We're putting together a set of STARS reports to build "
|
| 35 |
+
"against. If you're down, upload yours below β we'll strip out the sensitive "
|
| 36 |
+
"stuff (**your name, address, student ID, and grades**) right here, and only "
|
| 37 |
+
"ever keep the **redacted** version."
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
# ------------------------------------------------------------------- Q & A ----
|
| 41 |
+
st.subheader("Quick questions you might have")
|
| 42 |
|
| 43 |
+
with st.expander("Wait β are my grades going in a database?"):
|
| 44 |
st.markdown(
|
| 45 |
+
"Nope. Before anything gets saved, we swap **every grade for a plain "
|
| 46 |
+
"\"passed / didn't pass\" marker** and **wipe your GPA**. The copy we keep "
|
| 47 |
+
"literally doesn't have your letter grades in it β we can tell a class was "
|
| 48 |
+
"finished, not what you got in it."
|
|
|
|
|
|
|
|
|
|
| 49 |
)
|
| 50 |
|
| 51 |
+
with st.expander("How do I even get my STARS report?"):
|
| 52 |
st.markdown(
|
| 53 |
+
"1. Go to **experience.usc.edu** β **My Academics**.\n"
|
| 54 |
"2. Open your **STARS** (Degree Progress) report.\n"
|
| 55 |
+
"3. Hit the **red Print button** up top.\n"
|
| 56 |
+
"4. In the print pop-up, pick **Save as PDF** and save it.\n"
|
| 57 |
+
"5. Upload that PDF here. (Grab the real PDF from the site β a screenshot "
|
| 58 |
+
"or scan won't work.)"
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
with st.expander("Why should I bother?"):
|
| 62 |
+
st.markdown(
|
| 63 |
+
"You'd be helping build tools that make planning your degree and getting "
|
| 64 |
+
"into the classes you need way less painful β for you *and* everyone after "
|
| 65 |
+
"you. It takes about two minutes, and your personal info and grades get "
|
| 66 |
+
"stripped out before anything is stored. That's it."
|
| 67 |
)
|
| 68 |
|
| 69 |
+
st.markdown("### Ready? Let's do it π")
|
| 70 |
+
|
| 71 |
+
# --------------------------------------------------------------- pass gate ----
|
| 72 |
if not PASSPHRASE:
|
| 73 |
+
st.error("This app isn't set up yet (no passphrase configured). Ping the team.")
|
|
|
|
| 74 |
st.stop()
|
| 75 |
|
| 76 |
+
entered = st.text_input("Passphrase", type="password")
|
| 77 |
+
st.caption("If you're a USC student using this, whoever referred you should've "
|
| 78 |
+
"shared a passphrase.")
|
| 79 |
if entered.strip() != PASSPHRASE:
|
| 80 |
if entered:
|
| 81 |
+
st.warning("Hmm, that's not it β double-check with whoever sent you here.")
|
| 82 |
st.stop()
|
| 83 |
|
| 84 |
+
# ------------------------------------------------------- consent + upload ----
|
| 85 |
+
with st.expander("π Please read this before you upload β what you're agreeing to",
|
| 86 |
+
expanded=True):
|
| 87 |
+
st.markdown(
|
| 88 |
+
"- **This is totally voluntary.** You don't have to do it, and you can "
|
| 89 |
+
"close this page anytime. No penalty, no hard feelings.\n"
|
| 90 |
+
"- **What we keep:** only the **redacted** version of your STARS report β "
|
| 91 |
+
"the file this tool hands back after removing your personal info.\n"
|
| 92 |
+
"- **What's removed before anything is stored:** your **name, USC ID, "
|
| 93 |
+
"mailing address, sport/team**, every **letter grade** (each becomes a "
|
| 94 |
+
"simple pass/fail marker), and your **GPA**.\n"
|
| 95 |
+
"- **What stays in the file:** your **major/minor, the courses and terms "
|
| 96 |
+
"on your record, and your degree-progress details** β that's the part "
|
| 97 |
+
"we're actually building with.\n"
|
| 98 |
+
"- **Heads up on anonymity:** because that academic info stays in, we "
|
| 99 |
+
"**can't promise you're impossible to identify** β in a small major, "
|
| 100 |
+
"someone who already knows your situation might be able to guess. Only "
|
| 101 |
+
"share if you're comfortable with that.\n"
|
| 102 |
+
"- **Your original file** is processed on the spot and **not saved** by "
|
| 103 |
+
"this tool. You download the redacted copy yourself; if you send it back "
|
| 104 |
+
"to us, we store **only that redacted copy**.\n"
|
| 105 |
+
"- **How we use it:** to build and test tools that help USC students plan "
|
| 106 |
+
"degrees and register for classes. We won't sell it or try to identify "
|
| 107 |
+
"you.\n"
|
| 108 |
+
f"- **Changed your mind later?** It's your record and your call β you can "
|
| 109 |
+
f"ask us to delete your redacted report anytime. Contact {CONTACT}."
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
consent = st.checkbox(
|
| 113 |
+
"I've read the above and I'm good with sharing my **redacted** STARS report.")
|
| 114 |
|
| 115 |
uploaded = st.file_uploader(
|
| 116 |
"Upload your STARS report (the PDF you saved from experience.usc.edu)",
|
| 117 |
type=["pdf"], accept_multiple_files=False)
|
| 118 |
|
| 119 |
if uploaded is not None and not consent:
|
| 120 |
+
st.info("Check the consent box above and you're good to go.")
|
| 121 |
|
| 122 |
if uploaded is not None and consent:
|
| 123 |
+
with st.spinner("Scrubbing your infoβ¦"):
|
| 124 |
res, out = engine.redact_bytes(uploaded.getvalue(), {"pii", "grades"})
|
| 125 |
|
| 126 |
status = res["status"]
|
| 127 |
if status in ("REDACTED", "REVIEW") and out:
|
| 128 |
g = res.get("grades", {})
|
| 129 |
+
st.success("Done! Your redacted report is ready below. π")
|
| 130 |
st.write(
|
| 131 |
+
f"We removed **{len(res.get('pii', {}))}** personal detail(s), turned "
|
| 132 |
+
f"**{g.get('grades_replaced', 0)}** grade(s) into pass/fail markers, and "
|
| 133 |
+
f"wiped **{g.get('gpa_replaced', 0)}** GPA/points number(s)."
|
| 134 |
)
|
| 135 |
if res.get("fragments"):
|
| 136 |
+
st.info("Part of your name might still show up inside a course title β "
|
| 137 |
+
"we'll double-check that on our end.")
|
| 138 |
|
| 139 |
stem = os.path.splitext(uploaded.name)[0]
|
| 140 |
stem = stem.replace("DONOTSHARE_", "").replace("REDACTED_", "")
|
| 141 |
+
st.download_button("β¬οΈ Download my redacted report", data=out,
|
| 142 |
file_name=f"REDACTED_{stem}.pdf",
|
| 143 |
mime="application/pdf")
|
| 144 |
+
st.caption("Open it to make sure it looks right, then send it back to "
|
| 145 |
+
"whoever referred you (or to the BBH team). Thank you! π")
|
| 146 |
|
| 147 |
elif status == "SKIPPED":
|
| 148 |
+
st.error("This looks like a **scan or photo** (no text in it), so it can't "
|
| 149 |
+
"be redacted here. Grab the actual PDF via **Print β Save as PDF** "
|
| 150 |
+
"on experience.usc.edu and try again.")
|
|
|
|
| 151 |
else:
|
| 152 |
+
st.error("Something didn't check out, so we **didn't produce a file** β "
|
| 153 |
+
f"better safe than sorry. Please reach out to {CONTACT}, and "
|
| 154 |
+
"don't share the original in the meantime.")
|
| 155 |
|
| 156 |
st.divider()
|
| 157 |
+
st.caption("A BUAI Builder Hub (BBH) project. Your file is processed in memory; "
|
| 158 |
+
"nothing is stored by this tool.")
|