已开启匿评的作业编辑后变成了“禁用匿评”的作业

This commit is contained in:
cxt 2017-01-13 10:49:00 +08:00
parent a0b06f5b80
commit 2aa99f57ac
2 changed files with 18 additions and 6 deletions

View File

@ -180,6 +180,12 @@ class HomeworkCommonController < ApplicationController
@homework_detail_group.base_on_project = params[:base_on_project] ? 1 : 0 @homework_detail_group.base_on_project = params[:base_on_project] ? 1 : 0
end end
if anonymous != @homework.anonymous_comment
@homework.student_works.where("work_status != 0").each do |student_work|
student_work.save
end
end
@homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 1 @homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 1
if @homework.save if @homework.save
homework_detail_manual.save if homework_detail_manual homework_detail_manual.save if homework_detail_manual
@ -196,7 +202,7 @@ class HomeworkCommonController < ApplicationController
elsif params[:is_manage] == "2" elsif params[:is_manage] == "2"
redirect_to my_homeworks_user_path(User.current.id) redirect_to my_homeworks_user_path(User.current.id)
elsif @hw_status == 1 elsif @hw_status == 1
redirect_to user_path(User.current.id) redirect_to user_course_community_path(User.current.id)
elsif @hw_status == 2 elsif @hw_status == 2
redirect_to course_path(@course.id) redirect_to course_path(@course.id)
elsif @hw_status == 5 elsif @hw_status == 5

View File

@ -57,10 +57,14 @@
<% end %> <% end %>
}); });
function checked_val() { function checked_val() {
if ($("#anonymous_comment").is(":checked")) { if ($("#anonymous_comment").length > 0){
$("#anonymous_comment").val(0); if ($("#anonymous_comment").is(":checked")) {
} else { $("#anonymous_comment").val(0);
$("#anonymous_comment").val(1); $("#real_anonymous_comment").val(0);
} else {
$("#anonymous_comment").val(1);
$("#real_anonymous_comment").val(1);
}
} }
} }
function nh_reset_homework_form(params){ function nh_reset_homework_form(params){
@ -232,11 +236,13 @@
</div> </div>
<% if !edit_mode || edit_mode && homework.homework_detail_manual.comment_status < 2 %> <% if !edit_mode || edit_mode && homework.homework_detail_manual.comment_status < 2 %>
<div class="fr f14 ml10" style="margin-top: 4px;"> <div class="fr f14 ml10" style="margin-top: 4px;">
<input type="checkbox" name="homework_common[anonymous_comment]" value="<%=edit_mode ? homework.anonymous_comment : 1 %>" id="anonymous_comment"/> <input type="checkbox" value="<%=edit_mode ? homework.anonymous_comment : 1 %>" id="anonymous_comment"/>
<span class="f14 c_grey">启用匿评</span> <span class="f14 c_grey">启用匿评</span>
<!--<span id="anonymous_hint" style="display: none; font-size: 12px;" class="c_red">更改后评分比例将恢复默认值</span>--> <!--<span id="anonymous_hint" style="display: none; font-size: 12px;" class="c_red">更改后评分比例将恢复默认值</span>-->
</div> </div>
<% end %> <% end %>
<input type="hidden" name="homework_common[anonymous_comment]" value="<%=edit_mode ? homework.anonymous_comment : 1 %>" id="real_anonymous_comment"/>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<p id="homework_end_time_span" class="c_red mt5"></p> <p id="homework_end_time_span" class="c_red mt5"></p>