From 27bdeb2aa85647694b9f43684e01c95d32a8de23 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Wed, 17 Apr 2019 12:17:18 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=AE=9E=E8=AE=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_choose_shixuns.html.erb | 1 + .../_new_shixun_exercise_list.html.erb | 20 +++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/views/exercise/_choose_shixuns.html.erb b/app/views/exercise/_choose_shixuns.html.erb index dba67253..2be172ef 100644 --- a/app/views/exercise/_choose_shixuns.html.erb +++ b/app/views/exercise/_choose_shixuns.html.erb @@ -3,6 +3,7 @@
<%= labelled_form_for @exercise, :url =>{:controller=> 'exercise', :action => 'choose_shixuns', :id => @exercise.id, :is_search => 1}, :html => {:id => 'shixun_search_form'}, :method => "get", :remote => true do |f| %>
+ 试卷仅支持只有1个关卡的实训题
diff --git a/app/views/exercise/_new_shixun_exercise_list.html.erb b/app/views/exercise/_new_shixun_exercise_list.html.erb index 74be515d..ebce9560 100644 --- a/app/views/exercise/_new_shixun_exercise_list.html.erb +++ b/app/views/exercise/_new_shixun_exercise_list.html.erb @@ -11,7 +11,7 @@ <% @shixuns.each do |shixun| %> - + <%= link_to shixun.name, shixun_path(shixun), :class => "edu-info-dark task-hide mt3 ml20",:style=> "text-align:left", :target => "_blank" %> @@ -22,16 +22,16 @@
-

请至少选择一个实训

-
-
+

请至少选择一个实训

+
+ -
-
    - <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %> -
-
-
+ + + + + +
\ No newline at end of file From 148356275fd5f86875caea679932dcdc8ebe3a69 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 17 Apr 2019 15:47:47 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E7=89=88=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=80=83=E8=AF=95=E6=A8=A1=E5=BC=8F=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=88=E5=A2=9E=E5=88=A0=E6=94=B9=E6=9F=A5?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javascripts/local_settings.js.coffee | 3 + .../stylesheets/local_settings.css.scss | 3 + app/controllers/local_settings_controller.rb | 84 +++++++++ app/helpers/local_settings_helper.rb | 2 + app/models/local_setting.rb | 3 + app/views/local_settings/_form.html.erb | 21 +++ app/views/local_settings/edit.html.erb | 9 + app/views/local_settings/index.html.erb | 26 +++ app/views/local_settings/new.html.erb | 8 + app/views/local_settings/show.html.erb | 12 ++ config/routes.rb | 1 + .../20190417072148_create_local_settings.rb | 9 + .../local_settings_controller_spec.rb | 159 ++++++++++++++++++ spec/factories/local_settings.rb | 6 + spec/models/local_setting_spec.rb | 5 + 15 files changed, 351 insertions(+) create mode 100644 app/assets/javascripts/local_settings.js.coffee create mode 100644 app/assets/stylesheets/local_settings.css.scss create mode 100644 app/controllers/local_settings_controller.rb create mode 100644 app/helpers/local_settings_helper.rb create mode 100644 app/models/local_setting.rb create mode 100644 app/views/local_settings/_form.html.erb create mode 100644 app/views/local_settings/edit.html.erb create mode 100644 app/views/local_settings/index.html.erb create mode 100644 app/views/local_settings/new.html.erb create mode 100644 app/views/local_settings/show.html.erb create mode 100644 db/migrate/20190417072148_create_local_settings.rb create mode 100644 spec/controllers/local_settings_controller_spec.rb create mode 100644 spec/factories/local_settings.rb create mode 100644 spec/models/local_setting_spec.rb 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| %> + + + + + + + <% end %> +
考试模式
<%= 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?' } %>
+ +
+ + <%= 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 From d88139c12d7e61dd79bf7c2afb2cc236759617c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Wed, 17 Apr 2019 15:57:14 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=BC=B9=E6=A1=86=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E5=8A=A0=E8=BD=BD=EF=BC=8C=E2=80=9C=E5=AE=9E?= =?UTF-8?q?=E8=AE=AD=E9=A2=98=E2=80=9D=E7=BC=96=E8=BE=91=E5=9D=97=E7=9A=84?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_edit_shixun.html.erb | 117 +++++++++++++----- app/views/exercise/_new_shixun.html.erb | 81 +++++++----- .../_new_shixun_exercise_list.html.erb | 41 ++++-- public/stylesheets/educoder/edu-main.css | 58 ++++++++- 4 files changed, 222 insertions(+), 75 deletions(-) diff --git a/app/views/exercise/_edit_shixun.html.erb b/app/views/exercise/_edit_shixun.html.erb index 4d60a41c..1e8fb088 100644 --- a/app/views/exercise/_edit_shixun.html.erb +++ b/app/views/exercise/_edit_shixun.html.erb @@ -1,35 +1,86 @@ <%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:html => {:id => "update_exercise_question_#{exercise_question.id}"}) do |f|%> -
-

实训题

-

<%= exercise_question.shixun.name %>

-
  • - - - -
  • -
  • - - 关卡名称 - 分值 -
  • - <% exercise_question.exercise_shixun_challenges.each_with_index do |exercise_challenge,index| %> -
  • - - <%= exercise_challenge.challenge.subject %> - - -
  • -
    - <% end %> - -
  • -

    - 温馨提示:[实训题]属于客观题将由系统自动评分 - 保存 - 取消 -

    -
  • -
    + + + + + + + + + + + + + + <%# exercise_question.exercise_shixun_challenges.each_with_index do |exercise_challenge,index| %> + + + + + + + + + + <%# end %> + + + + + + + + + + + + <% end %> + +
    + +
    实训题
    + +
    + + 初级题 + +
    + *分值: 分/题 +
    *大于等于0,且不能大于100
    +
    + +
    + * + 随机出题量: 题 +
    *不能为空
    +
    *必须为正整数
    +
    *不能大于可用题数
    +
    + +
    + 3 + 题可用 +
    + +
    + +
    + + 中级题 + +
    + +
    + + 高级题 + +
    + +
    + + 顶级题 + +
    + +
    \ No newline at end of file diff --git a/app/views/exercise/_new_shixun.html.erb b/app/views/exercise/_new_shixun.html.erb index 1cff068f..389a4b67 100644 --- a/app/views/exercise/_new_shixun.html.erb +++ b/app/views/exercise/_new_shixun.html.erb @@ -3,40 +3,55 @@ <%= form_for(ExerciseQuestion.new, :html => { :multipart => true, :id => "new_exercise_question"}, :url=>create_exercise_question_exercise_path(exercise.id)) do |f| %> -
    -

    实训题

    - - - -

    <%= @shixun.name %>

    -
  • - - -
  • -
  • - - 关卡名称 - 分值 -
  • - <% @shixun.challenges.each_with_index do |challenge, i| %> -
  • - - <%= challenge.subject %> - - -
  • - <% end %> -
  • -

    - 温馨提示:[实训题]属于客观题将由系统自动评分 - 保存 - 取消 -

    -
  • -
    + + + + + + + + + + + + + + + + <%# @shixun.challenges.each_with_index do |challenge, i| %> + + + + + + + + + <%# end %> + + + + + + + + <% end %> + + +
    + +

    实训题

    + +

    + + +

    + +
    + + +
    <% end %> \ No newline at end of file diff --git a/public/stylesheets/educoder/edu-main.css b/public/stylesheets/educoder/edu-main.css index dac31425..583e4a15 100644 --- a/public/stylesheets/educoder/edu-main.css +++ b/public/stylesheets/educoder/edu-main.css @@ -149,7 +149,8 @@ a.decoration{text-decoration: underline} .padding20-15{padding: 20px 15px;box-sizing: border-box} .padding20-10{padding: 20px 10px;box-sizing: border-box} .padding20-25{padding: 20px 25px;box-sizing: border-box} - +.padding10{padding: 10px;box-sizing: border-box} +.padding20{padding: 20px;box-sizing: border-box} .padding30{padding: 30px;box-sizing: border-box} .padding30-20{padding: 30px 20px;box-sizing: border-box} .padding30-40{padding: 30px 40px;box-sizing: border-box} @@ -883,3 +884,58 @@ html>body #ajax-indicator { position: fixed; } margin-top: 60px; margin-left: -26px; } +.selecshixun{ + overflow-y: scroll; +} + +.practicalTemp{ + width:1200px; + height:950px; + background:rgba(255,255,255,1); + border:1px solid rgba(238,238,238,1); +} + +.practicalTitlefont{ + font-size:18px; + font-family:MicrosoftYaHei; + font-weight:400; + color:rgba(102,102,102,1); + width: 1200px; + height: 60px; + line-height: 25px; + padding-left: 10px; + border-bottom: 1px solid rgba(238,238,238,1); +} + +.practicalTitle{ + width: 1160px; + padding: 20px; + border-bottom:1px solid rgba(238,238,238,1); +} + +.Titlefont{ + width: 48px; + height: 30px; + font-size: 15px; + font-family: MicrosoftYaHei; + font-weight: 400; + color: rgba(5,16,26,1); +} +.shixun-title-font{ + font-size:16px; + font-family:MicrosoftYaHei; + font-weight:400; + color:#828282; +} + +.colorFF8121{ + color: #FF8121; + font-size: 12px; + text-align: left; + width: 110px; + margin-left: 117px; +} + +.borderFF8121{ + border:1px solid #FF8121 +} \ No newline at end of file