From cbbc93acbdda6be9a0a043b0ec604dc264d2a930 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sat, 1 Aug 2015 10:45:32 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=BD=93=E6=A0=87=E5=87=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=86=85=E5=AE=B9=E6=94=B9=E5=8F=98=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=BF=98=E5=8E=9F=E6=89=80=E6=9C=89=E7=9A=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_homework_detail_programing_form.html.erb | 14 +++++++++++--- app/views/homework_common/programing_test.js.erb | 2 +- public/javascripts/course.js | 2 +- 3 files changed, 13 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 5e53c4b15..7c66df057 100644 --- a/app/views/homework_common/_homework_detail_programing_form.html.erb +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -78,7 +78,7 @@
  • - +
  • @@ -96,7 +96,7 @@
  • - 测试 + 测试
  • @@ -115,7 +115,7 @@
  • - 测试 + 测试
  • @@ -142,4 +142,12 @@ } ); } + + function init_programing_test() + { + $(".programing_test").each(function(){ + $(this).removeClass("green_btn red_btn").addClass("blue_btn").text("测试"); + $(this).next("input").val(""); + }); + } \ No newline at end of file diff --git a/app/views/homework_common/programing_test.js.erb b/app/views/homework_common/programing_test.js.erb index 74ec9439a..8f76642f1 100644 --- a/app/views/homework_common/programing_test.js.erb +++ b/app/views/homework_common/programing_test.js.erb @@ -1,2 +1,2 @@ -$("#test_send_<%= @index%>").replaceWith(" fl ml5 mt1' onclick='programing_test(<%= @index%>)' id='test_send_<%= @index%>'><%= @result == 0 ? '正确' : '错误'%>"); +$("#test_send_<%= @index%>").replaceWith(" fl ml5 mt1 programing_test' onclick='programing_test(<%= @index%>)' id='test_send_<%= @index%>'><%= @result == 0 ? '正确' : '错误'%>"); $("#test_result_<%= @index%>").val("<%= @result%>"); \ No newline at end of file diff --git a/public/javascripts/course.js b/public/javascripts/course.js index c7b01cee1..6ba202b28 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -550,7 +550,7 @@ function add_programing_test(obj) { "
  • " + "
  • " + "" + - "测试" + + "测试" + "" + "
  • "); } From f5cfd7258d32493b93143c3e628875e5a40f0ec7 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sat, 1 Aug 2015 14:27:32 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=96=E7=A8=8B?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=97=B6=EF=BC=8C=E5=AF=B9=E5=B7=B2=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E6=B5=8B=E8=AF=95=E3=80=81=E6=9C=AA=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=98=BE=E7=A4=BA=E7=9A=84=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=EF=BC=8C=E4=BB=A5=E5=8F=8A=E4=BF=AE=E6=94=B9=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E7=BB=93=E6=9E=9C=E7=9A=84=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 4 +++- app/models/homework_test.rb | 2 +- .../_homework_detail_programing_form.html.erb | 12 ++++++++++-- db/migrate/20150801034945_change_result_default.rb | 9 +++++++++ db/schema.rb | 8 ++++---- 5 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 db/migrate/20150801034945_change_result_default.rb diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index e3424707f..6f2ecef0b 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -223,17 +223,19 @@ class HomeworkCommonController < ApplicationController homework_test = HomeworkTest.find id homework_test.destroy if homework_test end - if params[:input] && params[:output] + if params[:input] && params[:output] && params[:result] params[:input].each do |k,v| if params[:output].include? k homework_test = HomeworkTest.find_by_id k if homework_test #已存在的测试,修改 homework_test.input = v homework_test.output = params[:output][k] + homework_test.result = params[:result][k] else #不存在的测试,增加 homework_test = HomeworkTest.new homework_test.input = v homework_test.output = params[:output][k] + homework_test.result = params[:result][k] homework_test.homework_common = @homework end homework_test.save diff --git a/app/models/homework_test.rb b/app/models/homework_test.rb index 4ed290ecd..df2848194 100644 --- a/app/models/homework_test.rb +++ b/app/models/homework_test.rb @@ -1,5 +1,5 @@ class HomeworkTest < ActiveRecord::Base - attr_accessible :input, :output, :homework_common_id + attr_accessible :input, :output, :homework_common_id,:result,:error_msg belongs_to :homework_common has_many :student_work_test 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 7c66df057..22ca4cac7 100644 --- a/app/views/homework_common/_homework_detail_programing_form.html.erb +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -96,8 +96,16 @@
  • - 测试 - + <% if homework_test.result && !homework_test.result.to_s.empty?%> + <% if homework_test.result == 0%> + 成功 + <% else%> + 错误 + <% end%> + <% else%> + 测试 + <% end%> +
  • diff --git a/db/migrate/20150801034945_change_result_default.rb b/db/migrate/20150801034945_change_result_default.rb new file mode 100644 index 000000000..1f629aa45 --- /dev/null +++ b/db/migrate/20150801034945_change_result_default.rb @@ -0,0 +1,9 @@ +class ChangeResultDefault < ActiveRecord::Migration + def up + change_column :homework_tests,:result,:integer,:default => nil + end + + def down + change_column :homework_tests,:result,:integer,:default => 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index 29aeb1f16..30ca29d12 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 => 20150730130816) do +ActiveRecord::Schema.define(:version => 20150801034945) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -632,9 +632,9 @@ ActiveRecord::Schema.define(:version => 20150730130816) do t.text "input" t.text "output" t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "result", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "result" t.text "error_msg" end From 1cd50693b53fc2f5bf39dd459562a800c590b615 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sat, 1 Aug 2015 14:31:22 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/account/zh.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/account/zh.yml b/config/locales/account/zh.yml index 69edc7aa3..c7c76707d 100644 --- a/config/locales/account/zh.yml +++ b/config/locales/account/zh.yml @@ -37,7 +37,7 @@ zh: label_password_lost: "忘记密码?" button_login: 登录 # account_controller中判断用户名或密码输入有误的提示信息 - notice_account_invalid_creditentials: "无效的用户名或密码" + notice_account_invalid_creditentials: "无效的用户名或密码,注意登录名区分大小写,谢谢!" # account_controller中判断未激活的提示信息 notice_account_invalid_creditentials_new: "您还未到邮箱激活。如果您丢失帐户,电子邮件验证帮助我们的支持团队验证帐户的所有权,并允许您接收所有您要求的通知。" From 793f477f1c2ed58076e80dfa48ab0e6ddac71a47 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sat, 1 Aug 2015 14:58:41 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E6=95=B0=E3=80=81=E5=8A=A0=E5=85=A5=E8=AF=BE=E7=A8=8B=E6=95=B0?= =?UTF-8?q?=E3=80=81=E5=88=9B=E5=BB=BA=E9=A1=B9=E7=9B=AE=E6=95=B0=E3=80=81?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E9=A1=B9=E7=9B=AE=E6=95=B0=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/users_helper.rb | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 5553990e6..5a87286b4 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -332,33 +332,45 @@ module UsersHelper end def get_create_course_count(user) - if user == User.current - user.courses.count - else - user.courses.where("is_public = 1").count - end + user.courses.visible.where("tea_id = ?",user.id).count end + + #获取加入课程数 def get_join_course_count(user) - user.coursememberships.count - get_create_course_count(user) + user.courses.visible.count - get_create_course_count(user) end + + #发布作业数 def get_homework_commons_count(user) HomeworkCommon.where("user_id = ?",user.id).count end + + #资源数 def get_projectandcourse_attachment_count(user) Attachment.where("author_id = ? and container_type in ('Project','Course')",user.id).count end + + #创建项目数 def get_create_project_count(user) - Project.where("user_id = ? and project_type = ?",user.id,Project::ProjectType_project).count + user.projects.visible.where("projects.user_id=#{user.id}").count end + + #加入项目数 def get_join_project_count(user) - user.memberships.count(conditions: "projects.project_type = #{Project::ProjectType_project}") - get_create_project_count(user) + user.projects.visible.count - get_create_project_count(user) end + + #创建缺陷数 def get_create_issue_count(user) Issue.where("author_id = ?",user.id).count end + + #解决缺陷数 def get_resolve_issue_count(user) Issue.where("assigned_to_id = ? and status_id=3",user.id).count end + + #参与匿评数 def get_anonymous_evaluation_count(user) StudentWorksScore.where("user_id = ? and reviewer_role=3",user.id).count end From bed46c050ff1512104cbd0154ed439d156338b2f Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sat, 1 Aug 2015 15:04:39 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E3=80=81=E5=8A=A0=E5=85=A5=E8=AF=BE=E7=A8=8B=E3=80=81=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E4=BD=9C=E4=B8=9A=E6=95=B0=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/views/layouts/base_users_new.html.erb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/layouts/base_users_new.html.erb b/app/views/layouts/base_users_new.html.erb index 33973b047..acd9c238e 100644 --- a/app/views/layouts/base_users_new.html.erb +++ b/app/views/layouts/base_users_new.html.erb @@ -171,11 +171,11 @@