From 20c160f03f5c633d45dd8c6363f27580ebbb21b8 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 15 Jan 2015 10:50:08 +0800 Subject: [PATCH 01/13] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E6=A0=87?= =?UTF-8?q?=E9=A2=98=E5=A4=B4=E3=80=81=E5=8F=96=E6=B6=88=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E5=A4=B4=E6=95=B0=E6=8D=AE=E7=9A=84=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E5=92=8C=E9=A1=B5=E9=9D=A2=E7=9A=84=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_controller.rb | 8 ++++--- app/views/poll/_edit_head.html.erb | 36 +++++++++++++----------------- app/views/poll/_poll_form.html.erb | 10 ++++++++- app/views/poll/_show_head.html.erb | 12 +++++----- app/views/poll/update.js.erb | 1 + config/locales/zh.yml | 2 ++ 6 files changed, 39 insertions(+), 30 deletions(-) create mode 100644 app/views/poll/update.js.erb diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 52b4d8997..196b3c7ba 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -60,12 +60,14 @@ class PollController < ApplicationController end def update - @poll.polls_name = params[:polls_name] + @poll.polls_name = params[:polls_name].empty? ? l(:label_poll_title) : params[:polls_name] + @poll.polls_description = params[:polls_description].empty? ? l(:label_poll_description) : params[:polls_description] if @poll.save respond_to do |format| - format.html { redirect_to poll_index_url(:polls_type => @course.class.to_s, :polls_group_id => @course.id) } + format.js end else + render_404 end end @@ -98,7 +100,7 @@ class PollController < ApplicationController answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] question_option = { :answer_position => i, - :answer_text => params[:question_answer].values[i-1] + :answer_text => answer } @poll_questions.poll_answers.new question_option end diff --git a/app/views/poll/_edit_head.html.erb b/app/views/poll/_edit_head.html.erb index 759fe58a1..7662c12e0 100644 --- a/app/views/poll/_edit_head.html.erb +++ b/app/views/poll/_edit_head.html.erb @@ -1,21 +1,15 @@ - -
描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述 - 描述描述描述描述描述描述描述描述描述描述描述描述 -
+ \ No newline at end of file diff --git a/app/views/poll/update.js.erb b/app/views/poll/update.js.erb new file mode 100644 index 000000000..e83b1b9f0 --- /dev/null +++ b/app/views/poll/update.js.erb @@ -0,0 +1 @@ +$("#polls_head").html("<%= escape_javascript(render :partial => 'show_head', :locals => {:poll => @poll}) %>"); \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 9dae54818..95ab07d5d 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2251,5 +2251,7 @@ zh: label_mulit: 多行文字 label_enter_single_title: 请输入单选题标题 label_new_answer: 新建选项 + label_poll_title: 问卷标题 + label_poll_description: 问卷描述 From 496ef94b97ac7073ec46159c9653ea96284165f1 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 15 Jan 2015 11:05:19 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=A4=B4=E9=A1=B5=E9=9D=A2js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/poll/_poll_form.html.erb | 9 +++------ app/views/poll/_show_head.html.erb | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/views/poll/_poll_form.html.erb b/app/views/poll/_poll_form.html.erb index 474f3be29..f32eabe8f 100644 --- a/app/views/poll/_poll_form.html.erb +++ b/app/views/poll/_poll_form.html.erb @@ -11,10 +11,8 @@ function add_single(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_single') %>");} function add_mulit(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_mulit') %>");} //问卷头 - function pollsCancel() - { - $("#polls_head").html("<%= escape_javascript(render :partial => 'show_head', :locals => {:poll => @poll}) %>"); - } + function pollsCancel(){$("#polls_head").html("<%= escape_javascript(render :partial => 'show_head', :locals => {:poll => @poll}) %>");} + function pollsEdit(){$("#polls_head").html("<%= escape_javascript(render :partial => 'edit_head', :locals => {:poll => @poll}) %>");} //单选题 function add_single_answer(doc) { @@ -66,8 +64,7 @@+
<%= @poll.polls_description%>
diff --git a/app/views/poll/update.js.erb b/app/views/poll/update.js.erb index e83b1b9f0..15d0fabd5 100644 --- a/app/views/poll/update.js.erb +++ b/app/views/poll/update.js.erb @@ -1 +1,6 @@ -$("#polls_head").html("<%= escape_javascript(render :partial => 'show_head', :locals => {:poll => @poll}) %>"); \ No newline at end of file +$("#polls_title").val("<%= @poll.polls_name%>"); +$("#polls_description").val("<%= @poll.polls_description %>"); +$("#polls_name_h").html("<%= @poll.polls_name %>"); +$("#polls_description_p").html("<%= @poll.polls_description %>"); +$("#polls_head_edit").hide(); +$("#polls_head_show").show(); \ No newline at end of file From a99d7c514537762d25c6a04de1db310f5fed39e8 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 15 Jan 2015 14:40:17 +0800 Subject: [PATCH 05/13] =?UTF-8?q?1=E3=80=81=E5=88=86=E7=A6=BB=E5=87=BA?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E9=97=AE=E5=8D=B7=E9=97=AE=E9=A2=98=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=202=E3=80=81=E5=A2=9E=E5=8A=A0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E7=9B=B8=E5=85=B3=E8=B7=AF=E7=94=B1=E5=8F=8A?= =?UTF-8?q?action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_controller.rb | 7 ++++- app/views/poll/_edit_MC.html.erb | 38 +++++++++--------------- app/views/poll/_new_MC.html.erb | 45 +++++++++++++++++++++++++++++ app/views/poll/_new_MCQ.html.erb | 33 +++++++++++++++++++++ app/views/poll/_new_mulit.html.erb | 18 ++++++++++++ app/views/poll/_new_single.html.erb | 13 +++++++++ app/views/poll/_poll_form.html.erb | 19 +++++++----- config/routes.rb | 1 + 8 files changed, 140 insertions(+), 34 deletions(-) create mode 100644 app/views/poll/_new_MC.html.erb create mode 100644 app/views/poll/_new_MCQ.html.erb create mode 100644 app/views/poll/_new_mulit.html.erb create mode 100644 app/views/poll/_new_single.html.erb diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 196b3c7ba..a63f9e8f6 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -89,7 +89,7 @@ class PollController < ApplicationController def create_poll_question question_title = params[:poll_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title] option = { - :is_necessary => params[:is_necessary] || true, + :is_necessary => params[:is_necessary] || 1, :question_title => question_title, :question_type => params[:question_type] || 1, :question_number => @poll.poll_questions.count + 1 @@ -112,6 +112,11 @@ class PollController < ApplicationController end end + #修改单选题 + def update_poll_question + a = 1 + end + private def find_poll_and_course @poll = Poll.find params[:id] diff --git a/app/views/poll/_edit_MC.html.erb b/app/views/poll/_edit_MC.html.erb index 0f031f61c..cc52e7c6b 100644 --- a/app/views/poll/_edit_MC.html.erb +++ b/app/views/poll/_edit_MC.html.erb @@ -1,37 +1,25 @@ -<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%> +<%= form_for poll_question,:url =>update_poll_question_poll_path(@poll.id),:remote => true do |f|%>