+ {problem.subsections.map((sub, sIndex) => {
+ const partLabel = `${pIndex + 1}${String.fromCharCode(97 + sIndex)}`;
+ const aiGraded = AI_GRADED_TYPES.has(sub.submissionType) || isAiHandwritten(sub);
+ // The TA note is the grading guidance when a person grades, so it
+ // is always open then. When the AI rubric is primary it is optional,
+ // and stays folded until it is wanted or already has text.
+ const noteOpen = !aiGraded || !!sub.graderNote || openNotes.has(sub.id);
+ return (
+
- {/* Medium — gated by the assignment's input mode */}
- Type:
- {([
- { label: 'Electronic text', type: SubmissionType.TEXT },
- { label: 'Image', type: SubmissionType.IMAGE },
- { label: 'Text + Image', type: SubmissionType.TEXT_AND_IMAGE },
- { label: 'Handwritten', type: SubmissionType.HANDWRITTEN },
- ]).filter(({ type }) => typeAllowedInMode(type, inputMode)).map(({ label, type }) => (
+ )}
updateSubsection(pIndex, sIndex,
- type === SubmissionType.HANDWRITTEN
- ? { submissionType: SubmissionType.HANDWRITTEN, handwrittenGradingMode: sub.handwrittenGradingMode ?? 'ai' }
- : { submissionType: type, imageGradingMode: 'human' as const }
- )}
- className={`text-xs px-3 py-1 rounded-full border font-medium transition-colors ${
- // Text is the fallback pill: active only when no other medium claims the type
- (type === SubmissionType.TEXT
- ? sub.submissionType !== SubmissionType.IMAGE
- && sub.submissionType !== SubmissionType.TEXT_AND_IMAGE
- && sub.submissionType !== SubmissionType.HANDWRITTEN
- : sub.submissionType === type)
- ? 'bg-academic-700 text-white border-academic-700'
- : 'bg-white text-academic-600 border-academic-300 hover:border-academic-500 hover:text-academic-800'
- }`}
+ onClick={() => removeSubsection(pIndex, sIndex)}
+ title={`Delete part ${partLabel}`}
+ aria-label={`Delete part ${partLabel}`}
+ className="mt-1 p-1.5 rounded-[5px] text-academic-400 hover:text-red-600 hover:bg-red-50 transition-colors"
>
- {label}
+
- ))}
-
- |
- Grading:
+
- {sub.submissionType === SubmissionType.HANDWRITTEN ? (
- /* Handwritten branch — AI (OCR + grade) or Human (TA grades the crop). No page count. */
- <>
+
+
+ Answer
{([
- { label: 'AI', mode: 'ai' as const },
- { label: 'Human', mode: 'human' as const },
- ]).map(({ label, mode }) => (
+ { label: 'Electronic text', type: SubmissionType.TEXT },
+ { label: 'Image', type: SubmissionType.IMAGE },
+ { label: 'Text + Image', type: SubmissionType.TEXT_AND_IMAGE },
+ { label: 'Handwritten', type: SubmissionType.HANDWRITTEN },
+ ]).filter(({ type }) => typeAllowedInMode(type, inputMode)).map(({ label, type }) => (
updateSubsection(pIndex, sIndex, { handwrittenGradingMode: mode })}
- className={`text-xs px-3 py-1 rounded-full border font-medium transition-colors ${
- (sub.handwrittenGradingMode ?? 'ai') === mode
- ? 'bg-academic-700 text-white border-academic-700'
- : 'bg-white text-academic-600 border-academic-300 hover:border-academic-500 hover:text-academic-800'
- }`}
+ onClick={() => updateSubsection(pIndex, sIndex,
+ type === SubmissionType.HANDWRITTEN
+ ? { submissionType: SubmissionType.HANDWRITTEN, handwrittenGradingMode: sub.handwrittenGradingMode ?? 'ai' }
+ : { submissionType: type, imageGradingMode: 'human' as const }
+ )}
+ className={pill(
+ type === SubmissionType.TEXT
+ ? sub.submissionType !== SubmissionType.IMAGE
+ && sub.submissionType !== SubmissionType.TEXT_AND_IMAGE
+ && sub.submissionType !== SubmissionType.HANDWRITTEN
+ : sub.submissionType === type)}
>
{label}
))}
+
+
+
+ Graded by
+ {sub.submissionType === SubmissionType.HANDWRITTEN ? (
+ <>
+ {([
+ { label: 'AI', mode: 'ai' as const },
+ { label: 'Human', mode: 'human' as const },
+ ]).map(({ label, mode }) => (
+ updateSubsection(pIndex, sIndex, { handwrittenGradingMode: mode })}
+ className={pill((sub.handwrittenGradingMode ?? 'ai') === mode)}
+ >
+ {label}
+
+ ))}
+ >
+ ) : sub.submissionType === SubmissionType.IMAGE ? (
+ A person reviews every image
+ ) : sub.submissionType === SubmissionType.TEXT_AND_IMAGE ? (
+ Human
+ ) : (
+ <>
+ updateSubsection(pIndex, sIndex, { submissionType: SubmissionType.TEXT })}
+ className={pill(sub.submissionType === SubmissionType.TEXT)}
+ >
+ Human
+
+ AI:
+ {([
+ { label: 'Binary', type: SubmissionType.AI_GRADED_BINARY, defaultPts: 3 },
+ { label: 'Short', type: SubmissionType.AI_GRADED_SHORT, defaultPts: 8 },
+ { label: 'Medium', type: SubmissionType.AI_GRADED_MEDIUM, defaultPts: 15 },
+ { label: 'Long', type: SubmissionType.AI_GRADED_LONG, defaultPts: 25 },
+ ] as { label: string; type: SubmissionType; defaultPts: number }[]).map(({ label, type, defaultPts }) => (
+ updateSubsection(pIndex, sIndex, {
+ submissionType: type,
+ points: sub.points > 0 ? sub.points : defaultPts,
+ minWords: AI_WORD_RANGES[type]?.min,
+ })}
+ className={pill(sub.submissionType === type)}
+ >
+ {label}
+
+ ))}
+ >
+ )}
+
- {/* Printed-template controls: how much writing room this part gets
- on the QR template, and whether it is a sketch. Answer lines only
- sizes a sheet this app prints, so it is hidden on the generic page,
- where it would do nothing; the stored value is kept and exported.
- Sketch stays everywhere: it sets answer_modality in the rubric. */}
-
|
+ {sub.submissionType === SubmissionType.HANDWRITTEN && (
+
{assignment.sheet !== 'generic' && (
- Answer lines:
+ Answer lines:
{
answerLines: Math.max(1, parseInt(e.target.value, 10) || DEFAULT_ANSWER_LINES),
})}
title={`Writing lines reserved for this answer on the printed sheet, drawn at exactly this size. ${DEFAULT_ANSWER_LINES} if you never set it; a part that no longer fits its page simply starts a new one.`}
- className="w-14 text-xs border border-academic-300 rounded px-2 py-1 focus:outline-none focus:border-academic-500"
+ className="w-16 text-xs bg-white border border-academic-300 rounded-[5px] px-2 py-1 focus:outline-none focus:border-academic-500"
/>
)}
updateSubsection(pIndex, sIndex, { isDrawing: !sub.isDrawing })}
- className={`text-xs px-3 py-1 rounded-full border font-medium transition-colors ${
- sub.isDrawing
- ? 'bg-academic-700 text-white border-academic-700'
- : 'bg-white text-academic-600 border-academic-300 hover:border-academic-500 hover:text-academic-800'
- }`}
+ className={pill(!!sub.isDrawing)}
title="Sketch part. The reserved space is drawn as a plain box with no rules, and flagged is_drawing in the layout map."
>
Sketch
- >
- ) : sub.submissionType === SubmissionType.IMAGE ? (
- /* Image branch */
- <>
+
+ )}
+
+ {(sub.submissionType === SubmissionType.IMAGE || sub.submissionType === SubmissionType.TEXT_AND_IMAGE) && (
- pages:
+ {sub.submissionType === SubmissionType.IMAGE ? 'Pages' : 'Image pages'}
updateSubsection(pIndex, sIndex, { maxImages: parseInt(e.target.value) || 1 })}
- className="w-14 text-xs border border-academic-300 rounded px-2 py-1 focus:outline-none focus:border-academic-500"
+ className="w-16 text-xs bg-white border border-academic-300 rounded-[5px] px-2 py-1 focus:outline-none focus:border-academic-500"
title="Number of image pages allowed"
/>
- {/* No mode choice for an image part any more.
- "AI Inspection" set imageGradingMode: 'auto', which
- awarded full marks for any upload with nobody
- looking. A person reviews every image, so there is
- one behaviour and nothing to pick. */}
-
- Reviewed by a person
-
- >
- ) : sub.submissionType === SubmissionType.TEXT_AND_IMAGE ? (
- /* Text + Image branch — human grading only */
- <>
-
- image pages:
- updateSubsection(pIndex, sIndex, { maxImages: parseInt(e.target.value) || 1 })}
- className="w-14 text-xs border border-academic-300 rounded px-2 py-1 focus:outline-none focus:border-academic-500"
- title="Number of image pages allowed"
+ )}
+
+
+
+ {aiGraded && (
+
+
+
+
+ AI grading rubric
+ private
+
+
+ {isAiHandwritten(sub)
+ ? 'The marked region is transcribed, then graded against this.'
+ : AI_WORD_RANGES[sub.submissionType]
+ ? `Suggested length ${AI_WORD_RANGES[sub.submissionType]?.range} · minimum ${AI_WORD_RANGES[sub.submissionType]?.min} words (guidance only)`
+ : ''}
+
+
+
+ )}
+
+ {noteOpen ? (
+
+
+
+ {sub.submissionType === SubmissionType.IMAGE
+ ? 'Grader note: what to look for in the submission'
+ : sub.submissionType === SubmissionType.TEXT_AND_IMAGE
+ ? 'Grader note: expected text answer, and what to look for in the image'
+ : aiGraded
+ ? 'TA note (optional; the AI rubric is primary)'
+ : sub.submissionType === SubmissionType.HANDWRITTEN
+ ? 'Grader note: expected answer or worked solution (a TA grades the marked region)'
+ : 'Grader note: expected answer or worked solution'}
+ private
+
+
-
- Human
-
- >
- ) : (
- /* Text branch */
- <>
+ ) : (
updateSubsection(pIndex, sIndex, { submissionType: SubmissionType.TEXT })}
- className={`text-xs px-3 py-1 rounded-full border font-medium transition-colors ${
- sub.submissionType === SubmissionType.TEXT
- ? 'bg-academic-700 text-white border-academic-700'
- : 'bg-white text-academic-600 border-academic-300 hover:border-academic-500 hover:text-academic-800'
- }`}
+ onClick={() => setOpenNotes(prev => new Set(prev).add(sub.id))}
+ className="inline-flex items-center gap-1.5 text-xs font-semibold text-academic-700 hover:text-academic-900"
>
- Human
+ Add a TA note
+ (optional, private)
-
|
-
AI:
- {([
- { label: 'Binary', type: SubmissionType.AI_GRADED_BINARY, defaultPts: 3 },
- { label: 'Short', type: SubmissionType.AI_GRADED_SHORT, defaultPts: 8 },
- { label: 'Medium', type: SubmissionType.AI_GRADED_MEDIUM, defaultPts: 15 },
- { label: 'Long', type: SubmissionType.AI_GRADED_LONG, defaultPts: 25 },
- ] as { label: string; type: SubmissionType; defaultPts: number }[]).map(({ label, type, defaultPts }) => (
-
updateSubsection(pIndex, sIndex, {
- submissionType: type,
- points: sub.points > 0 ? sub.points : defaultPts,
- minWords: AI_WORD_RANGES[type]?.min,
- })}
- className={`text-xs px-3 py-1 rounded-full border font-medium transition-colors ${
- sub.submissionType === type
- ? 'bg-purple-700 text-white border-purple-700'
- : 'bg-white text-purple-600 border-purple-300 hover:border-purple-500 hover:text-purple-800'
- }`}
- >
- {label}
-
- ))}
- >
- )}
-
- {(AI_GRADED_TYPES.has(sub.submissionType) || isAiHandwritten(sub)) && (
-
- {isAiHandwritten(sub) && (
-
- The student's marked region is cropped and transcribed, then graded against this rubric.
-
)}
- {AI_WORD_RANGES[sub.submissionType] && (
-
- Suggested length: {AI_WORD_RANGES[sub.submissionType]?.range} · suggested minimum: {AI_WORD_RANGES[sub.submissionType]?.min} words (guidance only — not enforced)
-
- )}
-
- )}
- {/* Grader note — shown for all subsection types */}
-
-
-
-
-
- {sub.submissionType === SubmissionType.IMAGE
- ? 'Grader note — what to look for in the submission'
- : sub.submissionType === SubmissionType.TEXT_AND_IMAGE
- ? 'Grader note — expected text answer + what to look for in the image'
- : (AI_GRADED_TYPES.has(sub.submissionType) || isAiHandwritten(sub))
- ? 'Supplementary TA note (optional — AI rubric above is primary)'
- : sub.submissionType === SubmissionType.HANDWRITTEN
- ? 'Grader note — expected answer / worked solution (TA grades the marked region)'
- : 'Grader note — expected answer / worked solution'}
-
- · not shown to students
-
-
-
- ))}
-
-
addSubsection(pIndex)} className="text-xs">
- Add Subsection
-
-
+ );
+ })}
+
addSubsection(pIndex)} className="text-xs">
+ Add part
+