问卷的单选题
This commit is contained in:
parent
4de0105d99
commit
3217f84df2
|
@ -151,6 +151,13 @@ class PollController < ApplicationController
|
|||
@poll_questions.poll_answers.new question_option
|
||||
end
|
||||
end
|
||||
if params[:question_other_answer]
|
||||
question_option = {
|
||||
:answer_position => params[:question_answer].count + 1,
|
||||
:answer_text => ''
|
||||
}
|
||||
@poll_questions.poll_answers.new question_option
|
||||
end
|
||||
# 如果是插入的话,那么从插入的这个id以后的question_num都将要+1
|
||||
if params[:quest_id]
|
||||
@is_insert = true
|
||||
|
|
|
@ -1,37 +1,47 @@
|
|||
<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>
|
||||
<!--新建单选start-->
|
||||
<% insert_begin = insert_begin %>
|
||||
<div class="ur_editor radio">
|
||||
<div class="questionContainer">
|
||||
<div class="ur_editor_title">
|
||||
<label>问题: </label>
|
||||
<input type="hidden" name="question_type" value="1"/>
|
||||
<input maxlength="250" class="ur_question_title" type="text" name="poll_questions_title" id="poll_questions_title_new" placeholder="请输入单选题标题"/>
|
||||
<input maxlength="250" class="questionTitle W600" type="text" name="poll_questions_title" id="poll_questions_title_new" placeholder="请输入单选题题目"/>
|
||||
<input type="checkbox" name="is_necessary" value="true" checked/>
|
||||
<label>必答</label>
|
||||
</div>
|
||||
<div class="ur_editor_content">
|
||||
<ul id="que_ul">
|
||||
<li class='ur_item new_answer'>
|
||||
<label>选项<span class='ur_index'></span>: </label>
|
||||
<input maxlength="200" 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 new_answer'>
|
||||
<label>选项<span class='ur_index'></span>: </label>
|
||||
<input maxlength="200" 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 new_answer'>
|
||||
<label>选项<span class='ur_index'></span>: </label>
|
||||
<input maxlength="200" 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>
|
||||
<ul>
|
||||
<li class='ur_item'>
|
||||
<label>选项<span class='ur_index'></span>: </label>
|
||||
<input maxlength="200" 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 class="ur_item">
|
||||
<div class="dash-block new-question" onclick='add_single_answer($(this));'>新建选项</div>
|
||||
</li>
|
||||
<div class='cl'></div>
|
||||
<li class='ur_item'>
|
||||
<label>选项<span class='ur_index'></span>: </label>
|
||||
<input maxlength="200" 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 class="ur_item">
|
||||
<a href="javascript:void(0);" class="ml50 fontGrey2" onclick='add_other_answer($(this))'>添加[其他]选项</a>
|
||||
</li>
|
||||
<div class='cl'></div>
|
||||
<li class='ur_item'>
|
||||
<label>选项<span class='ur_index'></span>: </label>
|
||||
<input maxlength="200" 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>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
|
|
|
@ -323,13 +323,22 @@ function insert_MCQ(quest_type,quest_num,quest_id){
|
|||
//单选题
|
||||
function add_single_answer(doc)
|
||||
{
|
||||
doc.parent().after("<li class='ur_item'><label>选项<span class='ur_index'></span>: </label><input maxlength='200' 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>");
|
||||
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>: </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>: </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>: </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>");
|
||||
}
|
||||
function remove_single_answer(doc)
|
||||
{
|
||||
if(doc.parent().siblings("li").length == 0)
|
||||
if(doc.parent().siblings("li.new_answer").length == 0)
|
||||
{
|
||||
alert("选择题至少有一个选项");
|
||||
}
|
||||
|
@ -338,7 +347,15 @@ function insert_MCQ(quest_type,quest_num,quest_id){
|
|||
doc.parent().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>: </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>");
|
||||
}
|
||||
}
|
||||
function poll_submit()
|
||||
{
|
||||
var title = $.trim($("#polls_name_h").html());
|
||||
|
@ -378,9 +395,10 @@ function insert_MCQ(quest_type,quest_num,quest_id){
|
|||
<%= render :partial => 'poll_content', :locals => {:poll => @poll}%>
|
||||
</div>
|
||||
|
||||
<div class="tabs">
|
||||
<ul class="tabs_list">
|
||||
<li class="tab_item02 " >
|
||||
<div class="testQuestion">
|
||||
<span class="fl mt10 mr18">题型</span>
|
||||
<ul class="tabs_list fl">
|
||||
<li class="tab_item02 ">
|
||||
<a title="<%= l(:label_MC) %>" class="tab_icon icon_radio" onclick="add_MC();">
|
||||
<%= l(:label_MC) %>
|
||||
</a>
|
||||
|
|
|
@ -588,4 +588,7 @@ a:hover.sy_btn_blue{ background: #2788d0;}
|
|||
|
||||
/*状态提示图标*/
|
||||
.success-icon {background:url("/images/icons_ziliao.png") 0 -28px no-repeat; padding-left:25px;}
|
||||
.error-icon {background:url("/images/icons_ziliao.png") 0 -56px no-repeat; padding-left:25px;}
|
||||
.error-icon {background:url("/images/icons_ziliao.png") 0 -56px no-repeat; padding-left:25px;}
|
||||
|
||||
/*禁用*/
|
||||
.disabled {background-color:#f5f5f5;}
|
|
@ -545,4 +545,9 @@ a:hover.blueCir{ background:#3598db; color:#fff;}
|
|||
.homework-detail-tab li {float:left; width:100px; text-align:center; padding:3px 0; border-bottom:2px solid #ddd;}
|
||||
.homework-detail-tab li.selected {border-bottom:2px solid #f00;}
|
||||
.test-set-table, .test-set-table tr, .test-set-table th, .test-set-table td {border-collapse:collapse; text-align:left; border:1px solid #ddd; color:#484848;}
|
||||
.test-set-table th, .test-set-table td {padding:2px 5px;}
|
||||
.test-set-table th, .test-set-table td {padding:2px 5px;}
|
||||
|
||||
/*20160912问卷调查*/
|
||||
.new-question {width:324px; height:30px; color:#888; background-color:#fff; padding-left:5px; margin-left:46px; cursor:pointer;}
|
||||
.new-subjective {width:550px; height:30px; color:#888; background-color:#fff; padding-left:5px; margin-left:96px; cursor:pointer;}
|
||||
.questionnaire-input {height:30px; border:1px solid #cbcbcb; padding-left:5px;}
|
|
@ -1461,3 +1461,6 @@ a:hover.sy_btn_green{ background: #51a74f;}
|
|||
.flex-container {display:flex;}
|
||||
.flex-cell {flex:1;}
|
||||
.flex-cell:last-child {text-align:right;}
|
||||
|
||||
/*20160912问卷调查*/
|
||||
.dash-block {border:1px dashed #ddd;}
|
Loading…
Reference in New Issue