Merge branch 'Poll' of http://repository.trustie.net/xianbo/trustie2 into Poll
This commit is contained in:
commit
30a058133d
|
@ -60,12 +60,14 @@ class PollController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
@poll.polls_name = params[:polls_name]
|
||||
@poll.polls_name = params[:polls_name].empty? ? l(:label_poll_title) : params[:polls_name]
|
||||
@poll.polls_description = params[:polls_description].empty? ? l(:label_poll_description) : params[:polls_description]
|
||||
if @poll.save
|
||||
respond_to do |format|
|
||||
format.html { redirect_to poll_index_url(:polls_type => @course.class.to_s, :polls_group_id => @course.id) }
|
||||
format.js
|
||||
end
|
||||
else
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -87,7 +89,7 @@ class PollController < ApplicationController
|
|||
def create_poll_question
|
||||
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,
|
||||
: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
|
||||
|
@ -98,7 +100,7 @@ class PollController < ApplicationController
|
|||
answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1]
|
||||
question_option = {
|
||||
:answer_position => i,
|
||||
:answer_text => params[:question_answer].values[i-1]
|
||||
:answer_text => answer
|
||||
}
|
||||
@poll_questions.poll_answers.new question_option
|
||||
end
|
||||
|
@ -110,6 +112,32 @@ class PollController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#修改单选题
|
||||
def update_poll_question
|
||||
@poll_question = PollQuestion.find params[:poll_question]
|
||||
@poll = @poll_question.poll
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
#删除单选题
|
||||
def delete_poll_question
|
||||
@poll_question = PollQuestion.find params[:poll_question]
|
||||
@poll = @poll_question.poll
|
||||
poll_questions = @poll.poll_questions.where("question_number > #{@poll_question.question_number}")
|
||||
poll_questions.each do |question|
|
||||
question.question_number -= 1
|
||||
question.save
|
||||
end
|
||||
if @poll_question && @poll_question.destroy
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#提交答案
|
||||
def commit_answer
|
||||
pq = PollQuestion.find(params[:poll_question_id])
|
||||
|
|
|
@ -1,45 +1,31 @@
|
|||
<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>
|
||||
<div>
|
||||
<!--编辑单选start-->
|
||||
<div class="ur_editor radio">
|
||||
<div class="ur_editor_title">
|
||||
<label>问题: </label>
|
||||
<input type="hidden" name="question_type" value="1"/>
|
||||
<input class="ur_question_title" type="text" name="poll_questions_title" placeholder="请输入单选题标题"/>
|
||||
<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'></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'></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>
|
||||
<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" 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>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<%= form_for(poll_question,:url => update_poll_question_poll_index_path(:poll_question => poll_question.id),:remote => true) do |f|%>
|
||||
<!--编辑单选start-->
|
||||
<div class="ur_editor radio">
|
||||
<div class="ur_editor_title">
|
||||
<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>
|
||||
<!--编辑单选 end-->
|
||||
<div class="ur_editor_content">
|
||||
<ul>
|
||||
<% 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" 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>
|
||||
<!--编辑单选 end-->
|
||||
<% end%>
|
|
@ -1,21 +1,15 @@
|
|||
<script type="text/javascript">
|
||||
function regexPollsTitle()
|
||||
{
|
||||
var polls_title = $.trim($("#polls_title").val());
|
||||
alert(polls_title);
|
||||
}
|
||||
</script>
|
||||
<div class="ur_editor ur_title_editor"> <!--编辑头部start-->
|
||||
<div class="ur_title_editor_title">
|
||||
<input type="text" name="title" id="polls_title" class="input_title" placeholder="问卷标题" onkeyup="regexPollsTitle();"/>
|
||||
</div>
|
||||
<div class="ur_title_editor_prefix">
|
||||
<textarea name="prefix" class="textarea_editor" placeholder="问卷描述">
|
||||
</textarea>
|
||||
</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 @poll,:remote => true do |f|%>
|
||||
<div class="ur_editor ur_title_editor"> <!--编辑头部start-->
|
||||
<div class="ur_title_editor_title">
|
||||
<input type="text" 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" 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,45 @@
|
|||
<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>
|
||||
<div>
|
||||
<!--编辑单选start-->
|
||||
<div class="ur_editor radio">
|
||||
<div class="ur_editor_title">
|
||||
<label>问题: </label>
|
||||
<input type="hidden" name="question_type" value="1"/>
|
||||
<input class="ur_question_title" type="text" name="poll_questions_title" id="poll_questions_title" placeholder="请输入单选题标题"/>
|
||||
<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'></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'></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>
|
||||
<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" 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>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<!--编辑单选 end-->
|
||||
</div>
|
||||
<% end%>
|
|
@ -0,0 +1,33 @@
|
|||
<div><!--编辑多选start-->
|
||||
<div class="ur_editor checkbox">
|
||||
<div class="ur_editor_title">
|
||||
<label >问题: </label>
|
||||
<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>
|
||||
</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>
|
||||
</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>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div><!--编辑多选 end-->
|
|
@ -0,0 +1,18 @@
|
|||
<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>
|
||||
</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">确定</a>
|
||||
<a class="btn_cancel" data-button="cancel">取消</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div><!--编辑多行文字end-->
|
|
@ -0,0 +1,13 @@
|
|||
<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-->
|
|
@ -0,0 +1,10 @@
|
|||
<% 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} %>
|
||||
</div>
|
||||
<div id="edit_poll_questions_<%= poll_question.id %>" style="display: none;">
|
||||
<%= render :partial => 'edit_MC', :locals => {:poll_question => poll_question} %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
|
@ -4,16 +4,42 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>问卷调查_问卷编辑</title>
|
||||
<%= stylesheet_link_tag 'polls', :media => 'all' %>
|
||||
<%#= javascript_include_tag "polls" %>
|
||||
|
||||
<script type="text/javascript">
|
||||
function add_MC(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_MC') %>");}
|
||||
function add_MCQ(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_MCQ') %>");}
|
||||
function add_single(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_single') %>");}
|
||||
function add_mulit(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_mulit') %>");}
|
||||
function add_MC(){
|
||||
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MC') %>");
|
||||
$("#poll_questions_title").focus();
|
||||
}
|
||||
function add_MCQ(){
|
||||
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MCQ') %>");
|
||||
$("#poll_questions_title").focus();
|
||||
}
|
||||
function add_single(){
|
||||
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_single') %>");
|
||||
$("#poll_questions_title").focus();
|
||||
}
|
||||
function add_mulit(){
|
||||
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_mulit') %>");
|
||||
$("#poll_questions_title").focus();
|
||||
}
|
||||
//问卷头
|
||||
function pollsCancel(){$("#polls_head_edit").hide();$("#polls_head_show").show();}
|
||||
function pollsEdit(){$("#polls_head_edit").show();$("#polls_head_show").hide();}
|
||||
//
|
||||
function pollQuestionCancel(question_id){
|
||||
$("#show_poll_questions_"+question_id).show();
|
||||
$("#edit_poll_questions_"+question_id).hide();
|
||||
}
|
||||
function pollQuestionEdit(question_id){
|
||||
$("#show_poll_questions_"+question_id).hide();
|
||||
$("#edit_poll_questions_"+question_id).show();
|
||||
$("#poll_questions_title_"+question_id).focus();
|
||||
}
|
||||
//单选题
|
||||
function add_single_answer(doc)
|
||||
{
|
||||
doc.parent().after("<li class='ur_item'><label>选项<span class='ur_index'></span>:</label><input type='text' name='question_answer["+(doc.parent().siblings("li").length + 1)+"]' placeholder='新建选项'/>" +
|
||||
doc.parent().after("<li class='ur_item'><label>选项<span class='ur_index'></span>:</label><input type='text' name='question_answer["+new Date().getTime()+"]' 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>");
|
||||
}
|
||||
|
@ -60,15 +86,21 @@
|
|||
<div class="cl"></div>
|
||||
</div><!--选项 end-->
|
||||
|
||||
<%= render :partial => 'edit_head'%>
|
||||
|
||||
<div>
|
||||
<% @poll.poll_questions.each do |poll_question|%>
|
||||
<%= render :partial => 'show_MC', :locals => {:poll_question => poll_question} %>
|
||||
<% 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 => 'edit_MC'%>
|
||||
<%= render :partial => 'poll_content', :locals => {:poll => @poll}%>
|
||||
</div>
|
||||
|
||||
<!-- 新增问题 -->
|
||||
<div id="new_poll_question">
|
||||
</div>
|
||||
|
||||
<div class="ur_buttons">
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
<%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" >
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<div class="ur_page_head ur_editor02" ><!--头部显示 start-->
|
||||
<h1 class="ur_page_title">标题标题标题标题标题标题标题</h1>
|
||||
<p class="ur_prefix_content">描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述
|
||||
描述描述描述描述描述描述描述描述描述描述描述描述
|
||||
<div class="ur_page_head ur_editor02"><!--头部显示 start-->
|
||||
<a href="#" class="ur_icon_edit" title="编辑" onclick="pollsEdit();"></a>
|
||||
<h1 class="ur_page_title" id="polls_name_h">
|
||||
<%= poll.polls_name%>
|
||||
</h1>
|
||||
<p class="ur_prefix_content" id="polls_description_p">
|
||||
<%= @poll.polls_description%>
|
||||
</p>
|
||||
<a href="#" class="ur_icon_edit" title="编辑"></a>
|
||||
<div class="cl"></div>
|
||||
</div><!--头部显示 end-->
|
|
@ -0,0 +1,10 @@
|
|||
$("#new_poll_question").html("");
|
||||
$("#poll_content").append("<div id='poll_questions_<%= @poll_questions.id%>'>" +
|
||||
"<div id='show_poll_questions_<%= @poll_questions.id %>'>" +
|
||||
"<%= escape_javascript(render :partial => 'show_MC', :locals => {:poll_question => @poll_questions}) %>" +
|
||||
"</div>" +
|
||||
"<div id='edit_poll_questions_<%= @poll_questions.id %>' style='display: none;'>" +
|
||||
"<%= escape_javascript(render :partial => 'edit_MC', :locals => {:poll_question => @poll_questions}) %>" +
|
||||
"</div>" +
|
||||
"</div>");
|
||||
|
|
@ -0,0 +1 @@
|
|||
$("#poll_content").html("<%= escape_javascript(render :partial => 'poll_content', :locals => {:poll => @poll}) %>");
|
|
@ -0,0 +1,6 @@
|
|||
$("#polls_title").val("<%= @poll.polls_name%>");
|
||||
$("#polls_description").val("<%= @poll.polls_description %>");
|
||||
$("#polls_name_h").html("<%= @poll.polls_name %>");
|
||||
$("#polls_description_p").html("<%= @poll.polls_description %>");
|
||||
$("#polls_head_edit").hide();
|
||||
$("#polls_head_show").show();
|
|
@ -2251,5 +2251,7 @@ zh:
|
|||
label_mulit: 多行文字
|
||||
label_enter_single_title: 请输入单选题标题
|
||||
label_new_answer: 新建选项
|
||||
label_poll_title: 问卷标题
|
||||
label_poll_description: 问卷描述
|
||||
|
||||
|
||||
|
|
|
@ -65,6 +65,10 @@ RedmineApp::Application.routes.draw do
|
|||
post 'create_poll_question'
|
||||
post 'commit_poll'
|
||||
end
|
||||
collection do
|
||||
delete 'delete_poll_question'
|
||||
post 'update_poll_question'
|
||||
end
|
||||
end
|
||||
|
||||
resources :contest_notification
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
function add_MC(){
|
||||
var now = new Date().getTime();
|
||||
$("#poll_content").append("<div id='new_poll_question_" + now + "'>"+
|
||||
"<form accept-charset='UTF-8' action='/poll/2/create_poll_question' class='new_poll_question' data-remote='true' id='new_poll_question' method='post'>"+
|
||||
"<div>" +
|
||||
"<div class='ur_editor radio'>" +
|
||||
"<div class='ur_editor_title'>" +
|
||||
"<label>问题: </label>" +
|
||||
"<input type='hidden' name='question_type' value='1'/>" +
|
||||
"<input class='ur_question_title' type='text' name='poll_questions_title' placeholder='请输入单选题标题'/>" +
|
||||
"<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'></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'></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>" +
|
||||
"<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' onclick='$(this).parent().parent().parent().parent().submit();'>确定</a>" +
|
||||
"<a class='btn btn_light btn_cancel' data-button='cancel' onclick='$("+ '"#new_poll_question_' + now + '"' +").remove();'>取消</a>" +
|
||||
"</div>" +
|
||||
"<div class='cl'></div>" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"</form>" +
|
||||
"</div>");
|
||||
}
|
||||
function add_MCQ(){$("#poll_content").append("<%= escape_javascript(render :partial => 'new_MCQ') %>");}
|
||||
function add_single(){$("#poll_content").append("<%= escape_javascript(render :partial => 'new_single') %>");}
|
||||
function add_mulit(){$("#poll_content").append("<%= escape_javascript(render :partial => 'new_mulit') %>");}
|
||||
//问卷头
|
||||
function pollsCancel(){$("#polls_head_edit").hide();$("#polls_head_show").show();}
|
||||
function pollsEdit(){$("#polls_head_edit").show();$("#polls_head_show").hide();}
|
||||
//单选题
|
||||
function add_single_answer(doc)
|
||||
{
|
||||
doc.parent().after("<li class='ur_item'><label>选项<span class='ur_index'></span>:</label><input type='text' name='question_answer["+new Date().getTime()+"]' 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>");
|
||||
}
|
||||
function remove_single_answer(doc)
|
||||
{
|
||||
if(doc.parent().siblings("li").length == 0){doc.parent().parent().parent().parent().parent().parent().remove();}else{doc.parent().remove();}
|
||||
}
|
Loading…
Reference in New Issue