Skip to content

phsestep/PythonQuizAISite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AP Java Student Server

A web-based platform for AP Java students to write, run, and submit code with AI tutoring assistance and automated grading powered by Claude AI.

Features

Student Portal

  • No Login Required: Students simply enter their name to get started
  • Markdown Assignment Prompts: Teachers can use markdown formatting (bold, lists, code blocks) in assignment instructions
  • Advanced Code Editor: CodeMirror-powered editor with:
    • Syntax highlighting for Java (keywords, strings, comments, etc.)
    • Auto-indent and smart formatting
    • Line numbers
    • Bracket matching and auto-closing
    • Maximized editor space (600px height)
  • Font Size Control: Choose between Small (A-), Medium (A), and Large (A+) text sizes
  • Dark Mode: Toggle between light and dark themes (preference saved)
  • Interactive Coding: Write and run Java code directly in the browser with any class name
  • Interactive Console: Real-time console with Scanner support - type input directly when program prompts
  • WebSocket-based execution: Live output streaming as the program runs
  • Flexible Class Names: System automatically detects and uses the student's class name
  • AI Tutor: Ask questions and receive markdown-formatted hints (not direct answers) from Claude
  • Brief Feedback Mode: Toggle for shorter, more concise AI responses (2-3 sentences)
  • Smart Context: AI tutor automatically receives your code and console output for better assistance
  • Maximized Chat Area: Larger chat space (600px height, 500px width) for better readability
  • Instant Feedback: Submit code and receive immediate grading and detailed feedback
  • Assignment Management: View and work on teacher-assigned problems

Teacher Dashboard

  • Dark Mode: Toggle between light and dark themes (preference saved)
  • Assignment Management: Create, edit, and delete coding assignments with prompts and detailed rubrics
  • Edit Assignments: Modify assignment title, prompt, and rubric after creation
  • Delete Assignments: Remove assignments and all related submissions/chat history with confirmation
  • API Key Management: Securely configure your Claude API key
  • Submission Viewing: View and review all student submissions with full code display
  • AI-Powered Grading: Automatically grade all submissions or individual ones using Claude
  • Student Roster: Track all registered students and their progress
  • Class Overview: View grades and feedback across the entire class
  • Question Logging: All student questions are logged to studentQuestions.txt with full context (code, output, errors)
  • Questions Tab: View all student questions directly in the dashboard with their code context
  • Enhanced Submission Details: Click any submission to view student code, grade, and detailed feedback in a modal
  • Black & Gold Theme: Student interface uses Purdue University's black and gold color scheme

Prerequisites

  • Node.js (v14 or higher)
  • Java Development Kit (JDK) installed on the server (for code execution)
  • Claude API Key from Anthropic

Installation

For detailed step-by-step instructions to replicate this project on a new computer, see replicateProject.txt.

Quick Start:

  1. Clone or download this repository

  2. Install dependencies:

    npm install
  3. Verify Java is installed:

    java -version
    javac -version

    If Java is not installed, download and install the JDK from Oracle or use OpenJDK.

Running the Server

  1. Start the server:

    npm start

    For development with auto-restart:

    npm run dev
  2. Access the application:

    • Open your browser and navigate to http://localhost:3000
    • Choose between Student Portal or Teacher Dashboard

Initial Setup for Teachers

  1. Go to the Teacher Dashboard (http://localhost:3000/teacher.html)
  2. Enter the teacher password: SMCSChief
  3. Navigate to the Settings tab
  4. Enter your Claude API key (get one from Anthropic Console)
  5. Click Save API Key
  6. Go to the Assignments tab and create your first assignment

How Students Use the Platform

  1. Navigate to the Student Portal (http://localhost:3000/student.html)
  2. Enter your name (no password needed)
  3. Select an assignment from the dropdown
  4. Write your Java code in the editor (starts with a Hello World template)
    • Note: You can use any class name - the system automatically detects it!
  5. Click Run Code to test your solution
  6. Use the AI Tutor chat for hints and guidance
    • The tutor automatically sees your code and any errors you encountered
  7. Click Submit for Grading when ready
  8. Receive instant feedback and grade

How Teachers Use the Platform

Creating an Assignment

  1. Go to Teacher Dashboard > Assignments tab
  2. Fill in:
    • Title: Name of the assignment
    • Prompt: What students need to accomplish
    • Rubric: Detailed grading criteria
  3. Click Create Assignment

Grading Submissions

Option 1: Grade All Submissions

  • Go to the Assignments tab
  • Click Grade All Submissions for an assignment
  • Claude will automatically grade all ungraded submissions

Option 2: View Individual Submissions

  • Go to the Submissions tab
  • Filter by assignment if needed
  • View individual submissions and their grades/feedback

Project Structure

AA Java Student Server/
├── server.js              # Express server with all API endpoints
├── database.js            # SQLite database initialization
├── package.json           # Node.js dependencies
├── apjava.db             # SQLite database (created on first run)
├── studentQuestions.txt  # Log of all student questions with context (created on first question)
├── public/               # Frontend files
│   ├── index.html        # Landing page
│   ├── student.html      # Student portal interface
│   └── teacher.html      # Teacher dashboard interface
├── startHere.txt         # Project requirements and notes
├── replicateProject.txt  # Step-by-step guide to replicate this project
└── README.md            # This file

API Endpoints

Students

  • POST /api/students - Register a new student
  • GET /api/students - Get all students
  • GET /api/students/:id - Get student by ID

Assignments

  • POST /api/assignments - Create new assignment
  • GET /api/assignments - Get all assignments
  • GET /api/assignments/:id - Get assignment by ID
  • PUT /api/assignments/:id - Update an assignment
  • DELETE /api/assignments/:id - Delete an assignment and all related data

Code Execution

  • POST /api/run-code - Compile and run Java code

Tutoring

  • POST /api/chat - Send message to AI tutor

Submissions

  • POST /api/submit - Submit code for grading
  • GET /api/submissions/assignment/:assignmentId - Get submissions for an assignment
  • GET /api/submissions/student/:studentId - Get submissions for a student
  • GET /api/submissions/:id - Get single submission with full details

Grading

  • POST /api/grade-all/:assignmentId - Grade all ungraded submissions for an assignment

Settings

  • POST /api/settings/api-key - Save Claude API key
  • GET /api/settings/api-key-status - Check if API key is configured

Questions

  • GET /api/student-questions - Get all student questions from log file with parsed context

Authentication

  • POST /api/teacher/login - Teacher login with password validation
  • GET /api/teacher/check-auth - Check if teacher is authenticated
  • POST /api/teacher/logout - Destroy teacher session

Security Considerations

Current Implementation (Development):

  • Java code runs directly on the server (suitable for trusted educational environments)
  • Teacher dashboard protected with server-side password validation
  • Password: SMCSChief (stored server-side, never sent to browser)
  • Session-based authentication using express-session
  • Session cookies are httpOnly to prevent XSS attacks
  • API key stored in SQLite database
  • No authentication required for students

For Production Use, Consider:

  • Docker containers for isolated code execution
  • User authentication and authorization
  • Rate limiting for API calls
  • Encrypted storage for API keys
  • HTTPS/SSL certificates
  • Input validation and sanitization

Student Question Logging

Every time a student asks a question to the AI tutor, the system automatically logs it to studentQuestions.txt in the project root directory. Each log entry includes:

  • Timestamp: When the question was asked
  • Student Name and ID: Who asked the question
  • Assignment Title and ID: What they were working on
  • Question: The actual question text
  • Code: Their current code (if available)
  • Output: Console output from their last run (if available)
  • Error: Any error messages (if available)

Example log entry:

================================================================================
Timestamp: 2025-11-06T21:30:45.123Z
Student: John Smith (ID: 5)
Assignment: Arrays and Loops Practice (ID: 2)
Question: Why is my loop not stopping?

Code:
public class Main {
    public static void main(String[] args) {
        for (int i = 0; i < 10; i--) {
            System.out.println(i);
        }
    }
}
================================================================================

This log file helps teachers:

  • Understand common student difficulties
  • Identify patterns in questions
  • Review what students are struggling with
  • Improve future assignments based on question trends

Note: The file is automatically created when the first question is asked and is excluded from git by default.

Database Schema

Tables

  • students: Student information (id, name, created_at)
  • assignments: Assignment details (id, title, prompt, rubric, created_at)
  • submissions: Code submissions (id, student_id, assignment_id, code, feedback, grade, submitted_at)
  • chat_history: AI tutor conversations (id, student_id, assignment_id, role, message, created_at)
  • settings: Application settings (key, value) - stores API key

Troubleshooting

Java Code Won't Run

  • Ensure JDK is installed: java -version and javac -version
  • Check that Java is in your system PATH
  • Verify the student's code has a public class with a main method

AI Tutor Not Working

  • Verify Claude API key is configured in Teacher Dashboard > Settings
  • Check that the API key is valid in the Anthropic Console
  • Ensure you have API credits available

Database Issues

  • Delete apjava.db and restart the server to recreate the database
  • Check file permissions in the project directory

Future Enhancements

Potential features to add:

User Experience:

  • Keyboard shortcuts (Ctrl+S to save, custom keybindings)
  • Auto-save functionality
  • Mobile-responsive design improvements
  • Font size adjustment in code editor
  • Additional CodeMirror themes and customization options
  • Code folding for large programs

Security & Infrastructure:

  • User authentication for students
  • Docker-based code execution for better security
  • Rate limiting and input validation

Features:

  • Support for multiple programming languages
  • Test case validation with hidden tests
  • Code plagiarism detection
  • Assignment deadlines and late submission handling
  • Code version history
  • Export grades to CSV
  • Collaborative coding features

Analytics:

  • Detailed analytics and progress tracking
  • Student performance dashboards
  • Common error analysis from question logs
  • Time tracking per assignment

License

MIT License

Support

For issues or questions, please create an issue in the project repository.

About

AP Python Educational Platform

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors