ace with files

This commit is contained in:
yqbk
2016-08-02 15:02:02 +02:00
parent f7eaa24a1d
commit de866d00ca
6 changed files with 38 additions and 6 deletions

View File

@ -7,6 +7,12 @@ button i.fa-spin {
width: 100%;
}
.editor2 {
height: 100%;
width: 100%;
}
.frame {
display: none;
height: 400px;
@ -16,6 +22,15 @@ button i.fa-spin {
}
}
.frame2 {
display: none;
height: 100px;
audio, img, video {
max-width: 100%;
}
}
.score {
display: none;
}

View File

@ -1,8 +1,10 @@
.form-group class="form-group-#{attribute.to_s.gsub('_', '-')}"
= form.label(attribute, label)
|  
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 original-input', rows: 16)
// Need to render content in ace editor instead of plain text
= render('editor_frame', exercise: e, file: @files)
/= render('editor_frame', exercise: e, file: @files)
= form.file_field(attribute, class: 'alternative-input form-control', disabled: true)

View File

@ -1,5 +1,7 @@
- id = f.object.id
li.panel.panel-default
.panel-heading role="tab" id="heading"
a.file-heading data-toggle="collapse" data-parent="#files" href="#collapse#{id}"
@ -38,3 +40,4 @@ li.panel.panel-default
= f.label(:role, t('activerecord.attributes.file.weight'))
= f.number_field(:weight, class: 'form-control', min: 1, step: 'any')
= render('code_field', attribute: :content, form: f, label: t('activerecord.attributes.file.content'))
/= render('form2', exercise: @exercise, file: @files)

View File

@ -33,10 +33,19 @@
= f.check_box(:allow_file_creation)
= t('activerecord.attributes.exercise.allow_file_creation')
h2 = t('activerecord.attributes.exercise.files')
= render('form2', exercise: @exercise, file: @files)
ul#files.list-unstyled.panel-group
= f.fields_for :files do |files_form|
= render('file_form', f: files_form)
= render('file_form', f: files_form, exercise: @exercise, file: @files)
a#add-file.btn.btn-default.btn-sm.pull-right href='#' = t('.add_file')
ul#dummies.hidden = f.fields_for(:files, CodeOcean::File.new, child_index: 'index') do |files_form|
= render('file_form', f: files_form)
= render('file_form', f: files_form, exercise: @exercise, file: @files)
.actions = render('shared/submit_button', f: f, object: @exercise)

View File

@ -1,5 +1,5 @@
#editor.row data-exercise-id=@exercise.id
#files style=("display: none;") data-entries=FileTree.new(@files).to_js_tree
#editor.panel-group.row data-exercise-id=@exercise.id
#files style=("") data-entries=FileTree.new(@files).to_js_tree
div id='frames' class=(@exercise.hide_file_tree ? 'col-sm-12' : 'col-sm-9')
- @files.each do |file|
.frame data-executable=file.file_type.executable? data-filename=file.name_with_extension data-renderable=file.file_type.renderable? data-role=file.role data-binary=file.file_type.binary? data-context-type=file.context_type

View File

@ -1,3 +1,6 @@
h1 = @exercise
= render('form')
/= render('form')
= render('form', exercise: @exercise, files: @files)