Feature: Auto-Completion in Source Code
+ allow flags for exercises
This commit is contained in:
@ -25,3 +25,4 @@
|
||||
//= require markdown.converter
|
||||
//= require markdown.sanitizer
|
||||
//= 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))
|
||||
|
||||
|
@ -36,6 +36,7 @@ de:
|
||||
public: Öffentlich
|
||||
title: Titel
|
||||
user: Autor
|
||||
allow_auto_completion: "Autovervollständigung aktivieren"
|
||||
allow_file_creation: "Dateierstellung erlauben"
|
||||
external_user:
|
||||
consumer: Konsument
|
||||
|
@ -36,6 +36,7 @@ en:
|
||||
public: Public
|
||||
title: Title
|
||||
user: Author
|
||||
allow_auto_completion: "Allow auto completion"
|
||||
allow_file_creation: "Allow file creation"
|
||||
external_user:
|
||||
consumer: Consumer
|
||||
|
@ -0,0 +1,5 @@
|
||||
class AddAllowAutoCompletionToExercises < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :exercises, :allow_auto_completion, :boolean, default: false
|
||||
end
|
||||
end
|
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160704143402) do
|
||||
ActiveRecord::Schema.define(version: 20160907123009) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@ -74,7 +74,6 @@ ActiveRecord::Schema.define(version: 20160704143402) do
|
||||
t.integer "file_type_id"
|
||||
t.integer "memory_limit"
|
||||
t.boolean "network_enabled"
|
||||
|
||||
end
|
||||
|
||||
create_table "exercises", force: true do |t|
|
||||
@ -90,6 +89,7 @@ ActiveRecord::Schema.define(version: 20160704143402) do
|
||||
t.string "token"
|
||||
t.boolean "hide_file_tree"
|
||||
t.boolean "allow_file_creation"
|
||||
t.boolean "allow_auto_completion", default: false
|
||||
end
|
||||
|
||||
create_table "external_users", force: true do |t|
|
||||
|
Reference in New Issue
Block a user