# Worked Example: Demo CDF Import And Read-Back

This example calls the live NWEAMap 1EdTech surface only. It downloads the demo
CDF files, imports them under a fresh demo `nweaAccountId`, reads the import
receipt, then asks the surface for the test-of-record row.

It performs no dedupe, norms lookup, growth-window switch, term parsing, or
report calculation.

## Run

```bash
set -euo pipefail

export NWEAMAP_BASE_URL="${NWEAMAP_BASE_URL:-https://platform3-andymontgomery-9773s-projects.vercel.app/nweamap/1edtech/implementation/api}"
export BASE_URL="$NWEAMAP_BASE_URL"
export WORK_DIR="$(mktemp -d)"
export NWEA_ACCOUNT_ID="skill-pack-demo-$(date +%s)"
export TERM_NAME="Spring 2025-2026"

TOKEN_JSON="$(curl -fsS -X POST "$BASE_URL/dev/mint?tenantId=demo")"
TOKEN="$(printf '%s' "$TOKEN_JSON" | jq -r '.token')"

for file in StudentsBySchool.csv AssessmentResults.csv ClassAssignments.csv ProgramAssignments.csv AccommodationAssignment.csv; do
  curl -fsS "$BASE_URL/dev/cdf/$file" > "$WORK_DIR/$file"
done

IMPORT_JSON="$(curl -fsS -X POST "$BASE_URL/nweamap/v1/imports" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: skill-pack-demo-$NWEA_ACCOUNT_ID" \
  -F "manifest={\"nweaAccountId\":\"$NWEA_ACCOUNT_ID\",\"termName\":\"$TERM_NAME\"};type=application/json" \
  -F "StudentsBySchool.csv=@$WORK_DIR/StudentsBySchool.csv;type=text/csv" \
  -F "AssessmentResults.csv=@$WORK_DIR/AssessmentResults.csv;type=text/csv" \
  -F "ClassAssignments.csv=@$WORK_DIR/ClassAssignments.csv;type=text/csv" \
  -F "ProgramAssignments.csv=@$WORK_DIR/ProgramAssignments.csv;type=text/csv" \
  -F "AccommodationAssignment.csv=@$WORK_DIR/AccommodationAssignment.csv;type=text/csv")"

printf '%s\n' "$IMPORT_JSON" \
  | jq '{status:.import.status,row_counts:.import.row_counts,import_id:.import.import_id}'

IMPORT_ID="$(printf '%s' "$IMPORT_JSON" | jq -r '.import.import_id')"

curl -fsS "$BASE_URL/nweamap/v1/imports/$IMPORT_ID" \
  -H "Authorization: Bearer $TOKEN" \
  | jq '{status:.import.status,row_counts:.import.row_counts,files:[.files[] | {source_file,row_count,validation_status}]}'

curl -fsS "$BASE_URL/nweamap/v1/assessment-results?nweaAccountId=$NWEA_ACCOUNT_ID&termName=Spring%202025-2026&sittingScope=test_of_record&studentId=stu-12345&subject=Math" \
  -H "Authorization: Bearer $TOKEN" \
  | jq '.data[0] | {student_id,subject,test_rit_score,test_id,is_test_of_record,test_of_record_reason,norms_reference_data,growth_measure_yn}'

rm -rf "$WORK_DIR"
```

## Expected Platform Answer

The final command must return:

```json
{
  "student_id": "stu-12345",
  "subject": "Math",
  "test_rit_score": 211,
  "test_id": "1110000001",
  "is_test_of_record": true,
  "test_of_record_reason": "highest_rit",
  "norms_reference_data": "2025",
  "growth_measure_yn": "Y"
}
```

That answer is the platform's answer. Do not recompute it from the two Math
sittings.
