From 36d82e1315f77b308fd0d8994f5ad3e0276eecd0 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 18 Apr 2016 11:24:18 +0800 Subject: [PATCH 01/18] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=87=BA=E7=8E=B0=E4=BA=86=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/wechats/login.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb index 27898b690..0e6fd8695 100644 --- a/app/views/wechats/login.html.erb +++ b/app/views/wechats/login.html.erb @@ -17,7 +17,7 @@
-
+
From 0fa16251e759c8aadc7f4fb88ffb36f6016ca440 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 18 Apr 2016 15:57:15 +0800 Subject: [PATCH 02/18] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E7=9A=84=E5=A4=9A=E5=88=86=E4=BD=9C=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20160418074429_delete_other_works.rb | 11 +++++ db/schema.rb | 48 +++++++++++++++++-- 2 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20160418074429_delete_other_works.rb diff --git a/db/migrate/20160418074429_delete_other_works.rb b/db/migrate/20160418074429_delete_other_works.rb new file mode 100644 index 000000000..54944a6ec --- /dev/null +++ b/db/migrate/20160418074429_delete_other_works.rb @@ -0,0 +1,11 @@ +class DeleteOtherWorks < ActiveRecord::Migration + def up + works = StudentWork.where("homework_common_id = 3253 and user_id = 10740 and final_score = 0") + unless works.empty? + works.destroy_all + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 4e4201050..124870b49 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,11 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -<<<<<<< HEAD -ActiveRecord::Schema.define(:version => 20160331063938) do -======= -ActiveRecord::Schema.define(:version => 20160405021915) do ->>>>>>> c3ee4dadfb92c75e8649cad7e0ed57c2ec02ec00 +ActiveRecord::Schema.define(:version => 20160418074429) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -813,6 +809,7 @@ ActiveRecord::Schema.define(:version => 20160405021915) do t.integer "anonymous_comment", :default => 0 t.integer "quotes", :default => 0 t.integer "is_open", :default => 0 + t.datetime "simi_time" end add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" @@ -1524,6 +1521,18 @@ ActiveRecord::Schema.define(:version => 20160405021915) do t.string "topic_resource" end + create_table "rep_statics", :force => true do |t| + t.integer "project_id" + t.integer "commits_num" + t.string "uname" + t.string "email" + t.integer "add" + t.integer "del" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "changeset" + end + create_table "repositories", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.string "url", :default => "", :null => false @@ -1689,6 +1698,8 @@ ActiveRecord::Schema.define(:version => 20160405021915) do t.integer "absence_penalty", :default => 0 t.float "system_score", :default => 0.0 t.boolean "is_test", :default => false + t.integer "simi_id" + t.integer "simi_value" end add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" @@ -1921,6 +1932,25 @@ ActiveRecord::Schema.define(:version => 20160405021915) do add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count" + create_table "user_wechats", :force => true do |t| + t.integer "subscribe" + t.string "openid" + t.string "nickname" + t.integer "sex" + t.string "language" + t.string "city" + t.string "province" + t.string "country" + t.string "headimgurl" + t.string "subscribe_time" + t.string "unionid" + t.string "remark" + t.integer "groupid" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "users", :force => true do |t| t.string "login", :default => "", :null => false t.string "hashed_password", :limit => 40, :default => "", :null => false @@ -1997,6 +2027,14 @@ ActiveRecord::Schema.define(:version => 20160405021915) do t.datetime "updated_at", :null => false end + create_table "wechat_logs", :force => true do |t| + t.string "openid", :null => false + t.text "request_raw" + t.text "response_raw" + t.text "session_raw" + t.datetime "created_at", :null => false + end + create_table "wiki_content_versions", :force => true do |t| t.integer "wiki_content_id", :null => false t.integer "page_id", :null => false From 0cc5eca34b5fd923cac04e59a2bce20123dd5bcb Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 19 Apr 2016 09:58:51 +0800 Subject: [PATCH 03/18] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E7=9A=84=E9=A1=B9=E7=9B=AE=E5=88=97=E8=A1=A8=E6=9C=89=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E7=9A=84=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/new_base_user.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index 2a6df9c86..318d0db7f 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -251,7 +251,7 @@ %> <% if @user.projects.visible.count > 0 - projects = @user.projects.visible.select("projects.*, (SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5) + projects = @user.projects.visible.select("projects.*, (SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5) else projects = [] end From 1ded6ddf0485e2be000bd9f48bc7c407e246d29b Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 19 Apr 2016 13:03:12 +0800 Subject: [PATCH 04/18] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=B7=B2=E6=8F=90=E4=BA=A4=E7=9A=84=E7=BC=96?= =?UTF-8?q?=E7=A8=8B=E4=BD=9C=E5=93=81?= 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 +- app/views/users/new_user_commit_homework.html.erb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb index becec239a..eb16dc807 100644 --- a/app/views/student_work/_programing_work_show.html.erb +++ b/app/views/student_work/_programing_work_show.html.erb @@ -69,7 +69,7 @@
<%=x["result"].force_encoding("UTF-8")%> 
正确输出: -
<%=x["output"]%>
+
<%=x["output"].force_encoding("UTF-8")%>
耗时:
<%=x["time_used"]==0?1:x["time_used"]%>毫秒
diff --git a/app/views/users/new_user_commit_homework.html.erb b/app/views/users/new_user_commit_homework.html.erb index e84b7a95e..1f8d3ca26 100644 --- a/app/views/users/new_user_commit_homework.html.erb +++ b/app/views/users/new_user_commit_homework.html.erb @@ -143,9 +143,9 @@ 测试错误! <% end %> 您的输出: -
<%=x["result"]%> 
+
<%=x["result"].force_encoding("UTF-8")%> 
正确输出: -
<%= x["output"] %>
+
<%= x["output"].force_encoding("UTF-8") %>
 耗时:
<%=x["time_used"]==0?1:x["time_used"]%>毫秒
From d0331da0c292b8cfa3271c0ae1bc2f6e1eae93f8 Mon Sep 17 00:00:00 2001 From: txz Date: Tue, 19 Apr 2016 16:26:05 +0800 Subject: [PATCH 05/18] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E5=8A=A8=E6=80=81=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 --- public/assets/wechat/activities.html | 169 +++++++++++++++------------ public/images/wechat/wechat_icon.png | Bin 0 -> 4259 bytes public/javascripts/wechat/app.js | 2 +- public/stylesheets/weui/weixin.css | 11 +- 4 files changed, 101 insertions(+), 81 deletions(-) create mode 100755 public/images/wechat/wechat_icon.png diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 7494b7033..dfd60e68a 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -7,29 +7,32 @@
-
- - +
-
+ +
迟交扣分:{{act.homework_common_detail.late_penalty}}分 匿评开启时间:{{act.homework_common_detail.evaluation_start}}
缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品 匿评关闭时间:{{act.homework_common_detail.evaluation_end}}
- 点击展开 + 点击展开
- {{act.latest_update}} + {{act.activity_type_name}} + {{act.latest_update}} + + {{act.reply_count}} +
+
{{act.praise_count}}
+
{{act.praise_count}}
-
-
回复 ({{act.reply_count}})
-
赞 ({{act.praise_count}})
-
已赞 ({{act.praise_count}})
-
@@ -38,23 +41,25 @@
-
- - +
+ +
+
- 点击展开 + 点击展开
- {{act.latest_update}} + {{act.activity_type_name}} + {{act.latest_update}} + + {{act.reply_count}} +
+
{{act.praise_count}}
+
{{act.praise_count}}
-
-
回复 ({{act.reply_count}})
-
赞 ({{act.praise_count}})
-
已赞 ({{act.praise_count}})
-
@@ -63,23 +68,25 @@
-
- - +
+ +
+
- 点击展开 + 点击展开
- {{act.latest_update}} + {{act.activity_type_name}} + {{act.latest_update}} + + {{act.reply_count}} +
+
{{act.praise_count}}
+
{{act.praise_count}}
-
-
回复 ({{act.reply_count}})
-
赞 ({{act.praise_count}})
-
已赞 ({{act.praise_count}})
-
@@ -89,7 +96,7 @@
-
+
@@ -104,25 +111,27 @@
-
- - +
+ +
-
+ +
状态:{{act.issue_detail.issue_status}} 优先级:{{act.issue_detail.issue_priority}}
指派给:{{act.issue_detail.issue_assigned_to}} 完成度:{{act.issue_detail.done_ratio}}%
- 点击展开 + 点击展开
- {{act.latest_update}} + {{act.activity_type_name}} + {{act.latest_update}} + + {{act.reply_count}} +
+
{{act.praise_count}}
+
{{act.praise_count}}
-
-
回复 ({{act.reply_count}})
-
赞 ({{act.praise_count}})
-
已赞 ({{act.praise_count}})
-
@@ -132,23 +141,25 @@
-
- - +
+ +
-
+ +
- 点击展开 + 点击展开
- {{act.latest_update}} + {{act.activity_type_name}} + {{act.latest_update}} + + {{act.reply_count}} +
+
{{act.praise_count}}
+
{{act.praise_count}}
-
-
回复 ({{act.reply_count}})
-
赞 ({{act.praise_count}})
-
已赞 ({{act.praise_count}})
-
@@ -157,7 +168,7 @@
-
+
@@ -172,20 +183,23 @@
-
- - +
+ +
-
+
+

- 点击展开 + 点击展开 +
+ {{act.latest_update}} + + {{act.reply_count}} +
+
{{act.praise_count}}
+
{{act.praise_count}}
-
-
-
回复 ({{act.reply_count}})
-
赞 ({{act.praise_count}})
-
已赞 ({{act.praise_count}})
@@ -196,23 +210,24 @@
-
- - +
+ +
+
- 点击展开 + 点击展开
- {{act.latest_update}} + {{act.latest_update}} + + {{act.reply_count}} +
+
{{act.praise_count}}
+
{{act.praise_count}}
-
-
回复 ({{act.reply_count}})
-
赞 ({{act.praise_count}})
-
已赞 ({{act.praise_count}})
-
diff --git a/public/images/wechat/wechat_icon.png b/public/images/wechat/wechat_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..cbc3eb565cc9ddd9ce1a9618becd0035d38f0919 GIT binary patch literal 4259 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 diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index f164b80e3..ead53557b 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -4,6 +4,7 @@ /*基本样式*/ body,table,input,textarea,select,button { font-family: "微软雅黑","宋体";} h1,h2,h3,h4,h5,p {padding:0px; margin:0px;} +.f12 {font-size:12px;} .f13 {font-size:13px;} .f15 {font-size:15px;} .fb {font-weight:bold;} @@ -29,6 +30,7 @@ a:hover,a:active{cursor:pointer;} a.link-blue {color:#269ac9;} a.underline {text-decoration:underline;} .border-radius {border-radius:5px;} +.w36 {width:36px;} .max-width-60 {max-width:60px;} .max-width-130 {max-width:130px;} .hidden {overflow:hidden; white-space:nowrap; text-overflow:ellipsis;} @@ -39,9 +41,9 @@ a.underline {text-decoration:underline;} /*动态样式*/ .post-container {width:100%;} -.post-wrapper {width:98%; border-radius:3px; box-shadow:0px 0px 8px rgba(146, 153, 169, 0.5); background-color:#ffffff; margin:15px auto;} +.post-wrapper {width:98%; border-radius:3px; box-shadow:0px 0px 8px rgba(146, 153, 169, 0.5); background-color:#ffffff; margin:10px auto;} .post-main {padding:10px; color:#9a9a9a;} -.post-avatar {width:45px; height:45px; margin-right:10px;} +.post-avatar {width:40px; height:40px; margin-right:5px;} .post-title {font-size:13px; text-align:left;} .post-detail-info {font-size:13px; text-align:left; color:#9a9a9a;} .fl {float:left;} @@ -63,4 +65,7 @@ a.underline {text-decoration:underline;} .post-reply-date, .post-reply-trigger {font-size:13px;} .post-input-container {padding-right:2px;} .post-reply-input {width:100%; height:28px; line-height:28px; border:1px solid #e6e6e6; outline:none; padding:0; margin:0; border-radius:3px;} -.post-reply-submit {font-size:13px; padding:3px 8px; color:#fff; background-color:#269ac9; outline:none; border:none; display:inline-block;} \ No newline at end of file +.post-reply-submit {font-size:13px; padding:3px 8px; color:#fff; background-color:#269ac9; outline:none; border:none; display:inline-block;} +.reply-icon {background:url(/images/wechat/wechat_icon.png) -100px 1px no-repeat; width:20px; height:18px; display:inline-block; vertical-align:middle;} +.praise-icon {background:url(/images/wechat/wechat_icon.png) -100px -38px no-repeat; width:20px; height:18px; display:inline-block; vertical-align:middle;} +.praised-icon {background:url(/images/wechat/wechat_icon.png) -100px -76px no-repeat; width:20px; height:18px; display:inline-block; vertical-align:middle;} \ No newline at end of file From 0f5fe51f97b4137e678961087ca9b901d7b4c8f9 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Wed, 20 Apr 2016 09:51:51 +0800 Subject: [PATCH 06/18] =?UTF-8?q?1.=E7=AE=A1=E7=90=86=E5=91=98=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E4=BB=A3=E7=A0=81=E6=B5=8B=E8=AF=95=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E4=BF=AE=E6=94=B9=202.=E4=BB=A3=E7=A0=81=E6=9F=A5?= =?UTF-8?q?=E9=87=8D=E6=8C=89=E9=92=AE=E4=BD=8D=E7=BD=AE=203.=E6=9F=A5?= =?UTF-8?q?=E9=87=8D=E7=BB=93=E6=9E=9C=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 26 ++- app/controllers/student_work_controller.rb | 37 ++++- app/models/code_tests.rb | 3 + app/models/student_work_test.rb | 2 +- app/views/admin/code_work_tests.html.erb | 67 ++++---- app/views/courses/code_repeat.html.erb | 4 +- .../student_work/_student_work_list.html.erb | 155 +----------------- app/views/student_work/work_canrepeat.js.erb | 2 +- .../20160419061745_create_code_tests.rb | 13 ++ ...74016_add_student_work_id_to_code_tests.rb | 5 + db/schema.rb | 16 +- public/stylesheets/application.css | 27 +-- public/stylesheets/nyan.css | 25 +++ spec/factories/code_tests.rb | 10 ++ spec/models/code_tests_spec.rb | 5 + 15 files changed, 172 insertions(+), 225 deletions(-) create mode 100644 app/models/code_tests.rb create mode 100644 db/migrate/20160419061745_create_code_tests.rb create mode 100644 db/migrate/20160419074016_add_student_work_id_to_code_tests.rb create mode 100644 spec/factories/code_tests.rb create mode 100644 spec/models/code_tests_spec.rb diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index f663bc272..1a55c947b 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -586,11 +586,31 @@ class AdminController < ApplicationController #代码测试列表 def code_work_tests - @code_work_tests = StudentWorkTest.find_by_sql("select status,results,created_at, student_work_id from student_work_tests order by id desc ") - #@code_work_tests = StudentWorkTest.find_by_sql("select a.status,a.results,a.created_at ,b.id as homeworkid,d.language from student_work_tests as a , homework_commons as b ,student_works as c, homework_detail_programings as d where a.student_work_id = c.id and b.id = c.homework_common_id and c.homework_common_id = d.homework_common_id order by a.id desc ") - #@code_work_tests = StudentWorkTest.order('created_at desc') + #求出所有条数 + tCount = StudentWorkTest.find_by_sql("select count(*) from code_tests").first['count(*)'] + + #设置个空的数组 以便paginateHelper来分页 + @code_work_tests = [] + @code_work_tests[tCount-1] = {} + @code_work_tests = paginateHelper @code_work_tests,30 @page = (params['page'] || 1).to_i - 1 + + #取出需要的那一页数据 + tStart = @page*30 + @code_work_tests = CodeTests.find_by_sql("select * from code_tests order by id desc limit #{tStart},30 ") + + #取出各个作业是否是模拟答题的 + is_test = {} + @code_work_tests.each do |test| + if is_test[test['student_work_id']] != nil + test['is_test'] = is_test[test['student_work_id']] + else + test['is_test'] = CodeTests.find_by_sql("select is_test from student_works where id = #{test['student_work_id']}").first['is_test'] + is_test[test['student_work_id']] = test['is_test'] + end + end + respond_to do |format| format.html end diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 89ee77053..43fe10bfe 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -100,8 +100,17 @@ class StudentWorkController < ApplicationController test = @homework.homework_tests[index - 1] #请求测试 - result = test_realtime_ex(test, params[:src]) + begin + result = test_realtime_ex(test, params[:src]) + rescue Timeout::Error + tEndtime = Time.now + tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000 + logger.debug "program_test_ex user wait time = #{tUsedtime} 毫秒" + #status 0:答案正确 -3http超时 -2:编译错误 -1:答案错误 2:程序运行超时 + CodeTests.create(:homework_id=>@homework.id,:language=>@homework.homework_detail_programing.language,:status=>-3,:wait_time=>tUsedtime,:student_work_id=>student_work.id) + + end if result["status"].to_i != -2 #result["results"].first['output'] = result["results"].first['output'].gsub(" ","□") #result["results"].first['result'] = result["results"].first['result'].gsub(" ","□") @@ -116,11 +125,19 @@ class StudentWorkController < ApplicationController resultObj[:results] = result["results"].first #本次测试结果 resultObj[:error_msg] = result["error_msg"] #编译错误时的信息 + #该状态用于存入CodeTests + tmpstatus = -1 if result["status"].to_i == -2 #编译错误 resultObj[:results] = result["error_msg"] resultObj[:status] = -2 + tmpstatus = -2 elsif result["results"][0]["status"].to_i == 2 resultObj[:status] = 2 + tmpstatus = 2 + end + + if result["status"] == 0 + tmpstatus = 0 end unless student_work.save @@ -136,9 +153,6 @@ class StudentWorkController < ApplicationController end #每次从数据库取出上次的结果加上本次的结果再存入数据库 - tEndtime = Time.now - tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000 - if result["status"].to_i != -2 result["results"].first['user_wait'] = tUsedtime @@ -175,11 +189,19 @@ class StudentWorkController < ApplicationController resultObj[:index] = student_work.student_work_tests.count end + #将每次用户等待时间都存起来以便管理界面显示用 tEndtime = Time.now tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000 - logger.debug "program_test_ex user wait time = #{tUsedtime} 毫秒" + time_used = 0 + if result["status"].to_i != -2 + #至少一毫秒 + time_used = result["results"].first['time_used'] == 0 ? 1:result["results"].first['time_used'] + end + #0:答案正确 -3http超时 -2:编译错误 -1:答案错误 2:程序运行超时 + CodeTests.create(:homework_id=>@homework.id,:language=>@homework.homework_detail_programing.language,:status=>tmpstatus,:time_used=>time_used,:wait_time=>tUsedtime,:student_work_id=>student_work.id) + #渲染返回结果 render :json => resultObj end @@ -223,6 +245,7 @@ class StudentWorkController < ApplicationController JSON.parse(res.body) end + #点击代码查重按钮 def work_canrepeat @homework_id = params[:homework] @course_id = params[:course_id] @@ -280,13 +303,14 @@ class StudentWorkController < ApplicationController render :json => resultObj end + #上次代码查重时间 def last_codecomparetime resultObj = {status: 0} @homework = HomeworkCommon.find params[:homework] #转换一下 if @homework.simi_time != nil - resultObj[:comparetime] = Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H:%M") + resultObj[:comparetime] = Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H:%M:%S") else resultObj[:comparetime] = 0 end @@ -1277,7 +1301,6 @@ class StudentWorkController < ApplicationController request["Content-Type"] = "application/json" client.request(request) end - JSON.parse(res.body) end diff --git a/app/models/code_tests.rb b/app/models/code_tests.rb new file mode 100644 index 000000000..f5a358b07 --- /dev/null +++ b/app/models/code_tests.rb @@ -0,0 +1,3 @@ +class CodeTests < ActiveRecord::Base + attr_accessible :homework_id, :language, :status, :time_used, :wait_time, :student_work_id +end diff --git a/app/models/student_work_test.rb b/app/models/student_work_test.rb index 0246ecabf..54d5ab07a 100644 --- a/app/models/student_work_test.rb +++ b/app/models/student_work_test.rb @@ -1,6 +1,6 @@ # encoding: utf-8 class StudentWorkTest < ActiveRecord::Base - attr_accessible :student_work_id, :results, :status, :src + attr_accessible :student_work_id, :results, :status, :src, :uwait_time belongs_to :student_work serialize :results, Array diff --git a/app/views/admin/code_work_tests.html.erb b/app/views/admin/code_work_tests.html.erb index 29fb588c2..385f97169 100644 --- a/app/views/admin/code_work_tests.html.erb +++ b/app/views/admin/code_work_tests.html.erb @@ -10,51 +10,51 @@ - 作业id - - - 平均等待时间 + 作业id - 语言 + 作品id - - 提交测试时间 + + 用户等待时间 - 答题状态 + 语言 - - 测试集数 + + 测试完成时间 - - 最小耗时 + + 答题状态 - 最大耗时 + 耗时 <% @code_work_tests.each do |test| %> - <% infos = StudentWorkTest.find_by_sql("select a.homework_common_id as homeworkid,b.language from student_works as a, homework_detail_programings as b where a.id = #{test.student_work_id} and a.homework_common_id = b.homework_common_id - ").first %> - <% if infos != nil %> + <% if test['homework_id'] != nil %> "> - - <%=link_to(infos.homeworkid, student_work_index_path(:homework => infos.homeworkid))%> + '> + <%=link_to(test['homework_id'], student_work_index_path(:homework => test['homework_id']))%> + + '> + <% if test['is_test'] == 0 %> + <%=link_to(test['student_work_id'], student_work_index_path(:homework => test['homework_id'],:student_work_id=>test['student_work_id']))%> + <% else %> + <%=link_to(test['student_work_id'], new_user_commit_homework_users_path(homework_id: test['homework_id'], is_test: true))%> + <% end %> - <% if test.status != -2 && test.results.first['user_wait'] %> - <% wait_time = 0 %> - <% test.results.each do |result| wait_time = wait_time + result['user_wait'] end %> - <%=(wait_time/test.results.count).to_s+"毫秒" %> + <% if test.wait_time != 0 %> + <%=test.wait_time.to_s+"毫秒" %> <% else %> <%="未记录"%> <% end %> - <%=%W(C C++ Python Java).at(infos.language.to_i - 1)%> + <%=%W(C C++ Python Java).at(test['language'].to_i - 1)%> <%=Time.parse(test.created_at.to_s).strftime("%Y-%m-%d %H:%M:%S")%> @@ -64,26 +64,17 @@ <%= "答题正确" %> <% elsif test.status == -2 %> <%= "编译错误" %> - <% elsif test.status == 2 || test.results.last['status'] == 2 %> - <%= "超时" %> + <% elsif test.status == 2 %> + <%= "代码超时" %> + <% elsif test.status == -3 %> + <%= "请求超时" %> <% else %> <%= "答题错误" %> <% end %> - <% if test.status != -2 %> - <%=test.results.count%> - <% end %> - - - <% if test.status != -2 %> - <%test.results = test.results.sort_by {|result| result['time_used'] }%> - <%=test.results.first['time_used'] == 0 ? "1毫秒":test.results.first['time_used'].to_s+"毫秒"%> - <% end %> - - - <% if test.status != -2 %> - <%=test.results.last['time_used'] == 0 ? "1毫秒":test.results.last['time_used'].to_s+"毫秒"%> + <% if test.time_used > 0 %> + <%=test.time_used.to_s+"毫秒"%> <% end %> diff --git a/app/views/courses/code_repeat.html.erb b/app/views/courses/code_repeat.html.erb index 0748dc30f..87cf539fa 100644 --- a/app/views/courses/code_repeat.html.erb +++ b/app/views/courses/code_repeat.html.erb @@ -2,8 +2,8 @@

查重结果

    -
  • 被查作品
  • -
  • 疑被抄袭作品
  • +
  • 被查作品
  • +
  • 疑被抄袭作品
    diff --git a/app/views/student_work/_student_work_list.html.erb b/app/views/student_work/_student_work_list.html.erb index ac06d900e..e0b6def7a 100644 --- a/app/views/student_work/_student_work_list.html.erb +++ b/app/views/student_work/_student_work_list.html.erb @@ -14,14 +14,14 @@ <% end %> <%if @is_teacher || @homework.homework_detail_manual.comment_status == 3 || @homework.is_open == 1%> -
    +
    + <%= select_tag(:student_work_in_group,options_for_select(course_group_list(@course),@group), {:class => "classSplit fl mr20"}) unless course_group_list(@course).empty? %> <%if @homework.homework_type == 2 && @is_teacher %> - <%= link_to "代码查重", work_canrepeat_student_work_index_path(homework:@homework.id, course_id:@course.id), class: 'BlueCirBtn fr',:remote => true %> + <%= link_to "代码查重", work_canrepeat_student_work_index_path(homework:@homework.id, course_id:@course.id), class: 'BlueCirBtn fl',:remote => true %> <% end %> - <%= select_tag(:student_work_in_group,options_for_select(course_group_list(@course),@group), {:class => "classSplit"}) unless course_group_list(@course).empty? %> <% end%>
    @@ -50,8 +50,12 @@ \ No newline at end of file diff --git a/app/views/student_work/work_canrepeat.js.erb b/app/views/student_work/work_canrepeat.js.erb index 353a150cf..29fd61c97 100644 --- a/app/views/student_work/work_canrepeat.js.erb +++ b/app/views/student_work/work_canrepeat.js.erb @@ -81,7 +81,7 @@ test_repeat(); <% else%> $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_1',:locals => {:homework=> @homework,:courseid=>@course_id })%>'); - $('#compare-tips-1').html('您上次查重的时间为<%= Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H-%M-%S")%>'); + $('#compare-tips-1').html('您上次查重的时间为<%= Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H:%M:%S")%>'); showModal('ajax-modal', '580px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before(""); diff --git a/db/migrate/20160419061745_create_code_tests.rb b/db/migrate/20160419061745_create_code_tests.rb new file mode 100644 index 000000000..565378ccd --- /dev/null +++ b/db/migrate/20160419061745_create_code_tests.rb @@ -0,0 +1,13 @@ +class CreateCodeTests < ActiveRecord::Migration + def change + create_table :code_tests do |t| + t.integer :homework_id + t.integer :wait_time, default: 0 + t.integer :language + t.integer :status + t.integer :time_used, default: 0 + + t.timestamps + end + end +end diff --git a/db/migrate/20160419074016_add_student_work_id_to_code_tests.rb b/db/migrate/20160419074016_add_student_work_id_to_code_tests.rb new file mode 100644 index 000000000..d2fc6b1f4 --- /dev/null +++ b/db/migrate/20160419074016_add_student_work_id_to_code_tests.rb @@ -0,0 +1,5 @@ +class AddStudentWorkIdToCodeTests < ActiveRecord::Migration + def change + add_column :code_tests, :student_work_id, :integer,:default=>0 + end +end diff --git a/db/schema.rb b/db/schema.rb index 7c1efce6d..2fecd9f48 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 => 20160330103916) do +ActiveRecord::Schema.define(:version => 20160419074016) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -334,6 +334,17 @@ ActiveRecord::Schema.define(:version => 20160330103916) do t.boolean "diff_all" end + create_table "code_tests", :force => true do |t| + t.integer "homework_id" + t.integer "wait_time", :default => 0 + t.integer "language" + t.integer "status" + t.integer "time_used", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "student_work_id", :default => 0 + end + create_table "comments", :force => true do |t| t.string "commented_type", :limit => 30, :default => "", :null => false t.integer "commented_id", :default => 0, :null => false @@ -1290,6 +1301,7 @@ ActiveRecord::Schema.define(:version => 20160330103916) do t.datetime "updated_at", :null => false t.string "field_type" t.integer "hide", :default => 0 + t.integer "status", :default => 1 end create_table "organizations", :force => true do |t| @@ -1302,6 +1314,7 @@ ActiveRecord::Schema.define(:version => 20160330103916) do t.datetime "updated_at", :null => false t.boolean "allow_guest_download", :default => true t.integer "visits", :default => 0 + t.integer "show_mode", :default => 0 end create_table "phone_app_versions", :force => true do |t| @@ -1666,6 +1679,7 @@ ActiveRecord::Schema.define(:version => 20160330103916) do t.integer "status", :default => 9 t.text "results" t.text "src" + t.integer "uwait_time", :default => 0 end create_table "student_works", :force => true do |t| diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 5162bcb16..3764ceb04 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -2847,29 +2847,4 @@ img.school_avatar { } .admin_message_warn{font-size: 12px;color: red;} -a.btn_message_free{ background:#15BCCF; display:block; text-align:center; color:#fff; padding:3px 0; width:60px; margin-bottom:10px;margin-left: 58px;} - -/*20160401袁可------------------ 查重结果样式*/ -.conbox{ width:1000px; margin:0 auto; border:3px solid #f0f0f0; background:#fff;} -.conbox-h2{ font-size:16px; padding:10px 0; padding-left:25px;} -.chabox{ width:1000px;} -.chabox ul li{ float:left; width:82px; text-align:center; display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} -.chabox ul li.chabox-w-401{ width:151px; display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} -.chabox ul li.chabox-r-line{ border-right:1px solid #D1D1D1;} -.chabox-top{ width:1000px; } -.chabox-top li{ font-size:14px; font-weight:bold; line-height:40px; height:40px; background:#E4E4E4; color:#000;} -.chabox-con li{font-size:12px; line-height:35px; height:35px; color:#888; border-bottom:1px solid #DFDFDF;} -a.cha-btn{ display:block; width:50px; height:20px; line-height:20px; margin:0 auto; border:1px solid #269ac9; color:#269ac9;-webkit-border-radius: 3px;border-radius:3px; margin-top:8px;} -a:hover.cha-btn{ background:#269ac9; color:#fff;} -.chabox-header li{ font-size:14px; font-weight:bold; line-height:40px; height:40px; border-top:1px solid #E4E4E4; border-right:1px solid #E4E4E4; color:#000;} -.chabox ul li.chabox-w-500{ width:499px;} -.chabox ul li.chabox-w-40{ width:39px; border-right:1px solid #D1D1D1;} -.chabox ul li.chabox-txt-left{ text-align:left;text-indent:1em; } - -.contrast-box{ width:1200px;box-shadow: 0 0 5px #6B6B6B; background:#fff; margin:0 auto; } -.contrast-con{ width:599px; border-right:1px solid #D1D1D1; float:left;} -.contrast-con h3{font-size:14px; font-weight:bold; line-height:40px; height:40px; background:#E4E4E4; color:#000; text-align:center; display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} -.contrast-txt{ padding:10px;} -.showCodeC{ width:580px; float:left;} - -.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000;} \ No newline at end of file +a.btn_message_free{ background:#15BCCF; display:block; text-align:center; color:#fff; padding:3px 0; width:60px; margin-bottom:10px;margin-left: 58px;} \ No newline at end of file diff --git a/public/stylesheets/nyan.css b/public/stylesheets/nyan.css index dc380f6ef..e9fd46adf 100644 --- a/public/stylesheets/nyan.css +++ b/public/stylesheets/nyan.css @@ -1452,3 +1452,28 @@ ul.contest-notification-list li span{ color: #136b3b !important; font-weight:normal !important; } + +/*20160401袁可------------------ 查重结果样式*/ +.conbox{ width:1000px; margin:0 auto; border:3px solid #f0f0f0; background:#fff;} +.conbox-h2{ font-size:16px; padding:10px 0; padding-left:25px;} +.chabox{ width:1000px;} +.chabox ul li{ float:left; width:82px; text-align:center; display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} +.chabox ul li.chabox-w-401{ width:151px; display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} +.chabox ul li.chabox-r-line{ border-right:1px solid #D1D1D1;} +.chabox-top{ width:1000px; } +.chabox-top li{ font-size:14px; font-weight:bold; line-height:40px; height:40px; background:#E4E4E4; color:#000;} +.chabox-con li{font-size:12px; line-height:35px; height:35px; color:#888; border-bottom:1px solid #DFDFDF;} +a.cha-btn{ display:block; width:50px; height:20px; line-height:20px; margin:0 auto; border:1px solid #269ac9; color:#269ac9;-webkit-border-radius: 3px;border-radius:3px; margin-top:8px;} +a:hover.cha-btn{ background:#269ac9; color:#fff;} +.chabox-header li{ font-size:14px; font-weight:bold; line-height:40px; height:40px; border-top:1px solid #E4E4E4; border-right:1px solid #E4E4E4; color:#000;} +.chabox ul li.chabox-w-500{ width:499px;} +.chabox ul li.chabox-w-40{ width:39px; border-right:1px solid #D1D1D1;} +.chabox ul li.chabox-txt-left{ text-align:left;text-indent:1em; } + +.contrast-box{ width:1200px;box-shadow: 0 0 5px #6B6B6B; background:#fff; margin:0 auto; } +.contrast-con{ width:599px; border-right:1px solid #D1D1D1; float:left;} +.contrast-con h3{font-size:14px; font-weight:bold; line-height:40px; height:40px; background:#E4E4E4; color:#000; text-align:center; display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} +.contrast-txt{ padding:10px;} +.showCodeC{ width:580px; float:left;} + +.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000;} diff --git a/spec/factories/code_tests.rb b/spec/factories/code_tests.rb new file mode 100644 index 000000000..b8eed45fb --- /dev/null +++ b/spec/factories/code_tests.rb @@ -0,0 +1,10 @@ +FactoryGirl.define do + factory :code_test, :class => 'CodeTests' do + homework_id 1 +wait_time 1 +language 1 +status 1 +time_used "MyString" + end + +end diff --git a/spec/models/code_tests_spec.rb b/spec/models/code_tests_spec.rb new file mode 100644 index 000000000..4e0d71cf3 --- /dev/null +++ b/spec/models/code_tests_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe CodeTests, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 6957c24da555c4d160b3590c11c73234aa9ff1d5 Mon Sep 17 00:00:00 2001 From: txz Date: Wed, 20 Apr 2016 10:08:03 +0800 Subject: [PATCH 07/18] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E9=A1=B5=E9=9D=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 2 +- public/javascripts/wechat/app.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index dfd60e68a..3cea45bcd 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -143,7 +143,7 @@
    - +
    diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index e9f45f3a9..9f0987552 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,6 +1,6 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = '/api/v1/'; -var debug = false; //调试标志,如果在本地请置为true +var debug = true; //调试标志,如果在本地请置为true if(debug===true){ apiUrl = 'http://localhost:3000/api/v1/'; From c6174406fb0294c2371dc095cc34490a131210cb Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Wed, 20 Apr 2016 10:39:07 +0800 Subject: [PATCH 08/18] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E8=AF=AD?= =?UTF-8?q?=E5=8F=A5=E4=BD=BF=E7=94=A8rails=E5=B7=B2=E6=9C=89=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 5 +++-- app/views/admin/code_work_tests.html.erb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 7d1ff6426..e581216fe 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -596,7 +596,7 @@ class AdminController < ApplicationController #代码测试列表 def code_work_tests #求出所有条数 - tCount = StudentWorkTest.find_by_sql("select count(*) from code_tests").first['count(*)'] + tCount = CodeTests.count() #设置个空的数组 以便paginateHelper来分页 @code_work_tests = [] @@ -615,7 +615,8 @@ class AdminController < ApplicationController if is_test[test['student_work_id']] != nil test['is_test'] = is_test[test['student_work_id']] else - test['is_test'] = CodeTests.find_by_sql("select is_test from student_works where id = #{test['student_work_id']}").first['is_test'] + test['is_test'] = StudentWork.find(test['student_work_id']).is_test + #test['is_test'] = CodeTests.find_by_sql("select is_test from student_works where id = #{test['student_work_id']}").first['is_test'] is_test[test['student_work_id']] = test['is_test'] end end diff --git a/app/views/admin/code_work_tests.html.erb b/app/views/admin/code_work_tests.html.erb index 385f97169..cb113f1e6 100644 --- a/app/views/admin/code_work_tests.html.erb +++ b/app/views/admin/code_work_tests.html.erb @@ -40,7 +40,7 @@ <%=link_to(test['homework_id'], student_work_index_path(:homework => test['homework_id']))%> '> - <% if test['is_test'] == 0 %> + <% if !test['is_test'] %> <%=link_to(test['student_work_id'], student_work_index_path(:homework => test['homework_id'],:student_work_id=>test['student_work_id']))%> <% else %> <%=link_to(test['student_work_id'], new_user_commit_homework_users_path(homework_id: test['homework_id'], is_test: true))%> From ef987d6bf7aaaca4854ddb5364536e51c904a4c9 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 20 Apr 2016 10:44:54 +0800 Subject: [PATCH 09/18] =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E4=B8=AD=E6=9C=89html=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1234567 | 2 +- app/helpers/application_helper.rb | 15 +++++++++++++++ app/models/blog_comment.rb | 6 ++++-- app/models/comment.rb | 6 ++++-- app/models/issue.rb | 3 ++- app/models/journal.rb | 3 ++- app/models/journals_for_message.rb | 10 +++++++--- app/models/message.rb | 12 ++++++++---- app/models/news.rb | 3 ++- 9 files changed, 45 insertions(+), 15 deletions(-) diff --git a/1234567 b/1234567 index 459204fe5..b584c6f69 100644 --- a/1234567 +++ b/1234567 @@ -1 +1 @@ -{"access_token":"q51KZUeA6_-CCCH-Buy1mxFmRjcrCViHgk2mHHHqEDbjuA_pgCM1IyW1DASYvpzyB06xHiarujo3rz1Ucq3GRoXdgQ7hAoFCzkL_q3Z5vczLjwAjowAVwmulYE-cAij8ATUfADAWPQ","expires_in":7200,"got_token_at":1460601163} \ No newline at end of file +{"access_token":"GbIQJdIaX2c0IyQSOJcNNT2TxUH5aSQCNL7N92BV9oggGePRoj886HDohtqRokwPS6OVcIYF8WZTnSn717CP-czrWupY_gIHehK4UqjqXYqGkVqODXaXEB_LV0grMIwEXQDhAAAFYL","expires_in":7200,"got_token_at":1461117548} \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 366cea06b..f0f959830 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3068,3 +3068,18 @@ def host_with_protocol return Setting.protocol + "://" + Setting.host_name end +def strip_html(text,len=0,endss="...") + ss = "" + if text.length>0 + ss=text.gsub(/<\/?.*?>/, '').strip + + if len > 0 && ss.length > len + ss = ss[0, len] + endss + elsif len > 0 && ss.length <= len + ss = ss + #ss = truncate(ss, :length => len) + end + end + return ss +end + diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index 62451591f..a328791bf 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -81,10 +81,12 @@ class BlogComment < ActiveRecord::Base ws = WechatService.new if self.parent_id.nil? self.author.watcher_users.each do |watcher| - ws.message_update_template watcher.id, "#{l(:label_new_blog_template)}", self.author.try(:realname) + " 发表了博客:" + self.title.html_safe, format_time(self.created_at) + content = strip_html self.author.try(:realname) + " 发表了博客:" + self.title.html_safe, 200 + ws.message_update_template watcher.id, "#{l(:label_new_blog_template)}", content, format_time(self.created_at) end else - ws.comment_template self.parent.author_id, "#{l(:label_blog_comment_template)}", self.author.try(:realname), format_time(self.created_at), self.content.html_safe + content = strip_html self.content.html_safe, 200 + ws.comment_template self.parent.author_id, "#{l(:label_blog_comment_template)}", self.author.try(:realname), format_time(self.created_at), content end end end diff --git a/app/models/comment.rb b/app/models/comment.rb index 9a752129b..f613a6d46 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -45,12 +45,14 @@ class Comment < ActiveRecord::Base if self.commented.course if self.author_id != self.commented.author_id self.course_messages << CourseMessage.new(:user_id => self.commented.author_id, :course_id => self.commented.course.id, :viewed => false) - ws.comment_template self.commented.author_id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.comments.html_safe + content = strip_html self.comments.html_safe, 200 + ws.comment_template self.commented.author_id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end else # 项目相关 if self.author_id != self.commented.author_id self.forge_messages << ForgeMessage.new(:user_id => self.commented.author_id, :project_id => self.commented.project.id, :viewed => false) - ws.comment_template self.commented.author_id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.comments.html_safe + content = strip_html self.comments.html_safe, 200 + ws.comment_template self.commented.author_id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 5124dd54b..7681ce45d 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -160,7 +160,8 @@ class Issue < ActiveRecord::Base unless self.author_id == self.assigned_to_id self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, :project_id => self.project_id, :viewed => false) ws = WechatService.new - ws.message_update_template self.assigned_to_id, "#{l(:label_new_issue_template)}", self.author.try(:realname) + " 给您指派了缺陷:" + self.subject.html_safe, format_time(self.created_on) + content = strip_html self.author.try(:realname) + " 给您指派了缺陷:" + self.subject.html_safe, 200 + ws.message_update_template self.assigned_to_id, "#{l(:label_new_issue_template)}", content, format_time(self.created_on) end if self.tracker_id == 5 self.project.members.each do |m| diff --git a/app/models/journal.rb b/app/models/journal.rb index 80d585b06..60bb16b11 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -240,6 +240,7 @@ class Journal < ActiveRecord::Base #缺陷回复微信模板消息 def issue_wechat_message ws = WechatService.new - ws.comment_template self.issue.author_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), self.notes.html_safe + content = strip_html self.notes.html_safe, 200 + ws.comment_template self.issue.author_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), content end end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 799af8f74..58aa8620b 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -257,7 +257,9 @@ class JournalsForMessage < ActiveRecord::Base end if self.jour_type == 'HomeworkCommon' ws = WechatService.new - ws.comment_template self.jour.user_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), self.notes.html_safe + #content = truncate(strip_tags(self.notes.to_s), length: 200) + content = strip_html self.notes.html_safe, 200 + ws.comment_template self.jour.user_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), content end end @@ -271,7 +273,8 @@ class JournalsForMessage < ActiveRecord::Base if self.reply_id == 0 if self.user_id != self.jour_id # 过滤自己给自己的留言消息 receivers << self.jour - ws.message_update_template self.jour_id, "#{l(:label_new_journals_template)}", self.notes.html_safe, format_time(self.created_on) + content = strip_html self.notes, 200 + ws.message_update_template self.jour_id, "#{l(:label_new_journals_template)}", content, format_time(self.created_on) end else # 留言回复 reply_to = User.find(self.reply_id) @@ -281,7 +284,8 @@ class JournalsForMessage < ActiveRecord::Base if self.user_id != self.parent.jour_id && self.reply_id != self.parent.jour_id # 给东家发信息,如果回复的对象是东家则不发 receivers << self.parent.jour end - ws.comment_template self.reply_id, "#{l(:label_journals_comment_template)}", self.user.try(:realname), format_time(self.created_on), self.notes.html_safe + content = strip_html self.notes, 200 + ws.comment_template self.reply_id, "#{l(:label_journals_comment_template)}", self.user.try(:realname), format_time(self.created_on), content end receivers.each do |r| self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false) diff --git a/app/models/message.rb b/app/models/message.rb index 2f4637042..d606962e1 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -266,14 +266,16 @@ class Message < ActiveRecord::Base self.course.members.each do |m| if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息 self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) - ws.topic_publish_template m.user_id, "#{l(:label_course_topic_template)}", self.subject, self.author.try(:realname), format_time(self.created_on) + content = strip_html self.subject, 200 + ws.topic_publish_template m.user_id, "#{l(:label_course_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) end end else # 回帖 self.course.members.each do |m| if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) - ws.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.content.html_safe + content = strip_html self.content.html_safe, 200 + ws.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end end end @@ -282,14 +284,16 @@ class Message < ActiveRecord::Base self.project.members.each do |m| if m.user_id != self.author_id self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) - ws.topic_publish_template m.user_id, "#{l(:label_project_topic_template)}", self.subject, self.author.try(:realname), format_time(self.created_on) + content = strip_html self.subject, 200 + ws.topic_publish_template m.user_id, "#{l(:label_project_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) end end else # 回帖 self.project.members.each do |m| if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) - ws.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.content.html_safe + content = strip_html self.content.html_safe, 200 + ws.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end end end diff --git a/app/models/news.rb b/app/models/news.rb index 25a70095f..b7a8baaf5 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -171,7 +171,8 @@ class News < ActiveRecord::Base if m.user_id != self.author_id self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) ws = WechatService.new - ws.message_update_template m.user_id, "#{l(:label_new_notice_template)}", self.author.try(:realname) + " 发布了通知:" + self.title.html_safe, format_time(self.created_on) + content = strip_html self.author.try(:realname) + " 发布了通知:" + self.title.html_safe, 200 + ws.message_update_template m.user_id, "#{l(:label_new_notice_template)}", self.author.try(:realname) + " 发布了通知:" + content, format_time(self.created_on) end end else From aed38182738ac586a31eb34611dc6dbc2eb54d9a Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 20 Apr 2016 14:44:10 +0800 Subject: [PATCH 10/18] =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E8=B7=B3=E5=88=B0=E5=BE=AE=E4=BF=A1=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1234567 | 2 +- app/models/blog_comment.rb | 4 ++-- app/models/comment.rb | 6 +++--- app/models/homework_common.rb | 4 ++-- app/models/issue.rb | 2 +- app/models/journal.rb | 2 +- app/models/journals_for_message.rb | 6 +++--- app/models/message.rb | 8 ++++---- app/models/news.rb | 2 +- app/services/wechat_service.rb | 25 ++++++++++++++----------- config/locales/zh.yml | 8 +------- 11 files changed, 33 insertions(+), 36 deletions(-) diff --git a/1234567 b/1234567 index b584c6f69..327c92785 100644 --- a/1234567 +++ b/1234567 @@ -1 +1 @@ -{"access_token":"GbIQJdIaX2c0IyQSOJcNNT2TxUH5aSQCNL7N92BV9oggGePRoj886HDohtqRokwPS6OVcIYF8WZTnSn717CP-czrWupY_gIHehK4UqjqXYqGkVqODXaXEB_LV0grMIwEXQDhAAAFYL","expires_in":7200,"got_token_at":1461117548} \ No newline at end of file +{"access_token":"x7GUTe-MLoVPMzId82-3VSdCsO6sq5cOJZCmIN-yUjDcohfI00t2lzPkNKdRhETLUBptZRQ--v-IBQTG-o5iRZZv-EelOBX7K96DcPMFt9rdzwNu7XerNnZw_ncGYncSLHXeACAQMC","expires_in":7200,"got_token_at":1461133885} \ No newline at end of file diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index a328791bf..af21b4f69 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -82,11 +82,11 @@ class BlogComment < ActiveRecord::Base if self.parent_id.nil? self.author.watcher_users.each do |watcher| content = strip_html self.author.try(:realname) + " 发表了博客:" + self.title.html_safe, 200 - ws.message_update_template watcher.id, "#{l(:label_new_blog_template)}", content, format_time(self.created_at) + ws.message_update_template watcher.id, "blog_comment", self.id, "#{l(:label_new_blog_template)}", content, format_time(self.created_at) end else content = strip_html self.content.html_safe, 200 - ws.comment_template self.parent.author_id, "#{l(:label_blog_comment_template)}", self.author.try(:realname), format_time(self.created_at), content + ws.comment_template self.parent.author_id, "blog_comment", self.parent_id, "#{l(:label_blog_comment_template)}", self.author.try(:realname), format_time(self.created_at), content end end end diff --git a/app/models/comment.rb b/app/models/comment.rb index f613a6d46..6b1732eab 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -46,13 +46,13 @@ class Comment < ActiveRecord::Base if self.author_id != self.commented.author_id self.course_messages << CourseMessage.new(:user_id => self.commented.author_id, :course_id => self.commented.course.id, :viewed => false) content = strip_html self.comments.html_safe, 200 - ws.comment_template self.commented.author_id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content + ws.comment_template self.commented.author_id, "course_notice", self.id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end else # 项目相关 if self.author_id != self.commented.author_id self.forge_messages << ForgeMessage.new(:user_id => self.commented.author_id, :project_id => self.commented.project.id, :viewed => false) - content = strip_html self.comments.html_safe, 200 - ws.comment_template self.commented.author_id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), content + #content = strip_html self.comments.html_safe, 200 + #ws.comment_template self.commented.author_id, "blog_comment", self.id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end end end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 54f13e57e..a2216bdf9 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -60,7 +60,7 @@ class HomeworkCommon < ActiveRecord::Base # if m.user_id != self.user_id self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) ws = WechatService.new - ws.homework_template(m.user_id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") + ws.homework_template(m.user_id, "homework", self.id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") # end end end @@ -107,7 +107,7 @@ class HomeworkCommon < ActiveRecord::Base def wechat_message self.course.members.each do |member| ws = WechatService.new - ws.homework_template(member.user_id, "#{l(:label_update_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") + ws.homework_template(member.user_id, "homework", self.id, "#{l(:label_update_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 7681ce45d..fd378bc05 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -161,7 +161,7 @@ class Issue < ActiveRecord::Base self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, :project_id => self.project_id, :viewed => false) ws = WechatService.new content = strip_html self.author.try(:realname) + " 给您指派了缺陷:" + self.subject.html_safe, 200 - ws.message_update_template self.assigned_to_id, "#{l(:label_new_issue_template)}", content, format_time(self.created_on) + ws.message_update_template self.assigned_to_id, "issues", self.id, "#{l(:label_new_issue_template)}", content, format_time(self.created_on) end if self.tracker_id == 5 self.project.members.each do |m| diff --git a/app/models/journal.rb b/app/models/journal.rb index 60bb16b11..02086fa62 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -241,6 +241,6 @@ class Journal < ActiveRecord::Base def issue_wechat_message ws = WechatService.new content = strip_html self.notes.html_safe, 200 - ws.comment_template self.issue.author_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), content + ws.comment_template self.issue.author_id, "issues", self.journalized_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), content end end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 58aa8620b..1f8b0253f 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -259,7 +259,7 @@ class JournalsForMessage < ActiveRecord::Base ws = WechatService.new #content = truncate(strip_tags(self.notes.to_s), length: 200) content = strip_html self.notes.html_safe, 200 - ws.comment_template self.jour.user_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), content + ws.comment_template self.jour.user_id, "homework", self.jour_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), content end end @@ -274,7 +274,7 @@ class JournalsForMessage < ActiveRecord::Base if self.user_id != self.jour_id # 过滤自己给自己的留言消息 receivers << self.jour content = strip_html self.notes, 200 - ws.message_update_template self.jour_id, "#{l(:label_new_journals_template)}", content, format_time(self.created_on) + ws.message_update_template self.jour_id, "journal_for_message", self.id, "#{l(:label_new_journals_template)}", content, format_time(self.created_on) end else # 留言回复 reply_to = User.find(self.reply_id) @@ -285,7 +285,7 @@ class JournalsForMessage < ActiveRecord::Base receivers << self.parent.jour end content = strip_html self.notes, 200 - ws.comment_template self.reply_id, "#{l(:label_journals_comment_template)}", self.user.try(:realname), format_time(self.created_on), content + ws.comment_template self.reply_id, "journal_for_message", self.parent.id, "#{l(:label_journals_comment_template)}", self.user.try(:realname), format_time(self.created_on), content end receivers.each do |r| self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false) diff --git a/app/models/message.rb b/app/models/message.rb index d606962e1..5dc5dcc2e 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -267,7 +267,7 @@ class Message < ActiveRecord::Base if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息 self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) content = strip_html self.subject, 200 - ws.topic_publish_template m.user_id, "#{l(:label_course_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) + ws.topic_publish_template m.user_id, "course_discussion", self.id, "#{l(:label_course_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) end end else # 回帖 @@ -275,7 +275,7 @@ class Message < ActiveRecord::Base if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) content = strip_html self.content.html_safe, 200 - ws.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content + ws.comment_template m.user_id, "course_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end end end @@ -285,7 +285,7 @@ class Message < ActiveRecord::Base if m.user_id != self.author_id self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) content = strip_html self.subject, 200 - ws.topic_publish_template m.user_id, "#{l(:label_project_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) + ws.topic_publish_template m.user_id, "project_discussion", self.id, "#{l(:label_project_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) end end else # 回帖 @@ -293,7 +293,7 @@ class Message < ActiveRecord::Base if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) content = strip_html self.content.html_safe, 200 - ws.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content + ws.comment_template m.user_id, "project_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end end end diff --git a/app/models/news.rb b/app/models/news.rb index b7a8baaf5..45e5bc424 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -172,7 +172,7 @@ class News < ActiveRecord::Base self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) ws = WechatService.new content = strip_html self.author.try(:realname) + " 发布了通知:" + self.title.html_safe, 200 - ws.message_update_template m.user_id, "#{l(:label_new_notice_template)}", self.author.try(:realname) + " 发布了通知:" + content, format_time(self.created_on) + ws.message_update_template m.user_id, "course_notice", self.id, "#{l(:label_new_notice_template)}", self.author.try(:realname) + " 发布了通知:" + content, format_time(self.created_on) end end else diff --git a/app/services/wechat_service.rb b/app/services/wechat_service.rb index ae097ad4a..2fb222d4f 100644 --- a/app/services/wechat_service.rb +++ b/app/services/wechat_service.rb @@ -1,11 +1,11 @@ #encoding: utf-8 class WechatService - def template_data(openid, template_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") + def template_data(openid, template_id, type, id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") data = { touser:openid, template_id:template_id, - url:"https://www.trustie.net/", + url:"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect", topcolor:"#FF0000", data:{ first: { @@ -33,10 +33,10 @@ class WechatService data end - def homework_template(user_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") + def homework_template(user_id, type, id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") uw = UserWechat.where(user_id: user_id).first unless uw.nil? - data = template_data uw.openid,"3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI",first, key1, key2, key3, remark + data = template_data uw.openid,"3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI", type, id, first, key1, key2, key3, remark begin req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) rescue Exception => e @@ -44,12 +44,13 @@ class WechatService end Rails.logger.info "send over. #{req}" end + Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect" end - def topic_publish_template(user_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") + def topic_publish_template(user_id, type, id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") uw = UserWechat.where(user_id: user_id).first unless uw.nil? - data = template_data uw.openid,"oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ",first, key1, key2, key3, remark + data = template_data uw.openid,"oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", type, id,first, key1, key2, key3, remark Rails.logger.info "start send template message: #{data}" begin req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) @@ -58,12 +59,13 @@ class WechatService end Rails.logger.info "send over. #{req}" end + Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect" end - def comment_template(user_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") + def comment_template(user_id,type, id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") uw = UserWechat.where(user_id: user_id).first unless uw.nil? - data = template_data uw.openid,"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c",first, key1, key2, key3, remark + data = template_data uw.openid,"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c",type, id,first, key1, key2, key3, remark Rails.logger.info "start send template message: #{data}" begin req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) @@ -72,15 +74,16 @@ class WechatService end Rails.logger.info "send over. #{req}" end + Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect" end - def message_update_template(user_id, first, key1, key2, remark="具体内容请点击详情查看网站") + def message_update_template(user_id, type, id, first, key1, key2, remark="具体内容请点击详情查看网站") uw = UserWechat.where(user_id: user_id).first unless uw.nil? data = { touser:uw.openid, template_id:"YTyNPZnQD8uZFBFq-Q6cCOWaq5LA9vL6RFlF2JuD5Cg", - url:"https://www.trustie.net/", + url:"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect", topcolor:"#FF0000", data:{ first: { @@ -101,7 +104,6 @@ class WechatService } } } - Rails.logger.info "start send template message: #{data}" begin req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) @@ -110,5 +112,6 @@ class WechatService end Rails.logger.info "send over. #{req}" end + Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect" end end \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 65d405733..7160e9d27 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2138,15 +2138,9 @@ zh: label_new_journals_template: 您有新留言了 label_journals_comment_template: 您的留言有新回复了 label_blog_comment_template: 您的博客有新回复了 - label_new_blog_template: 您的课程有新作业了 + label_new_blog_template: 有新博客了 label_new_issue_template: 您有新缺陷了 label_new_notice_template: 您的课程有新通知了 - label_resource_name: 您的课程有新作业了 - label_resource_name: 您的课程有新作业了 - label_resource_name: 您的课程有新作业了 - label_resource_name: 您的课程有新作业了 - label_resource_name: 您的课程有新作业了 - label_resource_name: 您的课程有新作业了 #edit yk label_code_work_tests: 代码测试列表 From 0b82bf50c2014fcd2cd26d6bd945425c5be3826f Mon Sep 17 00:00:00 2001 From: txz Date: Wed, 20 Apr 2016 15:45:33 +0800 Subject: [PATCH 11/18] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E4=B8=AD=E5=9B=BE=E7=89=87=E6=AD=A3=E5=B8=B8=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 2 +- public/javascripts/wechat/app.js | 3 +-- public/stylesheets/weui/weixin.css | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 3cea45bcd..f87af796f 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -215,7 +215,7 @@
    -
    +
    点击展开 diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 9f0987552..834ccf9d6 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,6 +1,6 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = '/api/v1/'; -var debug = true; //调试标志,如果在本地请置为true +var debug = false; //调试标志,如果在本地请置为true if(debug===true){ apiUrl = 'http://localhost:3000/api/v1/'; @@ -394,7 +394,6 @@ app.directive('textAutoHeight', function($timeout){ }); } }, false); - } } }); diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index ead53557b..19206d916 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -50,6 +50,7 @@ a.underline {text-decoration:underline;} .fr {float:right;} .cl {clear:both; overflow:hidden;} .post-content {width:100%; font-size:13px; line-height:18px; height:90px; overflow:hidden; word-break:break-all; word-wrap:break-word;} +.post-content img {max-width:100%;} .post-interactive {width:100%; height:35px; line-height:35px; vertical-align:middle; border-top:1px solid #e6e6e6; background-color:#f8f9fb;} .post-interactive-column, .post-interactive-reply, @@ -62,6 +63,7 @@ a.underline {text-decoration:underline;} .post-reply-avatar {width:45px; height:30px; text-align:center; margin-right:10px;} .post-reply-user {font-size:13px; text-align:left; margin-bottom:10px;} .post-reply-content {font-size:13px; text-align:left; word-break:break-all; word-wrap:break-word; overflow:hidden;} +.post-reply-content img {max-width:100%;} .post-reply-date, .post-reply-trigger {font-size:13px;} .post-input-container {padding-right:2px;} .post-reply-input {width:100%; height:28px; line-height:28px; border:1px solid #e6e6e6; outline:none; padding:0; margin:0; border-radius:3px;} From ff177557c802c48f33192051d4c73280a2db8f5c Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Wed, 20 Apr 2016 16:13:06 +0800 Subject: [PATCH 12/18] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=88=97=E8=A1=A8=E6=8A=A5500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index e581216fe..e6e0ec087 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -600,8 +600,9 @@ class AdminController < ApplicationController #设置个空的数组 以便paginateHelper来分页 @code_work_tests = [] - @code_work_tests[tCount-1] = {} - + if tCount >= 1 + @code_work_tests[tCount-1] = {} + end @code_work_tests = paginateHelper @code_work_tests,30 @page = (params['page'] || 1).to_i - 1 From 6e6a29cfa6c95897f9c391b64c149648c1967df9 Mon Sep 17 00:00:00 2001 From: txz Date: Wed, 20 Apr 2016 17:04:59 +0800 Subject: [PATCH 13/18] =?UTF-8?q?api=E8=B7=AF=E5=BE=84=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/app.html | 51 ++++++++++++++++++++++++++++++++ public/javascripts/wechat/app.js | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/public/app.html b/public/app.html index 5ebcdc286..90dc64956 100644 --- a/public/app.html +++ b/public/app.html @@ -14,6 +14,57 @@ +
    diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 834ccf9d6..97589721e 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -3,7 +3,7 @@ var apiUrl = '/api/v1/'; var debug = false; //调试标志,如果在本地请置为true if(debug===true){ - apiUrl = 'http://localhost:3000/api/v1/'; + apiUrl = 'https://www.trustie.net/api/v1/'; } app.factory('auth', function($http,$routeParams, $cookies, $q){ From 26b1aee90db08df53d4551f71c6396188a54bc1c Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 21 Apr 2016 10:01:12 +0800 Subject: [PATCH 14/18] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=A8=E6=B5=B7?= =?UTF-8?q?=E8=8A=B3=E8=80=81=E5=B8=88=E5=9B=9B=E4=B8=AA=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=9A=84=E6=88=AA=E6=AD=A2=E6=97=A5=E6=9C=9F=E5=92=8C=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E5=BE=97=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20160421011543_alter_homework_end_time.rb | 21 +++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20160421011543_alter_homework_end_time.rb diff --git a/db/migrate/20160421011543_alter_homework_end_time.rb b/db/migrate/20160421011543_alter_homework_end_time.rb new file mode 100644 index 000000000..4470bd63b --- /dev/null +++ b/db/migrate/20160421011543_alter_homework_end_time.rb @@ -0,0 +1,21 @@ +class AlterHomeworkEndTime < ActiveRecord::Migration + def up + homeworks = HomeworkCommon.where("id in (3229, 3234, 3235, 3236)"); + unless homeworks.empty? || homeworks.nil? + homeworks.each do |hw| + hw.end_time = hw.end_time + 4 + hm = hw.homework_detail_manual + hm.comment_status = 1 + hw.student_works.each do |stu| + stu.late_penalty = 0 + stu.save + end + hm.save + hw.save + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 124870b49..7e84996e6 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 => 20160418074429) do +ActiveRecord::Schema.define(:version => 20160421011543) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From 8e254ff7220d2d70cc19a9bb2bdb9ad480886d75 Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 21 Apr 2016 10:38:36 +0800 Subject: [PATCH 15/18] =?UTF-8?q?=E5=BE=AE=E4=BF=A1loading=E5=BC=B9?= =?UTF-8?q?=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/app.html | 8 +++++++- public/javascripts/wechat/app.js | 24 +++++++++++++++++++++--- public/stylesheets/weui/weixin.css | 8 +++++++- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/public/assets/wechat/app.html b/public/assets/wechat/app.html index eb97a8360..5b2f4e9ec 100644 --- a/public/assets/wechat/app.html +++ b/public/assets/wechat/app.html @@ -13,7 +13,13 @@ -
    +
    +
    +
    + 加载中... +
    +
    +
    diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index bedd79ed4..984d9a9b2 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,9 +1,9 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = '/api/v1/'; -var debug = false; //调试标志,如果在本地请置为true +var debug = true; //调试标志,如果在本地请置为true if(debug===true){ - apiUrl = 'https://www.trustie.net/api/v1/'; + apiUrl = 'http://localhost:3000/api/v1/'; } app.factory('auth', function($http,$routeParams, $cookies, $q){ @@ -399,7 +399,7 @@ app.directive('textAutoHeight', function($timeout){ } }); -app.config(['$routeProvider',function ($routeProvider) { +app.config(['$routeProvider',"$httpProvider",function ($routeProvider, $httpProvider) { $routeProvider .when('/activities', { templateUrl: 'activities.html', @@ -436,4 +436,22 @@ app.config(['$routeProvider',function ($routeProvider) { .otherwise({ redirectTo: '/activities' }); + $httpProvider.interceptors.push('timestampMarker'); +}]); + +//loading +app.factory('timestampMarker', ["$rootScope", function ($rootScope) { + var timestampMarker = { + request: function (config) { + $rootScope.loading = true; + config.requestTimestamp = new Date().getTime(); + return config; + }, + response: function (response) { + // $rootScope.loading = false; + response.config.responseTimestamp = new Date().getTime(); + return response; + } + }; + return timestampMarker; }]); diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index 3872bb649..d79ad16ae 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -64,4 +64,10 @@ a.underline {text-decoration:underline;} .post-reply-trigger {font-size:13px;} .post-input-container {padding-right:2px;} .post-reply-input {width:100%; height:28px; line-height:28px; border:1px solid #e6e6e6; outline:none; padding:0; margin:0; border-radius:3px;} -.post-reply-submit {font-size:13px; padding:3px 8px; color:#fff; background-color:#269ac9; outline:none; border:none; display:inline-block;} \ No newline at end of file +.post-reply-submit {font-size:13px; padding:3px 8px; color:#fff; background-color:#269ac9; outline:none; border:none; display:inline-block;} + +/* loading 弹框*/ +.loading-bg {position:fixed; width:100%; height:100%; left:0; top:0; z-index:99; background:rgba(0, 0, 0, 0.3); overflow:hidden;} +.loading-box {position:absolute; top:50%; background:white; width:160px; height:72px; left:50%; margin-top:-36px; margin-left:-80px; text-align:center;} +.loading-box img {margin-top: 12px; text-align: center;} +.loading-box span {display: block;} \ No newline at end of file From d538d1967bda900187bab90633027d349d61d340 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 21 Apr 2016 11:16:32 +0800 Subject: [PATCH 16/18] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E7=95=8C=E9=9D=A2=E4=BB=A3=E7=A0=81=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=88=97=E8=A1=A8404=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 22 ++++++++++++++++++++-- app/views/admin/code_work_tests.html.erb | 16 ++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index e6e0ec087..8ae20972c 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -610,15 +610,33 @@ class AdminController < ApplicationController tStart = @page*30 @code_work_tests = CodeTests.find_by_sql("select * from code_tests order by id desc limit #{tStart},30 ") - #取出各个作业是否是模拟答题的 + #取出各个作品是否是模拟答题的 is_test = {} + #作品是否存在 + link_swork = {} + #作业是否存在 + link_hwork = {} @code_work_tests.each do |test| + #作品是否存在 if is_test[test['student_work_id']] != nil + test['link_swork'] = link_swork[test['student_work_id']] test['is_test'] = is_test[test['student_work_id']] else - test['is_test'] = StudentWork.find(test['student_work_id']).is_test + work = StudentWork.where("id=?",test['student_work_id']).first + test['link_swork'] = !work.nil? + test['is_test'] = work.nil? ? false : work.is_test #test['is_test'] = CodeTests.find_by_sql("select is_test from student_works where id = #{test['student_work_id']}").first['is_test'] is_test[test['student_work_id']] = test['is_test'] + link_swork[test['student_work_id']] = test['link_swork'] + end + + #作业是否存在 + if link_hwork[test['homework_id']] != nil + test['link_hwork'] = link_hwork[test['homework_id']] + else + hwork = HomeworkCommon.where("id=?",test['homework_id']).first + test['link_hwork'] = !hwork.nil? + link_hwork[test['homework_id']] = test['link_hwork'] end end diff --git a/app/views/admin/code_work_tests.html.erb b/app/views/admin/code_work_tests.html.erb index cb113f1e6..64c3a41e1 100644 --- a/app/views/admin/code_work_tests.html.erb +++ b/app/views/admin/code_work_tests.html.erb @@ -37,13 +37,21 @@ <% if test['homework_id'] != nil %> "> '> - <%=link_to(test['homework_id'], student_work_index_path(:homework => test['homework_id']))%> + <% if test['link_hwork'] %> + <%=link_to(test['homework_id'], student_work_index_path(:homework => test['homework_id']))%> + <% else %> + <%= test['homework_id'] %> + <% end %> '> - <% if !test['is_test'] %> - <%=link_to(test['student_work_id'], student_work_index_path(:homework => test['homework_id'],:student_work_id=>test['student_work_id']))%> + <% if test['link_swork'] && test['link_hwork'] %> + <% if !test['is_test'] %> + <%=link_to(test['student_work_id'], student_work_index_path(:homework => test['homework_id'],:student_work_id=>test['student_work_id']))%> + <% else %> + <%=link_to(test['student_work_id'], new_user_commit_homework_users_path(homework_id: test['homework_id'], is_test: true))%> + <% end %> <% else %> - <%=link_to(test['student_work_id'], new_user_commit_homework_users_path(homework_id: test['homework_id'], is_test: true))%> + <%= test['student_work_id'] %> <% end %> From 0bab42256c6e6c6d54c9cf0b61553d42205788e0 Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 21 Apr 2016 11:21:29 +0800 Subject: [PATCH 17/18] =?UTF-8?q?=E5=BE=AE=E4=BF=A1loading=E5=BC=B9?= =?UTF-8?q?=E6=A1=86=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/app.html | 2 +- public/images/wechat/loading.gif | Bin 0 -> 3878 bytes public/javascripts/wechat/app.js | 2 +- public/stylesheets/weui/weixin.css | 4 ++-- 4 files changed, 4 insertions(+), 4 deletions(-) create mode 100755 public/images/wechat/loading.gif diff --git a/public/assets/wechat/app.html b/public/assets/wechat/app.html index 5b2f4e9ec..187439468 100644 --- a/public/assets/wechat/app.html +++ b/public/assets/wechat/app.html @@ -16,7 +16,7 @@
    - 加载中... + 加载中...
    diff --git a/public/images/wechat/loading.gif b/public/images/wechat/loading.gif new file mode 100755 index 0000000000000000000000000000000000000000..b806bf34c396900414f74b8e591e85333f9ab38f GIT binary patch literal 3878 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 literal 0 HcmV?d00001 diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 984d9a9b2..241c88129 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -377,7 +377,7 @@ app.directive('textAutoHeight', function($timeout){ link: function(scope, element, attr){ scope.text = '点击展开'; $timeout(function(){ - var e = element.parent().children().eq(4); + var e = element.parent().children().eq(5); var height = e[0].scrollHeight; var offsetHeight = e[0].offsetHeight; if(height>90){ diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index 92aeec9cf..21fde54bb 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -73,7 +73,7 @@ a.underline {text-decoration:underline;} .praised-icon {background:url(/images/wechat/wechat_icon.png) -100px -76px no-repeat; width:20px; height:18px; display:inline-block; vertical-align:middle;} /* loading 弹框*/ -.loading-bg {position:fixed; width:100%; height:100%; left:0; top:0; z-index:99; background:rgba(0, 0, 0, 0.3); overflow:hidden;} +.loading-bg {position:fixed; width:100%; height:100%; left:0; top:0; z-index:99; background:rgba(206, 206, 206, 0.3); overflow:hidden;} .loading-box {position:absolute; top:50%; background:white; width:160px; height:72px; left:50%; margin-top:-36px; margin-left:-80px; text-align:center;} -.loading-box img {margin-top: 12px; text-align: center;} +.loading-box img {margin-top: 3px; text-align: center;} .loading-box span {display: block;} From 2345eb9d644730310786e791913965677740bd40 Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 21 Apr 2016 11:22:52 +0800 Subject: [PATCH 18/18] =?UTF-8?q?=E8=B7=AF=E5=BE=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 241c88129..0a6b97e5b 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,9 +1,9 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = '/api/v1/'; -var debug = true; //调试标志,如果在本地请置为true +var debug = false; //调试标志,如果在本地请置为true if(debug===true){ - apiUrl = 'http://localhost:3000/api/v1/'; + apiUrl = 'https://www.trustie.net/api/v1/'; } app.factory('auth', function($http,$routeParams, $cookies, $q){