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

Added a button to release/unrelease grades #2081

Merged
merged 24 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7fa313f
added a button to release/unrelease grades
dwang3851 Feb 10, 2024
27331b4
Merge branch 'master' into releaseGrades-button
dwang3851 Feb 10, 2024
a5edda4
changed schema back
dwang3851 Feb 11, 2024
3a5b0d9
Update app/views/submissions/_release_grades.html.erb
dwang3851 Feb 11, 2024
16a2e1d
Update assessments_controller.rb
dwang3851 Feb 11, 2024
995aa05
Update _golden-layout.html.erb
dwang3851 Feb 11, 2024
94928f7
Update submissions_controller.rb for rubocop
dwang3851 Feb 11, 2024
ee36cb9
Update _release_grades.html.erb for linter
dwang3851 Feb 11, 2024
dfcdd61
fixed rubocop and linting
dwang3851 Feb 11, 2024
49887dd
Fixed issues from review
dwang3851 Feb 12, 2024
9da674d
Changed button from Release Grades to Release Grade
dwang3851 Feb 12, 2024
88c8c62
Merge branch 'master' into releaseGrades-button
dwang3851 Feb 12, 2024
2ac4e20
Update schema.rb
dwang3851 Feb 17, 2024
a5dd695
empty commit
dwang3851 Feb 19, 2024
0e44d5e
resolved various style issues, changed from get to post, and changed …
dwang3851 Feb 23, 2024
65e672a
Merge branch 'master' into releaseGrades-button
dwang3851 Feb 23, 2024
197151e
misc changes
dwang3851 Feb 23, 2024
c1c1e96
Fixed accidental spacing change to viewGradesheet.html
dwang3851 Feb 23, 2024
b438bb1
fixed annotation bug
dwang3851 Feb 26, 2024
04f7553
Merge branch 'master' into releaseGrades-button
dwang3851 Feb 26, 2024
31a7851
Merge branch 'master' into releaseGrades-button
dwang3851 Feb 26, 2024
2758d11
Removed release grades from cached page
dwang3851 Feb 26, 2024
20f28c2
Update view.js.erb
dwang3851 Feb 26, 2024
fa6c87b
Merge branch 'master' into releaseGrades-button
dwang3851 Feb 26, 2024
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
3 changes: 2 additions & 1 deletion app/assets/javascripts/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function purgeCurrentPageCache() {
symbolTree: `<div id="symbol-tree-container">${$('#symbol-tree-container').html()}</div>`,
versionLinks: `<span id="version-links">${$('#version-links').html()}</span>`,
versionDropdown: `<span id="version-dropdown">${$('#version-dropdown').html()}</span>`,
url: window.location.href,
url: window.location.href
};
}

Expand Down Expand Up @@ -184,6 +184,7 @@ function fillAnnotationBox() {
$('.problemGrades').html($page.find('.problemGrades'));
$('#annotationPane').html($page.find(' #annotationPane'));
$('.collapsible').collapsible({ accordion: false });
$('#release-grades').html($page.find('#release-grades'));
$('#loadScreen').hide();
attachChangeFileEvents();
attachAnnotationPaneEvents();
Expand Down
21 changes: 20 additions & 1 deletion app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class SubmissionsController < ApplicationController
before_action :set_assessment
before_action :set_assessment_breadcrumb
before_action :set_manage_submissions_breadcrumb, except: %i[index]
before_action :set_submission, only: %i[destroy destroyConfirm download edit update view]
before_action :set_submission, only: %i[destroy destroyConfirm download edit update
view release_student_grade unrelease_student_grade]
before_action :get_submission_file, only: %i[download view]

# this page loads. links/functionality may be/are off
Expand Down Expand Up @@ -611,6 +612,24 @@ def view
end
end

action_auth_level :release_student_grade, :course_assistant
def release_student_grade
@submission.scores.each do |score|
score.released = true
score.save
end
redirect_back(fallback_location: root_path)
end
dwang3851 marked this conversation as resolved.
Show resolved Hide resolved

action_auth_level :unrelease_student_grade, :course_assistant
def unrelease_student_grade
@submission.scores.each do |score|
score.released = false
score.save
end
redirect_back(fallback_location: root_path)
end
dwang3851 marked this conversation as resolved.
Show resolved Hide resolved

private

def new_submission_params
Expand Down
1 change: 1 addition & 0 deletions app/helpers/submission_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ def plus_fix(f)
sprintf("%.2f", f.round(2))
end
end

end
7 changes: 5 additions & 2 deletions app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,13 @@ def as_json(options = {})
json
end

def problems_released?
scores.pluck(:released).all?
end
dwang3851 marked this conversation as resolved.
Show resolved Hide resolved

def grades_released?(as_seen_by)
include_unreleased = as_seen_by.course_assistant? || as_seen_by.instructor?
released = scores.pluck(:released).all?
released || include_unreleased
problems_released? || include_unreleased
end

# easy access to AUD
Expand Down
50 changes: 25 additions & 25 deletions app/views/assessments/_handin_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
<% grace_late_info = "" %>

<% if @aud.past_due_at? %>
<% currentTime = Time.zone.now %>
<% days_late = currentTime - @aud.due_at + (currentTime.utc_offset - @aud.due_at.utc_offset) %>
<% days_late = (days_late / 1.day).ceil %>
<% grace_days_left = @aud.grace_days_usable %>
<% if grace_days_left >= days_late %>
<% grace_late_info = "submitting #{pluralize(days_late, 'day')} late using #{pluralize(days_late, 'grace day')}" %>
<% elsif grace_days_left > 0 %>
<% grace_late_info = "submitting #{pluralize(days_late, 'day')} late using #{pluralize(grace_days_left, 'grace day')} with #{pluralize(days_late - grace_days_left, 'penalty late day')}" %>
<% else %>
<% grace_late_info = "submitting #{pluralize(days_late, 'day')} late using #{pluralize(days_late, 'penalty late day')}" %>
<% end %>
<% late_confirm = " and that I am #{grace_late_info} under the late policy as defined in the syllabus" %>
<% currentTime = Time.zone.now %>
<% days_late = currentTime - @aud.due_at + (currentTime.utc_offset - @aud.due_at.utc_offset) %>
<% days_late = (days_late / 1.day).ceil %>
<% grace_days_left = @aud.grace_days_usable %>
<% if grace_days_left >= days_late %>
<% grace_late_info = "submitting #{pluralize(days_late, 'day')} late using #{pluralize(days_late, 'grace day')}" %>
<% elsif grace_days_left > 0 %>
<% grace_late_info = "submitting #{pluralize(days_late, 'day')} late using #{pluralize(grace_days_left, 'grace day')} with #{pluralize(days_late - grace_days_left, 'penalty late day')}" %>
<% else %>
<% grace_late_info = "submitting #{pluralize(days_late, 'day')} late using #{pluralize(days_late, 'penalty late day')}" %>
<% end %>
<% late_confirm = " and that I am #{grace_late_info} under the late policy as defined in the syllabus" %>
<p><b>Warning:</b> Submitting late may result in the usage of a grace day or a grade penalty!</p>
<% end %>

Expand All @@ -33,14 +33,14 @@
<%= render partial: "submission_panel", locals: { repos: @repos, f: } %>
<% filename_list = @assessment.handin_filename.split(".") %>
<% if (filename_list.size > 1) %>
<!-- file needs to have a period, else we ignore (e.g. for README files) -->
<div class="filename-check" id="filename-check">
<div>
Handin format:
.<b id="handin-file-type"><%= filename_list[1..].join(".") %></b> files
</div>
<b id="handin-file-type-incorrect" style="color: red; margin: 0"></b>
<!-- file needs to have a period, else we ignore (e.g. for README files) -->
<div class="filename-check" id="filename-check">
<div>
Handin format:
.<b id="handin-file-type"><%= filename_list[1..].join(".") %></b> files
</div>
<b id="handin-file-type-incorrect" style="color: red; margin: 0"></b>
</div>
<% end %>
<%= label_tag(:integrity_checkbox) do %>
<%= check_box_tag(:integrity_checkbox) %>
Expand All @@ -52,13 +52,13 @@
<div class="row" style="padding-top: 10px">
<div id="submission_error" style="color:red" class="col s6 m8 center-align"></div>
<% if @aud.past_due_at? then %>
<div class="col s6 m4 center-align">
<%= f.submit("Submit Late", id: "fake-submit", class: "btn primary handin-btn disabled") %>
</div>
<div class="col s6 m4 center-align">
<%= f.submit("Submit Late", id: "fake-submit", class: "btn primary handin-btn disabled") %>
</div>
<% else %>
<div class="col s6 m4 center-align">
<%= f.submit("Submit", id: "fake-submit", class: "btn primary handin-btn disabled") %>
</div>
<div class="col s6 m4 center-align">
<%= f.submit("Submit", id: "fake-submit", class: "btn primary handin-btn disabled") %>
</div>
<% end %>
</div>
<div class="row">
Expand Down
9 changes: 9 additions & 0 deletions app/views/submissions/_grades.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
<b> &ndash; </b>
<% end %>
<b> / <%= p.max_score ? sprintf("%.2f", p.max_score.round(2)) : raw("&ndash;") %></b>
<b>
<% if p_score != nil and (@cud.instructor? or @cud.course_assistant?) %>
<% if p_score.released %>
(Released)
<% else %>
(Unreleased)
<% end %>
<% end %>
</b>
</div>
</div>
<% end %>
Expand Down
13 changes: 13 additions & 0 deletions app/views/submissions/_release_grades.html.erb
dwang3851 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<span id="release-grades">
<% unless @submission.problems_released? %>
<%= link_to(release_student_grade_course_assessment_submission_path(@course, @assessment, @submission),
class: "btn small", title: "Release scores for current student", method: :post) do %>
Release Grade
<% end %>
<% else %>
<%= link_to(unrelease_student_grade_course_assessment_submission_path(@course, @assessment, @submission),
class: "btn small", title: "Unrelease scores for current student", method: :post) do %>
Unrelease Grade
<% end %>
<% end %>
</span>
1 change: 1 addition & 0 deletions app/views/submissions/view.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<%= render "version_links" %>
<a href="<%= download_file_url(@submission) %>" class="btn small" title="Download">Download</a>
<button class="btn small" onclick="resetLayout()">Reset Layout</button>
<%= render "release_grades" %>
</div>

<div class="col s2 center-align">
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@
get "destroyConfirm"
get "download"
get "view"
post "release_student_grade"
post "unrelease_student_grade"
end

collection do
Expand Down