Assessment Components
Assessment components compile QuestionData into rendered AssessmentElement output, shared between both the teacher and student modalities.
AssessmentComponent Subtrait
Section titled “AssessmentComponent Subtrait”trait AssessmentComponent: Component<Metadata = QuestionMetadata, Output = AssessmentElement> { fn id(&self) -> &'static str;}QuestionMetadata
Section titled “QuestionMetadata”The metadata passed to each component during compilation:
pub struct QuestionMetadata { pub question: QuestionData, pub answer: Option<AnswerData>, pub show_answer: bool,}QuestionMetadata: Hash for the incremental compilation cache.
QuestionData
Section titled “QuestionData”The core question model (defined in Overview):
pub struct QuestionData { pub id: String, pub format: QuestionFormat, // MultiChoice or ShortAnswer pub content: String, // question text pub answers: Vec<String>, // options (MC) or accepted answers (SA) pub answer_format: AnswerFormatType, // Whole, Decimal, Fraction, Text, MathKeyboard, OpenEnded pub skill_indicator: Vec<(usize, f32)>, // sparse skill weights pub score_factor: f32, // weight for knowledge updates}AnswerData
Section titled “AnswerData”Stored per-question when the student submits:
pub struct AnswerData { pub answer: String, pub correct: bool, pub time_taken: Duration,}AssessmentElement Output
Section titled “AssessmentElement Output”The compiled output enum, rendered by the Dart UI:
pub enum AssessmentElement { MultiChoice { placement_id: String, question_id: String, content: String, options: Vec<String>, selected: Option<String>, correct: Option<bool>, // only when show_answer is true }, ShortAnswer { placement_id: String, question_id: String, content: String, prefix: Option<String>, suffix: Option<String>, format_type: AnswerFormatType, answer: Option<String>, correct: Option<bool>, },}Compile Flow
Section titled “Compile Flow”The compile_question() function handles both question formats:
pub fn compile_question(metadata: &QuestionMetadata) -> Result<AssessmentElement, CompileError> { match metadata.question.format { QuestionFormat::MultiChoice => { // Build MultiChoice element with options // Include selected answer + correctness if show_answer } QuestionFormat::ShortAnswer => { // Build ShortAnswer element with format type // Include prefix/suffix for formatted answers } }}The show_answer flag (from AssessmentConfig.show_answers) controls whether correctness information is included in the output. When false, the correct field is None.