1. Reference Guide

Key Topics


Term Definition Example
Class Blueprint that groups related data into one type. class Submission { ... }
Instance variable A field each object keeps its own copy of. int submitterId;
Constructor Sets an object’s fields when it is created with new. new Submission(1, 101, 201, null)
Static Belongs to the class itself, not to any one object, so it is used with the class name instead of new. public static int countPending(...)
ArrayList A resizable list of object references. List<Submission> all = new ArrayList<>();
Traversal Visiting every element of a collection. for (Submission s : all)
Selection Choosing what to do with an if / else if. if (role == Role.ADMIN)
Role Which kind of user is viewing the data. STUDENT, TEACHER, ADMIN
  • A Double grade of null means not graded yet, which a primitive double cannot express
  • Filtering never changes the original list; it builds a new list of the matches

Submissions Page Tabs

The live Submissions page (/submissions) has three tabs. Each tab is the same list of submissions, filtered a different way:

Tab Who sees it Filter rule
My Submissions Every logged-in user Keep only submissions where submitterId matches the viewer
Assignments You Created Any teacher who authored an assignment Keep only submissions whose assignment is owned by the viewer
All Submissions Admins only Keep every submission, no filter

Picking a Filter Rule

  • “What did I turn in?” → compare submitterId to the viewer
  • “Who turned in my assignment?” → compare assignmentOwnerId to the viewer
  • “Show me everything” → no comparison, admins only
  • “Is it graded?” → check whether grade is null

2. 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.

3. College Board Requirements

This lesson combines AP CSA Unit 3, Class Creation (Topic 3.3 Anatomy of a Class and Topic 3.4 Constructors), with Unit 4, Data Collections (Topics 4.8 to 4.10 on ArrayList). Quoted from the course and exam description (College Board, 2025, pp. 110-113):

  • 4.8.A.1 “An ArrayList object is mutable in size and contains object references.”
  • 4.9.A.4 “Changing the size of an ArrayList while traversing it using an enhanced for loop can result in a ConcurrentModificationException. Therefore, when using an enhanced for loop to traverse an ArrayList, you should not add or remove elements.”
  • 4.10.A.1 “There are standard ArrayList algorithms that utilize traversals to: … determine if at least one element has a particular property; … determine the number of elements having a particular property; …”

This is why visibleSubmissionsFor builds a new list instead of removing rows from the original while it loops.

enum is outside the AP CSA Java subset. This lesson uses it for Role because it matches how the real backend names roles, but it will not be on the exam; a String or int constant would work the same way.


4. Lesson Plan

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.

Tech Talk (5 minutes)

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.html and assets/js/submissions/creator-dashboard.js.


5. 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 ...

6. Hacks & Practice Tasks

Prepare your submission IPYNB

  1. Create a new notebook in your portfolio homework area: _notebooks/homework.
  2. Add one raw cell at the top with the frontmatter:

---
layout: post
codemirror: true
title: Submission Roles HW
categories: [Java]
lesson_language: Java
lesson_topic: Submission-Roles HW
lesson_part: interactive
lesson_type: lesson
permalink: /csa/unit_04/submission-roles-hw
author: yourGithubID
---
  1. Add code cells for the Popcorn Hack and the three Homework Hacks. Make sure every cell runs with visible output.
  2. Submit the link to your published page at the bottom of this page, and paste this in the description box:

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.

    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.

    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.

    7. Lesson Revisions

    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.


    8. Feedback Evidence

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


    9. References

    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

    Self-Assessment

    Rate your work on this assignment, then add a short reflection. All 5 fields are required before you can submit.

    Technical Excellence

    Rate the technical quality of your work on this assignment — your use of tools, problem-solving, and technical growth.

    1 Explore · 2 Understand · 3 Apply · 4 Analyze/Evaluate · 5 Create/Extend
    Communication

    Rate how clearly you communicated your work and process — explanations, documentation, and collaboration or help-seeking.

    1 Beginning · 2 Developing · 3 Consistent · 4 Strong · 5 Model
    Work Habits

    Rate your work habits on this assignment — time management, persistence, responsibility, and follow-through.

    1 Beginning · 2 Developing · 3 Consistent · 4 Strong · 5 Model
    AI Orchestration

    Rate how effectively you used AI tools to support your work — prompting, verifying, extending, or accelerating your development process.

    1 Explore · 2 Understand · 3 Apply · 4 Analyze/Evaluate · 5 Create/Extend

    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.