From 44e3daa0d2ea1512534e84b24c41d4bbede1c761 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 16 Jun 2015 10:39:42 +0800 Subject: [PATCH 01/55] =?UTF-8?q?1=E3=80=81=E8=80=81=E5=B8=88=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E4=BD=9C=E4=B8=9A=EF=BC=8C=E4=B8=A4=E7=B1=BB=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E7=9A=84=E9=80=89=E6=8B=A9=202=E3=80=81=E7=BC=96?= =?UTF-8?q?=E7=A8=8B=E4=BD=9C=E4=B8=9A=E9=9D=99=E6=80=81=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=9A=84=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_common/new.html.erb | 118 +++++++++++++++++++++++-- public/javascripts/course.js | 21 +++++ public/stylesheets/public.css | 1 + 3 files changed, 132 insertions(+), 8 deletions(-) diff --git a/app/views/homework_common/new.html.erb b/app/views/homework_common/new.html.erb index b0fdc5299..4fd52c8a0 100644 --- a/app/views/homework_common/new.html.erb +++ b/app/views/homework_common/new.html.erb @@ -6,12 +6,114 @@ <%= l(:label_course_homework_new)%> -
- <%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> - <%= hidden_field_tag "course",@course.id%> - <%= render :partial => 'homework_common/homework_common_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> - 提交 - <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> - <% end%> +
+

请选择将要发布的作业类型 +

+ 人工评分的作业(支持匿名互评、灵活设置评分比例) +
+ 自动评测的编程作业(支持C++程序的自动评分) +
+ 下一步
-
\ No newline at end of file +
+ +
+
+ <%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> + <%= hidden_field_tag "course",@course.id%> + <%= render :partial => 'homework_common/homework_common_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> + 提交 + 上一步 + <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> + <% end%> +
+
+
+
+
+
    +
  • + + +
  • +
    +
  • + + +
  • +
    +
  • + +     -文件不超过200MB +
  • +
    +
  • + + + +
    +
  • +
  • + + + +
    +
  • +
    +
  • + + +  分 +
    +
  • +
+
+

编程评测设置

+
+
    +
  • + + +
    +
  • +
  • + + +
    +
  • +
  • + + +
  • +
  • + + +
  • +
  • OK !
  • +
    +
  • + + +
  • +
  • + + +
  • +
  • 测试
  • +
    +
+
+ 提交 + 上一步 + 取消 +
+
+
\ No newline at end of file diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 8f87767ed..b493277fd 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -394,6 +394,27 @@ function show_bid_dead_line(year,month,day,divname) + "" + "

作品提交还剩:

"); } + +//新建作业,下一步按钮 +function select_homework_common_type() +{ + if($("#homework_detail_manual_radio").attr("checked") == "checked"){ + $("#homework_detail_manual").show(); + } + else if($("#homework_detail_programing_radio").attr("checked") == "checked"){ + $("#homework_detail_programing").show(); + } + $("#hwork_new").hide(); +} + +//新建作业,上一步按钮 +function return_homework_common_type() +{ + $("#homework_detail_manual").hide(); + $("#homework_detail_programing").hide(); + $("#hwork_new").show(); +} + //验证新建作业的名字 function regex_homework_name() { diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 0ed497127..5b00dbd57 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -161,6 +161,7 @@ a.green_btn{background:#28be6c;color:#fff;font-size:14px; font-weight:normal; pa a:hover.green_btn{ background:#14ad5a;} .blue_btn{ background:#64bdd9; color:#fff; font-size:14px; font-weight:normal;padding:2px 10px; text-align:center;} a.blue_btn{background:#64bdd9;color:#fff;font-size:14px; font-weight:normal; padding:2px 10px; text-align:center;} +a.orange_btn_homework{background:#d63502;color:#fff;font-size:14px; font-weight:normal; padding:2px 10px; text-align:center;} a:hover.blue_btn{ background:#329cbd;cursor: pointer;} a.orange_btn{ background:#ff5722;color:#fff;font-size:14px; font-weight:normal; padding:2px 10px; text-align:center; } a:hover.orange_btn{ background:#d63502;} From 9423f4b45ab4b5b242a22d40e283f78560a78965 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 16 Jun 2015 10:50:27 +0800 Subject: [PATCH 02/55] =?UTF-8?q?1=E3=80=81=E5=8C=BF=E8=AF=84=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=94=B9=E5=90=8D=202=E3=80=81=E7=BC=96=E7=A8=8B?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E9=9D=99=E6=80=81=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... => _homework_detail_manual_form.html.erb} | 0 .../_homework_detail_programing_form.html.erb | 80 ++++++++++++++++ app/views/homework_common/edit.html.erb | 2 +- app/views/homework_common/new.html.erb | 92 ++----------------- 4 files changed, 89 insertions(+), 85 deletions(-) rename app/views/homework_common/{_homework_common_form.html.erb => _homework_detail_manual_form.html.erb} (100%) create mode 100644 app/views/homework_common/_homework_detail_programing_form.html.erb diff --git a/app/views/homework_common/_homework_common_form.html.erb b/app/views/homework_common/_homework_detail_manual_form.html.erb similarity index 100% rename from app/views/homework_common/_homework_common_form.html.erb rename to app/views/homework_common/_homework_detail_manual_form.html.erb diff --git a/app/views/homework_common/_homework_detail_programing_form.html.erb b/app/views/homework_common/_homework_detail_programing_form.html.erb new file mode 100644 index 000000000..d0556745b --- /dev/null +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -0,0 +1,80 @@ + +
+

编程评测设置

+
+ +
\ No newline at end of file diff --git a/app/views/homework_common/edit.html.erb b/app/views/homework_common/edit.html.erb index f9d3f8b70..87977c6a9 100644 --- a/app/views/homework_common/edit.html.erb +++ b/app/views/homework_common/edit.html.erb @@ -8,7 +8,7 @@
<%= form_for @homework do |f| %> - <%= render :partial => 'homework_common/homework_common_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %> + <%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %> 提交 <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> <% end%> diff --git a/app/views/homework_common/new.html.erb b/app/views/homework_common/new.html.erb index 4fd52c8a0..0c4780133 100644 --- a/app/views/homework_common/new.html.erb +++ b/app/views/homework_common/new.html.erb @@ -21,7 +21,7 @@
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> <%= hidden_field_tag "course",@course.id%> - <%= render :partial => 'homework_common/homework_common_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> + <%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> 提交 上一步 <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> @@ -31,89 +31,13 @@
-
    -
  • - - -
  • -
    -
  • - - -
  • -
    -
  • - -     -文件不超过200MB -
  • -
    -
  • - - - -
    -
  • -
  • - - - -
    -
  • -
    -
  • - - -  分 -
    -
  • -
-
-

编程评测设置

-
-
    -
  • - - -
    -
  • -
  • - - -
    -
  • -
  • - - -
  • -
  • - - -
  • -
  • OK !
  • -
    -
  • - - -
  • -
  • - - -
  • -
  • 测试
  • -
    -
-
- 提交 - 上一步 - 取消 + <%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> + <%= hidden_field_tag "course",@course.id%> + <%= render :partial => 'homework_common/homework_detail_programing_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> + 提交 + 上一步 + <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> + <% end%>
\ No newline at end of file From df96ece903c4b190410ee4b48fa706e0335eafa0 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 16 Jun 2015 10:51:58 +0800 Subject: [PATCH 03/55] =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A=EF=BC=9F=E5=8C=BF=E8=AF=84?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=EF=BC=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_common/new.html.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/homework_common/new.html.erb b/app/views/homework_common/new.html.erb index 0c4780133..239987035 100644 --- a/app/views/homework_common/new.html.erb +++ b/app/views/homework_common/new.html.erb @@ -21,6 +21,7 @@
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> <%= hidden_field_tag "course",@course.id%> + <%= hidden_field_tag "homework_common_tyle","homework_detail_manual"%> <%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> 提交 上一步 @@ -33,6 +34,7 @@
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> <%= hidden_field_tag "course",@course.id%> + <%= hidden_field_tag "homework_common_tyle","homework_detail_programing"%> <%= render :partial => 'homework_common/homework_detail_programing_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> 提交 上一步 From 8f645f840cfe0139d5796fdb6094fcd47b9470b0 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 16 Jun 2015 11:20:17 +0800 Subject: [PATCH 04/55] =?UTF-8?q?=E4=B8=8A=E4=B8=80=E6=AD=A5=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E6=A0=B7=E5=BC=8F=20=E7=BC=96=E7=A8=8B=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E9=83=A8=E5=88=86=E6=95=B0=E6=8D=AE=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_homework_detail_manual_form.html.erb | 1 - .../_homework_detail_programing_form.html.erb | 49 +++++++++++-------- app/views/homework_common/new.html.erb | 4 +- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/app/views/homework_common/_homework_detail_manual_form.html.erb b/app/views/homework_common/_homework_detail_manual_form.html.erb index fa45397f0..f70ec6017 100644 --- a/app/views/homework_common/_homework_detail_manual_form.html.erb +++ b/app/views/homework_common/_homework_detail_manual_form.html.erb @@ -10,7 +10,6 @@
  • -
    <% if edit_mode %> <%= f.kindeditor :description,:editor_id => 'homework_description_editor',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %> 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 d0556745b..12e6b7074 100644 --- a/app/views/homework_common/_homework_detail_programing_form.html.erb +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -1,41 +1,50 @@
    • - - + + +

    • - - + +
      + <% if edit_mode %> + <%= f.kindeditor :description,:editor_id => 'homework_description_editor_1',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %> + <% else %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + <%= f.kindeditor :description,:editor_id => 'homework_description_editor_1' %> + <% end %> +
    • -
    • +
    • -     -文件不超过200MB + <%= render :partial => 'attachments/new_form', :locals => {:container => homework} %>
    • - - - + + + <%= calendar_for('homework_end_time')%>
    • -
    • +
    • -
    • + +
    • - + <%= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %>  分
    • diff --git a/app/views/homework_common/new.html.erb b/app/views/homework_common/new.html.erb index 239987035..6a67c17d1 100644 --- a/app/views/homework_common/new.html.erb +++ b/app/views/homework_common/new.html.erb @@ -24,7 +24,7 @@ <%= hidden_field_tag "homework_common_tyle","homework_detail_manual"%> <%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> 提交 - 上一步 + 上一步 <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> <% end%>
    @@ -37,7 +37,7 @@ <%= hidden_field_tag "homework_common_tyle","homework_detail_programing"%> <%= render :partial => 'homework_common/homework_detail_programing_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> 提交 - 上一步 + 上一步 <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> <% end%>
  • From 61eb3ecc621e90a26bd9398a4fc1a501f1275e63 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 16 Jun 2015 14:45:57 +0800 Subject: [PATCH 05/55] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=BB=BA=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E4=B8=8A=E4=B8=80=E6=AD=A5=E4=B8=8B=E4=B8=80=E6=AD=A5?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E9=A1=B5=E9=9D=A2=E5=88=B7=E6=96=B0=202?= =?UTF-8?q?=E3=80=81=E4=B8=8B=E4=B8=80=E6=AD=A5=E8=B7=AF=E7=94=B1=E6=94=B9?= =?UTF-8?q?=E4=B8=BApost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 11 +++- app/views/homework_common/new.html.erb | 56 +++++++------------ app/views/homework_common/next_step.html.erb | 31 ++++++++++ config/routes.rb | 2 +- public/javascripts/course.js | 21 +++++-- 5 files changed, 79 insertions(+), 42 deletions(-) create mode 100644 app/views/homework_common/next_step.html.erb diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 06bc1fd38..351feb979 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -1,6 +1,6 @@ class HomeworkCommonController < ApplicationController layout "base_courses" - before_filter :find_course, :only => [:index,:new,:create] + 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] before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment] @@ -15,6 +15,15 @@ class HomeworkCommonController < ApplicationController end def new + respond_to do |format| + format.html + end + end + + #新建作业下一步 + def next_step + @homework_type = params[:homework_common_type] + @homework = HomeworkCommon.new @homework.safe_attributes = params[:homework_common] @homework.late_penalty = 0 diff --git a/app/views/homework_common/new.html.erb b/app/views/homework_common/new.html.erb index 6a67c17d1..bace02de9 100644 --- a/app/views/homework_common/new.html.erb +++ b/app/views/homework_common/new.html.erb @@ -1,45 +1,29 @@ <%= javascript_include_tag "/assets/kindeditor/kindeditor" %> <%= error_messages_for 'homework_common' %> -

    <%= l(:label_course_homework_new)%>

    -

    请选择将要发布的作业类型 -

    - 人工评分的作业(支持匿名互评、灵活设置评分比例) -
    - 自动评测的编程作业(支持C++程序的自动评分) -
    - 下一步 + <%= form_for("new_homework_common",:url => next_step_homework_common_index_path) do |f|%> + +

    + 请选择将要发布的作业类型 +

    + + + 人工评分的作业(支持匿名互评、灵活设置评分比例) + +
    + + + 自动评测的编程作业(支持C++程序的自动评分) + +
    + + 下一步 + + <% end%>
    -
    - -
    -
    - <%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> - <%= hidden_field_tag "course",@course.id%> - <%= hidden_field_tag "homework_common_tyle","homework_detail_manual"%> - <%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> - 提交 - 上一步 - <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> - <% end%> -
    -
    -
    -
    -
    - <%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> - <%= hidden_field_tag "course",@course.id%> - <%= hidden_field_tag "homework_common_tyle","homework_detail_programing"%> - <%= render :partial => 'homework_common/homework_detail_programing_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> - 提交 - 上一步 - <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> - <% end%> -
    -
    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/app/views/homework_common/next_step.html.erb b/app/views/homework_common/next_step.html.erb new file mode 100644 index 000000000..148379f9e --- /dev/null +++ b/app/views/homework_common/next_step.html.erb @@ -0,0 +1,31 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> +<%= error_messages_for 'homework_common' %> +
    +

    + <%= l(:label_course_homework_new)%> +

    +
    +<% if @homework_type == "1"%> +
    + <%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> + <%= hidden_field_tag "course",@course.id%> + <%= hidden_field_tag "homework_common_tyle","homework_detail_manual"%> + <%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> + 提交 + <%= link_to "上一步", new_homework_common_path(:course => @course.id), :class => "orange_btn_homework fl"%> + <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> + <% end%> +
    +<% elsif @homework_type == "2"%> +
    + <%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> + <%= hidden_field_tag "course",@course.id%> + <%= hidden_field_tag "homework_common_tyle","homework_detail_programing"%> + <%= render :partial => 'homework_common/homework_detail_programing_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> + 提交 + <%= link_to "上一步", new_homework_common_path(:course => @course.id), :class => "orange_btn_homework fl"%> + <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> + <% end%> +
    +
    +<% end%> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index c92c732d2..dcdca73d4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -85,7 +85,7 @@ RedmineApp::Application.routes.draw do get 'alert_anonymous_comment' end collection do - + post 'next_step' end end diff --git a/public/javascripts/course.js b/public/javascripts/course.js index b493277fd..62769f2f5 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -396,15 +396,28 @@ function show_bid_dead_line(year,month,day,divname) } //新建作业,下一步按钮 -function select_homework_common_type() +function select_homework_common_type(url,course_id) { + var homework_common_type = ""; if($("#homework_detail_manual_radio").attr("checked") == "checked"){ - $("#homework_detail_manual").show(); + homework_common_type = "homework_detail_manual"; } else if($("#homework_detail_programing_radio").attr("checked") == "checked"){ - $("#homework_detail_programing").show(); + homework_common_type = "homework_detail_programing"; } - $("#hwork_new").hide(); + else{ + alert("未知错误,请联系管理员"); + return; + } + $.get( + url, + { + course: course_id, + homework_common_type: homework_common_type + }, + function (data) { + } + ); } //新建作业,上一步按钮 From dd8e8e38acdf202b6aa0e3b3b180626ba9670dd9 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 16 Jun 2015 14:46:18 +0800 Subject: [PATCH 06/55] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/course.js | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 62769f2f5..85f718d31 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -395,39 +395,6 @@ function show_bid_dead_line(year,month,day,divname) + "

    作品提交还剩:

    "); } -//新建作业,下一步按钮 -function select_homework_common_type(url,course_id) -{ - var homework_common_type = ""; - if($("#homework_detail_manual_radio").attr("checked") == "checked"){ - homework_common_type = "homework_detail_manual"; - } - else if($("#homework_detail_programing_radio").attr("checked") == "checked"){ - homework_common_type = "homework_detail_programing"; - } - else{ - alert("未知错误,请联系管理员"); - return; - } - $.get( - url, - { - course: course_id, - homework_common_type: homework_common_type - }, - function (data) { - } - ); -} - -//新建作业,上一步按钮 -function return_homework_common_type() -{ - $("#homework_detail_manual").hide(); - $("#homework_detail_programing").hide(); - $("#hwork_new").show(); -} - //验证新建作业的名字 function regex_homework_name() { From ab88156d2f09ddfef1e00a833cdbde40e4a844ea Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 16 Jun 2015 17:55:07 +0800 Subject: [PATCH 07/55] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E9=83=A8=E5=88=86=E5=80=BC=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0=E3=80=81=E5=88=A0=E9=99=A4=E7=BC=96?= =?UTF-8?q?=E7=A8=8B=E4=BD=9C=E4=B8=9A=E6=B5=8B=E8=AF=95=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=20=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 58 +++++++++++++------ .../_homework_detail_programing_form.html.erb | 49 ++++++++-------- app/views/homework_common/new.html.erb | 2 - app/views/homework_common/next_step.html.erb | 3 +- public/javascripts/course.js | 20 +++++++ public/stylesheets/courses.css | 18 ++---- public/stylesheets/public.css | 1 + 7 files changed, 93 insertions(+), 58 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 351feb979..d4a5cab24 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -30,14 +30,22 @@ class HomeworkCommonController < ApplicationController @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') @homework.publish_time = Time.now.strftime('%Y-%m-%d') - #匿评作业相关属性 - @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 + 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 @@ -58,15 +66,31 @@ class HomeworkCommonController < ApplicationController homework.save_attachments(params[:attachments]) render_attachment_warning_if_needed(homework) - #匿评作业相关属性 - 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 = params[:evaluation_start] - homework_detail_manual.evaluation_end = params[:evaluation_end] - homework_detail_manual.evaluation_num = params[:evaluation_num] - homework_detail_manual.absence_penalty = params[:absence_penalty] - homework.homework_detail_manual = homework_detail_manual + if homework.homework_type == 2 + homework_detail_programing = HomeworkDetailPrograming.new + homework_detail_programing.language = "C++" + homework_detail_programing.standard_code = params[:standard_code] + + if params[:input] && params[:output] + params[:input].each do |k,v| + if params[:output][k] + + end + end + end + + homework.homework_detail_programing = homework_detail_programing + 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 = params[:evaluation_start] + homework_detail_manual.evaluation_end = params[:evaluation_end] + homework_detail_manual.evaluation_num = params[:evaluation_num] + homework_detail_manual.absence_penalty = params[:absence_penalty] + homework.homework_detail_manual = homework_detail_manual + end if homework.save respond_to do |format| 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 12e6b7074..1a1804275 100644 --- a/app/views/homework_common/_homework_detail_programing_form.html.erb +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -1,6 +1,6 @@
    \ No newline at end of file diff --git a/app/views/homework_common/new.html.erb b/app/views/homework_common/new.html.erb index bace02de9..ece4af158 100644 --- a/app/views/homework_common/new.html.erb +++ b/app/views/homework_common/new.html.erb @@ -1,5 +1,3 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> -<%= error_messages_for 'homework_common' %>

    <%= l(:label_course_homework_new)%> diff --git a/app/views/homework_common/next_step.html.erb b/app/views/homework_common/next_step.html.erb index 148379f9e..75e9f4c0a 100644 --- a/app/views/homework_common/next_step.html.erb +++ b/app/views/homework_common/next_step.html.erb @@ -9,7 +9,6 @@
    <%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> <%= hidden_field_tag "course",@course.id%> - <%= hidden_field_tag "homework_common_tyle","homework_detail_manual"%> <%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> 提交 <%= link_to "上一步", new_homework_common_path(:course => @course.id), :class => "orange_btn_homework fl"%> @@ -20,7 +19,7 @@
    <%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> <%= hidden_field_tag "course",@course.id%> - <%= hidden_field_tag "homework_common_tyle","homework_detail_programing"%> + <%= hidden_field_tag "homework_common[homework_type]","2"%> <%= render :partial => 'homework_common/homework_detail_programing_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> 提交 <%= link_to "上一步", new_homework_common_path(:course => @course.id), :class => "orange_btn_homework fl"%> diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 85f718d31..0b3d78fc4 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -415,6 +415,7 @@ function regex_homework_name() //验证匿评数量 function regex_evaluation_num() { + if($("#evaluation_num").length == 0){ return true;} var evaluation_num = $.trim($("#evaluation_num").val()); var regex = /^\d+$/; if(evaluation_num=="") @@ -502,6 +503,25 @@ function submit_homework(id) } } +//增加测试结果 +function add_programing_test(obj) { + var now = new Date().getTime(); + obj.after("
  • " + + "
  • " + + "
  • " + + "" + + "测试
  • "); +} +//删除测试结果 +function remove_programing_test(obj) { + if(obj.siblings("div").length == 0){ + alert("至少需要一组测试"); + } + else{ + obj.remove(); + } +} + function show_window (id1,id2,top,left) { $('#'+ id1).css('top',top); $('#'+ id1).css('left',left); diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 769136f2d..3835559fa 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -551,19 +551,7 @@ a.wzan_visited{background:url(../images/new_project/public_icon.png) 0px -503px a.files_tag_icon{ background:#e2f3f9; color:#54aeca; border:1px solid #bbe2ef; padding:1px 10px; float:left; margin-right:10px;margin-bottom:10px; } a.files_tag_select{ background:#64bdd9; color:#fff; border:1px solid #64bdd9; padding:1px 10px; float:left; margin-right:10px;margin-bottom:10px;} -/* 20150423作业评分*/ -.ml14{ margin-left:14px;} -.w548{ width:552px;} -.w547{ width:544px;} -.w196{ width:182px;} -.w459{ width:459px;} -.hwork_new_set{border:1px dashed #CCC; background:#f5f5f5; text-align:center; padding:10px 0; margin-bottom:10px;} -.hwork_new_grey{background:#dbdbdb; width:610px; padding:10px 20px; margin:0 auto; text-align:left; margin-bottom:5px;} -.hwork_new_left{ width:220px; float:left; } -.hwork_new_right{ width:350px; float:left; margin-left:40px;} -.w305{ width:305px;} -.icon_add{ background:url(images/icons.png) 0px -310px no-repeat; width:16px; height:27px; display:block;float:left; margin-right:5px;} -a:hover.icon_add{background:url(images/icons.png) -20px -310px no-repeat;} + /* 20150505讨论区*/ .w664{ width:664px;} @@ -599,10 +587,12 @@ a:hover.Reply_pic{border:1px solid #64bdd9;} /*.talk_new{ border-bottom:1px dashed #d9d9d9; padding-bottom:10px;}*/ #about_newtalk{ display:none;} +/* 20150423作业评分*/ .ml14{ margin-left:14px;} .w548{ width:552px;} .w547{ width:544px;} .w196{ width:196px;} +.w186{ width:186px;} .w459{ width:459px;} .hwork_new_set{border:1px dashed #CCC; background:#f5f5f5; text-align:center; padding:10px 0; margin-bottom:10px;} .hwork_new_grey{background:#dbdbdb; width:610px; padding:10px 20px; margin:0 auto; text-align:left; margin-bottom:5px;} @@ -611,6 +601,8 @@ a:hover.Reply_pic{border:1px solid #64bdd9;} .w305{ width:305px;} .icon_add{background:url(images/icons.png) 0px -310px no-repeat; width:16px; height:27px; display:block;float:left; margin-right:5px;} a:hover.icon_add{background:url(images/icons.png) -20px -310px no-repeat;} +.icon_remove{background:url(images/icons.png) 0px -338px no-repeat; width:16px; height:27px; display:block;float:left;} +a:hover.icon_remove{background:url(images/icons.png) -20px -338px no-repeat;} /* 20150506上传头像*/ .uppicBox{ width:265px; height:265px; background:#f2f2f5; float:left; color:#666; text-align:center;} diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 5b00dbd57..62f169126 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -77,6 +77,7 @@ h4{ font-size:14px; color:#3b3b3b;} .mr50{margin-right: 50px;} .mr55{margin-right: 55px;} .mr70{margin-right: 70px;} +.mt1{margin-top: 1px;} .mt3{ margin-top:3px;} .mt5{ margin-top:5px;} .mt8{ margin-top:8px;} From 24970ce580a9f7de35d16a760bb10b118f11ac56 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 17 Jun 2015 09:58:01 +0800 Subject: [PATCH 08/55] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E7=BC=96=E7=A8=8B?= =?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 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index d4a5cab24..bfac1432f 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -73,8 +73,11 @@ class HomeworkCommonController < ApplicationController if params[:input] && params[:output] params[:input].each do |k,v| - if params[:output][k] - + if params[:output].include? k + homework_test = HomeworkTest.new + homework_test.input = v + homework_test.output = params[:output][k] + homework.homework_tests << homework_test end end end From 02d7215f6f51d9cd73977193afed1183a3cd65d0 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 17 Jun 2015 10:03:00 +0800 Subject: [PATCH 09/55] =?UTF-8?q?=E7=BC=96=E8=BE=91=E7=BC=96=E7=A8=8B?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_homework_detail_programing_form.html.erb | 19 ++++++++++++++++++- app/views/homework_common/edit.html.erb | 16 ++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) 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 1a1804275..7b732d7c3 100644 --- a/app/views/homework_common/_homework_detail_programing_form.html.erb +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -67,7 +67,24 @@ <% if edit_mode %> - + <% homework.homework_tests.each_with_index do |homework_test,i|%> +
    +
  • + + +
  • +
  • + + +
  • +
  • + + + 测试 +
  • +
    +
    + <% end%> <% else %>
  • diff --git a/app/views/homework_common/edit.html.erb b/app/views/homework_common/edit.html.erb index 87977c6a9..fc5596437 100644 --- a/app/views/homework_common/edit.html.erb +++ b/app/views/homework_common/edit.html.erb @@ -7,10 +7,18 @@
  • - <%= form_for @homework do |f| %> - <%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %> - 提交 - <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> + <%if @homework.homework_type == 2%> + <%= form_for @homework do |f| %> + <%= render :partial => 'homework_common/homework_detail_programing_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %> + 提交 + <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> + <% end%> + <% else %> + <%= form_for @homework do |f| %> + <%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %> + 提交 + <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> + <% end%> <% end%>
    \ No newline at end of file From d23189b93374baa453b7586ef0125c0ea0f41d23 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 17 Jun 2015 10:05:10 +0800 Subject: [PATCH 10/55] =?UTF-8?q?=E5=B7=B2=E5=AD=98=E5=9C=A8=E7=9A=84?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E8=BE=93=E5=87=BA=E6=B5=8B=E8=AF=95=E7=9A=84?= =?UTF-8?q?name=E6=94=B9=E4=B8=BA=E6=B5=8B=E8=AF=95=E7=9A=84id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_homework_detail_programing_form.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 7b732d7c3..6808f8cfe 100644 --- a/app/views/homework_common/_homework_detail_programing_form.html.erb +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -67,15 +67,15 @@ <% if edit_mode %> - <% homework.homework_tests.each_with_index do |homework_test,i|%> + <% homework.homework_tests.each do |homework_test|%>
  • - +
  • - +
  • From b95259566019f548e724602d8b65d584db6a24c0 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 17 Jun 2015 10:29:41 +0800 Subject: [PATCH 11/55] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 48 +++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index bfac1432f..dad01c79f 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -125,22 +125,54 @@ class HomeworkCommonController < ApplicationController @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] @homework.late_penalty = params[:late_penalty] @homework.user_id = User.current.id @homework.course_id = @course.id - #匿评作业相关属性 - @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] - @homework_detail_manual.absence_penalty = params[:absence_penalty] + @homework_detail_programing = @homework.homework_detail_programing + if @homework.homework_type == 2 #编程作业 + @homework_detail_programing.language = "C++" + @homework_detail_programing.standard_code = params[:standard_code] + 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[: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] + else #不存在的测试,增加 + homework_test = HomeworkTest.new + homework_test.input = v + homework_test.output = params[:output][k] + homework_test.homework_common = @homework + end + homework_test.save + end + end + end + else + #匿评作业相关属性 + @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] + @homework_detail_manual.absence_penalty = params[:absence_penalty] + end @homework.save_attachments(params[:attachments]) render_attachment_warning_if_needed(@homework) - if @homework.save && @homework_detail_manual.save + 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) From 71ab5ed74f0c1a304285608c785650f30fac2e1c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 19 Jun 2015 15:08:00 +0800 Subject: [PATCH 12/55] 111 --- app/views/bids/new_contest.html.erb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/bids/new_contest.html.erb b/app/views/bids/new_contest.html.erb index 216816bd1..899aea1e7 100644 --- a/app/views/bids/new_contest.html.erb +++ b/app/views/bids/new_contest.html.erb @@ -1,10 +1,10 @@ - -

    <%=l(:label_newtype_contest)%>

    + + -<%= labelled_form_for @bid, :url => {:controller => 'bids', :action => 'create_contest'} do |f| %> -
    - <%= render :partial => 'form_contest', :locals => { :f => f } %> - <%= submit_tag l(:button_create) %> - <%= javascript_tag "$('#bid_name').focus();" %> - <% end %> -
    \ No newline at end of file + + + + + + + \ No newline at end of file From e734abe613c2962d453566ccefce1b94756835d3 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 6 Jul 2015 10:44:27 +0800 Subject: [PATCH 13/55] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E6=A2=B3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 6b92e8198..3c3a42b69 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -133,19 +133,8 @@ class HomeworkCommonController < ApplicationController end @homework.late_penalty = params[:late_penalty] end - @homework.course_id = @course.id + # @homework.course_id = @course.id - @homework_detail_programing = @homework.homework_detail_programing - if @homework.homework_type == 2 #编程作业 - @homework_detail_programing.language = "C++" - @homework_detail_programing.standard_code = params[:standard_code] - 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 @homework.homework_type == 1 @homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 @@ -171,6 +160,16 @@ class HomeworkCommonController < ApplicationController @homework_detail_manual.absence_penalty = 0 end + if @homework.homework_type == 2 #编程作业 + @homework_detail_programing.language = "C++" + @homework_detail_programing.standard_code = params[:standard_code] + 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[:input].each do |k,v| if params[:output].include? k @@ -188,13 +187,6 @@ class HomeworkCommonController < ApplicationController end end end - else - #匿评作业相关属性 - @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] - @homework_detail_manual.absence_penalty = params[:absence_penalty] end @homework.save_attachments(params[:attachments]) From 23f6941001a6a2f1b9839a312d777d0571d8dcb1 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 6 Jul 2015 16:28:33 +0800 Subject: [PATCH 14/55] =?UTF-8?q?1=E3=80=81=E7=BC=96=E7=A8=8B=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E8=BF=9F=E4=BA=A4=E6=89=A3=E5=88=86=E7=9A=84=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=202=E3=80=81=E4=BF=AE=E6=94=B9=E7=BC=96=E7=A8=8B?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=97=B6=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 9 +++++---- .../_homework_detail_programing_form.html.erb | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 3c3a42b69..7a3b2b6c2 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -136,7 +136,7 @@ class HomeworkCommonController < ApplicationController # @homework.course_id = @course.id #匿评作业相关属性 - if @homework.homework_type == 1 + 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] @@ -152,15 +152,15 @@ class HomeworkCommonController < ApplicationController end @homework_detail_manual.absence_penalty = params[:absence_penalty] end - else #不是匿评作业,缺评扣分为0分,每个作品的缺评扣分改为0分,防止某些作业在结束匿评之后改为普通作业 + 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 + @homework_detail_manual.absence_penalty = 0 if @homework_detail_manual end - if @homework.homework_type == 2 #编程作业 + if @homework.homework_type == 2 && @homework_detail_programing #编程作业 @homework_detail_programing.language = "C++" @homework_detail_programing.standard_code = params[:standard_code] homework_tests = @homework.homework_tests @@ -293,6 +293,7 @@ class HomeworkCommonController < ApplicationController def find_homework @homework = HomeworkCommon.find params[:id] @homework_detail_manual = @homework.homework_detail_manual + @homework_detail_programing = @homework.homework_detail_programing @course = @homework.course rescue render_404 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 6808f8cfe..399e8355e 100644 --- a/app/views/homework_common/_homework_detail_programing_form.html.erb +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -40,15 +40,16 @@ <%= calendar_for('homework_publish_time')%>
  • -
    -
  • +
  • <%= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %>  分
  • + +

    编程评测设置

    From ec051ef929f16e694b13ffbce7e8c2057e7fee44 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 7 Jul 2015 15:47:48 +0800 Subject: [PATCH 15/55] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E8=80=81=E5=B8=88=E3=80=81=E5=AD=A6=E7=94=9F=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=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 | 4 +++- app/views/homework_common/index.html.erb | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a31bd6189..c4762e8cc 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2292,6 +2292,8 @@ module ApplicationHelper else link = "启动匿评".html_safe end + elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业作业 + link = "编程作业".html_safe else link = "启动匿评".html_safe end @@ -2324,7 +2326,7 @@ module ApplicationHelper elsif homework.homework_type == 0 "未启用匿评".html_safe elsif homework.homework_type == 2 - "编程作业".html_safe + " 编程作业  ".html_safe end end diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index 870edbfe4..d9a93fe8f 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -68,8 +68,6 @@ ,缺评一个作品扣 <%= homework.homework_detail_manual.absence_penalty%> 分 - <% else%> - 。 <% end%>
    From 515c854f0f702df2e8afc455bc65c459b3e9a499 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 8 Jul 2015 09:49:24 +0800 Subject: [PATCH 16/55] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BD=9C=E5=93=81=E6=97=B6=E4=B8=8D=E7=8E=B0?= =?UTF-8?q?=E5=AE=9E=E5=85=B3=E8=81=94=E9=A1=B9=E7=9B=AE=E3=80=81=E9=99=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/new.html.erb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index b4162c4da..500a0ccd3 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -33,9 +33,12 @@

    <%= f.text_field "name", :required => true, :size => 60, :class => "bo fl", :maxlength => 200, :placeholder => "作品名称", :onkeyup => "regexStudentWorkName();" %> - 项目信息 - - + <% if @homework.homework_type != 2%> + + 项目信息 + + + <% end%>

    @@ -52,11 +55,13 @@

    -

    - - <%= render :partial => 'attachments/new_form' %> -

    -
    + <% if @homework.homework_type != 2%> +

    + + <%= render :partial => 'attachments/new_form' %> +

    +
    + <% end%>

    提交作品 <%= link_to "返  回".html_safe, student_work_index_path(:homework => @homework), :class => "blue_btn grey_btn fl c_white"%> From 17a9a1023a9a239ac489a325bf6fa2efb393649b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 8 Jul 2015 10:58:03 +0800 Subject: [PATCH 17/55] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BC=96=E7=A8=8B?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E4=B8=AD=E6=95=99=E8=BE=85=E6=AF=94=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20150708025533_add_proportion_to_programing.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 db/migrate/20150708025533_add_proportion_to_programing.rb diff --git a/db/migrate/20150708025533_add_proportion_to_programing.rb b/db/migrate/20150708025533_add_proportion_to_programing.rb new file mode 100644 index 000000000..b3da59c25 --- /dev/null +++ b/db/migrate/20150708025533_add_proportion_to_programing.rb @@ -0,0 +1,9 @@ +class AddProportionToPrograming < ActiveRecord::Migration + def up + add_column :homework_detail_programings, :ta_proportion, :float, :default => 0.1 + end + + def down + remove_column :homework_detail_programings, :ta_proportion + end +end From 9a2cb324ab6dc9a909b57cd34dd64527d8de4c21 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 8 Jul 2015 11:17:36 +0800 Subject: [PATCH 18/55] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E7=94=B1=E5=8C=BF=E8=AF=84=E4=BD=9C=E4=B8=9A=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E6=99=AE=E9=80=9A=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 | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 7a3b2b6c2..4ea590d54 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -126,6 +126,7 @@ class HomeworkCommonController < ApplicationController @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] 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] From 6af6fdd5a396f76cdd1e4b3c890c444b4bb0620d Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 8 Jul 2015 11:17:59 +0800 Subject: [PATCH 19/55] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=88=86=E9=85=8D=E6=AF=94=E4=BE=8B=E6=B7=BB=E5=8A=A0=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E7=95=8C=E9=9D=A2=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_homework_detail_programing_form.html.erb | 17 +++++++++++++++++ db/schema.rb | 7 ++++--- public/javascripts/course.js | 19 +++++++++++-------- 3 files changed, 32 insertions(+), 11 deletions(-) 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 399e8355e..008f88138 100644 --- a/app/views/homework_common/_homework_detail_programing_form.html.erb +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -61,6 +61,23 @@

    + +
  • + + <%= select_tag :ta_proportion,options_for_select(ta_proportion_option,homework.homework_detail_programing.ta_proportion), {:class => "fl mb10 h26 w70"} %> + × 教辅评分 +   +   + + × 系统评分 + = 学生得分 +
    +
  • +
  • + + 如果教师对学生作品进行了评分,则教师评分为学生最终得分。 +
    +
  • +
  • diff --git a/db/schema.rb b/db/schema.rb index 988d5649a..4016cd6a9 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 => 20150702073308) do +ActiveRecord::Schema.define(:version => 20150708025533) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -586,8 +586,9 @@ ActiveRecord::Schema.define(:version => 20150702073308) do t.string "language" t.text "standard_code", :limit => 2147483647 t.integer "homework_common_id" - 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.float "ta_proportion", :default => 0.1 end create_table "homework_evaluations", :force => true do |t| diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 3dc30404d..8db456cbf 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -473,15 +473,18 @@ $(function(){ }); //第一次加载时,如果未开启匿评作业,隐藏显示匿评配置信息 $(function(){ - if($("#homework_common_homework_type").attr("checked") == "checked") + if($("#homework_common_homework_type").attr("id") != null && $("#homework_common_homework_type").val() != 2) { - $("#evaluation_setting").show(); - $("#ta_proportion").removeAttr("disabled"); - } - else - { - $("#evaluation_setting").hide(); - $("#ta_proportion").attr("disabled","disabled"); + if($("#homework_common_homework_type").attr("checked") == "checked") + { + $("#evaluation_setting").show(); + $("#ta_proportion").removeAttr("disabled"); + } + else + { + $("#evaluation_setting").hide(); + $("#ta_proportion").attr("disabled","disabled"); + } } }); From 7ada5db28e38a85b578f95ec27bfb955546d5335 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 8 Jul 2015 16:14:54 +0800 Subject: [PATCH 20/55] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E6=97=B6=EF=BC=8C=E7=BC=96=E7=A8=8B=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=EF=BC=8C=E7=B3=BB=E7=BB=9F=E8=AF=84=E5=88=86=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E9=A2=84=E7=95=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index cc858cc19..429f787e5 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -42,7 +42,6 @@ class StudentWorkController < ApplicationController end end @homework_commons = @course.homework_commons.order("created_at desc") - @homework_commons = @course.homework_commons.order("created_at desc") @score = @b_sort == "desc" ? "asc" : "desc" respond_to do |format| format.html @@ -80,6 +79,11 @@ class StudentWorkController < ApplicationController stundet_work.late_penalty = 0 end render_attachment_warning_if_needed(stundet_work) + + if @homework.homework_type == 2 #编程作业,学生提交作品后计算系统得分 + + end + if stundet_work.save respond_to do |format| format.html { From dc01b90dbdcdc1003b3b7be20a6ddf2797cd1ea8 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 8 Jul 2015 16:24:47 +0800 Subject: [PATCH 21/55] =?UTF-8?q?=E5=8C=BF=E8=AF=84=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../student_work/_evaluation_student_work_title.html.erb | 8 ++++++-- app/views/student_work/index.html.erb | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/views/student_work/_evaluation_student_work_title.html.erb b/app/views/student_work/_evaluation_student_work_title.html.erb index 0e4151065..a95106a48 100644 --- a/app/views/student_work/_evaluation_student_work_title.html.erb +++ b/app/views/student_work/_evaluation_student_work_title.html.erb @@ -29,8 +29,12 @@ <% end%>
  • -
  • - <%= link_to "匿评",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> +
  • + <% if @homework.homework_type == 1%> + <%= link_to "匿评",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <% elsif @homework.homework_type == 2%> + <%= link_to "系统",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <% end %> <% if @show_all && @order == "student_score"%> <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%> diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index 76ae71459..70f7c08f4 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -89,7 +89,7 @@
    <% end%> <% else %> - <% if @homework.homework_type == 1%> + <% if @homework.homework_type == 1 || @homework.homework_type == 2%> From 2fb76458b6016e1effb16b3fd928489cac945fa2 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 8 Jul 2015 16:33:18 +0800 Subject: [PATCH 22/55] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=9D=99=E6=80=81=E9=A1=B5=E9=9D=A2=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_programing_work_show.html.erb | 72 +++++++++++++++++++ app/views/student_work/show.js.erb | 6 +- 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 app/views/student_work/_programing_work_show.html.erb diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb new file mode 100644 index 000000000..c231ab94b --- /dev/null +++ b/app/views/student_work/_programing_work_show.html.erb @@ -0,0 +1,72 @@ +
    +
    +
      +
    • 上交时间:2015-05-07
    • +
    • 赞(10)
    • +
      +
    • 参与人员:程梦雯  王强
    • +
    • 关联项目:Trustie Forge
    • +
    • 编程代码:

      编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码

    • +
    • 测试结果: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      测试结果一错误0
      测试结果二正确20
      测试结果三正确20
      测试结果四正确20
      测试结果五正确20
      最后得分 80
      +
      +
    • +
    • 评价:
    • + +
    • 评分:
    • +
    • 批阅结果:    -文件不超过200MB提交
    • +
    +
    + + + +
    + 收起 +
    +
    \ No newline at end of file diff --git a/app/views/student_work/show.js.erb b/app/views/student_work/show.js.erb index fa12e097d..1c8874c2f 100644 --- a/app/views/student_work/show.js.erb +++ b/app/views/student_work/show.js.erb @@ -2,6 +2,10 @@ if($("#about_hwork_<%= @work.id%>").children().length > 0) {$("#about_hwork_<%= @work.id%>").html("");} else { - $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'show') %>"); + <% if @homework.homework_type == 2%> + $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show') %>"); + <% else%> + $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'show') %>"); + <% end%> $('#score_<%= @work.id%>').peSlider({range: 'min'}); } \ No newline at end of file From 2eff8cce6a9fe43ec8dfc3750edd55c5c9a05fe3 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 8 Jul 2015 16:38:34 +0800 Subject: [PATCH 23/55] =?UTF-8?q?=E6=9B=B4=E6=96=B0css=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/courses.css | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 5f7e7eebd..a6d8ff0a2 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -30,6 +30,10 @@ a:hover.news_foot{ color:#787b7e; border:1px solid #d4d4d4;} .box_h3{ color:#15bccf; text-align:center; font-size:16px;} .box_p{ color:#404040; margin-bottom:5px;} .fb_item{ color:#919191; border:1px solid #919191; height:28px; margin-bottom:10px; padding-left:5px; width:290px;} +a.icon_addm{ background:url(../images/img_floatbox.png) 0 -33px no-repeat; width:16px; height:16px; display:block; margin:5px 0 0 5px;} +a:hover.icon_addm{background:url(../images/img_floatbox.png) 0 -61px no-repeat; } +a.icon_removem{ background:url(../images/img_floatbox.png) -22px -33px no-repeat;width:16px; height:16px; display:block; margin:5px 0 0 5px} +a:hover.icon_removem{background:url(../images/img_floatbox.png) -22px -61px no-repeat;} a.btn_free{ background:#ff5722; display:block; width:80px; text-align:center; color:#fff; height:26px; padding-top:3px; margin-bottom:10px;} a:hover.btn_free{ background:#d63502;} /*成员邀请*/ @@ -338,7 +342,6 @@ a:hover.st_add{ color:#ff8e15;} .upbtn{ margin:40px 0 0 15px; display:block; padding:2px 5px; border:1px solid #eaeaea;} .upbtn:hover{border:1px solid #64bdd9; color:#64bdd9;cursor: pointer;} .upload_file{margin-left: -60px;margin-top: 40px;width: 50px;position: absolute;height: 24px;opacity: 0;cursor: pointer} - /* 功能倒计时*/ .w_img{ float:left; margin:10px 10px 15px 0px;} .w_p{ float:left; color:#15bccf; font-size:16px; font-weight:bold; margin-top:70px; } @@ -349,7 +352,9 @@ a:hover.st_add{ color:#ff8e15;} .upload_con h2{ display:block; background:#eaeaea; font-size:14px; color:#343333; height:31px; width: auto; margin-top:25px; padding-left:20px; padding-top:5px;} .upload_box{ width:430px; margin:15px auto;} +a.link_file{ background:url(../images/pic_file.png) 0 2px no-repeat; padding-left:20px; } a:hover.link_file{ background:url(../images/pic_file.png) 0 -25px no-repeat; color:#3ca5c6;} +.r_txt_tit{width:510px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;color:#15bccf; float:left; color:#09658c; font-size:14px;} blockquote {background: #eeeeee;padding: 10px;margin-bottom: 10px;word-break: break-all;word-wrap: break-word;} .respond-form{display: none;margin: auto;clear: both;} @@ -550,7 +555,19 @@ a.wzan_visited{background:url(../images/new_project/public_icon.png) 0px -503px a.files_tag_icon{ background:#e2f3f9; color:#54aeca; border:1px solid #bbe2ef; padding:1px 10px; float:left; margin-right:10px;margin-bottom:10px; } a.files_tag_select{ background:#64bdd9; color:#fff; border:1px solid #64bdd9; padding:1px 10px; float:left; margin-right:10px;margin-bottom:10px;} - +/* 20150423作业评分*/ +.ml14{ margin-left:14px;} +.w548{ width:552px;} +.w547{ width:544px;} +.w196{ width:182px;} +.w459{ width:459px;} +.hwork_new_set{border:1px dashed #CCC; background:#f5f5f5; text-align:center; padding:10px 0; margin-bottom:10px;} +.hwork_new_grey{background:#dbdbdb; width:610px; padding:10px 20px; margin:0 auto; text-align:left; margin-bottom:5px;} +.hwork_new_left{ width:220px; float:left; } +.hwork_new_right{ width:350px; float:left; margin-left:40px;} +.w305{ width:305px;} +.icon_add{ background:url(../stylesheets/images/icons.png) 0px -310px no-repeat; width:16px; height:27px; display:block;float:left; margin-right:5px;} +a:hover.icon_add{background:url(../stylesheets/images/icons.png) -20px -310px no-repeat;} /* 20150505讨论区*/ .w664{ width:664px;} @@ -648,6 +665,7 @@ a:hover.ping_pic{border:1px solid #64bdd9;} a.down_btn{ border:1px solid #CCC; color:#999; padding:0px 5px; font-size:12px; text-align:center; display:block;} a:hover.down_btn{ background:#14ad5a; color:#fff; border:1px solid #14ad5a;} .fr{ float:right;} +.min_search{ width:200px; height:20px; border:1px solid #d0d0d0; color:#666; background:url(../images/public_icon.png) 185px -193px no-repeat; cursor:pointer;} .li_min_search{ float:right; margin-right:-10px;} .info_ni_download{ width:100px; padding:5px;position: absolute;display:none;-moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; box-shadow:0px 0px 5px #194a81; color:#666; background:#fff; text-align:left;margin-left: 200px;margin-top: 10px;} .info_ni{ width:100px; padding:5px;position: absolute;display:none;-moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; box-shadow:0px 0px 5px #194a81; color:#666; background:#fff; text-align:left;margin-left: 50px;margin-top: -5px;} @@ -666,6 +684,12 @@ input#score{ width:40px;} .ui-slider .ui-slider-handle:hover,.ui-slider .ui-slider-handle:focus{background:#64bdd9;} .ui-slider .ui-slider-handle:active{background-image:none;} .ui-slider .ui-slider-range{position:absolute;z-index:1;font-size:.7em;display:block;border:0;top:0;height:100%;background:#64bdd9;left:0;} +/* 编程作品 */ +.border_ce{ border:1px solid #e4e4e4; } +.border_ce tr td{ height:26px; } +.td_tit{width:155px; text-align:center;} +.td_50{width:50px; text-align:center;} +a.work_list_tit{width:610px; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} .filename { background: url(../images/pic_file.png) 0 -25px no-repeat;color: #3ca5c6;max-width: 150px;border: none; padding-left: 20px;margin-right: 10px;margin-bottom: 5px; white-space: nowrap; text-overflow:ellipsis;} .evaluation{position: relative;} From 2ed2ba97fa48633bfd2f61aa4104749ed20d420d Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 8 Jul 2015 16:54:27 +0800 Subject: [PATCH 24/55] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E5=93=81show?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_programing_work_show.html.erb | 103 ++++++++---------- 1 file changed, 46 insertions(+), 57 deletions(-) diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb index c231ab94b..80284dac0 100644 --- a/app/views/student_work/_programing_work_show.html.erb +++ b/app/views/student_work/_programing_work_show.html.erb @@ -1,72 +1,61 @@
      -
    • 上交时间:2015-05-07
    • -
    • 赞(10)
    • +
    • + + 上交时间: + + <%=format_time @work.created_at %> +
    • + <% if @work.user != User.current%> + +
    • + <%= render :partial => 'student_work_praise' %> +
    • + <% end%>
      -
    • 参与人员:程梦雯  王强
    • -
    • 关联项目:Trustie Forge
    • -
    • 编程代码:

      编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码编程作品代码

    • +
    • + + 编程代码: + +
      + <%= textilizable @work.description%> +
      +
      +
    • 测试结果: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + <%@homework.homework_tests.each do |test|%> + "> + + + + + + <% end%>
      测试结果一错误0
      测试结果二正确20
      测试结果三正确20
      测试结果四正确20
      测试结果五正确20
      最后得分 80
      + <%= test.input%> + + <%= test.output%> + 错误0
    • -
    • 评价:
    • - -
    • 评分:
    • -
    • 批阅结果:    -文件不超过200MB提交
    • + <% if @is_teacher%> + +
      + <%= render :partial => 'add_score',:locals => {:work => @work,:score => @score}%> +
      + <% end%>
    -
    - - +
    + <%@work.student_works_scores.order("updated_at desc").each do |score|%> +
    + <%= render :partial => 'student_work_score',:locals => {:score => score}%> +
    + <% end%>
    - 收起 -
    + 收起
    \ No newline at end of file From 8f3ac85fec83888be61bd797919b2540fddb87f9 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 8 Jul 2015 17:19:11 +0800 Subject: [PATCH 25/55] =?UTF-8?q?1=E3=80=81=E4=BD=9C=E4=B8=9A=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0=E3=80=81=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=AD=97=E6=AE=B5=E6=94=B9=E4=B8=BAlongtext=202?= =?UTF-8?q?=E3=80=81=E6=8F=90=E4=BA=A4=E4=BD=9C=E4=B8=9A=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=BF=AE=E6=94=B9=203=E3=80=81=E7=BC=96?= =?UTF-8?q?=E7=A8=8B=E4=BD=9C=E4=B8=9A=E4=B8=8D=E5=8F=AF=E4=BB=A5=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=92=8C=E5=88=A0=E9=99=A4control=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 12 +++++++++--- app/views/student_work/edit.html.erb | 8 -------- app/views/student_work/new.html.erb | 8 ++++++-- .../20150708085629_change_studen_work_desc.rb | 9 +++++++++ db/schema.rb | 14 +++++++------- 5 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 db/migrate/20150708085629_change_studen_work_desc.rb diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 429f787e5..0efa0aa66 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -103,8 +103,12 @@ class StudentWorkController < ApplicationController end def edit - respond_to do |format| - format.html + if @homework.homework_type == 2 #编程作业不能修改作业 + render_403 + else + respond_to do |format| + format.html + end end end @@ -139,7 +143,9 @@ class StudentWorkController < ApplicationController end def destroy - if @work.destroy + if @homework.homework_type == 2 #编程作业,作品提交后不可以删除 + render_403 + elsif @work.destroy respond_to do |format| format.html { redirect_to student_work_index_url(:homework => @homework.id) diff --git a/app/views/student_work/edit.html.erb b/app/views/student_work/edit.html.erb index dfa995f47..6e36447d2 100644 --- a/app/views/student_work/edit.html.erb +++ b/app/views/student_work/edit.html.erb @@ -2,14 +2,6 @@

    编辑作品

    - - - - - - - -
    <%= labelled_form_for @work,:html => { :multipart => true } do |f|%> diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index 500a0ccd3..eda09114e 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -49,8 +49,12 @@

    - - <%= f.text_area "description", :class => "w620 hwork_txt ", :maxlength => 3000, :placeholder => "最多3000个汉字", :onkeyup => "regexStudentWorkDescription();"%> + + <%= f.text_area "description", :class => "w620 hwork_txt ", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();"%>

    diff --git a/db/migrate/20150708085629_change_studen_work_desc.rb b/db/migrate/20150708085629_change_studen_work_desc.rb new file mode 100644 index 000000000..af3c25671 --- /dev/null +++ b/db/migrate/20150708085629_change_studen_work_desc.rb @@ -0,0 +1,9 @@ +class ChangeStudenWorkDesc < ActiveRecord::Migration + def up + change_column :student_works,:description,:text,:limit => 4294967295 + end + + def down + change_column :student_works,:description,:text + end +end diff --git a/db/schema.rb b/db/schema.rb index 4016cd6a9..539dd95d3 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 => 20150708025533) do +ActiveRecord::Schema.define(:version => 20150708085629) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1222,18 +1222,18 @@ ActiveRecord::Schema.define(:version => 20150708025533) do create_table "student_works", :force => true do |t| t.string "name" - t.text "description" + t.text "description", :limit => 2147483647 t.integer "homework_common_id" t.integer "user_id" t.float "final_score" t.float "teacher_score" t.float "student_score" t.float "teaching_asistant_score" - t.integer "project_id", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "late_penalty", :default => 0 - t.integer "absence_penalty", :default => 0 + t.integer "project_id", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "late_penalty", :default => 0 + t.integer "absence_penalty", :default => 0 end create_table "student_works_evaluation_distributions", :force => true do |t| From eb1976efbbeb5adaafe9a6154ef32659ef86562a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 9 Jul 2015 10:38:44 +0800 Subject: [PATCH 26/55] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=EF=BC=8C=E6=9C=80=E7=BB=88=E8=AF=84=E5=88=86=E7=9A=84=E8=AE=A1?= =?UTF-8?q?=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 0efa0aa66..b6f69a4da 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -190,8 +190,10 @@ class StudentWorkController < ApplicationController if @work.student_score.nil? @work.final_score = @work.teaching_asistant_score else - final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}") - final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}")) + ta_proportion = @homework.homework_detail_manual.ta_proportion if @homework.homework_detail_manual + ta_proportion = @homework.homework_detail_programing.ta_proportion if @homework.homework_detail_programing + final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}") + final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) final_score = final_ta_score + final_s_score @work.final_score = format("%.2f",final_score.to_f) end From 24d6c8e17e83b80d552864490b4dc9527a009831 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 9 Jul 2015 15:20:59 +0800 Subject: [PATCH 27/55] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E8=A1=A8=E5=A2=9E=E5=8A=A0question=5Fid=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20150709071731_add_question_id_to_homework.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 db/migrate/20150709071731_add_question_id_to_homework.rb diff --git a/db/migrate/20150709071731_add_question_id_to_homework.rb b/db/migrate/20150709071731_add_question_id_to_homework.rb new file mode 100644 index 000000000..d1be59431 --- /dev/null +++ b/db/migrate/20150709071731_add_question_id_to_homework.rb @@ -0,0 +1,9 @@ +class AddQuestionIdToHomework < ActiveRecord::Migration + def up + add_column :homework_detail_programings, :question_id, :integer + end + + def down + remove_column :homework_detail_programings, :question_id + end +end From 11191f6743f958342d6888d3d1b3716459d6b90b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 9 Jul 2015 15:50:04 +0800 Subject: [PATCH 28/55] =?UTF-8?q?=E4=B8=8E=E7=BC=96=E7=A8=8B=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=9C=8D=E5=8A=A1=E5=99=A8=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 7 +++++++ app/controllers/student_work_controller.rb | 10 ++++++++-- db/schema.rb | 3 ++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 4ea590d54..8109a7e62 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -1,4 +1,5 @@ class HomeworkCommonController < ApplicationController + require 'net/http' layout "base_courses" 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] @@ -72,6 +73,8 @@ class HomeworkCommonController < ApplicationController homework_detail_programing.language = "C++" homework_detail_programing.standard_code = params[:standard_code] + question = {title:homework.name,content:homework.description} + uri = URI('http://fast.forge.trustie.net/api/questions.json') if params[:input] && params[:output] params[:input].each do |k,v| if params[:output].include? k @@ -79,6 +82,10 @@ class HomeworkCommonController < ApplicationController homework_test.input = v homework_test.output = params[:output][k] homework.homework_tests << homework_test + question[:input] = homework_test.input + question[:output] = homework_test.output + + res = Net::HTTP.post_form(uri, question) end end end diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index b6f69a4da..d6b79cece 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -80,8 +80,14 @@ class StudentWorkController < ApplicationController end render_attachment_warning_if_needed(stundet_work) - if @homework.homework_type == 2 #编程作业,学生提交作品后计算系统得分 - + if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分 + url = "http://fast.forge.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json" + uri = URI(url) + solutions = { + src:stundet_work.description, + language:1 + } + Net::HTTP.post_form(uri, solutions) end if stundet_work.save diff --git a/db/schema.rb b/db/schema.rb index 539dd95d3..fcb925c50 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 => 20150708085629) do +ActiveRecord::Schema.define(:version => 20150709071731) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -589,6 +589,7 @@ ActiveRecord::Schema.define(:version => 20150708085629) do t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.float "ta_proportion", :default => 0.1 + t.integer "question_id" end create_table "homework_evaluations", :force => true do |t| From 851b468e8d875c29e344e6e2ea9aeda955042fb8 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 10 Jul 2015 10:05:28 +0800 Subject: [PATCH 29/55] =?UTF-8?q?admin=E8=83=BD=E8=AE=BF=E9=97=AE=E9=97=AE?= =?UTF-8?q?=E5=8D=B7=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index d8a9d88c3..758747e02 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -23,7 +23,7 @@ class PollController < ApplicationController def show @poll = Poll.find params[:id] - if @poll.polls_status != 2 && !User.current.allowed_to?(:as_teacher,@course) + if @poll.polls_status != 2 && (!User.current.allowed_to?(:as_teacher,@course) || User.current.admin?) render_403 return end @@ -393,7 +393,7 @@ class PollController < ApplicationController end def is_member_of_course - render_403 unless(@course && User.current.member_of_course?(@course)) + render_403 unless(@course && (User.current.member_of_course?(@course) || User.current.admin?)) end def is_course_teacher From 4b275bcbdf11e4d1eb0795fafe25bb80b28e7ae8 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 10 Jul 2015 11:36:44 +0800 Subject: [PATCH 30/55] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=80=BC=EF=BC=8C=E4=BD=9C=E4=B8=9A=E8=8E=B7=E5=8F=96question?= =?UTF-8?q?=E7=9A=84id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 2 ++ config/routes.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 8109a7e62..017d22de0 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -86,6 +86,8 @@ class HomeworkCommonController < ApplicationController question[:output] = homework_test.output res = Net::HTTP.post_form(uri, question) + result = JSON.parse(res.body) + homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0 end end end diff --git a/config/routes.rb b/config/routes.rb index f31ec9859..de8a92b66 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -86,6 +86,7 @@ RedmineApp::Application.routes.draw do end collection do post 'next_step' + post 'set_program_score' end end From aa5255c430388f79b0bdcca019b2e9a0dbdf2513 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 10 Jul 2015 17:20:04 +0800 Subject: [PATCH 31/55] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=E5=86=8D=E8=B0=83=E7=94=A8=E7=BC=96=E7=A8=8B?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E4=BC=A0=E9=80=92=E5=A2=9E=E5=8A=A0=E4=BD=9C=E5=93=81=E7=9A=84?= =?UTF-8?q?ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 29 ++++++++++++++-------- config/routes.rb | 2 +- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index d6b79cece..fa14f5d42 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -80,17 +80,17 @@ class StudentWorkController < ApplicationController end render_attachment_warning_if_needed(stundet_work) - if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分 - url = "http://fast.forge.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json" - uri = URI(url) - solutions = { - src:stundet_work.description, - language:1 - } - Net::HTTP.post_form(uri, solutions) - end - if stundet_work.save + if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分 + url = "http://fast.forge.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json" + uri = URI(url) + solutions = { + id:stundet_work.id, + src:stundet_work.description, + language:1 + } + Net::HTTP.post_form(uri, solutions) + end respond_to do |format| format.html { flash[:notice] = l(:notice_successful_create) @@ -321,6 +321,15 @@ class StudentWorkController < ApplicationController end end + #设置编程作业得分 + def set_program_score + res = JSON.parse(response.body) + stundet_work = StudentWork.find_by_id res["id"] + if stundet_work + stundet_work.update_column("student_score",res["status"]) + end + end + private #获取作业 def find_homework diff --git a/config/routes.rb b/config/routes.rb index de8a92b66..0d47d2f57 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -86,7 +86,6 @@ RedmineApp::Application.routes.draw do end collection do post 'next_step' - post 'set_program_score' end end @@ -101,6 +100,7 @@ RedmineApp::Application.routes.draw do get 'student_work_absence_penalty' get 'absence_penalty_list' get 'evaluation_list' + post 'set_program_score' end end From 4ae773276285e79f087cbf29aef3aebcbeb9aec4 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 15 Jul 2015 14:44:58 +0800 Subject: [PATCH 32/55] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A=E4=BD=9C=E5=93=81=E6=97=B6?= =?UTF-8?q?=E3=80=81=E9=93=BE=E6=8E=A5=E7=BD=91=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 2 +- app/controllers/student_work_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 017d22de0..dce5bdf6c 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -74,7 +74,7 @@ class HomeworkCommonController < ApplicationController homework_detail_programing.standard_code = params[:standard_code] question = {title:homework.name,content:homework.description} - uri = URI('http://fast.forge.trustie.net/api/questions.json') + uri = URI('http://test.gitlab.trustie.net/api/questions.json') if params[:input] && params[:output] params[:input].each do |k,v| if params[:output].include? k diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index fa14f5d42..da4e01d8a 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -82,7 +82,7 @@ class StudentWorkController < ApplicationController if stundet_work.save if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分 - url = "http://fast.forge.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json" + url = "http://test.gitlab.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json" uri = URI(url) solutions = { id:stundet_work.id, From 4606cf7c28dc83628ec0bafa95c18348fe7ba79b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 15 Jul 2015 14:57:47 +0800 Subject: [PATCH 33/55] =?UTF-8?q?1=E3=80=81=E7=BC=96=E7=A8=8B=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=94=AF=E6=8C=81=E5=A4=9A=E4=B8=AA=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E8=BE=93=E5=87=BA=202=E3=80=81=E7=BC=96=E7=A8=8B=E4=BD=9C?= =?UTF-8?q?=E5=93=81=E5=9B=9E=E8=B0=83=E5=8F=82=E6=95=B0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=94=B9=E4=B8=BAparams=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 13 +++++++------ app/controllers/student_work_controller.rb | 5 ++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index dce5bdf6c..a8ccf2b9a 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -75,6 +75,8 @@ class HomeworkCommonController < ApplicationController question = {title:homework.name,content:homework.description} uri = URI('http://test.gitlab.trustie.net/api/questions.json') + question[:input] = [] + question[:output] = [] if params[:input] && params[:output] params[:input].each do |k,v| if params[:output].include? k @@ -82,15 +84,14 @@ class HomeworkCommonController < ApplicationController homework_test.input = v homework_test.output = params[:output][k] homework.homework_tests << homework_test - question[:input] = homework_test.input - question[:output] = homework_test.output - - res = Net::HTTP.post_form(uri, question) - result = JSON.parse(res.body) - homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0 + question[:input] << homework_test.input + question[:output] << homework_test.output end end end + res = Net::HTTP.post_form(uri, question) + result = JSON.parse(res.body) + homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0 homework.homework_detail_programing = homework_detail_programing else diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index da4e01d8a..cf712bfc9 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -323,10 +323,9 @@ class StudentWorkController < ApplicationController #设置编程作业得分 def set_program_score - res = JSON.parse(response.body) - stundet_work = StudentWork.find_by_id res["id"] + stundet_work = StudentWork.find_by_id params[:id] if stundet_work - stundet_work.update_column("student_score",res["status"]) + stundet_work.update_column("student_score",params[:status] == 0 ? 100 : 0) end end From 0b66097bfb7d8721efa7030b10e544c14e0e4981 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 15 Jul 2015 15:21:26 +0800 Subject: [PATCH 34/55] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=AF=8F=E4=BB=BD?= =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E5=93=81=E7=9A=84=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E7=9A=84=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/homework_test.rb | 1 + app/models/student_work.rb | 1 + app/models/student_work_test.rb | 6 ++++++ db/migrate/20150715070534_create_test_result.rb | 13 +++++++++++++ 4 files changed, 21 insertions(+) create mode 100644 app/models/student_work_test.rb create mode 100644 db/migrate/20150715070534_create_test_result.rb diff --git a/app/models/homework_test.rb b/app/models/homework_test.rb index f7d9b20bc..7c477bfaf 100644 --- a/app/models/homework_test.rb +++ b/app/models/homework_test.rb @@ -2,4 +2,5 @@ class HomeworkTest < ActiveRecord::Base attr_accessible :input, :output, :homework_common_id belongs_to :homework_common + has_one :student_work_test end diff --git a/app/models/student_work.rb b/app/models/student_work.rb index e2be18423..0db36b4ba 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -7,6 +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 acts_as_attachable end diff --git a/app/models/student_work_test.rb b/app/models/student_work_test.rb new file mode 100644 index 000000000..b9264191c --- /dev/null +++ b/app/models/student_work_test.rb @@ -0,0 +1,6 @@ +class StudentWorkTest < ActiveRecord::Base + attr_accessible :student_work_id, :homework_test_id + + belongs_to :homework_test + belongs_to :student_work +end diff --git a/db/migrate/20150715070534_create_test_result.rb b/db/migrate/20150715070534_create_test_result.rb new file mode 100644 index 000000000..f78953129 --- /dev/null +++ b/db/migrate/20150715070534_create_test_result.rb @@ -0,0 +1,13 @@ +class CreateTestResult < ActiveRecord::Migration + def up + create_table :student_work_test do |t| + t.integer :student_work_id + t.integer :homework_test_id + t.integer :result + t.timestamps + end + end + + def down + end +end From 536a9d7b6b65c1c0b90f3fa2e909cf26b0f814d4 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 15 Jul 2015 15:28:44 +0800 Subject: [PATCH 35/55] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A1=A8=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20150715070534_create_test_result.rb | 3 ++- db/schema.rb | 20 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/db/migrate/20150715070534_create_test_result.rb b/db/migrate/20150715070534_create_test_result.rb index f78953129..4816fbcb8 100644 --- a/db/migrate/20150715070534_create_test_result.rb +++ b/db/migrate/20150715070534_create_test_result.rb @@ -1,6 +1,6 @@ class CreateTestResult < ActiveRecord::Migration def up - create_table :student_work_test do |t| + create_table :student_work_tests do |t| t.integer :student_work_id t.integer :homework_test_id t.integer :result @@ -9,5 +9,6 @@ class CreateTestResult < ActiveRecord::Migration end def down + drop_table :student_work_tests end end diff --git a/db/schema.rb b/db/schema.rb index a37d2f9d8..383545cf6 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 => 20150709071731) do +ActiveRecord::Schema.define(:version => 20150715070534) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -723,16 +723,6 @@ ActiveRecord::Schema.define(:version => 20150709071731) 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" @@ -1231,6 +1221,14 @@ ActiveRecord::Schema.define(:version => 20150709071731) do t.integer "project_id" end + create_table "student_work_tests", :force => true do |t| + t.integer "student_work_id" + t.integer "homework_test_id" + t.integer "result" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "student_works", :force => true do |t| t.string "name" t.text "description", :limit => 2147483647 From f909fbb8356232502830c89ea1f409dc8142f1ea Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 15 Jul 2015 16:01:03 +0800 Subject: [PATCH 36/55] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=86=E7=8F=AD=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/student_work_helper.rb | 15 +++++++++++++++ app/views/student_work/index.html.erb | 1 + config/locales/zh.yml | 1 + public/stylesheets/courses.css | 2 +- public/stylesheets/public.css | 1 + 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index f88b1ff21..2171d44f5 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -80,4 +80,19 @@ module StudentWorkHelper end color end + + #获取分班信息 + def course_group_list course + result = [] + if course.course_groups && !course.course_groups.empty? + result << l(:label_chose_group) + course.course_groups.each do |group| + option = [] + option << group.name + option << group.id + result << option + end + end + result + end end \ No newline at end of file diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index 70f7c08f4..ad355c4ad 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -49,6 +49,7 @@ <% if @show_all%> + <%= select_tag :late_penalty,options_for_select(course_group_list(@course),@group), {:class => "fl h22 w100 ml10"} %> 搜索 <%= link_to("缺评情况",student_work_absence_penalty_student_work_index_path(:homework => @homework.id), :class => "student_work_search fl", :target => "_blank") if((@is_teacher || User.current.admin?) && @homework.homework_type == 1) %> <% end%> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index ac8ab40a9..2dd5bcf9a 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2026,6 +2026,7 @@ zh: label_file_lost_list: 缺失文件列表 lable_unset: 未设置 + label_chose_group: 请选择分班 diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index a6d8ff0a2..abeec52d3 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -665,7 +665,7 @@ a:hover.ping_pic{border:1px solid #64bdd9;} a.down_btn{ border:1px solid #CCC; color:#999; padding:0px 5px; font-size:12px; text-align:center; display:block;} a:hover.down_btn{ background:#14ad5a; color:#fff; border:1px solid #14ad5a;} .fr{ float:right;} -.min_search{ width:200px; height:20px; border:1px solid #d0d0d0; color:#666; background:url(../images/public_icon.png) 185px -193px no-repeat; cursor:pointer;} +.min_search{ width:140px; height:20px; border:1px solid #d0d0d0; color:#666; background:url(../images/public_icon.png) 185px -193px no-repeat; } .li_min_search{ float:right; margin-right:-10px;} .info_ni_download{ width:100px; padding:5px;position: absolute;display:none;-moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; box-shadow:0px 0px 5px #194a81; color:#666; background:#fff; text-align:left;margin-left: 200px;margin-top: 10px;} .info_ni{ width:100px; padding:5px;position: absolute;display:none;-moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; box-shadow:0px 0px 5px #194a81; color:#666; background:#fff; text-align:left;margin-left: 50px;margin-top: -5px;} diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 8a128e71f..8e16c9436 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -110,6 +110,7 @@ h4{ font-size:14px; color:#3b3b3b;} .w350{ width:350px;} .w610{ width:610px;} .w600{ width:600px;} +.h20{height: 20px;} .h22{ height:22px;} .h26{ height:26px;} .h50{ height:50px;} From 66c1dfa77e5f0c78c5e1b768bb5fe30c2eca0724 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 15 Jul 2015 17:34:34 +0800 Subject: [PATCH 37/55] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=86=E7=8F=AD=E7=9A=84=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 101 +++++++++++++----- app/helpers/student_work_helper.rb | 5 +- .../_evaluation_student_work.html.erb | 2 +- .../_evaluation_student_work_title.html.erb | 26 ++--- .../student_work/_student_work_title.html.erb | 20 ++-- app/views/student_work/index.html.erb | 6 +- public/javascripts/course.js | 8 +- 7 files changed, 110 insertions(+), 58 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index cf712bfc9..d4a1bd4e5 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -9,36 +9,75 @@ class StudentWorkController < ApplicationController before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list] def index - @order,@b_sort,@name = params[:order] || "score",params[:sort] || "desc",params[:name] || "" + @order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group] @is_teacher = User.current.allowed_to?(:as_teacher,@course) - #老师 || 非匿评作业 || 匿评结束 显示所有的作品 - @show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin? - if @show_all - if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品 - if @order == "name" - @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name - else - @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name - end - else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品 - my_work = @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) - if my_work.empty? - @stundet_works = [] - else + unless @group == "0" || @group.nil? + group_students = CourseGroup.find_by_id(@group).users + if group_students.empty? + student_in_group = '(0)' + else + student_in_group = '(' + group_students.map{|user| user.id}.join(',') + ')' + end + #老师 || 非匿评作业 || 匿评结束 显示所有的作品 + @show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin? + if @show_all + if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品 if @order == "name" - @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name + @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name else - @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name + @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name + end + else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品 + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + if my_work.empty? + @stundet_works = [] + else + if @order == "name" + @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name + else + @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name + end end end + else #学生 + if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品 + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品 + @is_evaluation = true + my_work = @homework.student_works.where(:user_id => User.current.id) + @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} + end end - else #学生 - if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品 - @stundet_works = @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) - elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品 - @is_evaluation = true - my_work = @homework.student_works.where(:user_id => User.current.id) - @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} + else + #老师 || 非匿评作业 || 匿评结束 显示所有的作品 + @show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin? + if @show_all + if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品 + if @order == "name" + @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name + else + @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name + end + else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品 + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + if my_work.empty? + @stundet_works = [] + else + if @order == "name" + @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name + else + @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name + end + end + end + else #学生 + if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品 + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品 + @is_evaluation = true + my_work = @homework.student_works.where(:user_id => User.current.id) + @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} + end end end @homework_commons = @course.homework_commons.order("created_at desc") @@ -170,6 +209,12 @@ class StudentWorkController < ApplicationController if @score @score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" @score.score = params[:score] if params[:score] + if User.current.admin? + @score.reviewer_role = 1 + else + role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name + @score.reviewer_role = get_role_by_name(role) + end @is_new = false else @score = StudentWorksScore.new @@ -177,8 +222,12 @@ class StudentWorkController < ApplicationController @score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" @score.user_id = User.current.id @score.student_work_id = @work.id - role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name - User.current.admin? ? @score.reviewer_role = 1 : @score.reviewer_role = get_role_by_name(role) + if User.current.admin? + @score.reviewer_role = 1 + else + role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name + @score.reviewer_role = get_role_by_name(role) + end @is_new = true end diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index 2171d44f5..f24d5078f 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -85,7 +85,10 @@ module StudentWorkHelper def course_group_list course result = [] if course.course_groups && !course.course_groups.empty? - result << l(:label_chose_group) + base = [] + base << l(:label_chose_group) + base << 0 + result << base course.course_groups.each do |group| option = [] option << group.name diff --git a/app/views/student_work/_evaluation_student_work.html.erb b/app/views/student_work/_evaluation_student_work.html.erb index 0f66452c7..b83917481 100644 --- a/app/views/student_work/_evaluation_student_work.html.erb +++ b/app/views/student_work/_evaluation_student_work.html.erb @@ -9,7 +9,7 @@ <%= link_to student_work.user.show_name,user_path(student_work.user),:title => student_work.user.show_name, :class => "c_blue02"%>
  • - <%= link_to student_work.name, student_work_path(student_work),:remote => true,:title => student_work.name, :class => "c_blue02"%> + <%= link_to student_work.name, student_work_path(student_work.id),:remote => true,:title => student_work.name, :class => "c_blue02"%>
  • <% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(student_work.created_at.to_s).strftime("%Y-%m-%d") %> diff --git a/app/views/student_work/_evaluation_student_work_title.html.erb b/app/views/student_work/_evaluation_student_work_title.html.erb index a95106a48..f19438f78 100644 --- a/app/views/student_work/_evaluation_student_work_title.html.erb +++ b/app/views/student_work/_evaluation_student_work_title.html.erb @@ -2,46 +2,46 @@ 学号
  • - <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "name"%> - + <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • 作品名称
  • - <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "created_at"%> - <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • - <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "teacher_score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • - <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "teaching_asistant_score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • <% if @homework.homework_type == 1%> - <%= link_to "匿评",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "匿评",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% elsif @homework.homework_type == 2%> - <%= link_to "系统",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "系统",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% end %> <% if @show_all && @order == "student_score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • - <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • \ No newline at end of file diff --git a/app/views/student_work/_student_work_title.html.erb b/app/views/student_work/_student_work_title.html.erb index c46f7dc79..24e6a1b37 100644 --- a/app/views/student_work/_student_work_title.html.erb +++ b/app/views/student_work/_student_work_title.html.erb @@ -2,36 +2,36 @@ 学号
  • - <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "name"%> - + <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • 作品名称
  • - <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "created_at"%> - <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • - <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "teacher_score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • - <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "teaching_asistant_score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • - <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> + <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> <% if @show_all && @order == "score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> <% end%>
  • \ No newline at end of file diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index ad355c4ad..b9148a88f 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -48,9 +48,9 @@ <%= link_to "所有作品(#{@stundet_works.count})".html_safe,student_work_index_path(:homework => @homework.id), :class => "fl"%> <% if @show_all%> - - <%= select_tag :late_penalty,options_for_select(course_group_list(@course),@group), {:class => "fl h22 w100 ml10"} %> - 搜索 + + <%= select_tag(:late_penalty,options_for_select(course_group_list(@course),@group), {:class => "fl h22 w100 ml10"}) if @is_teacher %> + 搜索 <%= link_to("缺评情况",student_work_absence_penalty_student_work_index_path(:homework => @homework.id), :class => "student_work_search fl", :target => "_blank") if((@is_teacher || User.current.admin?) && @homework.homework_type == 1) %> <% end%> <% if @is_teacher%> diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 8db456cbf..db1f761f2 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -861,14 +861,14 @@ function clickOK(path) }); } //查询 -function SearchByName(obj,url,event) +function SearchByName(name,group,url,event) { var keycode = (event.keyCode ? event.keyCode : event.which); if(keycode == '13'){ - location.href = url + "&name=" + obj.val(); + location.href = url + "&name=" + name + "&group=" + group; } } -function SearchByName_1(obj,url) +function SearchByName_1(name,group,url) { - location.href = url + "&name=" + obj.val(); + location.href = url + "&name=" + name + "&group=" + group; } From b6e123e47603f345de81cdbad2a28823522b8c2c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 16 Jul 2015 10:49:39 +0800 Subject: [PATCH 38/55] =?UTF-8?q?=E5=8F=B3=E4=B8=8A=E8=A7=92=E5=AF=BC?= =?UTF-8?q?=E8=88=AA=E6=A0=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_base_header.html.erb | 5 +---- public/javascripts/header.js | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb index b800a1722..16fa44c73 100644 --- a/app/views/layouts/_base_header.html.erb +++ b/app/views/layouts/_base_header.html.erb @@ -101,10 +101,7 @@ addSlipMenu(); addProjectSlipMenu (); addCourseSlipMenu(); - }); - - jQuery(document).ready(function($) { - $('.sub_menu').find("a").attr('target', '_blank'); + $('.sub_menu').find("a").attr('target', '_blank'); $('.project_sub_menu').find("a").attr('target', '_blank'); $('.course_sub_menu').find("a").attr('target', '_blank'); }); diff --git a/public/javascripts/header.js b/public/javascripts/header.js index e27f758d3..06748d726 100644 --- a/public/javascripts/header.js +++ b/public/javascripts/header.js @@ -1,11 +1,15 @@ function addSlipMenu () { - var loggedas = $('#current_user_li:first'); + var loggedas = $('#current_user_li a:first'); var sub_menu = $('#user_sub_menu'); - loggedas.mouseenter(function(event) { + loggedas.mouseenter(function() { sub_menu.show(); + $('#my_projects_ul').hide(); + $('#my_courses_ul').hide(); }); - sub_menu.mouseleave(function(event) { + sub_menu.mouseleave(function() { sub_menu.hide(); + $('#my_projects_ul').hide(); + $('#my_courses_ul').hide(); }); } @@ -13,24 +17,26 @@ function addProjectSlipMenu () { var loggedas = $('#my_projects_li'); var project_sub_menu = $('#my_projects_ul'); var course_sub_menu = $('#my_courses_ul'); - loggedas.mouseenter(function(event) { + loggedas.mouseenter(function() { course_sub_menu.hide(); project_sub_menu.show(); }); - loggedas.mouseleave(function(event) { + loggedas.mouseleave(function() { project_sub_menu.hide(); + course_sub_menu.hide(); }); } function addCourseSlipMenu () { var loggedas = $('#my_courses_li'); var project_sub_menu = $('#my_projects_ul'); var course_sub_menu = $('#my_courses_ul'); - loggedas.mouseenter(function(event) { + loggedas.mouseenter(function() { project_sub_menu.hide(); course_sub_menu.show(); }); - loggedas.mouseleave(function(event) { + loggedas.mouseleave(function() { course_sub_menu.hide(); + project_sub_menu.hide(); }); } From 17e61020057a2f2f54e8edd684c993e8d9d0effa Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 16 Jul 2015 14:26:43 +0800 Subject: [PATCH 39/55] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index d4a1bd4e5..0168e1057 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -124,7 +124,7 @@ class StudentWorkController < ApplicationController url = "http://test.gitlab.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json" uri = URI(url) solutions = { - id:stundet_work.id, + stundet_work_id:stundet_work.id, src:stundet_work.description, language:1 } @@ -372,9 +372,15 @@ class StudentWorkController < ApplicationController #设置编程作业得分 def set_program_score - stundet_work = StudentWork.find_by_id params[:id] - if stundet_work - stundet_work.update_column("student_score",params[:status] == 0 ? 100 : 0) + stundet_work = StudentWork.find_by_id params[:student_work_id] + if stundet_work && params[:result] && params[:results].class.to_s == "Array" + homework_common = stundet_work.homework_common + params[:results].each do |result| + homework_test = homework_common.homework_tests.where("input = #{result[:input]} AND output = #{result[:output]}").first + if homework_test + StudentWorkTest.create(:student_work_id => stundet_work.id,:homework_test_id => homework_test.id,:result => result[:status]) + end + end end end From 0fc3e0077a5120ab2d06bb99bef64174322fde2b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 16 Jul 2015 16:15:47 +0800 Subject: [PATCH 40/55] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E7=BC=96=E7=A8=8B=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 19 +++++++++++++++++-- app/controllers/student_work_controller.rb | 10 ++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index a8ccf2b9a..698f29c56 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -1,5 +1,6 @@ class HomeworkCommonController < ApplicationController require 'net/http' + require 'json' layout "base_courses" 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] @@ -74,7 +75,6 @@ class HomeworkCommonController < ApplicationController homework_detail_programing.standard_code = params[:standard_code] question = {title:homework.name,content:homework.description} - uri = URI('http://test.gitlab.trustie.net/api/questions.json') question[:input] = [] question[:output] = [] if params[:input] && params[:output] @@ -89,7 +89,22 @@ class HomeworkCommonController < ApplicationController end end end - res = Net::HTTP.post_form(uri, question) + + # uri = URI('http://test.gitlab.trustie.net/api/questions.json') + # req = Net::HTTP::Post.new(uri, initheader = {'Content-Type' =>'application/json'}) + # req.body = question.to_json + # res = Net::HTTP.start(uri.hostname, uri.port) do |http| + # http.request(req) + # end + + uri = URI('http://test.gitlab.trustie.net/api/questions.json') + body = question.to_json + res = Net::HTTP.new(uri.host, uri.port).start do |client| + request = Net::HTTP::Post.new(uri.path) + request.body = body + request["Content-Type"] = "application/json" + client.request(request) + end result = JSON.parse(res.body) homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0 diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 0168e1057..2d8403fa2 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -122,13 +122,19 @@ class StudentWorkController < ApplicationController if stundet_work.save if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分 url = "http://test.gitlab.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json" - uri = URI(url) solutions = { stundet_work_id:stundet_work.id, src:stundet_work.description, language:1 } - Net::HTTP.post_form(uri, solutions) + uri = URI(url) + body = solutions.to_json + res = Net::HTTP.new(uri.host, uri.port).start do |client| + request = Net::HTTP::Post.new(uri.path) + request.body = body + request["Content-Type"] = "application/json" + client.request(request) + end end respond_to do |format| format.html { From 93905f2f325bec101e5f1b46928e3730da20349e Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 16 Jul 2015 17:33:15 +0800 Subject: [PATCH 41/55] =?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/student_work_test.rb | 36 +++++++++++++++++++ .../_programing_work_show.html.erb | 18 ++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/app/models/student_work_test.rb b/app/models/student_work_test.rb index b9264191c..d9ac5e935 100644 --- a/app/models/student_work_test.rb +++ b/app/models/student_work_test.rb @@ -1,6 +1,42 @@ +# encoding: utf-8 class StudentWorkTest < ActiveRecord::Base attr_accessible :student_work_id, :homework_test_id belongs_to :homework_test belongs_to :student_work + + def status_to_s + case self.result + when -1 + '编译出错' + when -2 + '答题错误' + when -3 + '答案错误' + when 1 + '运行出错' + when 2 + '超时' + when 3 + '内存超出' + when 4 + '输出超出' + when 5 + '禁用函数' + when 6 + '其他错误' + when 0 + '成功' + else + '未知错误' + end + end + + def test_score + if self.result == 0 + format("%.1f",100.0 / self.student_work.homework_common.homework_tests.count) + else + 0 + end + end end diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb index 80284dac0..2711ad172 100644 --- a/app/views/student_work/_programing_work_show.html.erb +++ b/app/views/student_work/_programing_work_show.html.erb @@ -26,6 +26,19 @@
  • 测试结果: + + + + + + + + + + + + + <%@homework.homework_tests.each do |test|%> "> - - + + <% end%> +
    @@ -34,10 +47,11 @@ <%= test.output%> 错误0<%= test.student_work_test.nil? ? "正在编译队列中" : test.student_work_test.status_to_s%><%= test.student_work_test.nil? ? "0" : test.student_work_test.test_score%>
    From 8a9fd7d4c09dc5e5102b876e116eab1cb7912663 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 16 Jul 2015 17:34:13 +0800 Subject: [PATCH 42/55] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/_programing_work_show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb index 2711ad172..e73fdb1bb 100644 --- a/app/views/student_work/_programing_work_show.html.erb +++ b/app/views/student_work/_programing_work_show.html.erb @@ -47,7 +47,7 @@ <%= test.output%> - <%= test.student_work_test.nil? ? "正在编译队列中" : test.student_work_test.status_to_s%> + <%= test.student_work_test.nil? ? "正在编译" : test.student_work_test.status_to_s%> <%= test.student_work_test.nil? ? "0" : test.student_work_test.test_score%> <% end%> From 421b377785a98afb8ae3ed33986f5079afc5ebf6 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 16 Jul 2015 17:54:42 +0800 Subject: [PATCH 43/55] =?UTF-8?q?=E5=B1=80=E5=9F=9F=E7=BD=91=E4=B8=8D?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 2 +- app/controllers/student_work_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 698f29c56..8b37ca8e4 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -97,7 +97,7 @@ class HomeworkCommonController < ApplicationController # http.request(req) # end - uri = URI('http://test.gitlab.trustie.net/api/questions.json') + uri = URI('http://192.168.80.21:8080/api/questions.json') body = question.to_json res = Net::HTTP.new(uri.host, uri.port).start do |client| request = Net::HTTP::Post.new(uri.path) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 2d8403fa2..5b6de453e 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -121,7 +121,7 @@ class StudentWorkController < ApplicationController if stundet_work.save if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分 - url = "http://test.gitlab.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json" + url = "http://192.168.80.21:8080/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json" solutions = { stundet_work_id:stundet_work.id, src:stundet_work.description, From f9cf47804a37daaea73394a06c5e51142696c855 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 16 Jul 2015 18:13:43 +0800 Subject: [PATCH 44/55] =?UTF-8?q?x=E5=AD=A6=E7=94=9F=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=85=88=20base64=E7=BC=96=E7=A0=81=E5=9C=A8?= =?UTF-8?q?=E4=BC=A0=E9=80=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 5b6de453e..1d40415c8 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -2,6 +2,7 @@ class StudentWorkController < ApplicationController layout "base_courses" include StudentWorkHelper require 'bigdecimal' + require "base64" before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work] before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work] @@ -124,7 +125,7 @@ class StudentWorkController < ApplicationController url = "http://192.168.80.21:8080/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json" solutions = { stundet_work_id:stundet_work.id, - src:stundet_work.description, + src:Base64.encode64(stundet_work.description), language:1 } uri = URI(url) From 0718a2838237aa93d6937fac4cd2023b3e6c770e Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 17 Jul 2015 14:17:42 +0800 Subject: [PATCH 45/55] =?UTF-8?q?=E5=A2=9E=E5=8A=A0gem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 660a7ff49..2b43cade3 100644 --- a/Gemfile +++ b/Gemfile @@ -26,6 +26,7 @@ gem 'spreadsheet' gem 'ruby-ole' gem 'rails_kindeditor',path:'lib/rails_kindeditor' #gem "rmagick", ">= 2.0.0" +gem 'binding_of_caller' group :development do gem 'grape-swagger' From 666539a4cc89212492d486ad8ae03f16c4bda91d Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 17 Jul 2015 14:35:27 +0800 Subject: [PATCH 46/55] =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=90=8D=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 1d40415c8..78c12c382 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -124,7 +124,7 @@ class StudentWorkController < ApplicationController if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分 url = "http://192.168.80.21:8080/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json" solutions = { - stundet_work_id:stundet_work.id, + student_work_id:stundet_work.id, src:Base64.encode64(stundet_work.description), language:1 } From 1f6ed64e540e96850d945e9ce8c76e62dd5fc89a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 17 Jul 2015 14:48:20 +0800 Subject: [PATCH 47/55] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=88=A0=E9=99=A4=E4=BD=9C=E5=93=81=E7=9A=84?= =?UTF-8?q?=E7=82=B9=E8=B5=9E=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/student_work.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 0db36b4ba..c80d1315b 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -9,5 +9,11 @@ class StudentWork < ActiveRecord::Base belongs_to :project has_one :student_work_test + before_destroy :delete_praise + acts_as_attachable + + def delete_praise + PraiseTread.where("praise_tread_object_id = #{self.id} AND praise_tread_object_type = 'StudentWork'").destroy_all + end end From fa2dfd06923de6ee37566ff67fb02d3e0eade64e Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 17 Jul 2015 14:53:07 +0800 Subject: [PATCH 48/55] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=BE=97=E5=88=86?= =?UTF-8?q?=E5=BC=B9=E5=87=BA=E6=A1=86=EF=BC=8C=E4=BD=9C=E4=B8=9A=E5=90=8D?= =?UTF-8?q?=E8=BF=87=E9=95=BF=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/_show_member_score.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/courses/_show_member_score.html.erb b/app/views/courses/_show_member_score.html.erb index bdc1fa147..2d08e853e 100644 --- a/app/views/courses/_show_member_score.html.erb +++ b/app/views/courses/_show_member_score.html.erb @@ -19,7 +19,7 @@
  • 作业名称得分
  • <% @member_score.homework_common_list.each do |homework_common| %>
  • - + <%= homework_common.name %> From c18481e89cf1cc684215f537b12ee077afb6d8d8 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 17 Jul 2015 15:31:49 +0800 Subject: [PATCH 49/55] =?UTF-8?q?=E5=9B=9E=E8=B0=83=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=BF=94=E5=9B=9E=20=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=B8=8D=E8=83=BD=E5=AD=98=E5=82=A8=E7=BB=93?= =?UTF-8?q?=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 11 ++++++++--- app/views/student_work/set_program_score.html.erb | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 app/views/student_work/set_program_score.html.erb diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 78c12c382..71ccee592 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -380,12 +380,17 @@ class StudentWorkController < ApplicationController #设置编程作业得分 def set_program_score stundet_work = StudentWork.find_by_id params[:student_work_id] - if stundet_work && params[:result] && params[:results].class.to_s == "Array" + @course = stundet_work.homework_common.course + if stundet_work && params[:results] && params[:results].class.to_s == "Array" homework_common = stundet_work.homework_common params[:results].each do |result| - homework_test = homework_common.homework_tests.where("input = #{result[:input]} AND output = #{result[:output]}").first + homework_test = homework_common.homework_tests.where("input = '#{result[:input]}' AND output = '#{result[:output]}'").first if homework_test - StudentWorkTest.create(:student_work_id => stundet_work.id,:homework_test_id => homework_test.id,:result => result[:status]) + student_work_test = StudentWorkTest.new + student_work_test.student_work = stundet_work + student_work_test.homework_test = homework_test + student_work_test.result = result[:status] + student_work_test.save end end end diff --git a/app/views/student_work/set_program_score.html.erb b/app/views/student_work/set_program_score.html.erb new file mode 100644 index 000000000..6ea169c64 --- /dev/null +++ b/app/views/student_work/set_program_score.html.erb @@ -0,0 +1 @@ +成功 \ No newline at end of file From eae8e71561cddf402601e16e6da14153fdd47538 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 17 Jul 2015 15:49:58 +0800 Subject: [PATCH 50/55] save--->save! --- app/controllers/student_work_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 71ccee592..4e97c373c 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -390,7 +390,7 @@ class StudentWorkController < ApplicationController student_work_test.student_work = stundet_work student_work_test.homework_test = homework_test student_work_test.result = result[:status] - student_work_test.save + student_work_test.save! end end end From 26843c311fc70d2b4ffc520986f54bf21b08beba Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 17 Jul 2015 15:53:28 +0800 Subject: [PATCH 51/55] =?UTF-8?q?=E7=BC=96=E8=AF=91=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E8=B7=A8=E5=9F=9F=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 4e97c373c..c76bbd7b6 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -8,6 +8,7 @@ class StudentWorkController < ApplicationController before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work] before_filter :author_of_work, :only => [:edit, :update, :destroy] before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list] + protect_from_forgery :except => :set_program_score def index @order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group] From 59b2f247c5667c2a031320f2430cd67e95dc82fe Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 17 Jul 2015 16:12:29 +0800 Subject: [PATCH 52/55] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=AF=84=E5=88=86?= =?UTF-8?q?=E5=90=8E=E8=8E=B7=E5=8F=96=E5=BE=97=E5=88=86=E8=B5=8B=E5=80=BC?= =?UTF-8?q?=E5=88=B0=E7=B3=BB=E7=BB=9F=E8=AF=84=E5=88=86=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E8=AE=A1=E7=AE=97=E6=9C=80=E7=BB=88=E5=BE=97?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index c76bbd7b6..20cdc6659 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -382,6 +382,7 @@ class StudentWorkController < ApplicationController def set_program_score stundet_work = StudentWork.find_by_id params[:student_work_id] @course = stundet_work.homework_common.course + student_score_count = 0 if stundet_work && params[:results] && params[:results].class.to_s == "Array" homework_common = stundet_work.homework_common params[:results].each do |result| @@ -391,9 +392,28 @@ class StudentWorkController < ApplicationController student_work_test.student_work = stundet_work student_work_test.homework_test = homework_test student_work_test.result = result[:status] + if student_work_test.result == 0 + student_score_count += 1 + end student_work_test.save! end end + unless homework_common.homework_tests.empty? + stundet_work.student_score = student_score_count * 100.0 / homework_common.homework_tests.count + + if stundet_work.teacher_score.nil? + if stundet_work.teaching_asistant_score.nil? + stundet_work.final_score = stundet_work.student_score + else + final_ta_score = BigDecimal.new("#{stundet_work.teaching_asistant_score}") * BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}") + final_s_score = BigDecimal.new("#{stundet_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}")) + final_score = final_ta_score + final_s_score + stundet_work.final_score = format("%.1f",final_score.to_f) + end + end + + stundet_work.save! + end end end From 5799d08a0d986556406c65b420470a30f5db2779 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 17 Jul 2015 16:17:38 +0800 Subject: [PATCH 53/55] =?UTF-8?q?1=E3=80=81=E8=80=81=E5=B8=88=E8=AF=84?= =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A=E5=BE=97=E5=88=86=E5=90=8E?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF=202=E3=80=81=E7=BC=96?= =?UTF-8?q?=E7=A8=8B=E4=BD=9C=E4=B8=9A=E7=B3=BB=E7=BB=9F=E5=BE=97=E5=88=86?= =?UTF-8?q?=E4=B8=8D=E7=8E=B0=E5=AE=9E=E5=90=8E=E9=9D=A2=E6=8B=AC=E5=8F=B7?= =?UTF-8?q?=E5=92=8C=E7=9B=B8=E5=85=B3=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_evaluation_student_work.html.erb | 2 +- app/views/student_work/add_score.js.erb | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/views/student_work/_evaluation_student_work.html.erb b/app/views/student_work/_evaluation_student_work.html.erb index b83917481..b5bdd6f55 100644 --- a/app/views/student_work/_evaluation_student_work.html.erb +++ b/app/views/student_work/_evaluation_student_work.html.erb @@ -26,7 +26,7 @@
  • <%= student_work.student_score.nil? ? "--" : format("%.1f",student_work.student_score)%> - <% unless student_work.student_score.nil?%> + <% unless student_work.student_score.nil? || student_work.homework_common.homework_type == 2%> (<%= student_work.student_works_scores.where(:reviewer_role => 3).count%>) diff --git a/app/views/student_work/add_score.js.erb b/app/views/student_work/add_score.js.erb index 9298de8fc..1de92b51a 100644 --- a/app/views/student_work/add_score.js.erb +++ b/app/views/student_work/add_score.js.erb @@ -2,20 +2,23 @@ $("#add_student_score_<%= @work.id%>").html("<%= escape_javascript(render :parti $('#score_<%= @work.id%>').peSlider({range: 'min'}); <% if @is_new%> -$("#score_list_<%= @work.id%>").prepend("
    <%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>
    "); + $("#score_list_<%= @work.id%>").prepend("
    <%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>
    "); <% else %> -$("#work_score_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>"); + $("#work_score_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>"); <% end%> + $("#score_list_<%= @work.id%>").removeAttr("style"); <% if @is_teacher %> -<% if @homework.homework_type == 1%> -$("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_student_work',:locals => {:student_work => @work}) %>"); -<% else%> -$("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'student_work',:locals => {:student_work => @work}) %>"); -<% end%> + <% if @homework.homework_type == 1%> + $("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_student_work',:locals => {:student_work => @work}) %>"); + <% elsif @homework.homework_type == 2%> + $("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_student_work',:locals => {:student_work => @work}) %>"); + <% else%> + $("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'student_work',:locals => {:student_work => @work}) %>"); + <% end%> <% else %> -$("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_work',:locals => {:student_work => @work}) %>"); + $("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_work',:locals => {:student_work => @work}) %>"); <% end%> From 159d8f644e869ecc1be1a1a2bd55043d67904f96 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 17 Jul 2015 16:22:00 +0800 Subject: [PATCH 54/55] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E4=B8=8D=E5=8F=AF=E4=BF=AE=E6=94=B9=E4=BD=9C=E5=93=81=EF=BC=8C?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c4762e8cc..64d8ce142 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2307,6 +2307,8 @@ module ApplicationHelper else if homework.homework_type == 1 && homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前 "#{l(:label_edit_homework)}".html_safe + elsif homework.homework_type == 2 #编程作业不能修改作品 + "作品已交".html_safe else link_to l(:label_edit_homework), edit_student_work_path(work.id),:class => 'fr mr10 work_edit' end From b981c4d07b113e73a3ba83635d3b3d28a6807597 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 17 Jul 2015 17:30:48 +0800 Subject: [PATCH 55/55] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=88=A4=E6=96=AD=EF=BC=9A=E5=B0=86/n=E8=BD=AC=E8=BF=98?= =?UTF-8?q?=E6=88=90
    ?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 4 ++++ app/views/student_work/_programing_work_show.html.erb | 2 +- app/views/student_work/_show.html.erb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 64d8ce142..47a3b59ae 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2343,4 +2343,8 @@ module ApplicationHelper end end + #将文本内的/n转换为
    + def text_format text + text.gsub("\n","
    ").html_safe + end end diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb index e73fdb1bb..8060b8a79 100644 --- a/app/views/student_work/_programing_work_show.html.erb +++ b/app/views/student_work/_programing_work_show.html.erb @@ -19,7 +19,7 @@ 编程代码:
    - <%= textilizable @work.description%> + <%= text_format @work.description%>
  • diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index dfe61d3db..2b7d49402 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -36,7 +36,7 @@
  • 内容:
    - <%= textilizable @work.description%> + <%= text_format @work.description%>