Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scale rubric criterion levels on max_mark update #7311

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

pranavrao145
Copy link
Contributor

@pranavrao145 pranavrao145 commented Nov 28, 2024

Proposed Changes

Fixes #7296 by changing the order in which changes are processed when max_mark is updated on a rubric criterion.

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue) X
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality)
🚦 Test update (change that only adds or modifies tests)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the [ ] into a [x] in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.

After opening your pull request:

  • I have updated the project Changelog (this is required for all changes).
  • I have verified that the pre-commit.ci checks have passed.
  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

@pranavrao145 pranavrao145 force-pushed the fix/rubric-criterion-denominator branch from ad5c103 to 83c2862 Compare November 28, 2024 23:54
@coveralls
Copy link
Collaborator

coveralls commented Nov 29, 2024

Pull Request Test Coverage Report for Build 12602422561

Details

  • 38 of 43 (88.37%) changed or added relevant lines in 3 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.01%) to 91.721%

Changes Missing Coverage Covered Lines Changed/Added Lines %
app/controllers/criteria_controller.rb 1 2 50.0%
app/models/rubric_criterion.rb 6 10 60.0%
Files with Coverage Reduction New Missed Lines %
app/models/level.rb 2 92.31%
Totals Coverage Status
Change from base Build 12600620658: -0.01%
Covered Lines: 41186
Relevant Lines: 44219

💛 - Coveralls

Copy link
Collaborator

@david-yz-liu david-yz-liu left a comment

Choose a reason for hiding this comment

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

@pranavrao145 thanks for doing this. I realized now why the code was written the way it was originally, as we didn't want to accidentally override the instructor's inputs on the form (for example, if the instructor changes the criterion max mark and the level weights at the same time).

This is a bit more work, but can you please modify the back-end algorithm so that

  1. for each existing level, if the levels_attributes has a mark that is different from the current level mark, use the new levels_attributes mark directly (no scaling); but if the levels_attributes mark is the same as the current level mark, scale that.
  2. for each new level, use the instructor-provided mark in levels_attributes (no scaling)

I think the easiest way to do this is to keep the original order of criterion/level updating, but prior to the level updating mutate the levels_attributes hash to compute the new level marks according to my above description.

@pranavrao145 pranavrao145 marked this pull request as draft December 1, 2024 00:55
@pranavrao145 pranavrao145 force-pushed the fix/rubric-criterion-denominator branch from 83c2862 to 5bd8e93 Compare December 3, 2024 01:16
@pranavrao145 pranavrao145 reopened this Jan 1, 2025
@pranavrao145 pranavrao145 force-pushed the fix/rubric-criterion-denominator branch from 907828f to fc8bf48 Compare January 3, 2025 06:43
@pranavrao145 pranavrao145 force-pushed the fix/rubric-criterion-denominator branch from fc8bf48 to 7921401 Compare January 3, 2025 06:44
@pranavrao145 pranavrao145 marked this pull request as ready for review January 3, 2025 06:44
self.update(levels_attributes: levels_attributes)
end

def level_with_mark_closest_to(mark)
self.levels.min_by { |m| (m.mark - mark).abs }
end

def scale_marks_if_max_mark_changed
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Decided to do this manually, from my obeservations this wasn't getting triggered except on update anyways.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You shouldn't delete this; there may be other ways of updating RubricCriterion other than the controller method you're working on.

Instead, you can skip this validation in the controller method when calling update on the criterion.

before_save :round_max_mark

validates :levels, presence: true

DEFAULT_MAX_MARK = 4
# Checks whether the passed in param's level_attributes have unique name and marks.
# Skips the uniqueness validation if true.
def update_levels(levels_attributes)
def update_levels(levels_attributes, scale = 1.0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously we were looking at changes to max_mark using self.changes (which I figured was a callback thing, not sure if that's available/how that works here) - to avoid some weird logic with the same I just made it a parameter the caller can very easily calculate.

@pranavrao145 pranavrao145 force-pushed the fix/rubric-criterion-denominator branch from 6445098 to 8783ba9 Compare January 3, 2025 06:52
@pranavrao145 pranavrao145 force-pushed the fix/rubric-criterion-denominator branch from 8783ba9 to 8c4d2d3 Compare January 3, 2025 18:49
should_skip = false
break
# Check if there's a dup in marks or names
unless should_skip
Copy link
Collaborator

Choose a reason for hiding this comment

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

This branch will never evaluate since should_skip is initialized to true

self.update(levels_attributes: levels_attributes)
end

def level_with_mark_closest_to(mark)
self.levels.min_by { |m| (m.mark - mark).abs }
end

def scale_marks_if_max_mark_changed
Copy link
Collaborator

Choose a reason for hiding this comment

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

You shouldn't delete this; there may be other ways of updating RubricCriterion other than the controller method you're working on.

Instead, you can skip this validation in the controller method when calling update on the criterion.

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.

Rubic criterion isn't populated correctly with a denominator > 4
3 participants