-
Notifications
You must be signed in to change notification settings - Fork 252
Add penalty_type option to submission rules for percentage_of_mark penalties #7709
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
Add penalty_type option to submission rules for percentage_of_mark penalties #7709
Conversation
Pull Request Test Coverage Report for Build 19217721017Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
david-yz-liu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @freyazjiner, I'm just leaving a few quick comments now (will wait for you to work on these and re-request a review).
-
You made a great point at our meeting today about the % sign needing to change for different units, and please feel free to implement this. Please use the term "marks" instead of "points", both in the dropdown and for replacing the %.
-
I've merged in #7697, which also contains a database migration. This is a bit tricky to resolve the merge correctly. Please do the following:
- Rollback your current migration.
- Update your branch from master.
- Perform the
rails db:migratecommand again. This will both run the migration from that PR, plus your own.
- In the UI, the penalty type dropdown is a bit misaligned. It should be aligned with the other text under the option label, so that it looks like it's part of the option configuration.
david-yz-liu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@freyazjiner looking good! I just left a few comments. Since this is a new feature that is user-facing, you should also update the documentation repo (look for the page that describes setting late penalties for assignments).
| # submission Result | ||
| return submission if submission.is_empty | ||
| result = submission.get_original_result | ||
| unit = case self.penalty_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is necessary. The penalty_type validation should ensure that it's one of the expected values. You can just pass self.penalty_type directly to create the extra mark.
| # submission Result | ||
| return submission if submission.is_empty | ||
| result = submission.get_original_result | ||
| unit = case self.penalty_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment below
| accepts_nested_attributes_for :periods, allow_destroy: true | ||
| validates_associated :periods | ||
| validates :assignment, uniqueness: true | ||
| validates :penalty_type, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is okay, but please override this validation in the two penalty-based submission rules to disallow nil. For those two rules we should always expect a non-nil penalty type.
| } | ||
| $("#penalty_type_selector_decay select, #penalty_type_selector_period select").on( | ||
| "change", | ||
| function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can look at the jQuery documentation, but this function should be taking arguments for the event, from which you can obtain the new value of the select input. This is cleaner than doing another jQuery call to find the select element again.
| penalty_type: Penalty type | ||
| penalty_types: | ||
| marks: Marks | ||
| percentage: Percentage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the label "Percentage of assignment total"
| penalty_types: | ||
| marks: Marks | ||
| percentage: Percentage | ||
| percentage_of_mark: Percentage of mark |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here use "Percentage of earned mark"
david-yz-liu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@freyazjiner nice work! I just left a few small comments.
But also I realized that we should update the student-facing messages that appear in the assignment settings when you view the settings as a student.
Currently, each SubmissionRule type has its own student-facing messages (see config/locales/views/submission_rules/en.yml). But there's only one set of messages per rule, and for the penalty rules they assume a "percentage" penalty type. Now that we're generalizing this, we should update these messages as well!
app/views/assignments/_form.html.erb
Outdated
| <%= t('submission_rules.penalty_type') %>: | ||
| <%= rule.select :penalty_type, | ||
| [ | ||
| [t('submission_rules.penalty_types.percentage'), 'percentage'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, please use the ExtraMark constants here as well (not the string literals). Keep in mind that this is embedded Ruby code, so you have access to all of the backend models here!
app/views/assignments/_form.html.erb
Outdated
| <%= t('submission_rules.penalty_type') %>: | ||
| <%= rule.select :penalty_type, | ||
| [ | ||
| [t('submission_rules.penalty_types.percentage'), 'percentage'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above
david-yz-liu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@freyazjiner I left a few more comments and did some manual testing. There's currently a bug where an instructor cannot change the penalty_type for a submission rule (create an assignment with a particular penalty type, then try updating the assignment to change the penalty type). Please make sure to test this carefully and fix this issue.
| var selector = isDecay ? "#penalty_decay_periods" : "#penalty_periods"; | ||
|
|
||
| if ($(event.target).val() === "points") { | ||
| $(selector + " .deduction-unit").text("marks"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string "marks" should be internationalized
| overtime_hours = calculate_overtime_hours_from(Time.current, grouping) | ||
| # Calculate the penalty that the grouping will suffer | ||
| potential_penalty = calculate_penalty(overtime_hours) | ||
| type = case penalty_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit more complicated than it needs to be. Write the _ right after overtime_message below, so that you can use #{penalty_type} directly in the interpolation string.
This comment applies to the other submission rule below.
app/views/assignments/_form.html.erb
Outdated
| [ | ||
| [t('submission_rules.penalty_types.percentage'), ExtraMark::PERCENTAGE], | ||
| [t('submission_rules.penalty_types.marks'), ExtraMark::POINTS], | ||
| [t('submission_rules.penalty_types.percentage_of_mark'), ExtraMark::PERCENTAGE_OF_MARK] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List this option second, before the "Marks" option"
app/views/assignments/_form.html.erb
Outdated
| [t('submission_rules.penalty_types.marks'), ExtraMark::POINTS], | ||
| [t('submission_rules.penalty_types.percentage_of_mark'), ExtraMark::PERCENTAGE_OF_MARK] | ||
| ], | ||
| { selected: rule.object.penalty_type || 'percentage' } %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ExtraMark::PERCENTAGE instead of the string literal
app/views/assignments/_form.html.erb
Outdated
| [ | ||
| [t('submission_rules.penalty_types.percentage'), ExtraMark::PERCENTAGE], | ||
| [t('submission_rules.penalty_types.marks'), ExtraMark::POINTS], | ||
| [t('submission_rules.penalty_types.percentage_of_mark'), ExtraMark::PERCENTAGE_OF_MARK] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comments as above
| details_message_other: Thereafter, a deduction of %{deduction}% will be applied every %{interval} hours up to a maximum of %{hours} hours. | ||
| extramark_description: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount}% deduction. | ||
| overtime_message: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty}% deducted from the final mark on this assignment. | ||
| overtime_message_percentage: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty}% deducted from the final mark on this assignment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After %{potential_penalty}% include the phrase "of the assignment total"
| extramark_description: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount}% deduction. | ||
| overtime_message: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty}% deducted from the final mark on this assignment. | ||
| overtime_message_percentage: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty}% deducted from the final mark on this assignment. | ||
| overtime_message_percentage_of_mark: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty}% deducted from your earned mark on this assignment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reword the last part to "%{potential_penalty}% of your earned mark deducted from the final mark on this assignment."
(This will align the wording better with the other two options
| details_message: Up to %{hours} hours after the due date, your grade will be reduced by %{deduction}% | ||
| extramark_description: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount}% deduction. | ||
| overtime_message: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty}% deducted from the final mark on this assignment. | ||
| overtime_message_percentage: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty}% deducted from the final mark on this assignment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comments as above
| apply_rule | ||
| rule_overtime_message = rule.overtime_message(grouping) | ||
| expected_overtime_message = I18n.t 'penalty_decay_period_submission_rules.overtime_message', | ||
| type = case rule.penalty_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above
| apply_rule | ||
| rule_overtime_message = rule.overtime_message(grouping) | ||
| expected_overtime_message = I18n.t 'penalty_decay_period_submission_rules.overtime_message', | ||
| type = case rule.penalty_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above
david-yz-liu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@freyazjiner okay all of the code changes look good, but there are still student-facing messages that need to be updated. Make sure you login as a student to view exactly what they are seeing for the different late penalties. Update all of the messages to incorporate penalty type, and update your PR description with screenshots of each type so it's clear that you've changed all of the necessary messages.
david-yz-liu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@freyazjiner okay things are looking great. I left a few small comments on the message wording.
However, I noticed one other bug when testing: in the grading view, the Summary tab on the right side shows the "Bonuses/Deductions" table. This table isn't showing the correct mark deduction for percentage_of_mark penalty type. I do see that the "Total Extra Marks" total below it is correct, as well as the "Total Mark" calculation. So it seems that just the table is the problem.
| details_message_percentage_of_mark: Up to %{hours} hours after the due date, your grade will be reduced by %{deduction}% of your earned mark from the final mark on this assignment. | ||
| details_message_points: Up to %{hours} hours after the due date, your grade will be reduced by %{deduction} marks from the final mark on this assignment. | ||
| extramark_description_percentage: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount}% deduction from assignment total. | ||
| extramark_description_percentage_of_mark: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount}% deduction from earned mark . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete the space before the period
| details_message_percentage: Up to %{hours} hours after the due date, your grade will be reduced by %{deduction}% of the assignment total from the final mark on this assignment. | ||
| details_message_percentage_of_mark: Up to %{hours} hours after the due date, your grade will be reduced by %{deduction}% of your earned mark from the final mark on this assignment. | ||
| details_message_points: Up to %{hours} hours after the due date, your grade will be reduced by %{deduction} marks from the final mark on this assignment. | ||
| extramark_description_percentage: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount}% deduction from assignment total. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"from assignment total" -> "of the assignment total"
| extramark_description_percentage: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount}% deduction from assignment total. | ||
| extramark_description_percentage_of_mark: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount}% deduction from earned mark . | ||
| extramark_description_points: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount} marks deduction. | ||
| overtime_message_percentage: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty}% of the assignment total deducted from the final mark on this assignment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change "final mark" to "final grade"
| extramark_description_percentage_of_mark: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount}% deduction from earned mark . | ||
| extramark_description_points: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount} marks deduction. | ||
| overtime_message_percentage: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty}% of the assignment total deducted from the final mark on this assignment. | ||
| overtime_message_percentage_of_mark: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty}% of your earned mark deducted from the final mark on this assignment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change "final mark" to "final grade"
| extramark_description_points: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount} marks deduction. | ||
| overtime_message_percentage: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty}% of the assignment total deducted from the final mark on this assignment. | ||
| overtime_message_percentage_of_mark: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty}% of your earned mark deducted from the final mark on this assignment. | ||
| overtime_message_points: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty} marks deducted from the final mark on this assignment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change "final mark" to "final grade"
| extramark_description_percentage: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount}% deduction from assignment total. | ||
| extramark_description_percentage_of_mark: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount}% deduction from earned mark. | ||
| extramark_description_points: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount} marks deduction. | ||
| overtime_message_percentage: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty}% of the assignment total deducted from the final mark on this assignment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change "final mark" to "final grade"
| extramark_description_percentage_of_mark: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount}% deduction from earned mark. | ||
| extramark_description_points: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount} marks deduction. | ||
| overtime_message_percentage: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty}% of the assignment total deducted from the final mark on this assignment. | ||
| overtime_message_percentage_of_mark: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty}% of your earned mark deducted from the final mark on this assignment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change "final mark" to "final grade"
| extramark_description_points: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount} marks deduction. | ||
| overtime_message_percentage: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty}% of the assignment total deducted from the final mark on this assignment. | ||
| overtime_message_percentage_of_mark: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty}% of your earned mark deducted from the final mark on this assignment. | ||
| overtime_message_points: The due date for this assignment has passed and you are now in a penalty period. You can make changes to your submission, but will have %{potential_penalty} marks deducted from the final mark on this assignment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change "final mark" to "final grade"
| details_message_other_percentage: Thereafter, a deduction of %{deduction}% of the assignment total will be applied every %{interval} hours up to a maximum of %{hours} hours. | ||
| details_message_other_percentage_of_mark: Thereafter, a deduction of %{deduction}% of your earned mark will be applied every %{interval} hours up to a maximum of %{hours} hours. | ||
| details_message_other_points: Thereafter, a deduction of %{deduction}% marks will be applied every %{interval} hours up to a maximum of %{hours} hours. | ||
| extramark_description_percentage: Late submission (%{overtime_hours} hour(s)) resulted in automatic %{penalty_amount}% deduction from assignment total. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"from assignment total" -> "of the assignment total"
| details_message_first_points: A deduction of %{deduction} marks will be applied every %{interval} hours up to %{hours} hours after the assignment is due. | ||
| details_message_other_percentage: Thereafter, a deduction of %{deduction}% of the assignment total will be applied every %{interval} hours up to a maximum of %{hours} hours. | ||
| details_message_other_percentage_of_mark: Thereafter, a deduction of %{deduction}% of your earned mark will be applied every %{interval} hours up to a maximum of %{hours} hours. | ||
| details_message_other_points: Thereafter, a deduction of %{deduction}% marks will be applied every %{interval} hours up to a maximum of %{hours} hours. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the % after %{deduction}
david-yz-liu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, @freyazjiner!
Proposed Changes
(Describe your changes here. Also describe the motivation for your changes: what problem do they solve, or how do they improve the application or codebase? If this pull request fixes an open issue, use a keyword to link this pull request to the issue.)
This PR adds a penalty_type option to the late penalty submission rules, allowing instructors to choose whether late penalties are applied as a percentage of total assignment marks (default), a fixed number of points, or a percentage of each student’s earned mark.
Screenshots of your changes (if applicable)
Associated documentation repository pull request (if applicable)
See MarkUsProject/Wiki/pull/243 for updated instructor guide.Type of Change
(Write an
Xor a brief description next to the type or types that best describe your changes.)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:
After opening your pull request:
Questions and Comments
(Include any questions or comments you have regarding your changes.)