1. Reference Guide

Term Definition / Example College Board Requirement
Class Blueprint for data and behavior: class Submission {} Unit 3, Topic 3.3, pp. 110–113
Instance Variable Stores object-specific data: int submitterId; Unit 3, Topic 3.3, pp. 110–113
Constructor Initializes an object: new Submission(...) Unit 3, Topic 3.4, pp. 110–113
Static Belongs to the class: static int countPending(...) Unit 3, Topic 3.3
ArrayList Resizable collection of object references. Unit 4, Topic 4.8, 4.8.A.1, pp. 110–113
Traversal Visits each element: for (Submission s : all) Unit 4, Topic 4.9, 4.9.A.4, pp. 110–113
Filtering Builds a new list of matching elements. Unit 4, Topic 4.10, 4.10.A.1, pp. 110–113
null Double grade = null; means not graded. —
Role STUDENT, TEACHER, or ADMIN determines access. enum is outside the AP CSA exam subset.

Submissions Page Filters

  • My Submissions: submitterId matches the viewer.
  • Assignments You Created: assignmentOwnerId matches the viewer.
  • All Submissions: Admins see all submissions.
  • Grading status: grade == null means not graded.

Key rule: visibleSubmissionsFor creates a new filtered list rather than modifying the original ArrayList during traversal, avoiding potential ConcurrentModificationException.

Reference: College Board, AP Computer Science A Course and Exam Description (2025), Unit 3, Topics 3.3–3.4, and Unit 4, Topics 4.8–4.10, pp. 110–113.


2. OCS Application

Submissions Page Tabs

The live Submissions page (/submissions) has three tabs. Each displays submissions filtered by the viewer’s role or ownership. Everyone navigate to the OCS Submissions tab and take a look at the assignments you might have submitted or created!

Tab Who Sees It Filter Rule
My Submissions Every logged-in user submitterId matches the viewer
Assignments You Created Teachers who authored an assignment assignmentOwnerId matches the viewer
All Submissions Admins only Show all submissions without filtering

3. Tech Talk

Learning Objective: Write a class that models a submission, store many submissions in an ArrayList, and filter them by the viewer’s role.

Success Criteria: You can write a constructor that sets owner-related fields, traverse an ArrayList with an enhanced for loop, and use selection to return a different list for a student, a teacher, and an admin.

The Open Coding Society Submissions page shows three views of the same data: students see only their own work, teachers see submissions to assignments they created, and admins see everything.

Every view is the same loop. Only the if changes:


for (Submission submission : allSubmissions) {
    if (role == Role.ADMIN) {                                            // everything
        visible.add(submission);
    } else if (role == Role.TEACHER && submission.assignmentOwnerId == userId) {
        visible.add(submission);                                         // my assignments
    } else if (role == Role.STUDENT && submission.submitterId == userId) {
        visible.add(submission);                                         // my work
    }
}

This lesson does not touch the real Submissions database or API. It builds a small, self-contained Java model of the same idea, so you can practice before reading the production code in _layouts/submissions-v2.html and assets/js/submissions/creator-dashboard.js.


Code Examples

A. Submission basics. The Submission class stores who turned it in, who owns the assignment, and the grade

Three parts of a class get mixed up a lot:


int submitterId;                               // instance variable: the data each object keeps
Submission(int id, ...) { this.id = id; ... }  // constructor: fills in the fields
new Submission(1, 101, 201, null)              // object: one real submission

Terminology:

grade is a Double, not a double. Double is a reference type, so it can be null, which the site uses to mean “not graded yet.”


Code Runner Challenge

Run it, then give the pending submission a grade and predict the new output

View IPYNB Source
// CODE_RUNNER: Run it, then give the pending submission a grade and predict the new output
public class SubmissionBasics {
    static class Submission {
        int id;
        int submitterId;
        int assignmentOwnerId;
        Double grade;

        Submission(int id, int submitterId, int assignmentOwnerId, Double grade) {
            this.id = id;
            this.submitterId = submitterId;
            this.assignmentOwnerId = assignmentOwnerId;
            this.grade = grade;
        }
    }

    public static void main(String[] args) {
        Submission graded = new Submission(2, 102, 201, 0.9);
        Submission pending = new Submission(1, 101, 201, null);

        System.out.println("Submission " + graded.id + " by student " + graded.submitterId
                + " for teacher " + graded.assignmentOwnerId + ", grade: " + graded.grade);
        System.out.println("Submission " + pending.id + " by student " + pending.submitterId
                + " for teacher " + pending.assignmentOwnerId + ", grade: " + pending.grade);
        System.out.println("Is submission " + pending.id + " graded? " + (pending.grade != null));
    }
}
SubmissionBasics.main(null);
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

B. Role filtering. The SubmissionRoles class filters one list three different ways

visibleSubmissionsFor walks a List<Submission> with an enhanced for loop and uses if / else if selection to decide whether each submission belongs in the result, based on the caller’s Role.

Common filtering mistake:


allSubmissions.remove(submission);   // changes the list while looping: ConcurrentModificationException
visible.add(submission);             // build a new list of the matches instead

Terminology:

Security boundary: this method only decides what a role is shown. On the real Open Coding Society backend, every submissions API endpoint must also check the caller’s role and identity on the server before returning data. Filtering only in the browser would let anyone request the admin endpoint directly and see every student’s submissions.


Code Runner Challenge

Run the three role checks, then change a submitterId or assignmentOwnerId and predict the new counts.

View IPYNB Source
// CODE_RUNNER: Run the three role checks, then change a submitterId or assignmentOwnerId and predict the new counts.
import java.util.ArrayList;
import java.util.List;

public class SubmissionRoles {
    enum Role { STUDENT, TEACHER, ADMIN }

    static class Submission {
        int id;
        int submitterId;
        int assignmentOwnerId;
        Double grade;

        Submission(int id, int submitterId, int assignmentOwnerId, Double grade) {
            this.id = id;
            this.submitterId = submitterId;
            this.assignmentOwnerId = assignmentOwnerId;
            this.grade = grade;
        }
    }

    public static List<Submission> visibleSubmissionsFor(
            List<Submission> allSubmissions, Role role, int userId) {
        List<Submission> visible = new ArrayList<>();
        for (Submission submission : allSubmissions) {
            if (role == Role.ADMIN) {
                visible.add(submission);
            } else if (role == Role.TEACHER && submission.assignmentOwnerId == userId) {
                visible.add(submission);
            } else if (role == Role.STUDENT && submission.submitterId == userId) {
                visible.add(submission);
            }
        }
        return visible;
    }

    public static void main(String[] args) {
        List<Submission> allSubmissions = new ArrayList<>();
        allSubmissions.add(new Submission(1, 101, 201, null));
        allSubmissions.add(new Submission(2, 102, 201, 0.9));
        allSubmissions.add(new Submission(3, 101, 202, null));
        allSubmissions.add(new Submission(4, 103, 202, 1.0));

        System.out.println("Student 101 sees: " + visibleSubmissionsFor(allSubmissions, Role.STUDENT, 101).size());
        System.out.println("Teacher 201 sees: " + visibleSubmissionsFor(allSubmissions, Role.TEACHER, 201).size());
        System.out.println("Admin sees: " + visibleSubmissionsFor(allSubmissions, Role.ADMIN, 0).size());
    }
}
SubmissionRoles.main(null);
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Hacks & Practice Tasks


Lesson: CSA Roles in Submission, Teaching, and Grading
MCQ Roles: <paste the copied result line, such as 3/4 | answers: B,D,A,C>
Popcorn: predicted counts (mine / teacher / all) = <p1>, <p2>, <p3>; actual = <a1>, <a2>, <a3>
Homework Hack 1: status() checks both print true (yes/no)
Homework Hack 2: countPending check prints true (yes/no)
Homework Hack 3: all three role checks print true (yes/no)

Submission Safety Rules (Read First)

  • One class per cell, ending with ClassName.main(null);.
  • Run each cell and leave the output showing.
  • Use your own IDs, not the sample answer.
  • Include your MCQ score.
  • Use ## headings or smaller.
  • Do not commit real student names, grades, or submission content.

Popcorn Hack (In-Class)

2-minute challenge: put yourself in the submissions list, predict what each tab shows, then run the cell.

  1. Pick your own student ID for myId
  2. Pick a teacher ID for teacherId
  3. Add two submissions where you are the submitter: one for teacherId’s assignment and one for a different teacher
  4. Before running, write down how many rows each tab will show
  5. Run it and compare with your prediction
  6. Read the Popcorn checker under the runner. When every check passes, copy its line into your submission notes

Replace the sample values with your own.

Code Runner Challenge

Replace the sample IDs with your own, predict the three counts, then run it

View IPYNB Source
// CODE_RUNNER: Replace the sample IDs with your own, predict the three counts, then run it
// Practice #1 - Try it yourself first!
import java.util.ArrayList;
import java.util.List;

public class PopcornRoles {
    static class Submission {
        int submitterId;
        int assignmentOwnerId;

        Submission(int submitterId, int assignmentOwnerId) {
            this.submitterId = submitterId;
            this.assignmentOwnerId = assignmentOwnerId;
        }
    }

    public static void main(String[] args) {
        int myId = 500;       // your student ID
        int teacherId = 900;  // a teacher's ID

        List<Submission> submissions = new ArrayList<>();
        submissions.add(new Submission(101, teacherId));  // someone else's work

        // Try writing your own two submissions here first!

        // Sample answer:
        submissions.add(new Submission(myId, teacherId));
        submissions.add(new Submission(myId, 901));

        int mine = 0;
        int teachers = 0;
        for (Submission submission : submissions) {
            if (submission.submitterId == myId) {
                mine++;
            }
            if (submission.assignmentOwnerId == teacherId) {
                teachers++;
            }
        }

        System.out.println("My Submissions tab: " + mine);
        System.out.println("Assignments You Created tab (teacher " + teacherId + "): " + teachers);
        System.out.println("All Submissions tab: " + submissions.size());
    }
}

PopcornRoles.main(null);
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Write your predictions here before you press Run.

    Pass every check to finish the Popcorn Hack.

    4. MCQ Check

    4 questions, one at a time. Answer, check, then go to the next one. At the end, copy the score line into your submission notes.

    5. Homework Hack

    Task: Rebuild the Submissions model one piece at a time. Each starter compiles before you edit it, so you can run the initial version and compare its incorrect output with the expected output. Change only the requested method, and keep going until every check prints true.

    Solution Skeleton:

    Hack 1: Add a Status Method to the Class (5 minutes)

    Class creation. Complete the Submission class by adding a status() method. Return "graded" when grade is not null, and "pending" otherwise.

    Code Runner Challenge

    Finish status() so both checks print true.

    View IPYNB Source
    // CODE_RUNNER: Finish status() so both checks print true.
    public class SubmissionStatusHack {
        static class Submission {
            Double grade;
    
            Submission(Double grade) {
                this.grade = grade;
            }
    
            String status() {
                // TODO: return "graded" when grade is not null, otherwise "pending".
                return "not implemented";
            }
        }
    
        public static void main(String[] args) {
            Submission graded = new Submission(0.85);
            Submission pending = new Submission(null);
    
            System.out.println("graded".equals(graded.status()));
            System.out.println("pending".equals(pending.status()));
        }
    }
    SubmissionStatusHack.main(null);
    
    Lines: 1 Characters: 0
    Output
    Click "Run" in code control panel to see output ...

    Hack 2: Count Pending Submissions (5 minutes)

    Data collections. Complete countPending. Iterate through submissions and return how many have a null grade.

    Code Runner Challenge

    Add a loop so the check prints true.

    View IPYNB Source
    // CODE_RUNNER: Add a loop so the check prints true.
    import java.util.ArrayList;
    import java.util.List;
    
    public class PendingCountHack {
        static class Submission {
            Double grade;
    
            Submission(Double grade) {
                this.grade = grade;
            }
        }
    
        public static int countPending(List<Submission> submissions) {
            // TODO: iterate through submissions and count the ones with grade == null.
            return -1;
        }
    
        public static void main(String[] args) {
            List<Submission> submissions = new ArrayList<>();
            submissions.add(new Submission(null));
            submissions.add(new Submission(0.75));
            submissions.add(new Submission(null));
    
            System.out.println(countPending(submissions) == 2);
        }
    }
    PendingCountHack.main(null);
    
    Lines: 1 Characters: 0
    Output
    Click "Run" in code control panel to see output ...

    Hack 3: Filter Submissions by Role (5 minutes)

    Combined algorithm. Complete visibleSubmissionsFor. Combine iteration and selection: an ADMIN sees every submission, a TEACHER sees submissions whose assignmentOwnerId matches userId, and a STUDENT sees submissions whose submitterId matches userId.

    Code Runner Challenge

    Combine a loop with role-based selection so all three checks print true.

    View IPYNB Source
    // CODE_RUNNER: Combine a loop with role-based selection so all three checks print true.
    import java.util.ArrayList;
    import java.util.List;
    
    public class RoleFilterHack {
        enum Role { STUDENT, TEACHER, ADMIN }
    
        static class Submission {
            int submitterId;
            int assignmentOwnerId;
    
            Submission(int submitterId, int assignmentOwnerId) {
                this.submitterId = submitterId;
                this.assignmentOwnerId = assignmentOwnerId;
            }
        }
    
        public static List<Submission> visibleSubmissionsFor(
                List<Submission> allSubmissions, Role role, int userId) {
            List<Submission> visible = new ArrayList<>();
    
            // TODO: iterate through allSubmissions.
            // TODO: use role and userId to decide whether each submission belongs in visible.
    
            return visible;
        }
    
        public static void main(String[] args) {
            List<Submission> allSubmissions = new ArrayList<>();
            allSubmissions.add(new Submission(101, 201));
            allSubmissions.add(new Submission(102, 201));
            allSubmissions.add(new Submission(103, 202));
    
            System.out.println(visibleSubmissionsFor(allSubmissions, Role.STUDENT, 101).size() == 1);
            System.out.println(visibleSubmissionsFor(allSubmissions, Role.TEACHER, 201).size() == 2);
            System.out.println(visibleSubmissionsFor(allSubmissions, Role.ADMIN, 0).size() == 3);
        }
    }
    RoleFilterHack.main(null);
    
    Lines: 1 Characters: 0
    Output
    Click "Run" in code control panel to see output ...

    Grading Plan (1 Point Total)

    Part Points What earns the points
    Popcorn 0.2 Two submissions added with your own ID, predicted and actual counts recorded, and the cell runs.
    MCQ 0.2 4 correct. 0.15 for 2 or 3, 0.1 if every question was answered.
    Homework Hack 1 0.15 status() returns "graded" or "pending" based on the grade field.
    Homework Hack 2 0.2 countPending traverses the list and returns the correct count.
    Homework Hack 3 0.25 Traversal and role-based selection correctly filter all three roles.
    Total 1.0  

    Quick Validation Checklist

    • Each cell ends with ClassName.main(null); and shows output.
    • MCQ score in the notes.
    • Popcorn predictions written down before running.
    • Every homework check prints true.
    • No real student names, grades, or submission content.

    6. LxD Cycle Process

    Empathize: Students can describe “roles” in the abstract but struggle to see how a UI with three tabs (My Submissions, Assignments You Created, All Submissions) maps onto ordinary Unit 3 and Unit 4 Java code. Many also assume that hiding data on the screen is the same as protecting it.

    Define:

    • POV: CSA students need to see that a role-based view is just a traversal plus selection over one shared list, because the same pattern shows up anywhere data is shared between students, teachers, and admins.
    • Learning Goal: Students will write a class that models a submission, store submissions in an ArrayList, and filter the list differently for each role.

    Ideate:

    • HMW Question: How might we connect three tabs on a web page to one if / else if chain inside a loop?
    • HMW Question: How might we show that filtering on the client decides what is shown, not what is allowed?
    • Activity: Trace the real Submissions page, add your own submissions in the Popcorn Hack, check understanding with the MCQ, then rebuild the class and filter step by step in the homework.

    Prototype:

    • A reference guide, runnable Java examples built on one shared Submission model, an in-class popcorn hack, an MCQ knowledge check, and three scaffolded homework hacks with self-checking output.
    • Every starter compiles before editing, so students can compare wrong output with the expected true checks and revise.
    • Excellence means explaining why each role gets its rule, and why the server must repeat the check.

    Test:

    • Ask peers in peer review to complete the practice without additional explanation.
    • Observe whether peers can say which field each role compares against.
    • Compare your lesson with another that is posted.
    • Use the findings to revise any instruction or rubric criterion that did not guide students clearly.
    • On submission, collect evidence from runner output, MCQ results, AI grading and student explanations.
    • After teaching, grading and analysis, come back and revise lesson to complete teaching cycle for continuous improvement.

    Revision Made: The lesson builds one small Submission class and one List<Submission>, then reuses that same model across the worked examples, the popcorn hack, and all three homework hacks, so students practice the class-plus-collection pattern from several angles instead of on unrelated examples.

    Feedback Received: Ground every code example in the real Submissions page instead of an invented scenario, so students can open _layouts/submissions-v2.html and assets/js/submissions/creator-dashboard.js afterward and recognize the same filtering logic.


    7. References/Citations

    College Board. (2025). AP Computer Science A course and exam description [Effective fall 2025]. https://apcentral.collegeboard.org/media/pdf/ap-computer-science-a-course-and-exam-description-effective-fall-2025.pdf

    Open Coding Society. (2026). Submissions dashboard [Web application feature]. https://pages.opencodingsociety.com/submissions

    Submit Assignment

    This submits the code from this lesson's code runner(s) below as a Gist for automatic review. Save each runner with its 💾 button before submitting.

      Need to update a submission later? Open the submissions dashboard.