Shipping an Online Exam System in 3 Hours: An AI Coding Practice Report

    This article documents a real three-hour sprint to turn a messy question bank into a usable online exam system with AI coding assistance. It covers why a local offline model setup failed, how to choose between local small models, cloud coding assistants, and integrated cloud platforms, and a five-stage workflow from requirement scoping and schema design to staged generation, integration hardening, and deployment. It also shares prompt structure, common pitfalls, and the key takeaway that scope control, layered generation, and closed-loop validation matter more than raw generation speed.

    1. How It Started: An Almost Impossible Last-Minute Task

    At 8 a.m., a message dropped a poorly formatted question bank on my desk along with one requirement: it had to be ready to use before 11 a.m. My first instinct was to refuse. Building, integrating, and deploying a deliverable system from scratch in three hours is barely realistic under a normal engineering pace. But the point worth recording is not whether it got done. It is a common problem this exposed: many people treat AI coding as “generate a whole system from one sentence,” when the real bottleneck is never the speed of code generation. It is requirement convergence, quality validation, and the final delivery format.

    This article does not promote any specific product. Instead, it abstracts the experience into a general technical question: within a very short window, how do you use AI coding capabilities to turn a vague requirement into an acceptable, working system?

    2. First Failure: The Reality of a Local Offline Setup

    The first choice was a locally deployed, private open-source AI coding setup. The reasons were familiar territory, data staying inside the internal network, and no extra cost. The result was disappointing, for three reasons that are common across the industry:

    1. Model capability limits: A model that runs locally is constrained by parameter size and inference resources. It clearly struggled with long-context understanding, complex logic generation, and organizing UI code. It could produce the core “answer + grading” flow, but could not maintain overall consistency.
    2. Interaction quality limits: The generated frontend structure was loose, the styling was dated, event bindings were missing, and state management was messy. Typical issues included “the button does nothing when clicked” and “state is lost when switching questions.”
    3. No validation loop: Without automated checks, problems could only be found by eye. Fixing one thing broke another, and a large amount of time was consumed by regression.

    The conclusion is clear: an offline setup suits data-sensitive, simple internal tools. Once you need a delivery-grade experience and a short launch window, you need stronger model capability and a more complete engineering pipeline.

    3. Capability Tiers: Choosing Among Three Types of AI Development

    Abstracting the options into three layers makes scenario-based decisions easier:

    • Local small-parameter model setup: The advantages are controlled data, offline availability, and low marginal cost. It suits scripts, format conversion, and internal tools.
    • Cloud general-purpose LLM coding assistant: The advantages are long-context understanding, cross-file changes, and better consistency between UI and logic. It suits delivery-grade prototypes and fast iteration.
    • Platform-based integrated development capability: On a cloud platform such as Baidu AI Cloud, you can typically combine common capabilities like compute resources, object storage, log services, and monitoring and alerting. This reduces environment setup time and lets you focus on business logic.

    The selection criterion is not “which one is stronger.” It is a trade-off among data sensitivity, delivery quality, and the time window.

    4. Rebuilding the Three-Hour Workflow: Pushing Uncertainty Down

    1) Requirement Clarification (0–20 minutes)

    Break “build an exam system” into a minimal, acceptable closed loop: question bank import → paper assembly → answering → automatic grading → result export. Fix three hard constraints: question types (single choice, multiple choice, true/false), whether a time limit is needed, and whether duplicate submissions must be prevented. Once the scope is clear, generation quality improves significantly.

    2) Data Layer First (20–50 minutes)

    Define the structure before writing the logic. A sample schema:

    1. CREATE TABLE question (
    2. id BIGINT PRIMARY KEY AUTO_INCREMENT,
    3. type TINYINT NOT NULL, -- 1 single choice, 2 multiple choice, 3 true/false
    4. stem TEXT NOT NULL,
    5. options JSON,
    6. answer JSON NOT NULL,
    7. score INT DEFAULT 5
    8. );
    9. CREATE TABLE exam_record (
    10. id BIGINT PRIMARY KEY AUTO_INCREMENT,
    11. user_id VARCHAR(64),
    12. started_at DATETIME,
    13. submitted_at DATETIME,
    14. total_score INT
    15. );

    Use a script to clean and import the question bank instead of handling it manually:

    1. import json, re
    2. def normalize(raw_items):
    3. out = []
    4. for it in raw_items:
    5. stem = re.sub(r'\s+', ' ', it['题干']).strip()
    6. opts = [o.strip() for o in it['选项'].split('|') if o.strip()]
    7. out.append({
    8. "type": it['题型'],
    9. "stem": stem,
    10. "options": opts,
    11. "answer": it['答案'],
    12. "score": 5
    13. })
    14. return out

    3) Generate in Batches, Not All at Once (50–110 minutes)

    Split the system into four independently verifiable pieces: the data access layer, paper assembly and grading logic, the answering UI, and the results page. Let the model generate only one piece at a time, with the interface contract attached, to avoid context drift.

    Sample grading logic:

    1. def grade(questions, answers):
    2. total, got = 0, 0
    3. for q in questions:
    4. total += q['score']
    5. user = set(answers.get(str(q['id']), []))
    6. right = set(q['answer'])
    7. if q['type'] == 2: # multiple choice: score only on an exact match
    8. got += q['score'] if user == right else 0
    9. else:
    10. got += q['score'] if user == right else 0
    11. return got, total

    4) Integration and Hardening (110–150 minutes)

    Prioritize three high-frequency defect classes: duplicate submissions (idempotency key + unique index), state loss when switching questions (centralized frontend state management), and corrupted grading under concurrency (serialized submission). Sample constraint:

    1. ALTER TABLE exam_record ADD UNIQUE KEY uk_user (user_id);

    5) Deployment and Acceptance (150–180 minutes)

    Package into containers, add log services and basic monitoring, run a small canary release first, then open it up fully. Acceptance checks only four things: can it import, can users answer, is grading accurate, and can results be exported.

    5. Prompt Engineering: The Key Variable for Generation Quality

    An effective prompt structure has five elements: role, input, constraints, output format, and acceptance criteria. A bad example is “write me an exam system.” A good example is “generate a service layer with only single-choice and multiple-choice questions, using parameterized queries, returning a unified struct, with three unit tests.” The more specific the constraints, the less rework.

    6. Common Pitfalls

    • Trying to generate the entire system at once, causing context overflow and front-to-back inconsistency;
    • Ignoring data validation, so dirty data all erupts during grading;
    • Having no automated tests and relying entirely on manual regression;
    • Treating a prototype as a deliverable, missing idempotency, concurrency, and monitoring design.

    7. Conclusion

    The key to the three hours was not “how fast AI is,” but scope convergence, layered generation, and closed-loop validation. Local offline setups and strong cloud models each have their applicable boundaries. Choose based on data sensitivity and delivery quality, then combine them with general cloud capabilities to cut environment and operations costs. Only then does short-cycle delivery become repeatable.