作业编辑

This commit is contained in:
cxt 2016-09-14 16:45:10 +08:00
parent 9002844188
commit e4efc8c302
4 changed files with 11 additions and 33 deletions

View File

@ -86,7 +86,7 @@ class HomeworkCommonController < ApplicationController
@homework.end_time = params[:homework_common][:end_time] || Time.now @homework.end_time = params[:homework_common][:end_time] || Time.now
@homework.course_id = params[:course_id] @homework.course_id = params[:course_id]
@homework.homework_type = params[:homework_type].to_i || @homework.homework_type @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 != @homework.anonymous_comment
if anonymous == 1 if anonymous == 1
homework_detail_manual.ta_proportion = @homework.homework_type == 1 ? 1.0 : 0.4 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 if @homework.homework_type == 2
@homework.homework_detail_programing ||= HomeworkDetailPrograming.new @homework.homework_detail_programing ||= HomeworkDetailPrograming.new
@homework_detail_programing = @homework.homework_detail_programing @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 != @homework.anonymous_comment
if anonymous == 1 if anonymous == 1
@homework_detail_programing.ta_proportion = 0.6 @homework_detail_programing.ta_proportion = 0.6
@ -121,8 +121,8 @@ class HomeworkCommonController < ApplicationController
end end
end end
@homework.homework_tests.delete_all @homework.homework_tests.delete_all if params[:program]
inputs = params[:program][:input] inputs = params[:program][:input] if params[:program]
if Array === inputs if Array === inputs
inputs.each_with_index do |val, i| inputs.each_with_index do |val, i|
@homework.homework_tests << HomeworkTest.new( @homework.homework_tests << HomeworkTest.new(
@ -137,12 +137,12 @@ class HomeworkCommonController < ApplicationController
if @homework.homework_type == 3 if @homework.homework_type == 3
@homework.homework_detail_group ||= HomeworkDetailGroup.new @homework.homework_detail_group ||= HomeworkDetailGroup.new
@homework_detail_group = @homework.homework_detail_group @homework_detail_group = @homework.homework_detail_group
@homework_detail_group.min_num = params[:min_num].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 @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 @homework_detail_group.base_on_project = params[:base_on_project].to_i if params[:base_on_project]
end 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 if @homework.save
homework_detail_manual.save if homework_detail_manual homework_detail_manual.save if homework_detail_manual
@homework_detail_programing.save if @homework_detail_programing @homework_detail_programing.save if @homework_detail_programing

View File

@ -192,18 +192,6 @@ module CoursesHelper
# garble count # garble count
# end # 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 def proportion_option
type = [] type = []
i = 0 i = 0

View File

@ -225,19 +225,6 @@ module ProjectsHelper
Project.tagged_with(tag_name).order('updated_on desc') Project.tagged_with(tag_name).order('updated_on desc')
end 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 def is_evaluation_option
type = [] type = []

View File

@ -191,6 +191,9 @@
<select class="homework-type-option fl mr10" name="homework_type" <%=(not_allow_select || group_pro) ? 'disabled' : '' %> id="homework_type_option"> <select class="homework-type-option fl mr10" name="homework_type" <%=(not_allow_select || group_pro) ? 'disabled' : '' %> id="homework_type_option">
<%= options_for_select(homework_type_option,homework.homework_type) %> <%= options_for_select(homework_type_option,homework.homework_type) %>
</select> </select>
<% if not_allow_select || group_pro %>
<input type="text" style="display: none" name="homework_type" value="<%=homework.homework_type %>"/>
<% end %>
<label class="fl c_grey f14 mt5">截止日期:</label> <label class="fl c_grey f14 mt5">截止日期:</label>
<div class="calendar_div fl mr10"> <div class="calendar_div fl mr10">
<input type="text" name="homework_common[end_time]" id="homework_end_time" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.end_time%>" > <input type="text" name="homework_common[end_time]" id="homework_end_time" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.end_time%>" >