commit
1803eab9f1
@ -1,2 +0,0 @@
|
||||
class PollAnswerController < ApplicationController
|
||||
end
|
File diff suppressed because it is too large
Load Diff
@ -1,2 +0,0 @@
|
||||
class PollQuestionController < ApplicationController
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
class PollUserController < ApplicationController
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
class PollVoteController < ApplicationController
|
||||
end
|
@ -0,0 +1,77 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module PollHelper
|
||||
#判断选项是否被选中
|
||||
def answer_be_selected?(answer,user)
|
||||
pv = answer.poll_votes.where("#{PollVote.table_name}.user_id = #{user.id} ")
|
||||
if !pv.nil? && pv.count > 0
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
#获取文本题答案
|
||||
def get_anwser_vote_text(question_id,user_id)
|
||||
pv = PollVote.find_by_poll_question_id_and_user_id(question_id,user_id)
|
||||
if pv.nil?
|
||||
''
|
||||
else
|
||||
pv.vote_text
|
||||
end
|
||||
end
|
||||
|
||||
#判断用户是否已经提交了问卷
|
||||
def has_commit_poll?(poll_id,user_id)
|
||||
pu = PollUser.find_by_poll_id_and_user_id(poll_id,user_id)
|
||||
if pu.nil?
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
#统计答题百分比,统计结果保留两位小数
|
||||
def statistics_result_percentage(e, t)
|
||||
e = e.to_f
|
||||
t = t.to_f
|
||||
t == 0 ? 0 : format("%.2f", e*100/t)
|
||||
end
|
||||
|
||||
#多选的时候查询去重
|
||||
def total_answer id
|
||||
total = PollVote.find_by_sql("SELECT distinct(user_id) FROM `poll_votes` where poll_question_id = #{id}").count
|
||||
end
|
||||
|
||||
#页面体型显示
|
||||
def options_show pq
|
||||
case pq
|
||||
when 1
|
||||
"单选题"
|
||||
when 2
|
||||
"多选题"
|
||||
when 3
|
||||
"单行主观题"
|
||||
else
|
||||
"多行主观题"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,28 @@
|
||||
<div class="ur_table_result">
|
||||
<table border="0" cellspacing="0" cellpadding="0" >
|
||||
<tbody>
|
||||
<tr class="table_bluebg">
|
||||
<td class="td327"><%= l(:label_poll_options) %> </td>
|
||||
<td class="td42"><%= l(:label_poll_subtotal) %> </td>
|
||||
<td class="td287"><%= l(:label_poll_proportion) %> </td>
|
||||
</tr>
|
||||
<% poll_question.poll_answers.each do |poll_answer| %>
|
||||
<tr>
|
||||
<td class="td327"><%= poll_answer.answer_text %> </td>
|
||||
<td class="td42"><%= poll_answer.poll_votes.count %> </td>
|
||||
<td class="td287">
|
||||
<div class="Bar">
|
||||
<span style="width:<%= statistics_result_percentage(poll_answer.poll_votes.count, total_answer(poll_question.id)) %>%;" id="choice_percentage_<%= poll_answer.id %>"></span>
|
||||
</div>
|
||||
<%= statistics_result_percentage(poll_answer.poll_votes.count, total_answer(poll_question.id)) %>%</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr class="table_bluebg">
|
||||
<td class="td327"><%= l(:label_poll_valid_commit) %> </td>
|
||||
<td class="td42"><%= total_answer(poll_question.id) %></td>
|
||||
<td class="td287"> </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
@ -0,0 +1,12 @@
|
||||
<div id="popbox" style="text-align: center;margin-top: 25px">
|
||||
<% if status == 0 %>
|
||||
<h3 style="font-weight: normal;color: green">提交成功!</h3>
|
||||
<%= link_to "确定", poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course'),:class => 'commit'%>
|
||||
<% elsif status == 1 %>
|
||||
<h3 style="font-weight: normal;color: red">您还有尚未作答的必答题目请完成后再提交!</h3>
|
||||
<%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%>
|
||||
<% else %>
|
||||
<h3 style="font-weight: normal;color: red">发生未知错误,请检查您的网络。</h3>
|
||||
<%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%>
|
||||
<% end %>
|
||||
</div>
|
@ -0,0 +1,15 @@
|
||||
<%= form_for @poll,:remote => true do |f|%>
|
||||
<div class="ur_editor ur_title_editor"> <!--编辑头部start-->
|
||||
<div class="ur_title_editor_title">
|
||||
<input type="text" maxlength="100" name="polls_name" id="polls_title" value="<%= @poll.polls_name %>" class="input_title" placeholder="问卷标题"/>
|
||||
</div>
|
||||
<div class="ur_title_editor_prefix">
|
||||
<textarea name="polls_description" maxlength="300" id="polls_description" class="textarea_editor"><%= @poll.polls_description%></textarea>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn_submit" data-button="ok" onclick="$(this).parent().parent().parent().submit();">确定</a>
|
||||
<a class="btn_cancel" data-button="cancel" onclick="pollsCancel();">取消</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div><!--编辑头部 end-->
|
||||
<% end%>
|
@ -0,0 +1,28 @@
|
||||
<%= form_for("",:url => update_poll_question_poll_index_path(:poll_question => poll_question.id),:remote => true) do |f|%>
|
||||
<script type="text/javascript">
|
||||
function resetQuestion<%=poll_question.id%>()
|
||||
{
|
||||
$("#poll_questions_title_<%=poll_question.id%>").val("<%= poll_question.question_title%>")
|
||||
$("#is_necessary_<%=poll_question.id%>").replaceWith("<input type='checkbox' name='is_necessary' id='is_necessary_<%=poll_question.id%>' value='true' <%= poll_question.is_necessary == 1 ? 'checked' : ''%>/>");
|
||||
}
|
||||
</script>
|
||||
<div class="ur_editor textarea"> <!--编辑多行文字start-->
|
||||
<div class="ur_editor_title">
|
||||
<label for="ur_question_title">问题: </label>
|
||||
<input type="hidden" name="question_type" value="<%= poll_question.question_type%>"/>
|
||||
<input maxlength="250" class="ur_question_title" type="text" name="poll_questions_title" id="poll_questions_title_<%=poll_question.id%>" placeholder="请输入多行主观标题" value="<%= poll_question.question_title%>"/>
|
||||
<input type="checkbox" id="is_necessary_<%=poll_question.id%>" name="is_necessary" value="true" <%= poll_question.is_necessary == 1 ? "checked" : ""%>/>
|
||||
<label for="ur_question_require">必答</label>
|
||||
</div>
|
||||
<div class="ur_editor_toolbar">
|
||||
<!--<label>尺寸:</label>-->
|
||||
<!--<label>宽 <input name="cols" type="number" min="1" value="60"> 字</label>,-->
|
||||
<!--<label>高 <input name="rows" type="number" min="1" value="5"> 行</label>-->
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn_submit" data-button="ok" onclick="$(this).parent().parent().parent().submit();">确定</a>
|
||||
<a class="btn_cancel" data-button="cancel" onclick="resetQuestion<%=poll_question.id%>();pollQuestionCancel(<%= poll_question.id%>);">取消</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div><!--编辑多行文字end-->
|
||||
<% end%>
|
@ -0,0 +1,24 @@
|
||||
<%= form_for("",:url => update_poll_question_poll_index_path(:poll_question => poll_question.id),:remote => true) do |f|%>
|
||||
<script type="text/javascript">
|
||||
function resetQuestion<%=poll_question.id%>()
|
||||
{
|
||||
$("#poll_questions_title_<%=poll_question.id%>").val("<%= poll_question.question_title%>")
|
||||
$("#is_necessary_<%=poll_question.id%>").replaceWith("<input type='checkbox' name='is_necessary' id='is_necessary_<%=poll_question.id%>' value='true' <%= poll_question.is_necessary == 1 ? 'checked' : ''%>/>");
|
||||
}
|
||||
</script>
|
||||
<div class="ur_editor text "> <!--编辑单行文字start-->
|
||||
<div class="ur_editor_title">
|
||||
<label for="ur_question_title">问题: </label>
|
||||
<input type="hidden" name="question_type" value="<%= poll_question.question_type%>"/>
|
||||
<input maxlength="250" id="poll_questions_title_<%=poll_question.id%>" class="ur_question_title" contenteditable="true" type="text"
|
||||
name="poll_questions_title" placeholder="请输入单行主观标题" value="<%= poll_question.question_title%>"/>
|
||||
<input type="checkbox" id="is_necessary_<%=poll_question.id%>" name="is_necessary" value="true" <%= poll_question.is_necessary == 1 ? "checked" : ""%>/>
|
||||
<label for="ur_question_require">必答</label>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn_submit" data-button="ok" onclick="$(this).parent().parent().parent().submit();">确定</a>
|
||||
<a class="btn_cancel" data-button="cancel" onclick="resetQuestion<%=poll_question.id%>();pollQuestionCancel(<%= poll_question.id%>);">取消</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div><!--编辑单行文字end-->
|
||||
<% end%>
|
@ -0,0 +1,21 @@
|
||||
<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>
|
||||
<div class="ur_editor textarea"> <!--编辑多行文字start-->
|
||||
<div class="ur_editor_title">
|
||||
<label for="ur_question_title">问题: </label>
|
||||
<input type="hidden" name="question_type" value="4"/>
|
||||
<input maxlength="250" id="poll_questions_title" class="ur_question_title" contenteditable="true" type="text" name="poll_questions_title" placeholder="请输入多行主观标题"/>
|
||||
<input type="checkbox" name="is_necessary" value="true" checked/>
|
||||
<label>必答</label>
|
||||
</div>
|
||||
<div class="ur_editor_toolbar">
|
||||
<!--<label>尺寸:</label>-->
|
||||
<!--<label>宽 <input name="cols" type="number" min="1" value="60"> 字</label>,-->
|
||||
<!--<label>高 <input name="rows" type="number" min="1" value="5"> 行</label>-->
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn_submit" data-button="ok" onclick="$(this).parent().parent().parent().submit();">确定</a>
|
||||
<a class="btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">取消</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div><!--编辑多行文字end-->
|
||||
<% end%>
|
@ -0,0 +1,16 @@
|
||||
<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>
|
||||
<div class="ur_editor text "> <!--编辑单行文字start-->
|
||||
<div class="ur_editor_title">
|
||||
<label for="ur_question_title">问题: </label>
|
||||
<input type="hidden" name="question_type" value="3"/>
|
||||
<input maxlength="250" id="poll_questions_title" class="ur_question_title" contenteditable="true" type="text" name="poll_questions_title" placeholder="请输入单行主观标题"/>
|
||||
<input type="checkbox" name="is_necessary" value="true" checked/>
|
||||
<label for="ur_question_require">必答</label>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn_submit" data-button="ok" onclick="$(this).parent().parent().parent().submit();">确定</a>
|
||||
<a class="btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">取消</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div><!--编辑单行文字end-->
|
||||
<% end%>
|
@ -0,0 +1,26 @@
|
||||
<% poll.poll_questions.each do |poll_question|%>
|
||||
<div id="poll_questions_<%= poll_question.id%>">
|
||||
<div id="show_poll_questions_<%= poll_question.id %>">
|
||||
<% if poll_question.question_type == 1%>
|
||||
<%= render :partial => 'show_MC', :locals => {:poll_question => poll_question} %>
|
||||
<% elsif poll_question.question_type == 2%>
|
||||
<%= render :partial => 'show_MCQ', :locals => {:poll_question => poll_question} %>
|
||||
<% elsif poll_question.question_type == 3%>
|
||||
<%= render :partial => 'show_single', :locals => {:poll_question => poll_question} %>
|
||||
<% elsif poll_question.question_type == 4%>
|
||||
<%= render :partial => 'show_mulit', :locals => {:poll_question => poll_question} %>
|
||||
<% end%>
|
||||
</div>
|
||||
<div id="edit_poll_questions_<%= poll_question.id %>" style="display: none;">
|
||||
<% if poll_question.question_type == 1%>
|
||||
<%= render :partial => 'edit_MC', :locals => {:poll_question => poll_question} %>
|
||||
<% elsif poll_question.question_type == 2%>
|
||||
<%= render :partial => 'edit_MCQ', :locals => {:poll_question => poll_question} %>
|
||||
<% elsif poll_question.question_type == 3%>
|
||||
<%= render :partial => 'edit_single', :locals => {:poll_question => poll_question} %>
|
||||
<% elsif poll_question.question_type == 4%>
|
||||
<%= render :partial => 'edit_mulit', :locals => {:poll_question => poll_question} %>
|
||||
<% end%>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
@ -0,0 +1,12 @@
|
||||
<tbody>
|
||||
<% poll_question.poll_answers.reorder("answer_position").each do |poll_answer| %>
|
||||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
<input class="ur_radio" type="radio" name="<%= poll_question %>" value="<%= poll_answer.answer_text%>" >
|
||||
<%= poll_answer.answer_text%>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue