Merge branch 'exercise_upload'

This commit is contained in:
Sebastian Serth
2020-12-16 18:51:13 +01:00
4 changed files with 6 additions and 4 deletions

View File

@ -219,7 +219,7 @@ class ExercisesController < ApplicationController
file_params[:content] = nil file_params[:content] = nil
file_params[:native_file] = file_attributes[:content] file_params[:native_file] = file_attributes[:content]
else else
file_params[:content] = file_attributes[:content].read file_params[:content] = file_attributes[:content].read.encode.delete("\x00")
end end
end end
end end

View File

@ -1,7 +1,7 @@
.form-group class="form-group-#{attribute.to_s.gsub('_', '-')}" .form-group class="form-group-#{attribute.to_s.gsub('_', '-')}"
= form.label(attribute, label) = form.label(attribute, label)
| &nbsp;
a.toggle-input data={text_initial: t('shared.upload_file'), text_toggled: t('shared.back')} href='#' = t('shared.upload_file')
= form.text_area(attribute, class: 'code-field form-control', rows: 16, style: "display:none;") = form.text_area(attribute, class: 'code-field form-control', rows: 16, style: "display:none;")
= form.file_field(attribute, class: 'alternative-input form-control-file', disabled: true)
= render partial: 'editor_edit', locals: { exercise: @exercise } = render partial: 'editor_edit', locals: { exercise: @exercise }
.card.border-warning.p-2.my-2
= form.file_field(attribute, class: 'form-control-file', style: "display: inline-block;")
.help-block.form-text = t('exercises.file_form.hints.upload')

View File

@ -366,6 +366,7 @@ de:
hints: hints:
feedback_message: Diese Nachricht wird als Hinweis zu fehlschlagenden Tests angezeigt. feedback_message: Diese Nachricht wird als Hinweis zu fehlschlagenden Tests angezeigt.
path: 'Pfad der Datei im Projektverzeichnis. Kann auch leer gelassen werden.' path: 'Pfad der Datei im Projektverzeichnis. Kann auch leer gelassen werden.'
upload: Eine hochgeladene Datei hat Vorrang vor Änderungen im Textfeld und wird nach dem Speichern sichtbar. Der Dateiname und die Dateiendung wird automatisch von der hochgeladenen Datei übernommen.
form: form:
add_file: Datei hinzufügen add_file: Datei hinzufügen
add_tips: Tipps hinzufügen add_tips: Tipps hinzufügen

View File

@ -368,6 +368,7 @@ en:
hints: hints:
feedback_message: This message is used as a hint for failing tests. feedback_message: This message is used as a hint for failing tests.
path: "The file's path in the project tree. Can be left blank." path: "The file's path in the project tree. Can be left blank."
upload: An uploaded file takes precedence over changes in the text area and will be visible once saved. The resulting file name and file type will be set to match the uploaded file automatically.
form: form:
add_file: Add file add_file: Add file
add_tips: Add tips add_tips: Add tips