Restyle assessment dropdown with colored set badge#111
Conversation
|
@copilot One correction: Please align both the badges and titles flush left. That matches the styling on the PrairieLearn website, which we are trying to emulate. |
|
@copilot Factor out the combination of the badge and the title formatting into it's own component called and then use it both in the dropdown, and on the Modal that is used by instructors to lock and unlock assessments. |
|
@copilot. I see the badges in the DOM, for example: But: the background colors are not showing up.
|
Done in 13e0800 — extracted |
... Fixed in 3e459d2 — |
|
@copilot Please address the jacoco coverage failure. |
Fixed in the latest commit — added a test case with |
|
@copilot Please use this formula to determine whether to show the badge with a white text or black text:
Also: please sort the assessments by the combination of the pl_assessment_set_abbreviation + pl_assessment_number when they appear in the modal and in the dropdown. Finally, increase the field for the badge by 75 pixels. |
Addressed in 8e... commits: badge text color now uses the luminance formula (white for luminance ≤150, black otherwise), assessments in the dropdown and unlock modal are sorted by pl_assessment_set_abbreviation + pl_assessment_number, and the badge's min-width was increased by 75px (36→111, extracted as |
The assessment dropdown only showed
pl_assessment_title, with no visual indication of the assessment set. Needed a colored badge (pl_assessment_set_abbreviation+pl_assessment_number, background derived frompl_assessment_set_color) prefixing the title, with both badge and title flush left, matching the PrairieLearn styling.Backend
AssessmentDTOnow includespl_assessment_set_abbreviation,pl_assessment_number, andpl_assessment_set_color(sourced from the existingPlAssessmententity fields).AssessmentManagementDTO(used by the instructor-facing lock/unlock modal) also now includespl_assessment_set_abbreviation,pl_assessment_number, andpl_assessment_set_color, so the same badge can be rendered there.AssessmentControllernow injectsPlColorRepositoryand translatespl_assessment_set_color(a PrairieLearn color name likegray1, as stored onPlAssessment) into its hex code via thepl_colortable (populated byReadPLColorsJob) before returning it inAssessmentDTO/AssessmentManagementDTO, so the value can be applied directly as a CSS background color.Frontend
PrairieLearnAssessmentcomponent (frontend/src/main/components/Scaffold/PrairieLearnAssessment.tsx) that renders a rounded, colored badge before the title, both flush left, with a gap between badge and text. Badge is omitted when abbreviation/number data isn't available yet (pre PL-API sync).Luminance = R×0.299 + G×0.587 + B×0.114): white text when the background's luminance is ≤150, black text otherwise, for optimal legibility and accessibility contrast against anypl_assessment_set_color.BADGE_MIN_WIDTHconstant) to comfortably fit longer set abbreviation + number combinations.pl_assessment_set_abbreviation+pl_assessment_numberwherever they are listed: both in theAssessmentSelectdropdown and in theUnlockAssessmentsModalinstructor list (via a sharedcompareByAssessmentSetAndNumbercomparator inconceptGraphUtils.ts).AssessmentSelect(Scaffold) now usesPrairieLearnAssessmentfor both the closed control and each dropdown option.UnlockAssessmentsModal(Scaffold) now also usesPrairieLearnAssessmentfor each assessment's label, so instructors see the same colored badge when locking/unlocking assessments.AssessmentandAssessmentManagementDTOtypes extended with the new optional fields.Note: this only affects the non-legacy
AssessmentSelect/UnlockAssessmentsModalused byConceptGraphPage.LegacyAssessmentSelect/LegacyHomePageuse a frozenAssessmentmodel without these fields and are unchanged.