diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb
index e1439b7f9..b3fdf5087 100644
--- a/app/controllers/poll_controller.rb
+++ b/app/controllers/poll_controller.rb
@@ -19,8 +19,8 @@ class PollController < ApplicationController
def show
@poll = Poll.find params[:id]
- @poll_questions = @poll.poll_questions
-
+ poll_questions = @poll.poll_questions
+ @poll_questions = paginateHelper poll_questions,3 #分页
respond_to do |format|
format.html {render :layout => 'base_courses'}
end
diff --git a/app/models/poll.rb b/app/models/poll.rb
index 803ee6ac6..06f1369c1 100644
--- a/app/models/poll.rb
+++ b/app/models/poll.rb
@@ -3,7 +3,7 @@ class Poll < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :user
- has_many :poll_questions, :dependent => :destroy
+ has_many :poll_questions, :dependent => :destroy,:order => "#{PollQuestion.table_name}.question_number"
has_many :poll_users, :dependent => :destroy
has_many :users, :through => :poll_users #该文件被哪些用户提交答案过
end
diff --git a/app/models/poll_question.rb b/app/models/poll_question.rb
index 66dcea67e..2d9912fc2 100644
--- a/app/models/poll_question.rb
+++ b/app/models/poll_question.rb
@@ -3,6 +3,6 @@ class PollQuestion < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :poll
- has_many :poll_answers, :dependent => :destroy
+ has_many :poll_answers, :order => "#{PollAnswer.table_name}.answer_position",:dependent => :destroy
has_many :poll_votes, :dependent => :destroy
end
diff --git a/app/views/poll/show.html.erb b/app/views/poll/show.html.erb
index 66fcd3bcd..26daa8fc5 100644
--- a/app/views/poll/show.html.erb
+++ b/app/views/poll/show.html.erb
@@ -20,86 +20,105 @@
-
- -
-
- 第1题: 单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题 *
-
-
-
-
- -
-
- 第2题: 多选题 *
-
-
-
-
-
- -
-
- 第3题: 单行主观
-
-
-
-
-
-
- -
-
-
-
+ <% @poll_questions.each do |pq| %>
+ <% if pq.question_type == 1 %>
+
+ -
+
+ 第<%= pq.question_number %>题:
+ <%= pq.question_title %>
+ <% if pq.is_necessary == 1 %>
+ *
+ <% end %>
+
+
+
+
+ <% elsif pq.question_type == 2 %>
+
+ -
+
+ 第<%= pq.question_number %>题:
+ <%= pq.question_title %>
+ <% if pq.is_necessary == 1 %>
+ *
+ <% end %>
+
+
+
+
+ <% elsif pq.question_type == 3 %>
+
+ -
+
+ 第<%= pq.question_number %>题:
+ <%= pq.question_title %>
+ <% if pq.is_necessary == 1 %>
+ *
+ <% end %>
+
+
+
+
+
+
+ <% elsif pq.question_type == 4 %>
+
+ -
+
+
+ 第<%= pq.question_number %>题:
+ <%= pq.question_title %>
+ <% if pq.is_necessary == 1 %>
+ *
+ <% end %>
+
+
+
+
+
+
+
+ <% else %>
+
+ <% end %>
+ <% end %>
-
-