@@ -98,8 +98,9 @@ def regradeBatch
98
98
end
99
99
end
100
100
101
- if failed_list . length > 0
102
- flash [ :error ] = "Warning: Could not regrade #{ failed_list . length } submission(s):<br>"
101
+ failure_jobs = failed_list . length
102
+ if failure_jobs > 0
103
+ flash [ :error ] = "Warning: Could not regrade #{ pluralize ( failure_jobs , "submission" ) } :<br>"
103
104
failed_list . each do |failure |
104
105
if failure [ :error ] . error_code == :nil_submission
105
106
flash [ :error ] += "Unrecognized submission ID<br>"
@@ -109,12 +110,15 @@ def regradeBatch
109
110
end
110
111
end
111
112
112
- success_jobs = submission_ids . size - failed_list . length
113
+ success_jobs = submission_ids . size - failure_jobs
113
114
if success_jobs > 0
114
- link = "<a href=\" #{ url_for ( controller : 'jobs' ) } \" >#{ success_jobs } submission</a>"
115
- flash [ :success ] = ( "Regrading #{ link } " ) . html_safe
115
+ link = "<a href=\" #{ url_for ( controller : 'jobs' ) } \" >#{ pluralize ( success_jobs , " submission" ) } </a>"
116
+ flash [ :success ] = ( "Regrading #{ link } " )
116
117
end
117
118
119
+ # For both :success and :error
120
+ flash [ :html_safe ] = true
121
+
118
122
redirect_to ( [ @course , @assessment , :submissions ] ) && return
119
123
end
120
124
@@ -141,8 +145,9 @@ def regradeAll
141
145
end
142
146
end
143
147
144
- if failed_list . length > 0
145
- flash [ :error ] = "Warning: Could not regrade #{ failed_list . length } submission(s):<br>"
148
+ failure_jobs = failed_list . length
149
+ if failure_jobs > 0
150
+ flash [ :error ] = "Warning: Could not regrade #{ pluralize ( failure_jobs , "submission" ) } :<br>"
146
151
failed_list . each do |failure |
147
152
if failure [ :error ] . error_code == :nil_submission
148
153
flash [ :error ] += "Unrecognized submission ID<br>"
@@ -152,12 +157,15 @@ def regradeAll
152
157
end
153
158
end
154
159
155
- success_jobs = last_submissions . size - failed_list . length
160
+ success_jobs = last_submissions . size - failure_jobs
156
161
if success_jobs > 0
157
- link = "<a href=\" #{ url_for ( controller : 'jobs' ) } \" >#{ success_jobs } students </a>"
158
- flash [ :success ] = ( "Regrading the most recent submissions from #{ link } " ) . html_safe
162
+ link = "<a href=\" #{ url_for ( controller : 'jobs' ) } \" >#{ pluralize ( success_jobs , "student" ) } </a>"
163
+ flash [ :success ] = ( "Regrading the most recent submissions from #{ link } " )
159
164
end
160
165
166
+ # For both :success and :error
167
+ flash [ :html_safe ] = true
168
+
161
169
redirect_to ( [ @course , @assessment , :submissions ] ) && return
162
170
end
163
171
@@ -186,6 +194,7 @@ def sendJob_AddHTMLMessages(course, assessment, submissions)
186
194
if @cud . instructor?
187
195
link = ( view_context . link_to "Autograder Settings" , [ :edit , course , assessment , :autograder ] )
188
196
flash [ :error ] += " Visit #{ link } to set the autograding properties."
197
+ flash [ :html_safe ] = true
189
198
else
190
199
flash [ :error ] += " Please contact your instructor."
191
200
end
@@ -199,6 +208,7 @@ def sendJob_AddHTMLMessages(course, assessment, submissions)
199
208
if @cud . instructor?
200
209
link = ( view_context . link_to "Autograder Settings" , [ :edit , course , assessment , :autograder ] )
201
210
flash [ :error ] += " (Verify the autograding properties at #{ link } .)\n ErrorMsg: " + e . additional_data
211
+ flash [ :html_safe ] = true
202
212
end
203
213
when :missing_autograder_file
204
214
flash [ :error ] = "One or more files are missing in the server. Please contact the instructor. The missing files are: " + e . additional_data
@@ -211,8 +221,8 @@ def sendJob_AddHTMLMessages(course, assessment, submissions)
211
221
212
222
link = "<a href=\" #{ url_for ( controller : 'jobs' , action : 'getjob' , id : job ) } \" >Job ID = #{ job } </a>"
213
223
flash [ :success ] = ( "Submitted file #{ submissions [ 0 ] . filename } (#{ link } ) for autograding." \
214
- " Refresh the page to see the results." ) . html_safe
215
-
224
+ " Refresh the page to see the results." )
225
+ flash [ :html_safe ] = true
216
226
job
217
227
end
218
228
0 commit comments