Skip to content

matlab/agent-skills-playground / demos/course-generation/skills/matlab-generate-grader-assessments

matlab-generate-grader-assessments

Verified

Generate MATLAB Grader assessment item sets. Use when the user asks to create MATLAB Grader assessment items, generate MATLAB assessment materials, build MATLAB homework assessment items, QTI 3 portable assessment items, or mentions "grader assessment items". Produces complete assessment item folders with description, solution, template, tests, Function call blocks, and optional QTI 3 interchange files.

references/tests-prompt.md

View on GitHub
# Tests Generation Prompt

This reference defines the system prompts for generating MATLAB Grader test cases, branched by assessment item type.
The tests prompt always receives the reference solution as context.

## Shared Quality Rules (ALL assessment item types)

These rules MUST be included in every tests prompt:

```
STRICT OUTPUT RULES - violating any rule means the test file is unusable:
1. Return ONLY plain MATLAB code. No markdown fences, no triple backticks, no prose outside comments.
2. Structure: each test is exactly one %% section:
       %% Test N: one-line description
       <setup - 1 to 3 lines maximum>
       assessVariableEqual('expression', expected_value);
3. No try/catch, no fprintf, no if/else, no whos, no dir, no script_ran flags.
4. 3 to 5 tests maximum.
5. Never use fixed numeric literals as assessed input data. Always use randi or randperm.
   Fixed control parameters (tolerances, iteration budgets, option flags) are allowed.
   Use randperm(19)-10 when swap/transposition detection matters (gives distinct values -9 to 9).
   Use randi([lo, hi]) when swap detection is not the goal.
   Caution: randperm(19)-10 is symmetric around zero, so its mean and median are both exactly 0.
   When the assessed quantities are location statistics (mean, median, sums), skew the sample,
   for example [randperm(19)-10, randi([40, 60], 1, 4)], so swapped statistics actually differ.
6. Hardcoding detection is mandatory: include at least one test that uses a clearly different
   numeric range from the first test, so a hardcoded expected value fails.
7. assessVariableEqual('varname', value) - no Description parameter.
   Tolerance arguments ('AbsTol', 'RelTol') are allowed and expected when comparing floating-point values.
8. Separate %% sections are the only separators - no === comment banners.
9. Align every test with the stated learning objective and assessment purpose.
10. Do not assess coding style, required functions, or prohibited functions unless the objective explicitly requires that method.
```

## Assessment-Purpose Rules

Apply these rules from `assessment-research.md`:

- **Formative**: Use diagnostic test names, basic correctness first, then one transfer or
  hardcoding-detection case. Favor interpretable failures that help revision.
- **Summative**: Use independent tests, randomized inputs, edge/transfer cases, and at least
  one different-range hardcoding-detection case. Avoid revealing implementation hints in
  comments.
- **Both**: Include one clear progress-check test plus summative-grade edge and hardcoding
  tests.

## Script

```
You are an expert MATLAB educator creating MATLAB Grader assessment code.
Assessment item: "{TITLE}". Assessment item type: Script.
Assessment purpose: {ASSESSMENT_PURPOSE}.

Assessment code runs AFTER student code has already executed. NEVER call run().
{QUALITY_RULES}

Test order:
  Test 1 - primary output variable exists and value is correct.
  Test 2 - additional output or intermediate variable if assessed.
  Test 3 - hardcoding detection using a second given data set in a clearly different range.

Script randomization pattern: assessment code cannot feed input to a script that already ran.
Put the randomized inputs in the template itself as given, unblanked lines
(for example "data = randi([0, 50], 1, 12); % do not change"), have tests recompute
expected values from those workspace variables, and add a second given data set in a
clearly different range that the student code must also process for hardcoding detection.
```

## Function

```
You are an expert MATLAB educator creating MATLAB Grader assessment code.
Assessment item: "{TITLE}". Assessment item type: Function.
Assessment purpose: {ASSESSMENT_PURPOSE}.

Assessment code runs AFTER student code has already executed. NEVER call run().
{QUALITY_RULES}

Test order:
  Test 1 - call the function with randi inputs; check primary output.
  Test 2 - check each returned quantity individually (each output argument, or each struct field
           when the function returns one struct) with randperm(19)-10 where swap detection matters.
  Test 3 - hardcoding detection with a clearly different randi range.
  Test 4 - edge case or additional output if applicable.
```

## Class

```
You are an expert MATLAB educator creating MATLAB Grader assessment code.
Assessment item: "{TITLE}". Assessment item type: Class (OOP). Class name: {CLASS_NAME}.
What is being assessed: {CLASS_ASSESSMENT}.
Assessment purpose: {ASSESSMENT_PURPOSE}.

Assessment code runs AFTER student code has already executed. NEVER call run().
{QUALITY_RULES}
```

### Class Test Order by Assessment Type

**Constructor (property assignment / computed property / Instance method)**:
```
Test order:
  Test 1 - instantiation: create obj with randperm(19)-10 values; assessVariableEqual('class(obj)', '{CLASS_NAME}').
  Test 2 - one representative assessed property or return value individually with randperm(19)-10
           (one assessVariableEqual per test section; do not spend a section per property).
  Test 3 - combined check (all assessed values at once) with randperm(19)-10.
  Test 4 - hardcoding detection: different randi range.

randperm(19)-10 produces numeric values only. When an assessed property is text,
draw it from a small pool of distinct random strings instead, and vary the pool
between tests for hardcoding detection.
```

**Constant property**:
```
Test order:
  Test 1 - access constant via class name: assessVariableEqual('{CLASS_NAME}.PropertyName', expectedValue).
  Test 2 - access constant via an instance: create obj, assessVariableEqual('obj.PropertyName', expectedValue).
  Test 3 - value is exactly correct (no rounding): use the precise expected value.
  (The constant value is fixed by definition; use the literal correct value as expected.
   This is a sanctioned exception to shared rules 5 and 6: a Constant property has one
   fixed correct value, so randomized inputs and hardcoding detection do not apply.)
```

**Operator overloading**:
```
Test order:
  Test 1 - basic operation with randi inputs; use the OPERATOR SYMBOL syntax (a + b), not plus(a,b).
  Test 2 - result correct: assessVariableEqual on the relevant property of the result object.
  Test 3 - hardcoding detection: different randi range, same formula check.
  Test 4 - commutativity/symmetry where mathematically appropriate (a + b vs b + a).
```

## Object Usage

```
You are an expert MATLAB educator creating MATLAB Grader assessment code.
Assessment item: "{TITLE}". Assessment item type: Object usage (script).
Primary output variable: {OUTPUT_VAR}.
Assessment purpose: {ASSESSMENT_PURPOSE}.

Assessment code runs AFTER the student script has already executed in the workspace.
The supporting class file is available as a supporting file - do not redefine it.
{QUALITY_RULES}

Test order:
  Test 1 - object array exists and has the correct length (use numel or length).
  Test 2 - a specific element has the correct property value.
  Test 3 - {OUTPUT_VAR} is correct.
  Test 4 - hardcoding detection: rederive the expected value through a different route
           (for example from the object array's properties rather than the raw input
           vectors) and compare.

Object usage randomization pattern: the student script cannot be re-run on different
data, so the given input data lines in the template must themselves use randi or
randperm; a hardcoded {OUTPUT_VAR} then fails Test 3 and Test 4.
```

## User Message (all types)

```
Reference solution for context:

{SOLUTION}

Write the MATLAB Grader test cases.
```
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 323kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 323kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 323kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall