Merge branch 'Poll' of http://repository.trustie.net/xianbo/trustie2 into Poll
This commit is contained in:
commit
2cbe801528
|
@ -24,6 +24,7 @@ class PollController < ApplicationController
|
|||
render_403
|
||||
else
|
||||
@can_edit_poll = (!has_commit_poll?(@poll.id,User.current.id)) || User.current.admin?
|
||||
@percent = get_percent(@poll,User.current)
|
||||
poll_questions = @poll.poll_questions
|
||||
@poll_questions = paginateHelper poll_questions,3 #分页
|
||||
respond_to do |format|
|
||||
|
@ -131,8 +132,7 @@ class PollController < ApplicationController
|
|||
#修改单选题
|
||||
def update_poll_question
|
||||
@poll_question = PollQuestion.find params[:poll_question]
|
||||
@poll = @poll_question.poll
|
||||
|
||||
#@poll = @poll_question.poll
|
||||
@poll_question.is_necessary = params[:is_necessary]=="true" ? 1 : 0
|
||||
@poll_question.question_title = params[:poll_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title]
|
||||
################处理选项
|
||||
|
@ -182,7 +182,7 @@ class PollController < ApplicationController
|
|||
def commit_answer
|
||||
pq = PollQuestion.find(params[:poll_question_id])
|
||||
if has_commit_poll?(@poll.id,User.current.id) && (!User.current.admin?)
|
||||
render :text => 'failure'
|
||||
render :json => {:text => "failure"}
|
||||
return
|
||||
end
|
||||
if pq.question_type == 1
|
||||
|
@ -195,9 +195,10 @@ class PollController < ApplicationController
|
|||
end
|
||||
pv.poll_answer_id = params[:poll_answer_id]
|
||||
if pv.save
|
||||
render :text => "ok"
|
||||
@percent = get_percent(@poll,User.current)
|
||||
render :json => {:text => "ok" ,:percent => format("%.2f" ,@percent)}
|
||||
else
|
||||
render :text => "failure"
|
||||
render :json => {:text => "failure"}
|
||||
end
|
||||
elsif pq.question_type == 2
|
||||
pv = PollVote.find_by_poll_answer_id_and_user_id(params[:poll_answer_id],User.current.id)
|
||||
|
@ -207,38 +208,64 @@ class PollController < ApplicationController
|
|||
pv.poll_question_id = params[:poll_question_id]
|
||||
pv.poll_answer_id = params[:poll_answer_id]
|
||||
if pv.save
|
||||
render :text => "true"
|
||||
@percent = get_percent(@poll,User.current)
|
||||
render :json => {:text => "true",:percent => format("%.2f" ,@percent)}
|
||||
else
|
||||
render :text => "failure"
|
||||
render :json => {:text => "failure"}
|
||||
end
|
||||
else
|
||||
if pv.delete
|
||||
render :text => "false"
|
||||
@percent = get_percent(@poll,User.current)
|
||||
render :json => {:text => "false" ,:percent => format("%.2f" ,@percent)}
|
||||
else
|
||||
render :text => "failure"
|
||||
render :json => {:text => "failure"}
|
||||
end
|
||||
end
|
||||
elsif pq.question_type == 3 || pq.question_type == 4
|
||||
pv = PollVote.find_by_poll_question_id_and_user_id(params[:poll_question_id],User.current.id)
|
||||
if pv.nil?
|
||||
pv = PollVote.new
|
||||
pv.user_id = User.current.id
|
||||
pv.poll_question_id = params[:poll_question_id]
|
||||
end
|
||||
pv.vote_text = params[:vote_text]
|
||||
if pv.save
|
||||
render :text => pv.vote_text
|
||||
if params[:vote_text].nil? || params[:vote_text].blank?
|
||||
@percent = get_percent(@poll,User.current)
|
||||
render :json => {:text => pv.vote_text,:percent => format("%.2f" ,@percent)}
|
||||
else
|
||||
pv = PollVote.new
|
||||
pv.user_id = User.current.id
|
||||
pv.poll_question_id = params[:poll_question_id]
|
||||
pv.vote_text = params[:vote_text]
|
||||
if pv.save
|
||||
@percent = get_percent(@poll,User.current)
|
||||
render :json => {:text => pv.vote_text,:percent => format("%.2f" ,@percent)}
|
||||
else
|
||||
render :json => {:text => "failure"}
|
||||
end
|
||||
end
|
||||
else
|
||||
render :text => "failure"
|
||||
if params[:vote_text].nil? || params[:vote_text].blank?
|
||||
if pv.delete
|
||||
@percent = get_percent(@poll,User.current)
|
||||
render :json => {:text => pv.vote_text,:percent => format("%.2f" ,@percent)}
|
||||
else
|
||||
render :json => {:text => "failure"}
|
||||
end
|
||||
else
|
||||
pv.vote_text = params[:vote_text]
|
||||
if pv.save
|
||||
@percent = get_percent(@poll,User.current)
|
||||
render :json => {:text => pv.vote_text,:percent => format("%.2f" ,@percent)}
|
||||
else
|
||||
render :json => {:text => "failure"}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
render :text => "failure"
|
||||
render :json => {:text => "failure"}
|
||||
end
|
||||
end
|
||||
|
||||
#提交问卷
|
||||
def commit_poll
|
||||
@uncomplete_question = get_uncomplete_question(@poll)
|
||||
@uncomplete_question = get_uncomplete_question(@poll,User.current)
|
||||
if @uncomplete_question.count < 1
|
||||
pu = get_poll_user(@poll.id,User.current.id)
|
||||
pu.user_id = User.current.id
|
||||
|
@ -287,17 +314,41 @@ class PollController < ApplicationController
|
|||
end
|
||||
|
||||
#获取未完成的题目
|
||||
def get_uncomplete_question poll
|
||||
def get_uncomplete_question poll,user
|
||||
necessary_questions = poll.poll_questions.where("#{PollQuestion.table_name}.is_necessary = 1")
|
||||
uncomplete_question = []
|
||||
necessary_questions.each do |question|
|
||||
if question.poll_votes.nil? || question.poll_votes.count < 1
|
||||
answers = get_user_answer(question,user)
|
||||
if answers.nil? || answers.count < 1
|
||||
uncomplete_question << question
|
||||
end
|
||||
end
|
||||
uncomplete_question
|
||||
end
|
||||
|
||||
#获取用户对某个问题的答案
|
||||
def get_user_answer(question,user)
|
||||
user_answer = question.poll_votes.where("#{PollVote.table_name}.user_id = #{user.id}")
|
||||
user_answer
|
||||
end
|
||||
|
||||
def get_complete_question(poll,user)
|
||||
questions = poll.poll_questions
|
||||
complete_question = []
|
||||
questions.each do |question|
|
||||
answers = get_user_answer(question,user)
|
||||
if !(answers.nil? || answers.count < 1)
|
||||
complete_question << question
|
||||
end
|
||||
end
|
||||
complete_question
|
||||
end
|
||||
|
||||
def get_percent poll,user
|
||||
complete_count = get_complete_question(poll,user).count
|
||||
(complete_count.to_f / poll.poll_questions.count.to_f)*100
|
||||
end
|
||||
|
||||
#PollUser记录用户是否已提交问卷有对应的记录则已提交,没有则新建一个
|
||||
def get_poll_user poll_id,user_id
|
||||
pu = PollUser.find_by_poll_id_and_user_id(poll_id,user_id)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<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>
|
||||
<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>
|
||||
|
|
|
@ -1,33 +1,28 @@
|
|||
<div><!--编辑多选start-->
|
||||
<%= form_for("",:url => update_poll_question_poll_index_path(:poll_question => poll_question.id),:remote => true) do |f|%><!--编辑多选start-->
|
||||
<div class="ur_editor checkbox">
|
||||
<div class="ur_editor_title">
|
||||
<label >问题: </label>
|
||||
<input class="ur_question_title" type="text" name="title" placeholder="请输入多选题题标题"/>
|
||||
<input type="checkbox" name="required" value="true" checked=""/>
|
||||
<label >必答</label>
|
||||
<input type="hidden" name="question_type" value="<%= poll_question.question_type%>"/>
|
||||
<input 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" name="is_necessary" value="true" <%= poll_question.is_necessary == 1 ? "checked" : ""%>/>
|
||||
<label>必答</label>
|
||||
</div>
|
||||
<div class="ur_editor_content">
|
||||
<ul>
|
||||
<li class="ur_item">
|
||||
<label>选项 <span class="ur_index">01</span>: </label>
|
||||
<input type="text" name="option" placeholder="新建选项"/>
|
||||
<a class="icon_add" title="向下插入选项"></a>
|
||||
<a class="icon_remove" title="删除"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label >选项 <span class="ur_index">01</span>: </label>
|
||||
<input type="text" name="option" placeholder="新建选项"/>
|
||||
<a class="icon_add" title="向下插入选项"></a>
|
||||
<a class="icon_remove" title="删除"></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<% poll_question.poll_answers.reorder("answer_position").each do |poll_answer| %>
|
||||
<li class='ur_item'>
|
||||
<label>选项<span class='ur_index'></span>:</label>
|
||||
<input type='text' name='question_answer[<%= poll_answer.id %>]' placeholder='新建选项' value="<%= poll_answer.answer_text%>"/>
|
||||
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
|
||||
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
|
||||
</li>
|
||||
<div class='cl'></div>
|
||||
<% end%>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn btn_dark btn_submit" data-button="ok">确定</a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel">取消</a>
|
||||
<a class="btn btn_dark btn_submit" data-button="ok" onclick="$(this).parent().parent().parent().submit();">确定</a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="pollQuestionCancel(<%= poll_question.id%>);">取消</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div><!--编辑多选 end-->
|
||||
</div><!--编辑多选 end-->
|
||||
<% end%>
|
|
@ -1,18 +1,21 @@
|
|||
<%= form_for("",:url => update_poll_question_poll_index_path(:poll_question => poll_question.id),:remote => true) do |f|%>
|
||||
<div class="ur_editor textarea"> <!--编辑多行文字start-->
|
||||
<div class="ur_editor_title">
|
||||
<label for="ur_question_title">问题: </label>
|
||||
<input id="ur_question_title" class="ur_question_title" contenteditable="true" type="text" name="title" placeholder="请输入多行文字标题"/>
|
||||
<input type="checkbox" name="required" value="true" id="ur_question_require" checked=""/>
|
||||
<input type="hidden" name="question_type" value="<%= poll_question.question_type%>"/>
|
||||
<input 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" 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>
|
||||
<!--<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">确定</a>
|
||||
<a class="btn_cancel" data-button="cancel">取消</a>
|
||||
<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%>
|
|
@ -1,13 +1,17 @@
|
|||
<%= form_for("",:url => update_poll_question_poll_index_path(:poll_question => poll_question.id),:remote => true) do |f|%>
|
||||
<div class="ur_editor text "> <!--编辑单行文字start-->
|
||||
<div class="ur_editor_title">
|
||||
<label for="ur_question_title">问题: </label>
|
||||
<input id="ur_question_title_1" class="ur_question_title" contenteditable="true" type="text" name="title" placeholder="请输入单行文字标题"/>
|
||||
<input type="checkbox" name="required" value="true" id="ur_question_require_2" checked=""/>
|
||||
<input type="hidden" name="question_type" value="<%= poll_question.question_type%>"/>
|
||||
<input 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" 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">确定</a>
|
||||
<a class="btn_cancel" data-button="cancel">取消</a>
|
||||
<a class="btn_submit" data-button="ok" onclick="$(this).parent().parent().parent().submit();">确定</a>
|
||||
<a class="btn_cancel" data-button="cancel" onclick="pollQuestionCancel(<%= poll_question.id%>);">取消</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div><!--编辑单行文字end-->
|
||||
<% end%>
|
|
@ -1,6 +1,5 @@
|
|||
<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>
|
||||
<div>
|
||||
<!--编辑单选start-->
|
||||
<!--新建单选start-->
|
||||
<div class="ur_editor radio">
|
||||
<div class="ur_editor_title">
|
||||
<label>问题: </label>
|
||||
|
@ -35,11 +34,10 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn btn_dark btn_submit" data-button="ok" onclick="$(this).parent().parent().parent().parent().submit();">确定</a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().parent().remove();">取消</a>
|
||||
<a class="btn btn_dark btn_submit" data-button="ok" onclick="$(this).parent().parent().parent().submit();">确定</a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">取消</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<!--编辑单选 end-->
|
||||
</div>
|
||||
<% end%>
|
|
@ -1,33 +1,41 @@
|
|||
<div><!--编辑多选start-->
|
||||
<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%><!--新建多选start-->
|
||||
<div class="ur_editor checkbox">
|
||||
<div class="ur_editor_title">
|
||||
<label >问题: </label>
|
||||
<label>问题: </label>
|
||||
<input type="hidden" name="question_type" value="2"/>
|
||||
<input class="ur_question_title" type="text" name="poll_questions_title" id="poll_questions_title" placeholder="请输入多选题题标题"/>
|
||||
<input type="checkbox" name="required" value="true" checked=""/>
|
||||
<label >必答</label>
|
||||
<input type="checkbox" name="is_necessary" value="true" checked/>
|
||||
<label>必答</label>
|
||||
</div>
|
||||
<div class="ur_editor_content">
|
||||
<ul>
|
||||
<li class="ur_item">
|
||||
<label>选项 <span class="ur_index">01</span>: </label>
|
||||
<input type="text" name="option" placeholder="新建选项"/>
|
||||
<a class="icon_add" title="向下插入选项"></a>
|
||||
<a class="icon_remove" title="删除"></a>
|
||||
<li class='ur_item'>
|
||||
<label>选项<span class='ur_index'></span>:</label>
|
||||
<input type='text' name='question_answer[0]' placeholder='新建选项'/>
|
||||
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
|
||||
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label >选项 <span class="ur_index">01</span>: </label>
|
||||
<input type="text" name="option" placeholder="新建选项"/>
|
||||
<a class="icon_add" title="向下插入选项"></a>
|
||||
<a class="icon_remove" title="删除"></a>
|
||||
<div class='cl'></div>
|
||||
<li class='ur_item'>
|
||||
<label>选项<span class='ur_index'></span>:</label>
|
||||
<input type='text' name='question_answer[1]' placeholder='新建选项'/>
|
||||
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
|
||||
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<div class='cl'></div>
|
||||
<li class='ur_item'>
|
||||
<label>选项<span class='ur_index'></span>:</label>
|
||||
<input type='text' name='question_answer[2]' placeholder='新建选项'/>
|
||||
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
|
||||
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
|
||||
</li>
|
||||
<div class='cl'></div>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn btn_dark btn_submit" data-button="ok">确定</a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel">取消</a>
|
||||
<a class="btn btn_dark btn_submit" data-button="ok" onclick="$(this).parent().parent().parent().submit();">确定</a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">取消</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div><!--编辑多选 end-->
|
||||
<% end%><!--编辑多选 end-->
|
|
@ -1,18 +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 id="poll_questions_title" class="ur_question_title" contenteditable="true" type="text" name="poll_questions_title" placeholder="请输入多行文字标题"/>
|
||||
<input type="checkbox" name="required" value="true" id="ur_question_require" checked=""/>
|
||||
<label for="ur_question_require">必答</label>
|
||||
<input type="hidden" name="question_type" value="4"/>
|
||||
<input 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>
|
||||
<!--<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">确定</a>
|
||||
<a class="btn_cancel" data-button="cancel">取消</a>
|
||||
<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%>
|
|
@ -1,13 +1,16 @@
|
|||
<div class="ur_editor text "> <!--编辑单行文字start-->
|
||||
<div class="ur_editor_title">
|
||||
<label for="ur_question_title">问题: </label>
|
||||
<input id="poll_questions_title" class="ur_question_title" contenteditable="true" type="text" name="title" placeholder="请输入单行文字标题"/>
|
||||
<input type="checkbox" name="required" value="true" id="ur_question_require_2" checked=""/>
|
||||
<label for="ur_question_require">必答</label>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn_submit" data-button="ok">确定</a>
|
||||
<a class="btn_cancel" data-button="cancel">取消</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div><!--编辑单行文字end-->
|
||||
<%= 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 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%>
|
|
@ -1,10 +1,26 @@
|
|||
<% poll.poll_questions.each do |poll_question|%>
|
||||
<div id="poll_questions_<%= poll_question.id%>">
|
||||
<div id="show_poll_questions_<%= poll_question.id %>">
|
||||
<%= render :partial => 'show_MC', :locals => {:poll_question => poll_question} %>
|
||||
<% 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;">
|
||||
<%= render :partial => 'edit_MC', :locals => {:poll_question => poll_question} %>
|
||||
<% 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 %>
|
|
@ -60,6 +60,19 @@
|
|||
<body>
|
||||
<div class=" polls_content polls_edit" id="polls">
|
||||
|
||||
<!-- 头部 -->
|
||||
<div id="polls_head_show" style="display: none;">
|
||||
<%= render :partial => 'show_head', :locals => {:poll => @poll}%>
|
||||
</div>
|
||||
<div id="polls_head_edit">
|
||||
<%= render :partial => 'edit_head', :locals => {:poll => @poll}%>
|
||||
</div>
|
||||
|
||||
<!-- 问题 -->
|
||||
<div id="poll_content">
|
||||
<%= render :partial => 'poll_content', :locals => {:poll => @poll}%>
|
||||
</div>
|
||||
|
||||
<div class="tabs_1">
|
||||
<ul class="tabs_list">
|
||||
<li class="tab_item02 " >
|
||||
|
@ -86,19 +99,6 @@
|
|||
<div class="cl"></div>
|
||||
</div><!--选项 end-->
|
||||
|
||||
<!-- 头部 -->
|
||||
<div id="polls_head_show">
|
||||
<%= render :partial => 'show_head', :locals => {:poll => @poll}%>
|
||||
</div>
|
||||
<div id="polls_head_edit" style="display: none;">
|
||||
<%= render :partial => 'edit_head', :locals => {:poll => @poll}%>
|
||||
</div>
|
||||
|
||||
<!-- 问题 -->
|
||||
<div id="poll_content">
|
||||
<%= render :partial => 'poll_content', :locals => {:poll => @poll}%>
|
||||
</div>
|
||||
|
||||
<!-- 新增问题 -->
|
||||
<div id="new_poll_question">
|
||||
</div>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<%if poll_question.is_necessary == 1%>
|
||||
<span class="ur_required" title="必答">*</span>
|
||||
<%end%>
|
||||
|
||||
(单选题)
|
||||
</div>
|
||||
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
|
||||
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
|
||||
|
|
|
@ -1,28 +1,31 @@
|
|||
<div class="ur_question_item checkbox ur_editor02">
|
||||
<div class="ur_title">
|
||||
<span class="title_index">第2题:</span> 多选题 <span class="ur_required" title="必答">*</span>
|
||||
<span class="title_index">
|
||||
第<%= poll_question.question_number%>题:
|
||||
</span>
|
||||
<%= poll_question.question_title %>
|
||||
<%if poll_question.is_necessary == 1%>
|
||||
<span class="ur_required" title="必答">*</span>
|
||||
<%end%>
|
||||
(多选题)
|
||||
</div>
|
||||
<a href="#" class="ur_icon_de" title="删除"></a>
|
||||
<a href="#" class="ur_icon_edit" title="编辑"></a>
|
||||
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
|
||||
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
|
||||
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a>
|
||||
<div class="cl"></div>
|
||||
<div class="ur_inputs">
|
||||
<table class="ur_table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<label ><input class="ur_checkbox" type="checkbox" value="新建选项" > 新建选项 </label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td>
|
||||
<label ><input class="ur_checkbox" type="checkbox" value="新建选项" > 新建选项 </label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label ><input class="ur_checkbox" type="checkbox" value="新建选项" > 新建选项 </label>
|
||||
</td>
|
||||
</tr>
|
||||
<% poll_question.poll_answers.reorder("answer_position").each do |poll_answer| %>
|
||||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
<input class="ur_radio" type="checkbox" name="<%= poll_question %>" value="<%= poll_answer.answer_text%>" >
|
||||
<%= poll_answer.answer_text%>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
<div class="ur_question_item textarea ur_editor02">
|
||||
<div class="ur_preview">
|
||||
<div class="ur_title">
|
||||
<span class="title_index">第4题:</span> 多行主观
|
||||
<span class="title_index">
|
||||
第<%= poll_question.question_number%>题:
|
||||
</span>
|
||||
<%= poll_question.question_title %>
|
||||
<%if poll_question.is_necessary == 1%>
|
||||
<span class="ur_required" title="必答">*</span>
|
||||
<%end%>
|
||||
(多行主观)
|
||||
</div>
|
||||
<a href="#" class="ur_icon_de" title="删除"></a>
|
||||
<a href="#" class="ur_icon_edit" title="编辑"></a>
|
||||
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
|
||||
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
|
||||
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a>
|
||||
<div class="cl"></div>
|
||||
<div class="ur_inputs">
|
||||
<textarea class="ur_textbox" rows="5" cols="60"></textarea>
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
<div class="ur_question_item text ur_editor02 ">
|
||||
<div class="ur_title">
|
||||
<span class="title_index">第3题:</span> 单行文字
|
||||
<span class="title_index">
|
||||
第<%= poll_question.question_number%>题:
|
||||
</span>
|
||||
<%= poll_question.question_title %>
|
||||
<%if poll_question.is_necessary == 1%>
|
||||
<span class="ur_required" title="必答">*</span>
|
||||
<%end%>
|
||||
(单行文字)
|
||||
</div>
|
||||
<a href="#" class="ur_icon_de" title="删除"></a>
|
||||
<a href="#" class="ur_icon_edit" title="编辑"></a>
|
||||
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
|
||||
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
|
||||
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a>
|
||||
<div class="cl"></div>
|
||||
<div class="ur_inputs">
|
||||
<input class="ur_text ur_textbox" type="text" size="" maxlength=""value="">
|
||||
|
|
|
@ -1,10 +1,26 @@
|
|||
$("#new_poll_question").html("");
|
||||
$("#poll_content").append("<div id='poll_questions_<%= @poll_questions.id%>'>" +
|
||||
"<div id='show_poll_questions_<%= @poll_questions.id %>'>" +
|
||||
"<% if @poll_questions.question_type == 1%>" +
|
||||
"<%= escape_javascript(render :partial => 'show_MC', :locals => {:poll_question => @poll_questions}) %>" +
|
||||
"<% elsif @poll_questions.question_type == 2%>" +
|
||||
"<%= escape_javascript(render :partial => 'show_MCQ', :locals => {:poll_question => @poll_questions}) %>" +
|
||||
"<% elsif @poll_questions.question_type == 3%>" +
|
||||
"<%= escape_javascript(render :partial => 'show_single', :locals => {:poll_question => @poll_questions}) %>" +
|
||||
"<% elsif @poll_questions.question_type == 4%>" +
|
||||
"<%= escape_javascript(render :partial => 'show_mulit', :locals => {:poll_question => @poll_questions}) %>" +
|
||||
"<% end%>" +
|
||||
"</div>" +
|
||||
"<div id='edit_poll_questions_<%= @poll_questions.id %>' style='display: none;'>" +
|
||||
"<% if @poll_questions.question_type == 1%>" +
|
||||
"<%= escape_javascript(render :partial => 'edit_MC', :locals => {:poll_question => @poll_questions}) %>" +
|
||||
"<% elsif @poll_questions.question_type == 2%>" +
|
||||
"<%= escape_javascript(render :partial => 'edit_MCQ', :locals => {:poll_question => @poll_questions}) %>" +
|
||||
"<% elsif @poll_questions.question_type == 3%>" +
|
||||
"<%= escape_javascript(render :partial => 'edit_single', :locals => {:poll_question => @poll_questions}) %>" +
|
||||
"<% elsif @poll_questions.question_type == 4%>" +
|
||||
"<%= escape_javascript(render :partial => 'edit_mulit', :locals => {:poll_question => @poll_questions}) %>" +
|
||||
"<% end%>" +
|
||||
"</div>" +
|
||||
"</div>");
|
||||
|
||||
|
|
|
@ -11,34 +11,46 @@
|
|||
<div class="cl"></div>
|
||||
<div class="polls_list">
|
||||
<% @polls.each do |poll|%>
|
||||
<ul id="polls_<%= poll.id %>">
|
||||
<li>
|
||||
<% if has_commit_poll?(poll.id ,User.current) %>
|
||||
<sapn class="polls_title fl"> <%= poll.polls_name %></sapn>
|
||||
<% else %>
|
||||
<%= link_to poll.polls_name, poll_path(poll.id), :class => "polls_title fl" %>
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
<%if @is_teacher%>
|
||||
<%= link_to l(:label_statistical_results), statistics_result_poll_path(poll.id), :class => "pollsbtn fl ml10"%>
|
||||
<% end%>
|
||||
</li>
|
||||
<li>
|
||||
<% if @is_teacher%>
|
||||
<%= link_to(l(:button_delete), poll,
|
||||
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml20 mr10") %>
|
||||
<% end%>
|
||||
</li>
|
||||
<li>
|
||||
<% if @is_teacher%>
|
||||
<%= link_to l(:button_edit), edit_poll_path(poll.id), :class => "polls_de fr ml20"%>
|
||||
<% end%>
|
||||
</li>
|
||||
<li class="polls_date fr">
|
||||
<%= format_time poll.created_at%>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<% unless !@is_teacher && poll.polls_status != 2 %>
|
||||
<ul id="polls_<%= poll.id %>">
|
||||
<li>
|
||||
<% if @is_teacher %>
|
||||
<% if has_commit_poll?(poll.id ,User.current) %>
|
||||
<sapn class="polls_title fl"> <%= poll.polls_name %></sapn>
|
||||
<% else %>
|
||||
<%= link_to poll.polls_name, poll_path(poll.id), :class => "polls_title fl" %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if has_commit_poll?(poll.id ,User.current) && poll.polls_status == 2 %>
|
||||
<sapn class="polls_title fl"> <%= poll.polls_name %></sapn>
|
||||
<% elsif (!has_commit_poll?(poll.id ,User.current)) && poll.polls_status == 2 %>
|
||||
<%= link_to poll.polls_name, poll_path(poll.id), :class => "polls_title fl" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
<%if @is_teacher%>
|
||||
<%= link_to l(:label_statistical_results), statistics_result_poll_path(poll.id), :class => "pollsbtn fl ml10"%>
|
||||
<% end%>
|
||||
</li>
|
||||
<li>
|
||||
<% if @is_teacher && poll.polls_status == 1 #新建状态的问卷可删除%>
|
||||
<%= link_to(l(:button_delete), poll,
|
||||
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml20 mr10") %>
|
||||
<% end%>
|
||||
</li>
|
||||
<li>
|
||||
<% if @is_teacher && poll.polls_status == 1 #新建状态的问卷可编辑%>
|
||||
<%= link_to l(:button_edit), edit_poll_path(poll.id), :class => "polls_de fr ml20"%>
|
||||
<% end%>
|
||||
</li>
|
||||
<li class="polls_date fr">
|
||||
<%= format_time poll.created_at%>
|
||||
</li>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<div class="cl"></div>
|
||||
<% end%>
|
||||
|
||||
|
|
|
@ -72,7 +72,10 @@
|
|||
poll_question_id: <%= pq.id %>
|
||||
},
|
||||
success: function (data) {
|
||||
obj.checked = true;
|
||||
var dataObj = eval(data);
|
||||
obj.checked = true;
|
||||
var span = $('#percent');
|
||||
span.html(dataObj.percent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -118,7 +121,8 @@
|
|||
poll_question_id: <%= pq.id %>
|
||||
},
|
||||
success: function (data) {
|
||||
if(data == "true")
|
||||
var dataObj = eval(data);
|
||||
if(dataObj.text == "true")
|
||||
{
|
||||
obj.checked = true;
|
||||
}
|
||||
|
@ -126,6 +130,8 @@
|
|||
{
|
||||
obj.checked = false;
|
||||
}
|
||||
var span = $('#percent');
|
||||
span.html(dataObj.percent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -165,6 +171,9 @@
|
|||
vote_text: obj.value
|
||||
},
|
||||
success: function (data) {
|
||||
var dataObj = eval(data);
|
||||
var span = $('#percent');
|
||||
span.html(dataObj.percent);
|
||||
// obj.value = data;
|
||||
}
|
||||
});
|
||||
|
@ -198,7 +207,17 @@
|
|||
vote_text: obj.innerHTML
|
||||
},
|
||||
success: function (data) {
|
||||
// obj.value = data;
|
||||
var dataObj = eval(data);
|
||||
if(dataObj.text != 'failure')
|
||||
{
|
||||
var span = $('#percent');
|
||||
span.html(dataObj.percent);
|
||||
}
|
||||
else
|
||||
{
|
||||
alert("error");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -217,10 +236,12 @@
|
|||
</ul>
|
||||
<div class="cl"></div>
|
||||
<div class="ur_buttons" style="width: 100px;">
|
||||
<%= link_to "提交",commit_poll_poll_path(@poll), :method => :post,:class => "ur_button",:format => 'js',:remote=>true %>
|
||||
<% if @poll.polls_status == 2 %>
|
||||
<%= link_to "提交",commit_poll_poll_path(@poll), :method => :post,:class => "ur_button",:format => 'js',:remote=>true %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="ur_progress_text">答题已完成 <strong class="ur_progress_number">0%</strong> </div>
|
||||
<div class="ur_progress_text">答题已完成 <strong class="ur_progress_number"><span id="percent"><%= format "%.2f" ,@percent %></span>%</strong> </div>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,6 +1,22 @@
|
|||
$("#poll_questions_<%= @poll_question.id%>").html("<div id='show_poll_questions_<%= @poll_question.id %>'>" +
|
||||
"<%= escape_javascript(render :partial => 'show_MC', :locals => {:poll_question => @poll_question}) %>" +
|
||||
"<% if @poll_question.question_type == 1%>" +
|
||||
"<%= escape_javascript(render :partial => 'show_MC', :locals => {:poll_question => @poll_question}) %>" +
|
||||
"<% elsif @poll_question.question_type == 2%>" +
|
||||
"<%= escape_javascript(render :partial => 'show_MCQ', :locals => {:poll_question => @poll_question}) %>" +
|
||||
"<% elsif @poll_question.question_type == 3%>" +
|
||||
"<%= escape_javascript(render :partial => 'show_single', :locals => {:poll_question => @poll_question}) %>" +
|
||||
"<% elsif @poll_question.question_type == 4%>" +
|
||||
"<%= escape_javascript(render :partial => 'show_mulit', :locals => {:poll_question => @poll_question}) %>" +
|
||||
"<% end%>" +
|
||||
"</div>" +
|
||||
"<div id='edit_poll_questions_<%= @poll_question.id %>' style='display: none;'>" +
|
||||
"<%= escape_javascript(render :partial => 'edit_MC', :locals => {:poll_question => @poll_question}) %>" +
|
||||
"<% if @poll_question.question_type == 1%>" +
|
||||
"<%= escape_javascript(render :partial => 'edit_MC', :locals => {:poll_question => @poll_question}) %>" +
|
||||
"<% elsif @poll_question.question_type == 2%>" +
|
||||
"<%= escape_javascript(render :partial => 'edit_MCQ', :locals => {:poll_question => @poll_question}) %>" +
|
||||
"<% elsif @poll_question.question_type == 3%>" +
|
||||
"<%= escape_javascript(render :partial => 'edit_single', :locals => {:poll_question => @poll_question}) %>" +
|
||||
"<% elsif @poll_question.question_type == 4%>" +
|
||||
"<%= escape_javascript(render :partial => 'edit_mulit', :locals => {:poll_question => @poll_question}) %>" +
|
||||
"<% end%>" +
|
||||
"</div>");
|
||||
|
|
Loading…
Reference in New Issue