发布和取消发布

This commit is contained in:
cxt 2015-11-20 19:59:05 +08:00
parent a3122a9a2c
commit 9ca336a70a
5 changed files with 16 additions and 6 deletions

View File

@ -294,7 +294,7 @@ class ExerciseController < ApplicationController
# 重新发布的时候会删除所有的答题 # 重新发布的时候会删除所有的答题
def republish_exercise def republish_exercise
@exercise.exercise_questions.each do |exercise_question| @exercise.exercise_questions.each do |exercise_question|
exercise_question.exercise_ansers.destroy_all exercise_question.exercise_answers.destroy_all
end end
@exercise.exercise_users.destroy_all @exercise.exercise_users.destroy_all
@exercise.exercise_status = 1 @exercise.exercise_status = 1

View File

@ -20,8 +20,10 @@
<% if exercise.exercise_status == 1 %> <% if exercise.exercise_status == 1 %>
<li><a href="javascript:" class="pollsbtn btn_pu fl ml5" onclick="exercise_submit(<%= exercise.id%>,<%= exercise.exercise_name.length %>);">发布试卷</a></li> <li><a href="javascript:" class="pollsbtn btn_pu fl ml5" onclick="exercise_submit(<%= exercise.id%>,<%= exercise.exercise_name.length %>);">发布试卷</a></li>
<% else %> <% elsif exercise.exercise_status == 2%>
<li class="pollsbtn fl ml5 pollsbtn_grey">发布试卷</li> <li><a href="javascript:" class="pollsbtn btn_de fl ml5" onclick="republish_exercise(<%= exercise.id%>);">取消发布</a></li>
<% else%>
<li class="pollsbtn fl ml10 pollsbtn_grey" style="margin-left: 5px;" >发布试卷</li>
<% end%> <% end%>
<%= link_to(l(:button_delete), exercise,:method => :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml5 mr10") %> <%= link_to(l(:button_delete), exercise,:method => :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml5 mr10") %>

View File

@ -84,8 +84,11 @@
{ {
var title = $.trim($("#poll_questions_title").val()); var title = $.trim($("#poll_questions_title").val());
var score = $.trim($("#question_score").val()); var score = $.trim($("#question_score").val());
var standard_ans = $.trim($("#question_standard_ans").val());
if(title.length == 0 || score.length == 0){ if(title.length == 0 || score.length == 0){
alert("题目标题/分数不能为空"); alert("题目标题/分数不能为空");
}else if(standard_ans.length == 0) {
alert("标准答案不能为空");
}else{ }else{
doc.parent().parent().parent().submit();} doc.parent().parent().parent().submit();}
} }
@ -94,8 +97,11 @@
{ {
var title = $.trim($("#poll_questions_title_" + id).val()); var title = $.trim($("#poll_questions_title_" + id).val());
var score = $.trim($("#poll_question_score_"+ 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){ if(title.length == 0 || score.length == 0){
alert("题目标题不能为空"); alert("题目标题/分数不能为空");
}else if(standard_ans.length == 0) {
alert("标准答案不能为空");
}else{ }else{
doc.parent().parent().parent().submit();} doc.parent().parent().parent().submit();}
} }

View File

@ -1,6 +1,8 @@
<% if @is_insert %> <% if @is_insert %>
$("#poll_content").html('<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise})%>'); $("#poll_content").html('<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise})%>');
$("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :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 %> <% else %>
$("#new_exercise_question").html('<%= escape_javascript(render :partial => 'new_question', :locals => {:exercise => @exercise}) %>'); $("#new_exercise_question").html('<%= escape_javascript(render :partial => 'new_question', :locals => {:exercise => @exercise}) %>');
$("#new_poll_question").html(""); $("#new_poll_question").html("");
@ -35,6 +37,6 @@
"</div>" + "</div>" +
"</div>"); "</div>");
<% end %> <% end %>
$("#current_score").html("<%=get_current_score @exercise %>分");
$("#current_score_div").show(); $("#current_score_div").show();
$("#current_score").html("<%=get_current_score @exercise %>分");
<% end %> <% end %>

View File

@ -16,5 +16,5 @@ $("#poll_questions_<%= @exercise_question.id%>").html("<div id='show_poll_questi
"<%= escape_javascript(render :partial => 'edit_single', :locals => {:exercise_question => @exercise_question}) %>" + "<%= escape_javascript(render :partial => 'edit_single', :locals => {:exercise_question => @exercise_question}) %>" +
"<% end%>" + "<% end%>" +
"</div>"); "</div>");
$("#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}) %>"); $("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise_question.exercise}) %>");