Skip to content

Commit

Permalink
Merge pull request #4822 from MarkUsProject/v1.10.1-rc
Browse files Browse the repository at this point in the history
v1.10.0
  • Loading branch information
mishaschwartz authored Aug 18, 2020
2 parents b8bf9d4 + 33412e7 commit c660fcc
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 25 deletions.
16 changes: 13 additions & 3 deletions app/assets/javascripts/Components/marks_spreadsheet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ class RawMarksSpreadsheet extends React.Component {
ref={(r) => this.actionBox = r}
toggleRelease={this.toggleRelease}
showHidden={this.state.show_hidden}
is_allowed_to_release_unrelease={this.props.is_allowed_to_release_unrelease}
updateShowHidden={this.updateShowHidden} />
<CheckboxTable
ref={(r) => this.checkboxTable = r}
Expand Down Expand Up @@ -391,15 +392,24 @@ class SpreadsheetActionBox extends React.Component {
};

render() {
return (
<div className='rt-action-box'>
{this.hiddenInput()}
let releaseButton, unreleaseButton;
if (this.props.is_allowed_to_release_unrelease) {
releaseButton = (
<button onClick={() => this.props.toggleRelease(true)}>
{I18n.t('submissions.release_marks')}
</button>
);
unreleaseButton = (
<button onClick={() => this.props.toggleRelease(false)}>
{I18n.t('submissions.unrelease_marks')}
</button>
);
}
return (
<div className='rt-action-box'>
{this.hiddenInput()}
{releaseButton}
{unreleaseButton}
</div>
);
}
Expand Down
6 changes: 1 addition & 5 deletions app/controllers/assignments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def update_starter_file
ApplicationRecord.transaction do
assignment.assignment_properties.update!(starter_file_assignment_params)
all_changed = assignment.assignment_properties.saved_changes?
starter_file_section_params.each do |section_params|
params[:sections].each do |section_params|
Section.find_by(id: section_params[:section_id])
&.update_starter_file_group(assignment.id, section_params[:group_id])
end
Expand Down Expand Up @@ -682,10 +682,6 @@ def starter_file_assignment_params
params.require(:assignment).permit(:starter_file_type, :default_starter_file_group_id)
end

def starter_file_section_params
params.permit(sections: [:section_id, :group_id]).require(:sections)
end

def starter_file_group_params
params.permit(starter_file_groups: [:id, :name, :entry_rename, :use_rename])
.require(:starter_file_groups)
Expand Down
6 changes: 2 additions & 4 deletions app/controllers/marking_schemes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ def create
marking_scheme.save!

# save marking weights
params['marking_scheme']['marking_weights_attributes'].each \
do |_key, obj|
params['marking_scheme']['marking_weights_attributes']&.each do |_key, obj|

marking_weight = MarkingWeight.new(
assessment_id: obj['id'],
Expand All @@ -63,8 +62,7 @@ def update
marking_scheme.save!

# save marking weights
params['marking_scheme']['marking_weights_attributes'].each \
do |_key, obj|
params['marking_scheme']['marking_weights_attributes']&.each do |_key, obj|

marking_weight = MarkingWeight.where(
assessment_id: obj['id'],
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def update_submissions
# See Assignment.get_repo_checkout_commands for details
def download_repo_checkout_commands
assignment = Assignment.find(params[:assignment_id])
ssh_url = allowed_to?(:git_enabled?, KeyPair) && params[:url_type] == 'ssh'
ssh_url = allowed_to?(:git_enabled?, KeyPair) && allowed_to?(:enabled?, KeyPair) && params[:url_type] == 'ssh'
svn_commands = assignment.get_repo_checkout_commands(ssh_url: ssh_url)
send_data svn_commands.join("\n"),
disposition: 'attachment',
Expand All @@ -629,7 +629,7 @@ def download_repo_checkout_commands
# See Assignment.get_repo_list for details
def download_repo_list
assignment = Assignment.find(params[:assignment_id])
send_data assignment.get_repo_list,
send_data assignment.get_repo_list(ssh: allowed_to?(:git_enabled?, KeyPair) && allowed_to?(:enabled?, KeyPair)),
disposition: 'attachment',
filename: "#{assignment.short_identifier}_repo_list.csv"
end
Expand Down
6 changes: 4 additions & 2 deletions app/models/assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,13 @@ def get_repo_checkout_commands(ssh_url: false)
end

# Get a list of group_name, repo-url pairs
def get_repo_list
def get_repo_list(ssh: false)
CSV.generate do |csv|
self.groupings.includes(:group).each do |grouping|
group = grouping.group
csv << [group.group_name, group.repository_external_access_url, group.repository_ssh_access_url]
data = [group.group_name, group.repository_external_access_url]
data << group.repository_ssh_access_url if ssh
csv << data
end
end
end
Expand Down
6 changes: 5 additions & 1 deletion app/policies/key_pair_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ class KeyPairPolicy < ApplicationPolicy
default_rule :manage?

def manage?
git_enabled? && (user.admin? || user.ta? || any_vcs_submit?)
enabled? && git_enabled? && (user.admin? || user.ta? || any_vcs_submit?)
end

def git_enabled?
Rails.configuration.x.repository.type == 'git'
end

def enabled?
Rails.configuration.enable_key_storage
end

def any_vcs_submit?
Assignment.joins(:assignment_properties)
.where('assignment_properties.vcs_submit': true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
</div>
<div class="listings separate-listing">
<%= render partial: 'uncategorized_annotations',
locals: { assignment: @annotation_categories.first.assignment } %>
locals: { assignment: @assignment } %>
</div>
2 changes: 1 addition & 1 deletion app/views/assignments/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
<h3><%= t('groups.student_interface.url_group_repository') %></h3>
<div class='sub_block'>
HTTPS: <a href='#'><%= @grouping.group.repository_external_access_url %></a>
<% if allowed_to?(:git_enabled?, KeyPair) %>
<% if allowed_to?(:git_enabled?, KeyPair) && allowed_to?(:enabled?, KeyPair) %>
<br/>
SSH: <a href='#'><%= @grouping.group.repository_ssh_access_url %></a>
<% end %>
Expand Down
3 changes: 2 additions & 1 deletion app/views/grade_entry_forms/grades.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
grade_entry_form_id: <%= @grade_entry_form.id %>,
show_total: <%= @grade_entry_form.show_total ? 'true' : 'false' %>,
out_of_total: <%= @grade_entry_form.out_of_total %>,
show_sections: <%= Section.exists? %>
show_sections: <%= Section.exists? %>,
is_allowed_to_release_unrelease: <%= @current_user.admin? %>
}
);
})
Expand Down
10 changes: 7 additions & 3 deletions app/views/submissions/browse.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@
{ link_text: t('submissions.repo_list'),
link_path: download_repo_list_assignment_submissions_path(@assignment)},
{ link_text: t('submissions.repo_checkout_file', type: 'HTTPS'),
link_path: download_repo_checkout_commands_assignment_submissions_path(@assignment, url_type: :https)},
{ link_text: t('submissions.repo_checkout_file', type: 'SSH'),
link_path: download_repo_checkout_commands_assignment_submissions_path(@assignment, url_type: :ssh)}
link_path: download_repo_checkout_commands_assignment_submissions_path(@assignment, url_type: :https)}
] %>
<% if allowed_to?(:git_enabled?, KeyPair) && allowed_to?(:enabled?, KeyPair)
@heading_buttons += [
{ link_text: t('submissions.repo_checkout_file', type: 'SSH'),
link_path: download_repo_checkout_commands_assignment_submissions_path(@assignment, url_type: :ssh)}
]
end %>
<% end %>
<% end %>

Expand Down
1 change: 1 addition & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
# Directory where authentication keys will be uploaded. Make sure MarkUs is
# allowed to write to this directory
config.key_storage = "#{config.data_dir}/keys"
config.enable_key_storage = true
config.x.queues.update_keys = "CSC108"

# Max file size for submission files, in bytes
Expand Down
1 change: 1 addition & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
# Directory where authentication keys will be uploaded. Make sure MarkUs
# is allowed to write to this directory
config.key_storage = "#{config.data_dir}/keys"
config.enable_key_storage = true
config.x.queues.update_keys = "CSC108"

# Max file size for submission files, in bytes
Expand Down
1 change: 1 addition & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
# Directory where authentication keys will be uploaded.
# Make sure MarkUs is allowed to write to this directory
config.key_storage = "#{config.data_dir}/keys"
config.enable_key_storage = true
config.x.queues.update_keys = "CSC108"

# Max file size for submission files, in bytes
Expand Down
26 changes: 26 additions & 0 deletions spec/controllers/marking_schemes_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@
expected_ids = [assignment.id, assignment_with_criteria_and_results.id]
expect(marking_weights.map(&:assessment_id)).to match_array expected_ids
end

it 'creates a marking scheme when there are no assessments' do
params = {
'marking_scheme': { 'name': 'Test Marking Scheme' }
}

post_as admin, :create, params: params
marking_scheme = MarkingScheme.first
marking_weights = marking_scheme.marking_weights
expect(marking_scheme.name).to eq 'Test Marking Scheme'
expect(marking_weights.size).to eq 0
end
end

context '#update' do
Expand Down Expand Up @@ -112,6 +124,20 @@
expect(marking_weights.size).to eq 4
expect(marking_weights.map(&:weight)).to match_array expected_weights
end

it 'updates an existing marking scheme with no assessments' do
create(:marking_scheme)
params = {
'id': MarkingScheme.first.id,
'marking_scheme': { 'name': 'Test Marking Scheme 2' }
}

post_as admin, :update, params: params
marking_scheme = MarkingScheme.first
marking_weights = marking_scheme.marking_weights
expect(marking_scheme.name).to eq 'Test Marking Scheme 2'
expect(marking_weights.size).to eq 0
end
end

context '#new' do
Expand Down
3 changes: 1 addition & 2 deletions spec/models/assignment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,7 @@ def grouping_count(groupings)
@assignment.groupings.each do |grouping|
group = grouping.group
expected_string += [group.group_name,
group.repository_external_access_url,
group.repository_ssh_access_url].to_csv
group.repository_external_access_url].to_csv
end
expect(expected_string).to eql(@assignment.get_repo_list), 'Repo access url list string is wrong!'
end
Expand Down

0 comments on commit c660fcc

Please sign in to comment.