From 66636efda9cf76da85b9562057b74c9a9fa45f75 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 11 Sep 2015 09:15:54 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=99=AE=E9=80=9A?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 133 ++++-------------- app/views/users/_user_homework_form.html.erb | 6 +- 2 files changed, 31 insertions(+), 108 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 862e6c80e..b60b12d36 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -142,116 +142,37 @@ class HomeworkCommonController < ApplicationController end def update - @homework.name = params[:homework_common][:name] - @homework.description = params[:homework_common][:description] - @homework.end_time = params[:homework_common][:end_time] - @homework.publish_time = params[:homework_common][:publish_time] - @homework.homework_type = params[:homework_common][:homework_type] if params[:homework_common][:homework_type] - unless @homework.late_penalty == params[:late_penalty] - @homework.student_works.where("created_at > '#{@homework.end_time} 23:59:59'").each do |student_work| - student_work.late_penalty = params[:late_penalty] - student_work.save - end - @homework.late_penalty = params[:late_penalty] - end - # @homework.course_id = @course.id + if params[:homework_common] + @homework.name = params[:homework_common][:name] + @homework.description = params[:homework_common][:description] + @homework.end_time = params[:homework_common][:end_time] || Time.now + @homework.course_id = params[:course_id] - #匿评作业相关属性 - if @homework.homework_type == 1 && @homework_detail_manual - @homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 - @homework_detail_manual.evaluation_start = params[:evaluation_start] - @homework_detail_manual.evaluation_end = params[:evaluation_end] - @homework_detail_manual.evaluation_num = params[:evaluation_num] - unless @homework_detail_manual.absence_penalty == params[:absence_penalty] - if @homework_detail_manual.comment_status == 3 #当前作业处于匿评结束状态,修改缺评扣分才会修改每个作品应扣分的值 - work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")" - @homework.student_works.each do |student_work| - absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count - student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0 - student_work.save - end - end - @homework_detail_manual.absence_penalty = params[:absence_penalty] - end - elsif @homework.homework_type == 0 #普通作业,缺评扣分为0分,每个作品的缺评扣分改为0分,防止某些作业在结束匿评之后改为普通作业 - @homework.student_works.where("absence_penalty != 0").each do |student_work| - student_work.late_penalty = 0 - student_work.save - end - @homework_detail_manual.absence_penalty = 0 if @homework_detail_manual - end + @homework.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(@homework) - if @homework.homework_type == 2 && @homework_detail_programing #编程作业 - @homework_detail_programing.language = params[:language] - @homework_detail_programing.standard_code = params[:standard_code] - @homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6 - homework_tests = @homework.homework_tests - #需要删除的测试 - ids = homework_tests.map(&:id) - params[:input].keys.map(&:to_i) - ids.each do |id| - homework_test = HomeworkTest.find id - homework_test.destroy if homework_test - end - if params[:input] && params[:output] && params[:result] - params[:input].each do |k,v| - if params[:output].include? k - homework_test = HomeworkTest.find_by_id k - if homework_test #已存在的测试,修改 - homework_test.input = v - homework_test.output = params[:output][k] - homework_test.result = params[:result][k] - homework_test.error_msg = params[:error_msg] - else #不存在的测试,增加 - homework_test = HomeworkTest.new - homework_test.input = v - homework_test.output = params[:output][k] - homework_test.result = params[:result][k] - homework_test.error_msg = params[:error_msg] - homework_test.homework_common = @homework - end - homework_test.save - end - end + #编程作业相关属性 + if @homework.homework_type == 2 + # homework_detail_programing = HomeworkDetailPrograming.new + # homework.homework_detail_programing = homework_detail_programing + # homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6 + # homework_detail_programing.language = params[:language_type].to_i + # + # inputs = params[:program][:input] + # if Array === inputs + # inputs.each_with_index do |val, i| + # homework.homework_tests << HomeworkTest.new( + # input: val, + # output: params[:program][:output][i] + # ) + # end + # end end - #发送修改作业的请求 - question = {title:@homework.name,content:@homework.description} - question[:input] = [] - question[:output] = [] - @homework.homework_tests.each do |test| - question[:input] << test.input - question[:output] << test.output - end - # uri = URI("http://192.168.80.21:8080/api/questions/#{@homework_detail_programing.question_id}.json") - # body = question.to_json - # res = Net::HTTP.new(uri.host, uri.port).start do |client| - # request = Net::HTTP::Put.new(uri.path) - # request.body = body - # request["Content-Type"] = "application/json" - # client.request(request) - # end - # result = JSON.parse(res.body) - end - - @homework.save_attachments(params[:attachments]) - render_attachment_warning_if_needed(@homework) - - if @homework.save - @homework_detail_manual.save if @homework_detail_manual - @homework_detail_programing.save if @homework_detail_programing - respond_to do |format| - format.html { - flash[:notice] = l(:notice_successful_edit) - redirect_to homework_common_index_path(:course => @course.id) - } - end - return - else - respond_to do |format| - format.html { - flash[:notice] = l(:notice_failed_edit) - redirect_to edit_homework_common_path(@homework) - } + if @homework.save + @homework_detail_manual.save if @homework_detail_manual + @homework_detail_programing.save if @homework_detail_programing + redirect_to user_homeworks_user_path(User.current.id) end end end diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index dfb48ef95..988c95643 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -45,11 +45,13 @@
- 发送 - <% if edit_mode %> + 确定 + <%= link_to "取消",user_homeworks_user_path(User.current.id),:class => "fr mr10 mt3"%> <% else %> + 发送 + 取消 <% end %>
From 948a6c9138ebb13047468aa2fd92343ba55b44ad Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 11 Sep 2015 09:20:43 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E9=9A=90=E8=97=8F=E6=95=99=E5=B8=88?= =?UTF-8?q?=E8=8A=82=E7=9B=B8=E5=85=B3=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/new_base_user.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index c337bb672..8676c6fb1 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -27,7 +27,7 @@
-
+
From a94521f2e15bf0b73d3c543c62709bd9fae7d2e8 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 11 Sep 2015 09:36:44 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=99=AE=E9=80=9A?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=8A=9F=E8=83=BD=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 1 + app/helpers/homework_common_helper.rb | 1 + app/views/users/_user_homework_form.html.erb | 2 +- public/javascripts/new_user.js | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index b60b12d36..a3b981b22 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -3,6 +3,7 @@ class HomeworkCommonController < ApplicationController require 'json' require "base64" layout "base_courses" + include StudentWorkHelper before_filter :find_course, :only => [:index,:new,:create,:next_step] before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy] diff --git a/app/helpers/homework_common_helper.rb b/app/helpers/homework_common_helper.rb index 43f815250..a03c4ccd7 100644 --- a/app/helpers/homework_common_helper.rb +++ b/app/helpers/homework_common_helper.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +include UsersHelper module HomeworkCommonHelper #迟交扣分下拉框 def late_penalty_option diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 988c95643..b4118bd2a 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -46,7 +46,7 @@
<% if edit_mode %> - 确定 + 确定 <%= link_to "取消",user_homeworks_user_path(User.current.id),:class => "fr mr10 mt3"%> <% else %> diff --git a/public/javascripts/new_user.js b/public/javascripts/new_user.js index 8362217a7..eb50c2762 100644 --- a/public/javascripts/new_user.js +++ b/public/javascripts/new_user.js @@ -71,6 +71,7 @@ function submit_homework(id) $("#course_id").focus(); } else{ + homework_description_editor.sync(); $("#"+id).submit(); } From 30ebe9b2d53469b1404f14828f7149a341497171 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 11 Sep 2015 09:59:34 +0800 Subject: [PATCH 4/9] =?UTF-8?q?1=E3=80=81=E7=BC=96=E7=A8=8B=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E5=8F=AF=E4=BB=A5=E5=BC=80=E5=90=AF=E5=8C=BF=E8=AF=84?= =?UTF-8?q?=202=E3=80=81=E5=8F=96=E6=B6=88=E6=89=A3=E5=88=86=E6=A0=87?= =?UTF-8?q?=E5=87=86=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 36 +++++++++++++----------- app/views/homework_common/index.html.erb | 14 ++++----- app/views/student_work/index.html.erb | 14 ++++----- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4c78c03df..a1663c76b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2297,25 +2297,27 @@ module ApplicationHelper #获取匿评相关连接代码 def homework_anonymous_comment homework - if homework.homework_type == 1 && homework.homework_detail_manual #匿评作业 - if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") - link = "启动匿评".html_safe - elsif homework.student_works.count >= 2 #作业份数大于2 - case homework.homework_detail_manual.comment_status - when 1 - link = link_to '启动匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'fr mr10 work_edit' - when 2 - link = link_to '关闭匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'fr mr10 work_edit' - when 3 - link = "匿评结束".html_safe - end - else - link = "启动匿评".html_safe + # if homework.homework_type == 1 && homework.homework_detail_manual #匿评作业 + # + # elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业作业 + # link = "编程作业".html_safe + # else + # link = "启动匿评".html_safe + # end + + if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") + link = "启动匿评".html_safe + elsif homework.student_works.count >= 2 #作业份数大于2 + case homework.homework_detail_manual.comment_status + when 1 + link = link_to '启动匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'fr mr10 work_edit' + when 2 + link = link_to '关闭匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'fr mr10 work_edit' + when 3 + link = "匿评结束".html_safe end - elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业作业 - link = "编程作业".html_safe else - link = "启动匿评".html_safe + link = "启动匿评".html_safe end link end diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index bbf4aa343..694069b44 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -98,17 +98,17 @@
<% end%> -
+ <%= l(:label_end_time)%>:<%= homework.end_time%> <% if betweentime(homework.end_time) < 0 %> diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index 776af3b3e..e8fa33902 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -185,18 +185,18 @@
-
+ 截止时间:<%= @homework.end_time%>
<% if betweentime(@homework.end_time) < 0 %> From 7db774eedb8c57b769731aae3a5ec252fee49cdb Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 11 Sep 2015 10:19:45 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=8C=BF=E8=AF=84=E7=9B=B8=E5=85=B3=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E4=B8=BA=E4=BD=9C=E4=B8=9A=E5=BF=85=E9=A1=BB=E5=B1=9E?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 088271e86..d332af793 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -408,17 +408,17 @@ class UsersController < ApplicationController homework.save_attachments(params[:attachments]) render_attachment_warning_if_needed(homework) - #匿评作业相关属性 - if homework.homework_type == 1 - homework_detail_manual = HomeworkDetailManual.new - homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 - homework_detail_manual.comment_status = 1 - homework_detail_manual.evaluation_start = Time.now - homework_detail_manual.evaluation_end = Time.now - homework_detail_manual.evaluation_num = params[:evaluation_num] || 3 - homework_detail_manual.absence_penalty = 2 - homework.homework_detail_manual = homework_detail_manual - else + homework_detail_manual = HomeworkDetailManual.new + homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 + homework_detail_manual.comment_status = 1 + homework_detail_manual.evaluation_start = Time.now + homework_detail_manual.evaluation_end = Time.now + homework_detail_manual.evaluation_num = params[:evaluation_num] || 3 + homework_detail_manual.absence_penalty = 2 + homework.homework_detail_manual = homework_detail_manual + + #编程作业相关属性 + if homework.homework_type == 2 homework_detail_programing = HomeworkDetailPrograming.new homework.homework_detail_programing = homework_detail_programing homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6 From dfed4885de1fbb8e1eafc4d18d7a1f07df717a17 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 11 Sep 2015 10:36:16 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=EF=BC=8C=E5=8F=96=E6=B6=88=E4=B9=8B=E5=90=8E=E7=BC=96=E7=A8=8B?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=8C=89=E9=92=AE=E6=B6=88=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_homeworks.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/user_homeworks.html.erb b/app/views/users/user_homeworks.html.erb index b3aaf5ece..f375496d1 100644 --- a/app/views/users/user_homeworks.html.erb +++ b/app/views/users/user_homeworks.html.erb @@ -3,7 +3,7 @@ $("#homework_name").val(""); $("#homework_end_time").val(""); $("#course_id").val($("#option_select").val()); - $("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new })%>"); + $("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new,:has_program => true })%>"); homework_description_editor.html(""); $("#homework_editor").toggle(); } From 527ff41d4305eb83b060f715ff5cee04ae641d19 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 11 Sep 2015 10:44:10 +0800 Subject: [PATCH 7/9] =?UTF-8?q?1=E3=80=81=E7=BC=96=E7=A8=8B=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E5=BC=80=E5=90=AF=E5=8C=BF=E8=AF=84=E4=B9=8B=E5=90=8E?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BD=9C=E5=93=81=E7=9A=84=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=202=E3=80=81=E5=8C=BF=E8=AF=84=E5=BC=B9=E6=A1=86=E4=B8=8D?= =?UTF-8?q?=E5=8F=AF=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/new.html.erb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index 556f054f1..85c23f300 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -1,17 +1,20 @@
From f4c19c0fb0224ec09f8171ea9fb2559549316afc Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 11 Sep 2015 10:50:16 +0800 Subject: [PATCH 8/9] =?UTF-8?q?1=E3=80=81homework.js=20=20=20on=E6=94=B9?= =?UTF-8?q?=E4=B8=BAlive=202=E3=80=81=E5=AF=BC=E5=85=A5=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=EF=BC=8C=E7=BC=96=E7=A8=8B=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=B6=88=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_select_homework.js.erb | 2 +- public/javascripts/homework.js | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/views/users/user_select_homework.js.erb b/app/views/users/user_select_homework.js.erb index a18fdacc8..acffd2506 100644 --- a/app/views/users/user_select_homework.js.erb +++ b/app/views/users/user_select_homework.js.erb @@ -3,6 +3,6 @@ hideModal('#coursesChoosePopup'); $("#homework_name").val("<%= @homework.name%>"); $("#homework_end_time").val("<%= @homework.end_time%>"); $("#course_id").val("<%= @homework.course_id%>"); -$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => @homework })%>"); +$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => @homework,:has_program => true })%>"); homework_description_editor.html("<%= escape_javascript(@homework.description.html_safe)%>"); $("#homework_editor").show(); diff --git a/public/javascripts/homework.js b/public/javascripts/homework.js index c136029bf..773a2c209 100644 --- a/public/javascripts/homework.js +++ b/public/javascripts/homework.js @@ -58,10 +58,10 @@ $(function(){ ); }; - $('#test-program-btn').on('click', test_program); + $('#test-program-btn').live('click', test_program); - $('#commit-program-work-btn').on('click', function(){ + $('#commit-program-work-btn').live('click', function(){ if(!valid_form()){ return; } @@ -89,7 +89,7 @@ $(function(){ $(".HomeWorkCon form").submit(); }); - $('form.edit_student_work').on('keydown', '#program-src', function(){ + $('form.edit_student_work').live('keydown', '#program-src', function(){ tested = false; }); @@ -104,12 +104,12 @@ $(function(){ $('input.date-input').datepicker(datepickerOptions); - $('a.pic_date').on('click', function(){ + $('a.pic_date').live('click', function(){ $(this).parent().prev().first().focus(); }) - $('a.ProBtn').on('click', function(){ + $('a.ProBtn').live('click', function(){ $("#BluePopupBox").dialog({ modal: true, dialogClass: 'BluePopupBox', @@ -117,12 +117,12 @@ $(function(){ }); $(".ui-dialog-titlebar").hide(); - $("a.CloseBtn").on('click', function(){ + $("a.CloseBtn").live('click', function(){ $("#BluePopupBox" ).dialog("close"); }); $('#textarea_input_test').focus(); - $("#BluePopupBox a.BlueCirBtn").on('click', function(){ + $("#BluePopupBox a.BlueCirBtn").live('click', function(){ var test_numbers = 0; var valid = true; var input = null; @@ -162,12 +162,12 @@ $(function(){ }); }); - $("#BluePopupBox").on('click', 'a.icon_add', function(){ + $("#BluePopupBox").live('click', 'a.icon_add', function(){ var html = bt('t:test-answer-list', null); $(this).parent('.mt10').after(html); }); - $("#BluePopupBox").on('click', 'a.icon_remove', function(){ + $("#BluePopupBox").live('click', 'a.icon_remove', function(){ $(this).parent('.mt10').remove(); }); }); \ No newline at end of file From cd36965cd12af08846a73f0e6eb60bb043306fb7 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 11 Sep 2015 11:31:59 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E5=8E=86=E5=8F=B2=E7=BC=96=E7=A8=8B?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=95=B0=E6=8D=AE=E8=A1=A5=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 15 +-- ...0150911031029_about_programing_homework.rb | 25 +++++ db/schema.rb | 103 ++++++++++-------- 3 files changed, 86 insertions(+), 57 deletions(-) create mode 100644 db/migrate/20150911031029_about_programing_homework.rb diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index a3b981b22..d4c02860e 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -154,20 +154,7 @@ class HomeworkCommonController < ApplicationController #编程作业相关属性 if @homework.homework_type == 2 - # homework_detail_programing = HomeworkDetailPrograming.new - # homework.homework_detail_programing = homework_detail_programing - # homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6 - # homework_detail_programing.language = params[:language_type].to_i - # - # inputs = params[:program][:input] - # if Array === inputs - # inputs.each_with_index do |val, i| - # homework.homework_tests << HomeworkTest.new( - # input: val, - # output: params[:program][:output][i] - # ) - # end - # end + end if @homework.save diff --git a/db/migrate/20150911031029_about_programing_homework.rb b/db/migrate/20150911031029_about_programing_homework.rb new file mode 100644 index 000000000..50786834b --- /dev/null +++ b/db/migrate/20150911031029_about_programing_homework.rb @@ -0,0 +1,25 @@ +class AboutProgramingHomework < ActiveRecord::Migration + def up + HomeworkCommon.where(:homework_type => 2).each do |homework| + unless homework.homework_detail_manual + homework_detail_manual = HomeworkDetailManual.new + homework_detail_manual.ta_proportion = 0.6 + homework_detail_manual.comment_status = 1 + homework_detail_manual.evaluation_start = homework.created_at + homework_detail_manual.evaluation_end = homework.created_at + homework_detail_manual.evaluation_num = 3 + homework_detail_manual.absence_penalty = 2 + homework_detail_manual.homework_common_id = homework.id + homework_detail_manual.save + end + end + end + + def down + HomeworkCommon.where(:homework_type => 2).each do |homework| + if homework.homework_detail_manual + homework.homework_detail_manual.destroy + end + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 96b243891..008e13129 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150907152238) do +ActiveRecord::Schema.define(:version => 20150911031029) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -236,6 +236,13 @@ ActiveRecord::Schema.define(:version => 20150907152238) do t.boolean "tracker_in_review_dialog", :default => false end + create_table "code_review_user_settings", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.integer "mail_notification", :default => 0, :null => false + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "code_reviews", :force => true do |t| t.integer "project_id" t.integer "change_id" @@ -469,6 +476,13 @@ ActiveRecord::Schema.define(:version => 20150907152238) do add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" + create_table "discuss_demos", :force => true do |t| + t.string "title" + t.text "body" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "documents", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.integer "category_id", :default => 0, :null => false @@ -483,23 +497,26 @@ ActiveRecord::Schema.define(:version => 20150907152238) do add_index "documents", ["created_on"], :name => "index_documents_on_created_on" add_index "documents", ["project_id"], :name => "documents_project_id" - create_table "dts", :force => true do |t| - t.string "IPLineCode" - t.string "Description" - t.string "Num" - t.string "Variable" - t.string "TraceInfo" - t.string "Method" + create_table "dts", :primary_key => "Num", :force => true do |t| + t.string "Defect", :limit => 50 + t.string "Category", :limit => 50 t.string "File" - t.string "IPLine" - t.string "Review" - t.string "Category" - t.string "Defect" - t.string "PreConditions" - t.string "StartLine" + t.string "Method" + t.string "Module", :limit => 20 + t.string "Variable", :limit => 50 + t.integer "StartLine" + t.integer "IPLine" + t.string "IPLineCode", :limit => 200 + t.string "Judge", :limit => 15 + t.integer "Review", :limit => 1 + t.string "Description" + t.text "PreConditions", :limit => 2147483647 + t.text "TraceInfo", :limit => 2147483647 + t.text "Code", :limit => 2147483647 t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "id", :null => false end create_table "enabled_modules", :force => true do |t| @@ -764,16 +781,6 @@ ActiveRecord::Schema.define(:version => 20150907152238) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_details_copy", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" @@ -909,7 +916,6 @@ ActiveRecord::Schema.define(:version => 20150907152238) do t.datetime "created_on" t.integer "comments_count", :default => 0, :null => false t.integer "course_id" - t.datetime "updated_on" end add_index "news", ["author_id"], :name => "index_news_on_author_id" @@ -1166,18 +1172,18 @@ ActiveRecord::Schema.define(:version => 20150907152238) do create_table "relative_memos", :force => true do |t| t.integer "osp_id" t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :null => false + t.string "subject", :null => false + t.text "content", :limit => 16777215, :null => false t.integer "author_id" - t.integer "replies_count", :default => 0 + t.integer "replies_count", :default => 0 t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.boolean "is_quote", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count_crawl", :default => 0 - t.integer "viewed_count_local", :default => 0 + t.boolean "lock", :default => false + t.boolean "sticky", :default => false + t.boolean "is_quote", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "viewed_count_crawl", :default => 0 + t.integer "viewed_count_local", :default => 0 t.string "url" t.string "username" t.string "userhomeurl" @@ -1202,6 +1208,19 @@ ActiveRecord::Schema.define(:version => 20150907152238) do add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" + create_table "rich_rich_files", :force => true do |t| + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "rich_file_file_name" + t.string "rich_file_content_type" + t.integer "rich_file_file_size" + t.datetime "rich_file_updated_at" + t.string "owner_type" + t.integer "owner_id" + t.text "uri_cache" + t.string "simplified_type", :default => "file" + end + create_table "roles", :force => true do |t| t.string "name", :limit => 30, :default => "", :null => false t.integer "position", :default => 1 @@ -1253,10 +1272,11 @@ ActiveRecord::Schema.define(:version => 20150907152238) do t.string "url" t.string "title" t.integer "share_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "project_id" t.integer "user_id" + t.string "description" end create_table "softapplications", :force => true do |t| @@ -1419,8 +1439,8 @@ ActiveRecord::Schema.define(:version => 20150907152238) do t.integer "zip_code" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false - t.integer "identity" t.string "technical_title" + t.integer "identity" t.string "student_id" t.string "teacher_realname" t.string "student_realname" @@ -1488,9 +1508,6 @@ ActiveRecord::Schema.define(:version => 20150907152238) do t.integer "active" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false - t.integer "level" - t.integer "file" - t.integer "issue" end create_table "user_statuses", :force => true do |t|