diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 0b1a035c1..6066ef3d0 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -302,6 +302,7 @@ class ExerciseController < ApplicationController # 发布试卷 def publish_exercise @is_teacher = User.current.allowed_to?(:as_teacher,@course) + @index = params[:index] @exercise.exercise_status = 2 @exercise.publish_time = Time.now if @exercise.save @@ -316,11 +317,13 @@ class ExerciseController < ApplicationController # 重新发布的时候会删除所有的答题 def republish_exercise @is_teacher = User.current.allowed_to?(:as_teacher,@course) + @index = params[:index] @exercise.exercise_questions.each do |exercise_question| exercise_question.exercise_answers.destroy_all end @exercise.exercise_users.destroy_all @exercise.exercise_status = 1 + @exercise.publish_time = nil @exercise.save respond_to do |format| format.js diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb index ba82fbf82..91af83aee 100644 --- a/app/views/exercise/_exercise.html.erb +++ b/app/views/exercise/_exercise.html.erb @@ -8,7 +8,7 @@ <%# else %> <%#= link_to poll_name, exercise_path(poll.id), :class => "polls_title polls_title_w fl c_dblue" %> <%# end %> - <%= link_to (index+1).to_s+". "+exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_w fl c_dblue" %> + <%= link_to (index.to_i+1).to_s+". "+exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_w fl c_dblue" %> @@ -24,9 +24,9 @@ <%# end%> <% if exercise.exercise_status == 1 %> -
  • 发布试卷
  • +
  • 发布试卷
  • <% elsif exercise.exercise_status == 2%> -
  • 取消发布
  • +
  • 取消发布
  • <% else%>
  • 发布试卷
  • <% end%> diff --git a/app/views/exercise/index.html.erb b/app/views/exercise/index.html.erb index aacc79950..9b6961e6c 100644 --- a/app/views/exercise/index.html.erb +++ b/app/views/exercise/index.html.erb @@ -5,14 +5,14 @@ $("#homework_page_right").css("min-height",$("#LSide").height()-30); $("#Container").css("width","1000px"); }); - function republish_exercise(exercise_id) + function republish_exercise(exercise_id,index) { $('#ajax-modal').html("
    " + "
    " + "
    " + "

    取消发布后学生答题将会被清空
    是否确定取消发布该测验?

    " + "
    " + - "确  定" + + "确  定" + "取  消" + "
    " + "
    " + @@ -31,7 +31,7 @@ function clickCanel(){hideModal("#popbox02");} - function exercise_submit(exercise_id,exercise_name) + function exercise_submit(exercise_id,exercise_name,index) { if(exercise_name == 0) { @@ -44,7 +44,7 @@ "
    " + "

    测验发布后将不能对测验进行修改,
    是否确定发布该测验?

    " + "
    " + - "确  定" + + "确  定" + "取  消" + "
    " + "
    " + diff --git a/app/views/exercise/publish_exercise.js.erb b/app/views/exercise/publish_exercise.js.erb index ac2899402..c1c4a4fd5 100644 --- a/app/views/exercise/publish_exercise.js.erb +++ b/app/views/exercise/publish_exercise.js.erb @@ -1,4 +1,4 @@ -$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise}) %>"); +$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise,:index =>@index}) %>"); $('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_memo_create_succ)}) %>"); showModal('ajax-modal', '250px'); //$('#ajax-modal').css('height','111px'); diff --git a/app/views/exercise/republish_exercise.js.erb b/app/views/exercise/republish_exercise.js.erb index b7172fe9e..2b4e67606 100644 --- a/app/views/exercise/republish_exercise.js.erb +++ b/app/views/exercise/republish_exercise.js.erb @@ -1,4 +1,4 @@ -$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise}) %>"); +$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise,:index => @index}) %>"); $('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_poll_republish_success)}) %>"); showModal('ajax-modal', '250px'); //$('#ajax-modal').css('height','80px');