Implement new structure-based comparison system #20

Merged
BobdaFett merged 12 commits from feature/form-schema into main 2025-12-12 16:46:29 +00:00
BobdaFett commented 2025-11-20 16:18:11 +00:00 (Migrated from github.com)

This PR will introduce a new ComparisonData struct and various enums that work together to create a very modular comparison system.

The ComparisonData struct will allow users to define a comparison that functions through a chain of enums. This chain can get very wordy, so a new interface will need to be created at some point. This will take some time (which we don't have right now) so for now, we will create these comparisons programmatically and defer creation of this page for a later date.

The ComparisonData uses the ComparisonType enum. This contains the brunt of the logic for this structure. By nesting the various enum types, we can define a series of operations that must compare against a single value (the target_value field). Each of the operations implements the Comparison trait, which defines the evaluate function. This function simply takes two ValueTypes: one for the comparison data (the student data for now) and one for the target value. The operations are then performed in their nested order and a boolean value is returned indicating if the comparison succeeded.

I've also decided to create a few extra pages, namely the ScholarshipInfoPage and StudentInfoPage. I've used these to create a testing scholarship and student entry, and then compare them against each other. These are the specific tests I've done:

  • Student can see that they are eligible for the scholarship
  • Scholarship provider can see that this student is eligible for their scholarship

These pages are not final products, and should be altered before a production build is required.

This PR will introduce a new `ComparisonData` struct and various enums that work together to create a very modular comparison system. The `ComparisonData` struct will allow users to define a comparison that functions through a chain of enums. This chain can get very wordy, so a new interface will need to be created at some point. This will take some time (which we don't have right now) so for now, we will create these comparisons programmatically and defer creation of this page for a later date. The `ComparisonData` uses the `ComparisonType` enum. This contains the brunt of the logic for this structure. By nesting the various enum types, we can define a series of operations that must compare against a single value (the `target_value` field). Each of the operations implements the `Comparison` trait, which defines the `evaluate` function. This function simply takes two `ValueType`s: one for the comparison data (the student data for now) and one for the target value. The operations are then performed in their nested order and a boolean value is returned indicating if the comparison succeeded. I've also decided to create a few extra pages, namely the `ScholarshipInfoPage` and `StudentInfoPage`. I've used these to create a testing scholarship and student entry, and then compare them against each other. These are the specific tests I've done: - Student can see that they are eligible for the scholarship - Scholarship provider can see that this student is eligible for their scholarship These pages are not final products, and should be altered before a production build is required.
meraghon (Migrated from github.com) reviewed 2025-11-20 16:18:11 +00:00
BobdaFett commented 2025-11-23 21:58:13 +00:00 (Migrated from github.com)

This PR ended up covering a little more than just the comparison structure. It now includes the scholarship entry page and some of the student data. We'll need to look at these in more detail in another PR at a later time.

This PR ended up covering a little more than just the comparison structure. It now includes the scholarship entry page and some of the student data. We'll need to look at these in more detail in another PR at a later time.
Sign in to join this conversation.