diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 0fddd7e6c..5e290d678 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -86,7 +86,7 @@ class HomeworkCommonController < ApplicationController @homework.end_time = params[:homework_common][:end_time] || Time.now @homework.course_id = params[:course_id] @homework.homework_type = params[:homework_type].to_i || @homework.homework_type - anonymous = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 0 + anonymous = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 1 if anonymous != @homework.anonymous_comment if anonymous == 1 homework_detail_manual.ta_proportion = @homework.homework_type == 1 ? 1.0 : 0.4 @@ -112,7 +112,7 @@ class HomeworkCommonController < ApplicationController if @homework.homework_type == 2 @homework.homework_detail_programing ||= HomeworkDetailPrograming.new @homework_detail_programing = @homework.homework_detail_programing - @homework_detail_programing.language = params[:language_type].to_i + @homework_detail_programing.language = params[:language_type].to_i if params[:language_type] if anonymous != @homework.anonymous_comment if anonymous == 1 @homework_detail_programing.ta_proportion = 0.6 @@ -121,8 +121,8 @@ class HomeworkCommonController < ApplicationController end end - @homework.homework_tests.delete_all - inputs = params[:program][:input] + @homework.homework_tests.delete_all if params[:program] + inputs = params[:program][:input] if params[:program] if Array === inputs inputs.each_with_index do |val, i| @homework.homework_tests << HomeworkTest.new( @@ -137,12 +137,12 @@ class HomeworkCommonController < ApplicationController if @homework.homework_type == 3 @homework.homework_detail_group ||= HomeworkDetailGroup.new @homework_detail_group = @homework.homework_detail_group - @homework_detail_group.min_num = params[:min_num].to_i - @homework_detail_group.max_num = params[:max_num].to_i - @homework_detail_group.base_on_project = params[:base_on_project].to_i + @homework_detail_group.min_num = params[:min_num].to_i if params[:min_num] + @homework_detail_group.max_num = params[:max_num].to_i if params[:max_num] + @homework_detail_group.base_on_project = params[:base_on_project].to_i if params[:base_on_project] end - @homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 0 + @homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 1 if @homework.save homework_detail_manual.save if homework_detail_manual @homework_detail_programing.save if @homework_detail_programing diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index b3e946f95..b7bf3543c 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -192,18 +192,6 @@ module CoursesHelper # garble count # end - def homework_type_option - type = [] - option1 = [] - option2 = [] - option1 << l(:label_task_submit_form_accessory) - option1 << 1 - option2 << l(:label_task_submit_form_project) - option2 << 2 - type << option1 - type << option2 - end - def proportion_option type = [] i = 0 diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index afc6cb1d9..88be249a1 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -224,19 +224,6 @@ module ProjectsHelper def get_projects_by_tag(tag_name) Project.tagged_with(tag_name).order('updated_on desc') end - - # added by fq - def homework_type_option - type = [] - option1 = [] - option2 = [] - option1 << l(:label_task_submit_form_accessory) - option1 << 1 - option2 << l(:label_task_submit_form_project) - option2 << 2 - type << option1 - type << option2 - end #是否启动互评下拉框 def is_evaluation_option diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 231c78b91..f225e4fcd 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -191,6 +191,9 @@ + <% if not_allow_select || group_pro %> + + <% end %>