插入题目菜单显隐控制;多选题答题限制js

This commit is contained in:
Tim 2016-10-27 15:07:46 +08:00
parent c58fb36f44
commit ae0db01569
7 changed files with 42 additions and 41 deletions

View File

@ -68,16 +68,5 @@
add_poll_question_new($(this)); add_poll_question_new($(this));
}); });
}); });
var multiLimit = function(){
var upperLimit = $(".new_answer").size();
for(var i = 1; i <= upperLimit; i++){
$(".poll-multiple-limit").append("<option>" + i + "</option>");
}
}
multiLimit(); multiLimit();
$(".new-question").click(function(){
$(".poll-multiple-limit option").remove();
multiLimit();
});
</script> </script>

View File

@ -26,10 +26,14 @@
<% end %> <% end %>
<script> <script>
$(".poll-add").mouseover(function(){ $(".poll-add").mouseover(function(){
$(this).children().show(); $(this).next().show();
}); }).mouseout(function(){
$(".poll-add").mouseout(function(){ $(this).next().hide();
$(this).children().hide(); });
}); $(".poll-add-menu").mouseover(function(){
$(this).show();
}).mouseout(function(){
$(this).hide();
});
</script> </script>

View File

@ -463,6 +463,8 @@ function insert_MCQ(quest_type,quest_num,quest_id){
// 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='输入选项内容'/>" + // 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>"+ // "<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>"+
// "</li><div class='cl'></div>"); // "</li><div class='cl'></div>");
$(".poll-multiple-limit option").remove();
multiLimit();
} }
function remove_single_answer(doc) function remove_single_answer(doc)
{ {
@ -476,11 +478,17 @@ function insert_MCQ(quest_type,quest_num,quest_id){
} }
$(".poll-multiple-limit option").remove(); $(".poll-multiple-limit option").remove();
var upperLimit = $(".new_answer").size(); multiLimit();
}
//多选题答题限制数实时更新
function multiLimit(){
var upperLimit = $(".questionContainer .new_answer").size();
for(var i = 1; i <= upperLimit; i++){ for(var i = 1; i <= upperLimit; i++){
$(".poll-multiple-limit").append("<option>" + i + "</option>"); $(".poll-multiple-limit").append("<option>" + i + "</option>");
} }
} }
//其他选项 //其他选项
function add_other_answer(doc) function add_other_answer(doc)
{ {
@ -489,6 +497,9 @@ function insert_MCQ(quest_type,quest_num,quest_id){
"<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>"+ "<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>"+
"</li><div class='cl'></div>"); "</li><div class='cl'></div>");
} }
$(".poll-multiple-limit option").remove();
multiLimit();
} }
function poll_cancel() function poll_cancel()
{ {

View File

@ -8,13 +8,12 @@
</p> </p>
<a class="poll-up mb8" title="上移"></a> <a class="poll-up mb8" title="上移"></a>
<a class="poll-down mb8" title="下移"></a> <a class="poll-down mb8" title="下移"></a>
<a href="javascript:void(0);" class="poll-add pr mb8"> <a href="javascript:void(0);" class="poll-add mb8"></a>
<ul class="poll-add-menu fontGrey3"> <ul class="poll-add-menu fontGrey3">
<li><a href="javascript:void(0);" onclick=" dismiss('mc',<%=poll_question.id%>);insert_MC('mc',<%=poll_question.question_number%>,<%=poll_question.id%>);">单选题</a></li> <li><a href="javascript:void(0);" onclick=" dismiss('mc',<%=poll_question.id%>);insert_MC('mc',<%=poll_question.question_number%>,<%=poll_question.id%>);">单选题</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('mc',<%=poll_question.id%>);insert_MCQ('mc',<%=poll_question.question_number%>,<%=poll_question.id%>);">多选题</a></li> <li><a href="javascript:void(0);" onclick=" dismiss('mc',<%=poll_question.id%>);insert_MCQ('mc',<%=poll_question.question_number%>,<%=poll_question.id%>);">多选题</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('mc',<%=poll_question.id%>);insert_SINGLE('mc',<%=poll_question.question_number%>,<%=poll_question.id%>);">主观题</a></li> <li><a href="javascript:void(0);" onclick=" dismiss('mc',<%=poll_question.id%>);insert_SINGLE('mc',<%=poll_question.question_number%>,<%=poll_question.id%>);">主观题</a></li>
</ul> </ul>
</a>
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), <%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "poll-delete", :title => "删除") %> method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "poll-delete", :title => "删除") %>
</div> </div>

View File

@ -8,13 +8,12 @@
</p> </p>
<a class="poll-up mb8" title="上移"></a> <a class="poll-up mb8" title="上移"></a>
<a class="poll-down mb8" title="下移"></a> <a class="poll-down mb8" title="下移"></a>
<a href="javascript:void(0);" class="poll-add pr mb8"> <a href="javascript:void(0);" class="poll-add mb8"> </a>
<ul class="poll-add-menu fontGrey3"> <ul class="poll-add-menu fontGrey3">
<li><a href="javascript:void(0);" onclick=" dismiss('mcq',<%=poll_question.id%>);insert_MC('mcq',<%=poll_question.question_number%>,<%=poll_question.id%>);">单选题</a></li> <li><a href="javascript:void(0);" onclick=" dismiss('mcq',<%=poll_question.id%>);insert_MC('mcq',<%=poll_question.question_number%>,<%=poll_question.id%>);">单选题</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('mcq',<%=poll_question.id%>);insert_MCQ('mcq',<%=poll_question.question_number%>,<%=poll_question.id%>);">多选题</a></li> <li><a href="javascript:void(0);" onclick=" dismiss('mcq',<%=poll_question.id%>);insert_MCQ('mcq',<%=poll_question.question_number%>,<%=poll_question.id%>);">多选题</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('mcq',<%=poll_question.id%>);insert_SINGLE('mcq',<%=poll_question.question_number%>,<%=poll_question.id%>);">主观题</a></li> <li><a href="javascript:void(0);" onclick=" dismiss('mcq',<%=poll_question.id%>);insert_SINGLE('mcq',<%=poll_question.question_number%>,<%=poll_question.id%>);">主观题</a></li>
</ul> </ul>
</a>
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), <%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "poll-delete", :title => "删除") %> method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "poll-delete", :title => "删除") %>
</div> </div>

View File

@ -8,13 +8,12 @@
</p> </p>
<a class="poll-up mb8" title="上移"></a> <a class="poll-up mb8" title="上移"></a>
<a class="poll-down mb8" title="下移"></a> <a class="poll-down mb8" title="下移"></a>
<a href="javascript:void(0);" class="poll-add pr mb8"> <a href="javascript:void(0);" class="poll-add mb8"></a>
<ul class="poll-add-menu fontGrey3"> <ul class="poll-add-menu fontGrey3">
<li><a href="javascript:void(0);" onclick=" dismiss('single',<%=poll_question.id%>);insert_MC('single',<%=poll_question.question_number%>,<%=poll_question.id%>);">单选题</a></li> <li><a href="javascript:void(0);" onclick=" dismiss('single',<%=poll_question.id%>);insert_MC('single',<%=poll_question.question_number%>,<%=poll_question.id%>);">单选题</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('single',<%=poll_question.id%>);insert_MCQ('single',<%=poll_question.question_number%>,<%=poll_question.id%>);">多选题</a></li> <li><a href="javascript:void(0);" onclick=" dismiss('single',<%=poll_question.id%>);insert_MCQ('single',<%=poll_question.question_number%>,<%=poll_question.id%>);">多选题</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('single',<%=poll_question.id%>);insert_SINGLE('single',<%=poll_question.question_number%>,<%=poll_question.id%>);">主观题</a></li> <li><a href="javascript:void(0);" onclick=" dismiss('single',<%=poll_question.id%>);insert_SINGLE('single',<%=poll_question.question_number%>,<%=poll_question.id%>);">主观题</a></li>
</ul> </ul>
</a>
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), <%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "poll-delete", :title => "删除") %> method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "poll-delete", :title => "删除") %>
</div> </div>
@ -27,7 +26,7 @@
<a class="poll-edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a> <a class="poll-edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a>
<div class="cl"></div> <div class="cl"></div>
<div class="ur_inputs"> <div class="ur_inputs">
<textarea type="text" size="" maxlength="" value="" style="width:640px; border:1px solid #ddd;" rows="3"></textarea> <textarea type="text" size="" maxlength="" value="" style="width:640px; border:1px solid #ddd;" rows="3" readonly="readonly"></textarea>
</div> </div>
</div> </div>
</div><!--单行文字展示 end--> </div><!--单行文字展示 end-->

View File

@ -574,7 +574,7 @@ a:hover.blueCir{ background:#3598db; color:#fff;}
.poll-delete:hover{ background:url(/images/course/icons.png) -17px -343px no-repeat;} .poll-delete:hover{ background:url(/images/course/icons.png) -17px -343px no-repeat;}
.poll-edit{ background:url(/images/course/icons.png) 0px -272px no-repeat; width:16px; height:27px; display:block;float:right;} .poll-edit{ background:url(/images/course/icons.png) 0px -272px no-repeat; width:16px; height:27px; display:block;float:right;}
.poll-edit:hover{ background:url(/images/course/icons.png) -21px -272px no-repeat;} .poll-edit:hover{ background:url(/images/course/icons.png) -21px -272px no-repeat;}
.poll-add-menu {border:1px solid #eaeaea; background:#fff; padding:5px 10px; width:60px; left:0; top:16px; position:absolute; z-index:9999; line-height:2; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); display:none;} .poll-add-menu {border:1px solid #eaeaea; background:#fff; padding:5px 8px; width:50px; left:15px; top:110px; position:absolute; z-index:9999; line-height:2; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); display:none;}
.poll-multiple-limit {width:70px; outline: none;} .poll-multiple-limit {width:70px; outline: none;}
/*黄色边框的提示信息 */ /*黄色边框的提示信息 */