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 +<%= form_for @poll,:remote => true do |f|%> +
+
+ +
+
+ +
+ +
+
+<% end%> diff --git a/app/views/poll/_poll_form.html.erb b/app/views/poll/_poll_form.html.erb index 473c1df83..474f3be29 100644 --- a/app/views/poll/_poll_form.html.erb +++ b/app/views/poll/_poll_form.html.erb @@ -10,6 +10,11 @@ function add_MCQ(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_MCQ') %>");} 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 add_single_answer(doc) { @@ -60,7 +65,10 @@
- <%= render :partial => 'edit_head'%> +
+ <%#= render :partial => 'show_head', :locals => {:poll => @poll} %> + <%= render :partial => 'edit_head', :locals => {:poll => @poll}%> +
<% @poll.poll_questions.each do |poll_question|%> diff --git a/app/views/poll/_show_head.html.erb b/app/views/poll/_show_head.html.erb index f8a2d58f0..28741843d 100644 --- a/app/views/poll/_show_head.html.erb +++ b/app/views/poll/_show_head.html.erb @@ -1,8 +1,10 @@ -
-

标题标题标题标题标题标题标题

-

描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述 - 描述描述描述描述描述描述描述描述描述描述描述描述 -

+
+

+ <%= poll.polls_name%> +

+

+ <%= @poll.polls_description%> +

\ 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: 问卷描述