Skip to content

Conversation

@levadadenys
Copy link
Contributor

@levadadenys levadadenys commented Jan 27, 2026

[Teachin-53] [CFU] Add support of Free response answers, add support of Level Group CFU levels

2026-01-27.21.10.41.mov
  • added support of Free response answers
  • added support of Level Group CFU levels

Links

Testing story

Deployment strategy

Follow-up work

Privacy

Security

Caching

PR Creation Checklist:

  • Tests provide adequate coverage
  • Privacy impacts have been documented
  • Security impacts have been documented
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Follow-up work items (including potential tech debt) are tracked and linked

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for Free Response answers and Level Group CFU (Check for Understanding) levels to the Student CFU Widget. It introduces a discriminated union type system to handle different level types and implements the necessary rendering logic for these new level types.

Changes:

  • Refactored type definitions to use discriminated unions for different CFU level types (LevelGroup vs. other types)
  • Implemented Free Response answer rendering with SafeMarkdown support
  • Added Level Group support with nested answer handling
  • Removed debug console.log statements

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
types.ts Refactored type definitions to use discriminated unions, added CFULevelGroup and CFULevelOther interfaces, and introduced CFULevelResponseResponse interface
studentCFUAnswers.module.scss Added CSS styles for free response answer container and AI insight section
CFUMultiAnswer.tsx Updated to accept answers as a direct prop and changed response prop to use CFULevelResponseResponse
CFUMatchAnswer.tsx Updated response prop type to CFULevelResponseResponse
CFUFreeResponseAnswer.tsx Implemented rendering of free response answers using SafeMarkdown
StudentCFUWidgetQuestionsSection.tsx Removed debug console.log statements
CFUQuestionStudentAnswer.tsx Added logic to handle Level Group answers with nested level results and index-based answer selection
CFUQuestion.tsx Added Level Group to questionTypeMap and implemented array-based question text rendering for Level Groups
Comments suppressed due to low confidence (1)

apps/src/templates/studentSnapshot/studentCFUWidget/questionsSection/CFUQuestionStudentAnswer.tsx:71

  • The switch statement doesn't handle the 'LevelGroup' case explicitly. When a level has type 'LevelGroup', it will fall through to the default case which shows a placeholder. Based on the PR's purpose to add support for Level Group CFU levels, this should be handled properly. Consider either: (1) adding a case for 'LevelGroup' if it requires special rendering, or (2) if LevelGroup should never reach this code due to the isLevelGroupAnswer flag, add a comment explaining this.
    switch (levelType) {
      case 'Multi':
        return (
          <CFUMultiAnswer
            answers={
              (isLevelGroupAnswer
                ? level.answers?.[levelGroupLevelIndex]
                : level.answers) as CFUMultipleLevelAnswer[]
            }
            level={level}
            response={studentResponse}
          />
        );
      case 'Match':
        return <CFUMatchAnswer level={level} response={studentResponse} />;
      case 'FreeResponse':
        return <CFUFreeResponseAnswer response={studentResponse} />;
      default:
        return (
          <Typography variant="body4">
            {/* TODO: Handle additional CFU level type: {type} */}"{levelType}
            "&nbsp;Student answer placeholder
          </Typography>
        );
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

levadadenys and others added 4 commits January 27, 2026 19:48
…ection/answers/CFUFreeResponseAnswer.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ection/CFUQuestionStudentAnswer.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ection/CFUQuestionStudentAnswer.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (2)

apps/src/templates/studentSnapshot/studentCFUWidget/questionsSection/CFUQuestionStudentAnswer.tsx:79

  • The switch statement does not explicitly handle the 'LevelGroup' case. When a LevelGroup level is passed directly (not as isLevelGroupAnswer), it will fall through to the default case. Consider adding explicit handling for 'LevelGroup' or documenting why it's expected to be handled differently through the isLevelGroupAnswer flag.
    switch (levelType) {
      case 'Multi':
        return (
          <CFUMultiAnswer
            answers={
              (isLevelGroupAnswer
                ? level.answers?.[levelGroupLevelIndex]
                : level.answers || []) as CFUMultipleLevelAnswer[]
            }
            level={level}
            response={studentResponse}
          />
        );
      case 'Match':
        return <CFUMatchAnswer level={level} response={studentResponse} />;
      case 'FreeResponse':
        return <CFUFreeResponseAnswer response={studentResponse} />;
      default:
        return (
          <Typography variant="body4">
            {/* TODO: Handle additional CFU level type: {levelType} */}"
            {levelType}
            "&nbsp;Student answer placeholder
          </Typography>
        );
    }

apps/src/templates/studentSnapshot/studentCFUWidget/questionsSection/CFUQuestion.tsx:92

  • The code assumes that when 'level.question_text' is an array, it's always a LevelGroup level. However, there's no explicit check to verify this. Consider adding a type guard to ensure 'level.type === "LevelGroup"' before treating it as a LevelGroup, or document this assumption clearly if it's guaranteed by the backend.
    {Array.isArray(level.question_text) ? (
      <>
        {level.question_text.map((questionText, index) => (
          <CFUQuestionStudentAnswer
            key={questionText}
            level={level}
            isLevelGroupAnswer
            levelGroupLevelIndex={index}
            response={response}
            questionText={questionText}
            isOpen={isOpen}
          />
        ))}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@levadadenys levadadenys requested review from a team and lfryemason January 27, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants