From cc2ef9380895dacd899322a5995ba9c5833d2adc Mon Sep 17 00:00:00 2001
From: cxt
Date: Thu, 27 Oct 2016 18:25:47 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E9=80=89=E9=A2=98=E7=9A=84=E4=B8=8A?=
=?UTF-8?q?=E9=99=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/poll_controller.rb | 15 +++++++-----
app/views/poll/_new_MCQ.html.erb | 28 ++++++++++++----------
app/views/poll/_poll_content.html.erb | 13 ----------
app/views/poll/_poll_form.html.erb | 4 ++--
app/views/poll/_poll_tool_bar.html.erb | 10 ++++++--
app/views/poll/_show_MC.html.erb | 12 ++++++++++
app/views/poll/_show_MCQ.html.erb | 25 ++++++++++++++++++-
app/views/poll/_show_mulit.html.erb | 14 ++++++++++-
app/views/poll/_show_single.html.erb | 14 ++++++++++-
app/views/poll/create_poll_question.js.erb | 11 +++++++++
app/views/poll/show.html.erb | 11 +++++++++
config/routes.rb | 2 +-
12 files changed, 120 insertions(+), 39 deletions(-)
diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb
index 4e81e2f35..a6356c6c0 100644
--- a/app/controllers/poll_controller.rb
+++ b/app/controllers/poll_controller.rb
@@ -143,7 +143,7 @@ class PollController < ApplicationController
if @before_que && @poll_question.update_attribute('question_number', @poll_question.question_number - 1)
@before_que.update_attribute('question_number', @before_que.question_number + 1)
end
- elsif params[:opr] == 'down' && @poll_question.question_number < members.count
+ elsif params[:opr] == 'down' && @poll_question.question_number < poll_questions.count
@after_que = poll_questions.where("question_number = #{@poll_question.question_number + 1}").first
if @after_que && @poll_question.update_attribute('question_number', @poll_question.question_number + 1)
@after_que.update_attribute('question_number', @after_que.question_number - 1)
@@ -157,12 +157,15 @@ class PollController < ApplicationController
#添加题目
def create_poll_question
+ @last_question = @poll.poll_questions.last
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" ? 1 : 0),
:question_title => question_title,
:question_type => params[:question_type] || 1,
- :question_number => @poll.poll_questions.count + 1
+ :question_number => @poll.poll_questions.count + 1,
+ :max_choices => params[:max_choices].to_i || 0,
+ :min_choices => params[:min_choices].to_i || 0,
}
@poll_questions = @poll.poll_questions.new option
if params[:question_answer]
@@ -193,11 +196,11 @@ class PollController < ApplicationController
@poll_questions.question_number = ques_num + 1
end
end
- if @poll_questions.save
- respond_to do |format|
- format.js
- end
+ if @poll_questions.save
+ respond_to do |format|
+ format.js
end
+ end
end
#修改题目
diff --git a/app/views/poll/_new_MCQ.html.erb b/app/views/poll/_new_MCQ.html.erb
index eaaa0848e..817367841 100644
--- a/app/views/poll/_new_MCQ.html.erb
+++ b/app/views/poll/_new_MCQ.html.erb
@@ -9,18 +9,6 @@
-
-
- 下限 :
-
- (可选)答题时最少选几项
-
-
- 上限 :
-
- (可选)答题时最多选几项
-
-
选项 :
@@ -41,6 +29,22 @@
+
+
+ 下限 :
+
+ (可选)答题时最少选几项
+
+
+
+
+
+ 上限 :
+
+ (可选)答题时最多选几项
+
+
+
新建选项
diff --git a/app/views/poll/_poll_content.html.erb b/app/views/poll/_poll_content.html.erb
index a9623c233..41df14118 100644
--- a/app/views/poll/_poll_content.html.erb
+++ b/app/views/poll/_poll_content.html.erb
@@ -24,16 +24,3 @@
<% end %>
-
-
\ No newline at end of file
diff --git a/app/views/poll/_poll_form.html.erb b/app/views/poll/_poll_form.html.erb
index fb82b4854..1c8f6ceb6 100644
--- a/app/views/poll/_poll_form.html.erb
+++ b/app/views/poll/_poll_form.html.erb
@@ -480,9 +480,9 @@ function insert_MCQ(quest_type,quest_id){
//多选题答题限制数实时更新
function multiLimit(){
var upperLimit = $(".questionContainer .new_answer").size();
- $(".poll-multiple-limit").append(" ");
+ $(".poll-multiple-limit").append(" ");
for(var i = 1; i <= upperLimit; i++){
- $(".poll-multiple-limit").append("" + i + " ");
+ $(".poll-multiple-limit").append("" + i + " ");
}
}
diff --git a/app/views/poll/_poll_tool_bar.html.erb b/app/views/poll/_poll_tool_bar.html.erb
index 6d1ee7d4d..f27100964 100644
--- a/app/views/poll/_poll_tool_bar.html.erb
+++ b/app/views/poll/_poll_tool_bar.html.erb
@@ -4,8 +4,14 @@
*
<%end%>
-
-
+<% poll = poll_question.poll %>
+<% count = poll.poll_questions.count %>
+<% unless poll_question.question_number == 1 %>
+ <%= link_to('', {:controller => 'poll', :action => 'update_question_num', :id => poll.id, :ques_id => poll_question.id, :opr => 'up'},:remote => true, :method => 'post', :class => "poll-up mb8", :title => '上移') %>
+<% end %>
+<% if poll_question.question_number < count %>
+ <%= link_to('', {:controller => 'poll', :action => 'update_question_num', :id => poll.id, :ques_id => poll_question.id, :opr => 'down'},:remote => true, :method => 'post', :class => "poll-down mb8", :title => '下移') %>
+<% end %>