试卷的题干换成ke

This commit is contained in:
cxt 2017-10-12 15:26:39 +08:00
parent cd64199151
commit b0b47b5443
17 changed files with 153 additions and 48 deletions

View File

@ -1,4 +1,3 @@
<div nhname="edit_exercise_mc_q_<%= exercise_question.id %>">
<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%>
<!--编辑单选start-->
<script type="text/javascript">
@ -32,7 +31,7 @@
<input style="display: none;" name="exercise_choice" id="exercise_choice_<%=exercise_question.id%>" value="<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>"/>
<label class="panel-form-label fl"><span class="mr10">题目</span></label>
<input name="question_type" value="<%=exercise_question.question_type %>" type="hidden">
<textarea name="question_title" id="poll_questions_title_<%=exercise_question.id %>" class="panel-form-width2-690 fl panel-box-sizing" placeholder="请输入单选题的题干"><%=exercise_question.question_title.html_safe %></textarea>
<textarea name="question_title" id="poll_questions_title_<%=exercise_question.id %>" class="panel-form-width2-690 fl panel-box-sizing undis" placeholder="请输入单选题的题干"><%=exercise_question.question_title.html_safe %></textarea>
</li>
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<li class="clearfix pr mb20">
@ -62,4 +61,4 @@
</li>
</div>
</div>
</div>
<% end %>

View File

@ -32,7 +32,7 @@
<input style="display: none;" name="exercise_choice" id="exercise_choice_<%=exercise_question.id%>" value="<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>"/>
<label class="panel-form-label fl"><span class="mr10">题目</span></label>
<input name="question_type" value="<%=exercise_question.question_type %>" type="hidden">
<textarea name="question_title" id="poll_questions_title_<%=exercise_question.id %>" class="panel-form-width2-690 fl panel-box-sizing" placeholder="请输入多选题的题干" type="text" oninput="autoHeight('#poll_questions_title_<%=exercise_question.id %>',30)"><%=exercise_question.question_title %></textarea>
<textarea name="question_title" id="poll_questions_title_<%=exercise_question.id %>" class="panel-form-width2-690 fl panel-box-sizing undis"><%=exercise_question.question_title.html_safe %></textarea>
</li>
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>

View File

@ -13,11 +13,11 @@
<li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="mr10">题目</span></label>
<input name="question_type" value="<%=exercise_question.question_type %>" type="hidden">
<textarea maxlength="250" class="panel-form-width2-690 fl panel-box-sizing" name="question_title" id="poll_questions_title_<%=exercise_question.id %>" placeholder="请输入简答题的题干" type="text" oninput="autoHeight('#poll_questions_title_<%=exercise_question.id %>',30)"><%=exercise_question.question_title %></textarea>
<textarea maxlength="250" class="panel-form-width2-690 fl panel-box-sizing undis" name="question_title" id="poll_questions_title_<%=exercise_question.id %>"><%=exercise_question.question_title.html_safe %></textarea>
</li>
<li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="fr mr10 color-grey" name="option_spans">参考答案</span></label>
<textarea class="fl panel-box-sizing with90 task-height-150 pl5 pt5 candiate_answer" name="exercise_choice" placeholder="如有参考答案,请输入参考答案"id="poll_questions_answer_<%=exercise_question.id %>"><%=exercise_question.exercise_standard_answers.empty? ? '' : exercise_question.exercise_standard_answers.first.answer_text %></textarea>
<textarea class="fl panel-box-sizing with90 task-height-150 pl5 pt5 candiate_answer" name="exercise_choice" placeholder="如有参考答案,请输入参考答案" id="poll_questions_answer_<%=exercise_question.id %>"><%=exercise_question.exercise_standard_answers.empty? ? '' : exercise_question.exercise_standard_answers.first.answer_text %></textarea>
</li>
<li class="clearfix mb20">
<label class="panel-form-label fl"><span class="mr10">分值</span></label>

View File

@ -26,7 +26,7 @@
<input name="question_type" value="3" type="hidden">
<label class="panel-form-label fl"><span class="mr10">题目</span></label>
<input name="question_type" value="<%=exercise_question.question_type %>" type="hidden">
<textarea maxlength="250" class="panel-form-width2-690 fl panel-box-sizing questionTitle" name="question_title" id="poll_questions_title_<%=exercise_question.id %>" placeholder="请输入填空题的题干(注意:目前仅支持一个空)" type="text" oninput="autoHeight('#poll_questions_title_<%=exercise_question.id %>',30)"><%=exercise_question.question_title %></textarea>
<textarea maxlength="250" class="panel-form-width2-690 fl panel-box-sizing questionTitle undis" name="question_title" id="poll_questions_title_<%=exercise_question.id %>"><%=exercise_question.question_title.html_safe %></textarea>
</li>
<% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>
<li class="clearfix pr mb20">

View File

@ -92,7 +92,7 @@
<div class="clearfix pl15 pr15">
<p class="fl font-15">第<%= i + 1 %>题:<span class="color-orange03 ml10">[<%= exercise_question.question_type_name %>]</span><span class="ml10"><%= exercise_question.question_score %></span>分</p>
</div>
<pre class="exercise_que_title pl15 pr15"><%= exercise_question.question_title %></pre>
<div class="pl15 pr15 justify"><%= exercise_question.question_title.html_safe %></div>
<% case exercise_question.question_type %>
<% when 1 %>
<div class="pl15 pr15 mb15">

View File

@ -75,7 +75,7 @@
<p class="fr" id="multi_q_score_<%= exercise_question.id %>"><span class="<%= answer.empty? ? 'color-red' : (answer.first.score == -1 || answer.first.score == 0 ? "color-red" : "color-light-green") %> mr3"><%= answer.empty? ? 0 : (answer.first.score == -1 ? "未批" : answer.first.score) %></span><%= answer.empty? ? "分" : (answer.first.score == -1 ? "" : "分") %></p>
<% end %>
</div>
<pre class="exercise_que_title pl15 pr15"><%= exercise_question.question_title %></pre>
<div class="pl15 pr15 justify"><%= exercise_question.question_title.html_safe %></div>
<% case exercise_question.question_type %>
<% when 1 %>
<div class="pl15 pr15 mb15">

View File

@ -15,7 +15,7 @@
<li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="mr10">题目</span></label>
<!--<textarea name="question_title" id="poll_questions_title" class="panel-form-width2-690 fl panel-box-sizing" placeholder="请输入单选题的题干" type="text" oninput="autoHeight('#poll_questions_title',30)"></textarea>-->
<textarea id="poll_questions_title" name="question_title" class="panel-form-width2-690 fl panel-box-sizing undis">请输入单选题的题干</textarea>
<textarea id="poll_questions_title" name="question_title" class="panel-form-width2-690 fl panel-box-sizing undis"></textarea>
</li>
<input style="display: none;" name="exercise_choice" id="exercise_choice_1"/>

View File

@ -1,5 +1,6 @@
<% if exercise.id %>
<%= form_for(ExerciseQuestion.new,
<div nhname="new_exercise_mc_q">
<%= form_for(ExerciseQuestion.new,
:html => { :multipart => true },
:url=>create_exercise_question_exercise_path(exercise.id),
:remote=>true ) do |f| %>
@ -13,7 +14,7 @@
</div>
<li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="mr10">题目</span></label>
<textarea name="question_title" id="poll_questions_title" class="panel-form-width2-690 fl panel-box-sizing" placeholder="请输入多选题的题干" type="text" oninput="autoHeight('#poll_questions_title',30)"></textarea>
<textarea id="poll_questions_title" name="question_title" class="panel-form-width2-690 fl panel-box-sizing undis"></textarea>
</li>
<li class="clearfix pr mb20">
<label class="panel-form-label fl">
@ -55,6 +56,7 @@
</li>
</div>
<% end %>
</div>
<% end %>
<script type="text/javascript">
$(function(){

View File

@ -1,5 +1,6 @@
<% if exercise.id %>
<%= form_for(ExerciseQuestion.new,
<div nhname="new_exercise_mc_q">
<%= form_for(ExerciseQuestion.new,
:html => { :multipart => true },
:url=>create_exercise_question_exercise_path(exercise.id),
:remote=>true ) do |f| %>
@ -9,7 +10,7 @@
<input name="quest_id" id="quest_id" value="0" type="hidden">
<li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="mr10">题目</span></label>
<textarea maxlength="250" class="panel-form-width2-690 fl panel-box-sizing" name="question_title" id="poll_questions_title" placeholder="请输入简答题的题干" type="text" oninput="autoHeight('#poll_questions_title',30)"></textarea>
<textarea id="poll_questions_title" name="question_title" class="panel-form-width2-690 fl panel-box-sizing undis"></textarea>
</li>
<li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="fr mr10 color-grey" name="option_spans">参考答案</span></label>
@ -29,6 +30,7 @@
</li>
</div>
<% end %>
</div>
<% end %>
<script type="text/javascript">
$(function(){

View File

@ -35,7 +35,6 @@
}else if(forms.length > 0){
notice_box("请先保存正在编辑的题目再新建。");
} else{
//$.get("<%#= new_exercise_question_path(:exercise => @exercise, :type => "MC") %>");
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MC', :locals => {:exercise=>@exercise}) %>");
KindEditor.ready(function(K){
$("div[nhname='new_exercise_mc_q']").each(function(){
@ -67,6 +66,24 @@
} else{
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MCQ', :locals => {:exercise=>@exercise}) %>");
$("#poll_questions_title").focus();
KindEditor.ready(function(K){
$("div[nhname='new_exercise_mc_q']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
params.placeholder = "请输入多选题的题干";
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[name='question_title']",params.div_form);
if(params.textarea.data('init') == undefined) {
params.editor = init_exercise_quetison_editor(params);
new_quetion_title_editor = params.editor;
params.textarea.data('init', 1);
}
});
});
}
}
@ -79,6 +96,24 @@
} else{
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_single', :locals => {:exercise=>@exercise}) %>");
$("#poll_questions_title").focus();
KindEditor.ready(function(K){
$("div[nhname='new_exercise_mc_q']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
params.placeholder = "请输入填空题的题干(注意:目前仅支持一个空)";
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[name='question_title']",params.div_form);
if(params.textarea.data('init') == undefined) {
params.editor = init_exercise_quetison_editor(params);
new_quetion_title_editor = params.editor;
params.textarea.data('init', 1);
}
});
});
}
}
@ -91,6 +126,24 @@
} else{
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_multi', :locals => {:exercise=>@exercise}) %>");
$("#poll_questions_title").focus();
KindEditor.ready(function(K){
$("div[nhname='new_exercise_mc_q']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
params.placeholder = "请输入简答题的题干";
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[name='question_title']",params.div_form);
if(params.textarea.data('init') == undefined) {
params.editor = init_exercise_quetison_editor(params);
new_quetion_title_editor = params.editor;
params.textarea.data('init', 1);
}
});
});
}
}

View File

@ -1,5 +1,6 @@
<% if exercise.id %>
<%= form_for(ExerciseQuestion.new,
<div nhname="new_exercise_mc_q">
<%= form_for(ExerciseQuestion.new,
:html => { :multipart => true },
:url=>create_exercise_question_exercise_path(exercise.id),
:remote=>true ) do |f| %>
@ -9,7 +10,7 @@
<input name="question_type" value="3" type="hidden">
<input name="quest_id" id="quest_id" value="0" type="hidden">
<label class="panel-form-label fl"><span class="mr10">题目</span></label>
<textarea maxlength="250" class="panel-form-width2-690 fl panel-box-sizing" name="question_title" id="poll_questions_title" placeholder="请输入填空题的题干(注意:目前仅支持一个空)" type="text" oninput="autoHeight('#poll_questions_title',30)"></textarea>
<textarea id="poll_questions_title" name="question_title" class="panel-form-width2-690 fl panel-box-sizing undis"></textarea>
</li>
<li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="fr mr10 color-grey" name="fill_span">答案 一</span></label>
@ -38,6 +39,7 @@
</li>
</div>
<% end %>
</div>
<% end %>
<script type="text/javascript">
$(function(){

View File

@ -13,7 +13,7 @@
<a href="javascript:void(0)" onclick="exQuestionEdit(<%= exercise_question.id%>);"><i data-tip-down="编辑" class="fa fa-pencil color-orange05"></i></a>
</p>
</div>
<div style="text-align: justify;" class="pl15 pr15"><%= exercise_question.question_title.html_safe %></div>
<div class="pl15 pr15 justify"><%= exercise_question.question_title.html_safe %></div>
<div class="pl15 pr15 mb10">
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<li class="clearfix">
@ -41,11 +41,23 @@
} else{
$("#insert_new_poll_question_"+quest_id).html("<%= escape_javascript(render :partial => 'new_MC', :locals => {:exercise=>@exercise}) %>");
$("#quest_id").val(quest_id);
$("#poll_questions_title").focus();
$(".questionTitle").on("input",function(){
$(this).height(30);
var scrollVal = $(this)[0].scrollHeight;
$(this).height(scrollVal);
KindEditor.ready(function(K){
$("div[nhname='new_exercise_mc_q']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
params.placeholder = "请输入单选题的题干";
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[name='question_title']",params.div_form);
if(params.textarea.data('init') == undefined) {
params.editor = init_exercise_quetison_editor(params);
new_quetion_title_editor = params.editor;
params.textarea.data('init', 1);
}
});
});
}
}

View File

@ -13,7 +13,7 @@
<a href="javascript:void(0)" onclick="exQuestionEdit(<%= exercise_question.id%>);"><i data-tip-down="编辑" class="fa fa-pencil color-orange05"></i></a>
</p>
</div>
<pre class="exercise_que_title pl15 pr15"><%= exercise_question.question_title %></pre>
<div style="text-align: justify;" class="pl15 pr15"><%= exercise_question.question_title.html_safe %></div>
<div class="pl15 pr15 mb10">
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<li class="clearfix">
@ -40,11 +40,23 @@
} else {
$("#insert_new_poll_question_"+quest_id).html("<%= escape_javascript(render :partial => 'new_MCQ', :locals => {:exercise=>@exercise}) %>");
$("#quest_id").val(quest_id);
$("#poll_questions_title").focus();
$(".questionTitle").on("input",function(){
$(this).height(30);
var scrollVal = $(this)[0].scrollHeight;
$(this).height(scrollVal);
KindEditor.ready(function(K){
$("div[nhname='new_exercise_mc_q']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
params.placeholder = "请输入多选题的题干";
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[name='question_title']",params.div_form);
if(params.textarea.data('init') == undefined) {
params.editor = init_exercise_quetison_editor(params);
new_quetion_title_editor = params.editor;
params.textarea.data('init', 1);
}
});
});
}
}else {

View File

@ -13,7 +13,7 @@
<a href="javascript:void(0)" onclick="exQuestionEdit(<%= exercise_question.id%>);"><i data-tip-down="编辑" class="fa fa-pencil color-orange05"></i></a>
</p>
</div>
<pre class="exercise_que_title pl15 mb10 pr15"><%= exercise_question.question_title %></pre>
<div style="text-align: justify;" class="pl15 pr15"><%= exercise_question.question_title.html_safe %></div>
<div class="clearfix bor-top-greyE padding15 answer_con">
<p>参考答案:</p>
<pre class="exercise_que_title" style="text-align:justify;"><%= exercise_question.exercise_standard_answers.count > 0 ? exercise_question.exercise_standard_answers.first.answer_text : "无"%></pre>
@ -33,11 +33,23 @@
} else {
$("#insert_new_poll_question_"+quest_id).html("<%= escape_javascript(render :partial => 'new_multi', :locals => {:exercise=>@exercise}) %>");
$("#quest_id").val(quest_id);
$("#poll_questions_title").focus();
$(".questionTitle").on("input",function(){
$(this).height(30);
var scrollVal = $(this)[0].scrollHeight;
$(this).height(scrollVal);
KindEditor.ready(function(K){
$("div[nhname='new_exercise_mc_q']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
params.placeholder = "请输入简答题的题干";
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[name='question_title']",params.div_form);
if(params.textarea.data('init') == undefined) {
params.editor = init_exercise_quetison_editor(params);
new_quetion_title_editor = params.editor;
params.textarea.data('init', 1);
}
});
});
}
} else {

View File

@ -13,7 +13,7 @@
<a href="javascript:void(0)" onclick="exQuestionEdit(<%= exercise_question.id%>);"><i data-tip-down="编辑" class="fa fa-pencil color-orange05"></i></a>
</p>
</div>
<pre class="exercise_que_title pl15 pr15"><%= exercise_question.question_title %></pre>
<div style="text-align: justify;" class="pl15 pr15"><%= exercise_question.question_title.html_safe %></div>
<div class="pl15 pr15 pt10 pb10 bor-top-greyE">
<% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>
<p>候选答案<%= convert_to_chi_num(index+1) %><%= exercise_choice.answer_text%></p>
@ -34,11 +34,23 @@
} else {
$("#insert_new_poll_question_"+quest_id).html("<%= escape_javascript(render :partial => 'new_single', :locals => {:exercise=>@exercise}) %>");
$("#quest_id").val(quest_id);
$("#poll_questions_title").focus();
$(".questionTitle").on("input",function(){
$(this).height(30);
var scrollVal = $(this)[0].scrollHeight;
$(this).height(scrollVal);
KindEditor.ready(function(K){
$("div[nhname='new_exercise_mc_q']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
params.placeholder = "请输入填空题的题干(注意:目前仅支持一个空)";
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[name='question_title']",params.div_form);
if(params.textarea.data('init') == undefined) {
params.editor = init_exercise_quetison_editor(params);
new_quetion_title_editor = params.editor;
params.textarea.data('init', 1);
}
});
});
}
} else {

View File

@ -2521,7 +2521,7 @@ function init_exercise_quetison_editor(params){
},
afterBlur:function(){
params.textarea.blur();
if(this.isEmpty() || /^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\]*[\u4e00-\u9fa5]*[\。]*<\/\w*\>\s*$/.test(this.edit.html())) {
if(this.isEmpty() || /^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\]*[\]*[\u4e00-\u9fa5]*[\]*[\u4e00-\u9fa5]*[\。]*[\]*<\/\w*\>\s*$/.test(this.edit.html())) {
this.edit.html("<span id='hint' style='color:#999999;font-size:12px;'>"+params.placeholder+"</span>");
this.resize("90%", null);
}
@ -2529,7 +2529,7 @@ function init_exercise_quetison_editor(params){
afterFocus: function(){
var edit = this.edit;
var body = edit.doc.body;
if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\]*[\u4e00-\u9fa5]*[\。]*<\/\w*\>\s*$/.test(edit.html())){
if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\]*[\]*[\u4e00-\u9fa5]*[\]*[\u4e00-\u9fa5]*[\。]*[\]*<\/\w*\>\s*$/.test(edit.html())){
edit.html("");
}
this.resize("90%", null);
@ -2540,9 +2540,8 @@ function init_exercise_quetison_editor(params){
var body = edit.doc.body;
edit.iframe[0].scroll = 'no';
body.style.overflowY = 'hidden';
if(params.textarea.innerHTML != ""){
edit.html(params.textarea.innerHTML);
} else{
edit.html(params.textarea.innerHTML);
if(this.isEmpty()) {
edit.html("<span id='hint' style='color:#999999;font-size:12px;'>"+params.placeholder+"</span>");
}
}

View File

@ -654,6 +654,7 @@ function ex_setting_form_submit(){
//添加标题时确定按钮
function add_ex_question(doc,quest_type)
{
new_quetion_title_editor.sync();
var title = $.trim($("#poll_questions_title").val());
var score = $.trim($("#question_score").val());
var standard_ans = $.trim($("#exercise_choice_" + quest_type).val());
@ -701,12 +702,11 @@ function exQuestionEdit(question_id){
$("#edit_poll_questions_"+question_id).show();
$("#poll_questions_title_"+question_id).focus();
KindEditor.ready(function(K){
$("div[nhname='edit_exercise_mc_q_"+question_id+"']").each(function(){
$("div#edit_poll_questions_"+question_id).each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
params.placeholder = "请输入单选题的题干";
if(params.form==undefined || params.form.length==0){
return;
}