Skip to content

Commit 8fbdf08

Browse files
author
Ben Lerner
committed
don't repeat the DOM id string, and also make the distinction between BN's grade.id, Orca's job.id, and the DOM element id clearer
1 parent 1ecb55c commit 8fbdf08

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

app/views/submissions/_scoring_common.html.erb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
scores = all_scores[:scores][i]
1414
update_time = all_grades[:grade_times][i]
1515
grade = grades&.find{|g| g.grader_id == gr.id}
16-
if gr.orca_status && !grade.has_orca_output?
17-
grades_to_get_status_for << { id: grade.id, job_status: gr.orca_job_status_for(grade) }
16+
gradeStatusDomId = "orca-status-grade-#{grade&.id}"
17+
if gr.orca_status && !grade&.has_orca_output?
18+
grades_to_get_status_for << {
19+
gradeStatusDomId: gradeStatusDomId,
20+
job_status: gr.orca_job_status_for(grade)
21+
}
1822
end
1923
%>
2024
<tr>
@@ -33,7 +37,7 @@
3337
<% if cur_reg_staff %>
3438
<% if grade.nil? %>
3539
Missing
36-
<%= link_to "Create grader",
40+
<%= link_to "Create grade",
3741
recreate_grade_course_assignment_submission_path(@course, @assignment, @submission, @gradesheet.graders[i]),
3842
method: 'post', class: "btn btn-warning" %>
3943
<% else %>
@@ -44,7 +48,7 @@
4448
<% if gr.orca_status %>
4549
<br/>
4650
<% orca_job_status = grade.has_orca_output? ? "Completed" : "" %>
47-
Orca Status: <span id="<%= "orca-status-grade-#{grade.id}" %>" class=""><%= orca_job_status %></span>
51+
Orca Status: <span id="<%= gradeStatusDomId %>" class=""><%= orca_job_status %></span>
4852
<% end %>
4953
<% if gr.autograde? %>
5054
<%= link_to "Rerun autograder",

app/views/submissions/_scoring_common.js.erb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
$(function() {
22
const gradesWithOrcaIDs = JSON.parse('<%= raw grades_with_orca_job_status %>');
3-
orcaURL = '<%= Grader.orca_config['site_url'][Rails.env] %>';
4-
gradesWithOrcaIDs.forEach(({id, job_status}) => {
3+
orcaURL = '<%= Grader.orca_config['site_url'][Rails.env] %>';
4+
gradesWithOrcaIDs.forEach(({gradeStatusDomId, job_status}) => {
55
const { location, id: orca_id } = job_status;
6-
const statusDOMID = `orca-status-grade-${id}`;
76
if (location === "Worker") {
8-
return $(`#${statusDOMID}`).text("This job is currently being graded.");
7+
return $(`#${gradeStatusDomId}`).text("This job is currently being graded.");
98
}
109
const statusURL = `${orcaURL}/api/v1/${location === "HoldingPen" ? "holding_pen" : "grading_queue"}/${orca_id}/status`;
1110
$.ajax({
1211
url: statusURL,
1312
type: 'GET',
1413
dataType: 'json',
1514
success: function (data) {
16-
$(`#${statusDOMID}`).text(data);
15+
$(`#${gradeStatusDomId}`).text(data);
1716
},
1817
error: function (err) {
19-
$(`#${statusDOMID}`).text(`Could not fetch orca status; ${err.status} ${err.statusText}`);
18+
$(`#${gradeStatusDomId}`).text(`Could not fetch orca status; ${err.status} ${err.statusText}`);
2019
}
2120
});
2221
});

0 commit comments

Comments
 (0)