Build the page an administrator uses to add, edit, and remove every student in the program
The Goal
Every student in this program has a record in a database called roster.db. It holds names, logins, class session, level, computer number, district, and more. Right now the only way to change a record is to open the file and edit it by hand. One wrong tab and the whole file breaks.
Your job is to build the admin page that fixes that: one page where an administrator can see every student, open any one of them, change anything, and press Save. The same page adds new students and removes old ones.
You will build it in three parts
UI: what the admin sees. A clean, readable page with a short list of students. Click a student to open that student's full edit form. Plus an "Add a new student" form. No database yet, just the look. Go →
DNA / Data: make it real. Connect the page to roster.db with WebDNA so the list is real and Add, Save, and Delete actually change the data, safely. Go →
JavaScript: make it friendly. Small helpers in the browser: open or close every student at once, warn about unsaved changes, and ask "Are you sure?" before a delete. Go →
What it looks like when it's done
Use these as a reference point. Your colors and layout can be your own; the page has to do the same jobs.
A student opened for editing. The first name was just changed, so the row is marked (unsaved) until Save is pressed.The “Add a new student” area, opened. Same fields, empty, with sensible defaults.
Finish each part and show your teacher before you start the next one. Each part should still work on its own: the page has to do its real job (Part 2) even if JavaScript is turned off.
0Start Here
Go to your assignments folder: /citi/coding/2027/2/YOURINTS/lessons/assignments/. Make a new file there called week2.html. This one file is your whole project.
In the same assignments folder, make a folder called databases.
Download roster.zip and unzip it. It holds two files: roster.db and district.db. Upload both into assignments/databases/. Your page will find them at databases/roster.db and databases/district.db. Do not open them in your editor and save them. If your editor changes their line endings or tabs, WebDNA can stop reading them. Messed one up? Download the zip again for fresh copies.
Open your live URL in Chrome and keep it open the whole time. WebDNA only runs on the server, so always test the live page.
About apps
This assignment names the job, not the app. “Upload” means sending files to the server over SFTP (the secure file transfer protocol). “Your editor” means any plain-text editor. In class we use Fetch for SFTP and BBEdit as the editor, but any SFTP app and any plain-text editor do the same job.
Treat it like real data
The 12 students in the file are made up, but treat them like a real admin would. Do your testing on test students you add yourself (name them something like "Test Student"). Never delete or rename the records that came in the file.
Know Your Data
Before you design a single box, you need to know what is in the table. Here is every field in roster.db. Field names are the exact spelling in the file (WebDNA does not care about capital letters, but spelling must match).
Field
What it holds
Stored as
Best form control
SKU
Record number. WebDNA makes it.
number
Show it, never edit it
FNAME
First name
text
Text box (required)
LNAME
Last name
text
Text box (required)
KEY
A long unique ID made when the record is added
number
Show it, never edit it
UNAME
Login username. No two students may share one.
text
Text box (required)
PWORD
Login password
text
Text box (required)
SESSION
Class session
1 = AM, 0 = PM
Dropdown
SCHOOLYEAR
School year, like 2026
4-digit year
Dropdown: 5 years back to 5 years ahead of this year
Home school district. It holds the sku of a row in district.db, not the name.
number (a district sku)
Dropdown built from district.db
The second table: district.db
The district names live in their own small table. Each district is stored once.
Field
What it holds
sku
The district's record number (1 to 9)
district
The district's name, like Oswego
The two tables are linked. In district.db, sku is the primary key: it names exactly one district. In roster.db, r_district is a foreign key: it points at that sku. (The r_ means “related to.”) If a student's r_district is 6, look up sku 6 in district.db and you get Oswego. Rename a district once in district.db and every student shows the new name.
Notice
Most fields store a number that stands for a word. The database says 1; the admin should see "AM." Your page translates in both directions: show the word, save the number. For most fields, the meaning is in the table above. For the district, the meaning is in district.db.
1UI: What the Admin Sees
Goal: a finished-looking page built with hand-typed sample students. When Part 1 is done, a stranger should be able to look at it and know exactly how to add, edit, and delete a student, even though nothing saves yet.
Steps
Sketch it first. On paper, draw the page: a header, an "Add a new student" area, a toolbar, and a list of students. Decide which 6 to 8 fields are worth seeing in the closed list row (hint: the ones an admin scans for). Everything else lives in the open form.
Build the page shell. Header with a title and one line telling the admin how the page works. Put your CSS in a style block at the top of the page.
Build one student row that opens and closes. Use the HTML element that is made for "click to show more" (look up the pair of tags that do this with no JavaScript). The always-visible part is the summary row. The hidden part is that student's edit form.
Give each student their own form. One form per student, with a field for every editable column in the table above. Use the right control for each field: a text box or a dropdown.
Label every field. Every box gets a visible label. An admin should never have to guess what a box is for.
Group the fields. 15 fields in one long line is unreadable. Group them in boxes with titles, for example Name, Login, Class, Account, and Folder.
Add the buttons. Each student form needs Save, Delete, and Undo changes. Make Delete look different from Save (it should look dangerous). Show the record number and KEY, but as text, not as boxes.
Build the "Add a new student" form. Same fields, empty, inside its own open-and-close area at the top. One button: Add student. Add sensible defaults: this year selected, Active, Student.
Add a toolbar. Two dropdowns above the list: Show (Active, Inactive, All) and Sort (First name, Last name, Record #, Computer #). They don't need to work yet.
Make inactive students look inactive. Pick one of your sample rows to be inactive and style it so an admin can tell at a glance (faded, crossed out, a gray badge, your call).
Copy the row 3 or 4 times with different sample people, so you can judge how a full list looks.
Check a phone-width window. Make your browser narrow. The page must not scroll sideways. Hide the less important summary columns on small screens.
Done with Part 1 when
Each student is a closed summary row that opens to a full, labeled, grouped edit form.
Every editable field from Know Your Data has the right kind of control.
Save, Delete, and Undo changes are on every student; Delete looks different.
The Add form, toolbar, and an inactive row are all there.
No sideways scrolling at phone width.
Show your teacher before Part 2.
2DNA / Data: Make It Real
Goal: the sample rows are gone. The list comes from roster.db, and Add, Save, and Delete really change the data. Bad input can't break the file, and refreshing the page never saves anything twice.
How the page is laid out
Top of the fileSettings: the database path and any default values.
→
ThenThe action section: if a form was sent, do the add, save, or delete, then send the browser back to the page.
→
ThenThe HTML you built in Part 1, now filled from a database search.
→
Very endClose the database so changes are written to the file.
The page sends its forms to itself. One hidden piece of information (an "action") tells the top of the page which job to do. Hint: the Save and Delete buttons can each carry their own action value, so one form can do two jobs.
Steps
Settings. At the top, store each database path (roster and district) in its own text variable. Use the variables everywhere after that, never the typed paths.
List the real students. Replace your sample rows with a database search that finds every record, and put your Part 1 row inside the found-items loop. Every value in the row and the form comes from the record.
Translate numbers to words. In the summary row, show "PM" and "2nd Year," not 0 and 2. For the district, don't type the names into your page: look up the name in district.db using the student's r_district. If no district matches, show "Unknown."
Build the district dropdown from district.db. Replace your hand-typed district options with a search of district.db, sorted by name. Each option's value is the district's sku; its text is the name. Do this in the Add form and in every student's form. The form field is named r_district, to match the database. Careful: inside this search, sku means the district's sku, not the student's. Save the student's district in a text variable before the search starts, then compare to that.
Pre-select every dropdown. Each student's dropdowns must open on that student's saved value. Check the school year carefully: it must show the year in the record, not this year. (Last year's student version got this wrong, and every Save quietly changed students' years.)
Show a count. Above the list, show how many students were found, with the right word: "1 student," "10 students."
Make Show and Sort work. The toolbar sends its choice to the page. Use it to change the search: Active only, Inactive only, or All, and the sort order. Number fields (Record #, Computer #) must sort as numbers, or 10 lands before 2. If no students match, show a friendly "No students match this view" message.
Add. When the Add form is sent, append a new record with every field. Let WebDNA number the record. Give the KEY a unique value made by WebDNA.
Save. When a student's form is sent, replace that one record, found by its record number. Every student form needs to send its record number in a hidden field.
Delete. When Delete is pressed, delete that one record, found by its record number. Only test this on your own test students. The "Are you sure?" comes in Part 3.
Protect the data from special characters. Try adding a last name like O'Brien & Sons and a password with an equals sign in it. If the saved value gets cut off, you forgot to encode the values you write to the database. Every value you save must be encoded.
Block duplicate usernames. Before you add, search for the username. If it's taken, don't add. Show a clear red message, and keep the Add form open with what the admin typed. On Save, the username may match this student, but not anyone else.
Send the browser back after every change. After a successful add, save, or delete, redirect to the page. Then pressing Refresh can never send the form again. Keep the admin's Show and Sort choices in that redirect.
Confirm what happened. After the redirect, show a short green message: "Student added," "Changes saved," "Student deleted." Pass a short code word in the address, not the message itself. The page decides what each code word says. (Why? If the page prints whatever text is in the address, anyone can send an admin a link that puts their own words, or worse, on your page.)
Handle fields that were never sent. Open your page with no form sent. Do any square-bracket names show up in your messages or boxes? A form field that wasn't sent prints its own name. Find each one and make it blank.
Close both databases at the very end of the page.
View Source. On your live page, you should find no square brackets anywhere.
Done with Part 2 when
The list, count, Show, and Sort all come from roster.db.
District names and both district dropdowns come from district.db; nothing about districts is typed into the page.
Add, Save, and Delete work, and every dropdown opens on the saved value.
O'Brien & Sons saves and comes back exactly as typed.
A duplicate username is refused on Add and on Save, with a clear message.
Refreshing after any change does nothing.
The page works with JavaScript turned off.
Show your teacher before Part 3.
3JavaScript: Make It Friendly
Goal: small browser helpers that make the page safer and faster to use. JavaScript never saves data here. WebDNA already does that. JavaScript only helps the admin in the browser.
Watch out
WebDNA reads your whole page before the browser does, JavaScript included. Anything in square brackets inside your script can be read as a WebDNA tag. Write your JavaScript so it needs no square brackets.
Steps
"Are you sure?" before Delete. When Delete is pressed, ask "Delete First Last? This cannot be undone." If the admin cancels, nothing is sent. Get the student's name from a data attribute on the form, not by pasting it into the script. Test it on a name with an apostrophe in it.
Expand all / Collapse all. One toolbar button opens every student. Pressing it again closes them all. The button's words change to match.
Mark unsaved changes. The moment the admin types or changes anything in a student's form, that student's row changes color and says "(unsaved)." Undo changes and Save both clear it.
Warn before leaving. If any row is still marked unsaved and the admin tries to leave or refresh, the browser asks first.
Turn JavaScript off and test again. Everything from Part 2 must still work. (Delete just won't ask first.)
Done with Part 3 when
Delete always asks first, and Cancel really cancels, even for O'Brien.
Expand all and Collapse all work, and the button's words change.
An edited row is marked unsaved; Save and Undo clear it.
Leaving with unsaved edits asks first.
The browser console shows no red errors.
Test Plan: prove it works
Real developers write down their tests and the results. Copy this table into a document, run every test on your live page, and fill in what happened. Hand it in with your page.
#
Do this
It should
1
Add "Test O'Brien & Sons" with password a&b=c
Show "Student added"; name and password come back exactly as typed
2
Add another student with the same username
Refuse, red message, Add form still filled in
3
Change your test student's school year and district and save
Reopen shows the new year and district; the summary row shows the new district name
4
Give your test student a real student's username and save
Refuse with a message; nothing changes
5
Set your test student to Inactive and save
Leaves the Active view; shows in Inactive, styled as inactive
6
Press Refresh right after a save
Nothing is saved again
7
Sort by Computer #
2 comes before 10 and 19
8
Edit a field, then try to leave the page
Row shows unsaved; browser asks before leaving
9
Press Delete, then Cancel
Nothing deleted
10
Delete your test student for real
"Student deleted"; count goes down by one
11
View Source
No square brackets anywhere
12
Narrow the window to phone width
No sideways scrolling
Grading
Part
Points
What earns them
1 · UI
30
Clear layout, open-and-close rows, labeled and grouped fields, right controls, Add form, toolbar, inactive style
2 · DNA / Data
50
Real list and count, Show and Sort, district lookup and dropdown from district.db, Add, Save, Delete, saved values pre-selected, duplicate check, redirect, code-word messages
3 · JavaScript
15
Delete confirm, Expand all, unsaved marker, leave warning, no console errors
Test Plan
5
All 12 tests run on the live page, with results written down
Am I done? Check before you tell your teacher
My page is assignments/week2.html and reads assignments/databases/roster.db and district.db.
Every student opens to a full, labeled edit form with Save, Delete, and Undo changes.
Add, Save, and Delete really change the database, and Refresh never repeats them.
Every dropdown opens on the student's saved value, school year and district included.
Special characters save correctly, and duplicate usernames are refused.
Show, Sort, and the student count work.
Delete asks first; unsaved edits are marked and warned about.
The page works with JavaScript off.
View Source shows no square brackets.
I deleted my test students, and the original records are untouched.