diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 9655d49be..a6ab0a68e 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -12,7 +12,7 @@ class StudentWorkController < ApplicationController ### def program_test - resultObj = {status: 0, results: [], error_msg: ''} + resultObj = {status: 0, results: [], error_msg: '', time: Time.now} student_work = find_or_save_student_work unless student_work resultObj[:status] = 100 @@ -27,11 +27,14 @@ class StudentWorkController < ApplicationController if result["status"].to_i == -2 #编译错误 results = [result["error_msg"]] end - student_work.student_work_tests.build(status: result["status"], results: results) + student_work_test = student_work.student_work_tests.build(status: result["status"], results: results, + src: params[:src]) unless student_work.save resultObj[:status] = 200 else resultObj[:status] = result["status"].to_i + resultObj[:time] = student_work_test.created_at.to_s(:db) + resultObj[:index] = student_work.student_work_tests.count end end @@ -154,7 +157,6 @@ class StudentWorkController < ApplicationController stundet_work.late_penalty = 0 end render_attachment_warning_if_needed(stundet_work) - if stundet_work.save if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分 diff --git a/app/models/student_work_test.rb b/app/models/student_work_test.rb index 00484a820..96aa1d6c3 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, :results, :status + attr_accessible :student_work_id, :results, :status, :src belongs_to :student_work serialize :results, Array diff --git a/app/views/homework_common/new.html.erb b/app/views/homework_common/new.html.erb index 464490462..375460ebb 100644 --- a/app/views/homework_common/new.html.erb +++ b/app/views/homework_common/new.html.erb @@ -1,4 +1,4 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> <%= error_messages_for 'homework_common' %>
第<%= @student_work.student_work_tests.count - index%>次测试
<%= format_time(test.created_at) %> +第<%= @student_work.student_work_tests.count - index%>次测试
<%= test.created_at.to_s(:db) %>t |