Skip to content

Commit dd823f3

Browse files
authored
Merge branch 'master' into ec2-testing
2 parents 6765f5f + 674efe9 commit dd823f3

File tree

6 files changed

+98
-25
lines changed

6 files changed

+98
-25
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ jobs:
4040

4141
steps:
4242
- name: Checkout repository
43-
uses: actions/checkout@v4
43+
uses: actions/checkout@v5
4444

4545
# Initializes the CodeQL tools for scanning.
4646
- name: Initialize CodeQL
47-
uses: github/codeql-action/init@v3
47+
uses: github/codeql-action/init@v4
4848
with:
4949
languages: ${{ matrix.language }}
5050
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -58,7 +58,7 @@ jobs:
5858
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5959
# If this step fails, then you should remove it and run the build manually (see below)
6060
- name: Autobuild
61-
uses: github/codeql-action/autobuild@v3
61+
uses: github/codeql-action/autobuild@v4
6262

6363
# ℹ️ Command-line programs to run using the OS shell.
6464
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -71,4 +71,4 @@ jobs:
7171
# ./location_of_script_within_repo/buildscript.sh
7272

7373
- name: Perform CodeQL Analysis
74-
uses: github/codeql-action/analyze@v3
74+
uses: github/codeql-action/analyze@v4

.github/workflows/rubyonrails.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
steps:
2020
- name: Checkout code
21-
uses: actions/checkout@v4
21+
uses: actions/checkout@v5
2222

2323
- name: Install SQLite3 library
2424
run: sudo apt-get update && sudo apt-get install -y libsqlite3-dev
@@ -45,7 +45,7 @@ jobs:
4545

4646
steps:
4747
- name: Checkout code
48-
uses: actions/checkout@v4
48+
uses: actions/checkout@v5
4949

5050
- name: Install SQLite3 library
5151
run: sudo apt-get update && sudo apt-get install -y libsqlite3-dev

app/assets/javascripts/manage_submissions.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,56 @@ $(document).ready(function() {
329329
}
330330
}
331331

332+
$(document).on("click", "#regrade-all-btn, #regrade-all-trigger", function (event) {
333+
event.preventDefault();
334+
if (!confirm(`Are you sure you want to regrade all selected submissions?`)) return;
335+
const icon = $("#regrade-all-icon");
336+
const button = $("#regrade-all-btn");
337+
const link = $('#regrade-all-trigger');
338+
let refreshInterval = setInterval(() => {
339+
location.reload();
340+
}, 5000);
341+
342+
$.ajax({
343+
url: "regradeAll",
344+
type: "POST",
345+
contentType: "application/json",
346+
headers: {
347+
"X-CSRF-Token": $('meta[name="csrf-token"]').attr("content")
348+
},
349+
beforeSend: function () {
350+
if (icon && button) {
351+
button.addClass("disabled");
352+
link.addClass("disabled-link");
353+
icon.text("autorenew");
354+
icon.addClass("loading-icon");
355+
}
356+
},
357+
success: function (response) {
358+
clearInterval(refreshInterval);
359+
if (response.redirect) {
360+
console.log(response.redirect);
361+
window.location.href = response.redirect;
362+
return;
363+
}
364+
if (response.error) {
365+
alert(response.error);
366+
}
367+
if (response.success) {
368+
alert(response.success);
369+
}
370+
},
371+
error: function () {
372+
clearInterval(refreshInterval);
373+
alert("An error occurred while regrading.");
374+
}
375+
});
376+
});
377+
332378
function changeButtonStates(state) {
333379
buttonIDs.forEach((id) => {
334380
const button = $(id);
381+
const icon = button.find("i");
335382
if (state) {
336383
if (id === "#download-selected") {
337384
$(id).prop('href', baseURLs[id]);
@@ -374,6 +421,13 @@ $(document).ready(function() {
374421
headers: {
375422
"X-CSRF-Token": $('meta[name="csrf-token"]').attr("content"),
376423
},
424+
beforeSend: function () {
425+
button.addClass('disabled');
426+
if (icon) {
427+
icon.text("autorenew");
428+
icon.addClass("loading-icon");
429+
}
430+
},
377431
success: function (response) {
378432
clearInterval(refreshInterval);
379433
if (response.redirect) {

app/assets/stylesheets/manage_submissions.css.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,21 @@ table.prettyBorder tr:hover {
7474
.i-no-margin {
7575
margin-left: 0;
7676
}
77+
78+
.loading-icon {
79+
animation: spin 1.5s linear infinite;
80+
display: inline-block;
81+
}
82+
83+
.disabled-link {
84+
pointer-events: none;
85+
color: gray !important;
86+
opacity: 0.6;
87+
text-decoration: none;
88+
cursor: default;
89+
}
90+
91+
@keyframes spin {
92+
0% { transform: rotate(0deg); }
93+
100% { transform: rotate(360deg); }
94+
}

app/controllers/assessment/autograde.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ def regradeBatch
105105
# any handins that fail.
106106
submissions = submission_ids.filter_map do |sid|
107107
_is_i?(sid) ? @assessment.submissions.find_by_id(sid) : nil
108-
end
109-
108+
end.compact
110109
begin
111110
failed_list = sendJob_batch(@course, @assessment, submissions, @cud)
112111
rescue AssessmentAutogradeCore::AutogradeError => e
@@ -119,7 +118,7 @@ def regradeBatch
119118

120119
failure_jobs = failed_list.length
121120
if failure_jobs > 0
122-
flash[:error] =
121+
flash[:error] =
123122
"Warning: Could not regrade #{ActionController::Base.helpers.pluralize(failure_jobs,
124123
"submission")}:<br>"
125124
failed_list.each do |failure|
@@ -193,7 +192,10 @@ def regradeAll
193192
# For both :success and :error
194193
flash[:html_safe] = true
195194

196-
redirect_to([@course, @assessment, :submissions]) && return
195+
respond_to do |format|
196+
format.html { redirect_to [@course, @assessment, :submissions] }
197+
format.json { render json: { redirect: url_for([@course, @assessment, :submissions]) } }
198+
end
197199
end
198200

199201
##
@@ -260,7 +262,7 @@ def sendJob_AddHTMLMessages(course, assessment, submissions)
260262
job
261263
end
262264

263-
def _is_i?(string)
264-
!!(string =~ /\A[-+]?[0-9]+\z/)
265+
def _is_i?(value)
266+
value.is_a?(Integer) || (value.is_a?(String) && value =~ /\A[-+]?\d+\z/)
265267
end
266268
end

app/views/submissions/index.html.erb

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,16 @@
8484
class: "btn submissions-main" } %>
8585
</div>
8686

87-
<div id="regrade-all-html">
88-
<%= link_to "<i class='material-icons left submissions-icons'>cached</i>Regrade All".html_safe,
89-
regradeAll_course_assessment_path(@course, @assessment),
90-
{ method: :post,
91-
title: "Regrade all submissions for this assignment",
92-
class: "btn submissions-main",
93-
data: { confirm: "Are you sure you want to regrade all #{@assessment.submissions.where(special_type: [Submission::NORMAL, nil]).latest.count} latest submissions?" } } %>
94-
</div>
87+
<a id="regrade-all-btn" class="btn submissions-main" title="Regrade all submissions for this assignment">
88+
<i class='material-icons left submissions-icons' id="regrade-all-icon">cached</i>Regrade All
89+
</a>
9590
</div>
9691

9792
<%# Selected buttons, hidden so HTML can be accessed in DataTables %>
9893
<div class="selected-buttons-placeholder">
9994
<div id="regrade-batch-html">
100-
<%= link_to "Regrade Selected", class: "btn submissions-selected", title: "Regrade selected submissions" do %>
101-
<i class="material-icons">cached</i> Regrade Selected
95+
<%= link_to "Regrade Selected", class: "btn submissions-selected", id: "regrade-selected-btn", title: "Regrade selected submissions" do %>
96+
<i class="material-icons" id="regrade-selected-icon">cached</i>Regrade Selected
10297
<% end %>
10398
</div>
10499

@@ -125,9 +120,13 @@
125120

126121
<div class="selected-count-placeholder" style="display: none;">
127122
<span id="selected-count-html">0 submissions selected</span>
128-
<span>Click <%= link_to "Regrade All", regradeAll_course_assessment_path(@course, @assessment),
129-
{ method: :post, title: "Regrade all submissions", class: "selected-count-red",
130-
data: { confirm: "Are you sure you want to regrade all #{@assessment.submissions.where(special_type: [Submission::NORMAL, nil]).latest.count} latest submissions?" } } %> to regrade all </span><%= @submissions.latest.length %><span> latest submissions.</span>
123+
<span>
124+
Click
125+
<a href="#" id="regrade-all-trigger" class="selected-count-red" title="Regrade all submissions">
126+
Regrade All
127+
</a>
128+
to regrade all <%= @submissions.latest.length %> latest submissions.
129+
</span>
131130
</div>
132131

133132
<table class="prettyBorder" id="submissions">

0 commit comments

Comments
 (0)