From 4b1f4c7845876eb022f7481a9bb4bb334a7f553e Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 11 Sep 2019 14:48:23 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- app/views/homework_commons/works_list.json.jbuilder | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index e4f0ad641..7ba2c65fc 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -131,7 +131,7 @@ class ShixunsController < ApplicationController offset = (page.to_i - 1) * (limit.to_i) order = params[:order] || "desc" ## 搜索关键字创建者、实训名称、院校名称 - keyword = params[:search] + keyword = params[:search].blank? ? "*" : params[:search] @shixuns = Shixun.search keyword, where: {id: @shixuns.pluck(:id)}, order: {"myshixuns_count" => order}, limit: limit, offset: offset @total_count = @shixuns.total_count diff --git a/app/views/homework_commons/works_list.json.jbuilder b/app/views/homework_commons/works_list.json.jbuilder index 08c269670..e626cae13 100644 --- a/app/views/homework_commons/works_list.json.jbuilder +++ b/app/views/homework_commons/works_list.json.jbuilder @@ -40,6 +40,7 @@ elsif @user_course_identity == Course::STUDENT json.efficiency work_score_format(@work.efficiency, true, @score_open) json.eff_score work_score_format(@work.eff_score, true, @score_open) json.complete_count @work.myshixun.try(:passed_count) + # json.redo_work student_redo_work(@work) else json.(@work, :id, :work_status, :update_time, :ultimate_score) From 254f9cc569a15a6eb1f254f96155609be7615050 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Sep 2019 15:07:56 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E9=87=8D=E7=BD=AEvnc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 84 ++++++++++++++++++++--------- config/routes.rb | 1 + 2 files changed, 61 insertions(+), 24 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index b35f2996f..a77b72708 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -61,29 +61,7 @@ class GamesController < ApplicationController tomcat_url: edu_setting('cloud_tomcat_php'), is_teacher: is_teacher, myshixun_manager: myshixun_manager, git_url: (@shixun.vnc ? repo_url(@myshixun.repo_path) : "")} if @shixun.vnc - begin - shixun_tomcat = edu_setting('cloud_bridge') - service_host = edu_setting('vnc_url') - uri = "#{shixun_tomcat}/bridge/vnc/getvnc" - params = {tpiID: @myshixun.id, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(@shixun))}"} - res = uri_post uri, params - logger.info("###############---- ") - if res && res['code'].to_i != 0 - raise("实训云平台繁忙(繁忙等级:99)") - end - - if request.subdomain == "pre-newweb" - # 无域名版本 - @vnc_url = "http://#{service_host}:#{res['port']}/vnc_lite.html?password=headless" - else - # 有域名版本 - @vnc_url = "https://#{res['port']}.#{service_host}/vnc_lite.html?password=headless" - end - - @vnc_evaluate = @shixun.vnc_evaluate - rescue Exception => e - Rails.logger.error(e.message) - end + get_vnc_link(@game) end # 区分选择题和编程题,st:0编程题; @@ -110,6 +88,21 @@ class GamesController < ApplicationController end end + def reset_vnc_link + begin + # 删除vnc的pod + delete_vnc(@game) + # 重新连接 + get_vnc_link(@game) + + render :json => {status: 1, message: "重置VNC成功", data: {vnc_url: @vnc_url, vnc_evaluate: @vnc_evaluate}} + rescue Exception => e + logger.error("############'#{e.message}'") + tip_exception("实训云平台繁忙") + end + + end + # 查看效果 # todo : 这块代码有很大的改进空间 # todo : 中文排序问题 @@ -880,7 +873,7 @@ class GamesController < ApplicationController choose.challenge_questions.each do |question| position = question.position option_name = question.option_name - challenge_question << {:positon => position, :option_name => option_name} + challenge_question <<{:positon => position, :option_name => option_name} end # actual_output为空表示暂时没有评测答题,不允许查看 actual_output = output.try(:actual_output).try(:strip) @@ -941,4 +934,47 @@ class GamesController < ApplicationController game.myshixun.update_column(:updated_at, Time.now) end + # vnc连接 + def get_vnc_link game + begin + shixun = game.myshixun.shixun + shixun_tomcat = edu_setting('cloud_bridge') + service_host = edu_setting('vnc_url') + uri = "#{shixun_tomcat}/bridge/vnc/getvnc" + params = {tpiID: game.myshixun.id, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"} + res = uri_post uri, params + if res && res['code'].to_i != 0 + raise("实训云平台繁忙(繁忙等级:99)") + end + @vnc_url = + if request.subdomain == "pre-newweb" + # 无域名版本 + "http://#{service_host}:#{res['port']}/vnc_lite.html?password=headless" + else + # 有域名版本 + "https://#{res['port']}.#{service_host}/vnc_lite.html?password=headless" + end + @vnc_evaluate = shixun.vnc_evaluate + rescue Exception => e + Rails.logger.error(e.message) + end + end + + # 删除pod + def delete_vnc game + myshixun_id = game.myshixun_id + digest = game.identifier + edu_setting('bridge_secret_key') + digest_key = Digest::SHA1.hexdigest("#{digest}") + begin + shixun_tomcat = edu_setting('cloud_bridge') + uri = "#{shixun_tomcat}/bridge/vnc/delete" + Rails.logger.info("#{current_user} => cloese_webssh digest is #{digest}") + params = {:tpiID => myshixun_id, :digestKey => digest_key, :identifier => game.identifier} + res = uri_post uri, params + if res && res['code'].to_i != 0 + raise("实训云平台繁忙(繁忙等级:110)") + end + end + end + end diff --git a/config/routes.rb b/config/routes.rb index 0d6e108ad..15a91b910 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -161,6 +161,7 @@ Rails.application.routes.draw do get :picture_display get :sync_codes get :close_webssh + get :reset_vnc_link get :get_answer_info get :unlock_answer get :check_test_sets From 8f61078aad8e287bd5cd0ae50e3a1916e7f7b1b8 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Sep 2019 15:08:37 +0800 Subject: [PATCH 3/8] 1 --- app/controllers/games_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index a77b72708..f5dcdd037 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -968,7 +968,7 @@ class GamesController < ApplicationController begin shixun_tomcat = edu_setting('cloud_bridge') uri = "#{shixun_tomcat}/bridge/vnc/delete" - Rails.logger.info("#{current_user} => cloese_webssh digest is #{digest}") + Rails.logger.info("#{current_user} => cloese_vnc digest is #{digest}") params = {:tpiID => myshixun_id, :digestKey => digest_key, :identifier => game.identifier} res = uri_post uri, params if res && res['code'].to_i != 0 From cad878c6da8544549279db5a4dc77a14a62e87f6 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 11 Sep 2019 15:31:20 +0800 Subject: [PATCH 4/8] =?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=81=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_commons_controller.rb | 2 +- app/helpers/homework_commons_helper.rb | 5 +++++ app/views/homework_commons/works_list.json.jbuilder | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 3b395bab2..06ee8feee 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -113,7 +113,7 @@ class HomeworkCommonsController < ApplicationController if @user_course_identity == Course::STUDENT @work = @homework.user_work(current_user.id) # 学生访问列表时计算个人成绩 - if @homework.homework_type == "practice" + if @homework.homework_type == "practice" && !@homework.end_or_late myshixun = Myshixun.find_by(shixun_id: @shixun.id, user_id: current_user.id) if @work && myshixun challenge_settings = @homework.homework_challenge_settings diff --git a/app/helpers/homework_commons_helper.rb b/app/helpers/homework_commons_helper.rb index a3ed43405..e10917664 100644 --- a/app/helpers/homework_commons_helper.rb +++ b/app/helpers/homework_commons_helper.rb @@ -237,4 +237,9 @@ module HomeworkCommonsHelper def anon_comments user, work_id StudentWorksScore.where(student_work_id: work_id, reviewer_role: 3, user_id: user.id) end + + def student_redo_work work, homework + publish_time = homework.homework_group_setting(work.user_id)&.publish_time + work.myshixun && publish_time && work.myshixun.games.where("status = 2 and answer_open = 1 and end_time <= '#{publish_time}'").count > 0 + end end diff --git a/app/views/homework_commons/works_list.json.jbuilder b/app/views/homework_commons/works_list.json.jbuilder index e626cae13..fe05866e6 100644 --- a/app/views/homework_commons/works_list.json.jbuilder +++ b/app/views/homework_commons/works_list.json.jbuilder @@ -31,7 +31,7 @@ elsif @user_course_identity == Course::STUDENT json.left_time left_time @homework, @current_user.id if @homework.homework_type == "practice" - json.(@work, :id, :work_status, :update_time, :ultimate_score) + json.(@work, :id, :work_status, :update_time, :ultimate_score, :myshixun_id) json.calculation_time @work.calculation_time json.late_penalty @work.late_penalty if @homework.allow_late json.cost_time @work.myshixun.try(:total_spend_time) @@ -40,7 +40,7 @@ elsif @user_course_identity == Course::STUDENT json.efficiency work_score_format(@work.efficiency, true, @score_open) json.eff_score work_score_format(@work.eff_score, true, @score_open) json.complete_count @work.myshixun.try(:passed_count) - # json.redo_work student_redo_work(@work) + json.redo_work @homework.end_or_late ? false : student_redo_work(@work, @homework) else json.(@work, :id, :work_status, :update_time, :ultimate_score) From 9279722fc439927bf886ba1c6fb86492acb3aa4f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 11 Sep 2019 15:32:19 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E5=AD=A6=E4=B9=A0?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/online_learning.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/courses/online_learning.json.jbuilder b/app/views/courses/online_learning.json.jbuilder index 057ec61cf..b48cd9e23 100644 --- a/app/views/courses/online_learning.json.jbuilder +++ b/app/views/courses/online_learning.json.jbuilder @@ -5,6 +5,7 @@ end # json.description @subject&.description json.start_learning @start_learning +json.subject_id @subject.id json.learned @start_learning ? @course.my_subject_progress : 0 From 14b7c28d1dd47dc883d1a0159afe274d5ac9a0a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Wed, 11 Sep 2019 15:36:01 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=81=AB=E7=8B=90?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/tpm/TPMsettings/TPMsettings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js index a46654fe6..f78d62637 100644 --- a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js +++ b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js @@ -2355,10 +2355,10 @@ export default class TPMsettings extends Component { return(
+