单选多选题

This commit is contained in:
daiao 2017-09-06 14:42:31 +08:00
parent d2f3a460c7
commit 9c36affeec
7 changed files with 304 additions and 235 deletions

View File

@ -2,8 +2,8 @@
class ChallengesController < ApplicationController
layout "base_shixun"
before_filter :check_authentication
before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build, :update_evaluation]
before_filter :find_challenge, :only => [:show, :edit, :update, :challenge_build, :index_up, :index_down, :destroy, :update_evaluation]
before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build, :update_evaluation, :add_choose_question, :new_or_edit_choose_question]
before_filter :find_challenge, :only => [:show, :edit, :update, :challenge_build, :index_up, :index_down, :destroy, :update_evaluation, :add_choose_question, :new_or_edit_choose_question]
before_filter :build_challege_from_params, :only => [:new, :create]
before_filter :tpi_manager_allowed, :only => [:challenge_build, :destroy, :edit, :new, :create]
before_filter :allowed_view, :only => [:show]
@ -103,6 +103,20 @@ class ChallengesController < ApplicationController
end
end
def new_or_edit_choose_question
respond_to do |format|
format.js
end
end
def add_choose_question
@type = params[:type].to_i
respond_to do |format|
format.js
end
end
def destroy
next_challenges = @shixun.challenges.where("position > #{@challenge.position}")
next_challenges.update_all("position = position - 1")

View File

@ -35,7 +35,7 @@
</div>
<div id="set_content" class="task-pm-box mh550 user_bg_shadow undis">
<%= render :partial => "single_or_multiple_question" %>
<%#= render :partial => "single_or_multiple_question" %>
</div>
<%= render :partial => 'single_or_multiple_question_show'%>
@ -50,5 +50,57 @@
sequenceDiagram: true // 默认不解析
});
});
//添加单选、多选tab
$(".addoption-btn").on("click",function(){
var length= $(".stage-part-2").find(".nav_check_item li").length;
if(length<11){
var title=$(this).html();
var type = title.indexOf("多选")>0 ? 2 : 1;
if(title.indexOf("多选")>0){//多选
title="多选题";
}else{
title="单选题";
}
var li_con=length+".<span>"+title+"</span>";
var html="<li class=\"fl check_nav\"><a href=\"javascript:void(0)\" class=\"color-black\">"+li_con+"</a></li>";
$(".stage-part-2").find(".nav_check_item li").removeClass("check_nav");
$(".stage-part-2").find(".nav_check_item li").eq(length-1).after(html);
$.ajax({
url: "<%= add_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun) %>",
dateType: "script",
data: {type: type},
success: function(){
}
})
}
// editor_tigan();
});
//删除单选、多选tab
$(".deloption-btn").on("click",function(){
var index=0;
for(var i=1;i<$(".stage-part-2").find(".nav_check_item li").length;i++){
var length=$(".stage-part-2").find(".nav_check_item li").length;
var item=$(".stage-part-2").find(".nav_check_item li");
if(item.eq(i).hasClass("check_nav")){
if(length>1){
item.eq(0).addClass("check_nav");
item.eq(i).remove();
}
}
}
for(var i=1;i<$(".stage-part-2").find(".nav_check_item li").length;i++){
var item=$(".stage-part-2").find(".nav_check_item li");
item.eq(i).html(i+".<span>"+item.eq(i).find("span").html()+"</span>");
}
})
//第二个ul tab的切换事件
$(".stage-part-2").find(".nav_check_item li").live("click",function(){
if($(".nav_check_item li").length>1){
$(".nav_check_item li").removeClass("check_nav");
$(this).addClass("check_nav");
}
})
</script>

View File

@ -1,77 +1,76 @@
<li class="clearfix pt30 pr30">
<a href="javascript:void(0);" class="task-btn task-btn-green fr" >编辑</a>
<a href="javascript:void(0)" class="task-btn fr mr10 deloption-btn" id="skill_cancel">删除</a>
</li>
<div class="panel-form">
<div id="shixun_form">
<li class="clearfix">
<label class="panel-form-label fl"><span class="c_red mr5">*</span>题干:</label>
<div id="challenge_task_pass" class="fl task-bg-grey panel-box-sizing panel-form-width-690 new_li">
<textarea name="challenge[task_pass]"></textarea>
<%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min.css' %>
<%= javascript_include_tag '/editormd/editormd.min.js','/editormd/examples/js/jquery.min.js' %>
<%= labelled_form_for @challenge, :url => new_or_edit_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun), :html => {:id => "challenge_choose_update", :remote => true } do |f| %>
<li class="clearfix pt30 pr30">
<a href="javascript:void(0);" class="task-btn task-btn-green fr" >编辑</a>
<a href="javascript:void(0)" class="task-btn fr mr10 deloption-btn" id="skill_cancel">删除</a>
</li>
<div class="panel-form">
<div id="shixun_form">
<li class="clearfix">
<label class="panel-form-label fl"><span class="c_red mr5">*</span>题干:</label>
<div id="challenge_choose_subject" class="fl task-bg-grey panel-box-sizing panel-form-width-690 new_li">
<textarea name="choose[subject]"></textarea>
</div>
</li>
<script id="t:set-option-list" type="text/html">
<li class="clearfix pr">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @type %>);" name="option_span" title="点击设置答案">A</span></label>
<input type="hidden" name="choice[answer][]">
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
</script>
<li class="clearfix pr">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @type %>);" name="option_span" title="点击设置答案">A</span></label>
<input type="hidden" name="choice[answer][]">
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<li class="clearfix pr">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @type %>);" name="option_span" title="点击设置答案">B</span></label>
<input type="hidden" name="choice[answer][]">
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<li class="clearfix pr">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @type %>);" name="option_span" title="点击设置答案">C</span></label>
<input type="hidden" name="choice[answer][]">
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<li class="clearfix pr">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @type %>);" name="option_span" title="点击设置答案">D</span></label>
<input type="hidden" name="choice[answer][]">
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<ul>
<li class="clearfix mb10" >
<label class="panel-form-label fl"><span class="add-option-item fr mr10 color-grey border-dash-orange" name="option_span"><%#= params[:action] == "edit" ? (@challenge.challenge_questions.count + 65).chr : (@type == 1 ? "E" : "C") %></span></label>
<div class="fl panel-box-sizing add-option-input border-dash-orange"><a title="新增" class="option_icon_add">新增选项</a></div>
</li>
<span style="display: none" class="c_red ml95" id="choice_error_tip"></span>
<li class="clearfix" ><label class="fl" style="margin-left: 10%">温馨提示:点击选项,可以直接设置答案</label><label class="fr">标准答案:<span id="current-option" class="color-orange"><%#= @challenge.right_answers.blank? ? "请点击正确选项" : @challenge.right_answers %></span></label></li>
</ul>
</div>
</div>
<p class="bor-bottom-greyE"></p>
<!--参考答案-->
<li class="clearfix" style="line-height:1.9;">
<label class=" panel-form-label fl"> 参考答案:</label>
<div id="challenge_choose_answer" class="new_li">
<textarea name="challenge[answer]"><%= @challenge.answer %></textarea>
</div>
<p id="e_tip_in" style="margin-left: 10%" class="c_grey"></p>
<p id="e_tips_in" style="margin-left: 10%" class="c_grey"></p>
</li>
<script id="t:set-option-list" type="text/html">
<li class="clearfix pr">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @st %>);" name="option_span" title="点击设置答案">A</span></label>
<input type="hidden" name="choice[answer][]">
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
</script>
<li class="clearfix pr">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @st %>);" name="option_span" title="点击设置答案">A</span></label>
<input type="hidden" name="choice[answer][]">
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<li class="clearfix pr">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @st %>);" name="option_span" title="点击设置答案">B</span></label>
<input type="hidden" name="choice[answer][]">
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<li class="clearfix pr">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @st %>);" name="option_span" title="点击设置答案">C</span></label>
<input type="hidden" name="choice[answer][]">
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<li class="clearfix pr">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @st %>);" name="option_span" title="点击设置答案">D</span></label>
<input type="hidden" name="choice[answer][]">
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<ul>
<li class="clearfix mb10" >
<label class="panel-form-label fl"><span class="add-option-item fr mr10 color-grey border-dash-orange" name="option_span"><%#= params[:action] == "edit" ? (@challenge.challenge_questions.count + 65).chr : (@st == 1 ? "E" : "C") %></span></label>
<div class="fl panel-box-sizing add-option-input border-dash-orange"><a title="新增" class="option_icon_add">新增选项</a></div>
</li>
<span style="display: none" class="c_red ml95" id="choice_error_tip"></span>
<li class="clearfix" ><label class="fl" style="margin-left: 10%">温馨提示:点击选项,可以直接设置答案</label><label class="fr">标准答案:<span id="current-option" class="color-orange"><%#= @challenge.right_answers.blank? ? "请点击正确选项" : @challenge.right_answers %></span></label></li>
</ul>
</div>
</div>
<p class="bor-bottom-greyE"></p>
<!--参考答案-->
<div class="panel-form">
<div id="edit_answer_show">
<ul>
<li class="clearfix">
<label class=" panel-form-label fl"> 参考答案:</label>
<div class="fl task-bg-grey panel-box-sizing panel-form-width-690 new_li" id="tpm_answer_show" style="width: 90%;background: #fff!important;">
<textarea style="display:none;"><%= @challenge.answer.blank? ? "无" : (@challenge.answer) %></textarea>
</div>
</li>
</ul>
</div>
</div>
<p class="bor-bottom-greyE"></p>
<!--经验值设置-->
<div class="panel-form">
<div id="shixun_form">
<li class="clearfix">
<label class="panel-form-label fl"><span class="c_red mr5">*</span>难易度:</label>
<p class="bor-bottom-greyE"></p>
<!--经验值设置-->
<div class="panel-form">
<div id="shixun_form">
<li class="clearfix">
<label class="panel-form-label fl"><span class="c_red mr5">*</span>难易度:</label>
<span class="fl mt3 mr10">
<input id="challenge_difficulty_1" class="magic-radio" name="challenge[difficulty]" type="radio" value="1" <%= (@challenge.difficulty == 1 ? "checked" : "")%> >
<label for="challenge_difficulty_1">简单</label>
@ -85,154 +84,157 @@
<label for="challenge_difficulty_3">困难</label>
</span></li>
<li class="clearfix">
<label class="panel-form-label fl"><span class="c_red mr5">*</span>奖励经验值:</label>
<%= select_tag :challenge_score, options_for_select([100, 200]), :name => 'challenge[score]', :class => " fl", :style => "height: 40px; width:170px;" %>
<div class="clear"></div>
<span style="display: none" class="c_red ml90" id="new_shixun_score">分值设定不能为空</span>
</li>
<li class="clearfix">
<label class="panel-form-label fl"><span class="c_red mr5">*</span>奖励经验值:</label>
<%= select_tag :challenge_score, options_for_select([100, 200]), :name => 'challenge[score]', :class => " fl", :style => "height: 40px; width:170px;" %>
<div class="clear"></div>
<span style="display: none" class="c_red ml90" id="new_shixun_score">分值设定不能为空</span>
</li>
<div class="prop-notice-info mb10" style="margin-left: 10%">
<ol>
<% if @st == 0 %>
<li>如果学员查看了参考答案,则不能得到相应的经验值</li>
<li>如果学员成功得到经验值,那么将同时获得等值的金币奖励,如:+100经验值、+100金币</li>
<% else %>
<div class="prop-notice-info mb10" style="margin-left: 10%">
<ol>
<li>如果学员答题错误,则不能得到相应的经验值</li>
<li>如果学员成功得到经验值,那么将同时获得等值的金币奖励,如:+10经验值、+10金币</li>
<% end %>
</ol>
</div>
</div>
</div>
<p class="bor-bottom-greyE"></p>
<!--技能标签-->
<div class="panel-form">
<div id="shixun_form">
<li class="clearfix" style="margin-bottom: 0;">
<label class=" panel-form-label fl"> 技能标签:</label>
<div class="fl task-bd-grey">
<% if params[:action] == "edit" && @challenge_tags.count > 0 %>
<% @challenge_tags.each do |tag| %>
<div class="task-tag tag-grey mt5 mr10 fl">
<button data-dismiss="alert" class="close fr mt3 ml5" type="button" onclick="close_tag(this)">×</button>
<input class='knowledge_frame' name='knowledge[input][]' value="<%= tag.try(:name)%>" />
</div>
<% end %>
<% end %>
<div class="task-tag tag-grey mt5 mr10 fl <%#= @challenge_tags.count > 0 ? "undis" : "" %>" id="add_shixun_skill">
<button data-dismiss="alert" class="close fr mt3 ml5" type="button" onclick="$('#add_shixun_skill').slideToggle();">×</button>
<input type="text" class="task-tag-input" onblur="add_tag();" id="shixun_skill_input" placeholder="请输入技能标签" />
</ol>
</div>
</div>
</div>
<p class="bor-bottom-greyE"></p>
<!--技能标签-->
<div class="panel-form">
<div id="shixun_form">
<li class="clearfix" style="margin-bottom: 0;">
<label class=" panel-form-label fl"> 技能标签:</label>
<div class="fl task-bd-grey">
<% if params[:action] == "edit" && @challenge_tags.count > 0 %>
<% @challenge_tags.each do |tag| %>
<div class="task-tag tag-grey mt5 mr10 fl">
<button data-dismiss="alert" class="close fr mt3 ml5" type="button" onclick="close_tag(this)">×</button>
<input class='knowledge_frame' name='knowledge[input][]' value="<%= tag.try(:name)%>" />
</div>
<% end %>
<% end %>
<div class="task-tag tag-grey mt5 mr10 fl <%#= @challenge_tags.count > 0 ? "undis" : "" %>" id="add_shixun_skill">
<button data-dismiss="alert" class="close fr mt3 ml5" type="button" onclick="$('#add_shixun_skill').slideToggle();">×</button>
<input type="text" class="task-tag-input" onblur="add_tag();" id="shixun_skill_input" placeholder="请输入技能标签" />
</div>
<a href="javascript:void(0);" onclick="$('#add_shixun_skill').slideToggle();" id="add_knowledge" style="color: #627bfd;float: left;margin-top: 5px">+添加</a>
</div>
</li>
<p class="color-red" style="height: 25px;margin-left: 10%"><span id="stage_name_notice" style="display: none;"><i class="fa fa-exclamation-circle color-red mr5"></i>技能标签不能为空</span></p>
<div class="prop-notice-info mb10" style="margin-left: 10%">
<ol>
<li>学员答题正确将获得技能,否则不能获得技能</li>
</ol>
</div>
<a href="javascript:void(0);" onclick="$('#add_shixun_skill').slideToggle();" id="add_knowledge" style="color: #627bfd;float: left;margin-top: 5px">+添加</a>
</div>
</li>
<p class="color-red" style="height: 25px;margin-left: 10%"><span id="stage_name_notice" style="display: none;"><i class="fa fa-exclamation-circle color-red mr5"></i>技能标签不能为空</span></p>
<div class="prop-notice-info mb10" style="margin-left: 10%">
<ol>
<% if @st == 0 %>
<li>学员未参考答案通过了本阶段的评测时将获得技能,否则不能获得技能</li>
<% else %>
<li>学员答题正确将获得技能,否则不能获得技能</li>
<% end %>
</ol>
</div>
</div>
</div>
<li class="clearfix pr30 pb30">
<a href="javascript:void(0);" class="task-btn task-btn-green fr" >保存</a>
<a href="javascript:void(0)" class="task-btn fr mr10" id="skill_cancel">取消</a>
</li>
<li class="clearfix pr30 pb30">
<a href="javascript:void(0);" class="task-btn task-btn-green fr" >保存</a>
<a href="javascript:void(0)" class="task-btn fr mr10" id="skill_cancel">取消</a>
</li>
<% end %>
<script>
function editor_tigan(){
taskpass_editormd = editormd("challenge_task_pass", {
width : "89.6%",
height : 400,
syncScrolling : "single",
//你的lib目录的路径我这边用JSP做测试的
path : "/editormd/lib/",
tex : true,
autoFocus: false,
toolbarIcons : function() {
// Or return editormd.toolbarModes[name]; // full, simple, mini
// Using "||" set icons align right.
return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear" ]
},
toolbarCustomIcons : {
testIcon : "<a type=\"inline\" class=\"latex\" ><div class='zbg'></div></a>",
testIcon1 : "<a type=\"latex\" class=\"latex\" ><div class='zbg_latex'></div></a>"
},
//这个配置在simple.html中并没有但是为了能够提交表单使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中方便post提交表单。
saveHTMLToTextarea : true,
// 用于增加自定义工具栏的功能可以直接插入HTML标签不使用默认的元素创建图标
dialogMaskOpacity : 0.6,
placeholder: "请输入选择题的题干内容" ,
imageUpload : true,
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
imageUploadURL : "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>"//url
});
}
//参考答案的编辑器
$(document).ready(function() {
editormd.loadKaTeX(function() {
var answerMD = editormd.markdownToHTML("tpm_answer_show", {
htmlDecode: "style,script,iframe", // you can filter tags decode
taskList: true,
tex: true, // 默认不解析
flowChart: true, // 默认不解析
sequenceDiagram: true // 默认不解析
});
editormd.loadKaTeX(function() {
var answerMD = editormd.markdownToHTML("tpm_answer_show", {
htmlDecode: "style,script,iframe", // you can filter tags decode
taskList: true,
tex: true, // 默认不解析
flowChart: true, // 默认不解析
sequenceDiagram: true // 默认不解析
});
});
//添加单选、多选tab
$(".addoption-btn").on("click",function(){
var length= $(".stage-part-2").find(".nav_check_item li").length;
if(length<11){
var title=$(this).html();
if(title.indexOf("多选")>0){//多选
title="多选题";
}else{
title="单选题";
}
var li_con=length+".<span>"+title+"</span>";
var html="<li class=\"fl check_nav\"><a href=\"javascript:void(0)\" class=\"color-black\">"+li_con+"</a></li>";
$(".stage-part-2").find(".nav_check_item li").removeClass("check_nav");
$(".stage-part-2").find(".nav_check_item li").eq(length-1).after(html);
$("#set_content").show();
$("#task_content").hide();
}
editor_tigan();
})
//删除单选、多选tab
$(".deloption-btn").on("click",function(){
var index=0;
for(var i=1;i<$(".stage-part-2").find(".nav_check_item li").length;i++){
var length=$(".stage-part-2").find(".nav_check_item li").length;
var item=$(".stage-part-2").find(".nav_check_item li");
if(item.eq(i).hasClass("check_nav")){
if(length>1){
item.eq(0).addClass("check_nav");
item.eq(i).remove();
}
}
}
for(var i=1;i<$(".stage-part-2").find(".nav_check_item li").length;i++){
var item=$(".stage-part-2").find(".nav_check_item li");
item.eq(i).html(i+".<span>"+item.eq(i).find("span").html()+"</span>");
}
})
//第二个ul tab的切换事件
$(".stage-part-2").find(".nav_check_item li").live("click",function(){
if($(".nav_check_item li").length>1){
$(".nav_check_item li").removeClass("check_nav");
$(this).addClass("check_nav");
}
})
subject_editormd = editormd("challenge_choose_subject", {
width : "89.6%",
height : 400,
syncScrolling : "single",
//你的lib目录的路径我这边用JSP做测试的
path : "/editormd/lib/",
tex : true,
autoFocus: false,
toolbarIcons : function() {
// Or return editormd.toolbarModes[name]; // full, simple, mini
// Using "||" set icons align right.
return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear" ]
},
toolbarCustomIcons : {
testIcon : "<a type=\"inline\" class=\"latex\" ><div class='zbg'></div></a>",
testIcon1 : "<a type=\"latex\" class=\"latex\" ><div class='zbg_latex'></div></a>"
},
//这个配置在simple.html中并没有但是为了能够提交表单使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中方便post提交表单。
saveHTMLToTextarea : true,
// 用于增加自定义工具栏的功能可以直接插入HTML标签不使用默认的元素创建图标
dialogMaskOpacity : 0.6,
placeholder: "请输入选择题的题干内容" ,
imageUpload : true,
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
imageUploadURL : "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>"//url
});
choose_answer_editormd = editormd("challenge_choose_answer", {
width : "89.6%",
height : 400,
syncScrolling : "single",
//你的lib目录的路径我这边用JSP做测试的
path : "/editormd/lib/",
tex : true,
autoFocus: false,
toolbarIcons : function() {
// Or return editormd.toolbarModes[name]; // full, simple, mini
// Using "||" set icons align right.
return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear" ]
},
toolbarCustomIcons : {
testIcon : "<a type=\"inline\" class=\"latex\" ><div class='zbg'></div></a>",
testIcon1 : "<a type=\"latex\" class=\"latex\" ><div class='zbg_latex'></div></a>"
},
//这个配置在simple.html中并没有但是为了能够提交表单使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中方便post提交表单。
saveHTMLToTextarea : true,
// 用于增加自定义工具栏的功能可以直接插入HTML标签不使用默认的元素创建图标
dialogMaskOpacity : 0.6,
placeholder: "<%= @type == 0 ? '' : "请输入各个选项的具体解析或其他相关信息" %>",
imageUpload : true,
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
imageUploadURL : "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>"//url
});
/*
function latex_event(){
$("#challenge_choose_answer [type=\"latex\"]").bind("click", function(){
alert(2);
choose_answer_editormd.cm.replaceSelection("```latex");
choose_answer_editormd.cm.replaceSelection("\n");
choose_answer_editormd.cm.replaceSelection("\n");
choose_answer_editormd.cm.replaceSelection("```");
var __Cursor = choose_answer_editormd.cm.getDoc().getCursor();
choose_answer_editormd.cm.setCursor(__Cursor.line-1, 0);
});
$("#challenge_choose_answer [type=\"inline\"]").bind("click", function(){
choose_answer_editormd.cm.replaceSelection("$$$$");
var __Cursor = choose_answer_editormd.cm.getDoc().getCursor();
choose_answer_editormd.cm.setCursor(__Cursor.line, __Cursor.ch-2);
choose_answer_editormd.cm.focus();
});
$("#challenge_choose_subject [type=\"latex\"]").bind("click", function(){
alert(1);
subject_editormd.cm.replaceSelection("```latex");
subject_editormd.cm.replaceSelection("\n");
subject_editormd.cm.replaceSelection("\n");
subject_editormd.cm.replaceSelection("```");
var __Cursor = subject_editormd.cm.getDoc().getCursor();
subject_editormd.cm.setCursor(__Cursor.line-1, 0);
});
$("#challenge_choose_subject [type=\"inline\"]").bind("click", function(){
subject_editormd.cm.replaceSelection("$$$$");
var __Cursor = subject_editormd.cm.getDoc().getCursor();
subject_editormd.cm.setCursor(__Cursor.line, __Cursor.ch-2);
subject_editormd.cm.focus();
});
$("[type=\"inline\"]").attr("title", "行内公式");
$("[type=\"latex\"]").attr("title", "多行公式");
}*/
//技能标签
var SnSkill = $(".knowledge_frame").length;
@ -323,7 +325,7 @@
$("#current-option").html("请点击正确选项");
}
});
})
});
//设置选项答案
function selectchoice(item, st){
@ -331,7 +333,7 @@
if($(item).hasClass('check-option-bg')){
$(item).removeClass('check-option-bg');
}else{
if(st == 2){
if(st == 1){
//单选
$(".select-choice").removeClass('check-option-bg');
$(item).addClass('check-option-bg');

View File

@ -70,7 +70,26 @@
placeholder: "<%= @st == 0 ? "请输入完成当前任务依赖的知识点或者其它相关信息" : "请输入选择题的题干内容" %>",
imageUpload : true,
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
imageUploadURL : "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>"//url
imageUploadURL : "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>",//url
onload: function(){
$("#challenge_task_pass [type=\"latex\"]").bind("click", function(){
taskpass_editormd.cm.replaceSelection("```latex");
taskpass_editormd.cm.replaceSelection("\n");
taskpass_editormd.cm.replaceSelection("\n");
taskpass_editormd.cm.replaceSelection("```");
var __Cursor = taskpass_editormd.cm.getDoc().getCursor();
taskpass_editormd.cm.setCursor(__Cursor.line-1, 0);
});
$("#challenge_task_pass [type=\"inline\"]").bind("click", function(){
taskpass_editormd.cm.replaceSelection("$$$$");
var __Cursor = taskpass_editormd.cm.getDoc().getCursor();
taskpass_editormd.cm.setCursor(__Cursor.line, __Cursor.ch-2);
taskpass_editormd.cm.focus();
});
$("[type=\"inline\"]").attr("title", "行内公式");
$("[type=\"latex\"]").attr("title", "多行公式");
}
});
var bt = baidu.template;
@ -192,27 +211,6 @@
var lens = answer.length;
return lens;
}
window.onload = function(){
$("#challenge_task_pass [type=\"latex\"]").bind("click", function(){
taskpass_editormd.cm.replaceSelection("```latex");
taskpass_editormd.cm.replaceSelection("\n");
taskpass_editormd.cm.replaceSelection("\n");
taskpass_editormd.cm.replaceSelection("```");
var __Cursor = taskpass_editormd.cm.getDoc().getCursor();
taskpass_editormd.cm.setCursor(__Cursor.line-1, 0);
});
$("#challenge_task_pass [type=\"inline\"]").bind("click", function(){
taskpass_editormd.cm.replaceSelection("$$$$");
var __Cursor = taskpass_editormd.cm.getDoc().getCursor();
taskpass_editormd.cm.setCursor(__Cursor.line, __Cursor.ch-2);
taskpass_editormd.cm.focus();
});
$("[type=\"inline\"]").attr("title", "行内公式");
$("[type=\"latex\"]").attr("title", "多行公式");
};
$("#challenge_subject").keydown(function(){
$("#new_shixun_name").hide();
});

View File

@ -0,0 +1 @@
$("#task_content").html("<%= j(render :partial => "single_or_multiple_question") %>");

View File

@ -56,7 +56,7 @@
<li class="fl <%= @tab == 3 ? "check_nav" : "" %>">
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 3) %>" class="color-black">参考答案</a>
</li>
<!-- <li class="fl <%#= @tab == 6 ? "check_nav" : "" %>">
<!-- <li class="fl <%#= @tab == 6 ? "check_nav" : "" %>
<a href="<%#= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 6) %>" class="color-black">预备知识</a>
</li>-->
<li class="fl <%= @tab == 4 ? "check_nav" : "" %>">

View File

@ -116,6 +116,8 @@ RedmineApp::Application.routes.draw do
get 'index_up'
get 'index_down'
match 'update_evaluation', :via => [:get, :post, :put]
match 'add_choose_question', :via => [:get, :post]
match 'new_or_edit_choose_question', :via => [:get, :post]
end
end