From 747ec3f858fe8087b8aaaee7f13282b810e9c13f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Dec 2019 10:59:35 +0800 Subject: [PATCH 01/25] =?UTF-8?q?=E5=AE=9E=E8=AE=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/shixun.rb | 1 + db/migrate/20191212025227_add_public_status_to_shixun.rb | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 db/migrate/20191212025227_add_public_status_to_shixun.rb diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 0f9842739..08ddee08e 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -3,6 +3,7 @@ class Shixun < ApplicationRecord attr_accessor :page_no #管理员页面 实训配置更新状态时,需要接受page_no参数 # status: 0:编辑 1:申请发布 2:正式发布 3:关闭 -1:软删除 + # # hide_code: 隐藏代码窗口 # code_hidden: 隐藏代码目录 # task_pass: 跳关 diff --git a/db/migrate/20191212025227_add_public_status_to_shixun.rb b/db/migrate/20191212025227_add_public_status_to_shixun.rb new file mode 100644 index 000000000..0111db6ec --- /dev/null +++ b/db/migrate/20191212025227_add_public_status_to_shixun.rb @@ -0,0 +1,4 @@ +class AddPublicStatusToShixun < ActiveRecord::Migration[5.2] + def change + end +end From 6a25f12cc57467c3b3b035c1a0d71af647b688dd Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Dec 2019 15:55:03 +0800 Subject: [PATCH 02/25] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E7=9A=84=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admins/shixuns_controller.rb | 3 + app/controllers/shixuns_controller.rb | 82 +++++++++++-------- app/helpers/shixuns_helper.rb | 11 +++ app/models/shixun.rb | 3 +- app/queries/admins/shixun_query.rb | 10 +++ .../shixun_auths/agree_apply_service.rb | 2 +- .../shixun_auths/refuse_apply_service.rb | 2 +- app/services/search_service.rb | 3 +- app/views/admins/shixuns/index.html.erb | 16 ++-- .../admins/shixuns/shared/_list.html.erb | 6 +- app/views/shixuns/_top.json.jbuilder | 2 + config/routes.rb | 1 + ...91212025227_add_public_status_to_shixun.rb | 1 + .../20191212034354_migrate_shixun_status.rb | 9 ++ 14 files changed, 105 insertions(+), 46 deletions(-) create mode 100644 db/migrate/20191212034354_migrate_shixun_status.rb diff --git a/app/controllers/admins/shixuns_controller.rb b/app/controllers/admins/shixuns_controller.rb index e2d2830ad..6593f27c2 100644 --- a/app/controllers/admins/shixuns_controller.rb +++ b/app/controllers/admins/shixuns_controller.rb @@ -8,6 +8,9 @@ class Admins::ShixunsController < Admins::BaseController @pending_shixuns = shixuns.where(status:1).size @processed_shixuns = shixuns.where(status:2).size @closed_shixuns = shixuns.where(status:3).size + @none_public_shixuns = shixuns.where(public:0).size + @pending_public_shixuns = shixuns.where(public:1).size + @processed_pubic_shixuns = shixuns.where(public:2).size @shixuns_type_check = MirrorRepository.pluck(:type_name,:id) @params_page = params[:page] || 1 @shixuns = paginate shixuns.preload(:user,:challenges) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 03fdbf97f..f2a382e65 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -19,14 +19,14 @@ class ShixunsController < ApplicationController before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish, :shixun_members_added, :change_manager, :collaborators_delete, - :cancel_publish, :add_collaborators, :add_file] + :cancel_apply_public, :cancel_publish, :add_collaborators, :add_file] before_action :portion_allowed, only: [:copy] before_action :special_allowed, only: [:send_to_course, :search_user_courses] ## 获取课程列表 def index - @shixuns = current_laboratory.shixuns.unhidden + @shixuns = current_laboratory.shixuns.unhidden.publiced ## 方向 if params[:tag_level].present? && params[:tag_id].present? @@ -818,37 +818,41 @@ class ShixunsController < ApplicationController @status = 0 @position = [] begin - if @shixun.challenges.count == 0 - @status = 4 - else - @shixun.challenges.each do |challenge| - if challenge.challenge_tags.count == 0 - @status = 3 - @position << challenge.position + unless @shixun.is_jupyter? + if @shixun.challenges.count == 0 + @status = 4 + else + @shixun.challenges.each do |challenge| + if challenge.challenge_tags.count == 0 + @status = 3 + @position << challenge.position + end end - end - unfinish_challenge = @shixun.challenges.where(:st => 0, :path => nil) - if unfinish_challenge.count > 0 && !@shixun.is_choice_type? - @status = 2 - @pos = [] - unfinish_challenge.each do |challenge| - @pos << challenge.position + unfinish_challenge = @shixun.challenges.where(:st => 0, :path => nil) + if unfinish_challenge.count > 0 && !@shixun.is_choice_type? + @status = 2 + @pos = [] + unfinish_challenge.each do |challenge| + @pos << challenge.position + end end end end if @status == 0 - @shixun.update_attributes!(:status => 1) - apply = ApplyAction.where(:container_type => "ApplyShixun", :container_id => @shixun.id).order("created_at desc").first - if apply && apply.status == 0 - @status = 0 - else - ApplyAction.create(:container_type => "ApplyShixun", :container_id => @shixun.id, :user_id => current_user.id, :status => 0) - #begin - # status = Trustie::Sms.send(mobile: '18711011226', send_type:'publish_shixun' , name: '管理员') - #rescue => e - # Rails.logger.error "发送验证码出错: #{e}" - #end - @status = 1 + ActiveRecord::Base.transaction do + @shixun.update_attributes!(:status => 2) + apply = ApplyAction.where(:container_type => "ApplyShixun", :container_id => @shixun.id).order("created_at desc").first + if apply && apply.status == 0 + @status = 0 + else + ApplyAction.create(:container_type => "ApplyShixun", :container_id => @shixun.id, :user_id => current_user.id, :status => 0) + #begin + # status = Trustie::Sms.send(mobile: '18711011226', send_type:'publish_shixun' , name: '管理员') + #rescue => e + # Rails.logger.error "发送验证码出错: #{e}" + #end + @status = 1 + end end end rescue Exception => e @@ -993,14 +997,24 @@ class ShixunsController < ApplicationController :disposition => 'attachment' #inline can open in browser end + # 撤销申请公开 + def cancel_apply_public + tip_exception("实训已经公开,无法撤销") if @shixun.public == 2 + ActiveRecord::Base.transaction do + apply = ApplyAction.where(:container_type => "ApplyShixun", :container_id => @shixun.id).order("created_at desc").first + if apply && apply.status == 0 + apply.update_attributes!(status: 3) + apply.tidings&.destroy_all + end + @shixun.update_column(:public, 0) + end + normal_status(0, "成功撤销申请") + end + # 撤销发布 def cancel_publish - tip_exception("实训已经发布,无法撤销") if @shixun.status == 2 - apply = ApplyAction.where(:container_type => "ApplyShixun", :container_id => @shixun.id).order("created_at desc").first - if apply && apply.status == 0 - apply.update_attribute(:status, 3) - apply.tidings.destroy_all - end + tip_exception("请先撤销申请公开,再撤销发布") if @shixun.public == 1 + tip_exception("实训已经公开,无法撤销") if @shixun.public == 2 @shixun.update_column(:status, 0) end diff --git a/app/helpers/shixuns_helper.rb b/app/helpers/shixuns_helper.rb index b41750bed..655a7ed04 100644 --- a/app/helpers/shixuns_helper.rb +++ b/app/helpers/shixuns_helper.rb @@ -27,6 +27,17 @@ module ShixunsHelper end end + def shixun_public_status shixun + case shixun.try(:public) + when 0,nil + "未公开" + when 1 + "待审核" + when 2 + "已公开" + end + end + # 已完成实训所获得的经验值 def myshixun_exp myshixun score = 0 diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 08ddee08e..dc5348450 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -3,7 +3,7 @@ class Shixun < ApplicationRecord attr_accessor :page_no #管理员页面 实训配置更新状态时,需要接受page_no参数 # status: 0:编辑 1:申请发布 2:正式发布 3:关闭 -1:软删除 - # + # public: 0:未公开 1:申请公开 2:公开 # hide_code: 隐藏代码窗口 # code_hidden: 隐藏代码目录 # task_pass: 跳关 @@ -77,6 +77,7 @@ class Shixun < ApplicationRecord scope :published_closed, lambda{ where(status: [2, 3]) } scope :none_closed, lambda{ where(status: [0, 1, 2]) } scope :unhidden, lambda{ where(hidden: 0, status: 2) } + scope :publiced, lambda{ where(public: 2) } scope :field_for_recommend, lambda{ select([:id, :name, :identifier, :myshixuns_count]) } scope :find_by_ids,lambda{|k| where(id:k)} diff --git a/app/queries/admins/shixun_query.rb b/app/queries/admins/shixun_query.rb index 0d726f267..0f8523599 100644 --- a/app/queries/admins/shixun_query.rb +++ b/app/queries/admins/shixun_query.rb @@ -21,7 +21,17 @@ class Admins::ShixunQuery < ApplicationQuery [0,1,2,3] end + public = + case params[:public] + when "editing" then [0] + when "pending" then [1] + when "processed" then [2] + else + [0,1,2] + end + all_shixuns = all_shixuns.where(status: status) if status.present? + all_shixuns = all_shixuns.where(public: public) if public.present? if params[:tag].present? all_shixuns = all_shixuns.joins(:mirror_repositories).where("mirror_repositories.id = ?",params[:tag].to_i) diff --git a/app/services/admins/shixun_auths/agree_apply_service.rb b/app/services/admins/shixun_auths/agree_apply_service.rb index 4734e03bb..b8875cf09 100644 --- a/app/services/admins/shixun_auths/agree_apply_service.rb +++ b/app/services/admins/shixun_auths/agree_apply_service.rb @@ -10,7 +10,7 @@ class Admins::ShixunAuths::AgreeApplyService < ApplicationService def call ActiveRecord::Base.transaction do apply.update!(status: 1, dealer_id: user.id) - shixun.update!(status: 2, publish_time: Time.now) + shixun.update!(public: 2, publish_time: Time.now) # 奖励金币、经验 reward_grade_and_experience! diff --git a/app/services/admins/shixun_auths/refuse_apply_service.rb b/app/services/admins/shixun_auths/refuse_apply_service.rb index 49416a2b0..76d420e53 100644 --- a/app/services/admins/shixun_auths/refuse_apply_service.rb +++ b/app/services/admins/shixun_auths/refuse_apply_service.rb @@ -10,7 +10,7 @@ class Admins::ShixunAuths::RefuseApplyService < ApplicationService def call ActiveRecord::Base.transaction do - shixun.update!(status: 0) + shixun.update!(public: 0) apply.update!(status: 2, reason: reason, dealer_id: user.id) deal_tiding! diff --git a/app/services/search_service.rb b/app/services/search_service.rb index 5eb11f398..7947ce5d8 100644 --- a/app/services/search_service.rb +++ b/app/services/search_service.rb @@ -30,7 +30,6 @@ class SearchService < ApplicationService model_options = { includes: modal_name.searchable_includes } - model_options.deep_merge!(where: { status: 2 }) if modal_name == Shixun model_options.deep_merge!(extra_options) model_options.deep_merge!(default_options) @@ -40,7 +39,7 @@ class SearchService < ApplicationService def extra_options case params[:type].to_s.strip when 'shixun' then - { where: { id: Laboratory.current.shixuns.pluck(:id) } } + { where: { id: Laboratory.current.shixuns.where(public: 2, status: 2, fork_from: nil).or(Laboratory.current.shixuns.where(status: 2, id: current_user.shixuns)).pluck(:id) } } when 'subject' then { where: { id: Laboratory.current.subjects.pluck(:id) } } when 'course' then diff --git a/app/views/admins/shixuns/index.html.erb b/app/views/admins/shixuns/index.html.erb index d9f8086d8..d04257927 100644 --- a/app/views/admins/shixuns/index.html.erb +++ b/app/views/admins/shixuns/index.html.erb @@ -4,25 +4,31 @@
<%= form_tag(admins_shixuns_path, method: :get, class: 'form-inline search-form',id:"shixuns-search-form",remote:true) do %> -
+
<% status_options = [['全部', ''], ["编辑中(#{@editing_shixuns})", "editing"], ["待审核(#{@pending_shixuns})", 'pending'], ["已发布(#{@processed_shixuns})", 'processed'],["已关闭(#{@closed_shixuns})",'closed']] %> <%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
+
+ + <% public_options = [['全部', ''], ["未公开(#{@none_public_shixuns})", "editing"], ["待审核(#{@pending_public_shixuns})", 'pending'], ["已公开(#{@processed_pubic_shixuns})", 'processed']] %> + <%= select_tag(:public, options_for_select(public_options), class: 'form-control') %> +
+
<%= select_tag(:tag, options_for_select(@shixuns_type_check.unshift(["",nil])), class: 'form-control',id:"tag-choosed") %>
-
+
<% auto_trial_options = [['创建者姓名', 0], ['实训名称', 1], ['学校名称', 2]] %> <%= select_tag(:search_type, options_for_select(auto_trial_options), class: 'form-control') %>
- <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '输入关键字搜索') %> - <%= submit_tag('搜索', class: 'btn btn-primary ml-3','data-disable-with': '搜索中...') %> - <%= link_to "清除",admins_shixuns_path,class: "btn btn-default",id:"shixuns-clear-search",'data-disable-with': '清除中...' %> + <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2', placeholder: '输入关键字搜索') %> + <%= submit_tag('搜索', class: 'btn btn-primary','data-disable-with': '搜索中...') %> + <%= link_to "清除", admins_shixuns_path,class: "btn btn-default",id:"shixuns-clear-search",'data-disable-with': '清除中...' %> <% end %> 导出
diff --git a/app/views/admins/shixuns/shared/_list.html.erb b/app/views/admins/shixuns/shared/_list.html.erb index 7503d8fd2..9ee44ece3 100644 --- a/app/views/admins/shixuns/shared/_list.html.erb +++ b/app/views/admins/shixuns/shared/_list.html.erb @@ -2,14 +2,15 @@ 序号 ID - 实训名称 + 实训名称 技术平台 Fork源 实践 选择 状态 + 公开 创建者 - <%= sort_tag('创建于', name: 'created_at', path: admins_shixuns_path) %> + <%= sort_tag('创建于', name: 'created_at', path: admins_shixuns_path) %> 单测 操作 @@ -33,6 +34,7 @@ <%= shixun.challenges.where(:st => 0).size %> <%= shixun.challenges.where(:st => 1).size %> <%= shixun_authentication_status shixun %> + <%= shixun_public_status shixun %> <%= link_to shixun.user.try(:real_name),"/users/#{shixun.user.try(:login)}",target:'_blank' %> <%= format_time shixun.created_at %> diff --git a/app/views/shixuns/_top.json.jbuilder b/app/views/shixuns/_top.json.jbuilder index ebb77ec74..32c00cc79 100644 --- a/app/views/shixuns/_top.json.jbuilder +++ b/app/views/shixuns/_top.json.jbuilder @@ -16,3 +16,5 @@ json.diffcult diff_to_s(shixun.trainee) json.score_info shixun.shixun_preference_info # todo: 这块可以改成只显示实训的平均分,不用每次都去取每种星的分数了。 # 用于是否显示导航栏中的'背景知识' json.propaedeutics shixun.propaedeutics.present? + +json.public shixun.public diff --git a/config/routes.rb b/config/routes.rb index 3d4495edc..a6e9a3421 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -256,6 +256,7 @@ Rails.application.routes.draw do post :send_to_course delete :collaborators_delete get :cancel_publish + get :cancel_apply_public get :publish get :shixun_exec post :review_shixun diff --git a/db/migrate/20191212025227_add_public_status_to_shixun.rb b/db/migrate/20191212025227_add_public_status_to_shixun.rb index 0111db6ec..d1d817fb8 100644 --- a/db/migrate/20191212025227_add_public_status_to_shixun.rb +++ b/db/migrate/20191212025227_add_public_status_to_shixun.rb @@ -1,4 +1,5 @@ class AddPublicStatusToShixun < ActiveRecord::Migration[5.2] def change + add_column :shixuns, :public, :integer, default: 0 end end diff --git a/db/migrate/20191212034354_migrate_shixun_status.rb b/db/migrate/20191212034354_migrate_shixun_status.rb new file mode 100644 index 000000000..bb977f173 --- /dev/null +++ b/db/migrate/20191212034354_migrate_shixun_status.rb @@ -0,0 +1,9 @@ +class MigrateShixunStatus < ActiveRecord::Migration[5.2] + def change + # 平台上所有已发布且未隐藏的实训都设为公开 + Shixun.unhidden.update_all(public: 2) + + # 所有已申请发布的实训状态都改为已发布,申请发布改为申请公开 + Shixun.where(status: 1, id: ApplyAction.where(container_type: 'ApplyShixun', status: 0).pluck(:container_id)).update_all(status: 2, public: 1) + end +end From ef9596d48a1e94def8671f406fdd67b15e8e2019 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Dec 2019 16:18:22 +0800 Subject: [PATCH 03/25] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/search_service.rb | 2 +- app/services/shixun_search_service.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/search_service.rb b/app/services/search_service.rb index 7947ce5d8..a45875e07 100644 --- a/app/services/search_service.rb +++ b/app/services/search_service.rb @@ -39,7 +39,7 @@ class SearchService < ApplicationService def extra_options case params[:type].to_s.strip when 'shixun' then - { where: { id: Laboratory.current.shixuns.where(public: 2, status: 2, fork_from: nil).or(Laboratory.current.shixuns.where(status: 2, id: current_user.shixuns)).pluck(:id) } } + { where: { id: Laboratory.current.shixuns.where(public: 2, status: 2, fork_from: nil).or(Laboratory.current.shixuns.where(status: 2, id: User.current.shixuns)).pluck(:id) } } when 'subject' then { where: { id: Laboratory.current.subjects.pluck(:id) } } when 'course' then diff --git a/app/services/shixun_search_service.rb b/app/services/shixun_search_service.rb index 580208dfe..649de87bf 100644 --- a/app/services/shixun_search_service.rb +++ b/app/services/shixun_search_service.rb @@ -25,7 +25,7 @@ class ShixunSearchService < ApplicationService else none_shixun_ids = ShixunSchool.where("school_id != #{User.current.school_id}").pluck(:shixun_id) - @shixuns = @shixuns.where.not(id: none_shixun_ids).where(hidden: 0) + @shixuns = @shixuns.where.not(id: none_shixun_ids).where(hidden: 0, status: 2, public: 2).or(@shixuns.where(id: current_user.shixuns)) end end From 7ad3538839ccefef4b62489d5ef9f1b38144c571 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Dec 2019 16:46:51 +0800 Subject: [PATCH 04/25] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84=E6=88=90=E7=BB=A9=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 14 ++++++++++++-- config/routes.rb | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index de24f7a8e..4f82a4c9b 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -29,7 +29,7 @@ class CoursesController < ApplicationController :informs, :update_informs, :online_learning, :update_task_position, :tasks_list, :join_excellent_course, :export_couser_info, :export_member_act_score, :new_informs, :delete_informs, :change_member_role, :course_groups, :join_course_group, :statistics, - :work_score, :act_score] + :work_score, :act_score, :calculate_all_shixun_scores] before_action :user_course_identity, except: [:join_excellent_course, :index, :create, :new, :apply_to_join_course, :search_course_list, :get_historical_course_students, :mine, :search_slim, :board_list] before_action :teacher_allowed, only: [:update, :destroy, :settings, :search_teacher_candidate, @@ -48,7 +48,7 @@ class CoursesController < ApplicationController before_action :validate_page_size, only: :mine before_action :course_tasks, only: [:tasks_list, :update_task_position] before_action :validate_inform_params, only: [:update_informs, :new_informs] - before_action :course_member_allowed, only: [:statistics, :work_score, :act_score] + before_action :course_member_allowed, only: [:statistics, :work_score, :act_score, :calculate_all_shixun_scores] if RUBY_PLATFORM =~ /linux/ require 'simple_xlsx_reader' @@ -1332,6 +1332,16 @@ class CoursesController < ApplicationController end end + # 计算课堂所有已发布的实训作业成绩 + def calculate_all_shixun_scores + tip_exception(-1, "课堂已结束") if @course.is_end + shixun_homeworks = @course.homework_commons.homework_published.where(homework_type: 4) + shixun_homeworks.includes(:homework_challenge_settings, :published_settings, :homework_commons_shixun).each do |homework| + homework.update_homework_work_score + end + normal_status(0, "更新成功") + end + def search_slim courses = current_user.manage_courses.not_deleted.processing diff --git a/config/routes.rb b/config/routes.rb index a6e9a3421..919fd9e70 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -420,6 +420,7 @@ Rails.application.routes.draw do get 'statistics' post :inform_up post :inform_down + get :calculate_all_shixun_scores end collection do From baec0f86d789b8fc7739bff453da02ef80429ca3 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Dec 2019 17:57:41 +0800 Subject: [PATCH 05/25] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E7=AD=94=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/game.rb | 6 ++++++ app/models/myshixun.rb | 5 +++-- app/views/student_works/shixun_work_report.json.jbuilder | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/models/game.rb b/app/models/game.rb index d82392a59..ca7339352 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -119,6 +119,12 @@ class Game < ApplicationRecord # self.outputs.pluck(:query_index).first #end + # 是否查看了答案(通关的是否在通关前看的答案) + def view_answer + answer_exists = Grade.exists?("container_type = 'Answer' and container_id = #{id} and created_at < '#{end_time}'") + answer_open != 0 ? (status == 2 ? answer_exists : true) : false + end + # 用户关卡得分 def get_user_final_score diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index 54dcf9011..9b824c0d8 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -83,9 +83,10 @@ class Myshixun < ApplicationRecord self.games.select{|game| game.status == 2}.size end - # 查看答案的关卡数 + # 查看答案的关卡数,只统计通关前看的关卡 def view_answer_count - self.games.select{|game| game.status == 2 && game.answer_open != 0}.size + answer_ids = user.grades.joins("join games on grades.container_id = games.id").where("container_type = 'Answer' and games.status=2 and games.end_time > grades.created_at").pluck(:container_id) + self.games.select{|game| game.status == 2 && game.answer_open != 0 && answer_ids.include?(game.id)}.size end # 通关时间 diff --git a/app/views/student_works/shixun_work_report.json.jbuilder b/app/views/student_works/shixun_work_report.json.jbuilder index 162e2ab1c..068151856 100644 --- a/app/views/student_works/shixun_work_report.json.jbuilder +++ b/app/views/student_works/shixun_work_report.json.jbuilder @@ -42,7 +42,7 @@ if @shixun json.challenge_comment challenge_comment&.comment json.challenge_comment_hidden @user_course_identity < Course::STUDENT ? challenge_comment&.hidden_comment : nil json.comment_id challenge_comment&.id - json.view_answer game ? game.answer_open != 0 : 0 + json.view_answer game ? game.view_answer : false end end From 071ca422b12396dae59647e6e1f7aea2a999804a Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 12 Dec 2019 19:43:56 +0800 Subject: [PATCH 06/25] =?UTF-8?q?=E5=91=BD=E4=BB=A4=E8=A1=8C=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index b5c8af1f3..d40fc8237 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -217,7 +217,7 @@ class MyshixunsController < ApplicationController shixun_tomcat = edu_setting('tomcat_webssh') uri = "#{shixun_tomcat}/bridge/webssh/getConnectInfo" # 由于中间层采用混合云的方式,因为local参数表示在有文件生成的实训是在本地生成,还是在其他云端生成评测文件 - params = {tpiID:@myshixun.id, podType:@myshixun.shixun.try(:webssh), local: @myshixun.shixun.show_type != -1, + params = {tpiID:@myshixun.id, podType:@myshixun.shixun.try(:webssh)#, local: @myshixun.shixun.show_type != -1, containers:(Base64.urlsafe_encode64(shixun_container_limit @myshixun.shixun))} res = uri_post uri, params if res && res['code'].to_i != 0 From 8209f4d78d088d92d97afc23e15f403529475322 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 12 Dec 2019 19:44:33 +0800 Subject: [PATCH 07/25] =?UTF-8?q?=E5=91=BD=E4=BB=A4=E8=A1=8C=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index d40fc8237..6d7386e2f 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -217,7 +217,7 @@ class MyshixunsController < ApplicationController shixun_tomcat = edu_setting('tomcat_webssh') uri = "#{shixun_tomcat}/bridge/webssh/getConnectInfo" # 由于中间层采用混合云的方式,因为local参数表示在有文件生成的实训是在本地生成,还是在其他云端生成评测文件 - params = {tpiID:@myshixun.id, podType:@myshixun.shixun.try(:webssh)#, local: @myshixun.shixun.show_type != -1, + params = {tpiID:@myshixun.id, podType:@myshixun.shixun.try(:webssh), #local: @myshixun.shixun.show_type != -1, containers:(Base64.urlsafe_encode64(shixun_container_limit @myshixun.shixun))} res = uri_post uri, params if res && res['code'].to_i != 0 From d94c79cb061c58458fa5fca0b7e4dd9d6aee23e1 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 12 Dec 2019 20:40:21 +0800 Subject: [PATCH 08/25] =?UTF-8?q?=E5=91=BD=E4=BB=A4=E8=A1=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0local=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index b5c8af1f3..d603b557e 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -217,7 +217,8 @@ class MyshixunsController < ApplicationController shixun_tomcat = edu_setting('tomcat_webssh') uri = "#{shixun_tomcat}/bridge/webssh/getConnectInfo" # 由于中间层采用混合云的方式,因为local参数表示在有文件生成的实训是在本地生成,还是在其他云端生成评测文件 - params = {tpiID:@myshixun.id, podType:@myshixun.shixun.try(:webssh), local: @myshixun.shixun.show_type != -1, + local = @myshixun.shixun.challenges.where.not(show_type: -1).count == 0 + params = {tpiID:@myshixun.id, podType:@myshixun.shixun.try(:webssh), local: local, containers:(Base64.urlsafe_encode64(shixun_container_limit @myshixun.shixun))} res = uri_post uri, params if res && res['code'].to_i != 0 From 0aa695d7f1c1ce89780e6eef3d08d3029df7a148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Thu, 12 Dec 2019 23:46:25 +0800 Subject: [PATCH 09/25] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=BC=B9=E6=A1=86=20?= =?UTF-8?q?=E5=A1=9E=E9=80=89=E6=94=B9=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/coursesPublic/NewShixunModel.js | 72 +++++++++--- .../courses/coursesPublic/Newshixunmodel.css | 108 +++++++++++++++++- 2 files changed, 164 insertions(+), 16 deletions(-) diff --git a/public/react/src/modules/courses/coursesPublic/NewShixunModel.js b/public/react/src/modules/courses/coursesPublic/NewShixunModel.js index a20f7733c..462df7608 100644 --- a/public/react/src/modules/courses/coursesPublic/NewShixunModel.js +++ b/public/react/src/modules/courses/coursesPublic/NewShixunModel.js @@ -19,7 +19,8 @@ class NewShixunModel extends Component{ order:'desc', diff:0, limit:15, - sort:"myshixuns_count" + sort:"myshixuns_count", + belongtoindex:0, } } componentDidMount() { @@ -161,7 +162,17 @@ class NewShixunModel extends Component{ }) let{status,order,diff,limit,sort}=this.state; if(this.props.type==='shixuns'){ - this.getdatalist(1,value,status,undefined,order,diff,limit) + this.getdatalist(1,value,status,undefined,order,diff,limit); + if(value==="all"){ + this.setState({ + belongtoindex:0 + }) + }else{ + this.setState({ + belongtoindex:1 + }) + } + }else{ this.getdatalist(1,value,undefined,undefined,order,undefined,limit,undefined,sort) } @@ -322,6 +333,7 @@ class NewShixunModel extends Component{ this.getdatalist(page,type,status,keyword,order,diff,limit) } + updatepathlist=(sorts,orders)=>{ let{page,type,keyword,order,diff,limit,status,sort}=this.state; let seartorders; @@ -352,7 +364,7 @@ class NewShixunModel extends Component{ } render() { - let {diff,Grouplist,status,shixun_list,shixuns_count,page,type,order,sort}=this.state; + let {diff,Grouplist,status,shixun_list,shixuns_count,page,type,order,sort,belongtoindex}=this.state; // let {visible,patheditarry}=this.props; // console.log(Grouplist) // console.log(allGrouplist) @@ -446,7 +458,7 @@ class NewShixunModel extends Component{
-
+
@@ -472,7 +484,36 @@ class NewShixunModel extends Component{ onSearch={ (value)=>this.setdatafuns(value)} />
-
+ + + + + + + {this.props.type==='shixuns'? +
+

筛选:

+

this.belongto("all")}>全部实训

+

this.belongto("mine")}>普通实训

+
:"" + } + {/*{this.props.type==='shixuns'? */} + {/* */} + {/* {diff===0?"难度":diff===1?"初级":diff===2?"中级":diff===3?"高级":diff===4?"顶级":""}*/} + {/* */} + {/*:""}*/} + {this.props.type==='shixuns'? +
+

难度:

+

this.DropdownClick(0)}>全部

+

this.DropdownClick(1)}>初级

+

this.DropdownClick(2)}>中级

+

this.DropdownClick(3)}>高级

+

this.DropdownClick(4)}>顶级

+
:"" + } + +
@@ -509,17 +550,18 @@ class NewShixunModel extends Component{ :"":""} - {this.props.type==='shixuns'? - - {diff===0?"难度":diff===1?"初级":diff===2?"中级":diff===3?"高级":diff===4?"顶级":""} - - :""} +
-
- {/*this.props.hideNewShixunModelType()}>返回*/} - this.belongto("mine")}>我的{this.props.type==='shixuns'?'实训':"课程"} - this.belongto("all")}>全部{this.props.type==='shixuns'?'实训':"课程"} +
+ + {this.props.type==='shixuns'?"": + this.belongto("mine")}>我的课程 + } + + {this.props.type==='shixuns'?"": + this.belongto("all")}>全部课程 + }
@@ -684,4 +726,4 @@ export default NewShixunModel; // {} // ) // })} -//
} \ No newline at end of file +//
} diff --git a/public/react/src/modules/courses/coursesPublic/Newshixunmodel.css b/public/react/src/modules/courses/coursesPublic/Newshixunmodel.css index 42595bf29..307035602 100644 --- a/public/react/src/modules/courses/coursesPublic/Newshixunmodel.css +++ b/public/react/src/modules/courses/coursesPublic/Newshixunmodel.css @@ -384,4 +384,110 @@ .newshixunmodels{ margin: 0 auto; -} \ No newline at end of file +} + +/* 中间居中 */ +.intermediatecenter{ + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} +/* 简单居中 */ +.intermediatecenterysls{ + display: flex; + align-items: center; +} +.spacearound{ + display: flex; + justify-content: space-around; + +} +.spacebetween{ + display: flex; + justify-content: space-between; +} +/* 头顶部居中 */ +.topcenter{ + display: -webkit-flex; + flex-direction: column; + align-items: center; + +} + + +/* x轴正方向排序 */ +/* 一 二 三 四 五 六 七 八 */ +.sortinxdirection{ + display: flex; + flex-direction:row; +} +/* x轴反方向排序 */ +/* 八 七 六 五 四 三 二 一 */ +.xaxisreverseorder{ + display: flex; + flex-direction:row-reverse; +} +/* 垂直布局 正方向*/ +/* 一 + 二 + 三 + 四 + 五 + 六 + 七 + 八 */ +.verticallayout{ + display: flex; + flex-direction:column; +} +/* 垂直布局 反方向*/ +.reversedirection{ + display: flex; + flex-direction:column-reverse; +} + +.nandu{ + width: 42px; + height: 19px; + font-size: 14px; + color: #000000; + line-height: 19px; + margin-left: 6px; +} + +.clickbuts{ + text-align: center; + width: 60px; + height: 32px; + background: #4CACFF; + border-radius: 16px; + line-height: 30px; + color: #FFFFFF; + cursor:pointer; +} +.clickbutst{ + height:19px; + font-size:14px; + color:#505050; + line-height:19px; + cursor:pointer; +} + +.clickbutstwo{ + text-align: center; + width: 85px; + height: 32px; + background: #4CACFF; + border-radius: 16px; + line-height: 30px; + color: #FFFFFF; + cursor:pointer; +} +.clickbutstwos{ + height:19px; + font-size:14px; + color:#505050; + line-height:19px; + cursor:pointer; +} From 17381f5923096f20ccaca127d0930753adf126ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Fri, 13 Dec 2019 09:00:11 +0800 Subject: [PATCH 10/25] =?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/tpm/TPMDataset.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/public/react/src/modules/tpm/TPMDataset.js b/public/react/src/modules/tpm/TPMDataset.js index b7f168e0a..a67426a95 100644 --- a/public/react/src/modules/tpm/TPMDataset.js +++ b/public/react/src/modules/tpm/TPMDataset.js @@ -460,13 +460,10 @@ class TPMDataset extends Component {
- { - data_sets_count>0? +
全选
- :"" - }
- - + +
@@ -41,7 +45,6 @@ class Bottomsubmit extends Component { } - export default Bottomsubmit; diff --git a/public/react/src/modules/tpm/TPMsettings/Configuration.js b/public/react/src/modules/tpm/TPMsettings/Configuration.js index c7156abe8..3b135ac7a 100644 --- a/public/react/src/modules/tpm/TPMsettings/Configuration.js +++ b/public/react/src/modules/tpm/TPMsettings/Configuration.js @@ -11,8 +11,6 @@ import { Button, } from 'antd'; -// import "antd/dist/antd.css"; - import locale from 'antd/lib/date-picker/locale/zh_CN'; import moment from 'moment'; @@ -21,8 +19,8 @@ import axios from 'axios'; import './css/TPMsettings.css'; -import {getImageUrl, toPath, getUrl, appendFileSizeToUploadFileAll, getUploadActionUrl} from 'educoder'; import {handleDateStrings} from "./oldTPMsettings"; + import Bottomsubmit from "../../modals/Bottomsubmit"; const $ = window.$; @@ -34,7 +32,6 @@ let currentValue; const Option = Select.Option; const RadioGroup = Radio.Group; -const confirm = Modal.confirm; function range(start, end) { const result = []; @@ -61,12 +58,13 @@ export default class Shixuninformation extends Component { constructor(props) { super(props) this.state = { - can_copy:false, - use_scope:0, - opening_time:null, - opentime:false, - oldscope_partment:[], - scope_partment:[] + can_copy: false, + use_scope: 0, + opening_time: null, + opentime: false, + oldscope_partment: [], + scope_partment: [], + loading: false } } @@ -74,11 +72,11 @@ export default class Shixuninformation extends Component { if (this.props.data) { this.setState({ - can_copy: this.props.data && this.props.data.shixun.can_copy === undefined ? false :this.props.data.shixun.can_copy, - use_scope:this.props.data && this.props.data.shixun.use_scope, + can_copy: this.props.data && this.props.data.shixun.can_copy === undefined ? false : this.props.data.shixun.can_copy, + use_scope: this.props.data && this.props.data.shixun.use_scope, opening_time: this.props.data && this.props.data.shixun.opening_time, - opentime:!this.props.data && this.props.data.shixun.opening_time?false:true, - oldscope_partment:this.props.data&&this.props.data.shixun.scope_partment, + opentime: !this.props.data && this.props.data.shixun.opening_time ? false : true, + oldscope_partment: this.props.data && this.props.data.shixun.scope_partment, }) } @@ -102,11 +100,11 @@ export default class Shixuninformation extends Component { if (this.props.data) { this.setState({ - can_copy: this.props.data && this.props.data.shixun.can_copy === undefined ? false :this.props.data.shixun.can_copy, - use_scope:this.props.data && this.props.data.shixun.use_scope, + can_copy: this.props.data && this.props.data.shixun.can_copy === undefined ? false : this.props.data.shixun.can_copy, + use_scope: this.props.data && this.props.data.shixun.use_scope, opening_time: this.props.data && this.props.data.shixun.opening_time, - opentime:!this.props.data && this.props.data.shixun.opening_time?false:true, - oldscope_partment:this.props.data&&this.props.data.shixun.scope_partment, + opentime: !this.props.data && this.props.data.shixun.opening_time ? false : true, + oldscope_partment: this.props.data && this.props.data.shixun.scope_partment, }) } @@ -115,75 +113,84 @@ export default class Shixuninformation extends Component { onChangeTimePicker = (value, dateString) => { this.setState({ - opening_time: dateString === "" ? "" :handleDateStrings(dateString) + opening_time: dateString === "" ? "" : handleDateStrings(dateString) }) } onSubmits = () => { - let {can_copy,use_scope,scope_partment,opening_time }=this.state; + this.setState({ + loading: true + }) + let {can_copy, use_scope, scope_partment, opening_time} = this.state; let id = this.props.match.params.shixunId; - let url=`/shixuns/${id}/update_permission_setting.json`; + let url = `/shixuns/${id}/update_permission_setting.json`; axios.post(url, { - scope_partment:scope_partment, - shixun:{ - can_copy: can_copy, - use_scope:use_scope, - opening_time:opening_time + scope_partment: scope_partment, + shixun: { + can_copy: can_copy, + use_scope: use_scope, + opening_time: opening_time + } } - } ).then((response) => { - if(response.data.status===-1){ + if (response.data.status === -1) { - }else{ + } else { this.props.getdatas() - this.props.showNotification("保存成功") + this.props.showNotification("权限配置保存成功!") + this.setState({ + loading: false + }) } }).catch((error) => { - console.log(error) + this.setState({ + loading: false + }) }) } - CheckboxonChange=(e)=>{ - this.setState({ - can_copy:e.target.checked - }) - } - SelectOpenpublic=(e)=>{ + CheckboxonChange = (e) => { + this.setState({ + can_copy: e.target.checked + }) + } + + SelectOpenpublic = (e) => { this.setState({ use_scope: e.target.value }); } shixunScopeInput = (e) => { - let {scope_partment,oldscope_partment} = this.state; + let {scope_partment, oldscope_partment} = this.state; let datalist = scope_partment; - if (datalist===undefined) { - datalist=[] + if (datalist === undefined) { + datalist = [] } datalist.push(e) - let scopetype=false; + let scopetype = false; - scope_partment.map((item,key)=>{ - if(item===e){ - scopetype=true + scope_partment.map((item, key) => { + if (item === e) { + scopetype = true } }) - oldscope_partment.map((item,key)=>{ - if(item===e){ - scopetype=true + oldscope_partment.map((item, key) => { + if (item === e) { + scopetype = true } }) - if(scopetype===false){ + if (scopetype === false) { this.setState({ scope_partment: datalist }); - }else{ + } else { this.props.showNotification("请勿指定相同的单位") } @@ -221,11 +228,12 @@ export default class Shixuninformation extends Component { }); } - setopentime=(e)=>{ + setopentime = (e) => { this.setState({ - opentime:e.target.checked + opentime: e.target.checked }) } + render() { let options; @@ -253,9 +261,10 @@ export default class Shixuninformation extends Component {
- {this.props.data && this.props.data.shixun.use_scope === 0 &&this.props.data && this.props.data.shixun.status === 2?"":
- 公开程度: - + {this.props.data && this.props.data.shixun.use_scope === 0 && this.props.data && this.props.data.shixun.status === 2 ? "" : +
+ 公开程度: + 对所有单位公开 (实训发布后,所有用户可见) @@ -264,7 +273,7 @@ export default class Shixuninformation extends Component {
+ style={{display: this.state.use_scope === 0 ? 'none' : 'block'}}>
@@ -292,12 +301,12 @@ export default class Shixuninformation extends Component {
{ - this.state.oldscope_partment.map((item,key)=>{ + this.state.oldscope_partment.map((item, key) => { return (
  • - +
  • ) }) @@ -307,9 +316,9 @@ export default class Shixuninformation extends Component { return (
  • - this.deleteScopeInput(key)}> + this.deleteScopeInput(key)}>
  • @@ -331,31 +340,32 @@ export default class Shixuninformation extends Component { -
    } +
    }
    开启时间: - +
    - {this.state.opentime===false?"":
    - -
    } + {this.state.opentime === false ? "" :
    + +
    }
    @@ -365,7 +375,7 @@ export default class Shixuninformation extends Component {
    {this.props.identity < 5 ? : ""} + onSubmits={this.onSubmits} loadings={this.state.loading}/> : ""}
    ); } diff --git a/public/react/src/modules/tpm/TPMsettings/LearningSettings.js b/public/react/src/modules/tpm/TPMsettings/LearningSettings.js index d8caa83ee..40112c730 100644 --- a/public/react/src/modules/tpm/TPMsettings/LearningSettings.js +++ b/public/react/src/modules/tpm/TPMsettings/LearningSettings.js @@ -1,29 +1,14 @@ import React, {Component} from 'react'; import { - Input, - Select, Radio, Checkbox, - Popconfirm, - message, - Modal, - Icon, - DatePicker, - Breadcrumb, - Upload, - Button, - notification, - Tooltip, - Tabs } from 'antd'; import axios from 'axios'; import './css/TPMsettings.css'; -import {getImageUrl, toPath, getUrl, appendFileSizeToUploadFileAll, getUploadActionUrl} from 'educoder'; - import Bottomsubmit from "../../modals/Bottomsubmit"; const RadioGroup = Radio.Group; @@ -32,7 +17,19 @@ const RadioGroup = Radio.Group; export default class Shixuninformation extends Component { constructor(props) { super(props) - this.state = {} + this.state = { + vnc: false, + hide_code: false, + is_secret_repository: false, + code_hidden: false, + forbid_copy: false, + test_set_permission: true, + task_pass: true, + websshshow: false, + multi_webssh: false, + opensshRadio: null, + loading: false + } } @@ -41,27 +38,188 @@ export default class Shixuninformation extends Component { this.setState({ vnc: this.props.data && this.props.data.shixun.vnc, - use_scope: this.props.data && this.props.data.shixun.use_scope, - opening_time: this.props.data && this.props.data.shixun.opening_time, - opentime: !this.props.data && this.props.data.shixun.opening_time ? false : true, - oldscope_partment: this.props.data && this.props.data.shixun.scope_partment, + code_hidden: this.props.data && this.props.data.shixun.code_hidden, + forbid_copy: this.props.data && this.props.data.shixun.forbid_copy, + hide_code: this.props.data && this.props.data.shixun.hide_code, + task_pass: this.props.data && this.props.data.shixun.task_pass, + test_set_permission: this.props.data && this.props.data.shixun.test_set_permission, + is_secret_repository: this.props.data && this.props.data.shixun.is_secret_repository, + websshshow: this.props.data && this.props.data.shixun.webssh === 0 ? false : true, + multi_webssh: this.props.data && this.props.data.shixun.multi_webssh, + opensshRadio: this.props.data && this.props.data.shixun.webssh === 0 ? null : this.props.data && this.props.data.shixun.webssh, }) + // if(this.props.data && this.props.data.shixun.status===0){ + // this.setState({ + // task_pass:true + // }) + // } + + } + + } + + componentDidUpdate(prevProps, prevState) { + if (prevProps.data != this.props.data) { + if (this.props.data) { + + this.setState({ + vnc: this.props.data && this.props.data.shixun.vnc, + code_hidden: this.props.data && this.props.data.shixun.code_hidden, + forbid_copy: this.props.data && this.props.data.shixun.forbid_copy, + hide_code: this.props.data && this.props.data.shixun.hide_code, + task_pass: this.props.data && this.props.data.shixun.task_pass, + test_set_permission: this.props.data && this.props.data.shixun.test_set_permission, + is_secret_repository: this.props.data && this.props.data.shixun.is_secret_repository, + websshshow: this.props.data && this.props.data.shixun.webssh === 0 ? false : true, + multi_webssh: this.props.data && this.props.data.shixun.multi_webssh, + opensshRadio: this.props.data && this.props.data.shixun.webssh === 0 ? null : this.props.data && this.props.data.shixun.webssh, + }) + + // if(this.props.data && this.props.data.shixun.status===0){ + // this.setState({ + // task_pass:true + // }) + // } + + } } - let departmentsUrl = `/shixuns/departments.json`; - axios.get(departmentsUrl).then((response) => { - if (response.status === 200) { - if (response.data.message === undefined) { - this.setState({ - departmentslist: response.data.shools_name - }); - } + } + + + onSubmits = () => { + this.setState({ + loading: true + }) + let id = this.props.match.params.shixunId; + let url = `/shixuns/${id}/update_permission_setting.json`; + axios.post(url, + { + shixun: { + code_hidden: this.state.code_hidden, + forbid_copy: this.state.forbid_copy, + hide_code: this.state.hide_code, + multi_webssh: this.state.multi_webssh, + task_pass: this.state.task_pass, + test_set_permission: this.state.test_set_permission, + vnc: this.state.vnc, + webssh: this.state.websshshow === false ? 0 : this.state.opensshRadio, + }, + is_secret_repository: this.state.is_secret_repository + } + ).then((response) => { + if (response.data.status === -1) { + + } else { + this.props.getdatas() + this.props.showNotification("学习页面设置保存成功!") + this.setState({ + loading: false + }) } }).catch((error) => { - console.log(error) - }); + this.setState({ + loading: false + }) + }) + } + + Checkvnc = () => { + console.log(this.state.vnc) + if (this.state.vnc === false) { + this.setState({ + hide_code: false, + is_secret_repository: false, + code_hidden: false, + forbid_copy: false, + multi_webssh: false, + websshshow: false, + }) + } + this.setState({ + vnc: !this.state.vnc + }) + } + + Checkhide_code = () => { + if (this.state.hide_code === false) { + this.setState({ + is_secret_repository: false + }) + } + this.setState({ + hide_code: !this.state.hide_code + }) + } + + Checkis_secret_repository = () => { + this.setState({ + is_secret_repository: !this.state.is_secret_repository + }) + } + + Checkcode_hidden = () => { + this.setState({ + code_hidden: !this.state.code_hidden + }) + } + + Checkforbid_copy = () => { + this.setState({ + forbid_copy: !this.state.forbid_copy + }) } + Checktask_pass = () => { + this.setState({ + task_pass: !this.state.task_pass + }) + } + + Checktest_set_permission = () => { + this.setState({ + test_set_permission: !this.state.test_set_permission + }) + } + + Checkwebsshshow = () => { + if (this.state.websshshow === false) { + this.setState({ + vnc: false, + opensshRadio: 1 + }) + } else { + this.setState({ + multi_webssh: false, + opensshRadio: null + }) + } + this.setState({ + websshshow: !this.state.websshshow + }) + + } + + Checkmulti_webssh = () => { + this.setState({ + multi_webssh: !this.state.multi_webssh + }) + } + + opensshRadio = (e) => { + if (e.target.value === 1) { + this.setState({ + multi_webssh: false + }) + } else { + this.setState({ + multi_webssh: true + }) + } + this.setState({ + opensshRadio: e.target.value + }); + } render() { console.log(this.props) @@ -69,107 +227,107 @@ export default class Shixuninformation extends Component {
    -
    + {this.state.websshshow === true ? "" :
    开启图形化界面: + checked={this.state.vnc} + onChange={this.Checkvnc}> -
    +
    } -
    + {this.state.vnc === true ? "" :
    命令行: + checked={this.state.websshshow} + onChange={this.Checkwebsshshow}> -
    +
    } -
    + {this.state.vnc === true ? "" : this.state.websshshow === true ?
    - - 命令行练习窗口 + 命令行练习窗口 (选中则给学员提供用于练习操作的命令行,命令行的操作不会对学生的实验环境造成影响) - 命令行评测窗口 命令行评测窗口 (选中则给学员提供用于评测操作的命令行,命令行的操作可以对学生的实验环境产生影响) - + {this.state.opensshRadio === 2 ?
    + checked={this.state.multi_webssh} + onChange={this.Checkmulti_webssh}>
    -
    -
    + : ""} +
    : ""} -
    + {this.state.vnc === true ? "" :
    隐藏代码窗口: + checked={this.state.hide_code} + onChange={this.Checkhide_code}> -
    +
    } -
    + {this.state.vnc === true || this.state.hide_code === true ? "" :
    公开版本库: + checked={this.state.is_secret_repository} + onChange={this.Checkis_secret_repository}> -
    +
    } -
    - 隐藏代码目录: + {this.state.vnc === true ? "" :
    + 隐藏代码目录: + checked={this.state.code_hidden} + onChange={this.Checkcode_hidden}> -
    +
    } -
    - 禁用复制粘贴: + {this.state.vnc === true ? "" :
    + 禁用复制粘贴: + checked={this.state.forbid_copy} + onChange={this.Checkforbid_copy}> -
    +
    }
    - 跳关: + 跳关: + checked={this.state.task_pass} + onChange={this.Checktask_pass}>
    - 测试集解锁: + 测试集解锁: + checked={this.state.test_set_permission} + onChange={this.Checktest_set_permission}>
    @@ -179,7 +337,7 @@ export default class Shixuninformation extends Component { {this.props.identity < 5 ? : ""} + onSubmits={this.onSubmits} loadings={this.state.loading}/> : ""}
    ); } diff --git a/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js b/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js index 61f8c6bd8..f36c3a738 100644 --- a/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js +++ b/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js @@ -44,7 +44,8 @@ class Shixuninformation extends Component { Executiveordervalue: "", Compilecommandvalue: "", shixun_service_configs: undefined, - fileList:[] + fileList:[], + loading:false } } @@ -77,6 +78,10 @@ class Shixuninformation extends Component { selectscripts:this.props.data.shixun.standard_scripts[0].id }) this.get_mirror_script(this.props.data.shixun.standard_scripts[0].id) + }else{ + this.props.form.setFieldsValue({ + selectscripts:this.props.data.shixun.choice_standard_scripts + }) } let newlist = "" @@ -641,6 +646,9 @@ class Shixuninformation extends Component { } onSubmits=()=>{ + this.setState({ + loading:true + }) const mdContnet = this.contentMdRef.current.getValue().trim(); let{choice_standard_scriptssum,choice_standard_scripts}=this.state; this.props.form.validateFieldsAndScroll((err, values) => { @@ -675,14 +683,22 @@ class Shixuninformation extends Component { if (result.data) { this.props.getdatas() if(result.data.shixun_identifier){ - this.props.showNotification("基本信息更新成功") - + this.props.showNotification("基本信息更新成功!") + this.setState({ + loading:false + }) } } } }).catch((error) => { - // ////console.log(error) + this.setState({ + loading:false + }) }); + }else{ + this.setState({ + loading:false + }) } }); } @@ -997,7 +1013,8 @@ class Shixuninformation extends Component { { this.props.shixunsDetails&&this.props.shixunsDetails.is_jupyter===true?"": 私密版本库: (若需要对学员隐藏部分版本库内容时,请选中;选中保存后表示启用私密版本库,请将需要对学员隐藏的文件存储在私密版本库) + value={this.state.simichecked}> + {this.state.simichecked===false?"(若需要对学员隐藏部分版本库内容时,请选中;选中保存后表示启用私密版本库,请将需要对学员隐藏的文件存储在私密版本库)":"已创建的私密版本库及其内容,将在“保存”时被删除"} } {this.props.identity < 3 ?
    @@ -1064,6 +1081,24 @@ class Shixuninformation extends Component { } : ""} + {/**/} + {/*
    */} + {/*

    已创建的私密版本库及其内容,将在“保存”时被删除

    */} + {/*

    是否确认取消选择?

    */} + {/*
    */} + + {/* */} + {/**/} + + {this.props.identity < 5 ? : ""} + onSubmits={this.onSubmits} loadings={this.state.loading} /> : ""}
    ); diff --git a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js index ed04b63ab..343b07ec7 100644 --- a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js +++ b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js @@ -32,7 +32,7 @@ export default class TPMsettings extends Component { this.getdatas() } - getdatas=()=>{ + getdatas = () => { let id = this.props.match.params.shixunId; let Url = `/shixuns/` + id + `/settings.json`; @@ -113,7 +113,14 @@ export default class TPMsettings extends Component { render() { - let showtabs= this.props.shixunsDetails === undefined ?"":this.props.shixunsDetails.is_jupyter===true?"":"学习页面设置" + let showtabs = this.props.shixunsDetails === undefined ? "" : this.props.shixunsDetails.is_jupyter === true ? "" : "学习页面设置" + + // let a="isvnc"; + // let b="isVNC"; + // console.log(a.indexOf("vnc")) + // console.log(b.indexOf("vnc")) + + console.log( this.props.shixunsDetails === undefined ? "" : this.props.shixunsDetails.is_jupyter === false ? "学习页面设置" : "") return (
    @@ -130,6 +137,9 @@ export default class TPMsettings extends Component { .ant-tabs-nav{ margin-left:20px; } + .ant-tabs-nav .ant-tabs-tab { + font-size: 16px; + } ` } @@ -161,22 +171,24 @@ export default class TPMsettings extends Component { this.getdatas()} + getdatas={() => this.getdatas()} /> this.getdatas()} + getdatas={() => this.getdatas()} /> - {/*{ this.props.shixunsDetails===undefined?"":this.props.shixunsDetails.is_jupyter===true?"":*/} - {/* */} - {/*}*/} + {this.props.shixunsDetails === undefined ? "" : this.props.shixunsDetails.is_jupyter === false ? + + this.getdatas()} + /> + :"" } { + this.setState({ + loading: true + }) const mdContnet = this.contentMdRef.current.getValue().trim(); this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { @@ -110,17 +113,20 @@ class Newshixuns extends Component { // window.open("/shixuns/"+response.data.shixun_identifier+"/challenges"); } else { this.setState({ - bottonloading: false + loading: true }) } }).catch((error) => { - console.log(error) this.setState({ - bottonloading: false + loading: true }) }) + }else{ + this.setState({ + loading: true + }) } }); }; @@ -703,7 +709,7 @@ class Newshixuns extends Component {
    - this.handleSubmit()}/> + this.handleSubmit()} loadings={this.state.loading}/>
    ); From 80ed3e76e1ae7ee1e1a12b037209db1220f1eb4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Fri, 13 Dec 2019 09:42:53 +0800 Subject: [PATCH 12/25] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/tpm/shixunchild/Challenges/Challengesjupyter.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js index e10eb6161..cb79c357f 100644 --- a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js +++ b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js @@ -176,6 +176,7 @@ class Challengesjupyter extends Component { } }).catch((error) => { }) + } @@ -286,6 +287,10 @@ class Challengesjupyter extends Component { #header{ visibility:hidden; } + + + + ` } From fe3c794a2063feee9a1cf7e815ed8bc1e686ad33 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 13 Dec 2019 09:53:30 +0800 Subject: [PATCH 13/25] =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/hacks_controller.rb | 10 ++++++++-- app/views/hack_user_lastest_codes/show.json.jbuilder | 2 +- app/views/hacks/index.json.jbuilder | 2 +- config/routes.rb | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/hacks_controller.rb b/app/controllers/hacks_controller.rb index 657ad0f2a..cab952a04 100644 --- a/app/controllers/hacks_controller.rb +++ b/app/controllers/hacks_controller.rb @@ -1,8 +1,8 @@ class HacksController < ApplicationController before_action :require_login, except: [:index] - before_action :find_hack, only: [:edit, :update, :publish, :start, :update_set, :delete_set, :destroy] + before_action :find_hack, only: [:edit, :update, :publish, :start, :update_set, :delete_set, :destroy, :cancel_publish] before_action :require_teacher_identity, only: [:create] - before_action :require_auth_identity, only: [:update, :edit, :publish, :update_set, :delete_set, :destroy] + before_action :require_auth_identity, only: [:update, :edit, :publish, :update_set, :delete_set, :destroy, :cancel_publish] # 开启编程,如果第一次开启,创建一条记录,如果已经开启过的话,直接返回标识即可 @@ -99,6 +99,12 @@ class HacksController < ApplicationController render_ok end + # 取消发布 + def cancel_publish + @hack.update_attribute(:status, 0) + render_ok + end + # 发布列表 def unpulished_list limit = params[:limit] || 16 diff --git a/app/views/hack_user_lastest_codes/show.json.jbuilder b/app/views/hack_user_lastest_codes/show.json.jbuilder index 2d7ffd2bf..cfdc87d25 100644 --- a/app/views/hack_user_lastest_codes/show.json.jbuilder +++ b/app/views/hack_user_lastest_codes/show.json.jbuilder @@ -1,5 +1,5 @@ json.hack do - json.(@hack, :name, :difficult, :time_limit, :description, :score, :identifier) + json.(@hack, :name, :difficult, :time_limit, :description, :score, :identifier, :status) json.language @hack.language json.username @hack.user.real_name json.code @my_hack.code diff --git a/app/views/hacks/index.json.jbuilder b/app/views/hacks/index.json.jbuilder index c86884a41..2b4a8b8c7 100644 --- a/app/views/hacks/index.json.jbuilder +++ b/app/views/hacks/index.json.jbuilder @@ -8,6 +8,6 @@ end json.hacks_count @hacks_count json.hacks_list do json.array! @hacks do |hack| - json.(hack,:identifier, :name , :hack_user_lastest_codes_count, :difficult, :passed_rate, :category) + json.(hack,:identifier, :name , :hack_user_lastest_codes_count, :difficult, :passed_rate, :category, :open_or_not, :status) end end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 972579201..19cbe4058 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -41,6 +41,7 @@ Rails.application.routes.draw do end member do post :publish + post :cancel_publish get :start post :update_set delete :delete_set From df57b58933352a534295c2543abe166fe17704ca Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 13 Dec 2019 10:06:33 +0800 Subject: [PATCH 14/25] 1 --- 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 a721926b9..5fd15e674 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -367,7 +367,7 @@ class ShixunsController < ApplicationController def create begin @shixun = CreateShixunService.call(current_user, shixun_params, params) - rescue => e + rescue Exception => e logger_error("shixun_create_error: #{e.message}") tip_exception("创建实训失败!") end From 1b2d3ebabb3fedd051c6308ca3aa8e17ea210f55 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 13 Dec 2019 10:11:26 +0800 Subject: [PATCH 15/25] =?UTF-8?q?=E6=97=A5=E5=BF=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 7 +-- app/services/shixuns/create_shixun_service.rb | 59 ++++++++++--------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 5fd15e674..9733bbd9f 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -365,12 +365,7 @@ class ShixunsController < ApplicationController end def create - begin - @shixun = CreateShixunService.call(current_user, shixun_params, params) - rescue Exception => e - logger_error("shixun_create_error: #{e.message}") - tip_exception("创建实训失败!") - end + @shixun = CreateShixunService.call(current_user, shixun_params, params) end # 保存jupyter到版本库 diff --git a/app/services/shixuns/create_shixun_service.rb b/app/services/shixuns/create_shixun_service.rb index aa9968f5b..2a350fd5d 100644 --- a/app/services/shixuns/create_shixun_service.rb +++ b/app/services/shixuns/create_shixun_service.rb @@ -14,34 +14,39 @@ class CreateShixunService < ApplicationService shixun.user_id = user.id main_mirror = MirrorRepository.find params[:main_type] sub_mirrors = MirrorRepository.where(id: params[:sub_type]) - ActiveRecord::Base.transaction do - shixun.save! - # 获取脚本内容 - shixun_script = get_shixun_script(shixun, main_mirror, sub_mirrors) - # 创建额外信息 - ShixunInfo.create!(shixun_id: shixun.id, evaluate_script: shixun_script, description: params[:description]) - # 创建合作者 - shixun.shixun_members.create!(user_id: user.id, role: 1) - # 创建镜像 - ShixunMirrorRepository.create!(:shixun_id => shixun.id, :mirror_repository_id => main_mirror.id) - # 创建主服务配置 - ShixunServiceConfig.create!(:shixun_id => shixun.id, :mirror_repository_id => main_mirror.id) - # 创建子镜像相关数据(实训镜像关联表,子镜像服务配置) - sub_mirrors.each do |sub| - ShixunMirrorRepository.create!(:shixun_id => shixun.id, :mirror_repository_id => sub.id) - # 实训子镜像服务配置 - name = sub.name #查看镜像是否有名称,如果没有名称就不用服务配置 - ShixunServiceConfig.create!(:shixun_id => shixun.id, :mirror_repository_id => sub.id) if name.present? - end - # 创建版本库 - repo_path = repo_namespace(user.login, shixun.identifier) - GitService.add_repository(repo_path: repo_path) - shixun.update_column(:repo_name, repo_path.split(".")[0]) - # 如果是云上实验室,创建相关记录 - if !Laboratory.current.main_site? - Laboratory.current.laboratory_shixuns.create!(shixun: shixun, ownership: true) + begin + ActiveRecord::Base.transaction do + shixun.save! + # 获取脚本内容 + shixun_script = get_shixun_script(shixun, main_mirror, sub_mirrors) + # 创建额外信息 + ShixunInfo.create!(shixun_id: shixun.id, evaluate_script: shixun_script, description: params[:description]) + # 创建合作者 + shixun.shixun_members.create!(user_id: user.id, role: 1) + # 创建镜像 + ShixunMirrorRepository.create!(:shixun_id => shixun.id, :mirror_repository_id => main_mirror.id) + # 创建主服务配置 + ShixunServiceConfig.create!(:shixun_id => shixun.id, :mirror_repository_id => main_mirror.id) + # 创建子镜像相关数据(实训镜像关联表,子镜像服务配置) + sub_mirrors.each do |sub| + ShixunMirrorRepository.create!(:shixun_id => shixun.id, :mirror_repository_id => sub.id) + # 实训子镜像服务配置 + name = sub.name #查看镜像是否有名称,如果没有名称就不用服务配置 + ShixunServiceConfig.create!(:shixun_id => shixun.id, :mirror_repository_id => sub.id) if name.present? + end + # 创建版本库 + repo_path = repo_namespace(user.login, shixun.identifier) + GitService.add_repository(repo_path: repo_path) + shixun.update_column(:repo_name, repo_path.split(".")[0]) + # 如果是云上实验室,创建相关记录 + if !Laboratory.current.main_site? + Laboratory.current.laboratory_shixuns.create!(shixun: shixun, ownership: true) + end + return shixun end - return shixun + rescue => e + Rails.logger.error("shixun_create_error: #{e.message}") + raise("创建实训失败!") end end From 7a18c9cc390ed92beb08e8e3c70f9dc02accdd01 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 13 Dec 2019 10:14:02 +0800 Subject: [PATCH 16/25] =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E5=8F=AF=E4=BB=A5Wie?= =?UTF-8?q?=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/shixun_info.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/models/shixun_info.rb b/app/models/shixun_info.rb index e16f16537..321b4c44a 100644 --- a/app/models/shixun_info.rb +++ b/app/models/shixun_info.rb @@ -1,8 +1,6 @@ class ShixunInfo < ApplicationRecord belongs_to :shixun validates_uniqueness_of :shixun_id - validates_presence_of :shixun_id, :description - after_commit :create_diff_record private From 29c33b5cb0a8b84a4bf8616b7ce57844d081a5b8 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, 13 Dec 2019 10:22:45 +0800 Subject: [PATCH 17/25] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/modals/Bottomsubmit.js | 2 +- .../modules/tpm/TPMsettings/Configuration.js | 30 +++++----- .../tpm/TPMsettings/LearningSettings.js | 4 +- .../tpm/TPMsettings/Shixuninformation.js | 60 +++++++++---------- .../modules/tpm/TPMsettings/TPMsettings.js | 50 ++++++++++------ 5 files changed, 81 insertions(+), 65 deletions(-) diff --git a/public/react/src/modules/modals/Bottomsubmit.js b/public/react/src/modules/modals/Bottomsubmit.js index c324a9692..7287f0858 100644 --- a/public/react/src/modules/modals/Bottomsubmit.js +++ b/public/react/src/modules/modals/Bottomsubmit.js @@ -35,7 +35,7 @@ class Bottomsubmit extends Component { 取 消 + loading={this.props.loadings}>{this.props.bottomvalue===undefined?"确 定":this.props.bottomvalue}
    diff --git a/public/react/src/modules/tpm/TPMsettings/Configuration.js b/public/react/src/modules/tpm/TPMsettings/Configuration.js index 3b135ac7a..11a709f3f 100644 --- a/public/react/src/modules/tpm/TPMsettings/Configuration.js +++ b/public/react/src/modules/tpm/TPMsettings/Configuration.js @@ -69,14 +69,14 @@ export default class Shixuninformation extends Component { } componentDidMount() { - if (this.props.data) { + if (this.props.data.shixun) { this.setState({ - can_copy: this.props.data && this.props.data.shixun.can_copy === undefined ? false : this.props.data.shixun.can_copy, - use_scope: this.props.data && this.props.data.shixun.use_scope, - opening_time: this.props.data && this.props.data.shixun.opening_time, - opentime: !this.props.data && this.props.data.shixun.opening_time ? false : true, - oldscope_partment: this.props.data && this.props.data.shixun.scope_partment, + can_copy:this.props.data.shixun && this.props.data.shixun.can_copy === undefined ? false : this.props.data.shixun&&this.props.data.shixun.can_copy, + use_scope: this.props.data.shixun && this.props.data.shixun.use_scope, + opening_time: this.props.data.shixun && this.props.data.shixun.opening_time, + opentime: !this.props.data.shixun && this.props.data.shixun.opening_time ? false : true, + oldscope_partment:this.props.data.shixun && this.props.data.shixun.scope_partment, }) } @@ -100,11 +100,11 @@ export default class Shixuninformation extends Component { if (this.props.data) { this.setState({ - can_copy: this.props.data && this.props.data.shixun.can_copy === undefined ? false : this.props.data.shixun.can_copy, - use_scope: this.props.data && this.props.data.shixun.use_scope, - opening_time: this.props.data && this.props.data.shixun.opening_time, - opentime: !this.props.data && this.props.data.shixun.opening_time ? false : true, - oldscope_partment: this.props.data && this.props.data.shixun.scope_partment, + can_copy: this.props.data.shixun && this.props.data.shixun.can_copy === undefined ? false : this.props.data.shixun&&this.props.data.shixun.can_copy, + use_scope: this.props.data.shixun&& this.props.data.shixun.use_scope, + opening_time: this.props.data.shixun && this.props.data.shixun.opening_time, + opentime: !this.props.data.shixun && this.props.data.shixun.opening_time ? false : true, + oldscope_partment: this.props.data.shixun && this.props.data.shixun.scope_partment, }) } @@ -138,7 +138,7 @@ export default class Shixuninformation extends Component { if (response.data.status === -1) { } else { - this.props.getdatas() + this.props.getdatas("3") this.props.showNotification("权限配置保存成功!") this.setState({ loading: false @@ -249,7 +249,7 @@ export default class Shixuninformation extends Component { return (
    -
    +
    复制: @@ -261,7 +261,7 @@ export default class Shixuninformation extends Component {
    - {this.props.data && this.props.data.shixun.use_scope === 0 && this.props.data && this.props.data.shixun.status === 2 ? "" : + {this.props.data.shixun && this.props.data.shixun.use_scope === 0 && this.props.data.shixun && this.props.data.shixun.status === 2 ? "" :
    公开程度: @@ -375,7 +375,7 @@ export default class Shixuninformation extends Component {
    {this.props.identity < 5 ? : ""} + onSubmits={this.onSubmits} loadings={this.state.loading} bottomvalue={ this.props.shixunsDetails&&this.props.shixunsDetails.is_jupyter === true?"确 定":"下一步"} /> : ""}
    ); } diff --git a/public/react/src/modules/tpm/TPMsettings/LearningSettings.js b/public/react/src/modules/tpm/TPMsettings/LearningSettings.js index 40112c730..f2a04796f 100644 --- a/public/react/src/modules/tpm/TPMsettings/LearningSettings.js +++ b/public/react/src/modules/tpm/TPMsettings/LearningSettings.js @@ -34,7 +34,7 @@ export default class Shixuninformation extends Component { componentDidMount() { - if (this.props.data) { + if (this.props.data.shixun) { this.setState({ vnc: this.props.data && this.props.data.shixun.vnc, @@ -225,7 +225,7 @@ export default class Shixuninformation extends Component { console.log(this.props) return (
    -
    +
    {this.state.websshshow === true ? "" :
    开启图形化界面: diff --git a/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js b/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js index f36c3a738..4b6130b92 100644 --- a/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js +++ b/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js @@ -45,7 +45,7 @@ class Shixuninformation extends Component { Compilecommandvalue: "", shixun_service_configs: undefined, fileList:[], - loading:false + loading:false, } } @@ -57,35 +57,35 @@ class Shixuninformation extends Component { if (prevProps.data != this.props.data) { if (this.props.data) { this.setState({ - shixunName: this.props.data.shixun.name, - trainee: this.props.data.shixun.trainee, - choice_main_type: this.props.data.shixun.choice_main_type, - choice_small_type: this.props.data.shixun.choice_small_type, - choice_standard_scripts: this.props.data.shixun.choice_standard_scripts, - shixunmemoMDvalue: this.props.data.shixun.evaluate_script, - simichecked: this.props.data.shixun.is_secret_repository, - shixun_service_configs: this.props.data.shixun.shixun_service_configs, - standard_scripts:this.props.data.shixun.standard_scripts, - shixun_service_configlist:this.props.data.shixun.shixun_service_configs, + shixunName: this.props.data.shixun&&this.props.data.shixun.name, + trainee:this.props.data.shixun&&this.props.data.shixun.trainee, + choice_main_type: this.props.data.shixun&&this.props.data.shixun.choice_main_type, + choice_small_type: this.props.data.shixun&&this.props.data.shixun.choice_small_type, + choice_standard_scripts:this.props.data.shixun&&this.props.data.shixun.choice_standard_scripts, + shixunmemoMDvalue: this.props.data.shixun&&this.props.data.shixun.evaluate_script, + simichecked: this.props.data.shixun&&this.props.data.shixun.is_secret_repository, + shixun_service_configs: this.props.data.shixun&&this.props.data.shixun.shixun_service_configs, + standard_scripts:this.props.data.shixun&&this.props.data.shixun.standard_scripts, + shixun_service_configlist:this.props.data.shixun&&this.props.data.shixun.shixun_service_configs, }) - if(this.props.data.shixun.choice_standard_scripts===null){ + if(this.props.data.shixun&&this.props.data.shixun.choice_standard_scripts===null){ this.setState({ - choice_standard_scripts:{id: this.props.data.shixun.standard_scripts[0].id, value: ""}, - choice_standard_scriptssum:this.props.data.shixun.standard_scripts[0].id + choice_standard_scripts:{id: this.props.data.shixun&&this.props.data.shixun.standard_scripts[0].id, value: ""}, + choice_standard_scriptssum:this.props.data.shixun&&this.props.data.shixun.standard_scripts[0].id }) this.props.form.setFieldsValue({ - selectscripts:this.props.data.shixun.standard_scripts[0].id + selectscripts:this.props.data.shixun&&this.props.data.shixun.standard_scripts[0].id }) - this.get_mirror_script(this.props.data.shixun.standard_scripts[0].id) + this.get_mirror_script(this.props.data.shixun&&this.props.data.shixun.standard_scripts[0].id) }else{ this.props.form.setFieldsValue({ - selectscripts:this.props.data.shixun.choice_standard_scripts + selectscripts:this.props.data.shixun&&this.props.data.shixun.choice_standard_scripts }) } let newlist = "" - this.props.data.shixun.choice_small_type.map((item, key) => { + this.props.data.shixun&&this.props.data.shixun.choice_small_type.map((item, key) => { this.props.data.shixun.small_type.map((i,k)=>{ if (item===i.id) { newlist = newlist + `${i.description}` @@ -96,8 +96,8 @@ class Shixuninformation extends Component { subvalues: newlist }) - this.props.data.shixun.main_type.map((item,key)=>{ - if(item.id===this.props.data.shixun.choice_main_type){ + this.props.data.shixun&&this.props.data.shixun.main_type.map((item,key)=>{ + if(item.id===this.props.data.shixun&&this.props.data.shixun.choice_main_type){ this.setState({ mainvalues:item.description, }) @@ -105,12 +105,12 @@ class Shixuninformation extends Component { }) this.props.form.setFieldsValue({ - name: this.props.data.shixun.name, - trainee: this.props.data.shixun.trainee, - selectleft: this.props.data.shixun.choice_main_type, - selectright:this.props.data.shixun.choice_small_type, + name:this.props.data.shixun&&this.props.data.shixun.name, + trainee: this.props.data.shixun&&this.props.data.shixun.trainee, + selectleft: this.props.data.shixun&&this.props.data.shixun.choice_main_type, + selectright:this.props.data.shixun&&this.props.data.shixun.choice_small_type, }) - this.contentMdRef.current.setValue(this.props.data.shixun.description); + this.contentMdRef.current.setValue(this.props.data.shixun&&this.props.data.shixun.description); } } } @@ -681,7 +681,7 @@ class Shixuninformation extends Component { axios.put(url, data).then((result) => { if (result) { if (result.data) { - this.props.getdatas() + this.props.getdatas("2") if(result.data.shixun_identifier){ this.props.showNotification("基本信息更新成功!") this.setState({ @@ -838,7 +838,7 @@ class Shixuninformation extends Component { > { - this.props.data === undefined ? "" : this.props.data.shixun.main_type.map((item, key) => { + this.props.data === undefined ? "" : this.props.data.shixun&&this.props.data.shixun.main_type.map((item, key) => { return (