From 9ca336a70a926d62ad2fa407fe4c115b238c7354 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 20 Nov 2015 19:59:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=92=8C=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 2 +- app/views/exercise/_exercise.html.erb | 6 ++++-- app/views/exercise/_exercise_form.html.erb | 8 +++++++- app/views/exercise/create_exercise_question.js.erb | 4 +++- app/views/exercise/update_exercise_question.js.erb | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 448c9a90a..94a5a8028 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -294,7 +294,7 @@ class ExerciseController < ApplicationController # 重新发布的时候会删除所有的答题 def republish_exercise @exercise.exercise_questions.each do |exercise_question| - exercise_question.exercise_ansers.destroy_all + exercise_question.exercise_answers.destroy_all end @exercise.exercise_users.destroy_all @exercise.exercise_status = 1 diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb index dfcc8d3b4..f5896c5e3 100644 --- a/app/views/exercise/_exercise.html.erb +++ b/app/views/exercise/_exercise.html.erb @@ -20,8 +20,10 @@ <% if exercise.exercise_status == 1 %>
  • 发布试卷
  • - <% else %> -
  • 发布试卷
  • + <% elsif exercise.exercise_status == 2%> +
  • 取消发布
  • + <% else%> +
  • 发布试卷
  • <% end%> <%= link_to(l(:button_delete), exercise,:method => :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml5 mr10") %> diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 22589097a..29ccc685d 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -84,8 +84,11 @@ { var title = $.trim($("#poll_questions_title").val()); var score = $.trim($("#question_score").val()); + var standard_ans = $.trim($("#question_standard_ans").val()); if(title.length == 0 || score.length == 0){ alert("题目标题/分数不能为空"); + }else if(standard_ans.length == 0) { + alert("标准答案不能为空"); }else{ doc.parent().parent().parent().submit();} } @@ -94,8 +97,11 @@ { var title = $.trim($("#poll_questions_title_" + id).val()); var score = $.trim($("#poll_question_score_"+ id).val()); + var standard_ans = $.trim($("#poll_question_standard_answer_" + id).val()); if(title.length == 0 || score.length == 0){ - alert("题目标题不能为空"); + alert("题目标题/分数不能为空"); + }else if(standard_ans.length == 0) { + alert("标准答案不能为空"); }else{ doc.parent().parent().parent().submit();} } diff --git a/app/views/exercise/create_exercise_question.js.erb b/app/views/exercise/create_exercise_question.js.erb index 9047cfeda..326a19ec8 100644 --- a/app/views/exercise/create_exercise_question.js.erb +++ b/app/views/exercise/create_exercise_question.js.erb @@ -1,6 +1,8 @@ <% if @is_insert %> $("#poll_content").html('<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise})%>'); $("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise}) %>"); + $("#current_score_div").show(); + $("#current_score").html("<%=get_current_score @exercise %>分"); <% else %> $("#new_exercise_question").html('<%= escape_javascript(render :partial => 'new_question', :locals => {:exercise => @exercise}) %>'); $("#new_poll_question").html(""); @@ -35,6 +37,6 @@ "" + ""); <% end %> -$("#current_score").html("<%=get_current_score @exercise %>分"); $("#current_score_div").show(); +$("#current_score").html("<%=get_current_score @exercise %>分"); <% end %> diff --git a/app/views/exercise/update_exercise_question.js.erb b/app/views/exercise/update_exercise_question.js.erb index ef9004c06..9e7822cb7 100644 --- a/app/views/exercise/update_exercise_question.js.erb +++ b/app/views/exercise/update_exercise_question.js.erb @@ -16,5 +16,5 @@ $("#poll_questions_<%= @exercise_question.id%>").html("
    {:exercise_question => @exercise_question}) %>" + "<% end%>" + "
    "); -$("#current_score").html("<%=get_current_score @exercise %>分"); +$("#current_score").html("<%=get_current_score @exercise_question.exercise %>分"); $("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise_question.exercise}) %>");