Files
codeocean/app/views/exercises/_form.html.slim
Sebastian Serth d223abfb5e Update from webpacker v5 to shakapacker v6.0.0.rc13
Using a two-step process is recommended:
332e25186a/docs/v6_upgrade.md
2022-08-12 10:22:55 +02:00

105 lines
4.8 KiB
Plaintext

- content_for :head do
// Force a full page reload, see https://github.com/turbolinks/turbolinks/issues/326.
Otherwise, code might not be highlighted correctly (race condition)
meta name='turbolinks-visit-control' content='reload'
- append_javascript_pack_tag('sortable')
- execution_environments = ExecutionEnvironment.where('file_type_id IS NOT NULL').select(:file_type_id, :id)
- file_types = FileType.where('file_extension IS NOT NULL').select(:file_extension, :id)
= form_for(@exercise, data: {execution_environments: execution_environments, file_types: file_types}, multipart: true, builder: PagedownFormBuilder) do |f|
= render('shared/form_errors', object: @exercise)
.form-group
= f.label(:title)
= f.text_field(:title, class: 'form-control', required: true)
.form-group
= f.label(:description)
= f.pagedown :description, input_html: { preview: true, rows: 10 }
.form-group
= f.label(:execution_environment_id)
= f.collection_select(:execution_environment_id, @execution_environments, :id, :name, {include_blank: t('exercises.form.none')}, class: 'form-control')
/.form-group
= f.label(:instructions)
= f.hidden_field(:instructions)
.form-control.markdown
.form-group
= f.label(:submission_deadline)
.chosen-inline
= f.datetime_select(:submission_deadline, include_blank: true)
.help-block.form-text == t('.hints.submission_deadline')
.form-group
= f.label(:late_submission_deadline)
.chosen-inline
= f.datetime_select(:late_submission_deadline, include_blank: true)
.help-block.form-text == t('.hints.late_submission_deadline')
.form-check
label.form-check-label
= f.check_box(:public, class: 'form-check-input')
= t('activerecord.attributes.exercise.public')
.form-check
label.form-check-label
= f.check_box(:unpublished, class: 'form-check-input')
= t('activerecord.attributes.exercise.unpublished')
.form-check
label.form-check-label
= f.check_box(:hide_file_tree, class: 'form-check-input')
= t('activerecord.attributes.exercise.hide_file_tree')
.form-check
label.form-check-label
= f.check_box(:allow_file_creation, class: 'form-check-input')
= t('activerecord.attributes.exercise.allow_file_creation')
.form-check.mb-3
label.form-check-label
= f.check_box(:allow_auto_completion, class: 'form-check-input')
= t('activerecord.attributes.exercise.allow_auto_completion')
.form-group
= f.label(t('activerecord.attributes.exercise.difficulty'))
= f.number_field :expected_difficulty, in: 1..10, step: 1, class: 'form-control'
h2 = t('exercises.form.tags')
ul.list-unstyled.card-group
li.card
.card-header role="tab" id="heading"
a.file-heading data-toggle="collapse" href="#tag-collapse"
div.clearfix role="button"
span = t('exercises.form.click_to_collapse')
.card-collapse.collapse id="tag-collapse" role="tabpanel"
.table-responsive
table.table#tags-table
thead
tr
th = t('activerecord.attributes.exercise.selection')
th = sort_link(@search, :title, t('activerecord.attributes.tag.name'))
th = t('activerecord.attributes.tag.difficulty')
= collection_check_boxes :exercise, :tag_ids, @exercise_tags, :tag_id, :id do |b|
tr
td = b.check_box
td = b.object.tag.name
td = number_field "tag_factors[#{b.object.tag.id}]", :factor, :value => b.object.factor, in: 1..10, step: 1, class: 'form-control-sm'
h2 = t('.tips')
ul.list-unstyled.card-group
li.card
.card-header role="tab" id="tip-heading"
a.file-heading data-toggle="collapse" href="#tip-collapse"
div.clearfix role="button"
span = t('exercises.form.click_to_collapse')
.card-collapse.collapse.mx-2 id="tip-collapse" role="tabpanel"
= f.hidden_field(:tips, id: "tips-json", value: "")
.list-group.nested-sortable-list.mt-2#tip-list
= render(partial: 'tips/sortable_tip', collection: @tips, as: :exercise_tip)
button.btn.btn-outline-primary.my-2.w-100 type='button' data-toggle='modal' data-target='#add-tips-modal' = t('.add_tips')
h2 = t('activerecord.attributes.exercise.files')
ul#files.list-unstyled
= f.fields_for :files do |files_form|
= render('file_form', f: files_form)
a#add-file.btn.btn-secondary.btn-sm.float-right href='#' = t('.add_file')
ul#dummies.d-none = f.fields_for(:files, CodeOcean::File.new, child_index: 'index') do |files_form|
= render('file_form', f: files_form)
.actions = render('shared/submit_button', f: f, object: @exercise)
= render('shared/modal', id: 'add-tips-modal', title: t('.add_tips'), template: 'exercises/_add_tip_modal')