File size: 1,292 Bytes
9580dce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import type { CodingProblem, PublicCodingProblem } from "./types";

// ---------------------------------------------------------------------------
// Strip answer keys before a problem crosses the wire to the browser.
//
// The reference solution, the full hidden-test set, the known review issues,
// and the architecture rubric all stay server-side. The client only ever sees
// what a real candidate would see: the prompt, starter/buggy code, and the
// public (non-hidden) example tests.
// ---------------------------------------------------------------------------

export function toPublicProblem(problem: CodingProblem): PublicCodingProblem {
  switch (problem.type) {
    case "code-creation": {
      const { referenceSolution: _ref, tests, ...rest } = problem;
      void _ref;
      return { ...rest, tests: tests.filter((t) => !t.hidden) };
    }
    case "debugging": {
      const { referenceSolution: _ref, tests, ...rest } = problem;
      void _ref;
      return { ...rest, tests: tests.filter((t) => !t.hidden) };
    }
    case "code-review": {
      const { issues: _issues, ...rest } = problem;
      void _issues;
      return rest;
    }
    case "architecture": {
      const { rubric: _rubric, ...rest } = problem;
      void _rubric;
      return rest;
    }
  }
}