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

Adds warning when assessment.rb file upload isn't a .rb file #1999

Merged
merged 4 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ PLATFORMS
arm64-darwin-22
x86_64-darwin-19
x86_64-darwin-20
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
Expand Down
11 changes: 11 additions & 0 deletions app/assets/javascripts/edit_assessment.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@
changes = false;
});

$('#assessment_config_file').on('change', function () {
var fileSelector = $("#assessment_config_file").get(0);
var file = fileSelector.files[0];

if (!file?.name?.endsWith('.rb')) {
$('#config-file-type-incorrect').text(`Warning: ${file.name} doesn't match expected .rb file type`)
} else {
$('#config-file-type-incorrect').text("")
}
})

$('input[name="assessment[is_positive_grading]"]').on('change', function() {
if(has_annotations){
if ($(this).prop('checked') != is_positive_grading) {
Expand Down
1 change: 1 addition & 0 deletions app/views/assessments/_edit_basic.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<%= f.file_field :config_file, button_text: "Upload #{@assessment.name}.rb",
help_text: "Config file will be automatically reloaded after saving. Changes to other settings will
be lost if an error is encountered." %>
<b id="config-file-type-incorrect" style="color: red; margin: 0"></b>

<h4>Modules Used</h4>
<ul class="collection attachments">
Expand Down
Loading