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

Remove custom pluralize method in application_controller.rb #2082

Merged
merged 3 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,6 @@ def set_breadcrumbs
end
end

def pluralize(count, singular, plural = nil)
"#{count || 0} " +
(count == 1 || count =~ /^1(\.0+)?$/ ? singular : (plural || singular.pluralize))
end

# make_dlist - Creates a string of emails that can be added as b/cc field.
# @param section The section to email. nil if we should email the entire
# class.
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/assessment/autograde.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def regradeBatch

failure_jobs = failed_list.length
if failure_jobs > 0
flash[:error] = "Warning: Could not regrade #{pluralize(failure_jobs, "submission")}:<br>"
flash[:error] = "Warning: Could not regrade #{ActionController::Base.helpers.pluralize(failure_jobs, "submission")}:<br>"
20wildmanj marked this conversation as resolved.
Show resolved Hide resolved
failed_list.each do |failure|
if failure[:error].error_code == :nil_submission
flash[:error] += "Unrecognized submission ID<br>"
Expand All @@ -116,7 +116,7 @@ def regradeBatch

success_jobs = submission_ids.size - failure_jobs
if success_jobs > 0
link = "<a href=\"#{url_for(controller: 'jobs')}\">#{pluralize(success_jobs, "submission")}</a>"
link = "<a href=\"#{url_for(controller: 'jobs')}\">#{ActionController::Base.helpers.pluralize(success_jobs, "submission")}</a>"
20wildmanj marked this conversation as resolved.
Show resolved Hide resolved
flash[:success] = ("Regrading #{link}")
end

Expand Down Expand Up @@ -151,7 +151,7 @@ def regradeAll

failure_jobs = failed_list.length
if failure_jobs > 0
flash[:error] = "Warning: Could not regrade #{pluralize(failure_jobs, "submission")}:<br>"
flash[:error] = "Warning: Could not regrade #{ActionController::Base.helpers.pluralize(failure_jobs, "submission")}:<br>"
20wildmanj marked this conversation as resolved.
Show resolved Hide resolved
failed_list.each do |failure|
if failure[:error].error_code == :nil_submission
flash[:error] += "Unrecognized submission ID<br>"
Expand All @@ -163,7 +163,7 @@ def regradeAll

success_jobs = last_submissions.size - failure_jobs
if success_jobs > 0
link = "<a href=\"#{url_for(controller: 'jobs')}\">#{pluralize(success_jobs, "student")}</a>"
link = "<a href=\"#{url_for(controller: 'jobs')}\">#{ActionController::Base.helpers.pluralize(success_jobs, "student")}</a>"
20wildmanj marked this conversation as resolved.
Show resolved Hide resolved
flash[:success] = ("Regrading the most recent submissions from #{link}")
end

Expand Down
Loading