Welcome to the PeP5 Wiki
Relevant source files
The following files were used as context for generating this wiki page:- Models/ProgrammingExamModels.cs
- DEPLOY-GCLOUD.md
- Services/OpenAIService.cs
- PeP.ExamApp/Installer/README.md
- wwwroot/js/pep-ide.js
- Services/CodeExecutionService.cs
- PeP.ExamApp/Pages/AntiCheatPage.xaml.cs
- Controllers/ExamAppController.cs
- Data/ApplicationDbContext.cs
- Models/ExamModels.cs
- PeP.ExamApp/Pages/ExamCodePage.xaml.cs
- PeP.ExamApp/Pages/TeacherAuthPage.xaml.cs
- deploy-gcloud.ps1
- PeP.ExamApp/Installer/build-installer.ps1
PeP5 (Programming Examination Platform) is a comprehensive system for creating, administering, and evaluating programming exams. It consists of a web-based platform for instructors to design exams and a secure, locked-down desktop application for students to take them. The system supports both traditional multiple-choice questions and complex, project-based programming tasks.
Key features include a secure desktop client with anti-cheat measures, automated code execution against test cases, and AI-powered services for generating questions and evaluating student code submissions. The platform is designed for cloud deployment, specifically on Google Cloud Platform, and utilizes a range of modern technologies including .NET, Blazor, WPF, and external APIs for code execution and AI.
Architecture Overview
The PeP5 system is composed of several key components that interact to provide a complete examination experience. The main components are the PeP Web App, the PeP Exam App (desktop client), a SQL Server database, and external services for specialized tasks.
This diagram illustrates the high-level architecture of the PeP5 platform.
Database Schema
The core of PeP5 is its relational database, which stores all information about courses, exams, users, and attempts. The system uses Entity Framework Core for data access. There are two main types of exams: standard multiple-choice exams and programming exams, each with its own set of related tables.
Entity Relationship Diagram
The following diagram shows the key entities and their relationships for the programming exam module.
Key Data Models
Standard Exam Models
These models support traditional multiple-choice exams.
| Class | Description | File |
|---|---|---|
Exam | Represents a standard exam with properties like duration, scoring type, and a collection of questions. | Models/ExamModels.cs:33 |
Question | A single question within an exam, which can be multiple-choice or multiple-answer. | Models/ExamModels.cs:111 |
QuestionChoice | A possible answer for a Question. | Models/ExamModels.cs:141 |
ExamAttempt | A student's attempt at a standard exam, tracking score and status. | Models/ExamModels.cs:163 |
StudentAnswer | A student's submitted answer for a specific question in an attempt. | Models/ExamModels.cs:197 |
Programming Exam Models
These models are specifically designed for project-based programming exams.
| Class | Description | File |
|---|---|---|
ProgrammingExam | Defines a programming exam, including the language, project name, and starter files. | Models/ProgrammingExamModels.cs:8 |
ProgrammingTask | A specific task or problem within a programming exam, with instructions and points. | Models/ProgrammingExamModels.cs:90 |
TestCase | A test case for a ProgrammingTask used for automated evaluation, with input, expected output, and points. | Models/ProgrammingExamModels.cs:119 |
ProjectFile | A starter file (source code, data file, etc.) provided to the student at the beginning of the exam. | Models/ProgrammingExamModels.cs:152 |
ProgrammingExamAttempt | A student's attempt at a programming exam, tracking status, score, and containing all student-modified files. | Models/ProgrammingExamModels.cs:189 |
StudentProjectFile | A student's version of a project file, storing their code and modifications. | Models/ProgrammingExamModels.cs:258 |
TaskProgress | Tracks a student's progress on a single ProgrammingTask, including AI feedback and scores. | Models/ProgrammingExamModels.cs:282 |
TestCaseResult | The result of running a single TestCase against the student's code. | Models/ProgrammingExamModels.cs:348 |
CodeSubmission | A snapshot of the student's code, created on auto-save, manual save, or run. | Models/ProgrammingExamModels.cs:377 |
Sources: Models/ProgrammingExamModels.cs, Models/ExamModels.cs
AI Services Integration
PeP5 leverages the OpenAI API for two primary purposes: generating exam content and evaluating student code. The OpenAIService class encapsulates this functionality.
Sources: Services/OpenAIService.cs
AI-Powered Exam Generation
The system can automatically generate both multiple-choice questions and complete programming exam projects based on a given topic, difficulty, and language.
- Question Generation: The
GenerateQuestionsAsyncmethod creates a set of multiple-choice questions by providing a structured prompt to the AI. It requests a strict JSON output and performs multiple attempts and parsing to ensure valid data is returned. - Programming Exam Generation: The
GenerateProgrammingTasksAsyncmethod generates a full-fledged programming exam, including a project name, description, starter files (withTODOcomments), and multiple tasks with instructions and test cases. It is capable of creating data files (e.g., CSV, JSON) for tasks involving file I/O.
Sources: Services/OpenAIService.cs:91-247, Services/OpenAIService.cs:257-410
AI Code Evaluation
A core feature is the automated evaluation of student code submissions using an AI model. The EvaluateCodeAsync method sends the student's code, the task instructions, and a detailed system prompt to the AI for assessment.
This sequence diagram shows the code evaluation flow.
The evaluation returns a detailed breakdown of the student's performance based on several criteria:
| Metric | Description |
|---|---|
Score | The final score awarded for the task, out of maxPoints. |
CodeQualityScore | A score from 0-100 for structure, readability, and naming. |
CorrectnessScore | A score from 0-100 assessing if the logic implements the task requirements. |
EfficiencyScore | A score from 0-100 for the algorithmic efficiency of the solution. |
CompletionPercentage | A score from 0-100 indicating how much of the task was addressed. |
Feedback | Detailed constructive feedback on the overall submission. |
CodeSnippets | Specific snippets from the student's code with targeted comments. |
Sources: Services/OpenAIService.cs:17-36, Services/OpenAIService.cs:644-825
Code Execution Service
To run student code against test cases, PeP5 uses the CodeExecutionService, which acts as a client for the external Piston API. This service is responsible for packaging the student's files, sending them for execution, and interpreting the results.
The following diagram shows the process of executing a single test case.
A key implementation detail is the InjectDataFiles method. Since the Piston API does not support a virtual file system, this method reads data files (like .csv or .txt) and embeds their content as strings within a helper source file (e.g., DataFiles.java or data_helper.py). This allows the student's code to "read" files in the sandboxed execution environment.
Sources: Services/CodeExecutionService.cs:194-281
Secure Exam App (PeP.ExamApp)
The PeP.ExamApp is a WPF desktop application that provides a secure environment for students to take exams.
Authentication and Authorization Flow
Before starting an exam, a student must go through a multi-step authentication and authorization process, which involves the teacher's approval.
This flowchart outlines the student's journey from login to starting the exam.
Anti-Cheat System
The application performs a series of security checks before allowing an exam to begin. These checks are implemented in the AntiCheatPage.
The following checks are performed:
- Administrator Privileges: Verifies the application is running with admin rights.
- Monitor Count: Ensures only one display is connected.
- Remote Session: Detects if the session is a remote desktop connection.
- Virtual Machine: Checks if the OS is running inside a VM.
- Debugger Attached: Verifies no debugger is attached to the process.
- Blacklisted Processes: Scans for and flags processes associated with screen recording, remote access, or cheating tools.
- Screen Recording: Checks for active screen recording sessions.
If any blocking issues are found, the "Launch Exam" button is disabled. For blacklisted processes, the student is given an option to automatically close them.
Sources: PeP.ExamApp/Pages/AntiCheatPage.xaml.cs:69-148
IDE and Editor
For programming exams, the exam runner page hosts a WebView2 control that loads the web-based IDE. The front-end interaction with the Monaco Editor is managed by pep-ide.js. This JavaScript interop layer provides functions to create, update, and interact with the editor from the Blazor application.
Key functions include:
createEditor: Initializes a new Monaco editor instance.getContent/setContent: Gets or sets the editor's content.OnEditorContentChanged: A callback that invokes a .NET method when the content changes.OnEditorSaveRequested: A callback that invokes a .NET method whenCtrl+Sis pressed.setMarkers: Displays error or warning markers in the editor, typically for compilation errors.
Sources: wwwroot/js/pep-ide.js:2-80
Installer and Auto-Update
The PeP.ExamApp installer is built using Inno Setup. The build process is automated with a PowerShell script (build-installer.ps1).
The application supports auto-updates by checking an API endpoint on startup.
- Endpoint:
GET /api/exam-app/update?currentVersion=X.X.X - Configuration: The update information is managed in the main web application's configuration.
{
"ExamAppUpdate": {
"Version": "1.1.0",
"DownloadUrl": "https://yourserver.com/downloads/PeP.ExamApp_Setup_1.1.0.exe",
"ReleaseNotes": "- Bug fixes\n- Performance improvements",
"ReleaseDate": "2025-12-22",
"IsMandatory": false,
"MinimumVersion": "1.0.0",
"Checksum": "sha256hashofinstallerfile"
}
}
Sources: PeP.ExamApp/Installer/README.md:55-77, Controllers/ExamAppController.cs:29-50, PeP.ExamApp/Installer/build-installer.ps1
Cloud Deployment
The platform is designed for deployment on Google Cloud Platform. The DEPLOY-GCLOUD.md guide and deploy-gcloud.ps1 script outline the infrastructure setup.
Google Cloud Services
Sources: DEPLOY-GCLOUD.md, deploy-gcloud.ps1
Estimated Monthly Costs
The following table provides a cost estimate based on the recommended specifications.
| Service | Specification | Est. Cost |
|---|---|---|
| Cloud SQL for SQL Server | db-custom-1-3840 (1 vCPU, 3.75GB RAM) | ~$50-80 |
| Cloud Run | 1 vCPU, 512MB RAM, auto-scaling | ~$5-20 |
| Cloud Storage | For ExamApp installer hosting | ~$1 |
| Total | ~$56-100/month |
Note: Costs are estimates and vary based on actual usage.
Sources: DEPLOY-GCLOUD.md:10-18