diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index d5b0a25bf..ee953e913 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -514,7 +514,7 @@ private end def has_login - unless @attachment.container_type == "PhoneAppVersion" + unless @attachment && @attachment.container_type == "PhoneAppVersion" render_403 unless User.current.logged? end end diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 50f303700..e71fd5e29 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -18,28 +18,28 @@ class HomeworkCommonController < ApplicationController end def new - @homework_type = "1" - - @homework = HomeworkCommon.new - @homework.safe_attributes = params[:homework_common] - @homework.late_penalty = 0 - @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') - @homework.publish_time = Time.now.strftime('%Y-%m-%d') - - if @homework_type == "1" - #匿评作业相关属性 - @homework_detail_manual = HomeworkDetailManual.new - @homework_detail_manual.ta_proportion = 0.6 - @homework_detail_manual.absence_penalty = 0 - @homework_detail_manual.evaluation_num = 3 - @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d') - @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d') - @homework.homework_detail_manual = @homework_detail_manual - elsif @homework_type == "2" - #编程作业相关属性 - @homework_detail_programing = HomeworkDetailPrograming.new - @homework.homework_detail_programing = @homework_detail_programing - end + # @homework_type = "1" + # + # @homework = HomeworkCommon.new + # @homework.safe_attributes = params[:homework_common] + # @homework.late_penalty = 0 + # @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') + # @homework.publish_time = Time.now.strftime('%Y-%m-%d') + # + # if @homework_type == "1" + # #匿评作业相关属性 + # @homework_detail_manual = HomeworkDetailManual.new + # @homework_detail_manual.ta_proportion = 0.6 + # @homework_detail_manual.absence_penalty = 0 + # @homework_detail_manual.evaluation_num = 3 + # @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d') + # @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d') + # @homework.homework_detail_manual = @homework_detail_manual + # elsif @homework_type == "2" + # #编程作业相关属性 + # @homework_detail_programing = HomeworkDetailPrograming.new + # @homework.homework_detail_programing = @homework_detail_programing + # end respond_to do |format| format.html end @@ -93,7 +93,7 @@ class HomeworkCommonController < ApplicationController if homework.homework_type == 2 homework_detail_programing = HomeworkDetailPrograming.new - homework_detail_programing.language = "C++" + homework_detail_programing.language = params[:language] homework_detail_programing.standard_code = params[:standard_code] homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6 question = {title:homework.name,content:homework.description} diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index dae0bcab6..209fa7269 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -128,7 +128,7 @@ class StudentWorkController < ApplicationController solutions = { student_work_id:stundet_work.id, src:Base64.encode64(stundet_work.description), - language:1 + language:@homework.homework_detail_programing.language } uri = URI(url) body = solutions.to_json diff --git a/app/helpers/homework_common_helper.rb b/app/helpers/homework_common_helper.rb index 81f817ee9..49384cca4 100644 --- a/app/helpers/homework_common_helper.rb +++ b/app/helpers/homework_common_helper.rb @@ -27,6 +27,19 @@ module HomeworkCommonHelper type end + def programing_languages_options + type = [] + option = [] + option << "C" + option << 1 + type << option + option_1 = [] + option_1 << "C++" + option_1 << 2 + type << option_1 + type + end + #缺评扣分 def absence_penalty_option type = [] diff --git a/app/models/student_work.rb b/app/models/student_work.rb index c80d1315b..b95c11c11 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -7,7 +7,7 @@ class StudentWork < ActiveRecord::Base has_many :student_works_evaluation_distributions, :dependent => :destroy has_many :student_works_scores, :dependent => :destroy belongs_to :project - has_one :student_work_test + has_many :student_work_test before_destroy :delete_praise diff --git a/app/views/homework_common/_homework_detail_programing_form.html.erb b/app/views/homework_common/_homework_detail_programing_form.html.erb index e27fb5b9e..5d1d5ce88 100644 --- a/app/views/homework_common/_homework_detail_programing_form.html.erb +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -56,9 +56,7 @@