启用匿评和禁用匿评时修改评分设置

This commit is contained in:
cxt 2016-04-21 17:00:30 +08:00
parent e6916f356a
commit 16348654a5
3 changed files with 30 additions and 8 deletions

View File

@ -73,11 +73,17 @@ class HomeworkCommonController < ApplicationController
else
@homework.publish_time = params[:homework_common][:publish_time]
end
homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
@homework.end_time = params[:homework_common][:end_time] || Time.now
@homework.course_id = params[:course_id]
@homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 0
if params[:homework_common][:anonymous_comment] && params[:homework_common][:anonymous_comment] != @homework.anonymous_comment
if @homework.anonymous_comment == 1
homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 1.0 : 0.4
else
homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3
end
end
homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0
homework_detail_manual.comment_status = 1
end
@ -94,6 +100,13 @@ class HomeworkCommonController < ApplicationController
@homework.homework_detail_programing ||= HomeworkDetailPrograming.new
@homework_detail_programing = @homework.homework_detail_programing
@homework_detail_programing.language = params[:language_type].to_i
if params[:homework_common][:anonymous_comment] && params[:homework_common][:anonymous_comment] != @homework.anonymous_comment
if @homework.anonymous_comment == 1
@homework_detail_programing.ta_proportion = 0.6
else
@homework_detail_programing.ta_proportion = 0.5
end
end
@homework.homework_tests.delete_all
inputs = params[:program][:input]
@ -116,6 +129,7 @@ class HomeworkCommonController < ApplicationController
@homework_detail_group.base_on_project = params[:base_on_project].to_i
end
@homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 0
if @homework.save
@homework_detail_manual.save if @homework_detail_manual
@homework_detail_programing.save if @homework_detail_programing

View File

@ -750,7 +750,11 @@ class UsersController < ApplicationController
render_attachment_warning_if_needed(homework)
homework_detail_manual = HomeworkDetailManual.new
homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3
if homework.anonymous_comment == 1
homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 1.0 : 0.4
else
homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3
end
if homework.publish_time > Date.today
homework_detail_manual.comment_status = 0
else
@ -766,7 +770,11 @@ class UsersController < ApplicationController
if homework.homework_type == 2
homework_detail_programing = HomeworkDetailPrograming.new
homework.homework_detail_programing = homework_detail_programing
homework_detail_programing.ta_proportion = 0.5
if homework.anonymous_comment == 1
homework_detail_programing.ta_proportion = 0.6
else
homework_detail_programing.ta_proportion = 0.5
end
homework_detail_programing.language = params[:language_type].to_i
inputs = params[:program][:input]

View File

@ -19,21 +19,21 @@
<script>
$("#sy_proportion").change(function(){
var ta_proportion = 100 - parseInt($("#sy_proportion").val() * 100);
var ta_proportion = 100 - parseInt(parseFloat($("#sy_proportion").val()) * 100);
$("#ta_proportion").replaceWith(build_selector(ta_proportion));
$("#student_proportion").val("0%");
});
$("#ta_proportion").live("change",function(){
var ta_proportion = 100 - parseInt($("#sy_proportion").val() * 100) - parseInt($("#ta_proportion").val() * 100);
var ta_proportion = 100 - parseInt(parseFloat($("#sy_proportion").val()) * 100) - parseInt(parseFloat($("#ta_proportion")).val() * 100);
$("#student_proportion").val(ta_proportion + "%");
});
</script>
<% else%>
<script>
$("#ta_proportion").change(function(){
var ta_proportion = $("#ta_proportion").val();
$("#student_proportion").val((100 - parseInt(ta_proportion * 100)) + "%");
var ta_proportion = parseFloat($("#ta_proportion").val());
$("#student_proportion").val((100 - parseFloat(parseInt(ta_proportion * 100))) + "%");
});
</script>
<% end%>