socialforge/app/views/poll/_poll_form.html.erb

682 lines
34 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<%= stylesheet_link_tag 'polls', :media => 'all' %>
<script type="text/javascript">
//编辑问卷描述之后
var popWindow ; //弹出框的引用
var importPollPopWindow; //选择导入的弹出框引用
function edit_head(){
$("#polls_description").val($("#polls_description_div").html());
}
$(function(){
//点击空白处
$(document).bind('click',function(e){
//弹出框非空 不是a标签 点击的不是弹出框 ,那么弹出框就会隐藏
if(popWindow && e.target.nodeName != 'A' && !popWindow.is(e.target) && popWindow.has(e.target).length === 0){ // Mark 1
popWindow.css('display', 'none');
}
if(importPollPopWindow && e.target.nodeName != 'A' && !importPollPopWindow.is(e.target) && importPollPopWindow.has(e.target).length === 0){
importPollPopWindow.css('display', 'none');
}
});
})
function dismiss(quest_type,quest_id){
popWindow = $("#div_"+quest_type+"_"+quest_id);
if(popWindow){
popWindow.css('display', 'none');
}
}
function chooseQuestionType(quest_type,quest_id){
//quest_type 分为 mc mcq single multi
//quest_id 是quetion的id 下同
if(popWindow){
popWindow.css('display', 'none');
}
popWindow = $("#div_"+quest_type+"_"+quest_id);
$("#div_"+quest_type+"_"+quest_id).click(function(e){
e.stopPropagation(); //组织冒泡到document.body中去
});
$("#div_"+quest_type+"_"+quest_id).css("position", "absolute");
$("#div_"+quest_type+"_"+quest_id).css("top", $("#add_"+quest_type+"_"+quest_id).offset().top+30);
$("#div_"+quest_type+"_"+quest_id).css("left", $("#add_"+quest_type+"_"+quest_id).offset().left-10);
if( $("#div_"+quest_type+"_"+quest_id).css('display') == 'block') {
$("#div_"+quest_type+"_"+quest_id).css('display', 'none');
}
else{
$("#div_"+quest_type+"_"+quest_id).css('display', 'block');
}
}
function add_MC(){
var forms = $("form.new_poll_question");
if($("#polls_head_edit").is(":visible")){
alert("请先保存问卷标题及问卷描述。");
}else if(forms.length > 0){
alert("请先保存正在编辑的题目再新建。");
} else{
$("#new_poll_question_new").html("<%= escape_javascript(render :partial => 'new_MC') %>");
$("#poll_questions_title_new").focus();
}
}
function insert_MC(quest_type,quest_id){
var forms = $("form.new_poll_question");
if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") {
if(forms.length > 0){
alert("请先保存正在编辑的题目再新建。");
} else{
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
'<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>'+
' <div class="questionEditContainer"> '+
'<div class="ur_editor_title"> '+
'<label class="questionLabel mt8">问题:&nbsp;&nbsp;</label>'+
'<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+
'<input type="hidden" name="question_type" value="1"/>'+
'<textarea maxlength="250" class="questionTitle w570" type="text" name="poll_questions_title" id="poll_questions_title" placeholder="请输入单选题题目"></textarea>'+
'<input type="checkbox" name="is_necessary" value="true" checked/>'+
'<label>必答</label>'+
'</div>'+
'<div class="ur_editor_content">'+
'<ul>'+
'<li class="ur_item new_answer">'+
'<label>选项<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input maxlength="200" type="text" name="question_answer[0]" placeholder="输入选项内容"/>'+
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
'</li>'+
'<div class="cl"></div>'+
'<li class="ur_item new_answer">'+
'<label>选项<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input maxlength="200" type="text" name="question_answer[1]" placeholder="输入选项内容"/>'+
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
'</li>'+
'<div class="cl"></div>'+
'<li class="ur_item new_answer">'+
'<label>选项<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input maxlength="200" type="text" name="question_answer[2]" placeholder="输入选项内容"/>'+
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
'</li>'+
'<div class="cl"></div>'+
'</ul>'+
'<ul>'+
'<li class="ur_item">'+
'<div class="dash-block new-question" onclick="add_single_answer($(this));">新建选项</div>'+
'</li>'+
'<div class="cl"></div>'+
'<li class="ur_item">'+
'<a href="javascript:void(0);" class="ml50 fontGrey2" onclick="add_other_answer($(this))">添加[其他]选项</a>'+
'</li>'+
'<div class="cl"></div>'+
'</ul>'+
'</div>'+
'<div class="ur_editor_footer">'+
'<a class="grey_btn fr borderRadius" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
'<%= l(:button_cancel)%>'+
'</a>'+
'<a class="blue_btn fr borderRadius mr5" data-button="ok" id="add_new_question">'+
'<%= l(:label_button_ok)%>'+
'</a>'+
'</div>'+
'<div class="cl"></div>'+
'</div>'+
'<% end%>'
);
$("#poll_questions_title").focus();
$("#add_new_question").one('click', function(){
add_poll_question($(this));
});
$(".questionTitle").on("input",function(){
$(this).height(30);
var scrollVal = $(this)[0].scrollHeight;
$(this).height(scrollVal);
});
}
}
else {
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");
}
}
function add_MCQ(){
var forms = $("form.new_poll_question");
if($("#polls_head_edit").is(":visible")){
alert("请先保存问卷标题及问卷描述。");
}else if(forms.length > 0){
alert("请先保存正在编辑的题目再新建。");
} else{
$("#new_poll_question_new").html("<%= escape_javascript(render :partial => 'new_MCQ') %>");
$("#poll_questions_title_new").focus();
}
}
function insert_MCQ(quest_type,quest_id){
var forms = $("form.new_poll_question");
if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") {
if(forms.length > 0){
alert("请先保存正在编辑的题目再新建。");
} else{
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
'<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>'+
'<div class="questionEditContainer">'+
'<div class="ur_editor_title">'+
'<label class="questionLabel mt8">问题:&nbsp;&nbsp;</label>'+
'<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+
'<input type="hidden" name="question_type" value="2"/>'+
'<textarea maxlength="250" class="questionTitle w570" type="text" name="poll_questions_title" id="poll_questions_title" placeholder="请输入多选题题目"></textarea>'+
'<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>&nbsp;&nbsp;&nbsp;</label>'+
'<input maxlength="200" type="text" name="question_answer[0]" placeholder="输入选项内容"/>'+
'<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>&nbsp;&nbsp;&nbsp;</label>'+
'<input maxlength="200" type="text" name="question_answer[1]" placeholder="输入选项内容"/>'+
'<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>&nbsp;&nbsp;&nbsp;</label>'+
'<input maxlength="200" type="text" name="question_answer[2]" placeholder="输入选项内容"/>'+
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
'</li>'+
'<div class="cl"></div>'+
'</ul>'+
'<ul>'+
'<li class="ur_item">'+
'<div class="fl mr30">'+
'<label>下限<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<select name="min_choices" class="poll-multiple-limit">'+
'<option value="0">不限</option>'+
'<option value="1">1</option>'+
'<option value="2">2</option>'+
'<option value="3">3</option>'+
'</select>'+
'<span class="fontGrey2">(可选)答题时最少选几项</span>'+
'</div>'+
'</li>'+
'<div class="cl"></div>'+
'<li class="ur_item">'+
'<div class="fl mr30">'+
'<label>上限<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>' +
'<select name="max_choices" class="poll-multiple-limit">'+
'<option value="0">不限</option>'+
'<option value="1">1</option>'+
'<option value="2">2</option>'+
'<option value="3">3</option>'+
'</select>'+
'<span class="fontGrey2">(可选)答题时最多选几项</span><span class="c_red ml10" id="choices_notice"></span>'+
'</div>' +
'</li>' +
'<div class="cl"></div>'+
'<li class="ur_item">'+
'<div class="dash-block new-question" onclick="add_single_answer($(this));">新建选项</div>'+
'</li>'+
'<div class="cl"></div>'+
'<li class="ur_item">'+
'<a href="javascript:void(0);" class="ml50 fontGrey2" onclick="add_other_answer($(this))">添加[其他]选项</a>'+
'</li>'+
'<div class="cl"></div>'+
'</ul>'+
'</div>'+
'<div class="ur_editor_footer">'+
'<a class="grey_btn fr borderRadius" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
'<%= l(:button_cancel)%>'+
'</a>'+
'<a class="blue_btn fr borderRadius mr5" data-button="ok" id="add_new_question">'+
'<%= l(:label_button_ok)%>'+
'</a>'+
'</div>'+
'<div class="cl"></div>'+
'</div>'+
'<% end%>'
);
$("#poll_questions_title").focus();
$("#add_new_question").one('click', function(){
add_poll_question($(this));
});
$(".questionTitle").on("input",function(){
$(this).height(30);
var scrollVal = $(this)[0].scrollHeight;
$(this).height(scrollVal);
});
}
}
else {
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");
}
}
function add_single(){
var forms = $("form.new_poll_question");
if($("#polls_head_edit").is(":visible")){
alert("请先保存问卷标题及问卷描述。");
}else if(forms.length > 0){
alert("请先保存正在编辑的题目再新建。");
} else{
$("#new_poll_question_new").html("<%= escape_javascript(render :partial => 'new_single') %>");
$("#poll_questions_title_new").focus();
}
}
function insert_SINGLE(quest_type,quest_id){
var forms = $("form.new_poll_question");
if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") {
if(forms.length > 0){
alert("请先保存正在编辑的题目再新建。");
} else{
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
'<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>'+
'<div class="questionEditContainer">'+
'<div class="ur_editor_title">'+
'<label for="ur_question_title" class="questionLabel mt8">问题:&nbsp;&nbsp;</label>'+
'<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+
'<input type="hidden" name="question_type" value="3"/>'+
'<textarea maxlength="250" id="poll_questions_title" class="questionTitle w570" contenteditable="true" type="text" name="poll_questions_title" placeholder="请输入单行主观题"></textarea>'+
'<input type="checkbox" name="is_necessary" value="true" checked/>'+
'<label for="ur_question_require">必答</label>'+
'</div>'+
'<div class="ur_editor_footer">'+
'<a class="grey_btn fr borderRadius" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
'<%= l(:button_cancel)%>'+
'</a>'+
'<a class="blue_btn fr borderRadius mr5" data-button="ok" id="add_new_question">'+
'<%= l(:label_button_ok)%>'+
'</a>'+
'</div>'+
'<div class="cl"></div>'+
'</div>'+
'<% end%>'
);
$("#poll_questions_title").focus();
$("#add_new_question").one('click', function(){
add_poll_question($(this));
});
$(".questionTitle").on("input",function(){
$(this).height(30);
var scrollVal = $(this)[0].scrollHeight;
$(this).height(scrollVal);
});
}
}
else {
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");
}
}
function add_mulit(){
var forms = $("form.new_poll_question");
if($("#polls_head_edit").is(":visible")){
alert("请先保存问卷标题及问卷描述。");
}else if(forms.length > 0){
alert("请先保存正在编辑的题目再新建。");
} else{
$("#new_poll_question_new").html("<%= escape_javascript(render :partial => 'new_mulit') %>");
$("#poll_questions_title_new").focus();
}
}
function insert_MULIT(quest_type,quest_id){
var forms = $("form.new_poll_question");
if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") {
if(forms.length > 0){
alert("请先保存正在编辑的题目再新建。");
} else{
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
'<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>'+
'<div class="questionEditContainer">'+
'<div class="ur_editor_title">'+
'<label for="ur_question_title" class="questionLabel mt8">问题:&nbsp;&nbsp;</label>'+
'<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+
'<input type="hidden" name="question_type" value="4"/>'+
'<textarea maxlength="250" id="poll_questions_title" class="questionTitle w570" contenteditable="true" type="text" name="poll_questions_title" placeholder="请输入多行主观题的问题描述"></textarea>'+
'<label><input type="checkbox" name="is_necessary" value="true" checked/>'+
'必答</label>'+
'</div>'+
'<div class="ur_editor_content">'+
'<ul>'+
'<li class="ur_item new_answer">'+
'<label class="ml50">问题<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input placeholder="请输入主观题分题的问题" class="w520" type="text" name="question_answer[0]">'+
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>'+
'</li>'+
'<div class="cl"></div>'+
'<li class="ur_item new_answer">'+
'<label class="ml50">问题<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input placeholder="请输入主观题分题的问题" class="w520" type="text" name="question_answer[1]">'+
'<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> </li>'+
'<div class="cl"></div>'+
'</ul>'+
'<ul>'+
'<li class="ur_item">'+
'<div class="dash-block new-subjective w520" onclick="add_multi_question($(this))">新建选项</div>'+
'</li>'+
'<div class="cl"></div>'+
'</ul>'+
'</div>'+
'<div class="ur_editor_footer">'+
'<a class="grey_btn fr borderRadius" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
'<%= l(:button_cancel)%>'+
'</a>'+
'<a class="blue_btn fr borderRadius mr5" data-button="ok" id="add_new_question">'+
'<%= l(:label_button_ok)%>'+
'</a>'+
'</div>'+
'<div class="cl"></div>'+
'</div>'+
'<% end%>'
);
$("#poll_questions_title").focus();
$("#add_new_question").one('click', function(){
add_poll_question($(this));
});
$(".questionTitle").on("input",function(){
$(this).height(30);
var scrollVal = $(this)[0].scrollHeight;
$(this).height(scrollVal);
});
}
}
else {
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");
}
}
//选择导入调查问卷
function importPoll(){
importPollPopWindow = $("#import_poll");
$("#import_poll").css("position", "absolute");
$("#import_poll").css("top", $("#import_btn").offset().top+30);
$("#import_poll").css("left", $("#import_btn").offset().left-65);
$("#import_poll").css("display","block")
}
function remote_import(){
importPollPopWindow.css('display', 'none');
if($("#import_poll").val() === 0){
return;
}else{
if(confirm("确认导入问卷"+$("#import_poll").find("option:selected").text()+"?")){
$("#import_form").submit();
}else{
return;
}
}
}
//添加标题时确定按钮
function add_poll_question(doc)
{
var title = $.trim($("#poll_questions_title").val());
if(title.length == 0){
alert("标题不能为空");
doc.one('click', function(){
add_poll_question($(this));
});
}else if(doc.parent().parent().find("select[name='min_choices']").length > 0 && doc.parent().parent().find("select[name='min_choices']").find("option:selected").val() != '0' && doc.parent().parent().find("select[name='max_choices']").length > 0 && doc.parent().parent().find("select[name='max_choices']").find("option:selected").val() != '0' && parseInt(doc.parent().parent().find("select[name='min_choices']").find("option:selected").val()) > parseInt(doc.parent().parent().find("select[name='max_choices']").find("option:selected").val())){
doc.parent().parent().find("#choices_notice").html("下限不能大于上限");
doc.one('click', function(){
add_poll_question($(this));
});
}else{
doc.parent().parent().find("#choices_notice").html("");
doc.parent().parent().parent().submit();
}
}
function add_poll_question_new(doc)
{
var title = $.trim($("#poll_questions_title_new").val());
if(title.length == 0){
alert("标题不能为空");
doc.one('click', function(){
add_poll_question_new($(this));
});
}else if(doc.parent().parent().find("select[name='min_choices']").length > 0 && doc.parent().parent().find("select[name='min_choices']").find("option:selected").val() != '0' && doc.parent().parent().find("select[name='max_choices']").length > 0 && doc.parent().parent().find("select[name='max_choices']").find("option:selected").val() != '0' && parseInt(doc.parent().parent().find("select[name='min_choices']").find("option:selected").val()) > parseInt(doc.parent().parent().find("select[name='max_choices']").find("option:selected").val())){
doc.parent().parent().find("#choices_notice").html("下限不能大于上限");
doc.one('click', function(){
add_poll_question_new($(this));
});
}
else{
doc.parent().parent().find("#choices_notice").html("");
doc.parent().parent().parent().submit();
}
}
//修改标题时确定按钮
function edit_poll_question(doc,id)
{
var title = $.trim($("#poll_questions_title_" + id).val());
if(title.length == 0){
alert("标题不能为空");
}else if(doc.parent().parent().find("select[name='min_choices']").length > 0 && doc.parent().parent().find("select[name='min_choices']").find("option:selected").val() != '0' && doc.parent().parent().find("select[name='max_choices']").length > 0 && doc.parent().parent().find("select[name='max_choices']").find("option:selected").val() != '0' && parseInt(doc.parent().parent().find("select[name='min_choices']").find("option:selected").val()) > parseInt(doc.parent().parent().find("select[name='max_choices']").find("option:selected").val())){
doc.parent().parent().find("#choices_notice").html("下限不能大于上限");
}else{
doc.parent().parent().find("#choices_notice").html("");
doc.parent().parent().parent().submit();
}
}
//问卷头
function pollsCancel(){$("#polls_head_edit").hide();$("#polls_head_show").show();}
function pollsSubmit(doc){
var title = $.trim($("#polls_title").val());
if(title.length == 0){alert("问卷标题不能为空");}else{doc.parent().parent().submit();}
}
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_multi_question(doc)
{
doc.parent().parent().prev().append("<li class='ur_item new_answer'><label class='ml50'>问题<span class='ur_index'></span>&nbsp;&nbsp;&nbsp;</label><input maxlength='200' style='width:520px;' type='text' name='question_answer["+new Date().getTime()+"]' placeholder='请输入主观题分题的问题'/>" +
"<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>"+
"</li><div class='cl'></div>");
}
//单选题
function add_single_answer(doc)
{
if (doc.parent().parent().prev().children('li:last').hasClass('other_answer')) {
doc.parent().parent().prev().children('li:last').before("<li class='ur_item new_answer'><label>选项<span class='ur_index'></span>&nbsp;&nbsp;&nbsp;</label><input maxlength='200' type='text' name='question_answer["+new Date().getTime()+"]' placeholder='输入选项内容'/>" +
"<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>"+
"</li><div class='cl'></div>");
} else {
doc.parent().parent().prev().append("<li class='ur_item new_answer'><label>选项<span class='ur_index'></span>&nbsp;&nbsp;&nbsp;</label><input maxlength='200' type='text' name='question_answer["+new Date().getTime()+"]' placeholder='输入选项内容'/>" +
"<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>"+
"</li><div class='cl'></div>");
}
// doc.parent().before("<li class='ur_item new_answer'><label>选项<span class='ur_index'></span>&nbsp;&nbsp;&nbsp;</label><input maxlength='200' type='text' name='question_answer["+new Date().getTime()+"]' placeholder='输入选项内容'/>" +
// "<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>"+
// "</li><div class='cl'></div>");
var count = doc.parent().parent().prev().children('li').length;
multiLimit(doc.parent().siblings("li").children("div").children("select:first"), count);
multiLimit(doc.parent().siblings("li").children("div").children("select:last"), count);
}
function remove_single_answer(doc)
{
var ul = doc.parent().parent();
if(doc.parent().siblings("li.new_answer").length == 0)
{
alert("至少有一个选项");
}
else
{
doc.parent().remove();
}
var count = ul.children('li').length;
multiLimit(ul.siblings("ul").children("li").children("div").children("select:first"), count);
multiLimit(ul.siblings("ul").children("li").children("div").children("select:last"), count);
}
//多选题答题限制数实时更新
function multiLimit(doc, count){
var upperLimit = $(".ur_editor_content .new_answer").size();
var option_count = doc.children('option').length;
if (option_count == 0){
doc.append("<option value='"+ 0 +"'>" + '' + "</option>");
}
var option_count = doc.children('option').length;
if(count > option_count - 1){
for(var i = option_count; i <= count; i++){
doc.append("<option value='"+ i +"'>" + i + "</option>");
}
} else if(count < option_count - 1){
for(var i = count + 1; i <= option_count - 1; i++){
doc.children("option[value='" + i + "']").remove();
}
}
}
//其他选项
function add_other_answer(doc)
{
if(doc.parent().parent().prev().children('li.other_answer').length == 0) {
doc.parent().parent().prev().append("<li class='ur_item new_answer other_answer'><label>其它<span class='ur_index'></span>&nbsp;&nbsp;&nbsp;</label><input maxlength='200' type='text' style='background-color:#f5f5f5;' readonly='readonly' name='question_other_answer' placeholder='由参加问卷的人输入内容'/>" +
"<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>"+
"</li><div class='cl'></div>");
}
var count = doc.parent().parent().prev().children('li').length;
multiLimit(doc.parent().siblings("li").children("div").children("select:first"), count);
multiLimit(doc.parent().siblings("li").children("div").children("select:last"), count);
}
function poll_cancel()
{
var htmlvalue = "<%= escape_javascript(render :partial => 'cancel_poll', locals: {:poll => @poll}) %>";
pop_box_new(htmlvalue,460,190);
}
function poll_save()
{
var forms = $("form.new_poll_question");
if($("#polls_head_edit").is(":visible")){
alert("请先保存问卷标题及问卷描述。");
}else if($.trim($("#polls_name_h").html()) == ""){
alert("问卷标题不能为空");
}else if(forms.length > 0){
alert("请先保存正在编辑的题目。");
} else {
if($("#show_result").is(":checked")) {
$.get(
'<%= save_poll_poll_path(@poll.id) %>'+'?show_result=1'
)
} else{
$.get(
'<%= save_poll_poll_path(@poll.id) %>'+'?show_result=0'
)
}
}
}
function poll_submit()
{
var forms = $("form.new_poll_question");
if($("#polls_head_edit").is(":visible")){
alert("请先保存问卷标题及问卷描述。");
}else if($.trim($("#polls_name_h").html()) == ""){
alert("问卷标题不能为空");
}else if(forms.length > 0){
alert("请先保存正在编辑的题目再发布。");
} else{
if($("#show_result").is(":checked")) {
var htmlvalue = "<%= escape_javascript(render :partial => 'poll_submit', locals: { :poll => @poll,:is_remote => false,:show_result=> 1}) %>";
} else{
var htmlvalue = "<%= escape_javascript(render :partial => 'poll_submit', locals: { :poll => @poll,:is_remote => false,:show_result=> 0}) %>";
}
pop_box_new(htmlvalue,460,190);
}
}
</script>
<div class="homepageRight mt0 ml10">
<div class="resources" id="polls">
<!-- 头部 -->
<div id="polls_head_show" style="<%=@poll.polls_name == "" ? 'display: none;' : '' %>">
<%= render :partial => 'show_head', :locals => {:poll => @poll}%>
</div>
<div id="polls_head_edit" style="<%=@poll.polls_name == "" ? '' : 'display: none;' %>">
<%= render :partial => 'edit_head', :locals => {:poll => @poll}%>
</div>
<!-- 问题 -->
<div id="poll_content">
<%= render :partial => 'poll_content', :locals => {:poll => @poll}%>
</div>
<div class="testQuestion">
<span class="fl mt10 mr18">题型</span>
<ul class="tabs_list fl">
<li class="tab_item02 mr95">
<a title="<%= l(:label_MC) %>" class="tab_icon icon_radio" onclick="add_MC();">
<%= l(:label_MC) %>
</a>
</li>
<li class="tab_item02 mr95" >
<a title="<%= l(:label_MCQ) %>" class=" tab_icon icon_checkbox" onclick="add_MCQ();">
<%= l(:label_MCQ) %>
</a>
</li>
<li class="tab_item02 " >
<a title="<%= l(:label_subjective) %>" class="tab_icon icon_text" onclick="add_single();">
<%= l(:label_subjective) %>
</a>
</li>
<!--<li class="tab_item02 " >-->
<!--<a title="<%#= l(:label_mulit)%>" class="tab_icon icon_textarea" onclick="add_mulit();">-->
<!--<%#= l(:label_mulit)%>-->
<!--</a>-->
<!--</li>-->
</ul>
<div class="cl"></div>
</div><!--选项 end-->
<!-- 新增问题 -->
<div id="new_poll_question_new">
</div>
<!--<div class="ur_buttons">-->
<!--<a class="ur_button_submit" onclick="poll_submit();">-->
<!--<%= l(:label_memo_create)%>-->
<!--</a>-->
<!--<div class="polls_cha">-->
<!--<input id="show_result" type="checkbox" checked name="show_result" value="1" >-->
<!--<label for="">允许学生查看调查结果</label>-->
<!--</div>-->
<!--</div>-->
<div class="tac">
<input name="show_result" value="1" type="checkbox" checked id="show_result">
<label for="">允许学生查看调查结果</label>
</div>
<div>
<!--<a href="javascript:void(0);" onclick="poll_cancel();" class="grey_btn fr borderRadius">取消</a>-->
<a href="javascript:void(0);" onclick="poll_save();" class="blue_btn fr borderRadius mr5">保存</a>
<a href="javascript:void(0);" onclick="poll_submit();" class="blue_btn fr borderRadius mr5" >发布</a>
</div>
<div class="cl"></div>
<!-- 新增问题 -->
<div id="import_poll" style="display: none">
<%= form_tag({:controller => 'poll', :action => 'import_poll', :to_id => @poll.id},:remote=>'true', :method => :get,:id=>"import_form") do %>
<%= select( :poll, :id, Poll.where("polls_group_id = #{@poll.polls_group_id} and polls_type='course' and id != #{@poll.id}").map{|c| [c.polls_name, c.id]}.unshift(["选择要导入的问卷",0]),
{ :include_blank => false,:selected=> 0,:class=>"w90"
},
{:onchange=>"remote_import();",:id=>"import_id",:name=>"import_id"}
)
%>
<% end%>
</select>
</div>
</div><!--编辑end-->
</div>