diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 50f303700..04a07e9a8 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -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..da2575456 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 @@ -157,7 +157,7 @@ class StudentWorkController < ApplicationController end def edit - if @homework.homework_type == 2 #编程作业不能修改作业 + if !User.current.admin? && @homework.homework_type == 2 #编程作业不能修改作业 render_403 else respond_to do |format| @@ -396,6 +396,7 @@ class StudentWorkController < ApplicationController if student_work_test.result == 0 student_score_count += 1 end + student_work_test.error_msg = params[:compile_error_msg] student_work_test.save! end end @@ -444,7 +445,7 @@ class StudentWorkController < ApplicationController #判断是不是当前作品的提交者 #提交者 && (非匿评作业 || 未开启匿评) 可以编辑作品 def author_of_work - render_403 unless (User.current.id == @work.user_id || User.current.admin?) && (@homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1 ) + render_403 unless User.current.admin? || (User.current.id == @work.user_id && @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1 ) end def teacher_of_course 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/models/student_work_test.rb b/app/models/student_work_test.rb index 2e6efdf0a..413528b82 100644 --- a/app/models/student_work_test.rb +++ b/app/models/student_work_test.rb @@ -1,6 +1,6 @@ # encoding: utf-8 class StudentWorkTest < ActiveRecord::Base - attr_accessible :student_work_id, :homework_test_id, :result + attr_accessible :student_work_id, :homework_test_id, :result, :error_msg belongs_to :homework_test belongs_to :student_work 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 @@