|
|
|
|
<div class="educontent mt30 mb30">
|
|
|
|
|
<style>
|
|
|
|
|
.CodeMirror-scroll{
|
|
|
|
|
overflow: auto !important;
|
|
|
|
|
margin-bottom: -30px;
|
|
|
|
|
margin-right: -30px;
|
|
|
|
|
padding-bottom: 30px;
|
|
|
|
|
height: 100%;
|
|
|
|
|
outline: none;
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<%= render :partial => "challenges/challenges_tab_nav" %>
|
|
|
|
|
<%= render :partial => "challenges/new_or_edit_task_page" %>
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
$(function() {
|
|
|
|
|
document.onkeydown = function(event) {
|
|
|
|
|
var target, code, tag;
|
|
|
|
|
if (!event) {
|
|
|
|
|
event = window.event; //针对ie浏览器
|
|
|
|
|
target = event.srcElement;
|
|
|
|
|
code = event.keyCode;
|
|
|
|
|
if (code == 13) {
|
|
|
|
|
tag = target.tagName;
|
|
|
|
|
if (tag == "INPUT") { return true; }
|
|
|
|
|
else { return false; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
target = event.target; //针对遵循w3c标准的浏览器,如Firefox
|
|
|
|
|
code = event.keyCode;
|
|
|
|
|
if (code == 13) {
|
|
|
|
|
tag = target.tagName;
|
|
|
|
|
if (tag == "INPUT") { return false; }
|
|
|
|
|
else { return true; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
var bt = baidu.template;
|
|
|
|
|
bt.LEFT_DELIMITER = '<!';
|
|
|
|
|
bt.RIGHT_DELIMITER = '!>';
|
|
|
|
|
|
|
|
|
|
$("#shixun_form").on('click', 'a.option_icon_add', function () {
|
|
|
|
|
var html = bt('t:set-option-list', null);
|
|
|
|
|
$(this).parent().parent('.clearfix').before(html);
|
|
|
|
|
var inputs = document.getElementsByName("question[cnt][]");
|
|
|
|
|
var inputs_spans = document.getElementsByName("option_span");
|
|
|
|
|
for (var j = 0; j < inputs_spans.length; j++) {
|
|
|
|
|
if(j >= 0 && j <= 26){
|
|
|
|
|
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (var i = 0; i < inputs.length; i++) {
|
|
|
|
|
autoTextarea(inputs[i], 0, 140);
|
|
|
|
|
}
|
|
|
|
|
$(inputs[inputs.length - 1]).focus();
|
|
|
|
|
});
|
|
|
|
|
$("#shixun_form").on('click', 'a.option_icon_remove', function () {
|
|
|
|
|
$(this).parent('.clearfix').remove();
|
|
|
|
|
var inputs_spans = document.getElementsByName("option_span");
|
|
|
|
|
for (var j = 0; j < inputs_spans.length; j++) {
|
|
|
|
|
if(j >= 0 && j <= 26){
|
|
|
|
|
if(j >= 0 && j <= 26){
|
|
|
|
|
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$("#current-option").html("");
|
|
|
|
|
if($(".check-option-bg").length>0){
|
|
|
|
|
for(var i=0;i<$(".check-option-bg").length;i++){
|
|
|
|
|
$("#current-option").html($("#current-option").html()+$(".check-option-bg").eq(i).html());
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
$("#current-option").html("请点击正确选项");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 实训简介自动保存
|
|
|
|
|
md_elocalStorage(taskpass_editormd, "challenge_in_<%= User.current.id %>", "in");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//设置选项答案
|
|
|
|
|
function selectchoice(item, st){
|
|
|
|
|
//判断是否选中,如果选中,再次点击的时候取消选中
|
|
|
|
|
if($(item).hasClass('check-option-bg')){
|
|
|
|
|
$(item).removeClass('check-option-bg');
|
|
|
|
|
}else{
|
|
|
|
|
if(st == 2){
|
|
|
|
|
//单选
|
|
|
|
|
$(".select-choice").removeClass('check-option-bg');
|
|
|
|
|
$(item).addClass('check-option-bg');
|
|
|
|
|
}else{
|
|
|
|
|
//多选
|
|
|
|
|
$(item).addClass('check-option-bg');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$("#current-option").html("");
|
|
|
|
|
if($(".check-option-bg").length>0){
|
|
|
|
|
for(var i=0;i<$(".check-option-bg").length;i++){
|
|
|
|
|
$("#current-option").html($("#current-option").html()+$(".check-option-bg").eq(i).html());
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
$("#current-option").html("请点击正确选项");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 判断选择题的答案
|
|
|
|
|
function set_choice_answer(){
|
|
|
|
|
var answer = document.getElementsByName("choice[answer][]");
|
|
|
|
|
var choice = document.getElementsByName("option_span");
|
|
|
|
|
for(var o = 0; o < choice.length; o++){
|
|
|
|
|
if($(choice[o]).hasClass("check-option-bg")){
|
|
|
|
|
$(answer[o]).val(String.fromCharCode(65 + o));
|
|
|
|
|
}else{
|
|
|
|
|
$(answer[o]).val(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 判断选择题内容是否为空
|
|
|
|
|
function judge_choice_contents(){
|
|
|
|
|
var answer = document.getElementsByName("choice[answer][]");
|
|
|
|
|
var contents = document.getElementsByName("question[cnt][]");
|
|
|
|
|
var lens = contents.length;
|
|
|
|
|
for(var i = 0; i < lens; i++){
|
|
|
|
|
if($(contents[i]).val().trim() == ""){
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 判断选择题选择答案的个数
|
|
|
|
|
function judge_choice_answer(){
|
|
|
|
|
var answer = document.getElementsByName("choice[answer][]");
|
|
|
|
|
var lens = answer.length;
|
|
|
|
|
var num = 0;
|
|
|
|
|
for(var i= 0; i < lens; i++){
|
|
|
|
|
if($(answer[i]).val() != "0"){
|
|
|
|
|
num += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return num;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 选择题选项的个数
|
|
|
|
|
function choice_num(){
|
|
|
|
|
var answer = document.getElementsByName("choice[answer][]");
|
|
|
|
|
var lens = answer.length;
|
|
|
|
|
return lens;
|
|
|
|
|
}
|
|
|
|
|
$("#challenge_subject").keydown(function(){
|
|
|
|
|
$("#new_shixun_name").hide();
|
|
|
|
|
});
|
|
|
|
|
$("#challenge_subject").keydown(function(){
|
|
|
|
|
$("#new_shixun_pass").hide();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#task_pass_cancel").click(function(){
|
|
|
|
|
$("#task_pass_show").show();
|
|
|
|
|
$("#task_pass_edit").hide();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* function challenge_update(st){
|
|
|
|
|
set_choice_answer();
|
|
|
|
|
var error = $("#choice_error_tip");
|
|
|
|
|
if($('#challenge_subject').val().trim() == ""){
|
|
|
|
|
$("#challenge_subject").focus();
|
|
|
|
|
$("#new_shixun_name").show();
|
|
|
|
|
}else if($("#challenge_task_pass textarea").val().trim() == ""){
|
|
|
|
|
$("#challenge_task_pass textarea").focus();
|
|
|
|
|
$("#new_shixun_pass").show();
|
|
|
|
|
}else if(judge_choice_contents()){
|
|
|
|
|
error.html("选项不能为空").show();
|
|
|
|
|
}else{
|
|
|
|
|
if(st == "2"){
|
|
|
|
|
if(judge_choice_contents()) {
|
|
|
|
|
error.html("选项内容不能为空").show();
|
|
|
|
|
}else if(choice_num() < 2){
|
|
|
|
|
error.html("单选题选项不能少于2个").show();
|
|
|
|
|
}else if(judge_choice_answer() == 0){
|
|
|
|
|
error.html("请设置答案").show();
|
|
|
|
|
}else{
|
|
|
|
|
$('#challenge_shixun_update').submit();
|
|
|
|
|
}
|
|
|
|
|
}else if(st == "1"){
|
|
|
|
|
if(judge_choice_contents()) {
|
|
|
|
|
error.html("选项内容不能为空").show();
|
|
|
|
|
}else if(choice_num() < 3){
|
|
|
|
|
error.html("多选题选项不能少于3个").show();
|
|
|
|
|
}else if(judge_choice_answer() < 2){
|
|
|
|
|
error.html("答案不能少于2个").show();
|
|
|
|
|
}else{
|
|
|
|
|
$('#challenge_shixun_update').submit();
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
$('#challenge_shixun_update').submit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
<% if false %>
|
|
|
|
|
<%= render :partial => "challenges/challenges_tab_nav" %>
|
|
|
|
|
<!--添加实践任务页面-->
|
|
|
|
|
<%#= render :partial => "challenges/add_task_page" %>
|
|
|
|
|
<!--编辑实践任务页面-->
|
|
|
|
|
<%#= render :partial => "challenges/edit_task_page" %>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--添加评测设置-->
|
|
|
|
|
<%#= render :partial => "challenges/add_testsetting_page" %>
|
|
|
|
|
<!--编辑评测设置-->
|
|
|
|
|
<%#= render :partial => "challenges/edit_testsetting_page" %>
|
|
|
|
|
|
|
|
|
|
<!--添加参考答案-->
|
|
|
|
|
<%= render :partial => "challenges/add_answer_page" %>
|
|
|
|
|
<!--编辑参考答案-->
|
|
|
|
|
<%= render :partial => "challenges/edit_answer_page" %>
|
|
|
|
|
|
|
|
|
|
<!--添加选择题-->
|
|
|
|
|
<%= render :partial => "challenges/add_choose_page" %>
|
|
|
|
|
<!--编辑选择题-->
|
|
|
|
|
<%= render :partial => "challenges/edit_choose_page" %>
|
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|