From 9c36affeec50cb22012c38e54189686399850f20 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 6 Sep 2017 14:42:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E9=80=89=E5=A4=9A=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 18 +- app/views/challenges/_choose_type.html.erb | 54 ++- .../_single_or_multiple_question.html.erb | 420 +++++++++--------- app/views/challenges/_task_pass_form.html.erb | 42 +- .../challenges/add_choose_question.js.erb | 1 + app/views/challenges/edit.html.erb | 2 +- config/routes.rb | 2 + 7 files changed, 304 insertions(+), 235 deletions(-) create mode 100644 app/views/challenges/add_choose_question.js.erb diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 834e6b302..7bbef79a1 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -2,8 +2,8 @@ class ChallengesController < ApplicationController layout "base_shixun" before_filter :check_authentication - before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build, :update_evaluation] - before_filter :find_challenge, :only => [:show, :edit, :update, :challenge_build, :index_up, :index_down, :destroy, :update_evaluation] + before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build, :update_evaluation, :add_choose_question, :new_or_edit_choose_question] + before_filter :find_challenge, :only => [:show, :edit, :update, :challenge_build, :index_up, :index_down, :destroy, :update_evaluation, :add_choose_question, :new_or_edit_choose_question] before_filter :build_challege_from_params, :only => [:new, :create] before_filter :tpi_manager_allowed, :only => [:challenge_build, :destroy, :edit, :new, :create] before_filter :allowed_view, :only => [:show] @@ -103,6 +103,20 @@ class ChallengesController < ApplicationController end end + def new_or_edit_choose_question + + respond_to do |format| + format.js + end + end + + def add_choose_question + @type = params[:type].to_i + respond_to do |format| + format.js + end + end + def destroy next_challenges = @shixun.challenges.where("position > #{@challenge.position}") next_challenges.update_all("position = position - 1") diff --git a/app/views/challenges/_choose_type.html.erb b/app/views/challenges/_choose_type.html.erb index 5590def69..a4e320270 100644 --- a/app/views/challenges/_choose_type.html.erb +++ b/app/views/challenges/_choose_type.html.erb @@ -35,7 +35,7 @@
+
-