111 lines
5.0 KiB
Plaintext
111 lines
5.0 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')
|
|
- append_javascript_pack_tag('toast-ui')
|
|
- append_stylesheet_pack_tag('toast-ui')
|
|
|
|
- execution_environments = ExecutionEnvironment.where.not(file_type_id: nil).select(:file_type_id, :id)
|
|
- file_types = FileType.where.not(file_extension: nil).select(:file_extension, :id)
|
|
|
|
= form_for(@exercise, data: {execution_environments:, file_types:}, multipart: true, builder: MarkdownFormBuilder) do |f|
|
|
= render('shared/form_errors', object: @exercise)
|
|
.mb-3
|
|
= f.label(:title, class: 'form-label')
|
|
= f.text_field(:title, class: 'form-control', required: true)
|
|
.mb-3
|
|
= f.label(:internal_title, class: 'form-label')
|
|
= f.text_field(:internal_title, class: 'form-control')
|
|
.help-block.form-text == t('.hints.internal_title')
|
|
.mb-3
|
|
= f.label(:description, class: 'form-label')
|
|
= f.markdown :description
|
|
.mb-3
|
|
= f.label(:execution_environment_id, class: 'form-label')
|
|
= f.collection_select(:execution_environment_id, @execution_environments, :id, :name, {include_blank: t('exercises.form.none')}, class: 'form-control')
|
|
/.mb-3
|
|
= f.label(:instructions, class: 'form-label')
|
|
= f.hidden_field(:instructions)
|
|
.form-control.markdown
|
|
.mb-3
|
|
= f.label(:submission_deadline, class: 'form-label')
|
|
.chosen-inline
|
|
= f.datetime_select(:submission_deadline, include_blank: true)
|
|
.help-block.form-text == t('.hints.submission_deadline')
|
|
.mb-3
|
|
= f.label(:late_submission_deadline, class: 'form-label')
|
|
.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')
|
|
= f.label(:public, class: 'form-label mb-0')
|
|
.form-check
|
|
label.form-check-label
|
|
= f.check_box(:unpublished, class: 'form-check-input')
|
|
= f.label(:unpublished, class: 'form-label mb-0')
|
|
.form-check
|
|
label.form-check-label
|
|
= f.check_box(:hide_file_tree, class: 'form-check-input')
|
|
= f.label(:hide_file_tree, class: 'form-label mb-0')
|
|
.form-check
|
|
label.form-check-label
|
|
= f.check_box(:allow_file_creation, class: 'form-check-input')
|
|
= f.label(:allow_file_creation, class: 'form-label mb-0')
|
|
.form-check.mb-3
|
|
label.form-check-label
|
|
= f.check_box(:allow_auto_completion, class: 'form-check-input')
|
|
= f.label(:allow_auto_completion, class: 'form-label mb-0')
|
|
.mb-3
|
|
= f.label(:expected_difficulty, class: 'form-label')
|
|
= 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#heading role='tab'
|
|
a.file-heading data-bs-toggle='collapse' href='#tag-collapse'
|
|
.clearfix role='button'
|
|
span = t('exercises.form.click_to_collapse')
|
|
.card-collapse.collapse#tag-collapse role='tabpanel'
|
|
.table-responsive
|
|
table.table#tags-table
|
|
thead
|
|
tr
|
|
th = Exercise.human_attribute_name('selection')
|
|
th = Tag.human_attribute_name('name')
|
|
th = Tag.human_attribute_name('difficulty')
|
|
= collection_check_boxes :exercise, :tag_ids, @exercise_tags, :tag_id, :id do |b|
|
|
tr
|
|
td = b.check_box class: 'form-check-input'
|
|
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 form-control-sm'
|
|
|
|
h2 = t('.tips')
|
|
ul.list-unstyled.card-group
|
|
li.card
|
|
.card-header#tip-heading role='tab'
|
|
a.file-heading data-bs-toggle='collapse' href='#tip-collapse'
|
|
.clearfix role='button'
|
|
span = t('exercises.form.click_to_collapse')
|
|
.card-collapse.collapse.mx-2#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-bs-toggle='modal' data-bs-target='#add-tips-modal' = t('.add_tips')
|
|
|
|
h2 = Exercise.human_attribute_name('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-end 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:, object: @exercise)
|
|
|
|
= render('shared/modal', id: 'add-tips-modal', title: t('.add_tips'), template: 'exercises/_add_tip_modal')
|