Merge branch 'Poll' of http://repository.trustie.net/xianbo/trustie2 into Poll
This commit is contained in:
commit
2af6121f82
|
@ -19,8 +19,8 @@ class PollController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@poll = Poll.find params[:id]
|
@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|
|
respond_to do |format|
|
||||||
format.html {render :layout => 'base_courses'}
|
format.html {render :layout => 'base_courses'}
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ class Poll < ActiveRecord::Base
|
||||||
include Redmine::SafeAttributes
|
include Redmine::SafeAttributes
|
||||||
|
|
||||||
belongs_to :user
|
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 :poll_users, :dependent => :destroy
|
||||||
has_many :users, :through => :poll_users #该文件被哪些用户提交答案过
|
has_many :users, :through => :poll_users #该文件被哪些用户提交答案过
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,6 @@ class PollQuestion < ActiveRecord::Base
|
||||||
include Redmine::SafeAttributes
|
include Redmine::SafeAttributes
|
||||||
|
|
||||||
belongs_to :poll
|
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
|
has_many :poll_votes, :dependent => :destroy
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,86 +20,105 @@
|
||||||
|
|
||||||
<div class="ur_card">
|
<div class="ur_card">
|
||||||
<ol class="ur_questions">
|
<ol class="ur_questions">
|
||||||
|
<% @poll_questions.each do |pq| %>
|
||||||
<li class="ur_question_item radio">
|
<% if pq.question_type == 1 %>
|
||||||
<div class="ur_title">
|
<!-- 单选题 -->
|
||||||
<span class="title_index">第1题:</span> 单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题单选题 <span class="ur_required" title="必答">*</span>
|
<li class="ur_question_item radio">
|
||||||
</div>
|
<div class="ur_title">
|
||||||
<div class="ur_inputs">
|
<span class="title_index">第<%= pq.question_number %>题:</span>
|
||||||
<table class="ur_table" >
|
<%= pq.question_title %>
|
||||||
<tbody>
|
<% if pq.is_necessary == 1 %>
|
||||||
<tr>
|
<span class="ur_required" title="必答">*</span>
|
||||||
<td>
|
<% end %>
|
||||||
<label ><input class="ur_radio" type="radio" value="新建选项" > 新建选项</label>
|
</div>
|
||||||
</td>
|
<div class="cl"></div>
|
||||||
</tr>
|
<div class="ur_inputs">
|
||||||
<tr >
|
<table class="ur_table" >
|
||||||
<td>
|
<tbody>
|
||||||
<label ><input class="ur_radio" type="radio" value="新建选项" > 新建选项</label>
|
<% pq.poll_answers.each do |pa| %>
|
||||||
</td>
|
<tr>
|
||||||
</tr>
|
<td>
|
||||||
<tr>
|
<label >
|
||||||
<td>
|
<input class="ur_radio" type="radio" value="新建选项" >
|
||||||
<label ><input class="ur_radio" type="radio" value="新建选项" > 新建选项</label>
|
<%= pa.answer_text %>
|
||||||
</td>
|
</label>
|
||||||
</tr>
|
</td>
|
||||||
</tbody>
|
</tr>
|
||||||
</table>
|
<% end %>
|
||||||
</div>
|
</tbody>
|
||||||
</li><!--单选题 end-->
|
</table>
|
||||||
|
</div>
|
||||||
<li class="ur_question_item checkbox">
|
</li>
|
||||||
<div class="ur_title">
|
<% elsif pq.question_type == 2 %>
|
||||||
<span class="title_index">第2题:</span> 多选题 <span class="ur_required" title="必答">*</span>
|
<!-- 多选题 -->
|
||||||
</div>
|
<li class="ur_question_item checkbox">
|
||||||
<div class="ur_inputs">
|
<div class="ur_title">
|
||||||
<table class="ur_table">
|
<span class="title_index">第<%= pq.question_number %>题:</span>
|
||||||
<tbody>
|
<%= pq.question_title %>
|
||||||
<tr>
|
<% if pq.is_necessary == 1 %>
|
||||||
<td>
|
<span class="ur_required" title="必答">*</span>
|
||||||
<label ><input class="ur_checkbox" type="checkbox" value="新建选项" > 新建选项 </label>
|
<% end %>
|
||||||
</td>
|
</div>
|
||||||
</tr>
|
<div class="cl"></div>
|
||||||
<tr class="ur_tr_even">
|
<div class="ur_inputs">
|
||||||
<td>
|
<table class="ur_table" >
|
||||||
<label ><input class="ur_checkbox" type="checkbox" value="新建选项" > 新建选项 </label>
|
<tbody>
|
||||||
</td>
|
<% pq.poll_answers.each do |pa| %>
|
||||||
</tr>
|
<tr>
|
||||||
<tr>
|
<td>
|
||||||
<td>
|
<label >
|
||||||
<label ><input class="ur_checkbox" type="checkbox" value="新建选项" > 新建选项 </label>
|
<input class="ur_checkbox" type="checkbox" value="新建选项" >
|
||||||
</td>
|
<%= pa.answer_text %>
|
||||||
</tr>
|
</label>
|
||||||
</tbody>
|
</td>
|
||||||
</table>
|
</tr>
|
||||||
</div>
|
<% end %>
|
||||||
</li><!--多选题 end-->
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
<li class="ur_question_item text">
|
</li>
|
||||||
<div class="ur_title">
|
<% elsif pq.question_type == 3 %>
|
||||||
<span class="title_index">第3题:</span> 单行主观
|
<!-- 单行文字-->
|
||||||
</div>
|
<li class="ur_question_item text">
|
||||||
<div class="ur_inputs">
|
<div class="ur_title">
|
||||||
<input class="ur_text ur_textbox" type="text" size="" maxlength=""value="">
|
<span class="title_index">第<%= pq.question_number %>题:</span>
|
||||||
</div>
|
<%= pq.question_title %>
|
||||||
</li><!--当行输入 end-->
|
<% if pq.is_necessary == 1 %>
|
||||||
|
<span class="ur_required" title="必答">*</span>
|
||||||
<li class="ur_question_item textarea">
|
<% end %>
|
||||||
<div class="ur_preview">
|
</div>
|
||||||
<div class="ur_title">
|
<div class="cl"></div>
|
||||||
<span class="title_index">第4题:</span> 多行主观
|
<div class="ur_inputs">
|
||||||
</div>
|
<input class="ur_text ur_textbox" type="text" size="" maxlength=""value="">
|
||||||
<div class="ur_inputs">
|
</div>
|
||||||
<textarea class="ur_textbox" rows="5" cols="60"></textarea>
|
</li><!--当行输入 end-->
|
||||||
</div>
|
<% elsif pq.question_type == 4 %>
|
||||||
</div>
|
<!-- 多行文字-->
|
||||||
</li><!--多行输入 end-->
|
<li class="ur_question_item textarea">
|
||||||
|
<div class="ur_preview">
|
||||||
|
<div class="ur_title">
|
||||||
|
<span class="title_index">第<%= pq.question_number %>题:</span>
|
||||||
|
<%= pq.question_title %>
|
||||||
|
<% if pq.is_necessary == 1 %>
|
||||||
|
<span class="ur_required" title="必答">*</span>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<div class="ur_inputs">
|
||||||
|
<textarea class="ur_textbox" rows="5" cols="60"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li><!--多行输入 end-->
|
||||||
|
<% else %>
|
||||||
|
<!-- 未知题型 -->
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</ol>
|
</ol>
|
||||||
|
<ul class="wlist">
|
||||||
<div class="ur_buttons">
|
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
|
||||||
<a href="#" class=" ur_button" >下一页</a>
|
</ul>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<div class="ur_buttons" style="width: 100px;">
|
||||||
<a href="#" class="ur_button" >提交</a>
|
<a href="#" class="ur_button" >提交</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
class AddQuestionNumberToPollQuestions < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :poll_questions, :question_number, :integer
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :poll_questions, :question_number
|
||||||
|
end
|
||||||
|
end
|
19
db/schema.rb
19
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20150112024820) do
|
ActiveRecord::Schema.define(:version => 20150114022710) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -23,6 +23,18 @@ ActiveRecord::Schema.define(:version => 20150112024820) do
|
||||||
add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type"
|
add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type"
|
||||||
add_index "activities", ["user_id"], :name => "index_activities_on_user_id"
|
add_index "activities", ["user_id"], :name => "index_activities_on_user_id"
|
||||||
|
|
||||||
|
create_table "api_keys", :force => true do |t|
|
||||||
|
t.string "access_token"
|
||||||
|
t.datetime "expires_at"
|
||||||
|
t.integer "user_id"
|
||||||
|
t.boolean "active", :default => true
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token"
|
||||||
|
add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id"
|
||||||
|
|
||||||
create_table "applied_projects", :force => true do |t|
|
create_table "applied_projects", :force => true do |t|
|
||||||
t.integer "project_id", :null => false
|
t.integer "project_id", :null => false
|
||||||
t.integer "user_id", :null => false
|
t.integer "user_id", :null => false
|
||||||
|
@ -803,8 +815,9 @@ ActiveRecord::Schema.define(:version => 20150112024820) do
|
||||||
t.integer "question_type"
|
t.integer "question_type"
|
||||||
t.integer "is_necessary"
|
t.integer "is_necessary"
|
||||||
t.integer "poll_id"
|
t.integer "poll_id"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
|
t.integer "question_number"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "poll_users", :force => true do |t|
|
create_table "poll_users", :force => true do |t|
|
||||||
|
|
Loading…
Reference in New Issue