transferred Code Ocean from original repository to GitHub
This commit is contained in:
11
db/migrate/20140625134118_create_exercises.rb
Normal file
11
db/migrate/20140625134118_create_exercises.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class CreateExercises < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :exercises do |t|
|
||||
t.text :description
|
||||
t.belongs_to :execution_environment
|
||||
t.text :template_code
|
||||
t.string :title
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
11
db/migrate/20140626143132_create_execution_environments.rb
Normal file
11
db/migrate/20140626143132_create_execution_environments.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class CreateExecutionEnvironments < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :execution_environments do |t|
|
||||
t.string :docker_image
|
||||
t.string :editor_mode
|
||||
t.string :file_extension
|
||||
t.string :name
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
11
db/migrate/20140626144036_create_submissions.rb
Normal file
11
db/migrate/20140626144036_create_submissions.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class CreateSubmissions < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :submissions do |t|
|
||||
t.text :code
|
||||
t.belongs_to :exercise
|
||||
t.float :score
|
||||
t.belongs_to :user
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddReferenceImplementationToExercises < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :exercises, :reference_implementation, :text
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddIndentSizeToExecutionEnvironments < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :execution_environments, :indent_size, :integer
|
||||
end
|
||||
end
|
8
db/migrate/20140701120126_create_consumers.rb
Normal file
8
db/migrate/20140701120126_create_consumers.rb
Normal file
@ -0,0 +1,8 @@
|
||||
class CreateConsumers < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :consumers do |t|
|
||||
t.string :name
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
11
db/migrate/20140701122345_create_users.rb
Normal file
11
db/migrate/20140701122345_create_users.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class CreateUsers < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :users do |t|
|
||||
t.belongs_to :consumer
|
||||
t.string :email
|
||||
t.string :external_id
|
||||
t.string :name
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
5
db/migrate/20140702100130_add_oauth_key_to_consumers.rb
Normal file
5
db/migrate/20140702100130_add_oauth_key_to_consumers.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddOauthKeyToConsumers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :consumers, :oauth_key, :string
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddOauthSecretToConsumers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :consumers, :oauth_secret, :string
|
||||
end
|
||||
end
|
5
db/migrate/20140716153147_add_role_to_users.rb
Normal file
5
db/migrate/20140716153147_add_role_to_users.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddRoleToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :role, :string
|
||||
end
|
||||
end
|
5
db/migrate/20140717074902_add_user_id_to_exercises.rb
Normal file
5
db/migrate/20140717074902_add_user_id_to_exercises.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddUserIdToExercises < ActiveRecord::Migration
|
||||
def change
|
||||
add_reference :exercises, :user
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddRunCommandToExecutionEnvironments < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :execution_environments, :run_command, :string
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddTestCommandToExecutionEnvironments < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :execution_environments, :test_command, :string
|
||||
end
|
||||
end
|
5
db/migrate/20140723135747_add_test_code_to_exercises.rb
Normal file
5
db/migrate/20140723135747_add_test_code_to_exercises.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddTestCodeToExercises < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :exercises, :test_code, :text
|
||||
end
|
||||
end
|
5
db/migrate/20140724155359_add_cause_to_submissions.rb
Normal file
5
db/migrate/20140724155359_add_cause_to_submissions.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddCauseToSubmissions < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :submissions, :cause, :string
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddTemplateTestCodeToExercises < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :exercises, :template_test_code, :text
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddSupportsUserDefinedTestsToExercises < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :exercises, :supports_user_defined_tests, :boolean
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddTestingFrameworkToExecutionEnvironments < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :execution_environments, :testing_framework, :string
|
||||
end
|
||||
end
|
12
db/migrate/20140812102114_create_file_types.rb
Normal file
12
db/migrate/20140812102114_create_file_types.rb
Normal file
@ -0,0 +1,12 @@
|
||||
class CreateFileTypes < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :file_types do |t|
|
||||
t.string :editor_mode
|
||||
t.string :file_extension
|
||||
t.integer :indent_size
|
||||
t.string :name
|
||||
t.belongs_to :user
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
14
db/migrate/20140812144733_create_files.rb
Normal file
14
db/migrate/20140812144733_create_files.rb
Normal file
@ -0,0 +1,14 @@
|
||||
class CreateFiles < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :files do |t|
|
||||
t.text :content
|
||||
t.belongs_to :context, polymorphic: true
|
||||
t.belongs_to :file
|
||||
t.belongs_to :file_type
|
||||
t.boolean :hidden
|
||||
t.string :name
|
||||
t.boolean :read_only
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
class RemoveFileTypeRelatedColumnsFromExecutionEnvironments < ActiveRecord::Migration
|
||||
def change
|
||||
remove_column :execution_environments, :editor_mode, :string
|
||||
remove_column :execution_environments, :file_extension, :string
|
||||
remove_column :execution_environments, :indent_size, :integer
|
||||
end
|
||||
end
|
@ -0,0 +1,9 @@
|
||||
class RemoveFileRelatedColumnsFromExercises < ActiveRecord::Migration
|
||||
def change
|
||||
remove_column :exercises, :reference_implementation, :text
|
||||
remove_column :exercises, :supports_user_defined_tests, :boolean
|
||||
remove_column :exercises, :template_code, :text
|
||||
remove_column :exercises, :template_test_code, :text
|
||||
remove_column :exercises, :test_code, :text
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class RemoveCodeFromSubmissions < ActiveRecord::Migration
|
||||
def change
|
||||
remove_column :submissions, :code, :text
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddInstructionsToExercises < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :exercises, :instructions, :text
|
||||
end
|
||||
end
|
5
db/migrate/20140821064318_add_published_to_exercises.rb
Normal file
5
db/migrate/20140821064318_add_published_to_exercises.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddPublishedToExercises < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :exercises, :published, :boolean
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddExecutableToFileTypes < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :file_types, :executable, :boolean
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddRenderableToFileTypes < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :file_types, :renderable, :boolean
|
||||
end
|
||||
end
|
11
db/migrate/20140825121336_create_external_users.rb
Normal file
11
db/migrate/20140825121336_create_external_users.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class CreateExternalUsers < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :external_users do |t|
|
||||
t.belongs_to :consumer
|
||||
t.string :email
|
||||
t.string :external_id
|
||||
t.string :name
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
11
db/migrate/20140825125801_create_internal_users.rb
Normal file
11
db/migrate/20140825125801_create_internal_users.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class CreateInternalUsers < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :internal_users do |t|
|
||||
t.belongs_to :consumer
|
||||
t.string :email
|
||||
t.string :name
|
||||
t.string :role
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
5
db/migrate/20140825154202_drop_users.rb
Normal file
5
db/migrate/20140825154202_drop_users.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class DropUsers < ActiveRecord::Migration
|
||||
def change
|
||||
drop_table :users
|
||||
end
|
||||
end
|
5
db/migrate/20140825161350_add_user_type_to_exercises.rb
Normal file
5
db/migrate/20140825161350_add_user_type_to_exercises.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddUserTypeToExercises < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :exercises, :user_type, :string
|
||||
end
|
||||
end
|
5
db/migrate/20140825161358_add_user_type_to_file_types.rb
Normal file
5
db/migrate/20140825161358_add_user_type_to_file_types.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddUserTypeToFileTypes < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :file_types, :user_type, :string
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddUserTypeToSubmissions < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :submissions, :user_type, :string
|
||||
end
|
||||
end
|
8
db/migrate/20140826073318_sorcery_core.rb
Normal file
8
db/migrate/20140826073318_sorcery_core.rb
Normal file
@ -0,0 +1,8 @@
|
||||
class SorceryCore < ActiveRecord::Migration
|
||||
def change
|
||||
InternalUser.delete_all
|
||||
add_column :internal_users, :crypted_password, :string, null: false
|
||||
add_column :internal_users, :salt, :string, null: false
|
||||
add_index :internal_users, :email, unique: true
|
||||
end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
class SorceryBruteForceProtection < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :internal_users, :failed_logins_count, :integer, default: 0
|
||||
add_column :internal_users, :lock_expires_at, :datetime, default: nil
|
||||
add_column :internal_users, :unlock_token, :string, default: nil
|
||||
end
|
||||
end
|
7
db/migrate/20140826073320_sorcery_remember_me.rb
Normal file
7
db/migrate/20140826073320_sorcery_remember_me.rb
Normal file
@ -0,0 +1,7 @@
|
||||
class SorceryRememberMe < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :internal_users, :remember_me_token, :string, default: nil
|
||||
add_column :internal_users, :remember_me_token_expires_at, :datetime, default: nil
|
||||
add_index :internal_users, :remember_me_token
|
||||
end
|
||||
end
|
8
db/migrate/20140826073321_sorcery_reset_password.rb
Normal file
8
db/migrate/20140826073321_sorcery_reset_password.rb
Normal file
@ -0,0 +1,8 @@
|
||||
class SorceryResetPassword < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :internal_users, :reset_password_token, :string, default: nil
|
||||
add_column :internal_users, :reset_password_token_expires_at, :datetime, default: nil
|
||||
add_column :internal_users, :reset_password_email_sent_at, :datetime, default: nil
|
||||
add_index :internal_users, :reset_password_token
|
||||
end
|
||||
end
|
8
db/migrate/20140826073322_sorcery_user_activation.rb
Normal file
8
db/migrate/20140826073322_sorcery_user_activation.rb
Normal file
@ -0,0 +1,8 @@
|
||||
class SorceryUserActivation < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :internal_users, :activation_state, :string, default: nil
|
||||
add_column :internal_users, :activation_token, :string, default: nil
|
||||
add_column :internal_users, :activation_token_expires_at, :datetime, default: nil
|
||||
add_index :internal_users, :activation_token
|
||||
end
|
||||
end
|
5
db/migrate/20140827065359_add_binary_to_file_types.rb
Normal file
5
db/migrate/20140827065359_add_binary_to_file_types.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddBinaryToFileTypes < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :file_types, :binary, :boolean
|
||||
end
|
||||
end
|
5
db/migrate/20140827083957_add_native_file_to_files.rb
Normal file
5
db/migrate/20140827083957_add_native_file_to_files.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddNativeFileToFiles < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :files, :native_file, :string
|
||||
end
|
||||
end
|
12
db/migrate/20140829141913_create_hints.rb
Normal file
12
db/migrate/20140829141913_create_hints.rb
Normal file
@ -0,0 +1,12 @@
|
||||
class CreateHints < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :hints do |t|
|
||||
t.belongs_to :execution_environment
|
||||
t.string :locale
|
||||
t.text :message
|
||||
t.string :name
|
||||
t.string :regular_expression
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,6 @@
|
||||
class RemoveNotNullConstraintsFromInternalUsers < ActiveRecord::Migration
|
||||
def change
|
||||
change_column_null(:internal_users, :crypted_password, true)
|
||||
change_column_null(:internal_users, :salt, true)
|
||||
end
|
||||
end
|
9
db/migrate/20140903165113_create_errors.rb
Normal file
9
db/migrate/20140903165113_create_errors.rb
Normal file
@ -0,0 +1,9 @@
|
||||
class CreateErrors < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :errors do |t|
|
||||
t.belongs_to :execution_environment
|
||||
t.text :message
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
5
db/migrate/20140904082810_add_token_to_exercises.rb
Normal file
5
db/migrate/20140904082810_add_token_to_exercises.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddTokenToExercises < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :exercises, :token, :string
|
||||
end
|
||||
end
|
5
db/migrate/20140909115430_add_file_id_to_exercises.rb
Normal file
5
db/migrate/20140909115430_add_file_id_to_exercises.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddFileIdToExercises < ActiveRecord::Migration
|
||||
def change
|
||||
add_reference :exercises, :file
|
||||
end
|
||||
end
|
5
db/migrate/20140915095420_add_role_to_files.rb
Normal file
5
db/migrate/20140915095420_add_role_to_files.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddRoleToFiles < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :files, :role, :string
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class RemoveFileIdFromExercises < ActiveRecord::Migration
|
||||
def change
|
||||
remove_reference :exercises, :file
|
||||
end
|
||||
end
|
11
db/migrate/20140918063522_add_hashed_content_to_files.rb
Normal file
11
db/migrate/20140918063522_add_hashed_content_to_files.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class AddHashedContentToFiles < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :files, :hashed_content, :string
|
||||
|
||||
reversible do |direction|
|
||||
direction.up do
|
||||
CodeOcean::File.all.each(&:save)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddFeedbackMessageToFiles < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :files, :feedback_message, :string
|
||||
end
|
||||
end
|
5
db/migrate/20140922161226_add_weight_to_files.rb
Normal file
5
db/migrate/20140922161226_add_weight_to_files.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddWeightToFiles < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :files, :weight, :float
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddHelpToExecutionEnvironments < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :execution_environments, :help, :text
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddExposedPortsToExecutionEnvironments < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :execution_environments, :exposed_ports, :string
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddPermittedExecutionTimeToExecutionEnvironments < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :execution_environments, :permitted_execution_time, :integer
|
||||
end
|
||||
end
|
@ -0,0 +1,6 @@
|
||||
class AddUserIdAndUserTypeToExecutionEnvironments < ActiveRecord::Migration
|
||||
def change
|
||||
add_reference :execution_environments, :user
|
||||
add_column :execution_environments, :user_type, :string
|
||||
end
|
||||
end
|
5
db/migrate/20141017110211_rename_published_to_public.rb
Normal file
5
db/migrate/20141017110211_rename_published_to_public.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class RenamePublishedToPublic < ActiveRecord::Migration
|
||||
def change
|
||||
rename_column :exercises, :published, :public
|
||||
end
|
||||
end
|
5
db/migrate/20141031161603_add_path_to_files.rb
Normal file
5
db/migrate/20141031161603_add_path_to_files.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddPathToFiles < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :files, :path, :string
|
||||
end
|
||||
end
|
151
db/schema.rb
Normal file
151
db/schema.rb
Normal file
@ -0,0 +1,151 @@
|
||||
# encoding: UTF-8
|
||||
# This file is auto-generated from the current state of the database. Instead
|
||||
# of editing this file, please use the migrations feature of Active Record to
|
||||
# incrementally modify your database, and then regenerate this schema definition.
|
||||
#
|
||||
# Note that this schema.rb definition is the authoritative source for your
|
||||
# database schema. If you need to create the application database on another
|
||||
# system, you should be using db:schema:load, not running all the migrations
|
||||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
||||
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20141031161603) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
create_table "consumers", force: true do |t|
|
||||
t.string "name"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "oauth_key"
|
||||
t.string "oauth_secret"
|
||||
end
|
||||
|
||||
create_table "errors", force: true do |t|
|
||||
t.integer "execution_environment_id"
|
||||
t.text "message"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "execution_environments", force: true do |t|
|
||||
t.string "docker_image"
|
||||
t.string "name"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "run_command"
|
||||
t.string "test_command"
|
||||
t.string "testing_framework"
|
||||
t.text "help"
|
||||
t.string "exposed_ports"
|
||||
t.integer "permitted_execution_time"
|
||||
t.integer "user_id"
|
||||
t.string "user_type"
|
||||
end
|
||||
|
||||
create_table "exercises", force: true do |t|
|
||||
t.text "description"
|
||||
t.integer "execution_environment_id"
|
||||
t.string "title"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.integer "user_id"
|
||||
t.text "instructions"
|
||||
t.boolean "public"
|
||||
t.string "user_type"
|
||||
t.string "token"
|
||||
end
|
||||
|
||||
create_table "external_users", force: true do |t|
|
||||
t.integer "consumer_id"
|
||||
t.string "email"
|
||||
t.string "external_id"
|
||||
t.string "name"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "file_types", force: true do |t|
|
||||
t.string "editor_mode"
|
||||
t.string "file_extension"
|
||||
t.integer "indent_size"
|
||||
t.string "name"
|
||||
t.integer "user_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.boolean "executable"
|
||||
t.boolean "renderable"
|
||||
t.string "user_type"
|
||||
t.boolean "binary"
|
||||
end
|
||||
|
||||
create_table "files", force: true do |t|
|
||||
t.text "content"
|
||||
t.integer "context_id"
|
||||
t.string "context_type"
|
||||
t.integer "file_id"
|
||||
t.integer "file_type_id"
|
||||
t.boolean "hidden"
|
||||
t.string "name"
|
||||
t.boolean "read_only"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "native_file"
|
||||
t.string "role"
|
||||
t.string "hashed_content"
|
||||
t.string "feedback_message"
|
||||
t.float "weight"
|
||||
t.string "path"
|
||||
end
|
||||
|
||||
create_table "hints", force: true do |t|
|
||||
t.integer "execution_environment_id"
|
||||
t.string "locale"
|
||||
t.text "message"
|
||||
t.string "name"
|
||||
t.string "regular_expression"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "internal_users", force: true do |t|
|
||||
t.integer "consumer_id"
|
||||
t.string "email"
|
||||
t.string "name"
|
||||
t.string "role"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "crypted_password"
|
||||
t.string "salt"
|
||||
t.integer "failed_logins_count", default: 0
|
||||
t.datetime "lock_expires_at"
|
||||
t.string "unlock_token"
|
||||
t.string "remember_me_token"
|
||||
t.datetime "remember_me_token_expires_at"
|
||||
t.string "reset_password_token"
|
||||
t.datetime "reset_password_token_expires_at"
|
||||
t.datetime "reset_password_email_sent_at"
|
||||
t.string "activation_state"
|
||||
t.string "activation_token"
|
||||
t.datetime "activation_token_expires_at"
|
||||
end
|
||||
|
||||
add_index "internal_users", ["activation_token"], name: "index_internal_users_on_activation_token", using: :btree
|
||||
add_index "internal_users", ["email"], name: "index_internal_users_on_email", unique: true, using: :btree
|
||||
add_index "internal_users", ["remember_me_token"], name: "index_internal_users_on_remember_me_token", using: :btree
|
||||
add_index "internal_users", ["reset_password_token"], name: "index_internal_users_on_reset_password_token", using: :btree
|
||||
|
||||
create_table "submissions", force: true do |t|
|
||||
t.integer "exercise_id"
|
||||
t.float "score"
|
||||
t.integer "user_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "cause"
|
||||
t.string "user_type"
|
||||
end
|
||||
|
||||
end
|
25
db/seeds.rb
Normal file
25
db/seeds.rb
Normal file
@ -0,0 +1,25 @@
|
||||
def find_factories_by_class(klass)
|
||||
FactoryGirl.factories.select do |factory|
|
||||
factory.instance_variable_get(:@class_name) == klass || factory.instance_variable_get(:@name) == klass.model_name.singular.to_sym
|
||||
end
|
||||
end
|
||||
|
||||
class ActiveRecord::Base
|
||||
[:build, :create].each do |strategy|
|
||||
define_singleton_method("#{strategy}_factories") do |attributes = {}|
|
||||
find_factories_by_class(self).map(&:name).map do |factory_name|
|
||||
FactoryGirl.send(strategy, factory_name, attributes)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# delete all present records
|
||||
Rails.application.eager_load!
|
||||
(ActiveRecord::Base.descendants - [ActiveRecord::SchemaMigration]).each(&:delete_all)
|
||||
|
||||
# delete file uploads
|
||||
FileUtils.rm_rf(Rails.root.join('public', 'uploads'))
|
||||
|
||||
# load environment-dependent seeds
|
||||
load(Rails.root.join('db', 'seeds', "#{Rails.env}.rb"))
|
BIN
db/seeds/audio_video/chai.ogg
Normal file
BIN
db/seeds/audio_video/chai.ogg
Normal file
Binary file not shown.
BIN
db/seeds/audio_video/devstories.mp4
Normal file
BIN
db/seeds/audio_video/devstories.mp4
Normal file
Binary file not shown.
BIN
db/seeds/audio_video/devstories.webm
Normal file
BIN
db/seeds/audio_video/devstories.webm
Normal file
Binary file not shown.
10
db/seeds/audio_video/index.html
Normal file
10
db/seeds/audio_video/index.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
|
||||
<script src="index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>HTML5 Audio & Video</h1>
|
||||
</body>
|
||||
</html>
|
27
db/seeds/audio_video/index.html_spec.rb
Normal file
27
db/seeds/audio_video/index.html_spec.rb
Normal file
@ -0,0 +1,27 @@
|
||||
require 'rack/file'
|
||||
require 'capybara/rspec'
|
||||
|
||||
AUDIO_FILENAME = 'chai.ogg'
|
||||
VIDEO_FILENAME = 'devstories.mp4'
|
||||
|
||||
Capybara.app = Rack::File.new(File.dirname(__FILE__))
|
||||
|
||||
describe 'index.html', type: :feature do
|
||||
before(:each) { visit('index.html') }
|
||||
|
||||
it 'contains an audio element' do
|
||||
expect(page).to have_css('audio')
|
||||
end
|
||||
|
||||
it 'plays the correct audio file' do
|
||||
expect(page).to have_css("audio[src='#{AUDIO_FILENAME}']")
|
||||
end
|
||||
|
||||
it 'contains a video element' do
|
||||
expect(page).to have_css('video')
|
||||
end
|
||||
|
||||
it 'plays the correct video file' do
|
||||
expect(page).to have_css("video[src='#{VIDEO_FILENAME}']")
|
||||
end
|
||||
end
|
3
db/seeds/audio_video/index.js
Normal file
3
db/seeds/audio_video/index.js
Normal file
@ -0,0 +1,3 @@
|
||||
$(function() {
|
||||
//
|
||||
});
|
BIN
db/seeds/audio_video/poster.png
Normal file
BIN
db/seeds/audio_video/poster.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 140 KiB |
24
db/seeds/development.rb
Normal file
24
db/seeds/development.rb
Normal file
@ -0,0 +1,24 @@
|
||||
# consumers
|
||||
FactoryGirl.create(:consumer)
|
||||
FactoryGirl.create(:consumer, name: 'openSAP')
|
||||
|
||||
# users
|
||||
%w[admin external_user teacher].each { |factory_name| FactoryGirl.create(factory_name) }
|
||||
|
||||
# execution environments
|
||||
ExecutionEnvironment.create_factories
|
||||
|
||||
# errors
|
||||
Error.create_factories
|
||||
|
||||
# exercises
|
||||
@exercises = find_factories_by_class(Exercise).map(&:name).map { |factory_name| [factory_name, FactoryGirl.create(factory_name)] }.to_h
|
||||
|
||||
# file types
|
||||
FileType.create_factories
|
||||
|
||||
# hints
|
||||
Hint.create_factories
|
||||
|
||||
# submissions
|
||||
FactoryGirl.create(:submission, exercise: @exercises[:fibonacci])
|
5
db/seeds/even_odd/exercise.py
Normal file
5
db/seeds/even_odd/exercise.py
Normal file
@ -0,0 +1,5 @@
|
||||
def even(x):
|
||||
pass
|
||||
|
||||
def odd(x):
|
||||
pass
|
15
db/seeds/even_odd/exercise_tests.py
Normal file
15
db/seeds/even_odd/exercise_tests.py
Normal file
@ -0,0 +1,15 @@
|
||||
from exercise import *
|
||||
import unittest
|
||||
|
||||
class ExerciseTests(unittest.TestCase):
|
||||
def test_even(self):
|
||||
for x in [1, 3, 5, 7, 9]:
|
||||
self.assertFalse(even(x))
|
||||
for x in [2, 4, 6, 8, 10]:
|
||||
self.assertTrue(even(x))
|
||||
|
||||
def test_odd(self):
|
||||
for x in [1, 3, 5, 7, 9]:
|
||||
self.assertTrue(odd(x))
|
||||
for x in [2, 4, 6, 8, 10]:
|
||||
self.assertFalse(odd(x))
|
5
db/seeds/even_odd/reference.py
Normal file
5
db/seeds/even_odd/reference.py
Normal file
@ -0,0 +1,5 @@
|
||||
def even(x):
|
||||
return x % 2 == 0
|
||||
|
||||
def odd(x):
|
||||
return not even(x)
|
2
db/seeds/fibonacci/exercise.rb
Normal file
2
db/seeds/fibonacci/exercise.rb
Normal file
@ -0,0 +1,2 @@
|
||||
def fibonacci(n)
|
||||
end
|
15
db/seeds/fibonacci/exercise_spec_1.rb
Normal file
15
db/seeds/fibonacci/exercise_spec_1.rb
Normal file
@ -0,0 +1,15 @@
|
||||
require './exercise'
|
||||
|
||||
describe '#fibonacci' do
|
||||
it 'is defined' do
|
||||
expect { method(:fibonacci) }.not_to raise_error
|
||||
end
|
||||
|
||||
it 'has the correct arity' do
|
||||
expect(method(:fibonacci).arity).to eq(1)
|
||||
end
|
||||
|
||||
it 'returns a number' do
|
||||
expect(fibonacci(1)).to be_an(Integer)
|
||||
end
|
||||
end
|
9
db/seeds/fibonacci/exercise_spec_2.rb
Normal file
9
db/seeds/fibonacci/exercise_spec_2.rb
Normal file
@ -0,0 +1,9 @@
|
||||
require './exercise'
|
||||
|
||||
describe '#fibonacci' do
|
||||
it 'works recursively' do
|
||||
@n = 16
|
||||
expect(self).to receive(:fibonacci).and_call_original.at_least(@n ** 2).times
|
||||
fibonacci(@n)
|
||||
end
|
||||
end
|
16
db/seeds/fibonacci/exercise_spec_3.rb
Normal file
16
db/seeds/fibonacci/exercise_spec_3.rb
Normal file
@ -0,0 +1,16 @@
|
||||
require './exercise'
|
||||
require './reference'
|
||||
|
||||
describe '#fibonacci' do
|
||||
SAMPLE_COUNT = 32
|
||||
|
||||
let(:reference) { Class.new.extend(Reference) }
|
||||
|
||||
SAMPLE_COUNT.times do |i|
|
||||
instance_eval do
|
||||
it "obtains the correct result for input #{i}" do
|
||||
expect(fibonacci(i)).to eq(reference.fibonacci(i))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
5
db/seeds/fibonacci/reference.rb
Normal file
5
db/seeds/fibonacci/reference.rb
Normal file
@ -0,0 +1,5 @@
|
||||
module Reference
|
||||
def fibonacci(n)
|
||||
n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2)
|
||||
end
|
||||
end
|
2
db/seeds/files/data.txt
Normal file
2
db/seeds/files/data.txt
Normal file
@ -0,0 +1,2 @@
|
||||
Foo
|
||||
Bar
|
6
db/seeds/files/exercise.rb
Normal file
6
db/seeds/files/exercise.rb
Normal file
@ -0,0 +1,6 @@
|
||||
SOURCE_FILENAME = 'data.txt'
|
||||
TARGET_FILENAME = 'copy.txt'
|
||||
|
||||
def copy_file
|
||||
# Implement this method.
|
||||
end
|
21
db/seeds/files/exercise_spec.rb
Normal file
21
db/seeds/files/exercise_spec.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require './exercise'
|
||||
|
||||
describe '#write_to_file' do
|
||||
before(:each) do
|
||||
@file_content = File.new(SOURCE_FILENAME, 'r').read
|
||||
write_to_file
|
||||
end
|
||||
|
||||
it 'preserves the source file' do
|
||||
expect(File.exist?(SOURCE_FILENAME)).to be true
|
||||
expect(File.new(SOURCE_FILENAME, 'r').read).to eq(@file_content)
|
||||
end
|
||||
|
||||
it 'creates the target file' do
|
||||
expect(File.exist?(TARGET_FILENAME)).to be true
|
||||
end
|
||||
|
||||
it 'copies the file content' do
|
||||
expect(File.new(TARGET_FILENAME, 'r').read).to eq(@file_content)
|
||||
end
|
||||
end
|
11
db/seeds/geolocation/index.html
Normal file
11
db/seeds/geolocation/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
|
||||
<script src="index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>HTML5 Geolocation</h1>
|
||||
<button id="locate">Locate me</button>
|
||||
</body>
|
||||
</html>
|
3
db/seeds/geolocation/index.js
Normal file
3
db/seeds/geolocation/index.js
Normal file
@ -0,0 +1,3 @@
|
||||
$(function() {
|
||||
var button = $('#locate');
|
||||
});
|
0
db/seeds/hello_world/exercise.rb
Normal file
0
db/seeds/hello_world/exercise.rb
Normal file
6
db/seeds/hello_world/exercise_spec.rb
Normal file
6
db/seeds/hello_world/exercise_spec.rb
Normal file
@ -0,0 +1,6 @@
|
||||
describe 'Exercise' do
|
||||
it "outputs 'Hello World" do
|
||||
expect(STDOUT).to receive(:puts).with('Hello World')
|
||||
require './exercise'
|
||||
end
|
||||
end
|
7
db/seeds/math/Makefile
Normal file
7
db/seeds/math/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
run:
|
||||
javac org/example/RecursiveMath.java
|
||||
java org/example/RecursiveMath
|
||||
|
||||
test:
|
||||
javac -cp .:/usr/java/lib/hamcrest-core-1.3.jar:/usr/java/lib/junit-4.11.jar org/example/${FILENAME}
|
||||
java -cp .:/usr/java/lib/hamcrest-core-1.3.jar:/usr/java/lib/junit-4.11.jar org.junit.runner.JUnitCore org.example.${CLASS_NAME}
|
12
db/seeds/math/org/example/RecursiveMath.java
Normal file
12
db/seeds/math/org/example/RecursiveMath.java
Normal file
@ -0,0 +1,12 @@
|
||||
package org.example;
|
||||
|
||||
public class RecursiveMath {
|
||||
|
||||
public static void main(String[] args) {
|
||||
//
|
||||
}
|
||||
|
||||
public static double power(int base, int exponent) {
|
||||
return 42;
|
||||
}
|
||||
}
|
26
db/seeds/math/org/example/RecursiveMathTest1.java
Normal file
26
db/seeds/math/org/example/RecursiveMathTest1.java
Normal file
@ -0,0 +1,26 @@
|
||||
package org.example;
|
||||
|
||||
import java.lang.Math.*;
|
||||
import org.example.RecursiveMath;
|
||||
import org.junit.*;
|
||||
|
||||
public class RecursiveMathTest1 {
|
||||
|
||||
@Test
|
||||
public void methodIsDefined() {
|
||||
boolean methodIsDefined = false;
|
||||
try {
|
||||
RecursiveMath.power(1, 1);
|
||||
methodIsDefined = true;
|
||||
} catch (NoSuchMethodError error) {
|
||||
//
|
||||
}
|
||||
org.junit.Assert.assertTrue("RecursiveMath does not define 'power'.", methodIsDefined);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodReturnsDouble() {
|
||||
Object result = RecursiveMath.power(1, 1);
|
||||
org.junit.Assert.assertTrue("Your method has the wrong return type.", result instanceof Double);
|
||||
}
|
||||
}
|
23
db/seeds/math/org/example/RecursiveMathTest2.java
Normal file
23
db/seeds/math/org/example/RecursiveMathTest2.java
Normal file
@ -0,0 +1,23 @@
|
||||
package org.example;
|
||||
|
||||
import java.lang.Math.*;
|
||||
import org.example.RecursiveMath;
|
||||
import org.junit.*;
|
||||
|
||||
public class RecursiveMathTest2 {
|
||||
|
||||
@Test
|
||||
public void exponentZero() {
|
||||
org.junit.Assert.assertEquals("Incorrect result for exponent 0.", 1, RecursiveMath.power(42, 0), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void negativeExponent() {
|
||||
org.junit.Assert.assertEquals("Incorrect result for exponent -1.", Math.pow(2, -1), RecursiveMath.power(2, -1), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void positiveExponent() {
|
||||
org.junit.Assert.assertEquals("Incorrect result for exponent 4.", Math.pow(2, 4), RecursiveMath.power(2, 4), 0);
|
||||
}
|
||||
}
|
9
db/seeds/primes/exercise.js
Normal file
9
db/seeds/primes/exercise.js
Normal file
@ -0,0 +1,9 @@
|
||||
var isPrime = function(number) {
|
||||
return true;
|
||||
};
|
||||
|
||||
var printPrimes = function(count) {
|
||||
|
||||
};
|
||||
|
||||
printPrimes();
|
37
db/seeds/production.rb
Normal file
37
db/seeds/production.rb
Normal file
@ -0,0 +1,37 @@
|
||||
require 'highline/import'
|
||||
|
||||
# consumers
|
||||
FactoryGirl.create(:consumer)
|
||||
|
||||
# users
|
||||
email = ask('Enter admin email: ')
|
||||
|
||||
passwords = ['password', 'password confirmation'].map do |attribute|
|
||||
ask("Enter admin #{attribute}: ") { |question| question.echo = false }
|
||||
end
|
||||
|
||||
if passwords.uniq.length == 1
|
||||
FactoryGirl.create(:admin, email: email, name: 'Administrator', password: passwords.first)
|
||||
else
|
||||
abort('Passwords do not match!')
|
||||
end
|
||||
|
||||
# execution environments
|
||||
ExecutionEnvironment.create_factories
|
||||
|
||||
# exercises
|
||||
Exercise.create_factories
|
||||
|
||||
# file types
|
||||
FileType.create_factories
|
||||
|
||||
# hints
|
||||
Hint.create_factories
|
||||
|
||||
# change all resources' author
|
||||
[ExecutionEnvironment, Exercise, FileType].each do |model|
|
||||
model.update_all(user_id: InternalUser.first.id)
|
||||
end
|
||||
|
||||
# delete temporary users
|
||||
InternalUser.where.not(id: InternalUser.first.id).delete_all
|
12
db/seeds/sql_select/comparator.rb
Normal file
12
db/seeds/sql_select/comparator.rb
Normal file
@ -0,0 +1,12 @@
|
||||
require 'sqlite3'
|
||||
|
||||
REFERENCE_QUERY = File.new('reference.sql', 'r').read
|
||||
STUDENT_QUERY = File.new('exercise.sql', 'r').read
|
||||
|
||||
database = SQLite3::Database.new('/database.db')
|
||||
|
||||
missing_tuples = database.execute(REFERENCE_QUERY) - database.execute(STUDENT_QUERY)
|
||||
unexpected_tuples = database.execute(STUDENT_QUERY) - database.execute(REFERENCE_QUERY)
|
||||
|
||||
puts("Missing tuples: #{missing_tuples}")
|
||||
puts("Unexpected tuples: #{unexpected_tuples}")
|
0
db/seeds/sql_select/exercise.sql
Normal file
0
db/seeds/sql_select/exercise.sql
Normal file
1
db/seeds/sql_select/reference.sql
Normal file
1
db/seeds/sql_select/reference.sql
Normal file
@ -0,0 +1 @@
|
||||
SELECT * FROM people WHERE name LIKE '% Doe';
|
0
db/seeds/tdd/exercise.rb
Normal file
0
db/seeds/tdd/exercise.rb
Normal file
5
db/seeds/tdd/exercise_spec.rb
Normal file
5
db/seeds/tdd/exercise_spec.rb
Normal file
@ -0,0 +1,5 @@
|
||||
describe 'Exercise' do
|
||||
it 'includes a successful example' do
|
||||
expect(true).to be true
|
||||
end
|
||||
end
|
11
db/seeds/tdd/instructions.md
Normal file
11
db/seeds/tdd/instructions.md
Normal file
@ -0,0 +1,11 @@
|
||||
Write a method `palindrome?` that outputs whether a given input is a palindromic word.
|
||||
|
||||
Write tests to verify that your method works correctly for normal words, empty inputs, and malformed inputs.
|
||||
|
||||
#### Expected Behavior:
|
||||
|
||||
`palindrome?('noon') => true`
|
||||
|
||||
`palindrome?('hello') => false`
|
||||
|
||||
`palindrome?(42) => false`
|
7
db/seeds/web_app/app.rb
Normal file
7
db/seeds/web_app/app.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'sinatra'
|
||||
|
||||
set :bind, '0.0.0.0'
|
||||
|
||||
get '/' do
|
||||
'Hello, World!'
|
||||
end
|
Reference in New Issue
Block a user