ace editor in edit view!
This commit is contained in:
@ -6,7 +6,7 @@ class ExercisesController < ApplicationController
|
||||
|
||||
before_action :handle_file_uploads, only: [:create, :update]
|
||||
before_action :set_execution_environments, only: [:create, :edit, :new, :update]
|
||||
before_action :set_exercise, only: MEMBER_ACTIONS + [:clone, :implement, :run, :statistics, :submit, :reload]
|
||||
before_action :set_exercise, only: MEMBER_ACTIONS + [:clone, :implement, :edit, :run, :statistics, :submit, :reload]
|
||||
before_action :set_external_user, only: [:statistics]
|
||||
before_action :set_file_types, only: [:create, :edit, :new, :update]
|
||||
before_action :set_teams, only: [:create, :edit, :new, :update]
|
||||
@ -64,6 +64,16 @@ class ExercisesController < ApplicationController
|
||||
end
|
||||
|
||||
def edit
|
||||
redirect_to(@exercise, alert: t('exercises.implement.no_files')) unless @exercise.files.visible.exists?
|
||||
@submission = current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first
|
||||
@files = (@submission ? @submission.collect_files : @exercise.files).select(&:visible).sort_by(&:name_with_extension)
|
||||
@paths = collect_paths(@files)
|
||||
|
||||
if current_user.respond_to? :external_id
|
||||
@user_id = current_user.external_id
|
||||
else
|
||||
@user_id = current_user.id
|
||||
end
|
||||
end
|
||||
|
||||
def import_proforma_xml
|
||||
|
@ -3,5 +3,7 @@
|
||||
|
|
||||
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)
|
||||
= render('editor_frame', exercise: e, file: @files)
|
||||
// Need to render content in ace editor instead of plain text
|
||||
/= render('editor_frame', exercise: @exercise, file: @exercise.files.first)
|
||||
= form.file_field(attribute, class: 'alternative-input form-control', disabled: true)
|
||||
|
||||
|
0
app/views/exercises/_editor2.html.slim
Normal file
0
app/views/exercises/_editor2.html.slim
Normal file
@ -1,10 +1,5 @@
|
||||
- id = f.object.id
|
||||
|
||||
|
||||
.editor-content.hidden data-file-id=:ancestor_id = :content
|
||||
.editor data-file-id=:ancestor_id data-indent-size=2 data-mode="ace/mode/python" data-read-only=true data-id=:id
|
||||
|
||||
|
||||
li.panel.panel-default
|
||||
.panel-heading role="tab" id="heading"
|
||||
a.file-heading data-toggle="collapse" data-parent="#files" href="#collapse#{id}"
|
||||
@ -37,10 +32,13 @@ li.panel.panel-default
|
||||
.test-related-fields style="display: #{f.object.teacher_defined_test? ? 'initial' : 'none'};"
|
||||
.form-group
|
||||
= f.label(:name, t('activerecord.attributes.file.feedback_message'))
|
||||
= f.label(:ancestor_id, t('activerecord.attributes.file.name'))
|
||||
= f.text_area(:feedback_message, class: 'form-control', maxlength: 255)
|
||||
.help-block = t('.hints.feedback_message')
|
||||
.form-group
|
||||
= 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, e: @exercise, label: t('activerecord.attributes.file.content'))
|
||||
= render('code_field', attribute: :content, form: f, exercise: @exercise, files: @exercise.files, label: t('activerecord.attributes.file.content'))
|
||||
|
||||
/=render('editor', exercise: @exercise, files: @files, submission: @submission)
|
||||
/= render('editor_frame', exercise: @exercise, file: @exercise.files.take)
|
||||
|
||||
|
@ -35,8 +35,10 @@
|
||||
h2 = t('activerecord.attributes.exercise.files')
|
||||
ul#files.list-unstyled.panel-group
|
||||
= f.fields_for :files do |files_form|
|
||||
= render('file_form', f: files_form, object: @exercise)
|
||||
a#add-file.btn.btn-default.btn-sm.pull-right href='#' = t('.add_file')
|
||||
= render('file_form', f: files_form)
|
||||
/a#add-file.btn.btn-default.btn-sm.pull-right href='#' = t('.add_file')
|
||||
= render('editor', exercise: @exercise, files: @files, submission: @submission)
|
||||
ul#dummies.hidden = f.fields_for(:files, CodeOcean::File.new, child_index: 'index') do |files_form|
|
||||
= render('file_form', f: files_form, e: @exercise)
|
||||
= render('file_form', f: files_form, exercise: @exercise)
|
||||
/= render('editor2', exercise: @exercise, files: @exercise.files, submission: @submission)
|
||||
.actions = render('shared/submit_button', f: f, object: @exercise)
|
||||
|
7
app/views/exercises/_form2.html.slim
Normal file
7
app/views/exercises/_form2.html.slim
Normal file
@ -0,0 +1,7 @@
|
||||
#editor.row data-exercise-id=@exercise.id
|
||||
#files style=("display: none;") 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
|
||||
.editor-content.hidden data-file-id=file.ancestor_id = file.content
|
||||
.editor data-file-id=file.ancestor_id data-indent-size=file.file_type.indent_size data-mode=file.file_type.editor_mode data-read-only=file.read_only data-id=file.id
|
@ -1,87 +1,5 @@
|
||||
.row
|
||||
#editor-column.col-md-10.col-md-offset-1
|
||||
h1 = @exercise
|
||||
|
||||
span.badge.pull-right.score
|
||||
|
||||
p.lead = render_markdown(@exercise.description)
|
||||
|
||||
#alert.alert.alert-danger role='alert'
|
||||
h4 = t('.alert.title')
|
||||
p = t('.alert.text', application_name: application_name)
|
||||
|
||||
#development-environment
|
||||
ul.nav.nav-justified.nav-tabs role='tablist'
|
||||
li.active
|
||||
a data-placement='top' data-toggle='tab' data-tooltip=true href='#workspace' role='tab' title=t('shared.tooltips.shortcut', shortcut: 'ALT + 1')
|
||||
i.fa.fa-code
|
||||
= t('.workspace')
|
||||
li
|
||||
a data-placement='top' data-toggle='tab' data-tooltip=true href='#outputInformation' role='tab' title=t('shared.tooltips.shortcut', shortcut: 'ALT + 2')
|
||||
i.fa.fa-terminal
|
||||
= t('.output')
|
||||
li
|
||||
a data-placement='top' data-toggle='tab' data-tooltip=true href='#progress' role='tab' title=t('shared.tooltips.shortcut', shortcut: 'ALT + 3')
|
||||
i.fa.fa-line-chart
|
||||
= t('.progress')
|
||||
|
||||
hr
|
||||
|
||||
.tab-content
|
||||
#workspace.tab-pane.active = render('editor', exercise: @exercise, files: @files, submission: @submission)
|
||||
#outputInformation.tab-pane data-message-no-output=t('.no_output')
|
||||
#hint
|
||||
.panel.panel-warning
|
||||
.panel-heading = t('.hint')
|
||||
.panel-body
|
||||
.row
|
||||
/ #output-col1.col-sm-12
|
||||
#output-col1
|
||||
// todo set to full width if turtle isnt used
|
||||
#prompt.input-group.hidden
|
||||
span.input-group-addon data-prompt=t('exercises.editor.input') = t('exercises.editor.input')
|
||||
input#prompt-input.form-control type='text'
|
||||
span.input-group-btn
|
||||
button#prompt-submit.btn.btn-primary type="button" = t('exercises.editor.send')
|
||||
#output
|
||||
pre = t('.no_output_yet')
|
||||
- if CodeOcean::Config.new(:code_ocean).read[:flowr][:enabled]
|
||||
#flowrHint.panel.panel-info data-url=CodeOcean::Config.new(:code_ocean).read[:flowr][:url] role='tab'
|
||||
.panel-heading = 'Gain more insights here'
|
||||
.panel-body
|
||||
#output-col2.col-lg-5.col-md-5
|
||||
#turtlediv
|
||||
// todo what should the canvas default size be?
|
||||
canvas#turtlecanvas.hidden width=400 height=400 style='border-style:solid;border-width:thin'
|
||||
#progress.tab-pane
|
||||
#results
|
||||
h2 = t('.results')
|
||||
p.test-count == t('.test_count', count: 0)
|
||||
ul.list-unstyled
|
||||
ul#dummies.hidden.list-unstyled
|
||||
li.panel.panel-default
|
||||
.panel-heading
|
||||
h3.panel-title == t('.file', filename: '', number: 0)
|
||||
.panel-body
|
||||
= row(label: '.passed_tests', value: t('shared.out_of', maximum_value: 0, value: 0).html_safe)
|
||||
= row(label: 'activerecord.attributes.submission.score', value: t('shared.out_of', maximum_value: 0, value: 0).html_safe)
|
||||
= row(label: '.feedback')
|
||||
= row(label: '.error_messages')
|
||||
= row(label: '.output', value: link_to(t('shared.show'), '#'))
|
||||
#score data-maximum-score=@exercise.maximum_score data-score=@submission.try(:score)
|
||||
h4
|
||||
span == "#{t('activerecord.attributes.submission.score')}: "
|
||||
span.score
|
||||
.progress
|
||||
.progress-bar role='progressbar'
|
||||
|
||||
br
|
||||
- if session[:lti_parameters].try(:has_key?, 'lis_outcome_service_url')
|
||||
p.text-center = render('editor_button', classes: 'btn-lg btn-success', data: {:'data-url' => submit_exercise_path(@exercise)}, icon: 'fa fa-send', id: 'submit', label: t('exercises.editor.submit'))
|
||||
- else
|
||||
p.text-center = render('editor_button', classes: 'btn-lg btn-warning-outline', data: {:'data-placement' => 'bottom', :'data-tooltip' => true} , icon: 'fa fa-clock-o', id: 'submit_outdated', label: t('exercises.editor.exercise_deadline_passed'), title: t('exercises.editor.tooltips.exercise_deadline_passed'))
|
||||
|
||||
- if qa_url
|
||||
#questions-column
|
||||
#questions-holder data-url="#{qa_url}/qa/index/#{@exercise.id}/#{@user_id}"
|
||||
= qa_js_tag
|
||||
#editor.row data-exercise-id=@exercise.id
|
||||
#files style=("display: none;") 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|
|
||||
= render('editor_frame', exercise: @exercise, file: file)
|
||||
|
7
app/views/exercises/implement2.html.slim
Normal file
7
app/views/exercises/implement2.html.slim
Normal file
@ -0,0 +1,7 @@
|
||||
#editor.row data-exercise-id=@exercise.id
|
||||
#files style=("display: none;") 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|
|
||||
/= render('editor_frame', exercise: @exercise, file: file)
|
||||
.editor-content.hidden data-file-id=file.ancestor_id = file.content
|
||||
.editor data-file-id=file.ancestor_id data-indent-size=file.file_type.indent_size data-mode=file.file_type.editor_mode data-read-only=file.read_only data-id=file.id
|
Reference in New Issue
Block a user