From bef79a52c29bf231d29a1e1dc21b367902afc786 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 24 May 2019 18:59:14 +0800 Subject: [PATCH 01/51] fix copy ec year --- app/services/copy_ec_year_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/copy_ec_year_service.rb b/app/services/copy_ec_year_service.rb index cbbcd5f1..15a95ea0 100644 --- a/app/services/copy_ec_year_service.rb +++ b/app/services/copy_ec_year_service.rb @@ -224,7 +224,7 @@ to_relate.attributes = relate.attributes.except('id', 'ec_course_achievement_method_id', 'ec_course_target_id', 'ec_course_evaluation_subitem_id', 'created_at', 'updated_at') to_relate.ec_course_target_id = course_target_map[relate.ec_course_target_id] - to_relate.ec_course_evaluation_subitem_id = course_target_map[relate.ec_course_evaluation_subitem_id] + to_relate.ec_course_evaluation_subitem_id = course_evaluation_subitem_map[relate.ec_course_evaluation_subitem_id] to_relate.save! achievement_evaluation_relates_map[relate.id] = to_relate.id From 27acd561c0c42966b17d4d4e8d9a3b78366662bc Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 24 May 2019 19:11:06 +0800 Subject: [PATCH 02/51] fix copy ec year bug --- app/services/copy_ec_year_service.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/services/copy_ec_year_service.rb b/app/services/copy_ec_year_service.rb index 15a95ea0..31bac9f9 100644 --- a/app/services/copy_ec_year_service.rb +++ b/app/services/copy_ec_year_service.rb @@ -224,7 +224,8 @@ to_relate.attributes = relate.attributes.except('id', 'ec_course_achievement_method_id', 'ec_course_target_id', 'ec_course_evaluation_subitem_id', 'created_at', 'updated_at') to_relate.ec_course_target_id = course_target_map[relate.ec_course_target_id] - to_relate.ec_course_evaluation_subitem_id = course_evaluation_subitem_map[relate.ec_course_evaluation_subitem_id] + # 可能不存在,所以为 -1 + to_relate.ec_course_evaluation_subitem_id = course_evaluation_subitem_map[relate.ec_course_evaluation_subitem_id] || -1 to_relate.save! achievement_evaluation_relates_map[relate.id] = to_relate.id From 02194f5503b83d241027286d414cb0565b10d5c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 24 May 2019 20:18:14 +0800 Subject: [PATCH 03/51] b --- app/views/common/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/common/index.html.erb b/app/views/common/index.html.erb index 5762eefe..15d6d3b5 100644 --- a/app/views/common/index.html.erb +++ b/app/views/common/index.html.erb @@ -1 +1 @@ -Educoder
\ No newline at end of file +Educoder
\ No newline at end of file From 39801556976f8f49f00485522536ae62668c6b53 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Fri, 24 May 2019 20:40:04 +0800 Subject: [PATCH 04/51] =?UTF-8?q?=E5=9D=97=E7=8A=B6=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/educoder/edu-all.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/stylesheets/educoder/edu-all.css b/public/stylesheets/educoder/edu-all.css index 3da912bb..bbd05a56 100644 --- a/public/stylesheets/educoder/edu-all.css +++ b/public/stylesheets/educoder/edu-all.css @@ -74,7 +74,7 @@ em.vertical-line{display: inline-block;width: 2px;background: #999;height: 10px} .moreitem{position: absolute;right: 5px;top:35px;height: 15px;color:#656565} /*块状列表*/ .square-list{width: 100%;box-sizing: border-box;margin-top:20px} -.square-Item{position: relative;width:280px;margin-right: 26px;margin-bottom: 26px;float: left;border-radius: 6px;background-color:#fff;box-shadow: 0px 0px 12px rgba(0,0,0,0.1); height: 301px;} +.square-Item{position: relative;width:280px;margin-right: 26px;margin-bottom: 26px;float: left;border-radius: 6px;background-color:#fff;box-shadow: 0px 0px 12px rgba(0,0,0,0.1); min-height: 301px;} .square-Item:hover{bottom: 3px; box-shadow: 0px 0px 12px rgba(0,0,0,0.3);} .square-Item:hover .closeSquare{display: block} .square-Item:nth-child(4n+0){margin-right: 0px;} From 543bb3e4c9652f100538959db852b75c7f2678a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 24 May 2019 20:48:24 +0800 Subject: [PATCH 05/51] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/ec/ecTitle/ecTitle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/ec/ecTitle/ecTitle.js b/public/react/src/modules/ec/ecTitle/ecTitle.js index f2440901..77daf2d4 100644 --- a/public/react/src/modules/ec/ecTitle/ecTitle.js +++ b/public/react/src/modules/ec/ecTitle/ecTitle.js @@ -51,7 +51,7 @@ class EcTitleCourseEvaluations extends Component { 毕业要求 vs 通用标准
  • - 5 + 5 学生
  • From 2c20ad2ed58d04ec9d7e43ee916eb53a8351a5c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 24 May 2019 20:54:12 +0800 Subject: [PATCH 06/51] b --- app/views/common/index.html.erb | 2 +- public/react/src/modules/ec/ecTitle/ecTitle.css | 2 ++ public/react/src/modules/ec/ecTitle/ecTitle.js | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/common/index.html.erb b/app/views/common/index.html.erb index 15d6d3b5..bc3cb422 100644 --- a/app/views/common/index.html.erb +++ b/app/views/common/index.html.erb @@ -1 +1 @@ -Educoder
    \ No newline at end of file +Educoder
    \ No newline at end of file diff --git a/public/react/src/modules/ec/ecTitle/ecTitle.css b/public/react/src/modules/ec/ecTitle/ecTitle.css index c6e612bc..3f6796cd 100644 --- a/public/react/src/modules/ec/ecTitle/ecTitle.css +++ b/public/react/src/modules/ec/ecTitle/ecTitle.css @@ -22,6 +22,8 @@ } #traningNav>li>.ecTitles { line-height: 16px !important; + height: 18px!important; + width: 18px!important; } #traningNav>li>.ecTitlefont:hover{ diff --git a/public/react/src/modules/ec/ecTitle/ecTitle.js b/public/react/src/modules/ec/ecTitle/ecTitle.js index 77daf2d4..f2440901 100644 --- a/public/react/src/modules/ec/ecTitle/ecTitle.js +++ b/public/react/src/modules/ec/ecTitle/ecTitle.js @@ -51,7 +51,7 @@ class EcTitleCourseEvaluations extends Component { 毕业要求 vs 通用标准
  • - 5 + 5 学生
  • From c677f58ca198c8f43bc1e95239abe82ceca64f48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 24 May 2019 20:56:38 +0800 Subject: [PATCH 07/51] b --- app/views/common/index.html.erb | 2 +- public/react/src/modules/ec/ecStudentList/ecStudentList.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/common/index.html.erb b/app/views/common/index.html.erb index bc3cb422..df334ea8 100644 --- a/app/views/common/index.html.erb +++ b/app/views/common/index.html.erb @@ -1 +1 @@ -Educoder
    \ No newline at end of file +Educoder
    \ No newline at end of file diff --git a/public/react/src/modules/ec/ecStudentList/ecStudentList.js b/public/react/src/modules/ec/ecStudentList/ecStudentList.js index 911ee1c2..4208b2bc 100644 --- a/public/react/src/modules/ec/ecStudentList/ecStudentList.js +++ b/public/react/src/modules/ec/ecStudentList/ecStudentList.js @@ -323,7 +323,7 @@ class ecStudentList extends Component { schooldata={schooldata} ecpath={this.state.ecComponentState} /> -
    +
    学生列表 返回
    From 29cf900c9973eea230be5521ab50f62e4d2e15c5 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 25 May 2019 14:14:28 +0800 Subject: [PATCH 08/51] =?UTF-8?q?shixun=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/_settings_show.html.erb | 1 + db/migrate/20190525060616_modify_exec_time_for_shixun.rb | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 db/migrate/20190525060616_modify_exec_time_for_shixun.rb diff --git a/app/views/shixuns/_settings_show.html.erb b/app/views/shixuns/_settings_show.html.erb index 92417f49..72752703 100644 --- a/app/views/shixuns/_settings_show.html.erb +++ b/app/views/shixuns/_settings_show.html.erb @@ -1,3 +1,4 @@ +
    配置 diff --git a/db/migrate/20190525060616_modify_exec_time_for_shixun.rb b/db/migrate/20190525060616_modify_exec_time_for_shixun.rb new file mode 100644 index 00000000..a5602ca8 --- /dev/null +++ b/db/migrate/20190525060616_modify_exec_time_for_shixun.rb @@ -0,0 +1,8 @@ +class ModifyExecTimeForShixun < ActiveRecord::Migration + def up + change_column(:shixuns, :exec_time, :integer, :default => 20) + end + + def down + end +end From a5d2976f172003eaa2b502f3fde5ffb69b7455f1 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 25 May 2019 15:05:04 +0800 Subject: [PATCH 09/51] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 2139715e..f946effa 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -801,6 +801,7 @@ class GamesService # 轮询获取状态 # resubmit是在file_update中生成的,从game_build中传入的 def game_status params, current_user + Rails.logger("sec_key is #{params[:sec_key]}**1") game = Game.find_by_identifier(params[:identifier]) resubmit_identifier = game.resubmit_identifier # 如果没有超时并且正在评测中 @@ -812,6 +813,7 @@ class GamesService return {:running_code_status => running_code_status, :running_code_message => running_code_message} end + Rails.logger("sec_key is #{params[:sec_key]}**2") Rails.logger.info("##### resubmit_identifier is #{resubmit_identifier}") port = params[:port] score = 0 @@ -838,6 +840,7 @@ class GamesService end end + Rails.logger("sec_key is #{params[:sec_key]}**3") # 实训的最大评测次数,这个值是为了优化查询,每次只取最新的最新一次评测的结果集 max_query_index = game.query_index - 1 # 区分评测过未评测过,未评测过按需求取数据 @@ -854,7 +857,7 @@ class GamesService # 能进入到此处,肯定是已经返回了结果,也就是说outputs中肯定有了数据 - + Rails.logger("sec_key is #{params[:sec_key]}**4") test_sets_count = qurey_test_sets.size # had_test = Output.where(:game_id => game.id, :query_index => max_query_index) # had_test_count = had_test.count @@ -881,6 +884,7 @@ class GamesService web_route = game_challenge.try(:web_route) mirror_name = shixun.mirror_name + Rails.logger("sec_key is #{params[:sec_key]}**5") # 轮询结束,更新评测耗时 e_record = EvaluateRecord.where(:identifier => params[:sec_key]).first if game_status == 0 || game_status == 2 @@ -898,12 +902,14 @@ class GamesService # 实训制作者当前拥有的金币 grade = User.where(:id => game.user_id).pluck(:grade).first + Rails.logger("sec_key is #{params[:sec_key]}**6") # 高性能取上一关、下一关 prev_game = Game.prev_identifier(shixun.id, game.myshixun_id, game_challenge.position) next_game = Game.next_game(shixun.id, game.myshixun_id, game_challenge.position).try(:identifier) output_hash = {:test_sets => test_sets, :had_test_count => test_sets_count, :test_sets_count => test_sets_count, :had_passed_testsests_error_count => had_passed_testsests_error_count} + Rails.logger("sec_key is #{params[:sec_key]}**7") return {:grade => grade, :gold => score, :experience => experience, :status => game_status, :had_done => had_done, :position => game_challenge.position, :port => port, :power => power, :record => record, :mirror_name => mirror_name, :picture => picture, :web_route => web_route, :latest_output => latest_output, From bfc78eb673801ab1666e2cfe44741bf378f6259a Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 25 May 2019 15:19:26 +0800 Subject: [PATCH 10/51] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=9B=91=E6=8E=A7=E7=AD=89=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index f946effa..f6f9926b 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -801,7 +801,7 @@ class GamesService # 轮询获取状态 # resubmit是在file_update中生成的,从game_build中传入的 def game_status params, current_user - Rails.logger("sec_key is #{params[:sec_key]}**1") + Rails.logger.info("sec_key is #{params[:sec_key]}**1") game = Game.find_by_identifier(params[:identifier]) resubmit_identifier = game.resubmit_identifier # 如果没有超时并且正在评测中 @@ -813,7 +813,7 @@ class GamesService return {:running_code_status => running_code_status, :running_code_message => running_code_message} end - Rails.logger("sec_key is #{params[:sec_key]}**2") + Rails.logger.info("sec_key is #{params[:sec_key]}**2") Rails.logger.info("##### resubmit_identifier is #{resubmit_identifier}") port = params[:port] score = 0 @@ -840,7 +840,7 @@ class GamesService end end - Rails.logger("sec_key is #{params[:sec_key]}**3") + Rails.logger.info("sec_key is #{params[:sec_key]}**3") # 实训的最大评测次数,这个值是为了优化查询,每次只取最新的最新一次评测的结果集 max_query_index = game.query_index - 1 # 区分评测过未评测过,未评测过按需求取数据 @@ -857,7 +857,7 @@ class GamesService # 能进入到此处,肯定是已经返回了结果,也就是说outputs中肯定有了数据 - Rails.logger("sec_key is #{params[:sec_key]}**4") + Rails.logger.info("sec_key is #{params[:sec_key]}**4") test_sets_count = qurey_test_sets.size # had_test = Output.where(:game_id => game.id, :query_index => max_query_index) # had_test_count = had_test.count @@ -884,7 +884,7 @@ class GamesService web_route = game_challenge.try(:web_route) mirror_name = shixun.mirror_name - Rails.logger("sec_key is #{params[:sec_key]}**5") + Rails.logger.info("sec_key is #{params[:sec_key]}**5") # 轮询结束,更新评测耗时 e_record = EvaluateRecord.where(:identifier => params[:sec_key]).first if game_status == 0 || game_status == 2 @@ -902,14 +902,14 @@ class GamesService # 实训制作者当前拥有的金币 grade = User.where(:id => game.user_id).pluck(:grade).first - Rails.logger("sec_key is #{params[:sec_key]}**6") + Rails.logger.info("sec_key is #{params[:sec_key]}**6") # 高性能取上一关、下一关 prev_game = Game.prev_identifier(shixun.id, game.myshixun_id, game_challenge.position) next_game = Game.next_game(shixun.id, game.myshixun_id, game_challenge.position).try(:identifier) output_hash = {:test_sets => test_sets, :had_test_count => test_sets_count, :test_sets_count => test_sets_count, :had_passed_testsests_error_count => had_passed_testsests_error_count} - Rails.logger("sec_key is #{params[:sec_key]}**7") + Rails.logger.info("sec_key is #{params[:sec_key]}**7") return {:grade => grade, :gold => score, :experience => experience, :status => game_status, :had_done => had_done, :position => game_challenge.position, :port => port, :power => power, :record => record, :mirror_name => mirror_name, :picture => picture, :web_route => web_route, :latest_output => latest_output, From 334d0a800d6a3c3ff1c4bf1ca0d135a0961d7359 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 25 May 2019 15:24:26 +0800 Subject: [PATCH 11/51] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E7=9B=91=E6=8E=A712?= =?UTF-8?q?=E5=B0=8F=E6=97=B6=E4=B8=80=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 769481b0..e3ecc2ce 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -853,7 +853,7 @@ class ManagementsController < ApplicationController def evaluate_simple page = params[:page] - @recodes = EvaluateRecord.where("created_at > ?", Time.now - 1.days).reorder("consume_time desc") + @recodes = EvaluateRecord.where("created_at > ?", Time.now - 0.5.days).reorder("consume_time desc") @recodes_count = @recodes.size @record_pages = Paginator.new @recodes_count, 20, page || 1 @offset ||= @record_pages.offset From 768881c1c332a6565f2e64b716154f66c662d394 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 25 May 2019 15:43:02 +0800 Subject: [PATCH 12/51] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=8C=BA=E5=88=86=E7=94=A8=E6=88=B7=E6=8F=90=E4=BA=A4=E5=92=8C?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index f6f9926b..e413c101 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -371,7 +371,8 @@ class GamesService end if content != last_content content_modified = 1 - code_file = @g.edit_file(@myshixun.gpid, current_user.login, :content => content, :file_path => path, :branch_name => "master", :commit_message => "auto commit") + code_file = @g.edit_file(@myshixun.gpid, current_user.login, :content => content, :file_path => path, :branch_name => "master", + :commit_message => (params[:evaluate] == 1 ? "commit by author" : "auto commit" )) end # REDO:是否有读写分离的问题 if record.present? From 88fa6989fecf9eba73e09f26fa05a055657615d2 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 25 May 2019 15:57:05 +0800 Subject: [PATCH 13/51] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index e413c101..d4fd733a 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -371,6 +371,9 @@ class GamesService end if content != last_content content_modified = 1 + + Rails.logger.info("@@@@@####{params[:evaluate]}") + Rails.logger.info("@@@@@####{params[:evaluate] == 1 ? "commit by author" : "auto commit" }") code_file = @g.edit_file(@myshixun.gpid, current_user.login, :content => content, :file_path => path, :branch_name => "master", :commit_message => (params[:evaluate] == 1 ? "commit by author" : "auto commit" )) end From 9ccd8c1c52920bf77c90c2016c7643dc3a8fe5f5 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 25 May 2019 16:00:05 +0800 Subject: [PATCH 14/51] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index d4fd733a..e413c101 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -371,9 +371,6 @@ class GamesService end if content != last_content content_modified = 1 - - Rails.logger.info("@@@@@####{params[:evaluate]}") - Rails.logger.info("@@@@@####{params[:evaluate] == 1 ? "commit by author" : "auto commit" }") code_file = @g.edit_file(@myshixun.gpid, current_user.login, :content => content, :file_path => path, :branch_name => "master", :commit_message => (params[:evaluate] == 1 ? "commit by author" : "auto commit" )) end From 07b7fe630e49f3f9de9db202a116ed143ad04508 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 25 May 2019 19:31:20 +0800 Subject: [PATCH 15/51] =?UTF-8?q?fork=E5=AE=9E=E8=AE=AD=E4=B8=8D=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E8=83=8C=E6=99=AF=E7=9F=A5=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index c60a9959..ecc5ce46 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -850,7 +850,7 @@ class ShixunsController < ApplicationController begin raise "请先绑定邮箱" if User.current.mail.blank? new_shixun = Shixun.new - new_shixun.attributes = @shixun.attributes.dup.except("id","user_id","visits","gpid","status", "identifier", "homepage_show","git_url") + new_shixun.attributes = @shixun.attributes.dup.except("id","user_id","visits","gpid","status", "identifier", "homepage_show","git_url", "propaedeutics") new_shixun.user_id = User.current.id new_shixun.identifier = generate_identifier new_shixun.status = 0 From 58bf8a994734cd1f65eae884d8817d5fa52728c2 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 27 May 2019 09:10:09 +0800 Subject: [PATCH 16/51] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=9A=84=E9=87=8D=E5=91=BD=E5=90=8D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 18 +++++++++-- .../_homework_index_list.html.erb | 6 +++- .../_rename_shixun_homework.html.erb | 30 +++++++++++++++++++ .../homework_common/rename_homework.js.erb | 5 ++++ app/views/homework_common/rename_modal.js.erb | 2 ++ config/routes.rb | 2 ++ 6 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 app/views/homework_common/_rename_shixun_homework.html.erb create mode 100644 app/views/homework_common/rename_homework.js.erb create mode 100644 app/views/homework_common/rename_modal.js.erb diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index e404c5ee..0e5ac1d6 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -12,11 +12,12 @@ class HomeworkCommonController < ApplicationController before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set, :set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works, :set_score_open,:alert_score_open_modal,:add_to_homework_bank,:publish_notice,:publish_homework,:end_notice,:end_homework, - :setting,:set_public,:homework_setting,:update_explanation,:cancel_publish, :homework_code_repeat, :review_detail,:move_to_category] + :setting,:set_public,:homework_setting,:update_explanation,:cancel_publish, :homework_code_repeat, :review_detail,:move_to_category, + :rename_modal, :rename_homework] before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment, :start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works, :open_student_works,:add_to_homework_bank,:publish_notice,:end_notice,:publish_homework,:end_homework,:update_explanation, - :cancel_publish, :move_to_category,:homework_setting] + :cancel_publish, :move_to_category,:homework_setting, :rename_homework, :rename_modal] # before_filter :member_of_course, :only => [:index,:setting] @@ -275,6 +276,19 @@ class HomeworkCommonController < ApplicationController @groups = paginateHelper @groups, 5 end + def rename_modal + + end + + def rename_homework + if params[:name].blank? + @notice = true + else + @homework.update_attributes(:name => params[:name].strip) + redirect_to homework_common_index_path(:course => @course.id, :homework_type => @homework.homework_type) + end + end + def setting @is_new = params[:is_new].to_i if params[:is_new] @is_empty = @homework.publish_time.nil? diff --git a/app/views/homework_common/_homework_index_list.html.erb b/app/views/homework_common/_homework_index_list.html.erb index 884fd0b9..bcc9bae8 100644 --- a/app/views/homework_common/_homework_index_list.html.erb +++ b/app/views/homework_common/_homework_index_list.html.erb @@ -11,7 +11,8 @@
    # <%= get_hw_index(homework_common, @is_teacher, @homework_type) + 1 %> <% homework_curr_status = homework_curr_time(homework_common) %> - <%= link_to homework_common.name.to_s, student_work_index_path(:homework => homework_common.id,:host=> Setting.host_course), :class => "edu-class-inner-list fl color-grey-3"%> + <%= link_to homework_common.name.to_s, student_work_index_path(:homework => homework_common.id,:host=> Setting.host_course), + :id => "homework_name_#{homework_common.id}", :class => "edu-class-inner-list fl color-grey-3"%> <% unless homework_common.is_public %> <% end %> @@ -144,6 +145,9 @@
  • <%= link_to "设置", student_work_index_path(:homework => homework_common.id, :tab => 4) %>
  • +
  • + <%= link_to "重命名", rename_modal_homework_common_path(homework_common), :remote => true %> +
  • <% if homework_common.homework_detail_manual.try(:comment_status) == 0 %>
  • <%= link_to '立即发布', publish_notice_homework_common_path(homework_common), :remote => true %> diff --git a/app/views/homework_common/_rename_shixun_homework.html.erb b/app/views/homework_common/_rename_shixun_homework.html.erb new file mode 100644 index 00000000..78f8eb27 --- /dev/null +++ b/app/views/homework_common/_rename_shixun_homework.html.erb @@ -0,0 +1,30 @@ +
    +
    + 重命名 +
    +
    + <%= form_for "", :url => rename_homework_homework_common_path(@homework), :remote => true, :html => {:id => "rename_shixun_homework_form"} do |f| %> +
    + 作业名称: +
    + +

    请输入作业名称

    +
    +
    + <% end %> +
  • + 取消 + 确定 +
  • + + + \ No newline at end of file diff --git a/app/views/homework_common/rename_homework.js.erb b/app/views/homework_common/rename_homework.js.erb new file mode 100644 index 00000000..1022f747 --- /dev/null +++ b/app/views/homework_common/rename_homework.js.erb @@ -0,0 +1,5 @@ +<% if @notice %> + notice_box("作业名称不能为空"); +<% else %> + $("#homework_name_<%= @homework.id %>").html(<%= @homework.name %>); +<% end %> \ No newline at end of file diff --git a/app/views/homework_common/rename_modal.js.erb b/app/views/homework_common/rename_modal.js.erb new file mode 100644 index 00000000..e691dff3 --- /dev/null +++ b/app/views/homework_common/rename_modal.js.erb @@ -0,0 +1,2 @@ +var html = '<%= escape_javascript(render :partial => "homework_common/rename_shixun_homework") %>'; +pop_box_new(html, 460, 227); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index e4dfe08d..137a1231 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1103,6 +1103,8 @@ RedmineApp::Application.routes.draw do ## oauth相关 match 'move_to_category', :via => [:get,:post] match 'homework_code_repeat', :via => [:get,:post] get 'review_detail' + post 'rename_homework' + get 'rename_modal' end collection do From ecff82dc0c161c2906a2faf73959f95064c499ff Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 27 May 2019 09:56:08 +0800 Subject: [PATCH 17/51] =?UTF-8?q?=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E7=9A=84=E8=AF=BE=E5=A0=82=E5=88=97=E8=A1=A8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=8C=89=E8=AF=BE=E5=A0=82=E5=90=8D=E7=A7=B0=E6=90=9C?= =?UTF-8?q?=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 8 +++++--- app/views/managements/classroom_classment.html.erb | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index e3ecc2ce..5df43ed6 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -2023,7 +2023,7 @@ end # @schools = School.where(:id =>user_exs.map(&:school_id)) # end @search = params[:search] # 搜索字 - @keyword = params[:keyword].blank? ? "u_name" : params[:keyword] # 根据姓名/课程名搜索 + @keyword = params[:keyword].blank? ? "c_name" : params[:keyword] # 根据姓名/课程名搜索 @status = params[:status] @school_id = params[:school_id] @@ -2044,11 +2044,13 @@ end if params[:status] && params[:status]!='' @courses = @courses.where(:is_end => @status.to_i) end - if "u_name" == @keyword + if "c_name" == @keyword + @courses = @courses.where("name like ?", "%#{@search}%") + elsif "u_name" == @keyword if @search.blank? @courses = @courses else - user_id = User.where("concat(lastname, firstname) like '%#{@search}%'") + # user_id = User.where("concat(lastname, firstname) like '%#{@search}%'") @courses = @courses.joins("join users u on courses.tea_id = u.id").where("concat(u.lastname, u.firstname) like '%#{@search}%'") end elsif "dep_name" == @keyword diff --git a/app/views/managements/classroom_classment.html.erb b/app/views/managements/classroom_classment.html.erb index 06ea072d..f9417d74 100644 --- a/app/views/managements/classroom_classment.html.erb +++ b/app/views/managements/classroom_classment.html.erb @@ -14,6 +14,7 @@ From c10ed929da3248d99f93257c2f69cbf75c807357 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 27 May 2019 11:05:29 +0800 Subject: [PATCH 18/51] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=94=AF=E4=B8=80=E8=A1=A8=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 2 +- .../managements/evaluate_simple.html.erb | 42 ++++--------------- 2 files changed, 10 insertions(+), 34 deletions(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index e3ecc2ce..636d4edb 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -853,7 +853,7 @@ class ManagementsController < ApplicationController def evaluate_simple page = params[:page] - @recodes = EvaluateRecord.where("created_at > ?", Time.now - 0.5.days).reorder("consume_time desc") + @recodes = EvaluateRecord.where("created_at > ?", Time.now - 10000.days).reorder("consume_time desc") @recodes_count = @recodes.size @record_pages = Paginator.new @recodes_count, 20, page || 1 @offset ||= @record_pages.offset diff --git a/app/views/managements/evaluate_simple.html.erb b/app/views/managements/evaluate_simple.html.erb index cecfe4a9..a278395c 100644 --- a/app/views/managements/evaluate_simple.html.erb +++ b/app/views/managements/evaluate_simple.html.erb @@ -1,54 +1,29 @@ -<% if false %> - -
    -
    -

    耗时详情

    - -
    -
    -
      -
    1. 总耗时:<%= @consume_time %>
    2. -
    3. 作品更新:<%= @student_work %>
    4. -
    5. 文件更新:<%= @file_update %>
    6. -
    7. 中间层总耗时:<%= @brige %>
    8. -
    9. pull代码:<%= @git_pull %>
    10. -
    11. pod启动:<%= @create_pod %>
    12. -
    13. pod执行:<%= @pod_execute %>
    14. -
    15. 中间层回传:<%= @return_back %>--(中间层出结果传Educoder)
    16. -
    17. 前端轮询:<%= @front_js %>--(局部数据查询,Js轮询)
    18. -
    19. 回调结果存储:<%= @test_cases %>
    20. -
    -
    -
    -<% end %> - <% if @recodes.present? %>
    - - + + - + - + - + + - <% @recodes.each_with_index do |record, index| %> + <% @recodes.each do |record| %> - + @@ -60,6 +35,7 @@ + <% end %> From c49f3813452460e6a0bb26b46b8d45f6c3cc3a90 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 27 May 2019 14:16:48 +0800 Subject: [PATCH 19/51] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 8 ++++---- app/views/student_work/index.html.erb | 9 +++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 8885353c..1afaefc3 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -584,16 +584,16 @@ class StudentWorkController < ApplicationController @stundet_works = @stundet_works.where(:work_status => @status) end + @stundet_works = search_work_member @stundet_works, @name + if @stundet_works.size != 0 if @order == "student_id" - @stundet_works = @stundet_works.includes(:user => {:user_extensions => []}).order("user_extensions.student_id #{@b_sort}") + @stundet_works = @stundet_works.joins(:user => {:user_extensions => []}).order("user_extensions.student_id #{@b_sort}") else @stundet_works = @stundet_works.order("#{@order} #{@b_sort}") end end - @stundet_works = search_work_member @stundet_works, @name - @score = @b_sort == "desc" ? "asc" : "desc" # @is_focus = params[:is_focus] ? params[:is_focus].to_i : 0 # 消息传过来的ID @@ -615,6 +615,7 @@ class StudentWorkController < ApplicationController _index @stundet_works = paginateHelper @stundet_works, @limit + @members = @course.members.select([:user_id, :course_group_id]) if @stundet_works.size != 0 @stundet_works = if @homework.homework_type == 1 @stundet_works.includes(:student_works_scores, [user: :user_extensions]) @@ -623,7 +624,6 @@ class StudentWorkController < ApplicationController elsif @homework.homework_type == 4 @stundet_works.includes(:student_works_scores, [myshixun: :games], [user: :user_extensions]) end - @members = @course.members.where(user_id: @stundet_works.pluck(:user_id)).select([:user_id, :course_group_id]) end respond_to do |format| format.js diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index 99384dfc..0e66401c 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -199,14 +199,11 @@ 不限> - + > - + > - +
  • From 5afb8d00d687c4df021efec95c557fc03a413744 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 27 May 2019 17:09:48 +0800 Subject: [PATCH 20/51] =?UTF-8?q?=E5=A5=BD=E5=A4=A7=E5=AD=A6=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/api.rb | 13 +++++- app/api/mobile/apis/cnmooc.rb | 54 ++++++++++++++++++++++ app/services/cnmoocs_service.rb | 82 +++++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 app/api/mobile/apis/cnmooc.rb create mode 100644 app/services/cnmoocs_service.rb diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index eefedb5b..d13dc61f 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -36,7 +36,7 @@ module Mobile content_type :json, "application/json;charset=UTF-8" # use ActionDispatch::Session::CookieStore - + require 'digest' use Mobile::Middleware::ErrorHandler helpers do @@ -53,6 +53,16 @@ module Mobile error!('401 Unauthorized', 401) if params[:private_token] != "hriEn3UwXfJs3PmyXnSG" end + def cnmooc_access_key! + ## 签名 + accessKeyId = 'LTAISM4HFWpQHh3g'.freeze + accessKeySecret = '9NMU8ushmFu8SN1EKHOhvo9jmv1qp0'.freeze + sign = Digest::MD5.hexdigest("AccessKeyId=#{accessKeyId}AccessKeySecret=#{accessKeySecret}").upcase + if params[:sign] != sign + error!('401 Unauthorized', 401) + end + end + # 有一些接口没登录也能查看数据 def career_authenticate! pass = request.path.include?("introduction") || request.path.include?("get_published_careers")|| request.path.include?("get_current_user") @@ -160,6 +170,7 @@ module Mobile mount Apis::Careers mount Apis::Assets mount Apis::Ecloud + mount Apis::Cnmooc diff --git a/app/api/mobile/apis/cnmooc.rb b/app/api/mobile/apis/cnmooc.rb new file mode 100644 index 00000000..f49b4f66 --- /dev/null +++ b/app/api/mobile/apis/cnmooc.rb @@ -0,0 +1,54 @@ +# encoding=utf-8 +# 好大学接口数据 +module Mobile + module Apis + class Cnmooc < Grape::API + before {cnmooc_access_key!} + content_type :json, 'application/json;charset=UTF-8' + + resources :cnmoocs do + desc '获取实训数据' + get "get_resources_data" do + CnmoocsService.new.get_resources_data params + end + + desc "实训搜索功能" + params do + requires :name, type: String, desc: "搜索名称" + end + get 'search_resources' do + CnmoocsService.new.search_resources params + end + + desc " 查找用户" + params do + requires :mail, type: String, desc: "邮箱地址" + end + get 'find_user' do + CnmoocsService.new.find_user params + end + + desc "创建用户" + params do + requires :mail, type: String, desc: "邮箱地址" + requires :name, type: String, desc: "昵称" + requires :password, type: String, desc: "密码" + end + post "create_user" do + CnmoocsService.new.create_user params + end + + desc "远程登录" + params do + requires :mail, type: String, desc: "邮箱地址" + requires :password, type: String, desc: "密码" + end + get "login_educoder" do + CnmoocsService.new.login_educoder params + end + + + end + end + end +end \ No newline at end of file diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb new file mode 100644 index 00000000..02e6d54b --- /dev/null +++ b/app/services/cnmoocs_service.rb @@ -0,0 +1,82 @@ +class CnmoocsService + include ApplicationHelper + include GamesHelper + + def get_resources_data params + page = params[:pageNo].to_i + limit = params[:pageSize] || 16 + offset = page * limit.to_i + shixuns = Shixun.select([:id, :identifier, :name, :myshixuns_count, :averge_star, :challenges_count, :trainee]). + where(status: 0, hidden: 0).order("myshixun_count desc") + shixun_count = shixuns.count + pageCount = ((shixun_count / limit.to_f) == (shixun_count / limit)) ? (shixun_count / limit) : ((shixun_count / limit) + 1) + shixuns = shixuns.offset(offset).limit(limit) + shixun_list = shixun_data shixuns + {error: 0, messages: "请求成功", + page: {count: shixuns.count, totalCount: shixun_count, pageNo: page, pageSize: limit, pageCount: pageCount}, + data: shixun_list } + end + + def search_resources params + page = params[:pageNo].to_i + limit = params[:pageSize] || 16 + offset = page * limit.to_i + shixuns = Shixun.select([:id, :identifier, :name, :myshixuns_count, :averge_star, :challenges_count, :trainee]). + where(status: 2, hidden: 0).where("name like ?", "%#{params[:name]}%").offset(offset).limit(limit) + shixun_count = shixuns.count + pageCount = ((shixun_count / limit.to_f) == (shixun_count / limit)) ? (shixun_count / limit) : ((shixun_count / limit) + 1) + shixuns = shixuns.offset(offset).limit(limit) + shixun_list = shixun_data shixuns + {error: 0, messages: "请求成功", + page: {count: shixuns.count, totalCount: shixun_count, pageNo: page, pageSize: limit, pageCount: pageCount}, + data: shixun_list } + end + + def find_user params + user = User.find_by_mail params[:mail] + if user + {error: 0, message: "找到用户"} + else + {error: -1, message: "找不到用户"} + end + end + + def create_user params + user = User.find_by_mail params[:mail] + if user.blank? + ActiveRecord::Base.transaction do + # 如果Educoder中已存在与该OpenI用户的邮箱相同的用户,则会直接跳转到登录educoder的登录页面 + user = User.new(lastname: params[:name], mail: params[:mail], mail_notification: email) + user.login = generate_login('m') + user.password = params[:password] + user.certification = 1 + user.save! + UserExtensions.create!(user_id: user.id, school_id: School.first.id, identity: 4, gender: 0) + end + {error: 0, message: "创建成功"} + else + {error: -1, message: "邮箱已经存在,请直接使用邮箱登录"} + end + end + + def login_educoder params + user, last_login_on = User.try_to_login(params[:mail], params[:password]) + self.logged_user = user + {error: 0, message: "登录成功"} + end + + + private + def shixun_data shixuns + shixun_list = [] + shixuns.includes(:tag_repertoires).find_each do |shixun| + tag_name = shixun.tag_repertoires.first.try(:name) + level = %W(初级 中级 高级 顶级)[shixun.trainee - 1] + shixun_list << {identifier: shixun.identifier, name: shixun.name, students_count: shixun.myshixuns_count, + challenges_count: shixun.challenges_count, score_info: shixun.averge_star, level: level} + + end + {resouces: shixun_list} + end + +end \ No newline at end of file From d56728da62240b50159773b858916cc4e70e1248 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 27 May 2019 17:44:07 +0800 Subject: [PATCH 21/51] =?UTF-8?q?=E5=A5=BD=E5=A4=A7=E5=AD=A6=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/cnmoocs_service.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index 02e6d54b..fbb8d55c 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -7,10 +7,12 @@ class CnmoocsService limit = params[:pageSize] || 16 offset = page * limit.to_i shixuns = Shixun.select([:id, :identifier, :name, :myshixuns_count, :averge_star, :challenges_count, :trainee]). - where(status: 0, hidden: 0).order("myshixun_count desc") + where(status: 0, hidden: 0) shixun_count = shixuns.count pageCount = ((shixun_count / limit.to_f) == (shixun_count / limit)) ? (shixun_count / limit) : ((shixun_count / limit) + 1) - shixuns = shixuns.offset(offset).limit(limit) + Rails.logger.info("#####{pageCount}") + Rails.logger.info("#####{limit}") + shixuns = shixuns.order("myshixuns_count desc").offset(offset).limit(limit) shixun_list = shixun_data shixuns {error: 0, messages: "请求成功", page: {count: shixuns.count, totalCount: shixun_count, pageNo: page, pageSize: limit, pageCount: pageCount}, @@ -22,10 +24,10 @@ class CnmoocsService limit = params[:pageSize] || 16 offset = page * limit.to_i shixuns = Shixun.select([:id, :identifier, :name, :myshixuns_count, :averge_star, :challenges_count, :trainee]). - where(status: 2, hidden: 0).where("name like ?", "%#{params[:name]}%").offset(offset).limit(limit) + where(status: 2, hidden: 0).where("name like ?", "%#{params[:name]}%") shixun_count = shixuns.count pageCount = ((shixun_count / limit.to_f) == (shixun_count / limit)) ? (shixun_count / limit) : ((shixun_count / limit) + 1) - shixuns = shixuns.offset(offset).limit(limit) + shixuns = shixuns.order("myshixuns_count desc").offset(offset).limit(limit) shixun_list = shixun_data shixuns {error: 0, messages: "请求成功", page: {count: shixuns.count, totalCount: shixun_count, pageNo: page, pageSize: limit, pageCount: pageCount}, @@ -69,7 +71,7 @@ class CnmoocsService private def shixun_data shixuns shixun_list = [] - shixuns.includes(:tag_repertoires).find_each do |shixun| + shixuns.includes(:tag_repertoires).each do |shixun| tag_name = shixun.tag_repertoires.first.try(:name) level = %W(初级 中级 高级 顶级)[shixun.trainee - 1] shixun_list << {identifier: shixun.identifier, name: shixun.name, students_count: shixun.myshixuns_count, From f027b52e4a874bfd4ea9c6300cfdc9c5a513d9f0 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 27 May 2019 17:58:52 +0800 Subject: [PATCH 22/51] =?UTF-8?q?=E5=A5=BD=E5=A4=A7=E5=AD=A6=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/cnmoocs_service.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index fbb8d55c..40f75a8c 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -37,9 +37,9 @@ class CnmoocsService def find_user params user = User.find_by_mail params[:mail] if user - {error: 0, message: "找到用户"} + {error: 0, messages: "找到用户"} else - {error: -1, message: "找不到用户"} + {error: -1, messages: "找不到用户"} end end @@ -55,16 +55,21 @@ class CnmoocsService user.save! UserExtensions.create!(user_id: user.id, school_id: School.first.id, identity: 4, gender: 0) end - {error: 0, message: "创建成功"} + {error: 0, messages: "创建成功"} else - {error: -1, message: "邮箱已经存在,请直接使用邮箱登录"} + {error: -1, messages: "邮箱已经存在,请直接使用邮箱登录"} end end def login_educoder params user, last_login_on = User.try_to_login(params[:mail], params[:password]) - self.logged_user = user - {error: 0, message: "登录成功"} + if user + self.logged_user = user + {error: 0, messages: "登录成功"} + else + {error: -1, messages: "登录失败,请检查邮箱和密码是否正确"} + end + end From 40a1e1d0341e536af7f731e6db6a7056a8287e7c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 28 May 2019 09:49:24 +0800 Subject: [PATCH 23/51] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=8F=8D=E9=A6=88?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=A2=9E=E5=8A=A0=E8=B4=A6=E5=8F=B7=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E5=86=85=E5=AE=B9=E5=92=8C=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 851c50e6..0f62dbe8 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -4295,7 +4295,7 @@ end count_row = 1 shixuns = Shixun.where(:id => shixun_ids).includes(discusses: [:user]) sheet1.row(0).concat(["序号", "实训ID", "实训名称", "实训作者", "作者单位", "评论数", "评论内容", "关卡", "评论者", "评论者职业", - "评论者单位", "评论时间", "社区导师是否已回复"]) + "评论者单位", "评论时间", "社区导师是否已回复", "我的账号回复内容", "回复时间"]) shixuns.each_with_index do |shixun, i| discusses = shixun.discusses.where("user_id != ?", 1) if beginTime.present? @@ -4313,6 +4313,7 @@ end discusses.each_with_index do |discuss, j| user = discuss.user content = discuss.content.gsub(//, "【图片评论】").gsub(/!\[\].+\)/, "【图片评论】") + myself_discuss = discuss.children.where(user_id: User.current.id).last sheet1[count_row, 6] = strip_html content sheet1[count_row, 7] = "第#{discuss.position}关" sheet1[count_row, 8] = user.show_real_name @@ -4320,6 +4321,8 @@ end sheet1[count_row, 10] = user.school_name sheet1[count_row, 11] = format_time discuss.created_at sheet1[count_row, 12] = discuss.children.pluck(:user_id).include?(1) ? "是" : "否" + sheet1[count_row, 13] = myself_discuss.try(:content) + sheet1[count_row, 14] = myself_discuss ? (format_time myself_discuss.created_at) : "" count_row += 1 end #count_row += 1 From f17754c1480c140ad289bc7d16a5257996dac965 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 28 May 2019 11:13:43 +0800 Subject: [PATCH 24/51] 1 --- app/services/cnmoocs_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index 40f75a8c..33f166da 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -7,7 +7,7 @@ class CnmoocsService limit = params[:pageSize] || 16 offset = page * limit.to_i shixuns = Shixun.select([:id, :identifier, :name, :myshixuns_count, :averge_star, :challenges_count, :trainee]). - where(status: 0, hidden: 0) + where(status: 2, hidden: 0) shixun_count = shixuns.count pageCount = ((shixun_count / limit.to_f) == (shixun_count / limit)) ? (shixun_count / limit) : ((shixun_count / limit) + 1) Rails.logger.info("#####{pageCount}") From ee2ae75ecc65f616c6a7cfa38f691f30545d3526 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Tue, 28 May 2019 14:10:01 +0800 Subject: [PATCH 25/51] fix axlsx gem --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 11029470..7909cb17 100644 --- a/Gemfile +++ b/Gemfile @@ -63,8 +63,8 @@ gem 'elasticsearch-rails' gem 'oauth2' # xlsx -#gem 'axlsx', '3.0.0.pre' -#gem 'axlsx_rails', '0.3.0' +gem 'axlsx', '3.0.0.pre' +gem 'axlsx_rails', '0.3.0' #Ruby 2.2+ has removed test/unit from the core library. if RUBY_VERSION>='2.2' From 924448efaacacaf628a0da91485284d1774129bd Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 28 May 2019 15:02:09 +0800 Subject: [PATCH 26/51] =?UTF-8?q?=E5=8F=96=E5=87=BA=E8=A1=A5=E4=BA=A4?= =?UTF-8?q?=E7=9A=84=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 8885353c..464a2842 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -647,7 +647,7 @@ class StudentWorkController < ApplicationController uid: "#{work.user.user_extensions.student_id}", downloadUrl: '' } - attachment = work.attachments.first + attachment = work.attachments.last if attachment o[:downloadUrl] = "https://#{Setting.host_name}/"+download_named_attachment_path(attachment.id, attachment.filename) end From 50e0bf1a92eb79b1633df92b40ea95ae2e37cf48 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 28 May 2019 15:07:33 +0800 Subject: [PATCH 27/51] 1 --- app/services/cnmoocs_service.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index 33f166da..e3bb8cee 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -10,8 +10,6 @@ class CnmoocsService where(status: 2, hidden: 0) shixun_count = shixuns.count pageCount = ((shixun_count / limit.to_f) == (shixun_count / limit)) ? (shixun_count / limit) : ((shixun_count / limit) + 1) - Rails.logger.info("#####{pageCount}") - Rails.logger.info("#####{limit}") shixuns = shixuns.order("myshixuns_count desc").offset(offset).limit(limit) shixun_list = shixun_data shixuns {error: 0, messages: "请求成功", From 02aa938fe48f5b2a5399e34adec09ca5308730c5 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Tue, 28 May 2019 16:26:57 +0800 Subject: [PATCH 28/51] add cnmooc use create api --- app/api/mobile/apis/cnmooc.rb | 5 +-- app/models/cnmooc_user.rb | 8 ++++ app/models/user_source.rb | 21 ++++++++++ app/services/cnmoocs_service.rb | 41 +++++++++++-------- .../20190528075558_create_user_sources.rb | 15 +++++++ 5 files changed, 71 insertions(+), 19 deletions(-) create mode 100644 app/models/cnmooc_user.rb create mode 100644 app/models/user_source.rb create mode 100644 db/migrate/20190528075558_create_user_sources.rb diff --git a/app/api/mobile/apis/cnmooc.rb b/app/api/mobile/apis/cnmooc.rb index f49b4f66..a45989c3 100644 --- a/app/api/mobile/apis/cnmooc.rb +++ b/app/api/mobile/apis/cnmooc.rb @@ -30,9 +30,8 @@ module Mobile desc "创建用户" params do - requires :mail, type: String, desc: "邮箱地址" - requires :name, type: String, desc: "昵称" - requires :password, type: String, desc: "密码" + requires :userName, type: String, desc: "好大学用户名" + optional :name, type: String, desc: "用户姓名" end post "create_user" do CnmoocsService.new.create_user params diff --git a/app/models/cnmooc_user.rb b/app/models/cnmooc_user.rb new file mode 100644 index 00000000..e834c768 --- /dev/null +++ b/app/models/cnmooc_user.rb @@ -0,0 +1,8 @@ +class CnmoocUser < UserSource + + private + + def email_prefix + 'cnmooc_' + end +end diff --git a/app/models/user_source.rb b/app/models/user_source.rb new file mode 100644 index 00000000..d8fb350d --- /dev/null +++ b/app/models/user_source.rb @@ -0,0 +1,21 @@ +class UserSource < ActiveRecord::Base + belongs_to :user + + def generate_email + email = rand_email + while User.exists?(mail: email) do + email = rand_email + end + email + end + + private + + def rand_email + email_prefix + Random.rand.to_s[2..8] + '@educoder.com' + end + + def email_prefix + '' + end +end diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index 33f166da..5057fabe 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -43,22 +43,32 @@ class CnmoocsService end end - def create_user params - user = User.find_by_mail params[:mail] - if user.blank? - ActiveRecord::Base.transaction do - # 如果Educoder中已存在与该OpenI用户的邮箱相同的用户,则会直接跳转到登录educoder的登录页面 - user = User.new(lastname: params[:name], mail: params[:mail], mail_notification: email) - user.login = generate_login('m') - user.password = params[:password] - user.certification = 1 - user.save! - UserExtensions.create!(user_id: user.id, school_id: School.first.id, identity: 4, gender: 0) - end - {error: 0, messages: "创建成功"} - else - {error: -1, messages: "邮箱已经存在,请直接使用邮箱登录"} + def create_user(params) + c_user = CnmoocUser.find_by_uuid(params[:userName]) + + if c_user.present? + return { error: -1, messages: '用户已存在' } end + + mail = c_user.generate_email + create_params = { + lastname: params[:name], + mail: mail, + mail_notification: mail, + login: generate_login('m'), + password: OauthController::DEFAULT_PASSWORD, + certification: 1 + } + ActiveRecord::Base.transaction do + user = User.create!(create_params) + + UserExtensions.create!(user_id: user.id, school_id: School.first.id, identity: 4, gender: 0) + + c_user.user_id = user.id + c_user.save! + end + + { error: 0, messages: "创建成功", data: { userId: user.id } } end def login_educoder params @@ -85,5 +95,4 @@ class CnmoocsService end {resouces: shixun_list} end - end \ No newline at end of file diff --git a/db/migrate/20190528075558_create_user_sources.rb b/db/migrate/20190528075558_create_user_sources.rb new file mode 100644 index 00000000..03f6c12a --- /dev/null +++ b/db/migrate/20190528075558_create_user_sources.rb @@ -0,0 +1,15 @@ +class CreateUserSources < ActiveRecord::Migration + def change + create_table :user_sources do |t| + t.string :type + t.integer :user_id + t.string :uuid + t.string :name + + t.timestamps + end + + add_index :user_sources, [:type, :uuid], unique: true + add_index :user_sources, :user_id + end +end From 3d1e29cf0a7b73029042ef9a51428231660e1aee Mon Sep 17 00:00:00 2001 From: p31729568 Date: Tue, 28 May 2019 16:46:59 +0800 Subject: [PATCH 29/51] cnmooc source url --- app/api/mobile/apis/cnmooc.rb | 10 ++++++++++ app/controllers/application_controller.rb | 3 +++ app/models/user.rb | 2 ++ app/services/cnmoocs_service.rb | 14 ++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/app/api/mobile/apis/cnmooc.rb b/app/api/mobile/apis/cnmooc.rb index a45989c3..42a6cfe3 100644 --- a/app/api/mobile/apis/cnmooc.rb +++ b/app/api/mobile/apis/cnmooc.rb @@ -37,6 +37,16 @@ module Mobile CnmoocsService.new.create_user params end + desc "获取资源访问地址" + params do + requires :userId, type: Integer, desc: "用户ID" + requires :resouceId, type: String, desc: "资源唯一标示" + requires :accessType, type: Integer, desc: "资源类型" + end + get "source_url" do + CnmoocsService.new.source_url(params) + end + desc "远程登录" params do requires :mail, type: String, desc: "邮箱地址" diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 435c71fc..42dd6e1e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -207,6 +207,9 @@ class ApplicationController < ActionController::Base elsif session[:wechat_openid] uw = UserWechat.find_by_openid(session[:wechat_openid]) user = uw.user if uw + elsif session[:third_party_user_id] + c_user = UserSource.find_by_id(session[:third_party_user_id]) + user = c_user.user if c_user end end if user.nil? && Setting.rest_api_enabled? && accept_api_auth? diff --git a/app/models/user.rb b/app/models/user.rb index 752ea113..3e89e4f2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -269,6 +269,8 @@ class User < Principal has_many :article_homepages, :dependent => :destroy has_many :competition_lists, :dependent => :destroy + has_one :user_source + ## end # default_scope -> { includes(:user_extensions, :user_score) } diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index 5057fabe..04df260d 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -82,6 +82,20 @@ class CnmoocsService end + def source_url(params) + if session[:third_party_user_id].blank? + user = User.find(params[:userId]) + session[:third_party_user_id] = user.user_source.id + end + + shixun = Shixun.find_by_identifier(params[:resouceId]) + if shixun.blank? + return { error: -1, messages: '资源不存在' } + end + + { error: 0, messages: '成功', accessUrl: "#{Redmine::Configuration['educoder_domain']}/shixuns/#{shixun.id}" } + end + private def shixun_data shixuns From f06a1b5df6e6753960dbb4dd09e559abf00469b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Tue, 28 May 2019 17:32:44 +0800 Subject: [PATCH 30/51] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E9=A2=98=20=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E5=A2=9E=E5=8A=A0=E9=A2=98=E7=9B=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_edit_shixun.html.erb | 5 ++++- app/views/exercise/_exercise_form.html.erb | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/views/exercise/_edit_shixun.html.erb b/app/views/exercise/_edit_shixun.html.erb index b7caa087..9c0f130b 100644 --- a/app/views/exercise/_edit_shixun.html.erb +++ b/app/views/exercise/_edit_shixun.html.erb @@ -1,7 +1,10 @@ <%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:html => {:id => "update_exercise_question_#{exercise_question.id}"}) do |f|%>

    实训题

    -

    <%= exercise_question.shixun.name %>

    +

    + + +

  • diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 677e7014..ca3080e4 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -106,11 +106,15 @@ //修改标题时确定按钮 function edit_poll_question(doc,id,quest_type) { + var name = $.trim($("#poll_questions_name_" + id).val()); var title = $.trim($("#poll_questions_title_" + id).val()); var score = $.trim($("#poll_question_score_"+ id).val()); var standard_ans = $.trim($("#exercise_choice_" + id).val()); + if(name===""){ + notice_box("题目标题"); + } if(title.length == 0 || score.length == 0){ - notice_box("题目标题/分数不能为空"); + notice_box("要求/分数不能为空"); }else if(!/^[1-9][0-9]*$/.test(score)) { notice_box("分数必须是非零开头的数字"); }else if(quest_type !=3 && quest_type !=4 && standard_ans.length == 0) { From 84466f113d41d6aec86f090e44a034a62669e5d3 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 28 May 2019 19:36:13 +0800 Subject: [PATCH 31/51] 1 --- app/api/mobile/apis/cnmooc.rb | 8 ++++ app/services/cnmoocs_service.rb | 68 +++++++++++++++++++++++++++------ 2 files changed, 64 insertions(+), 12 deletions(-) diff --git a/app/api/mobile/apis/cnmooc.rb b/app/api/mobile/apis/cnmooc.rb index 42a6cfe3..026581cd 100644 --- a/app/api/mobile/apis/cnmooc.rb +++ b/app/api/mobile/apis/cnmooc.rb @@ -56,6 +56,14 @@ module Mobile CnmoocsService.new.login_educoder params end + desc "资源学习情况查询" + params do + requires :userId, type: Integer, desc: "用户ID" + requires :resouceId, type: String, desc: "资源唯一标示" + end + get 'get_students_data' do + CnmoocsService.new.get_students_data params + end end end diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index da119452..ba4271e4 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -6,15 +6,43 @@ class CnmoocsService page = params[:pageNo].to_i limit = params[:pageSize] || 16 offset = page * limit.to_i - shixuns = Shixun.select([:id, :identifier, :name, :myshixuns_count, :averge_star, :challenges_count, :trainee]). - where(status: 2, hidden: 0) - shixun_count = shixuns.count - pageCount = ((shixun_count / limit.to_f) == (shixun_count / limit)) ? (shixun_count / limit) : ((shixun_count / limit) + 1) - shixuns = shixuns.order("myshixuns_count desc").offset(offset).limit(limit) - shixun_list = shixun_data shixuns + resouces = [] + if params[:level].to_s == "1" + subjects = Subject.find_by_sql("SELECT subjects.id, subjects.name, subjects.status, COUNT(myshixuns.id) AS myshixun_member_count + FROM myshixuns, stage_shixuns, subjects WHERE myshixuns.shixun_id = stage_shixuns.shixun_id + AND stage_shixuns.subject_id = subjects.id AND `subjects`.`hidden` = 0 AND `subjects`.`status` = 2 + GROUP BY subjects.id ORDER BY myshixun_member_count DESC limit #{offset},#{limit}") + + subjects.each do |subject| + resouces << {resouceId: subject.id, parentId: nil, resouceName: subject.name, accessType: 0, nodeType: 0, + resouceType: 2} + end + totalCount = Subject.where(:status => 2, :hidden => 0).count + count = subjects.count + elsif params[:level].to_s == "2" + return {error: -1, messages: "请求二级及其更高目录时,parentId不能为空"} if params[:parentId].blank? + stages = Stage.where(:subject_id => params[:parentId]).offset(offset).limit(limit) + stages.each do |stage| + resouces << {resouceId: stage.id, parentId: params[:parentId], resouceName: stage.name, accessType: 0, nodeType: 0, + resouceType: 2} + end + totalCount = Stage.where(:subject_id => params[:parentId]).count + count = stages.count + elsif params[:level].to_s == "3" + return {error: -1, messages: "请求二级及其更高目录时,parentId不能为空"} if params[:parentId].blank? + shixun_ids = StageShixun.where(:stage_id => params[:parentId]).pluck(:shixun_id) + shixuns = Shixun.where(:id => shixun_ids).offset(offset).limit(limit) + shixuns.each do |shixun| + resouces << {resouceId: shixun.identifier, parentId: params[:parentId], resouceName: shixun.name, accessType: 2, + nodeType: 1, resouceType: 1} + end + totalCount = Shixun.where(:id => shixun_ids).count + count = shixuns.count + end + pageCount = ((totalCount / limit.to_f) == (totalCount / limit)) ? (totalCount / limit) : ((totalCount / limit) + 1) {error: 0, messages: "请求成功", - page: {count: shixuns.count, totalCount: shixun_count, pageNo: page, pageSize: limit, pageCount: pageCount}, - data: shixun_list } + page: {count: count, totalCount: totalCount, pageNo: page, pageSize: limit, pageCount: pageCount}, + data: {resouces: resouces} } end def search_resources params @@ -33,9 +61,9 @@ class CnmoocsService end def find_user params - user = User.find_by_mail params[:mail] - if user - {error: 0, messages: "找到用户"} + c_user = CnmoocUser.find_by_uuid(params[:userName]) + if c_user + {error: 0, messages: "找到用户", data: { userId: user.id } } else {error: -1, messages: "找不到用户"} end @@ -48,7 +76,7 @@ class CnmoocsService return { error: -1, messages: '用户已存在' } end - mail = c_user.generate_email + mail = params[:email] || c_user.generate_email create_params = { lastname: params[:name], mail: mail, @@ -94,6 +122,22 @@ class CnmoocsService { error: 0, messages: '成功', accessUrl: "#{Redmine::Configuration['educoder_domain']}/shixuns/#{shixun.id}" } end + def get_students_data params + subject = Subject.find_by_id params[:resouceId] + return {error: -1, messages: "资源id不对,请使用一级目录资源查找"} if subject.blank? + shixun_ids = StageShixun.where(:stage_id => subject.stages).pluck(:shixun_id) + myshixuns = Myshixun.where(:user_id => params[:userId], shixun_id: shixun_ids).includes(:games) + score = 0 + time = 0 + myshixuns.each do |myshixun| + score += myshixun.total_score + myshixun.games.each do |game| + time += game.consumes_time_int + end + end + {error: 0, messages: '成功', data: {totalTime: time, score: score * 10}} + end + private def shixun_data shixuns From 40e15f9f1dd6609df740b08cd409b7ee72acf799 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 28 May 2019 19:47:00 +0800 Subject: [PATCH 32/51] =?UTF-8?q?=E5=A5=BD=E5=A4=A7=E5=AD=A6api=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/cnmoocs_service.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index ba4271e4..6740a706 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -77,8 +77,9 @@ class CnmoocsService end mail = params[:email] || c_user.generate_email + name = params[:name] || "好大学_#{params[:userName]}" create_params = { - lastname: params[:name], + lastname: name, mail: mail, mail_notification: mail, login: generate_login('m'), From 7dd479f689ba820d3fa1dbdb6fece0609ac067b4 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Tue, 28 May 2019 19:57:17 +0800 Subject: [PATCH 33/51] fix cnmooc create user api --- app/services/cnmoocs_service.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index ba4271e4..36b69301 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -75,6 +75,7 @@ class CnmoocsService if c_user.present? return { error: -1, messages: '用户已存在' } end + c_user = CnmoocUser.new(uuid: params[:userName], name: params[:name]) mail = params[:email] || c_user.generate_email create_params = { From 528361da6fa355b20ccbc0a32824fbbc1b2b2776 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 28 May 2019 20:00:44 +0800 Subject: [PATCH 34/51] 1 --- app/services/cnmoocs_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index 054a765d..3a68055d 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -137,7 +137,7 @@ class CnmoocsService time += game.consumes_time_int end end - {error: 0, messages: '成功', data: {totalTime: time, score: score * 10}} + {error: 0, messages: '成功', data: {time: time, score: score * 10}} end From b1263a1cd088dd72a56a7a96fa5687e2359ceb03 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 28 May 2019 20:03:53 +0800 Subject: [PATCH 35/51] 1 --- app/services/cnmoocs_service.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index 3a68055d..a7605110 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -153,4 +153,10 @@ class CnmoocsService end {resouces: shixun_list} end + + # 为新创建的用户随机生成以m为前缀的用户名,m表示该用户是用邮箱注册 + def generate_login(login_pre) + us = UsersService.new + us.generate_user_login(login_pre) + end end \ No newline at end of file From b252983b7d9520dc58401e265a78b8ebe307c7b9 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 28 May 2019 20:07:05 +0800 Subject: [PATCH 36/51] 1 --- app/api/mobile/apis/cnmooc.rb | 1 - app/services/cnmoocs_service.rb | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/mobile/apis/cnmooc.rb b/app/api/mobile/apis/cnmooc.rb index 026581cd..1f37af91 100644 --- a/app/api/mobile/apis/cnmooc.rb +++ b/app/api/mobile/apis/cnmooc.rb @@ -31,7 +31,6 @@ module Mobile desc "创建用户" params do requires :userName, type: String, desc: "好大学用户名" - optional :name, type: String, desc: "用户姓名" end post "create_user" do CnmoocsService.new.create_user params diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index a7605110..52514a67 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -79,11 +79,12 @@ class CnmoocsService mail = params[:email] || c_user.generate_email name = params[:name] || "好大学_#{params[:userName]}" + login = generate_login('m') create_params = { lastname: name, mail: mail, mail_notification: mail, - login: generate_login('m'), + login: login, password: OauthController::DEFAULT_PASSWORD, certification: 1 } From 965b320e2c07f8ad5c412e37deadbcc7f569d905 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 28 May 2019 20:07:47 +0800 Subject: [PATCH 37/51] 1 --- app/services/cnmoocs_service.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index 52514a67..4c287455 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -80,6 +80,7 @@ class CnmoocsService mail = params[:email] || c_user.generate_email name = params[:name] || "好大学_#{params[:userName]}" login = generate_login('m') + Rails.logger.info("#######mail: #{mail}, #{name}, #{login}") create_params = { lastname: name, mail: mail, From 41195aaa6e372cc477d341d2c8ddfcb246e234f0 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Tue, 28 May 2019 20:27:10 +0800 Subject: [PATCH 38/51] fix create cnmooc --- app/services/cnmoocs_service.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index 4c287455..d231ceae 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -85,12 +85,14 @@ class CnmoocsService lastname: name, mail: mail, mail_notification: mail, - login: login, password: OauthController::DEFAULT_PASSWORD, certification: 1 } ActiveRecord::Base.transaction do - user = User.create!(create_params) + user = User.new(create_params) + # login 有问题,只能这样赋值 + user.login = login + user.save! UserExtensions.create!(user_id: user.id, school_id: School.first.id, identity: 4, gender: 0) From 30cd567050ef67c9a853e5c720296d08e8eaf0f0 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Tue, 28 May 2019 20:31:12 +0800 Subject: [PATCH 39/51] fix --- app/services/cnmoocs_service.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index d231ceae..fb04ded8 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -88,10 +88,10 @@ class CnmoocsService password: OauthController::DEFAULT_PASSWORD, certification: 1 } + user = User.new(create_params) + # login 有问题,只能这样赋值 + user.login = login ActiveRecord::Base.transaction do - user = User.new(create_params) - # login 有问题,只能这样赋值 - user.login = login user.save! UserExtensions.create!(user_id: user.id, school_id: School.first.id, identity: 4, gender: 0) From e8fd8b97a3d62d4e62c1acc437a43f09a02abc2f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 28 May 2019 20:35:33 +0800 Subject: [PATCH 40/51] 1 --- app/api/mobile/apis/cnmooc.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/mobile/apis/cnmooc.rb b/app/api/mobile/apis/cnmooc.rb index 1f37af91..96b10101 100644 --- a/app/api/mobile/apis/cnmooc.rb +++ b/app/api/mobile/apis/cnmooc.rb @@ -22,7 +22,7 @@ module Mobile desc " 查找用户" params do - requires :mail, type: String, desc: "邮箱地址" + requires :userName, type: String, desc: "好大学用户名" end get 'find_user' do CnmoocsService.new.find_user params From f47cf352337eeeeb05bca4a3c5f940645ef93036 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 28 May 2019 20:37:19 +0800 Subject: [PATCH 41/51] 1 --- app/services/cnmoocs_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index fb04ded8..903db58d 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -63,7 +63,7 @@ class CnmoocsService def find_user params c_user = CnmoocUser.find_by_uuid(params[:userName]) if c_user - {error: 0, messages: "找到用户", data: { userId: user.id } } + {error: 0, messages: "找到用户", data: { userId: c_user.user_id } } else {error: -1, messages: "找不到用户"} end From b4ec3363efa4f9c733b12765dbf8d0b8f396b2a6 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 28 May 2019 20:51:43 +0800 Subject: [PATCH 42/51] 1 --- app/api/mobile/api.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index d13dc61f..958fe6a9 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -34,7 +34,7 @@ module Mobile version 'v1', using: :path format :json content_type :json, "application/json;charset=UTF-8" - # use ActionDispatch::Session::CookieStore + use ActionDispatch::Session::CookieStore require 'digest' use Mobile::Middleware::ErrorHandler From 1fb7c35c30e73b1890a61718197e6ea8eb62f4de Mon Sep 17 00:00:00 2001 From: p31729568 Date: Tue, 28 May 2019 20:56:53 +0800 Subject: [PATCH 43/51] fix session --- app/api/mobile/api.rb | 6 ++++++ app/api/mobile/apis/cnmooc.rb | 5 +++++ app/services/cnmoocs_service.rb | 5 ----- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index 958fe6a9..69bd4d44 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -109,6 +109,12 @@ module Mobile return uw.user if uw end + third_party_user_id = session[:third_party_user_id] + if third_party_user_id + c_user = UserSource.find_by_id(session[:third_party_user_id]) + return c_user.user if c_user + end + token = ApiKey.where(access_token: params[:token]).first if token && !token.expired? return User.find(token.user_id) diff --git a/app/api/mobile/apis/cnmooc.rb b/app/api/mobile/apis/cnmooc.rb index 96b10101..d67a390d 100644 --- a/app/api/mobile/apis/cnmooc.rb +++ b/app/api/mobile/apis/cnmooc.rb @@ -43,6 +43,11 @@ module Mobile requires :accessType, type: Integer, desc: "资源类型" end get "source_url" do + if session[:third_party_user_id].blank? + user = User.find(params[:userId]) + session[:third_party_user_id] = user.user_source.id + end + CnmoocsService.new.source_url(params) end diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index 903db58d..caba8ebb 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -115,11 +115,6 @@ class CnmoocsService end def source_url(params) - if session[:third_party_user_id].blank? - user = User.find(params[:userId]) - session[:third_party_user_id] = user.user_source.id - end - shixun = Shixun.find_by_identifier(params[:resouceId]) if shixun.blank? return { error: -1, messages: '资源不存在' } From 23d8e023dfe747a4e7ff1c790487ecd1fee597a6 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 28 May 2019 21:01:33 +0800 Subject: [PATCH 44/51] 1 --- app/services/cnmoocs_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index caba8ebb..34d97d6c 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -33,7 +33,7 @@ class CnmoocsService shixun_ids = StageShixun.where(:stage_id => params[:parentId]).pluck(:shixun_id) shixuns = Shixun.where(:id => shixun_ids).offset(offset).limit(limit) shixuns.each do |shixun| - resouces << {resouceId: shixun.identifier, parentId: params[:parentId], resouceName: shixun.name, accessType: 2, + resouces << {resouceId: shixun.id, parentId: params[:parentId], resouceName: shixun.name, accessType: 2, nodeType: 1, resouceType: 1} end totalCount = Shixun.where(:id => shixun_ids).count @@ -120,7 +120,7 @@ class CnmoocsService return { error: -1, messages: '资源不存在' } end - { error: 0, messages: '成功', accessUrl: "#{Redmine::Configuration['educoder_domain']}/shixuns/#{shixun.id}" } + { error: 0, messages: '成功', accessUrl: "#{Redmine::Configuration['educoder_domain']}/shixuns/#{shixun.identifier}" } end def get_students_data params From 3e416f2538c1b56a8082958b0d4345e3458a2a81 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 28 May 2019 21:12:06 +0800 Subject: [PATCH 45/51] 1 --- app/services/cnmoocs_service.rb | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index 34d97d6c..e1bae88d 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -124,19 +124,22 @@ class CnmoocsService end def get_students_data params - subject = Subject.find_by_id params[:resouceId] - return {error: -1, messages: "资源id不对,请使用一级目录资源查找"} if subject.blank? - shixun_ids = StageShixun.where(:stage_id => subject.stages).pluck(:shixun_id) - myshixuns = Myshixun.where(:user_id => params[:userId], shixun_id: shixun_ids).includes(:games) - score = 0 - time = 0 - myshixuns.each do |myshixun| - score += myshixun.total_score + shixun = Shixun.find_by_id params[:resouceId] + return {error: -1, messages: "资源id不对,请使用资源的id查找"} if shixun.blank? + # shixun_ids = StageShixun.where(:stage_id => subject.stages).pluck(:shixun_id) + #myshixuns = Myshixun.where(:user_id => params[:userId], shixun_id: shixun_ids).includes(:games) + myshixun = shixun.myshixuns.where(:user_id => params[:userId]).includes(:games) + if myshixun + score = myshixun.total_score + time = 0 myshixun.games.each do |game| time += game.consumes_time_int end + {error: 0, messages: '成功', data: {time: time, score: score * 10}} + else + {error: -1, messages: '用户还未开始学习此资源'} end - {error: 0, messages: '成功', data: {time: time, score: score * 10}} + end From dce940523ae7a3ce10d8ee01da60a75e84edfc07 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 28 May 2019 21:21:21 +0800 Subject: [PATCH 46/51] 1 --- app/services/cnmoocs_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index e1bae88d..a30e2ef2 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -129,7 +129,7 @@ class CnmoocsService # shixun_ids = StageShixun.where(:stage_id => subject.stages).pluck(:shixun_id) #myshixuns = Myshixun.where(:user_id => params[:userId], shixun_id: shixun_ids).includes(:games) myshixun = shixun.myshixuns.where(:user_id => params[:userId]).includes(:games) - if myshixun + if myshixun.present? score = myshixun.total_score time = 0 myshixun.games.each do |game| From 257f55ec006bc6a1ecfecab5aacdd23d6729fde7 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 28 May 2019 21:26:41 +0800 Subject: [PATCH 47/51] 1 --- app/services/cnmoocs_service.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index a30e2ef2..9ec02bfd 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -126,9 +126,7 @@ class CnmoocsService def get_students_data params shixun = Shixun.find_by_id params[:resouceId] return {error: -1, messages: "资源id不对,请使用资源的id查找"} if shixun.blank? - # shixun_ids = StageShixun.where(:stage_id => subject.stages).pluck(:shixun_id) - #myshixuns = Myshixun.where(:user_id => params[:userId], shixun_id: shixun_ids).includes(:games) - myshixun = shixun.myshixuns.where(:user_id => params[:userId]).includes(:games) + myshixun = shixun.myshixuns.where(:user_id => params[:userId]).includes(:games).first if myshixun.present? score = myshixun.total_score time = 0 From 0f359082e5df1b7e0c06b687857b1d7440ec9c37 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 29 May 2019 08:51:22 +0800 Subject: [PATCH 48/51] =?UTF-8?q?=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E8=AF=84=E6=B5=8B=E6=97=B6=E9=97=B4=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=A2=9E=E5=8A=A0=E6=9C=80=E5=A4=A7=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/managements/evaluate_simple.html.erb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/managements/evaluate_simple.html.erb b/app/views/managements/evaluate_simple.html.erb index a278395c..c01b58bc 100644 --- a/app/views/managements/evaluate_simple.html.erb +++ b/app/views/managements/evaluate_simple.html.erb @@ -14,8 +14,9 @@
  • - - + + + @@ -35,7 +36,8 @@ - + + <% end %> From 83373311033932f1797451fc89db83aabeffde36 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 29 May 2019 10:38:41 +0800 Subject: [PATCH 49/51] =?UTF-8?q?=E5=90=8E=E7=AB=AF-=E8=AF=95=E5=8D=B7?= =?UTF-8?q?=E3=80=81=E8=AF=95=E5=8D=B7=E9=A2=98=E5=BA=93=E7=9A=84=E5=AE=9E?= =?UTF-8?q?=E8=AE=AD=E9=A2=98=E5=A2=9E=E5=8A=A0=E6=94=B9=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_bank_controller.rb | 2 ++ app/controllers/exercise_controller.rb | 5 ++++- app/controllers/question_banks_controller.rb | 2 +- app/helpers/application_helper.rb | 3 ++- app/views/exercise/_edit_shixun.html.erb | 2 +- app/views/exercise/_exercise_form.html.erb | 2 +- app/views/exercise/_exercise_student.html.erb | 2 +- .../exercise/_exercise_student_result.html.erb | 2 +- app/views/exercise/_new_shixun.html.erb | 5 ++++- app/views/exercise/_show_shixun.html.erb | 2 +- .../exercise/student_exercise_list.html.erb | 2 +- app/views/exercise_bank/_edit_shixun.html.erb | 5 ++++- app/views/exercise_bank/_new_shixun.html.erb | 5 ++++- app/views/exercise_bank/_show_shixun.html.erb | 2 +- app/views/exercise_bank/show.html.erb | 2 +- .../homework_bank/_send_homework_bank.html.erb | 15 ++++++++++++++- ...90529014121_add_shixun_name_to_ex_question.rb | 14 ++++++++++++++ public/javascripts/edu/base_edu.js | 10 ---------- public/javascripts/edu/course.js | 16 ++++++++++++++++ 19 files changed, 73 insertions(+), 25 deletions(-) create mode 100644 db/migrate/20190529014121_add_shixun_name_to_ex_question.rb diff --git a/app/controllers/exercise_bank_controller.rb b/app/controllers/exercise_bank_controller.rb index e4fa6727..6b8090dd 100644 --- a/app/controllers/exercise_bank_controller.rb +++ b/app/controllers/exercise_bank_controller.rb @@ -104,6 +104,7 @@ class ExerciseBankController < ApplicationController :question_type => params[:question_type] || 1, :question_number => @exercise.exercise_bank_questions.count + 1, :question_score => params[:question_score], + :shixun_name => params[:question_type] == '5' ? params[:shixun_name] : nil, :shixun_id => params[:shixun], :max_choices => params[:max_choices].to_i || 0, :min_choices => params[:min_choices].to_i || 0 @@ -271,6 +272,7 @@ class ExerciseBankController < ApplicationController end end if @exercise_question.question_type == 5 + @exercise_question.shixun_name = params[:shixun_name].strip if !params[:shixun_name].blank? question_score = 0 @exercise_question.exercise_bank_shixun_challenges.each_with_index do |challenge, index| challenge.question_score = params[:question_score][index] diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 23024a78..ee5705fb 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -372,6 +372,7 @@ class ExerciseController < ApplicationController :question_type => params[:question_type] || 1, :question_number => @exercise.exercise_questions.count + 1, :question_score => params[:question_type] == '5' ? 0 : params[:question_score], + :shixun_name => params[:question_type] == '5' ? params[:shixun_name] : nil, :shixun_id => params[:shixun] } @exercise_questions = @exercise.exercise_questions.new option @@ -512,6 +513,7 @@ class ExerciseController < ApplicationController end end if @exercise_question.question_type == 5 + @exercise_question.shixun_name = params[:shixun_name].strip if !params[:shixun_name].blank? question_score = 0 @exercise_question.exercise_shixun_challenges.each_with_index do |challenge, index| challenge.question_score = params[:question_score][index] @@ -1508,7 +1510,8 @@ class ExerciseController < ApplicationController :question_type => q[:question_type] || 1, :question_number => q[:question_number], :question_score => q[:question_score], - :shixun_id => q[:shixun_id] + :shixun_id => q[:shixun_id], + :shixun_name => q[:shixun_name] } exercise_bank_question = exercise_bank.exercise_bank_questions.new option diff --git a/app/controllers/question_banks_controller.rb b/app/controllers/question_banks_controller.rb index 96f6db3b..cffecba1 100644 --- a/app/controllers/question_banks_controller.rb +++ b/app/controllers/question_banks_controller.rb @@ -117,7 +117,7 @@ class QuestionBanksController < ApplicationController else @courses = User.current.courses.where("is_delete = 0 and is_end = 0").select{ |course| User.current.has_teacher_role(course)} end - @homework_ids = params[:check_homework_bank] || params[:bank_id].split(" ") + @homework_ids = params[:check_homework_bank] || params[:bank_id].split(" ") unless params[:is_observe] @search = params[:search] respond_to do |format| format.js diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 35449aad..34fa1a8d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -7034,7 +7034,8 @@ def quote_exercise_bank exercise, course :question_type => q[:question_type] || 1, :question_number => q[:question_number], :question_score => q[:question_score], - :shixun_id => q[:shixun_id] + :shixun_id => q[:shixun_id], + :shixun_name => q[:shixun_name] } exercise_question = new_exercise.exercise_questions.new option diff --git a/app/views/exercise/_edit_shixun.html.erb b/app/views/exercise/_edit_shixun.html.erb index 9c0f130b..ef96f3b7 100644 --- a/app/views/exercise/_edit_shixun.html.erb +++ b/app/views/exercise/_edit_shixun.html.erb @@ -3,7 +3,7 @@

    实训题

    - +

  • diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index ca3080e4..bee149fd 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -111,7 +111,7 @@ var score = $.trim($("#poll_question_score_"+ id).val()); var standard_ans = $.trim($("#exercise_choice_" + id).val()); if(name===""){ - notice_box("题目标题"); + notice_box("题目标题不能为空"); } if(title.length == 0 || score.length == 0){ notice_box("要求/分数不能为空"); diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index add9d655..ec47f1c0 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -162,7 +162,7 @@ <% end %> <% if exercise_question.question_type == 5 %> -

    <%= exercise_question.shixun.name %>

    +

    <%= exercise_question.shixun_name %>

    <% end %>
    <%= exercise_question.question_title.html_safe %>
    <% case exercise_question.question_type %> diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb index 0dd656be..6d48573f 100644 --- a/app/views/exercise/_exercise_student_result.html.erb +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -140,7 +140,7 @@ <% end %> <% if exercise_question.question_type == 5 %> -

    <%= exercise_question.shixun.name %>

    +

    <%= exercise_question.shixun_name %>

    <% end %>
    <%= exercise_question.question_title.html_safe %>
    <% case exercise_question.question_type %> diff --git a/app/views/exercise/_new_shixun.html.erb b/app/views/exercise/_new_shixun.html.erb index 1cff068f..6ce2cd68 100644 --- a/app/views/exercise/_new_shixun.html.erb +++ b/app/views/exercise/_new_shixun.html.erb @@ -8,7 +8,10 @@ -

    <%= @shixun.name %>

    +

    + + +

  • diff --git a/app/views/exercise/_show_shixun.html.erb b/app/views/exercise/_show_shixun.html.erb index 92feef9d..75f460ec 100644 --- a/app/views/exercise/_show_shixun.html.erb +++ b/app/views/exercise/_show_shixun.html.erb @@ -16,7 +16,7 @@

    <% end %> -

    <%= exercise_question.shixun.name %>

    +

    <%= exercise_question.shixun_name %>

    <%= exercise_question.question_title.html_safe %>
    <% exercise_question.exercise_shixun_challenges.each_with_index do |exercise_challenge,index| %> diff --git a/app/views/exercise/student_exercise_list.html.erb b/app/views/exercise/student_exercise_list.html.erb index 3632b4d7..b8335515 100644 --- a/app/views/exercise/student_exercise_list.html.erb +++ b/app/views/exercise/student_exercise_list.html.erb @@ -256,7 +256,7 @@ <% end %>
    <% if exercise_question.question_type == 5 %> -

    <%= exercise_question.shixun.name %>

    +

    <%= exercise_question.shixun_name %>

    <% end %>
    <%= exercise_question.question_title.html_safe %> diff --git a/app/views/exercise_bank/_edit_shixun.html.erb b/app/views/exercise_bank/_edit_shixun.html.erb index 41383767..7aa84e9f 100644 --- a/app/views/exercise_bank/_edit_shixun.html.erb +++ b/app/views/exercise_bank/_edit_shixun.html.erb @@ -1,7 +1,10 @@ <%= form_for("",:url => update_exercise_question_exercise_bank_index_path(:exercise_question => exercise_question.id),:html => {:id => "update_exercise_question_#{exercise_question.id}"}) do |f|%>

    实训题

    -

    <%= exercise_question.shixun.name %>

    +

    + + +

  • diff --git a/app/views/exercise_bank/_new_shixun.html.erb b/app/views/exercise_bank/_new_shixun.html.erb index 36af84ad..140ee9b2 100644 --- a/app/views/exercise_bank/_new_shixun.html.erb +++ b/app/views/exercise_bank/_new_shixun.html.erb @@ -8,7 +8,10 @@ -

    <%= @shixun.name %>

    +

    + + +

  • diff --git a/app/views/exercise_bank/_show_shixun.html.erb b/app/views/exercise_bank/_show_shixun.html.erb index cf2a9b2b..e426fd0e 100644 --- a/app/views/exercise_bank/_show_shixun.html.erb +++ b/app/views/exercise_bank/_show_shixun.html.erb @@ -14,7 +14,7 @@

    -

    <%= exercise_question.shixun.name %>

    +

    <%= exercise_question.shixun_name %>

    <%= exercise_question.question_title.html_safe %>
    <% exercise_question.exercise_bank_shixun_challenges.each_with_index do |exercise_challenge,index| %> diff --git a/app/views/exercise_bank/show.html.erb b/app/views/exercise_bank/show.html.erb index 0fb5e2ca..14712a92 100644 --- a/app/views/exercise_bank/show.html.erb +++ b/app/views/exercise_bank/show.html.erb @@ -80,7 +80,7 @@ <% end %>
    <% if exercise_question.question_type == 5 %> -

    <%= exercise_question.shixun.name %>

    +

    <%= exercise_question.shixun_name %>

    <% end %>
    <%= exercise_question.question_title.html_safe %>
    <% case exercise_question.question_type %> diff --git a/app/views/homework_bank/_send_homework_bank.html.erb b/app/views/homework_bank/_send_homework_bank.html.erb index 3127aecd..6b935521 100644 --- a/app/views/homework_bank/_send_homework_bank.html.erb +++ b/app/views/homework_bank/_send_homework_bank.html.erb @@ -31,4 +31,17 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/db/migrate/20190529014121_add_shixun_name_to_ex_question.rb b/db/migrate/20190529014121_add_shixun_name_to_ex_question.rb new file mode 100644 index 00000000..8aa02878 --- /dev/null +++ b/db/migrate/20190529014121_add_shixun_name_to_ex_question.rb @@ -0,0 +1,14 @@ +class AddShixunNameToExQuestion < ActiveRecord::Migration + def change + add_column :exercise_questions, :shixun_name, :string + add_column :exercise_bank_questions, :shixun_name, :string + + ExerciseQuestion.where(question_type: 5).each do |question| + question.update_column("shixun_name", question.shixun.try(:name)) + end + + ExerciseBankQuestion.where(question_type: 5).each do |question| + question.update_column("shixun_name", question.shixun.try(:name)) + end + end +end diff --git a/public/javascripts/edu/base_edu.js b/public/javascripts/edu/base_edu.js index 8167249c..1963d1cb 100644 --- a/public/javascripts/edu/base_edu.js +++ b/public/javascripts/edu/base_edu.js @@ -1361,16 +1361,6 @@ function choose_course_to_send_hb(){ } } -function search_hw_course(url){ - $.ajax({ - url: url, - type: 'post', - data: {search: $("#hb_search_course_input").val(), is_observe: true}, - success: function(data){ - } - }); -} - function submit_send_hb_to_course(){ if($("input[name='course_id']:checked").length >= 1){ $("#search_course_notice_h").html("").hide(); diff --git a/public/javascripts/edu/course.js b/public/javascripts/edu/course.js index 330dbea7..98163bda 100644 --- a/public/javascripts/edu/course.js +++ b/public/javascripts/edu/course.js @@ -1103,6 +1103,15 @@ function add_ex_question(doc,quest_type) var title = $.trim($("#poll_questions_title").val()); var score = $.trim($("#question_score").val()); var standard_ans = $.trim($("#exercise_choice_" + quest_type).val()); + + if (quest_type == 5) { + var name = $.trim($("#poll_questions_name").val()); + if(name===""){ + notice_box("题目标题不能为空"); + result = false; + } + } + if(title.length == 0){ if(quest_type != 5){ notice_box("题目标题不能为空"); @@ -1414,6 +1423,13 @@ function edit_poll_question(doc,id,quest_type) { var title = $.trim($("#poll_questions_title_" + id).val()); var score = $.trim($("#poll_question_score_" + id).val()); var standard_ans = $.trim($("#exercise_choice_" + id).val()); + if (quest_type == 5) { + var name = $.trim($("#poll_questions_name_" + id).val()); + if(name===""){ + notice_box("题目标题不能为空"); + result = false; + } + } if (title.length == 0) { if (quest_type != 5) { notice_box("题目标题不能为空"); From 92a08caf9506f9029ffe3d6d62a096b5bafc021a Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 29 May 2019 10:53:48 +0800 Subject: [PATCH 50/51] 1 --- app/views/managements/evaluate_simple.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/managements/evaluate_simple.html.erb b/app/views/managements/evaluate_simple.html.erb index c01b58bc..6d05aedf 100644 --- a/app/views/managements/evaluate_simple.html.erb +++ b/app/views/managements/evaluate_simple.html.erb @@ -36,8 +36,8 @@
  • - - + + <% end %> From c86d364744b93fa428c77f85c831dfc059842e27 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 29 May 2019 13:56:12 +0800 Subject: [PATCH 51/51] =?UTF-8?q?=E8=AF=95=E7=94=A8=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=A2=9E=E5=8A=A0=E9=82=AE=E7=AE=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 0f62dbe8..54b7ffe6 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -4185,7 +4185,7 @@ end sheet1 = book.create_worksheet :name => "users" blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 sheet1.row(0).default_format = blue - sheet1.row(0).concat(["用户姓名","性别","职业","职称","地区"," 单位","子单位","注册时间","最后登录时间","授权"]) + sheet1.row(0).concat(["用户姓名","性别","职业","职称","地区"," 单位","子单位","注册时间","最后登录时间","授权", "邮箱"]) count_row = 1 users.each do |user| sheet1[count_row,0] = user.try(:show_real_name) @@ -4198,6 +4198,7 @@ end sheet1[count_row,7] = format_time user.created_on sheet1[count_row,8] = format_time user.last_login_on sheet1[count_row,9] = user.trial_authorization + sheet1[count_row,10] = user.mail count_row += 1 end book.write xls_report
    序号总耗时ID总耗时 作品更新 文件更新 中间层总耗时 pull代码 pod启动 pod执行中间层回传回传时间 前端轮询回调结果存储结果存储 创建时间实训名称唯一表示实训名称
    <%= index %><%= record.id %> <%= record.consume_time %> <%= record.student_work %> <%= record.file_update %><%= record.front_js %> <%= record.test_cases %> <%= format_time record.created_at %><%= record.identifier %> <%= link_to record.shixun.try(:name), task_path(record.game), :target => "_blank", :title => "#{record.shixun.try(:name)}" %>
    回传时间 前端轮询 结果存储创建时间唯一表示创建时间最大执行时间唯一标识 实训名称
    <%= record.front_js %> <%= record.test_cases %> <%= format_time record.created_at %><%= record.identifier %><%= record.shixun.exec_time %><%= record.shixun.identifier %> <%= link_to record.shixun.try(:name), task_path(record.game), :target => "_blank", :title => "#{record.shixun.try(:name)}" %>
    <%= record.front_js %> <%= record.test_cases %> <%= format_time record.created_at %><%= record.shixun.exec_time %><%= record.shixun.identifier %><%= record.shixun.try(:exec_time) %><%= record.shixun.try(:identifier) %> <%= link_to record.shixun.try(:name), task_path(record.game), :target => "_blank", :title => "#{record.shixun.try(:name)}" %>