diff --git a/app/assets/javascripts/local_settings.js.coffee b/app/assets/javascripts/local_settings.js.coffee
new file mode 100644
index 00000000..76156794
--- /dev/null
+++ b/app/assets/javascripts/local_settings.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
diff --git a/app/assets/stylesheets/local_settings.css.scss b/app/assets/stylesheets/local_settings.css.scss
new file mode 100644
index 00000000..4cad8d64
--- /dev/null
+++ b/app/assets/stylesheets/local_settings.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the local_settings controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/local_settings_controller.rb b/app/controllers/local_settings_controller.rb
new file mode 100644
index 00000000..b5f117d2
--- /dev/null
+++ b/app/controllers/local_settings_controller.rb
@@ -0,0 +1,84 @@
+class LocalSettingsController < ApplicationController
+ layout 'educoder'
+ # GET /local_settings
+ # GET /local_settings.json
+ def index
+ @local_settings = LocalSetting.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @local_settings }
+ end
+ end
+
+ # GET /local_settings/1
+ # GET /local_settings/1.json
+ def show
+ @local_setting = LocalSetting.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @local_setting }
+ end
+ end
+
+ # GET /local_settings/new
+ # GET /local_settings/new.json
+ def new
+ @local_setting = LocalSetting.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @local_setting }
+ end
+ end
+
+ # GET /local_settings/1/edit
+ def edit
+ @local_setting = LocalSetting.find(params[:id])
+ end
+
+ # POST /local_settings
+ # POST /local_settings.json
+ def create
+ @local_setting = LocalSetting.new(params[:local_setting])
+
+ respond_to do |format|
+ if @local_setting.save
+ format.html { redirect_to @local_setting, notice: 'Local setting was successfully created.' }
+ format.json { render json: @local_setting, status: :created, location: @local_setting }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @local_setting.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /local_settings/1
+ # PUT /local_settings/1.json
+ def update
+ @local_setting = LocalSetting.find(params[:id])
+
+ respond_to do |format|
+ if @local_setting.update_attributes(params[:local_setting])
+ format.html { redirect_to @local_setting, notice: 'Local setting was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @local_setting.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /local_settings/1
+ # DELETE /local_settings/1.json
+ def destroy
+ @local_setting = LocalSetting.find(params[:id])
+ @local_setting.destroy
+
+ respond_to do |format|
+ format.html { redirect_to local_settings_url }
+ format.json { head :no_content }
+ end
+ end
+end
diff --git a/app/helpers/local_settings_helper.rb b/app/helpers/local_settings_helper.rb
new file mode 100644
index 00000000..a8d7c654
--- /dev/null
+++ b/app/helpers/local_settings_helper.rb
@@ -0,0 +1,2 @@
+module LocalSettingsHelper
+end
diff --git a/app/models/local_setting.rb b/app/models/local_setting.rb
new file mode 100644
index 00000000..fd675fc0
--- /dev/null
+++ b/app/models/local_setting.rb
@@ -0,0 +1,3 @@
+class LocalSetting < ActiveRecord::Base
+ attr_accessible :exam
+end
diff --git a/app/views/local_settings/_form.html.erb b/app/views/local_settings/_form.html.erb
new file mode 100644
index 00000000..2747b721
--- /dev/null
+++ b/app/views/local_settings/_form.html.erb
@@ -0,0 +1,21 @@
+<%= form_for(@local_setting) do |f| %>
+ <% if @local_setting.errors.any? %>
+
+
<%= pluralize(@local_setting.errors.count, "error") %> prohibited this local_setting from being saved:
+
+
+ <% @local_setting.errors.full_messages.each do |msg| %>
+ - <%= msg %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= f.label :考试模式 %>
+ <%= f.check_box :exam %>
+
+
+ <%= f.submit %>
+
+<% end %>
diff --git a/app/views/local_settings/edit.html.erb b/app/views/local_settings/edit.html.erb
new file mode 100644
index 00000000..f6004433
--- /dev/null
+++ b/app/views/local_settings/edit.html.erb
@@ -0,0 +1,9 @@
+
+
编辑配置参数
+
+ <%= render 'form' %>
+
+ <%= link_to '详情', @local_setting %> |
+ <%= link_to 'Back', local_settings_path %>
+
+
diff --git a/app/views/local_settings/index.html.erb b/app/views/local_settings/index.html.erb
new file mode 100644
index 00000000..7eb5dc39
--- /dev/null
+++ b/app/views/local_settings/index.html.erb
@@ -0,0 +1,26 @@
+
+
本地配置
+
+
+
+ 考试模式 |
+ |
+ |
+ |
+
+
+ <% @local_settings.each do |local_setting| %>
+
+ <%= local_setting.exam %> |
+ <%= link_to '显示', local_setting %> |
+ <%= link_to '编辑', edit_local_setting_path(local_setting) %> |
+ <%= link_to '删除', local_setting, method: :delete, data: { confirm: 'Are you sure?' } %> |
+
+ <% end %>
+
+
+
+
+ <%= link_to '新增配置', new_local_setting_path %>
+
+
diff --git a/app/views/local_settings/new.html.erb b/app/views/local_settings/new.html.erb
new file mode 100644
index 00000000..47975217
--- /dev/null
+++ b/app/views/local_settings/new.html.erb
@@ -0,0 +1,8 @@
+
+
新建配置参数
+
+ <%= render 'form' %>
+
+ <%= link_to 'Back', local_settings_path %>
+
+
diff --git a/app/views/local_settings/show.html.erb b/app/views/local_settings/show.html.erb
new file mode 100644
index 00000000..a6a4802a
--- /dev/null
+++ b/app/views/local_settings/show.html.erb
@@ -0,0 +1,12 @@
+
+
<%= notice %>
+
+
+ 考试模式:
+ <%= @local_setting.exam %>
+
+
+
+ <%= link_to '编辑', edit_local_setting_path(@local_setting) %> |
+ <%= link_to 'Back', local_settings_path %>
+
diff --git a/config/routes.rb b/config/routes.rb
index 47a052db..65ab3d15 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -39,6 +39,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
post 'ecloud/ps_new', to: 'ecloud#ps_new'
post 'ecloud/ps_update', to: 'ecloud#ps_update'
+ resources :local_settings
resources :cooperates do
member do
diff --git a/db/migrate/20190417072148_create_local_settings.rb b/db/migrate/20190417072148_create_local_settings.rb
new file mode 100644
index 00000000..47ca8577
--- /dev/null
+++ b/db/migrate/20190417072148_create_local_settings.rb
@@ -0,0 +1,9 @@
+class CreateLocalSettings < ActiveRecord::Migration
+ def change
+ create_table :local_settings do |t|
+ t.boolean :exam
+
+ t.timestamps
+ end
+ end
+end
diff --git a/spec/controllers/local_settings_controller_spec.rb b/spec/controllers/local_settings_controller_spec.rb
new file mode 100644
index 00000000..3336e3f4
--- /dev/null
+++ b/spec/controllers/local_settings_controller_spec.rb
@@ -0,0 +1,159 @@
+require 'rails_helper'
+
+# This spec was generated by rspec-rails when you ran the scaffold generator.
+# It demonstrates how one might use RSpec to specify the controller code that
+# was generated by Rails when you ran the scaffold generator.
+#
+# It assumes that the implementation code is generated by the rails scaffold
+# generator. If you are using any extension libraries to generate different
+# controller code, this generated spec may or may not pass.
+#
+# It only uses APIs available in rails and/or rspec-rails. There are a number
+# of tools you can use to make these specs even more expressive, but we're
+# sticking to rails and rspec-rails APIs to keep things simple and stable.
+#
+# Compared to earlier versions of this generator, there is very limited use of
+# stubs and message expectations in this spec. Stubs are only used when there
+# is no simpler way to get a handle on the object needed for the example.
+# Message expectations are only used when there is no simpler way to specify
+# that an instance is receiving a specific message.
+
+RSpec.describe LocalSettingsController, :type => :controller do
+
+ # This should return the minimal set of attributes required to create a valid
+ # LocalSetting. As you add validations to LocalSetting, be sure to
+ # adjust the attributes here as well.
+ let(:valid_attributes) {
+ skip("Add a hash of attributes valid for your model")
+ }
+
+ let(:invalid_attributes) {
+ skip("Add a hash of attributes invalid for your model")
+ }
+
+ # This should return the minimal set of values that should be in the session
+ # in order to pass any filters (e.g. authentication) defined in
+ # LocalSettingsController. Be sure to keep this updated too.
+ let(:valid_session) { {} }
+
+ describe "GET #index" do
+ it "assigns all local_settings as @local_settings" do
+ local_setting = LocalSetting.create! valid_attributes
+ get :index, {}, valid_session
+ expect(assigns(:local_settings)).to eq([local_setting])
+ end
+ end
+
+ describe "GET #show" do
+ it "assigns the requested local_setting as @local_setting" do
+ local_setting = LocalSetting.create! valid_attributes
+ get :show, {:id => local_setting.to_param}, valid_session
+ expect(assigns(:local_setting)).to eq(local_setting)
+ end
+ end
+
+ describe "GET #new" do
+ it "assigns a new local_setting as @local_setting" do
+ get :new, {}, valid_session
+ expect(assigns(:local_setting)).to be_a_new(LocalSetting)
+ end
+ end
+
+ describe "GET #edit" do
+ it "assigns the requested local_setting as @local_setting" do
+ local_setting = LocalSetting.create! valid_attributes
+ get :edit, {:id => local_setting.to_param}, valid_session
+ expect(assigns(:local_setting)).to eq(local_setting)
+ end
+ end
+
+ describe "POST #create" do
+ context "with valid params" do
+ it "creates a new LocalSetting" do
+ expect {
+ post :create, {:local_setting => valid_attributes}, valid_session
+ }.to change(LocalSetting, :count).by(1)
+ end
+
+ it "assigns a newly created local_setting as @local_setting" do
+ post :create, {:local_setting => valid_attributes}, valid_session
+ expect(assigns(:local_setting)).to be_a(LocalSetting)
+ expect(assigns(:local_setting)).to be_persisted
+ end
+
+ it "redirects to the created local_setting" do
+ post :create, {:local_setting => valid_attributes}, valid_session
+ expect(response).to redirect_to(LocalSetting.last)
+ end
+ end
+
+ context "with invalid params" do
+ it "assigns a newly created but unsaved local_setting as @local_setting" do
+ post :create, {:local_setting => invalid_attributes}, valid_session
+ expect(assigns(:local_setting)).to be_a_new(LocalSetting)
+ end
+
+ it "re-renders the 'new' template" do
+ post :create, {:local_setting => invalid_attributes}, valid_session
+ expect(response).to render_template("new")
+ end
+ end
+ end
+
+ describe "PUT #update" do
+ context "with valid params" do
+ let(:new_attributes) {
+ skip("Add a hash of attributes valid for your model")
+ }
+
+ it "updates the requested local_setting" do
+ local_setting = LocalSetting.create! valid_attributes
+ put :update, {:id => local_setting.to_param, :local_setting => new_attributes}, valid_session
+ local_setting.reload
+ skip("Add assertions for updated state")
+ end
+
+ it "assigns the requested local_setting as @local_setting" do
+ local_setting = LocalSetting.create! valid_attributes
+ put :update, {:id => local_setting.to_param, :local_setting => valid_attributes}, valid_session
+ expect(assigns(:local_setting)).to eq(local_setting)
+ end
+
+ it "redirects to the local_setting" do
+ local_setting = LocalSetting.create! valid_attributes
+ put :update, {:id => local_setting.to_param, :local_setting => valid_attributes}, valid_session
+ expect(response).to redirect_to(local_setting)
+ end
+ end
+
+ context "with invalid params" do
+ it "assigns the local_setting as @local_setting" do
+ local_setting = LocalSetting.create! valid_attributes
+ put :update, {:id => local_setting.to_param, :local_setting => invalid_attributes}, valid_session
+ expect(assigns(:local_setting)).to eq(local_setting)
+ end
+
+ it "re-renders the 'edit' template" do
+ local_setting = LocalSetting.create! valid_attributes
+ put :update, {:id => local_setting.to_param, :local_setting => invalid_attributes}, valid_session
+ expect(response).to render_template("edit")
+ end
+ end
+ end
+
+ describe "DELETE #destroy" do
+ it "destroys the requested local_setting" do
+ local_setting = LocalSetting.create! valid_attributes
+ expect {
+ delete :destroy, {:id => local_setting.to_param}, valid_session
+ }.to change(LocalSetting, :count).by(-1)
+ end
+
+ it "redirects to the local_settings list" do
+ local_setting = LocalSetting.create! valid_attributes
+ delete :destroy, {:id => local_setting.to_param}, valid_session
+ expect(response).to redirect_to(local_settings_url)
+ end
+ end
+
+end
diff --git a/spec/factories/local_settings.rb b/spec/factories/local_settings.rb
new file mode 100644
index 00000000..cbedf040
--- /dev/null
+++ b/spec/factories/local_settings.rb
@@ -0,0 +1,6 @@
+FactoryGirl.define do
+ factory :local_setting do
+ exam false
+ end
+
+end
diff --git a/spec/models/local_setting_spec.rb b/spec/models/local_setting_spec.rb
new file mode 100644
index 00000000..c5e71eac
--- /dev/null
+++ b/spec/models/local_setting_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe LocalSetting, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end