Feature: Auto-Completion in Source Code
+ allow flags for exercises
This commit is contained in:
@ -24,4 +24,5 @@
|
||||
//= require bootstrap_pagedown
|
||||
//= require markdown.converter
|
||||
//= require markdown.sanitizer
|
||||
//= require markdown.editor
|
||||
//= require markdown.editor
|
||||
//= require ../../../vendor/assets/javascripts/ace/ext-language_tools
|
@ -221,6 +221,17 @@ var CodeOceanEditor = {
|
||||
editor.setReadOnly($(element).data('read-only') !== undefined);
|
||||
editor.setShowPrintMargin(false);
|
||||
editor.setTheme(this.THEME);
|
||||
|
||||
// set options for autocompletion
|
||||
if($(element).data('allow-auto-completion')){
|
||||
editor.setOptions({
|
||||
enableBasicAutocompletion: true,
|
||||
enableSnippets: false,
|
||||
enableLiveAutocompletion: true
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
editor.commands.bindKey("ctrl+alt+0", null);
|
||||
this.editors.push(editor);
|
||||
this.editor_for_file.set($(element).parent().data('filename'), editor);
|
||||
|
@ -118,7 +118,7 @@ class ExercisesController < ApplicationController
|
||||
private :user_by_code_harbor_token
|
||||
|
||||
def exercise_params
|
||||
params[:exercise].permit(:description, :execution_environment_id, :file_id, :instructions, :public, :hide_file_tree, :allow_file_creation, :title, files_attributes: file_attributes).merge(user_id: current_user.id, user_type: current_user.class.name)
|
||||
params[:exercise].permit(:description, :execution_environment_id, :file_id, :instructions, :public, :hide_file_tree, :allow_file_creation, :allow_auto_completion, :title, files_attributes: file_attributes).merge(user_id: current_user.id, user_type: current_user.class.name)
|
||||
end
|
||||
private :exercise_params
|
||||
|
||||
|
@ -12,4 +12,4 @@
|
||||
= link_to(file.native_file.file.name_with_extension, file.native_file.url)
|
||||
- else
|
||||
.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
|
||||
.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-allow-auto-completion=exercise.allow_auto_completion.to_s data-id=file.id
|
@ -28,6 +28,10 @@
|
||||
label
|
||||
= f.check_box(:allow_file_creation)
|
||||
= t('activerecord.attributes.exercise.allow_file_creation')
|
||||
.checkbox
|
||||
label
|
||||
= f.check_box(:allow_auto_completion)
|
||||
= t('activerecord.attributes.exercise.allow_auto_completion')
|
||||
h2 = t('activerecord.attributes.exercise.files')
|
||||
ul#files.list-unstyled.panel-group
|
||||
= f.fields_for :files do |files_form|
|
||||
|
@ -16,6 +16,7 @@ h1
|
||||
= row(label: 'exercise.public', value: @exercise.public?)
|
||||
= row(label: 'exercise.hide_file_tree', value: @exercise.hide_file_tree?)
|
||||
= row(label: 'exercise.allow_file_creation', value: @exercise.allow_file_creation?)
|
||||
= row(label: 'exercise.allow_auto_completion', value: @exercise.allow_auto_completion?)
|
||||
= row(label: 'exercise.embedding_parameters') do
|
||||
= content_tag(:input, nil, class: 'form-control', readonly: true, value: embedding_parameters(@exercise))
|
||||
|
||||
|
Reference in New Issue
Block a user