diff --git a/app/assets/javascripts/admins/courses/index.js b/app/assets/javascripts/admins/courses/index.js index 336d8c7c9..0e3473dff 100644 --- a/app/assets/javascripts/admins/courses/index.js +++ b/app/assets/javascripts/admins/courses/index.js @@ -26,6 +26,15 @@ $(document).on('turbolinks:load', function() { }); }); + // 清空 + searchForm.on('click', '.clear-btn', function () { + searchForm.find('select[name="status"]').val(''); + searchForm.find('.school-select').val('').trigger('change'); + searchForm.find('input[name="keyword"]').val(''); + searchForm.find('#homepage_show').attr('checked', false); + searchForm.find('input[type="submit"]').trigger('click'); + }); + // ************** 学校选择 ************* searchForm.find('.school-select').select2({ theme: 'bootstrap4', diff --git a/app/assets/javascripts/admins/projects/index.js b/app/assets/javascripts/admins/projects/index.js new file mode 100644 index 000000000..534a065ca --- /dev/null +++ b/app/assets/javascripts/admins/projects/index.js @@ -0,0 +1,11 @@ +$(document).on('turbolinks:load', function () { + if ($('body.admins-projects-index-page').length > 0) { + var $form = $('.search-form'); + + // 清空 + $form.on('click', '.clear-btn', function () { + $form.find('input[name="search"]').val(''); + $form.find('input[type="submit"]').trigger('click'); + }); + } +}); diff --git a/app/assets/javascripts/admins/shixun_feedback_messages/index.js b/app/assets/javascripts/admins/shixun_feedback_messages/index.js index c0b32ba32..c25a6b744 100644 --- a/app/assets/javascripts/admins/shixun_feedback_messages/index.js +++ b/app/assets/javascripts/admins/shixun_feedback_messages/index.js @@ -1,12 +1,14 @@ $(document).on('turbolinks:load', function(){ if ($('body.admins-shixun-feedback-messages-index-page').length > 0) { + $(".content-img img").addClass("w-20").addClass("preview-image"); + var baseOptions = { autoclose: true, language: 'zh-CN', format: 'yyyy-mm-dd 00:00:00', startDate: '2017-04-01' - } + }; var defineDateRangeSelect = function(element){ var options = $.extend({inputs: $(element).find('.start-date, .end-date')}, baseOptions); @@ -14,9 +16,9 @@ $(document).on('turbolinks:load', function(){ $(element).find('.start-date').datepicker().on('changeDate', function(e){ $(element).find('.end-date').datepicker('setStartDate', e.date); - }) + }); }; defineDateRangeSelect('.grow-date-input-daterange'); } -}) \ No newline at end of file +}); \ No newline at end of file diff --git a/app/assets/javascripts/admins/shixun_modify_records/index.js b/app/assets/javascripts/admins/shixun_modify_records/index.js new file mode 100644 index 000000000..13b348b04 --- /dev/null +++ b/app/assets/javascripts/admins/shixun_modify_records/index.js @@ -0,0 +1,12 @@ +$(document).on('turbolinks:load', function () { + if ($('body.admins-shixun-modify-records-index-page').length > 0) { + var $form = $('.search-form'); + + // 清空 + $form.on('click', '.clear-btn', function () { + $form.find('select[name="date"]').val('weekly'); + $form.find('input[name="user_name"]').val(''); + $form.find('input[type="submit"]').trigger('click'); + }); + } +}); diff --git a/app/assets/stylesheets/admins/diff.scss b/app/assets/stylesheets/admins/diff.scss new file mode 100644 index 000000000..34944ae4c --- /dev/null +++ b/app/assets/stylesheets/admins/diff.scss @@ -0,0 +1,14 @@ +.diff{overflow:auto;} +.diff ul{background:#fff;overflow:auto;font-size:13px;list-style:none;margin:0;padding:0 1rem;display:table;width:100%;} +.diff del, .diff ins{display:block;text-decoration:none;} +.diff li{padding:0; display:table-row;margin: 0;height:1em;} +.diff li.ins{background:#dfd; color:#080} +.diff li.del{background:#fee; color:#b00} +.diff li:hover{background:#ffc} + +/* try 'whitespace:pre;' if you don't want lines to wrap */ +.diff del, .diff ins, .diff span{white-space:pre-wrap;font-family:courier;} +.diff del strong{font-weight:normal;background:#fcc;} +.diff ins strong{font-weight:normal;background:#9f9;} +.diff li.diff-comment { display: none; } +.diff li.diff-block-info { background: none repeat scroll 0 0 gray; } \ No newline at end of file diff --git a/app/assets/stylesheets/admins/shixun_feedback_messages.scss b/app/assets/stylesheets/admins/shixun_feedback_messages.scss new file mode 100644 index 000000000..92b92c01c --- /dev/null +++ b/app/assets/stylesheets/admins/shixun_feedback_messages.scss @@ -0,0 +1,7 @@ +.admins-shixun-feedback-messages-index-page { + .content-img { + img { + height: 60px; + } + } +} \ No newline at end of file diff --git a/app/constraint/admin_constraint.rb b/app/constraint/admin_constraint.rb index 3ddf9a11e..2cf5649a7 100644 --- a/app/constraint/admin_constraint.rb +++ b/app/constraint/admin_constraint.rb @@ -1,7 +1,8 @@ class AdminConstraint def matches?(request) - return false unless request.session[:user_id] - user = User.find request.session[:user_id] + laboratory = Laboratory.first + return false unless request.session[:"#{laboratory.try(:identifier).split('.').first}_user_id"] + user = User.find request.session[:"#{laboratory.try(:identifier).split('.').first}_user_id"] user && user.admin? end end \ No newline at end of file diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index f03cbdef8..23240fa75 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -38,6 +38,8 @@ class AccountsController < ApplicationController return normal_status(-2, "验证码已失效") if !verifi_code&.effective? end + return normal_status(-1, "8~16位密码,支持字母数字和符号") unless params[:password] =~ CustomRegexp::PASSWORD + code = generate_identifier User, 8, pre login = pre + code @user = User.new(admin: false, login: login, mail: email, phone: phone, type: "User") @@ -114,6 +116,7 @@ class AccountsController < ApplicationController end return normal_status(-2, "验证码不正确") if verifi_code.try(:code) != code.strip return normal_status(-2, "验证码已失效") if !verifi_code&.effective? + return normal_status(-1, "8~16位密码,支持字母数字和符号") unless params[:new_password] =~ CustomRegexp::PASSWORD user.password, user.password_confirmation = params[:new_password], params[:new_password_confirmation] ActiveRecord::Base.transaction do @@ -123,7 +126,7 @@ class AccountsController < ApplicationController sucess_status rescue Exception => e uid_logger_error(e.message) - tip_exception("密码重置失败") + tip_exception(e.message) end end diff --git a/app/controllers/admins/daily_school_statistics_controller.rb b/app/controllers/admins/daily_school_statistics_controller.rb index eb9c75fbc..f0911f239 100644 --- a/app/controllers/admins/daily_school_statistics_controller.rb +++ b/app/controllers/admins/daily_school_statistics_controller.rb @@ -6,6 +6,7 @@ class Admins::DailySchoolStatisticsController < Admins::BaseController total_count, statistics = Admins::SchoolDailyStatisticService.call(params) @statistics = paginate statistics, total_count: total_count + @params_page = params[:page] || 1 respond_to do |format| format.html { load_statistic_total } diff --git a/app/controllers/admins/laboratory_settings_controller.rb b/app/controllers/admins/laboratory_settings_controller.rb index a65b13f59..283afc175 100644 --- a/app/controllers/admins/laboratory_settings_controller.rb +++ b/app/controllers/admins/laboratory_settings_controller.rb @@ -16,7 +16,7 @@ class Admins::LaboratorySettingsController < Admins::BaseController def form_params params.permit(:identifier, :name, - :nav_logo, :login_logo, :tab_logo, + :nav_logo, :login_logo, :tab_logo, :oj_banner, :subject_banner, :course_banner, :competition_banner, :moop_cases_banner, :footer, navbar: %i[name link hidden]) end diff --git a/app/controllers/admins/myshixuns_controller.rb b/app/controllers/admins/myshixuns_controller.rb index f70a64554..adc34e95e 100644 --- a/app/controllers/admins/myshixuns_controller.rb +++ b/app/controllers/admins/myshixuns_controller.rb @@ -6,6 +6,7 @@ class Admins::MyshixunsController < Admins::BaseController myshixuns = Admins::MyshixunQuery.call(params) @myshixuns = paginate myshixuns.includes(:last_executable_task, :last_task, shixun: :user, user: { user_extension: :school }) + @params_page = params[:page] || 1 myshixun_ids = @myshixuns.map(&:id) @finish_game_count = Game.where(myshixun_id: myshixun_ids, status: 2).group(:myshixun_id).count diff --git a/app/controllers/admins/school_statistics_controller.rb b/app/controllers/admins/school_statistics_controller.rb index fdd10c70f..5133cc997 100644 --- a/app/controllers/admins/school_statistics_controller.rb +++ b/app/controllers/admins/school_statistics_controller.rb @@ -10,6 +10,7 @@ class Admins::SchoolStatisticsController < Admins::BaseController @grow_summary = service.grow_summary total_count, statistics = service.call + @params_page = params[:page] || 1 @statistics = paginate statistics, total_count: total_count end diff --git a/app/controllers/admins/shixun_modify_records_controller.rb b/app/controllers/admins/shixun_modify_records_controller.rb new file mode 100644 index 000000000..43d9a4a16 --- /dev/null +++ b/app/controllers/admins/shixun_modify_records_controller.rb @@ -0,0 +1,9 @@ +class Admins::ShixunModifyRecordsController < Admins::BaseController + + def index + records = Admins::ShixunModifyRecordQuery.call(params) + + @records = paginate records.includes(:diff_record_content) + end + +end diff --git a/app/controllers/admins/shixun_settings_controller.rb b/app/controllers/admins/shixun_settings_controller.rb index bd54018cd..6dbbc077a 100644 --- a/app/controllers/admins/shixun_settings_controller.rb +++ b/app/controllers/admins/shixun_settings_controller.rb @@ -15,7 +15,8 @@ class Admins::ShixunSettingsController < Admins::BaseController hidden: params[:hidden].present? ? params[:hidden] : false, homepage_show: params[:homepage_show].present? ? params[:homepage_show] : false, task_pass: params[:task_pass].present? ? params[:task_pass] : false, - code_hidden: params[:code_hidden].present? ? params[:code_hidden] : false + code_hidden: params[:code_hidden].present? ? params[:code_hidden] : false, + vip: params[:vip].present? ? params[:vip] : false } @shixuns_type_check = MirrorRepository.pluck(:type_name,:id) @@ -126,6 +127,6 @@ class Admins::ShixunSettingsController < Admins::BaseController end def setting_params - params.permit(:use_scope,:excute_time,:close,:status,:can_copy,:webssh,:hidden,:homepage_show,:task_pass,:code_hidden,:page_no, :id,tag_repertoires:[]) + params.permit(:use_scope,:excute_time,:close,:status,:can_copy,:webssh,:hidden,:homepage_show,:task_pass,:code_hidden,:vip,:page_no,:id,tag_repertoires:[]) end end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 4f82a4c9b..a39789920 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1299,8 +1299,10 @@ class CoursesController < ApplicationController begin @all_members = @course.students search = params[:search] ? "#{params[:search].strip}" : "" #用户名或学生学号id搜索 - group_id = params[:group_id] #分班的班级id - @all_members = @all_members.where(course_group_id: group_id.map(&:to_i)) unless group_id.blank? + if params[:group_id].present? + group_ids = params[:group_id].is_a?(String) ? [params[:group_id].to_i] : params[:group_id].map(&:to_i) + @all_members = @all_members.where(course_group_id: group_ids) + end unless search.blank? @all_members = @all_members.joins(user: [:user_extension]).where('concat(users.lastname, users.firstname) like ? or user_extensions.student_id like ?',"%#{search}%","%#{search}%") end diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 0299fdf7d..25e0de44a 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -47,26 +47,26 @@ class FilesController < ApplicationController def bulk_publish return normal_status(403, "您没有权限进行操作") if current_user.course_identity(@course) >= 5 - tip_exception("请至少选择一个分班") if params[:group_ids].blank? && @course.course_groups.size != 0 + # tip_exception("请至少选择一个分班") if params[:group_ids].blank? && @course.course_groups.size != 0 attachments = @course.attachments.by_ids(@attachment_ids) ActiveRecord::Base.transaction do # 有分班设置时 - if @course.course_group_module? && @course.course_groups_count != 0 && params[:group_ids] - group_ids = params[:group_ids]&.reject(&:blank?) - charge_group_ids = @course.charge_group_ids(current_user) - publish_groups = charge_group_ids & group_ids if group_ids - - attachments.each do |atta| - if atta.published? && !atta.unified_setting || !atta.published? - create_atta_group_settings atta - atta.update_all(unified_setting: 0) if atta.unified_setting - none_publish_settings = atta.attachment_group_settings.where(course_group_id: publish_groups).none_published - none_publish_settings.update_all(publish_time: Time.now) - end - end - end + # if @course.course_group_module? && @course.course_groups_count != 0 && params[:group_ids] + # group_ids = params[:group_ids]&.reject(&:blank?) + # charge_group_ids = @course.charge_group_ids(current_user) + # publish_groups = charge_group_ids & group_ids if group_ids + # + # attachments.each do |atta| + # if atta.published? && !atta.unified_setting || !atta.published? + # create_atta_group_settings atta + # atta.update_attributes!(unified_setting: 0) if atta.unified_setting + # none_publish_settings = atta.attachment_group_settings.where(course_group_id: publish_groups).none_published + # none_publish_settings.update_all(publish_time: Time.now) + # end + # end + # end # 未发布的资源更新状态 attachments.where(is_publish: 0).update_all(is_publish: 1, publish_time: Time.now) @@ -140,7 +140,7 @@ class FilesController < ApplicationController def public_with_course_and_project @attachments = Attachment.publiced.simple_columns .contains_course_and_project - .includes(:author => :user_extension) + .includes(:container, author: :user_extension) .by_filename_or_user_name(params[:search]) .ordered(sort: 0, sort_type: 'created_on') @@ -361,15 +361,16 @@ class FilesController < ApplicationController def publish_params tip_exception("缺少发布参数") if params[:delay_publish].blank? @unified_setting = 1 - if params[:delay_publish].to_i == 1 && @course.course_group_module? && @course.course_groups_count != 0 - tip_exception("分班发布设置不能为空") if params[:group_settings].blank? - min_publish_time = params[:group_settings].pluck(:publish_time).reject(&:blank?).min - max_publish_time = params[:group_settings].pluck(:publish_time).reject(&:blank?).max - tip_exception("分班发布设置不能为空") if min_publish_time.blank? - - # 分班设置中的时间一样且包含所有分班 则按统一设置处理,否则是非统一设置 - @unified_setting = 0 unless min_publish_time == max_publish_time && params[:group_settings].pluck(:group_id).flatten.sort == @course.course_groups.pluck(:id).sort - elsif params[:delay_publish].to_i == 1 + # if params[:delay_publish].to_i == 1 && @course.course_group_module? && @course.course_groups_count != 0 + # tip_exception("分班发布设置不能为空") if params[:group_settings].blank? + # min_publish_time = params[:group_settings].pluck(:publish_time).reject(&:blank?).min + # max_publish_time = params[:group_settings].pluck(:publish_time).reject(&:blank?).max + # tip_exception("分班发布设置不能为空") if min_publish_time.blank? + # + # # 分班设置中的时间一样且包含所有分班 则按统一设置处理,否则是非统一设置 + # @unified_setting = 0 unless min_publish_time == max_publish_time && params[:group_settings].pluck(:group_id).flatten.sort == @course.course_groups.pluck(:id).sort + # els + if params[:delay_publish].to_i == 1 tip_exception("缺少延期发布的时间参数") if params[:publish_time].blank? min_publish_time = params[:publish_time] end diff --git a/app/controllers/hack_user_lastest_codes_controller.rb b/app/controllers/hack_user_lastest_codes_controller.rb index 37102a166..b7ec6fb8e 100644 --- a/app/controllers/hack_user_lastest_codes_controller.rb +++ b/app/controllers/hack_user_lastest_codes_controller.rb @@ -1,13 +1,14 @@ class HackUserLastestCodesController < ApplicationController before_action :require_login, except: [:listen_result] - before_action :find_my_hack, only: [:show, :code_debug, :code_submit, :update_code, + before_action :find_my_hack, only: [:show, :code_debug, :code_submit, :update_code, :sync_code, :listen_result, :result, :submit_records, :restore_initial_code] before_action :update_user_hack_status, only: [:code_debug, :code_submit] - before_action :require_auth_identity, only: [:update_code, :restore_initial_code] + before_action :require_auth_identity, only: [:update_code, :restore_initial_code, :sync_code] before_action :require_manager_identity, only: [:update_code] def show @my_hack.update_attribute(:submit_status, 0) if @my_hack.submit_status == 1 + @modify = @my_hack.modify_time.to_i < @hack.hack_codes.first.modify_time.to_i end def update_code @@ -15,10 +16,14 @@ class HackUserLastestCodesController < ApplicationController render_ok end - # 回复初始代码 + # 恢复初始代码 def restore_initial_code @my_hack.update_attribute(:code, @hack.code) - render_ok + end + + # 同步代码 + def sync_code + @my_hack.update_attributes(code: @hack.code, modify_time: @hack.modify_time) end # 调试代码 @@ -55,12 +60,15 @@ class HackUserLastestCodesController < ApplicationController end # 提交记录 - def submit_records;end + def submit_records + @records = @my_hack.hack_user_codes.created_order + end # 提交记录详情 def record_detail @hack_user = HackUserCode.find params[:id] + @my_hack = @hack_user.hack_user_lastest_code end # 接收中间件返回结果接口 diff --git a/app/controllers/hacks_controller.rb b/app/controllers/hacks_controller.rb index 993cba4e6..c9e9097f8 100644 --- a/app/controllers/hacks_controller.rb +++ b/app/controllers/hacks_controller.rb @@ -1,7 +1,7 @@ class HacksController < ApplicationController before_action :require_login, except: [:index] before_action :find_hack, only: [:edit, :update, :publish, :start, :update_set, :delete_set] - before_action :require_teacher_identity, only: [:create, :update_set] + before_action :require_teacher_identity, only: [:create, :update_set, :edit, :update] before_action :require_auth_identity, only: [:update, :edit, :publish, :update_set, :delete_set] @@ -15,7 +15,7 @@ class HacksController < ApplicationController user_hack.identifier else user_identifier = generate_identifier HackUserLastestCode, 12 - user_code = {user_id: current_user.id, code: @hack.code, + user_code = {user_id: current_user.id, code: @hack.code, modify_time: Time.now, identifier: user_identifier, language: @hack.language} @hack.hack_user_lastest_codes.create!(user_code) user_identifier @@ -47,10 +47,10 @@ class HacksController < ApplicationController hack.identifier = generate_identifier Hack, 8 hack.save! # 创建测试集与代码 - logger.info("hack_sets_params:#{hack_sets_params}") - logger.info("hack_code_params:#{hack_code_params}") hack.hack_sets.create!(hack_sets_params) - hack.hack_codes.create!(hack_code_params) + hack_codes = hack.hack_codes.new(hack_code_params) + hack_codes.modify_time = Time.now + hack_codes.save! end render_ok({identifier: hack.identifier}) rescue Exception => e @@ -69,7 +69,8 @@ class HacksController < ApplicationController # 新建 @hack.hack_sets.create!(hack_sets_params) # 更新代码 - @hack.hack_codes.create!(hack_code_params) + code_params = params[:hack_codes][:code] != @hack.code ? hack_code_params.merge(modify_time: Time.now) : hack_code_params + @hack.hack_codes.first.update_attributes!(code_params) end render_ok rescue Exception => e @@ -109,6 +110,8 @@ class HacksController < ApplicationController def edit;end + def new;end + private # 实名认证老师,管理员与运营人员权限 def require_teacher_identity @@ -199,7 +202,7 @@ class HacksController < ApplicationController end def start_hack_auth - return true if @hack == 1 + return true if @hack.status == 1 require_auth_identity end diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 1c6b606e5..e11fefea1 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -453,7 +453,9 @@ class HomeworkCommonsController < ApplicationController # 课堂结束后不能再更新 unless @course.is_end + UpdateHomeworkPublishSettingService.call(@homework, publish_params) # 作业未发布时,unified_setting参数不能为空 +=begin if @homework.publish_time.nil? || @homework.publish_time > Time.now tip_exception("缺少统一设置的参数") if params[:unified_setting].nil? if params[:unified_setting] || @course.course_groups_count == 0 @@ -549,6 +551,7 @@ class HomeworkCommonsController < ApplicationController @homework.end_time = @homework.max_group_end_time end end +=end # 补交设置 tip_exception("缺少allow_late参数") if params[:allow_late].nil? @@ -582,8 +585,8 @@ class HomeworkCommonsController < ApplicationController tip_exception("缺少answer_open_evaluation参数") if params[:answer_open_evaluation].nil? tip_exception("缺少work_efficiency参数") if params[:work_efficiency].nil? tip_exception("缺少eff_score参数") if params[:work_efficiency] && params[:eff_score].blank? - tip_exception("效率分不能小于等于0") if params[:eff_score] && params[:eff_score].to_f <= 0 - tip_exception("效率分不能大于总分值") if params[:eff_score] && params[:eff_score].to_f.round(2) > params[:total_score].to_f.round(2) + tip_exception("效率分不能小于等于0") if params[:work_efficiency] && params[:eff_score] && params[:eff_score].to_f <= 0 + tip_exception("效率分不能大于总分值") if params[:work_efficiency] && params[:eff_score] && params[:eff_score].to_f.round(2) > params[:total_score].to_f.round(2) tip_exception("缺少shixun_evaluation参数") if params[:shixun_evaluation].blank? tip_exception("缺少challenge_settings参数") if params[:challenge_settings].blank? # tip_exception("缺少challenge_id参数") if params[:challenge_settings][:challenge_id].blank? @@ -635,7 +638,7 @@ class HomeworkCommonsController < ApplicationController @homework.save! if score_change && @homework.end_or_late_none_group - UpdateShixunWorkScoreJob.perform_now(@homework.id) + UpdateShixunWorkScoreJob.perform_later(@homework.id) elsif update_eff_score && (@homework.end_or_late_none_group || @homework.max_efficiency > 0) # 更新所有学生的效率分(作业允许补交且补交已截止 或者 作业不允许补交且提交已截止 或者作业已计算过效率分) HomeworksService.new.update_student_eff_score HomeworkCommon.find_by(id: @homework.id) @@ -826,12 +829,16 @@ class HomeworkCommonsController < ApplicationController end end - - HomeworkCommonPushNotifyJob.perform_later(@homework.id, publish_group_ids) if send_tiding normal_status(0, "更新成功") else tip_exception("课堂已结束不能再更新") end + # rescue ActiveRecord::RecordInvalid + # render_error("保存失败") + # rescue ApplicationService::Error => ex + # uid_logger(ex.message) + # render_error(ex.message) + # raise ActiveRecord::Rollback rescue Exception => e uid_logger(e.backtrace) tip_exception(e.message) @@ -1101,7 +1108,7 @@ class HomeworkCommonsController < ApplicationController else homework.unified_setting = false # 创建作业分班设置:homework_group_setting - create_homework_group_settings(homework) + homework.create_homework_group_settings # 选中的分班设置的发布时间改为当前时间,截止时间改为传的截止时间参数 if params[:detail] @@ -1137,7 +1144,7 @@ class HomeworkCommonsController < ApplicationController # 发消息 HomeworkCommonPushNotifyJob.perform_later(homework.id, tiding_group_ids) else - create_homework_group_settings(homework) + homework.create_homework_group_settings none_publish_settings = homework.homework_group_settings.where(course_group_id: publish_groups).none_published if params[:detail] @@ -1211,7 +1218,7 @@ class HomeworkCommonsController < ApplicationController # 分组设置 if !params[:group_ids].blank? # 确保之前是统一设置或者有新创建的分班的数据一致性 - create_homework_group_settings(homework) + homework.create_homework_group_settings homework.unified_setting = false if homework.unified_setting && end_groups.length != @course.course_groups_count @@ -1582,15 +1589,6 @@ class HomeworkCommonsController < ApplicationController end - def create_homework_group_settings homework - if homework.homework_group_settings.size != @course.course_groups.size - @course.course_groups.where.not(id: homework.homework_group_settings.pluck(:course_group_id)).each do |group| - homework.homework_group_settings << HomeworkGroupSetting.new(course_group_id: group.id, course_id: @course.id, - publish_time: homework.publish_time, end_time: homework.end_time) - end - end - end - def get_new_code_reviews_result homework if homework.code_reviews_new_results? # 获取最新的查询id @@ -1653,4 +1651,8 @@ class HomeworkCommonsController < ApplicationController homework_bank end + def publish_params + params.permit(:unified_setting, :publish_time, :end_time, group_settings: [:publish_time, :end_time, group_id: []]) + end + end diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 068a0dafd..0c442a613 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -1409,23 +1409,29 @@ class PollsController < ApplicationController poll_questions.each do |q| user_poll_votes = u_user.poll_votes.find_current_vote("poll_question_id",q.id) if user_poll_votes.present? - user_poll_answer_ids = user_poll_votes.pluck(:poll_answer_id).reject(&:blank?) - user_poll_vote_texts = user_poll_votes.pluck(:vote_text).reject(&:blank?) - if user_poll_answer_ids.count > 0 - answer_content = q.poll_answers.find_answer_by_custom("id",user_poll_answer_ids) - if user_poll_answer_ids.count >1 - u_answer = answer_content.pluck(:answer_text).join(";") + if q.question_type < 3 + user_poll_answer_ids = user_poll_votes.pluck(:poll_answer_id).reject(&:blank?) + if user_poll_answer_ids.count > 0 + answer_content = q.poll_answers.find_answer_by_custom("id",user_poll_answer_ids) + if user_poll_answer_ids.count >1 + u_answer = answer_content.pluck(:answer_text).join(";") + else + u_answer = answer_content.first&.answer_text + end else - u_answer = answer_content.first.answer_text + u_answer = "--" end - elsif user_poll_vote_texts.count > 0 - if user_poll_vote_texts.count > 1 - u_answer = user_poll_vote_texts.join(";") + else + user_poll_vote_texts = user_poll_votes.pluck(:vote_text).reject(&:blank?) + if user_poll_vote_texts.count > 0 + if user_poll_vote_texts.count > 1 + u_answer = user_poll_vote_texts.join(";") + else + u_answer = user_poll_vote_texts.first + end else - u_answer = user_poll_vote_texts.first + u_answer = "--" end - else - u_answer = "--" end else u_answer = "--" diff --git a/app/controllers/users/authentication_applies_controller.rb b/app/controllers/users/authentication_applies_controller.rb index 3c43be553..bf5aa0d40 100644 --- a/app/controllers/users/authentication_applies_controller.rb +++ b/app/controllers/users/authentication_applies_controller.rb @@ -1,5 +1,6 @@ class Users::AuthenticationAppliesController < Users::BaseAccountController before_action :private_user_resources! + before_action :check_account, only: [:create] def create Users::ApplyAuthenticationService.call(observed_user, create_params) diff --git a/app/controllers/users/professional_auth_applies_controller.rb b/app/controllers/users/professional_auth_applies_controller.rb index d1ee70953..9fc8e73db 100644 --- a/app/controllers/users/professional_auth_applies_controller.rb +++ b/app/controllers/users/professional_auth_applies_controller.rb @@ -1,5 +1,6 @@ class Users::ProfessionalAuthAppliesController < Users::BaseAccountController before_action :private_user_resources! + before_action :check_account, only: [:create] def create Users::ApplyProfessionalAuthService.call(observed_user, create_params) diff --git a/app/controllers/weapps/courses_controller.rb b/app/controllers/weapps/courses_controller.rb index 1ccefcbe2..a30fdfa4c 100644 --- a/app/controllers/weapps/courses_controller.rb +++ b/app/controllers/weapps/courses_controller.rb @@ -6,7 +6,7 @@ class Weapps::CoursesController < Weapps::BaseController before_action :teacher_or_admin_allowed, only: [:change_member_roles, :delete_course_teachers] def create - return render_error("只有老师身份才能创建课堂") unless current_user.is_teacher? + # return render_error("只有老师身份才能创建课堂") unless current_user.is_teacher? course = Course.new(tea_id: current_user.id) Weapps::CreateCourseService.call(course, course_params) render_ok @@ -107,7 +107,7 @@ class Weapps::CoursesController < Weapps::BaseController # 批量修改角色 def change_member_roles @course = current_course - tip_exception("请至少选择一个角色") if params[:roles].blank? + tip_exception("请至少选择一个角色") if params[:roles].reject(&:blank?).blank? tip_exception("不能具有老师、助教两种角色") if params[:roles].include?("PROFESSOR") && params[:roles].include?("ASSISTANT_PROFESSOR") params[:user_ids].each do |user_id| @@ -150,13 +150,13 @@ class Weapps::CoursesController < Weapps::BaseController new_student.is_active = 0 if correspond_teacher_exist new_student.save! - CourseAddStudentCreateWorksJob.perform_later(@course.id, user_id) + CourseAddStudentCreateWorksJob.perform_later(@course.id, [user_id]) # StudentJoinCourseNotifyJob.perform_later(current_user.id, course.id) elsif !params[:roles].include?("STUDENT") && student_member.present? # 删除学生身份时激活老师身份 teacher_member.update_attributes!(is_active: 1) if student_member.is_active && teacher_member.present? student_member.destroy! - CourseDeleteStudentDeleteWorksJob.perform_later(@course.id, user_id) + CourseDeleteStudentDeleteWorksJob.perform_later(@course.id, [user_id]) # CourseDeleteStudentNotifyJob.perform_later(@course.id, [params[:user_id]], current_user.id) elsif params[:roles].include?("STUDENT") && student_member.present? && !params[:roles].include?("PROFESSOR") && !params[:roles].include?("ASSISTANT_PROFESSOR") # 学生身份存在且学生没有教师身份时更新is_active diff --git a/app/controllers/weapps/homework_commons_controller.rb b/app/controllers/weapps/homework_commons_controller.rb new file mode 100644 index 000000000..ebadd00b0 --- /dev/null +++ b/app/controllers/weapps/homework_commons_controller.rb @@ -0,0 +1,38 @@ +class Weapps::HomeworkCommonsController < Weapps::BaseController + before_action :require_login + before_action :find_homework, :user_course_identity + before_action :teacher_allowed + + def update_settings + begin + # 课堂结束后不能再更新 + unless @course.is_end + UpdateHomeworkPublishSettingService.call(@homework, publish_params) + render_ok + else + tip_exception("课堂已结束不能再更新") + end + rescue Exception => e + uid_logger(e.backtrace) + tip_exception(e.message) + raise ActiveRecord::Rollback + end + end + + private + + def teacher_allowed + return render_forbidden unless @user_course_identity < Course::STUDENT + end + + def find_homework + @homework = HomeworkCommon.find_by!(id: params[:id]) + @course = @homework.course + @homework_detail_manual = @homework.homework_detail_manual + end + + def publish_params + params.permit(:unified_setting, :publish_time, :end_time, group_settings: [:publish_time, :end_time, group_id: []]) + end + +end \ No newline at end of file diff --git a/app/forms/users/update_password_form.rb b/app/forms/users/update_password_form.rb index 4da341839..db674384c 100644 --- a/app/forms/users/update_password_form.rb +++ b/app/forms/users/update_password_form.rb @@ -3,5 +3,5 @@ class Users::UpdatePasswordForm attr_accessor :password, :old_password - validates :password, presence: true + validates :password, presence: true, length: { minimum: 8, maximum: 16 }, format: { with: CustomRegexp::PASSWORD, message: "8~16位密码,支持字母数字和符号" } end \ No newline at end of file diff --git a/app/libs/custom_regexp.rb b/app/libs/custom_regexp.rb index 2a2a99384..2980f2ed2 100644 --- a/app/libs/custom_regexp.rb +++ b/app/libs/custom_regexp.rb @@ -3,4 +3,5 @@ module CustomRegexp EMAIL = /\A[a-zA-Z0-9]+([._\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+\z/ LASTNAME = /\A[a-zA-Z0-9\u4e00-\u9fa5]+\z/ NICKNAME = /\A[\u4e00-\u9fa5_a-zA-Z0-9]+\z/ + PASSWORD = /\A[a-z_A-Z0-9\-\.!@#\$%\\\^&\*\)\(\+=\{\}\[\]\/",'_<>~\·`\?:;|]{8,16}\z/ end \ No newline at end of file diff --git a/app/models/attachment.rb b/app/models/attachment.rb index a918f4e0a..f18d9cd2a 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -21,7 +21,7 @@ class Attachment < ApplicationRecord scope :contains_only_project, -> { where(container_type: 'Project') } scope :contains_course_and_project, -> { contains_only_course.or(contains_only_project) } scope :mine, -> (author_id) { where(author_id: author_id) } - scope :simple_columns, -> { select(:id, :filename, :filesize, :created_on, :cloud_url, :author_id, :content_type) } + scope :simple_columns, -> { select(:id, :filename, :filesize, :created_on, :cloud_url, :author_id, :content_type, :container_type, :container_id) } scope :search_by_container, -> (ids) {where(container_id: ids)} scope :unified_setting, -> {where("unified_setting = ? ", 1)} @@ -35,7 +35,7 @@ class Attachment < ApplicationRecord def title title = filename - if container.is_a?(StudentWork) && author_id != User.current.id + if container && container.is_a?(StudentWork) && author_id != User.current.id course = container&.homework_common&.course unless User.current.teacher_of_course?(course) title = "#{Time.now.strftime('%Y%m%d%H%M%S')}_#{DCODES.sample(8).join}" + File.extname(filename) diff --git a/app/models/hack.rb b/app/models/hack.rb index 80724d3d4..506cd4942 100644 --- a/app/models/hack.rb +++ b/app/models/hack.rb @@ -3,6 +3,8 @@ class Hack < ApplicationRecord # diffcult: 难度 1:简单;2:中等; 3:困难 # 编程题 validates_length_of :name, maximum: 60 + validates :description, presence: { message: "描述不能为空" } + validates :name, presence: { message: "名称不能为空" } # 测试集 has_many :hack_sets, ->{order("position asc")}, :dependent => :destroy # 代码 @@ -39,4 +41,9 @@ class Hack < ApplicationRecord hack_sets.first&.input end + # 管理员 + def manager?(user) + user_id == user.id || user.admin_or_business? + end + end diff --git a/app/models/hack_set.rb b/app/models/hack_set.rb index 5dab862b5..6afe05663 100644 --- a/app/models/hack_set.rb +++ b/app/models/hack_set.rb @@ -1,6 +1,7 @@ class HackSet < ApplicationRecord - validates :input, presence: { message: "测试集输入不能为空" } + #validates :input, presence: { message: "测试集输入不能为空" } validates :output, presence: { message: "测试集输出不能为空" } + validates_uniqueness_of :input, scope: [:hack_id, :input], message: "多个测试集的输入不能相同" # 编程题测试集 belongs_to :hack end diff --git a/app/models/hack_user_code.rb b/app/models/hack_user_code.rb index d9d2dff77..eee394e39 100644 --- a/app/models/hack_user_code.rb +++ b/app/models/hack_user_code.rb @@ -1,4 +1,7 @@ class HackUserCode < ApplicationRecord # 用户编程题的信息 belongs_to :hack + belongs_to :hack_user_lastest_code + + scope :created_order, ->{ order("created_at desc")} end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index def3b6b0d..d37650c37 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -285,6 +285,15 @@ class HomeworkCommon < ApplicationRecord homework_challenge_settings.find_by(challenge_id: challenge_id)&.score.to_f end + def create_homework_group_settings + if homework_group_settings.size != course.course_groups.size + course.course_groups.where.not(id: homework_group_settings.pluck(:course_group_id)).each do |group| + homework_group_settings << HomeworkGroupSetting.new(course_group_id: group.id, course_id: course.id, + publish_time: publish_time, end_time: end_time) + end + end + end + def update_homework_work_score if unified_setting works = student_works diff --git a/app/models/laboratory_setting.rb b/app/models/laboratory_setting.rb index 416020836..4eacaf460 100644 --- a/app/models/laboratory_setting.rb +++ b/app/models/laboratory_setting.rb @@ -42,6 +42,10 @@ class LaboratorySetting < ApplicationRecord image_url('_moop_cases_banner') end + def oj_banner_url + image_url('_oj_banner') + end + def default_navbar self.class.default_config[:navbar] end diff --git a/app/queries/admins/shixun_modify_record_query.rb b/app/queries/admins/shixun_modify_record_query.rb new file mode 100644 index 000000000..227e2f4c2 --- /dev/null +++ b/app/queries/admins/shixun_modify_record_query.rb @@ -0,0 +1,33 @@ +class Admins::ShixunModifyRecordQuery < ApplicationQuery + attr_reader :params + + def initialize(params) + @params = params + end + + def call + if params[:user_name].blank? || params[:date].blank? + records = DiffRecord.none + else + records = DiffRecord.joins(:user).where("concat(users.lastname, users.firstname) like ?", "%#{params[:user_name].strip}%") + if time_range.present? + records = records.where(created_at: time_range) + end + end + records.order("diff_records.created_at desc") + end + + private + + def time_range + @_time_range ||= begin + case params[:date] + when 'weekly' then 1.weeks.ago..Time.now + when 'monthly' then 1.months.ago..Time.now + when 'quarterly' then 3.months.ago..Time.now + when 'yearly' then 1.years.ago..Time.now + else '' + end + end + end +end diff --git a/app/queries/admins/shixun_settings_query.rb b/app/queries/admins/shixun_settings_query.rb index ab871b58e..377e7bf60 100644 --- a/app/queries/admins/shixun_settings_query.rb +++ b/app/queries/admins/shixun_settings_query.rb @@ -51,6 +51,7 @@ class Admins::ShixunSettingsQuery < ApplicationQuery all_shixuns = all_shixuns.where(homepage_show: params[:homepage_show]) if params[:homepage_show] all_shixuns = all_shixuns.where(task_pass: params[:task_pass]) if params[:task_pass] all_shixuns = all_shixuns.where(code_hidden: params[:code_hidden]) if params[:code_hidden] + all_shixuns = all_shixuns.where(vip: params[:vip]) if params[:vip] custom_sort(all_shixuns, params[:sort_by], params[:sort_direction]) end diff --git a/app/services/admins/check_shixun_mirrors_service.rb b/app/services/admins/check_shixun_mirrors_service.rb index 8334df485..4aa0af4cf 100644 --- a/app/services/admins/check_shixun_mirrors_service.rb +++ b/app/services/admins/check_shixun_mirrors_service.rb @@ -75,13 +75,12 @@ class Admins::CheckShixunMirrorsService < ApplicationService def bridge_images @_bridge_images ||= begin - url = EduSetting.get('cloud_bridge') + url = "#{EduSetting.get('cloud_bridge')}/bridge/docker/images" res = Faraday.get(url) - res_body = JSON.parse(res.body) + res = JSON.parse(res.body) + raise Error, '拉取镜像信息异常' if res && res['code'] != 0 - raise Error, '拉取镜像信息异常' if res_body && res_body['code'].to_i != 0 - - res_body + res rescue => e Rails.logger.error("get response failed ! #{e.message}") raise Error, '实训云平台繁忙(繁忙等级:84)' diff --git a/app/services/admins/save_laboratory_setting_service.rb b/app/services/admins/save_laboratory_setting_service.rb index b35323608..c29e374bd 100644 --- a/app/services/admins/save_laboratory_setting_service.rb +++ b/app/services/admins/save_laboratory_setting_service.rb @@ -43,6 +43,7 @@ class Admins::SaveLaboratorySettingService < ApplicationService save_image_file(params[:course_banner], '_course_banner') save_image_file(params[:competition_banner], '_competition_banner') save_image_file(params[:moop_cases_banner], '_moop_cases_banner') + save_image_file(params[:oj_banner], '_oj_banner') end def save_image_file(file, type) diff --git a/app/services/create_diff_record_service.rb b/app/services/create_diff_record_service.rb index 8365404e2..3943af1ae 100644 --- a/app/services/create_diff_record_service.rb +++ b/app/services/create_diff_record_service.rb @@ -25,21 +25,23 @@ class CreateDiffRecordService < ApplicationService index = 0 fragment_size = 1 Diffy::Diff.new(before, after).each do |line| - unless line =~ /^[\+-]/ - if arr.empty? && index < fragment_size - content += line - index += 1 - else - index = 0 - arr << line - arr.shift if arr.size > fragment_size + unless line.include?("\\ 文件尾没有 newline 字符") + unless line =~ /^[\+-]/ + if arr.empty? && index < fragment_size + content += line + index += 1 + else + index = 0 + arr << line + arr.shift if arr.size > fragment_size + end + next end - next - end - content += arr.join('') if arr.present? - content += line - arr.clear + content += arr.join('') if arr.present? + content += line + arr.clear + end end content end diff --git a/app/services/update_homework_publish_setting_service.rb b/app/services/update_homework_publish_setting_service.rb new file mode 100644 index 000000000..69a68b613 --- /dev/null +++ b/app/services/update_homework_publish_setting_service.rb @@ -0,0 +1,116 @@ +class UpdateHomeworkPublishSettingService < ApplicationService + attr_reader :homework, :params + + def initialize(homework, params) + @params = params + @homework = homework + end + + def call + puts params + course = homework.course + # 作业未发布时,unified_setting参数不能为空 + if homework.publish_time.nil? || homework.publish_time > Time.now + tip_exception("缺少统一设置的参数") if params[:unified_setting].nil? + if params[:unified_setting] || course.course_groups_count == 0 + tip_exception("发布时间不能为空") if params[:publish_time].blank? + tip_exception("截止时间不能为空") if params[:end_time].blank? + tip_exception("发布时间不能早于当前时间") if params[:publish_time] <= Time.now.strftime("%Y-%m-%d %H:%M:%S") + tip_exception("截止时间不能早于当前时间") if params[:end_time] <= Time.now.strftime("%Y-%m-%d %H:%M:%S") + tip_exception("截止时间不能早于发布时间") if params[:publish_time] > params[:end_time] + tip_exception("截止时间不能晚于课堂结束时间(#{course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if + course.end_date.present? && params[:end_time] > course.end_date.end_of_day + + homework.unified_setting = 1 + homework.homework_group_settings.destroy_all + homework.publish_time = params[:publish_time] + # 截止时间为空时取发布时间后一个月 + homework.end_time = params[:end_time] + + else + tip_exception("分班发布设置不能为空") if params[:group_settings].blank? + # 创建作业的分班设置 + homework.create_homework_group_settings + + setting_group_ids = [] + + params[:group_settings].each do |setting| + tip_exception("分班id不能为空") if setting[:group_id].length == 0 + tip_exception("发布时间不能为空") if setting[:publish_time].blank? + tip_exception("截止时间不能为空") if setting[:end_time].blank? + tip_exception("发布时间不能早于当前时间") if setting[:publish_time].to_time <= Time.now + tip_exception("截止时间不能早于当前时间") if setting[:end_time].to_time <= Time.now + tip_exception("截止时间不能早于发布时间") if setting[:publish_time].to_time > setting[:end_time].to_time + tip_exception("截止时间不能晚于课堂结束时间(#{course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if + course.end_date.present? && setting[:end_time] > course.end_date.end_of_day + + + publish_time = setting[:publish_time] == "" ? Time.now : setting[:publish_time] + # 截止时间为空时取发布时间后一个月 + end_time = setting[:end_time] + HomeworkGroupSetting.where(homework_common_id: homework.id, course_group_id: setting[:group_id]). + update_all(publish_time: publish_time, end_time: end_time) + setting_group_ids << setting[:group_id] + end + + # 未设置的分班:发布时间和截止时间都为nil + HomeworkGroupSetting.where.not(course_group_id: setting_group_ids).where(homework_common_id: homework.id). + update_all(publish_time: nil, end_time: nil) + + # 记录已发布需要发消息的分班 + publish_group_ids = HomeworkGroupSetting.where(homework_common_id: homework.id).group_published.pluck(:course_group_id) + + homework.unified_setting = 0 + homework.publish_time = homework.min_group_publish_time + homework.end_time = homework.max_group_end_time + end + + # 如果作业立即发布则更新状态、发消息 + if homework.publish_time <= Time.now and homework_detail_manual.comment_status == 0 + homework_detail_manual.comment_status = 1 + send_tiding = true + end + + # 作业在"提交中"状态时 + else + if homework.end_time > Time.now && homework.unified_setting + tip_exception("截止时间不能为空") if params[:end_time].blank? + tip_exception("截止时间不能早于当前时间") if params[:end_time].to_time <= Time.now + tip_exception("截止时间不能晚于课堂结束时间(#{course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if + course.end_date.present? && params[:end_time].to_time > course.end_date.end_of_day + + homework.end_time = params[:end_time] + + elsif !homework.unified_setting + homework.create_homework_group_settings + tip_exception("分班发布设置不能为空") if params[:group_settings].reject(&:blank?).blank? + params[:group_settings].each do |setting| + group_settings = HomeworkGroupSetting.where(homework_common_id: homework.id, course_group_id: setting[:group_id]) + + tip_exception("分班id不能为空") if setting[:group_id].length == 0 + tip_exception("发布时间不能为空") if setting[:publish_time].blank? + tip_exception("截止时间不能为空") if setting[:end_time].blank? + # 如果该发布规则 没有已发布的分班则需判断发布时间 + tip_exception("发布时间不能早于等于当前时间") if setting[:publish_time].to_time <= Time.now && group_settings.group_published.count == 0 + + tip_exception("截止时间不能早于等于当前时间") if setting[:end_time].to_time <= Time.now && group_settings.none_end.count > 0 + tip_exception("截止时间不能早于发布时间") if setting[:publish_time].to_time > setting[:end_time].to_time + tip_exception("截止时间不能晚于课堂结束时间(#{course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if + course.end_date.present? && setting[:end_time].to_time > course.end_date.end_of_day + + group_settings.none_published.update_all(publish_time: setting[:publish_time]) + group_settings.none_end.update_all(end_time: setting[:end_time]) + end + + homework.end_time = homework.max_group_end_time + end + end + homework.save! + HomeworkCommonPushNotifyJob.perform_later(homework.id, publish_group_ids) if send_tiding + end + + private + def tip_exception(status = -1, message) + raise Educoder::TipException.new(status, message) + end +end \ No newline at end of file diff --git a/app/views/admins/courses/shared/_list.html.erb b/app/views/admins/courses/shared/_list.html.erb index 633616462..4105c8153 100644 --- a/app/views/admins/courses/shared/_list.html.erb +++ b/app/views/admins/courses/shared/_list.html.erb @@ -1,30 +1,31 @@ + - + - + - - + + <% if courses.present? %> - <% courses.each do |course| %> + <% courses.each_with_index do |course, index| %> - <%= render 'admins/courses/shared/td', course: course %> + <%= render partial: 'admins/courses/shared/td', locals: {course: course, no: index} %> <% end %> <% else %> diff --git a/app/views/admins/courses/shared/_td.html.erb b/app/views/admins/courses/shared/_td.html.erb index 1d2da2a33..51cc4b199 100644 --- a/app/views/admins/courses/shared/_td.html.erb +++ b/app/views/admins/courses/shared/_td.html.erb @@ -1,3 +1,4 @@ +
序号 ID 课堂名称成员成员 资源 普通作业 分组作业 实训作业 试卷评测次数评测次数 私有 状态 单位 创建者 <%= sort_tag('创建时间', name: 'created_at', path: admins_courses_path) %> 首页邮件通知操作邮件通知操作
<%= list_index_no((params[:page] || 1).to_i, no) %> <%= course.id %> <%= link_to(course.name, "/courses/#{course.id}", target: '_blank') %> diff --git a/app/views/admins/courses/update.js.erb b/app/views/admins/courses/update.js.erb index 1278a2e1f..983ac22f0 100644 --- a/app/views/admins/courses/update.js.erb +++ b/app/views/admins/courses/update.js.erb @@ -1 +1,3 @@ -$("#course-item-<%= @course.id %>").html("<%= j render partial: "admins/courses/shared/td",locals: {course: @course} %>") \ No newline at end of file +var index = $("#course-item-<%= @course.id %>").children(":first").html(); +$("#course-item-<%= @course.id %>").html("<%= j render partial: "admins/courses/shared/td",locals: {course: @course, no: 1} %>"); +$("#course-item-<%= @course.id %>").children(":first").html(index); \ No newline at end of file diff --git a/app/views/admins/customers/shared/_list.html.erb b/app/views/admins/customers/shared/_list.html.erb index 0ba5638cb..6f84db4e5 100644 --- a/app/views/admins/customers/shared/_list.html.erb +++ b/app/views/admins/customers/shared/_list.html.erb @@ -1,15 +1,17 @@ - + + <% if customers.present? %> - <% customers.each do |customer| %> + <% customers.each_with_index do |customer, index| %> +
客户名称序号客户名称 <%= sort_tag('添加时间', name: 'created_at', path: admins_partner_customers_path(current_partner)) %> 操作
<%= list_index_no((params[:page] || 1).to_i, index) %> <%= customer.school&.name %> <%= customer.created_at&.strftime('%Y-%m-%d %H:%M') %> diff --git a/app/views/admins/daily_school_statistics/shared/_list.html.erb b/app/views/admins/daily_school_statistics/shared/_list.html.erb index 611acdd2a..6982891ee 100644 --- a/app/views/admins/daily_school_statistics/shared/_list.html.erb +++ b/app/views/admins/daily_school_statistics/shared/_list.html.erb @@ -1,8 +1,8 @@ + - @@ -16,13 +16,14 @@ - + <% if statistics.present? %> - <% statistics.each do |statistic| %> + <% statistics.each_with_index do |statistic, index| %> +
序号 单位名称<%= sort_tag('教师总数', name: 'teacher_count', path: admins_daily_school_statistics_path) %> <%= sort_tag('学生总数', name: 'student_count', path: admins_daily_school_statistics_path) %> <%= sort_tag('课堂总数', name: 'course_count', path: admins_daily_school_statistics_path) %> <%= sort_tag('实训作业总数', name: 'homework_count', path: admins_daily_school_statistics_path) %> <%= sort_tag('其它作业总数', name: 'other_homework_count', path: admins_daily_school_statistics_path) %><%= sort_tag('动态时间', name: 'nearly_course_time', path: admins_daily_school_statistics_path) %><%= sort_tag('动态时间', name: 'nearly_course_time', path: admins_daily_school_statistics_path) %>
<%= list_index_no(@params_page.to_i, index) %> <%= link_to statistic[:name], "/colleges/#{statistic[:id]}/statistics", target: '_blank', data: { toggle: 'tooltip', title: '点击查看学校统计概况' } %> diff --git a/app/views/admins/department_applies/shared/_list.html.erb b/app/views/admins/department_applies/shared/_list.html.erb index 0a1d803be..87d5ab66f 100644 --- a/app/views/admins/department_applies/shared/_list.html.erb +++ b/app/views/admins/department_applies/shared/_list.html.erb @@ -1,18 +1,20 @@ + - + <% if applies.present? %> - <% applies.each do |apply| %> + <% applies.each_with_index do |apply, index| %> + diff --git a/app/views/admins/department_members/create.js.erb b/app/views/admins/department_members/create.js.erb index 4355c7432..6bf0a6ac3 100644 --- a/app/views/admins/department_members/create.js.erb +++ b/app/views/admins/department_members/create.js.erb @@ -1,4 +1,6 @@ $('.modal.admin-add-department-member-modal').modal('hide'); $.notify({ message: '操作成功' }); -$('.department-list-table .department-item-<%= current_department.id %>').html("<%= j(render partial: 'admins/departments/shared/department_item', locals: { department: current_department }) %>") \ No newline at end of file +var index = $(".department-item-<%= current_department.id %>").children(":first").html(); +$('.department-list-table .department-item-<%= current_department.id %>').html("<%= j(render partial: 'admins/departments/shared/department_item', locals: { department: current_department, index: 1 }) %>"); +$(".department-item-<%= current_department.id %>").children(":first").html(index); \ No newline at end of file diff --git a/app/views/admins/departments/shared/_department_item.html.erb b/app/views/admins/departments/shared/_department_item.html.erb index 64b4ee70b..62f3a81ac 100644 --- a/app/views/admins/departments/shared/_department_item.html.erb +++ b/app/views/admins/departments/shared/_department_item.html.erb @@ -1,3 +1,4 @@ + <% not_list = defined?(:users_count) %> diff --git a/app/views/admins/departments/shared/_list.html.erb b/app/views/admins/departments/shared/_list.html.erb index 6af63d6f4..09ba2a65f 100644 --- a/app/views/admins/departments/shared/_list.html.erb +++ b/app/views/admins/departments/shared/_list.html.erb @@ -1,10 +1,11 @@
序号 ID 部门名称 单位名称创建者创建者 <%= sort_tag('创建于', name: 'created_at', path: admins_department_applies_path) %> 操作
<%= list_index_no((params[:page] || 1).to_i, index) %> <%= apply.id %> <%= apply.name %> <%= apply.school.try(:name) %><%= list_index_no((params[:page] || 1).to_i, index) %><%= overflow_hidden_span department.name, width: 150 %>
+ - + @@ -14,9 +15,9 @@ <% if departments.present? %> - <% departments.each do |department| %> + <% departments.each_with_index do |department, index| %> - <%= render 'admins/departments/shared/department_item', department: department %> + <%= render partial: 'admins/departments/shared/department_item', locals: {department: department, index: index} %> <% end %> <% else %> diff --git a/app/views/admins/departments/update.js.erb b/app/views/admins/departments/update.js.erb index 359bac59c..d20ca9524 100644 --- a/app/views/admins/departments/update.js.erb +++ b/app/views/admins/departments/update.js.erb @@ -1,4 +1,6 @@ $('.modal.admin-edit-department-modal').modal('hide'); $.notify({ message: '操作成功' }); -$('.department-list-table .department-item-<%= current_department.id %>').html("<%= j(render partial: 'admins/departments/shared/department_item', locals: { department: current_department }) %>") \ No newline at end of file +var index = $(".department-item-<%= current_department.id %>").children(":first").html(); +$('.department-list-table .department-item-<%= current_department.id %>').html("<%= j(render partial: 'admins/departments/shared/department_item', locals: {department: current_department, index: 1}) %>"); +$(".department-item-<%= current_department.id %>").children(":first").html(index); \ No newline at end of file diff --git a/app/views/admins/identity_authentications/shared/_list.html.erb b/app/views/admins/identity_authentications/shared/_list.html.erb index 607feb93a..6e12d1c54 100644 --- a/app/views/admins/identity_authentications/shared/_list.html.erb +++ b/app/views/admins/identity_authentications/shared/_list.html.erb @@ -3,6 +3,7 @@
序号 部门名称 单位名称 用户数已职业认证已职业认证 部门管理员 统计链接 云主机数
+ <% unless is_processed %> - + <% unless is_processed %> <% if applies.present? %> - <% applies.each do |apply| %> + <% applies.each_with_index do |apply, index| %> <% user = apply.user %> + <% unless is_processed %> <% end %> diff --git a/app/views/admins/laboratories/shared/_laboratory_item.html.erb b/app/views/admins/laboratories/shared/_laboratory_item.html.erb index 81a45ca71..765616926 100644 --- a/app/views/admins/laboratories/shared/_laboratory_item.html.erb +++ b/app/views/admins/laboratories/shared/_laboratory_item.html.erb @@ -1,4 +1,5 @@ <% school = laboratory.school %> +
序号 <%= check_box_tag('all-check', 1, false, id: nil, class: 'batch-all-check-box', @@ -13,7 +14,7 @@ 姓名 身份证号 学校/单位职称职称 照片 @@ -33,9 +34,10 @@
<%= list_index_no((params[:page] || 1).to_i, index) %><%= check_box_tag('ids[]', apply.id, false, id: nil, class: 'batch-check-box') %><%= list_index_no((params[:page] || 1).to_i, index) %> <%= school&.name || 'EduCoder主站' %> <% if laboratory.identifier %> diff --git a/app/views/admins/laboratories/shared/_list.html.erb b/app/views/admins/laboratories/shared/_list.html.erb index 2520b3276..a731be44a 100644 --- a/app/views/admins/laboratories/shared/_list.html.erb +++ b/app/views/admins/laboratories/shared/_list.html.erb @@ -1,6 +1,7 @@ + @@ -9,14 +10,14 @@ - + <% if laboratories.present? %> - <% laboratories.each do |laboratory| %> + <% laboratories.each_with_index do |laboratory, index| %> - <%= render 'admins/laboratories/shared/laboratory_item', laboratory: laboratory %> + <%= render partial: 'admins/laboratories/shared/laboratory_item', locals: {laboratory: laboratory, index: index} %> <% end %> <% else %> diff --git a/app/views/admins/laboratories/update.js.erb b/app/views/admins/laboratories/update.js.erb index 1b9f307a6..149539ad6 100644 --- a/app/views/admins/laboratories/update.js.erb +++ b/app/views/admins/laboratories/update.js.erb @@ -1 +1,3 @@ -$(".laboratory-item-<%= @laboratory.id %>").html("<%= j render partial: "admins/laboratories/shared/laboratory_item",locals: {laboratory: @laboratory} %>") \ No newline at end of file +var index = $(".laboratory-item-<%= @laboratory.id %>").children(":first").html(); +$(".laboratory-item-<%= @laboratory.id %>").html("<%= j render partial: "admins/laboratories/shared/laboratory_item",locals: {laboratory: @laboratory, index: 1} %>"); +$(".laboratory-item-<%= @laboratory.id %>").children(":first").html(index); \ No newline at end of file diff --git a/app/views/admins/laboratories/update_sync_course.js.erb b/app/views/admins/laboratories/update_sync_course.js.erb index 5ae68f673..663f56ee1 100644 --- a/app/views/admins/laboratories/update_sync_course.js.erb +++ b/app/views/admins/laboratories/update_sync_course.js.erb @@ -1 +1,3 @@ -$("#laboratory-item-<%= @laboratory.id %>").html("<%= j render partial: 'admins/laboratories/shared/laboratory_item', locals: {laboratory: @laboratory} %>") \ No newline at end of file +var index = $(".laboratory-item-<%= @laboratory.id %>").children(":first").html(); +$("#laboratory-item-<%= @laboratory.id %>").html("<%= j render partial: 'admins/laboratories/shared/laboratory_item', locals: {laboratory: @laboratory, index: 1} %>"); +$(".laboratory-item-<%= @laboratory.id %>").children(":first").html(index); \ No newline at end of file diff --git a/app/views/admins/laboratory_settings/show.html.erb b/app/views/admins/laboratory_settings/show.html.erb index b99d6f022..ee9880fbb 100644 --- a/app/views/admins/laboratory_settings/show.html.erb +++ b/app/views/admins/laboratory_settings/show.html.erb @@ -129,6 +129,16 @@ + + diff --git a/app/views/admins/laboratory_shixuns/shared/_list.html.erb b/app/views/admins/laboratory_shixuns/shared/_list.html.erb index e1244c472..462486f4b 100644 --- a/app/views/admins/laboratory_shixuns/shared/_list.html.erb +++ b/app/views/admins/laboratory_shixuns/shared/_list.html.erb @@ -1,21 +1,22 @@
序号 单位名称 域名 统计链接同步课堂 同步实践课程 同步实训操作操作
- + + - + <% if laboratory_shixuns.present? %> - <% laboratory_shixuns.each do |laboratory_shixun| %> + <% laboratory_shixuns.each_with_index do |laboratory_shixun, index| %> - <%= render partial: 'admins/laboratory_shixuns/shared/td', locals: { laboratory_shixun: laboratory_shixun } %> + <%= render partial: 'admins/laboratory_shixuns/shared/td', locals: { laboratory_shixun: laboratory_shixun, index: index } %> <% end %> <% else %> diff --git a/app/views/admins/laboratory_shixuns/shared/_td.html.erb b/app/views/admins/laboratory_shixuns/shared/_td.html.erb index dbdf0df75..d987b53b4 100644 --- a/app/views/admins/laboratory_shixuns/shared/_td.html.erb +++ b/app/views/admins/laboratory_shixuns/shared/_td.html.erb @@ -1,5 +1,6 @@ <%- shixun = laboratory_shixun.shixun -%> +
实训名称序号实训名称 技术平台 技术体系 封面 创建者状态状态 执行时间 操作
<%= list_index_no((params[:page] || 1).to_i, index) %> <%= link_to "/shixuns/#{shixun.identifier}", target: '_blank' do %> <%= shixun.name %> diff --git a/app/views/admins/laboratory_subjects/shared/_list.html.erb b/app/views/admins/laboratory_subjects/shared/_list.html.erb index 55f67dea8..c40d02260 100644 --- a/app/views/admins/laboratory_subjects/shared/_list.html.erb +++ b/app/views/admins/laboratory_subjects/shared/_list.html.erb @@ -1,7 +1,8 @@ - + + @@ -13,10 +14,11 @@ <% if laboratory_subjects.present? %> - <% laboratory_subjects.each do |laboratory_subject| %> + <% laboratory_subjects.each_with_index do |laboratory_subject, index| %> <%- subject = laboratory_subject.subject -%> +
课程名称序号课程名称 技术体系 等级体系 封面
<%= list_index_no((params[:page] || 1).to_i, index) %> <%= link_to(subject.name, "/paths/#{subject.id}", target: '_blank') %> 首页 diff --git a/app/views/admins/laboratory_users/create.js.erb b/app/views/admins/laboratory_users/create.js.erb index f43fd7887..604e62943 100644 --- a/app/views/admins/laboratory_users/create.js.erb +++ b/app/views/admins/laboratory_users/create.js.erb @@ -1,4 +1,6 @@ $('.modal.admin-add-laboratory-user-modal').modal('hide'); $.notify({ message: '操作成功' }); -$('.laboratory-list-table .laboratory-item-<%= current_laboratory.id %>').html("<%= j(render partial: 'admins/laboratories/shared/laboratory_item', locals: { laboratory: current_laboratory }) %>") \ No newline at end of file +var index = $(".laboratory-item-<%= current_laboratory.id %>").children(":first").html(); +$('.laboratory-list-table .laboratory-item-<%= current_laboratory.id %>').html("<%= j(render partial: 'admins/laboratories/shared/laboratory_item', locals: {laboratory: current_laboratory, index: 1}) %>"); +$(".laboratory-item-<%= current_laboratory.id %>").children(":first").html(index); \ No newline at end of file diff --git a/app/views/admins/library_applies/shared/_list.html.erb b/app/views/admins/library_applies/shared/_list.html.erb index 783d0db30..fde3d1d1a 100644 --- a/app/views/admins/library_applies/shared/_list.html.erb +++ b/app/views/admins/library_applies/shared/_list.html.erb @@ -3,11 +3,12 @@ + - + <% if is_processed %> @@ -18,10 +19,11 @@ <% if applies.present? %> - <% applies.each do |apply| %> + <% applies.each_with_index do |apply, index| %> <% user = apply.library.user %> <% library = apply.library %> +
序号 头像 姓名 教学案例 案例描述时间时间拒绝原因 状态
<%= list_index_no((params[:page] || 1).to_i, index) %> <%= link_to "/users/#{user.login}", class: 'professional-authentication-avatar', target: '_blank', data: { toggle: 'tooltip', title: '个人主页' } do %> diff --git a/app/views/admins/myshixuns/shared/_list.html.erb b/app/views/admins/myshixuns/shared/_list.html.erb index 440437320..a80a4ef23 100644 --- a/app/views/admins/myshixuns/shared/_list.html.erb +++ b/app/views/admins/myshixuns/shared/_list.html.erb @@ -1,9 +1,10 @@ + - + @@ -14,8 +15,9 @@ <% if myshixuns.present? %> - <% myshixuns.each do |myshixun| %> + <% myshixuns.each_with_index do |myshixun, index| %> +
序号 ID 标识实训名称实训名称 实训老师 完成 经验值
<%= list_index_no(@params_page.to_i, index) %> <%= myshixun.id %> <%= myshixun.identifier %> diff --git a/app/views/admins/partners/shared/_list.html.erb b/app/views/admins/partners/shared/_list.html.erb index 0bebc2a4b..71153c175 100644 --- a/app/views/admins/partners/shared/_list.html.erb +++ b/app/views/admins/partners/shared/_list.html.erb @@ -1,15 +1,17 @@ - + + <% if partners.present? %> - <% partners.each do |partner| %> + <% partners.each_with_index do |partner, index| %> + diff --git a/app/views/admins/professional_authentications/shared/_list.html.erb b/app/views/admins/professional_authentications/shared/_list.html.erb index 6ec6355ba..7ffa5837e 100644 --- a/app/views/admins/professional_authentications/shared/_list.html.erb +++ b/app/views/admins/professional_authentications/shared/_list.html.erb @@ -3,6 +3,7 @@
名称序号名称 <%= sort_tag('添加时间', name: 'created_at', path: admins_partners_path) %> 操作
<%= list_index_no((params[:page] || 1).to_i, index) %> <%= link_to partner.school&.name || partner.name, customers_partner_path(partner), target: '_blank' %>
+ <% unless is_processed %> - + <% unless is_processed %> <% if applies.present? %> - <% applies.each do |apply| %> + <% applies.each_with_index do |apply, index| %> <% user = apply.user %> + <% unless is_processed %> <% end %> diff --git a/app/views/admins/project_package_applies/shared/_list.html.erb b/app/views/admins/project_package_applies/shared/_list.html.erb index d94c96184..bec0912ca 100644 --- a/app/views/admins/project_package_applies/shared/_list.html.erb +++ b/app/views/admins/project_package_applies/shared/_list.html.erb @@ -3,11 +3,12 @@
序号 <%= check_box_tag('all-check', 1, false, id: nil, class: 'batch-all-check-box', @@ -12,7 +13,7 @@ 头像 姓名 学校/单位职称职称 照片 @@ -31,9 +32,10 @@
<%= list_index_no((params[:page] || 1).to_i, index) %><%= check_box_tag('ids[]', apply.id, false, id: nil, class: 'batch-check-box') %>
+ - + <% if is_processed %> @@ -18,10 +19,11 @@ <% if applies.present? %> - <% applies.each do |apply| %> + <% applies.each_with_index do |apply, index| %> <% package = apply.project_package %> <% user = package.creator %> +
序号 头像 姓名 众包需求 需求描述时间时间拒绝原因 状态
<%= list_index_no((params[:page] || 1).to_i, index) %> <%= link_to "/users/#{user.login}", class: 'professional-authentication-avatar', target: '_blank', data: { toggle: 'tooltip', title: '个人主页' } do %> diff --git a/app/views/admins/projects/shared/_list.html.erb b/app/views/admins/projects/shared/_list.html.erb index 8a84a72d0..e2a6307ad 100644 --- a/app/views/admins/projects/shared/_list.html.erb +++ b/app/views/admins/projects/shared/_list.html.erb @@ -1,6 +1,7 @@ + @@ -11,14 +12,15 @@ - + <% if projects.present? %> - <% projects.each do |project| %> + <% projects.each_with_index do |project, index| %> +
序号 ID 项目名称 公开里程碑 成员 管理员<%= sort_tag('创建时间', name: 'created_at', path: admins_projects_path) %><%= sort_tag('创建时间', name: 'created_at', path: admins_projects_path) %> 操作
<%= list_index_no((params[:page] || 1).to_i, index) %> <%= project.id %> <%= link_to(project.name, "/projects/#{project.id}", target: '_blank') %> diff --git a/app/views/admins/school_statistics/shared/_list.html.erb b/app/views/admins/school_statistics/shared/_list.html.erb index aa043f097..9d2a1c209 100644 --- a/app/views/admins/school_statistics/shared/_list.html.erb +++ b/app/views/admins/school_statistics/shared/_list.html.erb @@ -20,7 +20,8 @@ - + + @@ -32,8 +33,9 @@ <% if statistics.present? %> - <% statistics.each do |statistic| %> + <% statistics.each_with_index do |statistic, index| %> +
单位名称序号单位名称 <%= sort_tag('新增教师', name: 'teacher_increase_count', path: admins_school_statistics_path) %> <%= sort_tag('新增学生', name: 'student_increase_count', path: admins_school_statistics_path) %> <%= sort_tag('新增课堂', name: 'course_increase_count', path: admins_school_statistics_path) %>
<%= list_index_no(@params_page.to_i, index) %> <%= link_to statistic.school_name, "/colleges/#{statistic.school_id}/statistics", target: '_blank', data: { toggle: 'tooltip', title: '点击查看学校统计概况' } %> diff --git a/app/views/admins/schools/index.html.erb b/app/views/admins/schools/index.html.erb index 9c41067ee..56cbadd9d 100644 --- a/app/views/admins/schools/index.html.erb +++ b/app/views/admins/schools/index.html.erb @@ -4,7 +4,7 @@
<%= form_tag(admins_schools_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> - <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '部门名称检索') %> + <%= 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': '搜索中...') %> <% end %> diff --git a/app/views/admins/schools/shared/_list.html.erb b/app/views/admins/schools/shared/_list.html.erb index ec7475028..ff0b17992 100644 --- a/app/views/admins/schools/shared/_list.html.erb +++ b/app/views/admins/schools/shared/_list.html.erb @@ -1,6 +1,7 @@ + @@ -11,13 +12,14 @@ - + <% if schools.present? %> - <% schools.each do |school| %> + <% schools.each_with_index do |school, index| %> +
序号 ID LOGO 标识码<%= sort_tag('用户数', name: 'users_count', path: admins_schools_path) %> 部门数 <%= sort_tag('创建时间', name: 'created_at', path: admins_schools_path) %>操作操作
<%= list_index_no((params[:page] || 1).to_i, index) %> <%= school.id %> <% if Util::FileManage.exists?(school) %> diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb index df344fd1a..4b84068e7 100644 --- a/app/views/admins/shared/_sidebar.html.erb +++ b/app/views/admins/shared/_sidebar.html.erb @@ -27,8 +27,9 @@
  • <%= sidebar_item(admins_shixun_settings_path, '实训配置', icon: 'cog', controller: 'admins-shixun_settings') %>
  • <%= sidebar_item(admins_mirror_repositories_path, '镜像管理', icon: 'cubes', controller: 'admins-mirror_repositories') %>
  • <%= sidebar_item(admins_myshixuns_path, '学员实训列表', icon: 'server', controller: 'admins-myshixuns') %>
  • -
  • <%= sidebar_item(admins_shixun_recycles_path, '实训回收站', icon: 'recycle', controller: 'admins-myshixuns') %>
  • - <% end %> +
  • <%= sidebar_item(admins_shixun_modify_records_path, '实训修改记录', icon: 'eraser', controller: 'admins-shixun_modify_records') %>
  • +
  • <%= sidebar_item(admins_shixun_recycles_path, '实训回收站', icon: 'recycle', controller: 'admins-shixun_recycles') %>
  • + <% end %>
  • diff --git a/app/views/admins/shixun_authorizations/shared/_list.html.erb b/app/views/admins/shixun_authorizations/shared/_list.html.erb index c1dec5f45..c3828ec86 100644 --- a/app/views/admins/shixun_authorizations/shared/_list.html.erb +++ b/app/views/admins/shixun_authorizations/shared/_list.html.erb @@ -3,11 +3,12 @@ + - + <% if is_processed %> @@ -19,12 +20,13 @@ <% if applies.present? %> - <% applies.each do |apply| %> + <% applies.each_with_index do |apply, index| %> <% user = apply.user %> <% shixun = shixun_map[apply.container_id] %> <% content_review = shixun.shixun_reviews.select{|sr| sr.review_type == 'Content'}.first %> <% perference_review = shixun.shixun_reviews.select{|sr| sr.review_type == 'Performance'}.first %> + <% identifier = Game.find_by(challenge_id: discuss.challenge_id, user_id: discuss.user_id)&.identifier %> - + diff --git a/app/views/admins/shixun_modify_records/index.html.erb b/app/views/admins/shixun_modify_records/index.html.erb new file mode 100644 index 000000000..cecba30cb --- /dev/null +++ b/app/views/admins/shixun_modify_records/index.html.erb @@ -0,0 +1,25 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('实训修改记录') %> +<% end %> + +
    + <%= form_tag(admins_shixun_modify_records_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> +
    + + <%= text_field_tag :user_name, params[:user_name], class: 'form-control flex-1', placeholder: '真实姓名搜索' %> +
    + +
    + + <% data_arrs = [['最近一周', 'weekly'], ['最近一个月', 'monthly']] %> + <%= select_tag(:date, options_for_select(data_arrs, params[:date]), class: 'form-control') %> +
    + + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + + <% end %> +
    + +
    + <%= render partial: 'admins/shixun_modify_records/shared/list', locals: { records: @records } %> +
    \ No newline at end of file diff --git a/app/views/admins/shixun_modify_records/index.js.erb b/app/views/admins/shixun_modify_records/index.js.erb new file mode 100644 index 000000000..fc9dc033b --- /dev/null +++ b/app/views/admins/shixun_modify_records/index.js.erb @@ -0,0 +1 @@ +$('.shixun-modify-record-list-container').html("<%= j( render partial: 'admins/shixun_modify_records/shared/list', locals: { records: @records } ) %>"); \ No newline at end of file diff --git a/app/views/admins/shixun_modify_records/shared/_list.html.erb b/app/views/admins/shixun_modify_records/shared/_list.html.erb new file mode 100644 index 000000000..525583d8e --- /dev/null +++ b/app/views/admins/shixun_modify_records/shared/_list.html.erb @@ -0,0 +1,36 @@ +<% if records.present? %> + <% records.each do |record| %> +
    +
    + <%= record.user.real_name %> + <%= format_time record.created_at %> +
    + +
    + 实训名称:<%= record.container&.shixun&.name %> + <% if record.container_type == "Challenge" %> + / + 关卡名:<%= record.container&.subject %> + <% end %> +
    + +
    +
      + <% record.diff_record_content&.content&.split("\n").each do |line| %> + <% if line =~ /^[\+]/ %> +
    • <%= line %>
    • + <% elsif line =~ /^[\-]/ %> +
    • <%= line %>
    • + <% else %> +
    • <%= line %>
    • + <% end %> + <% end %> +
    +
    +
    + <% end %> +<% else %> + <%= render 'admins/shared/no_data_for_table' %> +<% end %> + +<%= render partial: 'admins/shared/paginate', locals: { objects: records } %> \ No newline at end of file diff --git a/app/views/admins/shixun_recycles/shared/_list.html.erb b/app/views/admins/shixun_recycles/shared/_list.html.erb index 60d2742e9..5518fc753 100644 --- a/app/views/admins/shixun_recycles/shared/_list.html.erb +++ b/app/views/admins/shixun_recycles/shared/_list.html.erb @@ -1,16 +1,18 @@
    序号 头像 创建者 实训名称 审核情况任务数任务数 时间拒绝原因
    <%= list_index_no((params[:page] || 1).to_i, index) %> <%= link_to "/users/#{user.login}", class: 'shixun-authorization-avatar', target: '_blank', data: { toggle: 'tooltip', title: '个人主页' } do %> diff --git a/app/views/admins/shixun_feedback_messages/shared/_list.html.erb b/app/views/admins/shixun_feedback_messages/shared/_list.html.erb index af81f9e58..dfe140428 100644 --- a/app/views/admins/shixun_feedback_messages/shared/_list.html.erb +++ b/app/views/admins/shixun_feedback_messages/shared/_list.html.erb @@ -15,7 +15,7 @@ <%= (@params_page.to_i - 1) * 20 + index + 1 %><%= link_to discuss.dis.name, "/tasks/#{identifier}", target: '_blank'%><%= content_safe discuss.content %><%= content_safe discuss.content %> <%= discuss.user.show_real_name %> <%= format_time discuss.created_at %>
    + - + <% if shixuns.present? %> - <% shixuns.each do |shixun| %> + <% shixuns.each_with_index do |shixun, index| %> + diff --git a/app/views/admins/shixun_settings/index.html.erb b/app/views/admins/shixun_settings/index.html.erb index 7aab73f64..66286926a 100644 --- a/app/views/admins/shixun_settings/index.html.erb +++ b/app/views/admins/shixun_settings/index.html.erb @@ -65,6 +65,12 @@ 只看已隐藏文件目录 +
    + +
    <% end %> diff --git a/app/views/admins/shixun_settings/shared/_list.html.erb b/app/views/admins/shixun_settings/shared/_list.html.erb index 7591fe323..549c7edf4 100644 --- a/app/views/admins/shixun_settings/shared/_list.html.erb +++ b/app/views/admins/shixun_settings/shared/_list.html.erb @@ -1,12 +1,13 @@
    序号 ID 实训名称子站源子站源 创建者 <%= sort_tag('创建于', name: 'created_at', path: admins_shixun_recycles_path) %> 操作
    <%= list_index_no((params[:page] || 1).to_i, index) %> <%= shixun.identifier %> <%= link_to overflow_hidden_span(shixun.name), "/shixuns/#{shixun.identifier}", :target => "_blank", :title => shixun.name %> <%= shixun.laboratory&.school&.name %>
    - + + - - - + + + @@ -14,7 +15,7 @@ diff --git a/app/views/admins/shixun_settings/shared/_td.html.erb b/app/views/admins/shixun_settings/shared/_td.html.erb index f4a05f178..fc5af645a 100644 --- a/app/views/admins/shixun_settings/shared/_td.html.erb +++ b/app/views/admins/shixun_settings/shared/_td.html.erb @@ -1,3 +1,4 @@ + diff --git a/public/react/src/App.js b/public/react/src/App.js index 1c15b3dab..2fa9e0765 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -2,7 +2,7 @@ import React, {Component} from 'react'; import './public-path'; import logo from './logo.svg'; import './App.css'; -import {LocaleProvider} from 'antd' +import {ConfigProvider} from 'antd' import zhCN from 'antd/lib/locale-provider/zh_CN'; import { BrowserRouter as Router, @@ -311,6 +311,11 @@ const StudentStudy = Loadable({ loader: () => import('./modules/developer/studentStudy'), loading: Loading }); +// 提交记录详情 +const RecordDetail = Loadable({ + loader: () => import('./modules/developer/recordDetail'), + loading: Loading +}); // //个人竞赛报名 // const PersonalCompetit = Loadable({ // loader: () => import('./modules/competition/personal/PersonalCompetit.js'), @@ -478,7 +483,7 @@ class App extends Component { // console.log(mygetHelmetapi); return ( - + this.Modifyloginvalue()}> @@ -666,17 +671,31 @@ class App extends Component { (props)=>() }/> - + { + return () + } + } + /> () + (props) => () } /> + () + } + /> () } /> - + () + }/> - + ); } diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index bd25f6977..064c64db1 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -10,7 +10,6 @@ broadcastChannelOnmessage('refreshPage', () => { }) function locationurl(list){ - debugger if (window.location.port === "3007") { } else { @@ -31,6 +30,13 @@ if (isDev) { window.location.search.indexOf('debug=s') != -1 ? 'student' : window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || 'admin' } +// 超管 +// debugType="admin"; +// 老师 +// debugType="teacher"; +// 学生 +//debugType="student"; + window._debugType = debugType; export function initAxiosInterceptors(props) { initOnlineOfflineListener() diff --git a/public/react/src/constants/index.js b/public/react/src/constants/index.js index abae13db0..3e7aceab0 100644 --- a/public/react/src/constants/index.js +++ b/public/react/src/constants/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-20 23:10:48 * @LastEditors: tangjiang - * @LastEditTime: 2019-11-28 14:41:42 + * @LastEditTime: 2019-12-06 15:53:27 */ const CONST = { jcLabel: { @@ -20,8 +20,25 @@ const CONST = { title: '代码格式', type: 'select', content: [ + { + text: '显示风格', + type: 'style', + value: [ + { + key: 'dark', + text: '黑色背景', + value: 'dark' + }, + { + key: 'light', + text: '白色背景', + value: 'light' + } + ] + }, { - text: '字体大小', + text: '字体大小', + type: 'font', value: [ { key: 1, diff --git a/public/react/src/modules/courses/ListPageIndex.js b/public/react/src/modules/courses/ListPageIndex.js index 0a0ff0daf..5ff2c3c0e 100644 --- a/public/react/src/modules/courses/ListPageIndex.js +++ b/public/react/src/modules/courses/ListPageIndex.js @@ -200,7 +200,7 @@ class ListPageIndex extends Component{
    -
    +
    {/*left_nav*/}
    diff --git a/public/react/src/modules/courses/common/CourseLayoutComponent.js b/public/react/src/modules/courses/common/CourseLayoutComponent.js index 3a4403e43..c88bd8798 100644 --- a/public/react/src/modules/courses/common/CourseLayoutComponent.js +++ b/public/react/src/modules/courses/common/CourseLayoutComponent.js @@ -49,7 +49,7 @@ class CourseLayoutcomponent extends Component{
    -
    +
    {/*left_nav*/}
    diff --git a/public/react/src/modules/courses/coursesDetail/CoursesDetail.js b/public/react/src/modules/courses/coursesDetail/CoursesDetail.js index 350d2e45f..8a5519d2e 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesDetail.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesDetail.js @@ -58,7 +58,7 @@ class CoursesDetail extends Component{
    -
    +
    {/*left_nav*/}
    diff --git a/public/react/src/modules/courses/coursesPublic/SelectResource.js b/public/react/src/modules/courses/coursesPublic/SelectResource.js index 31c6d2f52..e2454652b 100644 --- a/public/react/src/modules/courses/coursesPublic/SelectResource.js +++ b/public/react/src/modules/courses/coursesPublic/SelectResource.js @@ -42,12 +42,7 @@ class Selectresource extends Component{ getallfiles:false, searchtype:'getallfiles', Radiovalue:0, - datatime:undefined, - course_group_publish_times:[ - { - group_id : [], - publish_time :undefined, - }], + datatime:undefined } } componentDidMount() { @@ -79,7 +74,7 @@ class Selectresource extends Component{ } SenttotheSearch=(value)=>{ - let {searchtype}=this.state; + let {searchtype}=this.state; if(searchtype==="getallfiles"){ this.getallfiles(value,1) }else if(searchtype==="getmyfiles"){ @@ -91,32 +86,32 @@ class Selectresource extends Component{ setupdatalist=(url,newpage)=>{ let {Resourcelist,Searchvalue}=this.state; if(Resourcelist!=undefined){ - let newResourcelist=Resourcelist.files; - axios.get(url,{ - params:{ - page:newpage, - page_size:15, - search:Searchvalue, - } - }).then((result)=>{ + let newResourcelist=Resourcelist.files; + axios.get(url,{ + params:{ + page:newpage, + page_size:15, + search:Searchvalue, + } + }).then((result)=>{ - var list=result.data.data.files; + var list=result.data.data.files; for(var i=0;i{ - console.log(error) - }) + }).catch((error)=>{ + console.log(error) + }) } } contentViewScroll=(e)=>{ @@ -152,7 +147,7 @@ class Selectresource extends Component{ // this.props.funshixunmodallist(Searchvalue,types,true,1) // this.props.funpatheditarry([]) if(types==="all"){ - this.getallfiles(undefined,1) + this.getallfiles(undefined,1) }else if(types==="my"){ this.getmyfiles(undefined,1) } @@ -168,12 +163,12 @@ class Selectresource extends Component{ search:value, } }).then((result)=>{ - this.setState({ - Resourcelist:result.data.data, - hometypepvisible:false, - getallfiles:true, - searchtype:'getallfiles' - }) + this.setState({ + Resourcelist:result.data.data, + hometypepvisible:false, + getallfiles:true, + searchtype:'getallfiles' + }) }).catch((error)=>{ console.log(error) }) @@ -189,11 +184,11 @@ class Selectresource extends Component{ search:value, } }).then((result)=>{ - this.setState({ - Resourcelist: result.data.data, - hometypepvisible:false, - searchtype:'getmyfiles' - }) + this.setState({ + Resourcelist: result.data.data, + hometypepvisible:false, + searchtype:'getmyfiles' + }) }).catch((error)=>{ console.log(error) }) @@ -201,7 +196,7 @@ class Selectresource extends Component{ hidecouseShixunModal=()=>{ - this.props.hidecouseShixunModal() + this.props.hidecouseShixunModal() } ModalCancelModalCancel=()=>{ @@ -217,22 +212,22 @@ class Selectresource extends Component{ savecouseShixunModal=()=>{ - let {patheditarry,datatime,Radiovalue,course_group_publish_times}=this.state; + let {patheditarry,datatime,Radiovalue}=this.state; let {coursesId,attachmentId}=this.props; - let url="/files/import.json"; - - if(patheditarry===undefined||patheditarry.length===0){ - this.setState({ - patheditarrytype:true - }) - return - }else{ - this.setState({ - patheditarrytype:false - }) - } - - if(this.state.Radiovalue===1&&this.props.course_groups.length===0){ + let url="/files/import.json"; + + if(patheditarry===undefined||patheditarry.length===0){ + this.setState({ + patheditarrytype:true + }) + return + }else{ + this.setState({ + patheditarrytype:false + }) + } + + if(this.state.Radiovalue===1){ if(datatime===undefined||datatime===null||datatime=== ""){ this.setState({ Radiovaluetype:true @@ -249,17 +244,16 @@ class Selectresource extends Component{ course_id:coursesId, attachment_ids:patheditarry, course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId, - delay_publish:Radiovalue, - publish_time:this.props.course_groups.length===0?Radiovalue===1?datatime===undefined? undefined:datatime:undefined:undefined, - group_settings:this.props.course_groups.length===0?undefined:course_group_publish_times + delay_publish:Radiovalue, + publish_time:Radiovalue===1?datatime:undefined } ).then((response) => { - if(response.data.status===0){ - this.ModalCancelModalCancel(); - this.props.updataleftNavfun(); - this.props.showNotification("选用资源成功"); - this.props.setupdate(attachmentId) - } + if(response.data.status===0){ + this.ModalCancelModalCancel(); + this.props.updataleftNavfun(); + this.props.showNotification("选用资源成功"); + this.props.setupdate(attachmentId) + } }).catch((error) => { console.log(error) }) @@ -277,58 +271,15 @@ class Selectresource extends Component{ }); } - onChangeTimepublish= (date, dateString,key,type) => { - if(type===1){ - this.setState({ - datatime:handleDateString(dateString), - }) - }else if(type===2){ - let {course_group_publish_times}=this.state; - let newgroup_publish=course_group_publish_times; - for(var i=0; i { - addgrouppublish=()=>{ - let newlist=this.state.course_group_publish_times; - newlist.push( { - group_id : undefined, - publish_time :undefined, - }) - this.setState({ - course_group_publish_times:newlist - }) - } - deletegrouppublish=(key)=>{ - let newlist=this.state.course_group_publish_times; - newlist.splice(key,1); this.setState({ - course_group_publish_times:newlist + datatime:handleDateString(dateString), }) - } - selectassigngroups=(e,index,key)=>{ - debugger - let {course_group_publish_times}=this.state; - let newgroup_publish=course_group_publish_times; - for(var i=0; i; const radioStyle = { @@ -336,8 +287,6 @@ class Selectresource extends Component{ height: '30px', lineHeight: '30px', }; - - console.log(course_group_publish_times) return(
    {/*提示*/} @@ -350,73 +299,73 @@ class Selectresource extends Component{ /> {visible===true? - - + } + - -
    -
    - -
  • this.changeTag("all")} className={ type==="all" ? "active edu-filter-cir-grey font-12":"edu-filter-cir-grey font-12"}>全部
  • -
  • this.changeTag("my")} className={ type==="my" ? " active edu-filter-cir-grey font-12":"edu-filter-cir-grey font-12"}>我的资源
  • -
    - this.SenttotheSearch(value)} - style={{width: '100%'}} - /> + - -
      -
    • 资源名称
    • -
    • 大小
    • -
    • 发布人
    • -
    • 时间
    • -
    +
      +
    • 资源名称
    • +
    • 大小
    • +
    • 发布人
    • +
    • 时间
    • +
    - -
    - - { - Resourcelist === undefined ?"":Resourcelist.files.length===0?: - - - { - Resourcelist.files.map((item,key)=>{ - return( -
    -
  • - - - -
  • -
  • {item.filesize}
  • -
  • {item.author.name}
  • -
  • {formatDate(item.created_on)}
  • -
    - ) - }) - } -
    - - } -
    +
    -
    - 发布设置: - - - 立即发布 - - - - 延期发布 - {this.props.course_groups.length>0?"":this.onChangeTimepublish(e,index,undefined,1)} - disabledTime={disabledDateTime} - disabledDate={disabledDate} - disabled={this.state.Radiovalue===1?false:true} - />} - - - (按照设置的时间定时发布) - - - - {this.props.course_groups.length>0?this.props.isStudent()===true?"":
    - {this.state.Radiovalue===1?:""} { - course_group_publish_times.map((item,key)=>{ - return( -
    - - - this.onChangeTimepublish(e,index,key,2)} - // onChange={ this.onChangeTimepublish } - disabledTime={disabledDateTime} - disabledDate={disabledDate} - /> - {key!=0?this.deletegrouppublish(key)}>:""} - {key+1===this.props.course_groups.length?"":} -
    - ) - }) + Resourcelist === undefined ?"":Resourcelist.files.length===0?: + + + { + Resourcelist.files.map((item,key)=>{ + return( +
    +
  • + + + +
  • +
  • {item.filesize}
  • +
  • {item.author.name}
  • +
  • {formatDate(item.created_on)}
  • +
    + ) + }) + } +
    } -
    :""} -
    +
    + +
    + 发布设置: + + + 立即发布 + + + + 延期发布 + this.onChangeTimepublish(e,index,undefined,1)} + disabledTime={disabledDateTime} + disabledDate={disabledDate} + disabled={this.state.Radiovalue===1?false:true} + /> + + + (按照设置的时间定时发布) + +
    - {this.state.patheditarrytype===true?

    请选择资源

    :""} - {this.state.Radiovaluetype===true?

    发布时间不能为空

    :""} -
    + {this.state.patheditarrytype===true?

    请选择资源

    :""} + {this.state.Radiovaluetype===true?

    发布时间不能为空

    :""} +
    -
    - - :""} + + :""}
    ) } diff --git a/public/react/src/modules/courses/coursesPublic/sendResource.js b/public/react/src/modules/courses/coursesPublic/sendResource.js index b0f4b1b69..73a0f6630 100644 --- a/public/react/src/modules/courses/coursesPublic/sendResource.js +++ b/public/react/src/modules/courses/coursesPublic/sendResource.js @@ -14,12 +14,12 @@ function range(start, end) { } return result; } - function disabledDateTime() { return { + // disabledHours: () => range(0, 24).splice(4, 20), disabledMinutes: () => range(1, 30).concat(range(31, 60)), - // disabledSeconds: () => range(0,60) - } + // disabledSeconds: () => [0, 60], + }; } function disabledDate(current) { @@ -45,8 +45,8 @@ class Sendresource extends Component{ // moment(new Date()).format('YYYY-MM-DD HH:mm:ss'), course_group_publish_times:[ { - group_id : undefined, - publish_time :undefined, + course_group_id : undefined, + publish_time :"" }], course_groups:undefined, course_groups_count:undefined, @@ -86,34 +86,34 @@ class Sendresource extends Component{ } onAttachmentRemove = (file) => { - if(!file.percent || file.percent == 100){ - const url = `/attachments/${file.response ? file.response.id : file.uid}.json` - axios.delete(url, { - }) - .then((response) => { - if (response.data) { - const { status } = response.data; - if (status == 0) { - this.setState({ - fileListtype:false, - fileList:[] - }) - } - - } - }) - .catch(function (error) { - console.log(error); - }); - this.setState({ - fileListtype:false, - }) - }else{ - this.setState({ - fileListtype:false, - fileList:[] - }) - } + if(!file.percent || file.percent == 100){ + const url = `/attachments/${file.response ? file.response.id : file.uid}.json` + axios.delete(url, { + }) + .then((response) => { + if (response.data) { + const { status } = response.data; + if (status == 0) { + this.setState({ + fileListtype:false, + fileList:[] + }) + } + + } + }) + .catch(function (error) { + console.log(error); + }); + this.setState({ + fileListtype:false, + }) + }else{ + this.setState({ + fileListtype:false, + fileList:[] + }) + } } ModalCancelModalCancel=()=>{ @@ -127,7 +127,7 @@ class Sendresource extends Component{ } Saves=()=>{ - let {fileList,description,is_public,datatime,Radiovalue,course_group_publish_times} =this.state; + let {fileList,description,is_public,datatime,Radiovalue} =this.state; let newfileList=[]; for(var list of fileList){ @@ -141,7 +141,7 @@ class Sendresource extends Component{ return } - if(this.state.Radiovalue===1&&this.props.course_groups.length===0){ + if(this.state.Radiovalue===1){ if(datatime===undefined||datatime===null||datatime=== ""){ this.setState({ Radiovaluetype:true @@ -156,7 +156,6 @@ class Sendresource extends Component{ - if(description===undefined){ }else if(description.length>100){ @@ -177,10 +176,9 @@ class Sendresource extends Component{ course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId, attachment_ids:newfileList, is_public:is_public, - publish_time:this.props.course_groups.length===0?Radiovalue===1?datatime===undefined? undefined:datatime:undefined:"", + publish_time:Radiovalue===1?datatime===undefined? undefined:datatime:undefined, description:description, delay_publish:Radiovalue, - group_settings:this.props.course_groups.length===0?"":course_group_publish_times }).then((result)=>{ if(result.data.status===0){ @@ -239,42 +237,10 @@ class Sendresource extends Component{ Radiovalue: e.target.value, }); } - - addgrouppublish=()=>{ - let newlist=this.state.course_group_publish_times; - newlist.push( { - group_id : undefined, - publish_time :undefined, - }) - this.setState({ - course_group_publish_times:newlist - }) - } - deletegrouppublish=(key)=>{ - let newlist=this.state.course_group_publish_times; - newlist.splice(key,1); - this.setState({ - course_group_publish_times:newlist - }) - } - selectassigngroups=(e,index,key)=>{ - let {course_group_publish_times}=this.state; - let newgroup_publish=course_group_publish_times; - for(var i=0; i {/*提示*/} @@ -406,8 +372,8 @@ class Sendresource extends Component{ {this.props.course_is_public===true?
    公开: - 选中,所有用户可见,否则课堂成员可见 - + 选中,所有用户可见,否则课堂成员可见 +
    :""} - {this.props.course_groups.length>0?this.props.isStudent()===true?"":
    - {this.state.Radiovalue===1?:""} - { - course_group_publish_times.map((item,key)=>{ - return( -
    - - - this.onChangeTimepublish(e,index,key,2)} - // onChange={ this.onChangeTimepublish } - disabledTime={disabledDateTime} - disabledDate={disabledDate} - /> - {key!=0?this.deletegrouppublish(key)}>:""} - {key+1===this.props.course_groups.length?"":} -
    - ) - }) - - } -
    :""}
    diff --git a/public/react/src/modules/courses/elearning/YslDetailCards.js b/public/react/src/modules/courses/elearning/YslDetailCards.js index 3c6b5daff..e705894e6 100644 --- a/public/react/src/modules/courses/elearning/YslDetailCards.js +++ b/public/react/src/modules/courses/elearning/YslDetailCards.js @@ -48,7 +48,9 @@ class YslDetailCards extends Component{ }; hideparagraph=()=>{ this.setState({ - showparagraph:false + showparagraph:false, + showparagraphkey:null, + showparagraphindex:null }) }; startgameid=(id)=>{ @@ -509,6 +511,15 @@ class YslDetailCards extends Component{ } + + {this.props.current_user&&this.props.current_user.admin===false&&line.shixun_status==="暂未公开"?"":
  • + { + showparagraphkey === key && showparagraphindex === index ? "" : + 实验任务 {line.challenges_count} + } +
  • } +
    ) }) } diff --git a/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js b/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js index 8bbbffa10..20c40f025 100644 --- a/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js +++ b/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js @@ -1,26 +1,33 @@ import React,{ Component } from "react"; -import {Checkbox,Radio, Input,InputNumber,Spin} from "antd"; +import {Input,InputNumber,Spin,Statistic} from "antd"; -import '../css/members.css' -import '../css/busyWork.css' -import '../poll/pollStyle.css' -import '../css/Courses.css' +import '../css/members.css'; +import '../css/busyWork.css'; +import '../poll/pollStyle.css'; +import '../css/Courses.css'; -import moment from 'moment' -import { WordsBtn,markdownToHTML,ActionBtn,getImageUrl, MarkdownToHtml } from 'educoder' -import Modals from '../../modals/Modals' +import moment from 'moment'; +import { WordsBtn,markdownToHTML,ActionBtn,getImageUrl, MarkdownToHtml } from 'educoder'; +import Modals from '../../modals/Modals'; import CoursesListType from '../coursesPublic/CoursesListType'; -import Multiple from './question/multiple' -import Single from './question/single' -import FillEmpty from './question/fillEmpty' -import SimpleAnswer from './question/simpleAnswer' -import ShixunAnswer from './question/shixunAnswer' +import Multiple from './question/multiple'; +import Single from './question/single'; +import FillEmpty from './question/fillEmpty'; +import SimpleAnswer from './question/simpleAnswer'; +import ShixunAnswer from './question/shixunAnswer'; -import update from 'immutability-helper' +import update from 'immutability-helper'; import axios from 'axios'; -import './new/common.css' +import './new/common.css'; + +const { Countdown } = Statistic; + +// const deadline = Date.now() + this.state.time*60*60; // Moment is also OK + +// console.log(deadline) + const Textarea =Input.TextArea const tagArray = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', @@ -98,33 +105,34 @@ class ExerciseReviewAndAnswer extends Component{ remainTime=(time)=>{ // let { time } = this.state; - let h=moment(parseInt(time)*1000).hour()-8; - let m=moment(parseInt(time)*1000).minutes(); - let s=moment(parseInt(time)*1000).seconds(); - this.timer = setInterval(() => { - if(time>0){ - if(s==0){ - if(m > 0){ - m--; - } - s=59; - }else{ - s--; - } - this.setState({ - hour:h, - minute:m, - second:s - }) - if(h==0 && m==0 && s==0){ - clearInterval(this.timer); - this.autoCommitExercise(); - } - }else{ - clearInterval(this.timer); - } - },1000) + // let h=moment(parseInt(time)*1000).hour()-8; + // let m=moment(parseInt(time)*1000).minutes(); + // let s=moment(parseInt(time)*1000).seconds(); + // this.timer = setInterval(() => { + // if(time>0){ + // if(s==0){ + // if(m > 0){ + // m--; + // } + // s=59; + // }else{ + // s--; + // } + // this.setState({ + // hour:h, + // minute:m, + // second:s + // }) + // if(h==0 && m==0 && s==0){ + // clearInterval(this.timer); + // this.autoCommitExercise(); + // } + // }else{ + // clearInterval(this.timer); + // } + // },1000) } + //自动交卷 autoCommitExercise=()=>{ let eId=this.props.match.params.Id; @@ -140,13 +148,18 @@ class ExerciseReviewAndAnswer extends Component{ modalsBottomval:"不能再修改答题", ModalCancel:undefined, ModalSave:this.sureCommit, - Loadtype:true + Loadtype:true, + time:null, }) this.props.showNotification(`${result.data.message}`); } if(result.data.status===-2){ - this.remainTime(parseInt(result.data.message)) + // this.remainTime(parseInt(result.data.message)) + this.setState({ + time:parseInt(result.data.mess) + }) + this.deadline(parseInt(result.data.message)) } } }).catch((error)=>{ @@ -244,7 +257,8 @@ class ExerciseReviewAndAnswer extends Component{ isSpin:false }) if(result.data.exercise.left_time != null){ - this.remainTime(result.data.exercise.left_time); + // this.remainTime(result.data.exercise.left_time); + this.deadline(result.data.exercise.left_time) } } }).catch((error)=>{ @@ -571,6 +585,19 @@ class ExerciseReviewAndAnswer extends Component{ this.props.history.push(`/courses/${coursesId}/exercises/${eId}/student_exercise_list?tab=0`) } + deadline=(time)=>{ + if(time===null){ + this.setState({ + Datetime:0 + }) + }else{ + this.setState({ + Datetime:Date.now() + time * 1000 + }) + // return Date.now() + time * 1000 ; + } + + } render(){ let coursesId=this.props.match.params.coursesId; let eId=this.props.match.params.Id; @@ -613,6 +640,7 @@ class ExerciseReviewAndAnswer extends Component{ const { current_user } = this.props // console.log(data&&data.exercise.user_name) document.title=courseName&&courseName; + return(
    @@ -663,6 +691,7 @@ class ExerciseReviewAndAnswer extends Component{

    {exercise && exercise.exercise_name} + @@ -671,15 +700,18 @@ class ExerciseReviewAndAnswer extends Component{ 返回 : time && time != 0 ? -

    -
  • { hour >= 10 ? hour : '0'+hour}
  • - : -
  • { minute >= 10 ? minute : '0'+minute}
  • - : -
  • { second >= 10 ? second : '0'+second}
  • -
    :"" +
    + +
    + :"" } - + {/*
    */} + {/*
  • { hour >= 10 ? hour : '0'+hour}
  • */} + {/* :*/} + {/*
  • { minute >= 10 ? minute : '0'+minute}
  • */} + {/* :*/} + {/*
  • { second >= 10 ? second : '0'+second}
  • */} + {/*
    */} { isAdmin && 打回重做 } diff --git a/public/react/src/modules/courses/poll/PollDetailIndex.js b/public/react/src/modules/courses/poll/PollDetailIndex.js index 184e95333..38cc3796e 100644 --- a/public/react/src/modules/courses/poll/PollDetailIndex.js +++ b/public/react/src/modules/courses/poll/PollDetailIndex.js @@ -213,7 +213,7 @@ class PollDetailIndex extends Component{ user_permission && user_permission.poll_publish_count>0 ?
  • - { user_permission && user_permission.current_status ==0 ? "继续答题" : user_permission.current_status == 1 ? - (polls_status===2?"":polls_status===3?"":polls_status===4?"":"查看答题") - : "开始答题" } + { user_permission && user_permission.current_status ==0 ? "继续答题" : + user_permission.current_status == 1 ? + (polls_status===1?"":"查看答题") + :user_permission.current_status == 2 ?(polls_status===3?"":polls_status===4?"":"开始答题"):"" + } :"" } @@ -266,4 +268,4 @@ class PollDetailIndex extends Component{ ) } } -export default PollDetailIndex \ No newline at end of file +export default PollDetailIndex diff --git a/public/react/src/modules/courses/poll/PollNew.js b/public/react/src/modules/courses/poll/PollNew.js index 7251f05a8..248434295 100644 --- a/public/react/src/modules/courses/poll/PollNew.js +++ b/public/react/src/modules/courses/poll/PollNew.js @@ -3151,8 +3151,11 @@ class PollNew extends Component { onClick={() => this.Deleteadddom(indexo,true)}>取消 this.Deleteadddomthree(indexo, itemo,true)}>保存 + { + polls_status && polls_status < 2 ? this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 + :""}
  • @@ -3248,8 +3251,11 @@ class PollNew extends Component { onClick={() => this.Deleteadddom(indexo,true)}>取消 this.Deleteadddomthree(indexo, itemo,true)}>保存 + { + polls_status && polls_status < 2 ? this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 + :""}
    @@ -3261,8 +3267,11 @@ class PollNew extends Component { onClick={() => this.Deleteadddom(indexo,true)}>取消 this.Deleteadddomthree(indexo, itemo,true)}>保存 + { + polls_status && polls_status < 2 ? this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 + :""}
    ) @@ -3274,8 +3283,11 @@ class PollNew extends Component { onClick={() => this.Deleteadddom(indexo,true)}>取消 this.Deleteadddomthree(indexo, itemo,true)}>保存 + { + polls_status && polls_status < 2 ? this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 + :""}
    : @@ -3393,8 +3405,11 @@ class PollNew extends Component { onClick={() => this.Deleteadddom(indexo,true)}>取消 this.Deleteadddomthree(indexo, itemo,true)}>保存 + { + polls_status && polls_status < 2 ? this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 + :""}
    @@ -3490,8 +3505,11 @@ class PollNew extends Component { onClick={() => this.Deleteadddom(indexo,true)}>取消 this.Deleteadddomthree(indexo, itemo,true)}>保存 + { + polls_status && polls_status < 2 ? this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 + :""}
    @@ -3503,8 +3521,11 @@ class PollNew extends Component { onClick={() => this.Deleteadddom(indexo,true)}>取消 this.Deleteadddomthree(indexo, itemo,true)}>保存 + { + polls_status && polls_status < 2 ? this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 + :""}
    ) @@ -3516,8 +3537,11 @@ class PollNew extends Component { onClick={() => this.Deleteadddom(indexo,true)}>取消 this.Deleteadddomthree(indexo, itemo,true)}>保存 + { + polls_status && polls_status < 2 ? this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 + :""}
    : @@ -3644,8 +3668,12 @@ class PollNew extends Component { onClick={() => this.Deleteadddom(indexo)}>取消 this.Deleteadddomthree(indexo, itemo)}>保存 - this.Deleteadddomtwo(indexo, itemo)}>保存并继续 + { + polls_status && polls_status < 2 ? + this.Deleteadddomtwo(indexo, itemo)}>保存并继续 + :"" + }
    @@ -3741,8 +3769,12 @@ class PollNew extends Component { onClick={() => this.Deleteadddom(indexo)}>取消 this.Deleteadddomthree(indexo, itemo)}>保存 + { + polls_status&&polls_status<2? this.Deleteadddomtwo(indexo, itemo)}>保存并继续 + :"" + }
    @@ -3754,8 +3786,12 @@ class PollNew extends Component { onClick={() => this.Deleteadddom(indexo)}>取消 this.Deleteadddomthree(indexo, itemo)}>保存 + { + polls_status&&polls_status<2? this.Deleteadddomtwo(indexo, itemo)}>保存并继续 + :"" + }
    ) @@ -3767,8 +3803,13 @@ class PollNew extends Component { onClick={() => this.Deleteadddom(indexo)}>取消 this.Deleteadddomthree(indexo, itemo)}>保存 - this.Deleteadddomtwo(indexo, itemo)}>保存并继续 + { + polls_status&&polls_status<2? + this.Deleteadddomtwo(indexo, itemo)}>保存并继续 + :"" + } +
    : @@ -3873,4 +3914,4 @@ class PollNew extends Component { const WrappedPollNew = Form.create({name: 'taskPollNew'})(PollNew); // RouteHOC() -export default (WrappedPollNew); \ No newline at end of file +export default (WrappedPollNew); diff --git a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js index 0a76ae339..03ae5ec33 100644 --- a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js +++ b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js @@ -132,7 +132,9 @@ class Trainingjobsetting extends Component { CalculateMax: 100,//总分值 borredszf:"ml10 color-grey-9", borredszfl:true, - borredszfls:'' + borredszfls:'', + total_scoretwo:0, + total_score:0, } // console.log("获取到的值") // console.log("Trainingjobsetting") @@ -144,8 +146,8 @@ class Trainingjobsetting extends Component { } componentDidMount() { - console.log("Trainingjobsetting"); - console.log("componentDidMount"); + //console.log("Trainingjobsetting"); + //console.log("componentDidMount"); this.getTrainingjobsetting(true); let query = this.props.location.pathname; const type = query.split('/'); @@ -302,7 +304,10 @@ class Trainingjobsetting extends Component { proportion: result.data.shixun_evaluation === 0 ? "均分比例" : result.data.shixun_evaluation === 1 ? "经验值比例" : result.data.shixun_evaluation === 2 ? "自定义分值" : "", publicwork: result.data.work_public, challenge_settings: result.data.challenge_settings, - code_review: result.data.code_review + code_review: result.data.code_review, + total_scoretwo:result.data.total_score, + total_score:result.data.total_score, + }) this.props.Getdataback(result, result.data); @@ -339,6 +344,7 @@ class Trainingjobsetting extends Component { var datas = challenge_settings; var challenge_scoredata = []; + let datasinde=0; for (var i = 0; i < datas.length; i++) { if (datas[i].checked === true) { // var object = { @@ -347,9 +353,16 @@ class Trainingjobsetting extends Component { // }; challenge_scoredata.push(datas[i].challenge_score); // array.push(object) + }else{ + datasinde=datasinde+1; } } + + // //console.log("datasinde Calculatethetotalscore"); + // //console.log(datasinde); + // //console.log(datas.length); + // if(array === "[]" || array.length === 0){ // this.props.showNotification(`没有关卡不能更新设置`); // return; @@ -361,32 +374,27 @@ class Trainingjobsetting extends Component { // latedeductiontwos = this.state.latedeductiontwo; // } // if(challenge_scoredata.length>0){ - let len = 0; - console.log(challenge_scoredata); - for (var k = 0; k < challenge_scoredata.length; k++) { - len = len + parseFloat(challenge_scoredata[k]); - // console.log(challenge_scoredata[k]); - // console.log(len); + if(datasinde!==datas.length){ + let len = 0; + //console.log(challenge_scoredata); + for (var k = 0; k < challenge_scoredata.length; k++) { + len = len + parseFloat(challenge_scoredata[k]); + } + let max = latedeductiontwos + len; + let maxs = max.toFixed(1); + this.setState({ + CalculateMax: maxs, + }) } - let max = latedeductiontwos + len; - let maxs = max.toFixed(1); - console.log("Calculatethetotalscore"); - console.log(maxs); - this.setState({ - CalculateMax: maxs, - }) - - // } - } //提交数据 pustdate = () => { var thiss = this; - // console.log("pustdate"); + // //console.log("pustdate"); var homeworkid = this.props.match.params.homeworkid var array = []; var datas = this.state.challenge_settings; @@ -399,9 +407,9 @@ class Trainingjobsetting extends Component { }; challenge_scoredata.push(datas[i].challenge_score); array.push(object) - // console.log("datas[i].challenge_score"); - // console.log(i); - // console.log(datas[i].challenge_score); + // //console.log("datas[i].challenge_score"); + // //console.log(i); + // //console.log(datas[i].challenge_score); } } @@ -643,6 +651,7 @@ class Trainingjobsetting extends Component { if (this.state.completionefficiencyscore === true) { latedeductiontwos = this.state.latedeductiontwo; } + //从这里开始记得等于0的时候还要做判断 if (challenge_scoredata.length > 0) { var len = 0; for (var k = 0; k < challenge_scoredata.length; k++) { @@ -677,6 +686,16 @@ class Trainingjobsetting extends Component { } + }else{ + try { + if(parseFloat(this.state.CalculateMax)!==parseFloat(0)){ + this.props.showNotification(`分值之和必须等于总分值:${this.state.CalculateMax}分`); + this.scrollToAnchor("zongfentimeid"); + return; + } + }catch (e) { + + } } var url = `/homework_commons/${homeworkid}/update_settings.json`; @@ -690,7 +709,7 @@ class Trainingjobsetting extends Component { if (this.state.unifiedsetting === true) { - console.log("统一设置"); + //console.log("统一设置"); data = { unified_setting: this.state.unifiedsetting, //统一配置 publish_time: moment(this.state.publish_time).format('YYYY-MM-DD HH:mm'), //发布时间 @@ -704,7 +723,9 @@ class Trainingjobsetting extends Component { shixun_evaluation: this.state.proportion === "均分比例" ? 0 : this.state.proportion === "经验值比例" ? 1 : this.state.proportion === "自定义分值" ? 2 : 0, challenge_settings: array, score_open: this.state.publicwork, - total_score:this.state.CalculateMax + total_score:this.state.CalculateMax, + total_scoretwo:this.state.CalculateMax,//记录总分值点击取消的时候还原总分值 + } } else { // //非统一配置 @@ -735,7 +756,8 @@ class Trainingjobsetting extends Component { shixun_evaluation: this.state.proportion === "均分比例" ? 0 : this.state.proportion === "经验值比例" ? 1 : this.state.proportion === "自定义分值" ? 2 : 0, challenge_settings: array, score_open: this.state.publicwork, - total_score:this.state.CalculateMax + total_score:this.state.CalculateMax, + total_scoretwo:this.state.CalculateMax } } @@ -999,21 +1021,21 @@ class Trainingjobsetting extends Component { for (var i = 0; i < challenge_settingsdata.length; i++) { if (challenge_settingsdata[i].checked === true) { if (srbool === false) { - console.log(intkks); + //console.log(intkks); mact = mact + 1; if (mact === srorelength) { challenge_settingsdata[i].challenge_score = (parseFloat(Proportion.toFixed(1)) + parseFloat(intkks.toFixed(1))).toFixed(1); - console.log(challenge_settingsdata[i].challenge_score); + //console.log(challenge_settingsdata[i].challenge_score); } else { challenge_settingsdata[i].challenge_score = Proportion.toFixed(1); } } else { - console.log(intkk); + //console.log(intkk); mact = mact + 1; if (mact === srorelength) { challenge_settingsdata[i].challenge_score = (parseFloat(Proportion.toFixed(1)) + parseFloat(intkk.toFixed(1))).toFixed(1); - console.log(challenge_settingsdata[i].challenge_score); + //console.log(challenge_settingsdata[i].challenge_score); } else { challenge_settingsdata[i].challenge_score = Proportion.toFixed(1); } @@ -1092,14 +1114,14 @@ class Trainingjobsetting extends Component { if (mact === macts) { if (bool === true) { challenge_settingsdata[i].challenge_score = (parseFloat(challenge_settingsdata[i].challenge_score) + parseFloat(expzsy.toFixed(1))).toFixed(1); - console.log(parseFloat(challenge_settingsdata[i].challenge_score) + parseFloat(expzsy.toFixed(1))); - console.log(parseFloat(expzsy.toFixed(1))); + //console.log(parseFloat(challenge_settingsdata[i].challenge_score) + parseFloat(expzsy.toFixed(1))); + //console.log(parseFloat(expzsy.toFixed(1))); } else { challenge_settingsdata[i].challenge_score = (parseFloat(challenge_settingsdata[i].challenge_score) - parseFloat(expzsy.toFixed(1))).toFixed(1); - console.log(parseFloat(challenge_settingsdata[i].challenge_score) - parseFloat(expzsy.toFixed(1))); - console.log(parseFloat(expzsy.toFixed(1))); + //console.log(parseFloat(challenge_settingsdata[i].challenge_score) - parseFloat(expzsy.toFixed(1))); + //console.log(parseFloat(expzsy.toFixed(1))); } } @@ -1190,8 +1212,7 @@ class Trainingjobsetting extends Component { } //总比分 Totalscorecalculation = (value) => { - - + debugger this.setState({ CalculateMax: value, }) @@ -1407,7 +1428,7 @@ class Trainingjobsetting extends Component { }); } ontimeonok = (value) => { - console.log("ontimeonok点击了2"); + //console.log("ontimeonok点击了2"); if (value === undefined) { return; @@ -1479,7 +1500,7 @@ class Trainingjobsetting extends Component { } } onStartChange = (value, dateString) => { - console.log("onStartChange点击了1"); + //console.log("onStartChange点击了1"); if (value == null) { this.setState({ @@ -1508,8 +1529,8 @@ class Trainingjobsetting extends Component { } catch (e) { } - // console.log(value); - console.log(dateString); + // //console.log(value); + //console.log(dateString); // console.log(handleDateString(dateString)); // this.onChangedata('publish_time', value, dateString); this.setState({ @@ -1662,7 +1683,7 @@ class Trainingjobsetting extends Component { rulesdata.map((item, key) => { if (item.publish_time != "Invalid date") { if (moment(value, "YYYY-MM-DD HH:mm") <= moment(item.publish_time)) { - console.log(moment(item.publish_time, "YYYY-MM-DD HH:mm") <= moment(publish_time)) + //console.log(moment(item.publish_time, "YYYY-MM-DD HH:mm") <= moment(publish_time)) let kes = key + 1; this.setState({ hand__e_tip: "补交时间不能早于发布规则" + kes + "的发布时间", @@ -2061,9 +2082,9 @@ class Trainingjobsetting extends Component { } } catch (e) { - console.log("报错editSettings"); - console.log(1); - console.log(e); + //console.log("报错editSettings"); + //console.log(1); + //console.log(e); } @@ -2089,8 +2110,8 @@ class Trainingjobsetting extends Component { } } } catch (e) { - console.log(2); - console.log(e); + //console.log(2); + //console.log(e); this.setState({ flagPageEditsbox: true, flagPageEdit: true, @@ -2121,8 +2142,8 @@ class Trainingjobsetting extends Component { } } catch (e) { - console.log(3); - console.log(e); + //console.log(3); + //console.log(e); } }; //取消编辑 @@ -2147,6 +2168,9 @@ class Trainingjobsetting extends Component { }) this.refs.targetElementTrainingjobsetting.scrollIntoView(); this.getTrainingjobsetting(false); + this.setState({ + CalculateMax:this.state.total_scoretwo, + }) } rulesCheckInfo = (rules) => { @@ -2167,8 +2191,8 @@ class Trainingjobsetting extends Component { } } - console.log(rules); - console.log(datas); + //console.log(rules); + //console.log(datas); this.setState({ rules, rulesdata: datas, diff --git a/public/react/src/modules/developer/DeveloperHome.js b/public/react/src/modules/developer/DeveloperHome.js index 646e21704..1816ccbc7 100644 --- a/public/react/src/modules/developer/DeveloperHome.js +++ b/public/react/src/modules/developer/DeveloperHome.js @@ -108,8 +108,8 @@ class DeveloperHome extends React.PureComponent { width: 100, render: (text, record) => ( - ), @@ -179,6 +179,7 @@ class DeveloperHome extends React.PureComponent { componentDidMount() { // 是否是我的,如果是我的 显示编辑按钮 const { isMySource } = this.props; + console.log(this.props); if (isMySource) { this.handleFilterSearch({come_from: 'mine'}); let _columns = this.columns.concat([this.options]); @@ -197,6 +198,31 @@ class DeveloperHome extends React.PureComponent { }); } + // 是否登录 + isLogin = (url) => { + if(this.props.checkIfLogin()===false){ + this.props.showLoginDialog() + return false; + } + return true; + } + + // 新建 + handleClickNew = () => { + if (this.isLogin()) { + // this.props.history.push('/problems/new'); + window.location.href = '/problems/new' + } + // window.location.href = '/problems/new'; + } + + // 编辑 + handleClickEditor = (identifier) => { + if (this.isLogin()) { + this.props.history.push(`/problems/${identifier}/edit`) + } + } + // table条件变化时 handleTableChange = (pagination, filters, sorter) => { const {field, order} = sorter; const {current, pageSize} = pagination; @@ -208,7 +234,7 @@ class DeveloperHome extends React.PureComponent { }); this.props.changePaginationInfo(pagination); }; - + // 获取接口数据 fetchData = () => { this.props.fetchOJList(this.state.searchParams); }; @@ -245,7 +271,9 @@ class DeveloperHome extends React.PureComponent { this.setState({ searchParams: searchParams }, () => { - this.fetchData(); + if (this.isLogin()) { + this.fetchData(); + } }); } @@ -343,10 +371,17 @@ class DeveloperHome extends React.PureComponent { // 点击name handleNameClick = (record) => { - console.log('name has click', record); + // console.log('name has click', record); // 先调用start接口获取返回的 identifier, 再跳转到开启编辑 - this.props.startProgramQuestion(record.identifier, this.props); + if (this.isLogin()) { + // console.log(record); + this.props.startProgramQuestion(record.identifier, this.props); + } } + // if(this.props.checkIfLogin()===false){ + // this.props.showLoginDialog() + // return + // } render () { // const { testReducer, handleClick } = this.props; @@ -388,8 +423,8 @@ class DeveloperHome extends React.PureComponent {
    -
    diff --git a/public/react/src/modules/developer/components/controlSetting/index.scss b/public/react/src/modules/developer/components/controlSetting/index.scss index 0c7f726f5..4a2c221c1 100644 --- a/public/react/src/modules/developer/components/controlSetting/index.scss +++ b/public/react/src/modules/developer/components/controlSetting/index.scss @@ -67,6 +67,14 @@ font-size: 12px; } } + + .ant-drawer-body{ + height: calc(100vh - 120px); + overflow-y: auto; + } + .ant-drawer-content{ + top: 120px; + } } diff --git a/public/react/src/modules/developer/components/errorResult/index.js b/public/react/src/modules/developer/components/errorResult/index.js index 236a0cb9d..fa568edca 100644 --- a/public/react/src/modules/developer/components/errorResult/index.js +++ b/public/react/src/modules/developer/components/errorResult/index.js @@ -4,49 +4,72 @@ * @Github: * @Date: 2019-12-03 15:20:55 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-03 15:31:15 + * @LastEditTime: 2019-12-03 20:36:24 */ +import './index.scss'; import React from 'react'; +import MonacoEditor from '@monaco-editor/react'; function ErrorResult (props) { - const { detail } = props; - + const { detail, language } = props; const renderError = (detail = {}) => { const { status, - error_line, + // error_line, error_msg, expected_output, input, output, execute_time, - execute_memory + // execute_memory } = detail; // 根据状态渲染不同的错误信息 let result = null; switch (status) { case -1: result = ( -
    -

    输入: [input]

    -

    输出: [output]

    -

    预期: [expected_output]

    +
    +

    输入: [{input}]

    +

    输出: [{output}]

    +

    预期: [{expected_output}]

    ); - break; + break; case 2: // 评测超时 - return ( -
    -

    执行超时,限制时限: {`${execute_time}s`}

    -
    - ); - break; + result = ( +
    +

    执行超时,限制时限: {`${execute_time}s`}

    +
    + ); + break; case 3: // 创建pod失败 + result = ( +
    +
    + ); break; case 4: // 编译失败 + result = ( +
    + {/*

    {error_msg}

    */} + +
    + ); break; case 5: // 执行失败 + result = ( +
    +

    执行出错信息:

    +

    最后执行的输入: {input}

    +
    + ); break; default: return result; diff --git a/public/react/src/modules/developer/components/errorResult/index.scss b/public/react/src/modules/developer/components/errorResult/index.scss index e69de29bb..d21a200bc 100644 --- a/public/react/src/modules/developer/components/errorResult/index.scss +++ b/public/react/src/modules/developer/components/errorResult/index.scss @@ -0,0 +1,11 @@ +.error_result_wrap{ + &.error_result_txt{ + padding: 20px 30px; + } + &.error_result_code{ + height: 150px; + .error_result_code_txt{ + line-height: 32px; + } + } +} \ No newline at end of file diff --git a/public/react/src/modules/developer/components/monacoSetting/index.js b/public/react/src/modules/developer/components/monacoSetting/index.js index 0d71f55be..a101819e0 100644 --- a/public/react/src/modules/developer/components/monacoSetting/index.js +++ b/public/react/src/modules/developer/components/monacoSetting/index.js @@ -4,25 +4,54 @@ * @Github: * @Date: 2019-11-25 17:50:33 * @LastEditors: tangjiang - * @LastEditTime: 2019-11-27 14:40:36 + * @LastEditTime: 2019-12-06 16:51:48 */ -import React from 'react'; -import { Select } from 'antd'; - -const { Option } = Select; +import React, { useState } from 'react'; +import { fromStore, toStore } from 'educoder'; +// import { Select } from 'antd'; +// const { Option } = Select; const SettingDrawer = (props) => { /** * title: '', // 一级标题 * type: '', // 类型: 目录 select 和 文本 * content: [] // 显示的内容 { text: '' , value: string | [{ key: 1, value: '', text: '' }] } */ + + const [fontSize, setFontSize] = useState(() => { + return +fromStore('oj_fontSize') || 14; + }); + const [theme, setTheme] = useState(() => { + return fromStore('oj_theme') || 'dark'; + }); + const {title, type = 'label', content = [] } = props; - const handleFontSize = (value) => { - const {onChangeFontSize} = props; - // console.log('fong size change: ', value); + // 字体改变时, 方法全名: handleChangeXX, XX 为指定的类型; + const { + onChangeFontSize, + onChangeTheme + } = props; + const handleChangeFont = (value) => { + setFontSize(value); + toStore('oj_fontSize', value); onChangeFontSize && onChangeFontSize(value); } + // 风格改变时 + const handleChangeStyle = (value) => { + setTheme(value); + toStore('oj_theme', value); + onChangeTheme && onChangeTheme(value); + } + + const handleSelectChange = (e, type) => { + const value = e.target.value; + if (type === 'font') { + handleChangeFont(value); + } + if (type === 'style') { + handleChangeStyle(value); + } + } const renderCtx = (title, content = [], type = 'label') => { const result = content.map((ctx, index) => { @@ -37,19 +66,25 @@ const SettingDrawer = (props) => {
    ); } else if (Array.isArray(value)) { + const defaultValue = ctx.type === 'font' ? fontSize : theme; + console.log('++', defaultValue); if (type === 'select') { - const child = ctx.value.map((opt, i) => ( - - )); + const child = ctx.value.map((opt, i) => { + return ( + + )}); renderResult = (
    {ctx.text} - handleSelectChange(e, ctx.type)}> {child} - -
    + +
    ); } } diff --git a/public/react/src/modules/developer/components/myMonacoEditor/index.js b/public/react/src/modules/developer/components/myMonacoEditor/index.js index 989fc07ba..50d96db2d 100644 --- a/public/react/src/modules/developer/components/myMonacoEditor/index.js +++ b/public/react/src/modules/developer/components/myMonacoEditor/index.js @@ -4,11 +4,12 @@ * @Github: * @Date: 2019-11-27 15:02:52 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-03 09:29:54 + * @LastEditTime: 2019-12-06 16:50:54 */ import './index.scss'; import React, { useState, useRef, useEffect } from 'react'; -import { Icon, Drawer } from 'antd'; +import { Icon, Drawer, Modal } from 'antd'; +import { fromStore } from 'educoder'; import { connect } from 'react-redux'; import MonacoEditor from '@monaco-editor/react'; import SettingDrawer from '../../components/monacoSetting'; @@ -21,23 +22,30 @@ function MyMonacoEditor (props, ref) { const { language, - code, + identifier, showOrHideControl, // saveUserInputCode, - onCodeChange + onCodeChange, + onRestoreInitialCode } = props; + const [showDrawer, setShowDrawer] = useState(false); // 控制配置滑框 const [editCode, setEditCode] = useState(''); // const [curLang, setCurLang] = useState('C'); - const [fontSize, setFontSize] = useState(12); + const [fontSize, setFontSize] = useState(() => { // 字体 + return +fromStore('oj_fontSize') || 14; + }); + const [theme, setTheme] = useState(() => { // 主题 theme + return fromStore('oj_theme') || 'dark'; + }); const [ height, setHeight ] = useState('calc(100% - 112px)'); const editorRef = useRef(null); useEffect(() => { - if (code) { - setEditCode(code); + if (props.code) { + setEditCode(props.code); } - }, [code]); + }, [props]); useEffect(() => { setHeight(showOrHideControl ? 'calc(100% - 382px)' : 'calc(100% - 112px)'); @@ -52,9 +60,13 @@ function MyMonacoEditor (props, ref) { setShowDrawer(false); } // 侧边栏改变字体大小 - const handleFontSizeChange = (value) => { + const handleChangeFontSize = (value) => { setFontSize(value); } + // 改变主题 + const handleChangeTheme = (value) => { + setTheme(value); + } // 文本框内容变化时,记录文本框内容 const handleEditorChange = (origin, monaco) => { @@ -77,11 +89,24 @@ function MyMonacoEditor (props, ref) { fontSize: `${fontSize}px` } + // 恢复初始代码 + const handleRestoreCode = () => { + Modal.confirm({ + content: '确定要恢复代码吗?', + okText: '确定', + cancelText: '取消', + onOk () { + onRestoreInitialCode && onRestoreInitialCode(); + } + }) + } + return (
    - 已保存 + {identifier ? '已保存' : ''} + {identifier ? '恢复初始代码' : ''}
    @@ -102,7 +127,11 @@ function MyMonacoEditor (props, ref) { onClose={handleDrawerClose} visible={showDrawer} > - +
    diff --git a/public/react/src/modules/developer/components/myMonacoEditor/index.scss b/public/react/src/modules/developer/components/myMonacoEditor/index.scss index cd474b885..7b73794aa 100644 --- a/public/react/src/modules/developer/components/myMonacoEditor/index.scss +++ b/public/react/src/modules/developer/components/myMonacoEditor/index.scss @@ -3,11 +3,19 @@ .code_title{ display: flex; align-items: center; - justify-content: space-between; + // justify-content: space-between; background: #000; color: #fff; height: 56px; padding: 0 30px; + .flex_strict{ + flex: 1; + } + .flex_normal{ + color: #E51C24; + cursor: pointer; + margin-right: 30px; + } .code-icon{ cursor: pointer; } diff --git a/public/react/src/modules/developer/index.js b/public/react/src/modules/developer/index.js index cf082fa70..fb64b3f67 100644 --- a/public/react/src/modules/developer/index.js +++ b/public/react/src/modules/developer/index.js @@ -7,12 +7,13 @@ */ import React from 'react'; import { TPMIndexHOC } from '../tpm/TPMIndexHOC'; +import { SnackbarHOC } from 'educoder'; import DeveloperHome from './DeveloperHome'; -const App = () => { +const App = (props) => { return ( - + ); } -export default TPMIndexHOC(App); +export default SnackbarHOC()(TPMIndexHOC(App)); diff --git a/public/react/src/modules/developer/index.scss b/public/react/src/modules/developer/index.scss index 8c9b141b0..cc76bc4b7 100644 --- a/public/react/src/modules/developer/index.scss +++ b/public/react/src/modules/developer/index.scss @@ -58,6 +58,7 @@ } .dropdonw-style{ margin-right: 50px; + cursor: pointer; .dropdown-span{ cursor: pointer; margin-right: 10px; diff --git a/public/react/src/modules/developer/newOrEditTask/index.js b/public/react/src/modules/developer/newOrEditTask/index.js index 6e1ec7a4a..fc9951d92 100644 --- a/public/react/src/modules/developer/newOrEditTask/index.js +++ b/public/react/src/modules/developer/newOrEditTask/index.js @@ -6,10 +6,10 @@ * @Last Modified time: 2019-11-19 23:23:41 */ import './index.scss'; -import React, { useState, useEffect, useRef } from 'react'; +import React, { useEffect } from 'react'; import { connect } from 'react-redux'; import SplitPane from 'react-split-pane';// import { Form } from 'antd'; -import { Button, Icon, notification } from 'antd'; +import { Button, Icon } from 'antd'; import { Link } from 'react-router-dom'; import LeftPane from './leftpane'; import RightPane from './rightpane'; @@ -20,76 +20,17 @@ const NewOrEditTask = (props) => { const { publishLoading, handlePublish, - testCases = [], + // testCases = [], // ojTestCaseValidate = [], - changeSubmitLoadingStatus, + // changeSubmitLoadingStatus, changePublishLoadingStatus, - updateTestAndValidate, + // updateTestAndValidate, identifier, } = props; - const leftRef = useRef(null); - const rightRef = useRef(null); - - const [formDate, setFormData] = useState({}); - - // const isNullOrUndefiendOrZero = (value) => { - // if ([undefined, null, ''].includes(value)) { - // return true; - // } - // return false; - // } // 表单提交 const handleSubmitForm = () => { // 调用输入表单验证功能 - - - // let hasErrorForTestCase = false; - // const tempTestCaseValidate = []; - // // 验证测试用例 - // testCases.forEach(tc => { - // const obj = {}; - // if (isNullOrUndefiendOrZero(tc.input)) { - // hasErrorForTestCase = true; - // obj['input'] = { - // validateStatus: 'error', - // errMsg: '输入值不能为空' - // } - // } else { - // obj['input'] = { - // validateStatus: '', - // errMsg: '' - // } - // } - // if (isNullOrUndefiendOrZero(tc.output)) { - // hasErrorForTestCase = true; - // obj['output'] = { - // validateStatus: 'error', - // errMsg: '输出值不能为空' - // } - // } else { - // obj['output'] = { - // validateStatus: '', - // errMsg: '' - // } - // } - // // 更改测试用例值 - // tempTestCaseValidate.push(obj); - // }); - // // 验证代码块 - // if (!formValue || hasErrorForTestCase) { - // // 验证不通过时, 回滚按钮状态 - // changeSubmitLoadingStatus(false); - // changePublishLoadingStatus(false); - // updateTestAndValidate({ // 测试用例 - // testCaseValidate: tempTestCaseValidate - // }); - // return; - // } - // console.log('调用提交接口===========》》》》》》》》》》》》'); - // props.saveOjFormCode(code); // 保存代码块值 - // // TODO - // // identifier 存在时 if (props.identifier) { props.handleUpdateOjForm(props); } else { @@ -135,7 +76,7 @@ const NewOrEditTask = (props) => { onClick={handleClickPublish}>立即发布
    - +
    diff --git a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/AddTestDemo.js b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/AddTestDemo.js index b4b5983f9..279333d1d 100644 --- a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/AddTestDemo.js +++ b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/AddTestDemo.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-21 09:19:38 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-02 19:20:30 + * @LastEditTime: 2019-12-04 15:44:12 */ import './index.scss'; import React, { useState } from 'react'; @@ -29,13 +29,14 @@ const AddTestDemo = (props) => { // 删除操作 const handleDeletePanel = (e) => { // console.log('点击的删除按钮') + e.preventDefault(); + e.stopPropagation(); Modal.confirm({ title: '删除', content: '确定要删除当前测试用例吗?', okText: '确定', cancelText: '取消', onOk() { - console.log('确定删除'); onDeleteTest(testCase); } }) diff --git a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js index 702e78040..b6416e979 100644 --- a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js +++ b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js @@ -4,20 +4,21 @@ * @Github: * @Date: 2019-11-20 10:35:40 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-03 08:41:14 + * @LastEditTime: 2019-12-06 20:20:27 */ import 'quill/dist/quill.core.css'; import 'quill/dist/quill.bubble.css'; import 'quill/dist/quill.snow.css'; import './index.scss'; // import 'katex/dist/katex.css'; -import React, { PureComponent } from 'react'; +import React from 'react'; import { Form, Input, Select, InputNumber, Button } from 'antd'; import { connect } from 'react-redux'; import AddTestDemo from './AddTestDemo'; import QuillEditor from '../../../quillEditor'; import actions from '../../../../../redux/actions'; import CONST from '../../../../../constants'; +import { fromStore, toStore } from 'educoder'; // 保存和读取store值 const scrollIntoView = require('scroll-into-view'); const {jcLabel} = CONST; const FormItem = Form.Item; @@ -25,9 +26,9 @@ const { Option } = Select; const maps = { language: [ { title: 'C', key: 'C' }, - { title: 'C++', key: 'C++' }, - { title: 'Python', key: 'Python' }, - { title: 'Java', key: 'Java' } + // { title: 'C++', key: 'C++' }, + // { title: 'Python', key: 'Python' }, + // { title: 'Java', key: 'Java' } ], difficult: [ { title: '简单', key: '1' }, @@ -43,7 +44,7 @@ const maps = { { title: '私有', key: '0' } ] } -class EditTab extends PureComponent { +class EditTab extends React.Component { constructor (props) { super(props); @@ -88,7 +89,7 @@ class EditTab extends PureComponent { const scrollTop = e.target.scrollTop; const { scrollHeight, offsetTop} = this.state; // 滚动距离 + 元素的高度 大于 offsetTop值时, 添加 fix_top 样式 - console.log(tOffsetTop, tOffsetHeight, scrollTop, scrollHeight, offsetTop); + // console.log(tOffsetTop, tOffsetHeight, scrollTop, scrollHeight, offsetTop); if ((scrollTop + tOffsetHeight > tOffsetTop) && (tOffsetTop >= offsetTop)) { oTarget.className = `test_demo_title fix_top`; } else if ((scrollHeight + scrollTop < offsetTop) && (scrollHeight <= offsetTop)){ @@ -110,6 +111,8 @@ class EditTab extends PureComponent { // 改变描述信息 handleChangeDescription = (value) => { // console.log('获取的编辑器内容为: ', value); + // 描述信息变化时,将信息保存至store中 + toStore('oj_description', value); this.props.validateOjDescription(value); } // 改变难易度 @@ -137,7 +140,7 @@ class EditTab extends PureComponent { const { ojForm, ojFormValidate, - testCases = [], // 测试用例集合 + // testCases = [], // 测试用例集合 addTestCase, // 添加测试用例 deleteTestCase, // 删除测试用例 testCasesValidate, @@ -181,8 +184,7 @@ class EditTab extends PureComponent { deleteTestCase(obj); }; const renderTestCase = () => { - console.log(openTestCodeIndex); - return testCases.map((item, i) => { + return this.props.testCases.map((item, i) => { return
    @@ -260,7 +272,8 @@ class EditTab extends PureComponent { style={{ height: '300px' }} placeholder="请输入描述信息" onEditorChange={this.handleChangeDescription} - htmlCtx={ojForm.description} + htmlCtx={ojForm.description || fromStore('oj_description')} + options={quillConfig} /> { - // const { } = props; + const { + description + } = props; + + const prevRef = useRef(null); const [desc, setDesc] = useState(''); + const [renderCtx, setRenderCtx] = useState(() => { + return function () { + return ''; + } + }); + + // 空内容 + const renderTxt = () => ( +
    + +
    + ); + // 渲染内容 + const renderQuill = () => ( +
    +
    + ); useEffect(() => { - setDesc(props.description); - }, [props.description]); - - const renderHtml = () => { - if (!desc) { - return ( -
    - -
    - ); + setDesc(description); + }, [description]); + + useEffect(() => { + if (description) { + setRenderCtx(() => renderQuill); + let count = 0; + let timer = setInterval(() => { + count++; + if (count >= 10 || prevRef.current) { + clearInterval(timer); + timer = null; + if (prevRef.current) { + const quillEditor = new Quill(prevRef.current, { + readOnly: true, + theme: 'bubble' + }); + quillEditor.container.firstChild.innerHTML = description; + } + } + }, 50); } else { - return ( -
    - ) + setRenderCtx(() => renderTxt); } - } + + }, [description]); + return (
    - {/* {renderHtml()} */} - {/*
    */} - + {renderCtx()}
    ) diff --git a/public/react/src/modules/developer/newOrEditTask/leftpane/prevTab/index.scss b/public/react/src/modules/developer/newOrEditTask/leftpane/prevTab/index.scss index ff1bf2469..e93f56951 100644 --- a/public/react/src/modules/developer/newOrEditTask/leftpane/prevTab/index.scss +++ b/public/react/src/modules/developer/newOrEditTask/leftpane/prevTab/index.scss @@ -8,4 +8,10 @@ .render_html{ padding: 20px 30px; +} + +.prev_area{ + // padding: 0 30px; + padding-left: 20px; + height: calc(100vh - 110px); } \ No newline at end of file diff --git a/public/react/src/modules/developer/newOrEditTask/rightpane/index.js b/public/react/src/modules/developer/newOrEditTask/rightpane/index.js index d1b022cac..77f1a1f5d 100644 --- a/public/react/src/modules/developer/newOrEditTask/rightpane/index.js +++ b/public/react/src/modules/developer/newOrEditTask/rightpane/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-12-01 10:18:35 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-03 09:11:50 + * @LastEditTime: 2019-12-06 17:50:58 */ import './index.scss'; import React from 'react'; @@ -17,14 +17,25 @@ function RightPane (props, ref) { const { // identifier, + code, onSubmitForm, saveOjFormCode } = props; + // let timer = null; // 代码改变时,保存 - const handleCodeChange = (code) => { + const handleCodeChange = (updateCode) => { // 保存用户输入的代码 - saveOjFormCode(code); + // if (!timer) { + // timer = setInterval(() => { + // clearInterval(timer); + // timer = null; + // if (updateCode) { + // console.log('调用更新代码------>>>>>>', updateCode); + // } + // }, 3000); + // } + saveOjFormCode(updateCode); } // 启动调试代码 // const handleDebuggerCode = (value) => { @@ -32,7 +43,11 @@ function RightPane (props, ref) { // } return (
    - + + { count++; if (count >= 10 || this.props.htmlCtx) { - quillEditor.container.firstChild.innerHTML = this.props.htmlCtx; + quillEditor.container.firstChild.innerHTML = this.props.htmlCtx || ''; clearInterval(this.timer); this.timer = null; } - // console.log('定时器====>>>>>', count); }, 50); // quillEditor.setText('

    aaa

    '); diff --git a/public/react/src/modules/developer/recordDetail/index.js b/public/react/src/modules/developer/recordDetail/index.js new file mode 100644 index 000000000..9bb66715a --- /dev/null +++ b/public/react/src/modules/developer/recordDetail/index.js @@ -0,0 +1,117 @@ +/* + * @Description: 提交记录详情 + * @Author: tangjiang + * @Github: + * @Date: 2019-12-04 08:36:21 + * @LastEditors: tangjiang + * @LastEditTime: 2019-12-05 13:52:04 + */ +import './index.scss'; +import React, { useState, useEffect } from 'react'; +import { Button } from 'antd'; +import moment from 'moment'; +import ErrorResult from '../components/errorResult'; +import { Link } from 'react-router-dom'; +import MonacoEditor from '@monaco-editor/react'; +import { connect } from 'react-redux'; +import { getImageUrl } from 'educoder'; +import actions from '../../../redux/actions'; +import CONST from '../../../constants'; + +const {reviewResult} = CONST; + +function RecordDetail (props) { + const { + match: { params }, + mygetHelmetapi = {}, + recordDetail, + identifier, + getUserCommitRecordDetail + } = props; + + const id = params.id; + const [detail, setDetail] = useState({}); + + useEffect(() => { + // 根据id获取记录详情 + console.log('提交记录详情', recordDetail); + getUserCommitRecordDetail(id, 'detail'); + }, []); + + useEffect(() => { + setDetail(recordDetail); + + }, [recordDetail]); + return ( +
    +
    +
    + 用户头像 + + {(mygetHelmetapi &&mygetHelmetapi.name) || ''} + +
    +
    + {detail.name || 'test'} +
    +
    + +
    +
    +
    +
    +

    提交记录

    +
    +
    + + 状态: {reviewResult[detail.status]} + + + 提交时间: + {moment(detail.created_at).format('YYYY-MM-DD HH:mm')} + + + + 语言: C + +
    +
    + +
    +
    +

    提交内容

    + +
    +
    + +
    +
    +
    + ) +} + +const mapStateToProps = (state) => { + const {recordDetail, user_program_identifier} = state.ojForUserReducer; + return { + identifier: user_program_identifier, + recordDetail + } +} +const mapDispatchToProps = (dispatch) => ({ + // 根据id号获取记录详情 + getUserCommitRecordDetail: (id, type) => dispatch(actions.getUserCommitRecordDetail(id, type)) +}); + +export default connect( + mapStateToProps, + mapDispatchToProps +)(RecordDetail); \ No newline at end of file diff --git a/public/react/src/modules/developer/recordDetail/index.scss b/public/react/src/modules/developer/recordDetail/index.scss new file mode 100644 index 000000000..5c6c78f7e --- /dev/null +++ b/public/react/src/modules/developer/recordDetail/index.scss @@ -0,0 +1,44 @@ +@import '../split_pane_resizer.scss'; + +.record_detail_area{ + .record_detail_ctx{ + padding: 0 30px; + .detail_ctx_header{ + position: relative; + height: 56px; + } + .header_h2{ + line-height: 56px; + } + .header_btn{ + position: absolute; + right: 0; + top: 14px; + } + .detail_ctx_status{ + height: 18px; + line-height: 18px; + .status_label{ + color: rgba(153,153,153,1); + margin-right: 40px; + } + .status_label_error{ + color: #E51C24; + } + .status_label_success{ + color: #28BD8B; + } + .status_label_sub{ + color: #333333; + } + } + + .result_code_area{ + // height: 500px; + height: calc(100vh - 360px); + } + .result_error_area{ + margin-top: 15px; + } + } +} diff --git a/public/react/src/modules/developer/split_pane_resizer.scss b/public/react/src/modules/developer/split_pane_resizer.scss index 7700cf7db..f8b5b28eb 100644 --- a/public/react/src/modules/developer/split_pane_resizer.scss +++ b/public/react/src/modules/developer/split_pane_resizer.scss @@ -1,9 +1,11 @@ .new_add_task_wrap, -.student_study_warp{ +.student_study_warp, +.record_detail_area{ height: 100vh; .task_header, - .student_study_header{ + .student_study_header, + .record_detail_header{ height: 65px; background:rgba(34,34,34,1); padding:0 30px; @@ -50,7 +52,8 @@ } } - .student_study_header{ + .student_study_header, + .record_detail_header{ position: relative; .avator_nicker, .study_quit, diff --git a/public/react/src/modules/developer/studentStudy/index.js b/public/react/src/modules/developer/studentStudy/index.js index 3af736006..9f7b9f1bc 100644 --- a/public/react/src/modules/developer/studentStudy/index.js +++ b/public/react/src/modules/developer/studentStudy/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-23 10:53:19 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-03 14:49:32 + * @LastEditTime: 2019-12-06 18:59:22 */ import './index.scss'; import React, { useEffect } from 'react'; @@ -30,7 +30,6 @@ const StudentStudy = (props) => { saveUserProgramIdentifier, } = props; - console.log(props); let { id } = params; // console.log(id); // 保存当前的id @@ -57,7 +56,7 @@ const StudentStudy = (props) => {
    - +
    diff --git a/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.js b/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.js index a2e7c7465..63d1bd2a3 100644 --- a/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.js +++ b/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.js @@ -4,16 +4,18 @@ * @Github: * @Date: 2019-11-27 09:49:33 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-03 15:14:34 + * @LastEditTime: 2019-12-05 10:38:49 */ import './index.scss'; import React, { useState, useEffect } from 'react'; import { Table, Icon, message } from 'antd'; import { connect } from 'react-redux'; +import { Link } from 'react-router-dom'; import actions from '../../../../../redux/actions'; import CONST from '../../../../../constants'; import moment from 'moment'; import ClipboardJS from 'clipboard'; +import ErrorResult from '../../../components/errorResult'; const numberal = require('numeral'); @@ -30,7 +32,11 @@ const columns = [ { title: '提交结果', dataIndex: 'status', - render: (value) => ({reviewResult[value]}) + render: (value, record) => ( + + {reviewResult[value]} + + ) }, { title: '执行用时', @@ -66,6 +72,7 @@ const CommitRecord = (props) => { identifier, commitRecord, // excuteState, + language, commitRecordDetail, getUserCommitRecord } = props; @@ -81,6 +88,7 @@ const CommitRecord = (props) => { // 渲染提交记录详情 const renderRecordDetail = () => { const { + id, error_line, error_msg, execute_memory, @@ -107,10 +115,14 @@ const CommitRecord = (props) => {

    - 显示详情 + + 显示详情 +

    -
    {error_msg}
    +
    + +
    ); } else { @@ -123,7 +135,10 @@ const CommitRecord = (props) => { }, []); // 提交记录变化时,同步到表单数据 useEffect(() => { + const len = commitRecord.length; + const pageConfig = Object.assign({}, paginationConfig, {total: len}); setTableData(commitRecord); + setPagination(pageConfig); }, [commitRecord]); // 提交详情变化时,显示当前提交信息 useEffect(() => { @@ -140,15 +155,21 @@ const CommitRecord = (props) => { }); } }, [commitRecordDetail.status]); + + // + const handleTableChange = (pagination) => { + setPagination(Object.assign({}, pagination)); + } // console.log(commitRecord); return (
    - {renderRecordDetail()} + {renderCtx()}
    ID序号ID 实训名称 技术平台 权限技术体系上传图片小程序封面技术体系上传图片小程序封面 创建者 关闭 复制 操作
    - ssh/隐藏/首页/跳关/隐藏目录 + ssh/隐藏/首页/跳关/隐藏目录/vip
    <%= page_no %> <%= shixun.identifier %> @@ -47,6 +48,7 @@ <%= check_box_tag :homepage_show,!shixun.homepage_show,shixun.homepage_show,remote:true,data:{id:shixun.id,toggle:"tooltip",placement:"top"},class:"shixun-setting-form",title:"首页" %> <%= check_box_tag :task_pass,!shixun.task_pass,shixun.task_pass,remote:true,data:{id:shixun.id,toggle:"tooltip",placement:"top"},class:"shixun-setting-form" ,title:"跳关"%> <%= check_box_tag :code_hidden,!shixun.code_hidden,shixun.code_hidden,remote:true,data:{id:shixun.id,toggle:"tooltip",placement:"top"},class:"shixun-setting-form" ,title:"隐藏目录"%> + <%= check_box_tag :vip,!shixun.vip,shixun.vip,remote:true,data:{id:shixun.id,toggle:"tooltip",placement:"top"},class:"shixun-setting-form" ,title:"vip"%>
    ) @@ -162,7 +183,8 @@ const mapStateToProps = (state) => { const { user_program_identifier, commitRecordDetail, - commitRecord + commitRecord, + hack } = ojForUserReducer; const { excuteState } = commonReducer; return { @@ -170,6 +192,7 @@ const mapStateToProps = (state) => { commitRecordDetail, commitRecord, // 提交记录 excuteState, // 代码执行状态 + language: hack.language } } const mapDispatchToProps = (dispatch) => ({ diff --git a/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.scss b/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.scss index bed7b8f96..d409b8cef 100644 --- a/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.scss +++ b/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.scss @@ -42,11 +42,12 @@ .record_error_info{ display: none; padding: 20px 30px; + word-wrap:break-word; } .show_error_code{ display: block; background: rgba(250,250,250,1); - padding: 20px 30px; + // padding: 20px 30px; color: #E51C24; margin-bottom: 20px; } diff --git a/public/react/src/modules/developer/studentStudy/rightpane/index.js b/public/react/src/modules/developer/studentStudy/rightpane/index.js index 216deffdb..691f540e6 100644 --- a/public/react/src/modules/developer/studentStudy/rightpane/index.js +++ b/public/react/src/modules/developer/studentStudy/rightpane/index.js @@ -4,9 +4,9 @@ * @Github: * @Date: 2019-11-27 14:59:51 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-03 09:31:59 + * @LastEditTime: 2019-12-06 18:48:52 */ -import React from 'react'; +import React, { useState, useEffect } from 'react'; import {connect} from 'react-redux'; import MyMonacoEditor from '../../components/myMonacoEditor'; import ControlSetting from '../../components/controlSetting'; @@ -19,22 +19,40 @@ const RightPane = (props) => { submitInput, submitUserCode, input, + hack, updateCode, - saveUserInputCode + saveUserInputCode, + restoreInitialCode, + saveUserCodeForInterval } = props; + + const [editorCode, setEditorCode] = useState(''); + + useEffect(() => { + console.log('1111111'); + setEditorCode(hack.code); + }, [hack]); const handleSubmitForm = () => { - console.log('提交了表单内容'); // 提交时, 先调用提交接口,提交成功后,循环调用测评接口 submitUserCode(identifier, submitInput, 'submit'); // // 提交时,先调用评测接口, 评测通过后才调用保存接口 // updateCode(identifier, submitInput, 'submit'); } + + let timer = null; // 定时器 // 代码块内容变化时 const handleCodeChange = (code) => { // 保存用户提交的代码块 console.log(code); - // 保存用户代码块 + if (!timer) { + timer = setInterval(() => { + clearInterval(timer); + timer = null; + saveUserCodeForInterval(identifier, code); + }, 3000); + } + // 保存用户代码块 saveUserInputCode(code); } // 代码调试 @@ -42,13 +60,19 @@ const RightPane = (props) => { // 调用保存代码块接口,成功后,调用调试接口 updateCode(identifier, value, 'debug'); } + // 恢复初始代码 + const handleRestoreInitialCode = () => { + restoreInitialCode(identifier); + } return (
    - { const mapStateToProps = (state) => { const {user_program_identifier, hack, userTestInput} = state.ojForUserReducer; - const { language, code } = hack; + // const { language, code } = hack; return { - language, - code, + hack, input: userTestInput, submitInput: hack.input, identifier: user_program_identifier @@ -77,8 +100,12 @@ const mapDispatchToProps = (dispatch) => ({ submitUserCode: (identifier, inputValue, type) => dispatch(actions.submitUserCode(identifier, inputValue, type)), // 更新代码块内容 updateCode: (identifier, inputValue, type) => dispatch(actions.updateCode(identifier, inputValue, type)), - // 保存用户代码块 + // 保存用户代码块至Reducer中 saveUserInputCode: (code) => dispatch(actions.saveUserInputCode(code)), + // 保存用户代码至后台 + saveUserCodeForInterval: (identifier, code) => dispatch(actions.saveUserCodeForInterval(identifier, code)), + // 恢复初始代码 + restoreInitialCode: (identifier) => dispatch(actions.restoreInitialCode(identifier)), }); export default connect( diff --git a/public/react/src/modules/home/shixunsHome.js b/public/react/src/modules/home/shixunsHome.js index 6439338eb..260436807 100644 --- a/public/react/src/modules/home/shixunsHome.js +++ b/public/react/src/modules/home/shixunsHome.js @@ -242,13 +242,13 @@ class ShixunsHome extends Component {
    更多 -
    +
    {homedatalist===undefined?"":homedatalist.subjects.map((item,key)=>{ if(key<8) return( -
    +
    {item.excellent === false ? "" :
    @@ -321,7 +321,7 @@ class ShixunsHome extends Component {
    更多 -
    +
    {homedatalist===undefined?"":homedatalist.shixuns.map((item,key)=>{ return( -
    +
    {item.tag_name} diff --git a/public/react/src/modules/login/LoginDialog.js b/public/react/src/modules/login/LoginDialog.js index af0b7ed1e..dda9fed7f 100644 --- a/public/react/src/modules/login/LoginDialog.js +++ b/public/react/src/modules/login/LoginDialog.js @@ -469,6 +469,7 @@ class LoginDialog extends Component { autologin:isGoingValue } ).then((response) => { + debugger; if(response===undefined){ return } diff --git a/public/react/src/modules/page/VNCContainer.js b/public/react/src/modules/page/VNCContainer.js index 4a591f4ac..8164f052a 100644 --- a/public/react/src/modules/page/VNCContainer.js +++ b/public/react/src/modules/page/VNCContainer.js @@ -37,6 +37,11 @@ class VNCContainer extends Component { } } + + shouldComponentUpdate () { + return false; + } + getSecondDrawerWidth = () => { return $('#game_right_contents').width() - firstDrawerWidth } diff --git a/public/react/src/modules/page/component/WebSSHTimer.js b/public/react/src/modules/page/component/WebSSHTimer.js index 844c29785..e83887345 100644 --- a/public/react/src/modules/page/component/WebSSHTimer.js +++ b/public/react/src/modules/page/component/WebSSHTimer.js @@ -63,6 +63,7 @@ class WebSSHTimer extends Component { } init() { + console.log('调用定时器开始: =========>>>>>>>>>>>>'); // 20分钟倒计时 this.timeRemain = 20 * 60 * 1000; this.startTimeRemain = 0 @@ -85,7 +86,6 @@ class WebSSHTimer extends Component { return; } let _timeRemain = this.timeRemain; - $('.webSSHTimer').html(moment(_timeRemain).format('mm:ss')) _timeRemain -= 1000 this.timeRemain = _timeRemain; @@ -198,8 +198,8 @@ class WebSSHTimer extends Component { // } } else if (e.data.tp === "sshWorking") { - this.startTimeRemain = 60; - this.forceUpdate() + // this.startTimeRemain = 60; + // this.forceUpdate(); } }); // } else { @@ -320,7 +320,7 @@ class WebSSHTimer extends Component { { this.props.showTimerProp === true && showTimer === true &&

    实验环境将恢复到初始状态,

    是否确认重置实验环境?

    } + title={

    实验环境将恢复到初始状态,

    是否确认重置实验环境?

    } placement="bottom" onConfirm={this.resetSsh} okText="确定" cancelText="取消"> diff --git a/public/react/src/modules/page/component/monaco/TPIMonaco.js b/public/react/src/modules/page/component/monaco/TPIMonaco.js index 519125f93..c71f13361 100644 --- a/public/react/src/modules/page/component/monaco/TPIMonaco.js +++ b/public/react/src/modules/page/component/monaco/TPIMonaco.js @@ -244,12 +244,15 @@ class TPIMonaco extends Component { // 重要:setState(因获取代码、重置代码等接口引起的调用)调用引起的变化才需要setValue editor_monaco.setValue(this.props.repositoryCode) } - // 代码没变也需要layout,可能从命令行自动切回了代码tab + // 代码没变也需要layout,可能从命令行自动切回了代码tab + editor_monaco.layout(); + // Clears the editor's undo history. // TODO // extend_editor.clearHistory() - } + } + editor_monaco.layout(); } componentWillUnmount() { // 注意销毁,不然会出现不能编辑的bug diff --git a/public/react/src/modules/paths/ShixunPaths.css b/public/react/src/modules/paths/ShixunPaths.css index b73f68163..802795556 100644 --- a/public/react/src/modules/paths/ShixunPaths.css +++ b/public/react/src/modules/paths/ShixunPaths.css @@ -267,4 +267,8 @@ .color181818{ color: #181818; +} + +.colorD5D8D6{ + color:#D5D8D6; } \ No newline at end of file diff --git a/public/react/src/modules/projectPackages/PackageIndex/PackageConcent.js b/public/react/src/modules/projectPackages/PackageIndex/PackageConcent.js index 12894603a..ed592dcf3 100644 --- a/public/react/src/modules/projectPackages/PackageIndex/PackageConcent.js +++ b/public/react/src/modules/projectPackages/PackageIndex/PackageConcent.js @@ -217,7 +217,7 @@ class PackageConcent extends Component {
    -
    +
    {/*concent*/} diff --git a/public/react/src/modules/tpm/TPMIndex.js b/public/react/src/modules/tpm/TPMIndex.js index 9b3308e04..7fd389197 100644 --- a/public/react/src/modules/tpm/TPMIndex.js +++ b/public/react/src/modules/tpm/TPMIndex.js @@ -148,7 +148,7 @@ class TPMIndex extends Component { componentDidMount = () => { let id = this.props.match.params.shixunId; - + console.log('props', this.props); // let collaborators = `/shixuns/` + id + `/propaedeutics.json`; // // axios.get(collaborators).then((response) => { diff --git a/public/react/src/modules/user/account/AccountBasicEdit.js b/public/react/src/modules/user/account/AccountBasicEdit.js index 033f433b0..7d6fc13d2 100644 --- a/public/react/src/modules/user/account/AccountBasicEdit.js +++ b/public/react/src/modules/user/account/AccountBasicEdit.js @@ -136,7 +136,7 @@ class AccountBasic extends Component { } handleSubmit = () => { - this.props.form.validateFieldsAndScroll((err, values) => { + this.props.form.validateFieldsAndScroll({ force: true }, (err, values) => { console.log(values); let {basicInfo}=this.props; if(!err ){ @@ -148,12 +148,12 @@ class AccountBasic extends Component { this.props.showNotification('请先选择院系/部门') return; } - + let url=`/users/accounts/${basicInfo.id}.json` axios.put((url),{ nickname:values.nickname, // 认证中的不能修改 - name: basicInfo.authentication == 'uncertified' ? + name: basicInfo.authentication == 'uncertified' ? (this.state.showRealName ? values.name : this.state.realName ) : basicInfo.name, show_realname:this.state.showRealName, gender:parseInt(values.sex), @@ -173,7 +173,7 @@ class AccountBasic extends Component { } this.props.getBasicInfo(); this.props.history.push('/account/profile') - + } }).catch((error)=>{ console.log(error); @@ -357,7 +357,7 @@ class AccountBasic extends Component { }) } - + addOrgSuccess = (name) => { // const schoolList = this.state.schoolList.slice(0) @@ -377,7 +377,7 @@ class AccountBasic extends Component { } showApplyForAddOrgModal = () => { - this.applyForAddOrgForm.setVisible(true) + this.applyForAddOrgForm.setVisible(true) } showApplyForAddChildOrgModal = () => { let{school,schoolList}=this.state; @@ -385,18 +385,18 @@ class AccountBasic extends Component { return item.name == school; }); if(arr.length > 0){ - this.applyForAddChildOrgForm.setVisible(true) + this.applyForAddChildOrgForm.setVisible(true) }else{ this.props.showNotification("请先选择正确的单位或者学校!"); } } - checkNameLength = (rule, value, callback) => { - if (value && value.length <= MAX_NAME_LENGTH) { - callback(); - return; - } - callback(`请输入真实姓名,最大限制${MAX_NAME_LENGTH}个字符`); - } + // checkNameLength = (rule, value, callback) => { + // if (value && value.length <= MAX_NAME_LENGTH) { + // callback(); + // return; + // } + // callback(`请输入真实姓名,最大限制${MAX_NAME_LENGTH}个字符`); + // } // 切换职称 changeJob=(e)=>{ this.setState({ @@ -410,9 +410,53 @@ class AccountBasic extends Component { }) } } - + //昵称 + handleSubmitName(rule, value, callback){ + if (value) { + let iconRule1 = /[`~!@#$%^&*()\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im; +// 判断是否含有emoji表情 + let iconRule2 = /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig; +// 如果为true,字符串含有emoji表情 ,false不含 + const iconRule2s =iconRule2.test(value); +// 如果为true,字符串含有特殊符号 ,false不 + const iconRule1s =iconRule1.test(value); + + if (iconRule2s===true|| iconRule1s===true) { + callback('2-20位中英文、数字及下划线'); + } + else if(value.length<2){ + callback('2-20位中英文、数字及下划线'); + }else if(value.length>=21){ + callback('2-20位中英文、数字及下划线'); + } + } + callback(); + } + + // 姓名 + handleSubmitNames(rule, value, callback){ + if (value) { + let iconRule1 = /[`~!@#$%^&()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&()——\-+={}|《》?:“”【】、;‘’,。、]/im; +// 判断是否含有emoji表情 + let iconRule2 = /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig; +// 如果为true,字符串含有emoji表情 ,false不含 + const iconRule2s =iconRule2.test(value); +// 如果为true,字符串含有特殊符号 ,false不 + const iconRule1s =iconRule1.test(value); + + if (iconRule2s===true|| iconRule1s===true) { + callback('2-10位中英文、数字'); + } + else if(value.length<2){ + callback('2-10位中英文、数字'); + }else if(value.length>=11){ + callback('2-10位中英文、数字'); + } + } + callback(); + } render() { - let{ + let{ nameLength, showRealName, filterSchoolList, @@ -446,10 +490,10 @@ class AccountBasic extends Component { {...propsWithoutForm} addOrgSuccess={this.addOrgSuccess} > this.applyForAddChildOrgForm = form} + {...propsWithoutForm} wrappedComponentRef={(form) => this.applyForAddChildOrgForm = form} addChildOrgSuccess={this.addChildOrgSuccess} > - +
    - - - 已完成 - 未完成 - - - - -
    - - :""} - - - - { tpmLoading ?
    : - -
    - -
    - - - -
    - {this.props.identity >2||this.props.identity===undefined?"": ( - this.showModal(item.id,item.status)} key={key}> - - , - ]} - > - -
    {item.name}
    - {item.status===undefined?"":item.status===1?已完成:未完成} -
    } - description={ -
    - {item.time===undefined?"":审核时间: {item.time}} - {item.username===undefined?"":审核人: {item.username}} -
    - } - /> - - )} - />} -
    - -
    - -
    - -
    -
    - - } - - ); - } -} - -export default Audit_situationComponent; diff --git a/public/react/src/tpm/NewFooter.js b/public/react/src/tpm/NewFooter.js deleted file mode 100644 index 4ff1cc46a..000000000 --- a/public/react/src/tpm/NewFooter.js +++ /dev/null @@ -1,67 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; -import { Link } from 'react-router-dom'; -import { getImageUrl, toPath } from 'educoder' -import PropTypes from 'prop-types'; - -class NewFooter extends Component { - constructor(props) { - super(props) - - } - - componentWillReceiveProps(newProps, newContext) { - - } - - - render() { - return ( -
    - {/*newContainers*/} -
    - {this.props.user&&this.props.user.main_site===true?
    - {/*
    - - 高校智能化教学与实训平台 - - - EduCoder.net -
    */} -
      -
    • 网站首页
    • -
    • 关于我们
    • -
    • 联系我们
    • -
    • 合作伙伴
    • -
    • 服务协议
    • -
    • 帮助中心
    • -
    • 意见反馈
    • -
    -
    :""} -
    - {this.props.mygetHelmetapi === null ? "" : - this.props.mygetHelmetapi===undefined|| this.props.mygetHelmetapi.footer===null||this.props.mygetHelmetapi.footer===undefined? -

    - © 2019 EduCoder - 湘ICP备17009477号 - - 湘公网安备43019002000962号 - - Trustie   &   IntelliDE inside. 版权所有 湖南智擎科技有限公司 -

    - : -
    - - } - -
    -
    -
    -
    - ); - } -} - -export default NewFooter; diff --git a/public/react/src/tpm/NewHeader.js b/public/react/src/tpm/NewHeader.js deleted file mode 100644 index 41855c15a..000000000 --- a/public/react/src/tpm/NewHeader.js +++ /dev/null @@ -1,1427 +0,0 @@ -import React, { Component } from 'react'; -import { BrowserRouter as Router, Route, Link } from "react-router-dom"; -import { Redirect } from 'react-router'; -import AccountProfile from"../user/AccountProfile"; -import PropTypes from 'prop-types'; -import Certifiedprofessional from "../../modules/modals/Certifiedprofessional" - -// import searchImg from '../../../../images/educoder/icon/search.svg' - -// /images/educoder/icon/search.svg - -import { getImageUrl, toPath ,trigger,broadcastChannelPostMessage} from 'educoder' - -import axios from 'axios'; - -import { Modal,Checkbox ,Radio,Input,message,notification } from 'antd'; - -import Addcourses from '../courses/coursesPublic/Addcourses'; - -import LoginDialog from '../login/LoginDialog'; - -import Trialapplication from '../login/Trialapplication' - -import 'antd/lib/modal/style/index.css'; - -import 'antd/lib/checkbox/style/index.css'; - -import 'antd/lib/radio/style/index.css'; - -import 'antd/lib/input/style/index.css'; - -import './TPMIndex.css'; - -const $ = window.$ -// TODO 这部分脚本从公共脚本中直接调用 - -const RadioGroup = Radio.Group; -const { Search } = Input; -let old_url; - -/* - _logined_header.html.erb - _unlogin_header.html.erb -*/ -window._header_componentHandler = null; -class NewHeader extends Component { - constructor(props) { - super(props) - this.state={ - Addcoursestypes:false, - tojoinitemtype:false, - tojoinclasstitle:undefined, - rolearr:["",""], - Checkboxteacherchecked:false, - Checkboxstudentchecked:false, - Checkboxteachingchecked:false, - Checkboxteachertype:false, - Checkboxteachingtype:false, - code_notice:false, - checked_notice:false, - RadioGroupvalue:undefined, - submitapplications:false, - isRender:false, - showSearchOpentype:false, - showTrial:false, - setevaluatinghides:false, - occupation:0, - mydisplay:false, - headtypesonClickbool:false, - headtypess:"/", - mygetHelmetapi2: null, - } - console.log("176") - // console.log(props); - // console.log("NewHeader1234567890"); - // console.log(this.props); - } - componentDidUpdate = (prevProps) => { - // console.log("componentDidMount2"); - // console.log(this.state.mygetHelmetapi2); - if(this.state.mygetHelmetapi2===undefined){ - this.getAppdata(); - } - } - componentDidMount() { - console.log("componentDidMount1"); - this.getAppdata(); - window._header_componentHandler = this; - - //下拉框的显示隐藏 - var hoverTimeout; - var hoveredPanel; - $(".edu-menu-panel").hover(function(){ - if (hoverTimeout) { // 一次只显示一个panel - if (hoveredPanel && hoveredPanel != this) { - $(hoveredPanel).find(".edu-menu-list").hide() - } - clearTimeout(hoverTimeout); - hoverTimeout = null; - } - hoveredPanel = this; - $(this).find(".edu-menu-list").show(); - },function(){ - var that =this; - // 延迟hide - hoverTimeout = setTimeout(function() { - $(that).find(".edu-menu-list").hide(); - }, 800) - - }); - - //获取游览器地址 - try { - window.sessionStorage.setItem("yslgeturls", JSON.stringify(window.location.href)) - } catch (e) { - - } - // axios.interceptors.response.use((response) => { - // if (response != undefined) - // if (response && response.data.status === -1) { - // if (response.data.message === "该课堂要求成员完成实名认证") { - // - // } else if (response.data.message === "该课堂要求成员完成职业认证") { - // console.log("该课堂要求成员完成职业认证"); - // this.HideAddcoursestypess(2); - // - // - // - // return - // } else if (response.data.message === "该课堂要求成员完成实名和职业认证") { - // console.log("该课堂要求成员完成实名和职业认证"); - // this.HideAddcoursestypess(3); - // return - // - // } - // } - // return response; - // }, (error) => { - // - // }); - } - - componentDidUpdate = (prevProps) => { - // if(prevProps.user!=this.props.user){ - // // console.log("216") - // // console.log(prevProps.user); - // // console.log(this.props.user); - // if(this.props.user !== undefined){ - // this.setState({ - // user_phone_binded :this.props.user.user_phone_binded, - // }) - // } - // - // - // } - } - - openNotification = (messge) => { - notification.open({ - message: "提示", - description: - messge, - }); - }; - - componentWillReceiveProps(newProps, oldProps) { - this.setState({ - user:newProps.user - }) - if(newProps.Headertop!=undefined){ - old_url=newProps.Headertop.old_url - } - - } - getCookie=(key)=>{ - var arr,reg = RegExp('(^| )'+key+'=([^;]+)(;|$)'); - if (arr = document.cookie.match(reg)) //["username=liuwei;", "", "liuwei", ";"] - return decodeURIComponent(arr[2]); - else - return null; - } - - delCookie=(name)=>{ - var exp = new Date(); - exp.setTime(exp.getTime() - 1); - var cval=this.getCookie(name); - if(cval!=null){ - document.cookie= name + "="+cval+";expires="+exp.toGMTString(); - } - } - onLogout = () => { - const url = `/accounts/logout.json` - this.delCookie("autologin_trustie") - axios.get(url, { - }) - .then((response) => { - if(response.data.status===1){ - this.setState({ - user:undefined - }) - // let path="/"; - // this.props.history.push(path); - // broadcastChannelPostMessage('refreshPage') - window.location.href ="/login" - message.success('退出成功'); - } - }); - } - - tojoinclass=()=>{ - let{user} =this.state; - if(user===undefined){ - this.setState({ - isRender:true - }) - return - } - if(user&&user.login===""){ - this.setState({ - isRender:true - }) - return; - } - - if(user&&user.profile_completed===false){ - this.setState({ - AccountProfiletype:true - }) - return; - } - - this.setState({ - Addcoursestypes:true, - }) - } - - tojoinitem=()=>{ - if(this.props.user&&this.props.user.email===undefined||this.props.user&&this.props.user.email===null||this.props.user&&this.props.user.email===""){ - this.openNotification("请先绑定邮箱,谢谢"); - return - } - let{user} =this.state; - if(user===undefined){ - this.setState({ - isRender:true - }) - return - } - if(user&&user.login===""){ - this.setState({ - isRender:true - }) - return; - } - - if(user&&user.profile_completed===false){ - this.setState({ - AccountProfiletype:true - }) - return; - } - - this.setState({ - tojoinitemtype:true - }) - } - - - submitstatevalue=(sum,value,data)=>{ - this.setState({ - Addcoursestypes:false, - tojoinitemtype:false, - tojoinclasstitle:undefined, - rolearr:["",""], - Checkboxteacherchecked:false, - Checkboxstudentchecked:false, - Checkboxteachingchecked:false, - Checkboxteachertype:false, - Checkboxteachingtype:false, - code_notice:false, - checked_notice:false, - submitapplicationssum:sum, - submitapplications:true, - submitapplicationsvalue:value, - submitapplicationsvaluedata:data, - RadioGroupvalue:undefined - }) - } - - onChangeRadioGroup = (e) => { - this.setState({ - RadioGroupvalue: e.target.value, - }); - } - - submitsubmitapplications=()=>{ - let { - submitapplicationssum, - submitapplicationsvaluedata - }=this.state; - this.setState({ - submitapplications:false, - RadioGroupvalue:undefined - }) - if(submitapplicationssum===0){ - if(submitapplicationsvaluedata!=undefined){ - window.location.href = "/courses/"+submitapplicationsvaluedata; - } - }else if(submitapplicationssum===1){ - if(submitapplicationsvaluedata!=undefined){ - window.location.href = "/projects/"+submitapplicationsvaluedata; - } - } - } - - hidesubmitapplications=()=>{ - this.setState({ - Addcoursestypes:false, - tojoinitemtype:false, - tojoinclasstitle:undefined, - rolearr:["",""], - Checkboxteacherchecked:false, - Checkboxstudentchecked:false, - Checkboxteachingchecked:false, - Checkboxteachertype:false, - Checkboxteachingtype:false, - code_notice:false, - checked_notice:false, - submitapplications:false, - RadioGroupvalue:undefined - }) - } - educoderlogin=()=>{ - //登录账号 - this.setState({ - isRender:true - }) - // var url = `/accounts/logout.json`; - // - // axios.get((url)).then((result) => { - // if(result!==undefined){ - // // this.setState({ - // // isRender:true - // // }) - // window.location.href = "/"; - // } - // }).catch((error) => { - // console.log(error); - // }) - } - educoderloginysl=()=>{ - //退出账号 - // this.setState({ - // isRender:true - // }) - var url = `/accounts/logout.json`; - - axios.get((url)).then((result) => { - if(result!==undefined){ - // this.setState({ - // isRender:true - // }) - // broadcastChannelPostMessage('refreshPage') - window.location.href = "/"; - } - }).catch((error) => { - console.log(error); - }) - } - - hideAddcoursestypes=()=>{ - this.setState({ - Addcoursestypes:false - }) - }; - HideAddcoursestypess=(i)=>{ - console.log("调用了"); - this.setState({ - Addcoursestypes:false, - mydisplay:true, - occupation:i, - }) - }; - ModalCancelsy=()=>{ - this.setState({ - mydisplay:false, - }) - }; - - - hidetojoinclass=()=>{ - this.setState({ - tojoinclasstype:false, - tojoinitemtype:false, - tojoinclasstitle:undefined, - rolearr:["",""], - Checkboxteacherchecked:false, - Checkboxstudentchecked:false, - Checkboxteachingchecked:false, - Checkboxteachertype:false, - Checkboxteachingtype:false, - code_notice:false, - checked_notice:false, - RadioGroupvalue:undefined - }) - } - -submittojoinclass=(value)=>{ - let {tojoinclasstitle,rolearr,RadioGroupvalue}=this.state; - - if(tojoinclasstitle===undefined){ - this.setState({ - code_notice:true - }) - return - } - let newrolearr=rolearr; - // if(value===1){ - if(tojoinclasstitle.length<6){ - this.setState({ - code_notice:true - }) - return - } - // }else if(value===0){ - // if(tojoinclasstitle.length<5){ - // this.setState({ - // code_notice:true - // }) - // return - // } - // } - if(tojoinclasstitle===""||tojoinclasstitle===undefined){ - this.setState({ - code_notice:true - }) - return - }else{ - this.setState({ - code_notice:false - }) - } - - let pamst=[]; - let num=0; - for(var i = 0 ; i { - // if( response.data.state===0){ - // this.submitstatevalue(0,"加入成功",response.data.course_id) - // }else if( response.data.state===1){ - // }else if( response.data.state===2){ - // this.submitstatevalue( 0,"课堂已过期! 请联系课堂管理员重启课堂。(在配置课堂处)") - // }else if( response.data.state===3){ - // this.submitstatevalue( 0,"您已是课堂成员)",response.data.course_id) - // }else if( response.data.state===4){ - // this.submitstatevalue( 0,"您输入的邀请码错误)") - // }else if( response.data.state===5){ - // this.submitstatevalue( 0,"您还未登录") - // }else if( response.data.state===6){ - // this.submitstatevalue( 0,"申请已提交,请等待审核") - // }else if( response.data.state===7){ - // this.submitstatevalue( 0," 您已经发送过申请了,请耐心等待") - // }else if( response.data.state===8){ - // this.submitstatevalue( 0,"您已经是该课堂的教师了",response.data.course_id) - // }else if( response.data.state==9){ - // this.submitstatevalue( 0,"您已经是该课堂的教辅了",response.data.course_id) - // }else if( response.data.state==10){ - // this.submitstatevalue(0,"您已经是该课堂的管理员了",response.data.course_id) - // }else if( response.data.state==11){ - // this.submitstatevalue(0," 该课堂已归档,请联系老师") - // }else if( response.data.state==12){ - // this.submitstatevalue(0,"您已经发送过申请了,请耐心等待师") - // }else if( response.data.state==13){ - // this.submitstatevalue(0,"您申请已提交,请等待审核") - // }else if( response.data.state==14){ - // this.submitstatevalue("此邀请码已停用,请与老师联系") - // }else if( response.data.state==15){ - // this.submitstatevalue(0,"您已是课堂成员! 加入分班请在课堂具体分班页面进行") - // }else { - // this.submitstatevalue(0," 未知错误,请稍后再试") - // } - // }) - // - // } - - if(value===1){ - let url="/project_applies.json" - // const form = new FormData(); - // form.append('code', tojoinclasstitle); - // form.append('role', RadioGroupvalue); - // form.append('type', 1); - axios.post(url,{ - code:tojoinclasstitle, - role:RadioGroupvalue - } - ).then((response) => { - if( response.data.status===1){ - this.submitstatevalue(1,"您输入的邀请码错误") - }else if( response.data.status===2){ - this.submitstatevalue( 1,"您已经是该项目成员",response.data.project) - }else if( response.data.status===3){ - this.submitstatevalue( 1,"请选择一个角色") - }else if( response.data.status===4){ - this.submitstatevalue( 1,"您的申请已提交,请等待项目管理员审批") - }else if( response.data.status===5){ - this.submitstatevalue( 1,"您已经申请加入该项目了,请耐心等待") - }else if( response.data.status===6){ - this.submitstatevalue( 1,"您已成功加入项目",response.data.project) - }else if( response.data.status===0){ - if(RadioGroupvalue==="reporter"){ - this.openNotification("您加入项目成功!"); - window.location.href=`/projects/${response.data.project_id}`; - }else{ - this.openNotification("您的申请已提交,请等待项目管理员审批!"); - } - } - }) - } - this.hidetojoinclass() -} - - // trialapplications =()=>{ - // console.log("点击了") - // this.setState({ - // isRenders: true, - // showTrial:true, - // }) - // } - - // 关闭 - cancelModulationModels = () => { - this.setState({isRenders: false}) - } - - inputjoinclassvalue=(e)=>{ - console.log(e.target.value.length); - if(e.target.value.length>=7){ - this.openNotification("请输入6位项目邀请码!"); - return - } - this.setState({ - tojoinclasstitle:e.target.value - }) - } - - showSearchOpen=(e)=>{ - this.setState({ - showSearchOpentype:true - }) - - } - - hideshowSearchOpen=(e)=>{ - let {setevaluatinghides}=this.state; - if(setevaluatinghides===true){ - this.setState({ - showSearchOpentype:false, - setevaluatinghides:false - }) - - } - } - - onKeywordSearchKeyDown = (value) => { - let url=`/search?value=${value}`; - this.props.history.push(url) - } - - onKeywordSearchKeyDowns=()=>{ - this.setState( - { - setevaluatinghides:false - } - ) - } - - setevaluatinghides=()=>{ - this.setState( - { - setevaluatinghides:true - } - ) - } - //头部获取是否已经登录了 - getUser=(url,type)=>{ - - if(type==="projects"){ - if(this.props.user&&this.props.user.email===undefined||this.props.user&&this.props.user.email===null||this.props.user&&this.props.user.email===""){ - this.openNotification("请先绑定邮箱,谢谢"); - return - } - } - // console.log("点击了503") - // console.log(url); - let{user} =this.state; - - if(user===undefined){ - this.setState({ - isRender:true - }) - return - } - - if(user&&user.login===""){ - this.setState({ - isRender:true - }) - return; - } - - if(user&&user.profile_completed===false){ - this.setState({ - AccountProfiletype:true - }) - return; - } - - if(url !== undefined || url!==""){ - window.location.href = url; - } - - - } - - //修改登录方法 - Modifyloginvalue=()=>{ - this.setState({ - isRender:false, - }) - } - - hideAccountProfile=()=>{ - this.setState({ - AccountProfiletype:false - }) - }; - headtypesonClick=(url,bool)=>{ - this.setState({ - headtypess:url, - headtypesonClickbool:bool, - }) - } - //获取数据为空的时候 - gettablogourlnull = () => { - this.setState({ - mygetHelmetapi2: undefined - }); - document.title = "EduCoder"; - var link = document.createElement('link'), - oldLink = document.getElementById('dynamic-favicon'); - link.id = 'dynamic-favicon'; - link.rel = 'shortcut icon'; - link.href = "/react/build/./favicon.ico"; - if (oldLink) { - document.head.removeChild(oldLink); - } - document.head.appendChild(link); - }; - - //获取数据的时候 - gettablogourldata = (response) => { - document.title = response.data.setting.name; - var link = document.createElement('link'), - oldLink = document.getElementById('dynamic-favicon'); - link.id = 'dynamic-favicon'; - link.rel = 'shortcut icon'; - link.href = '/' + response.data.setting.tab_logo_url; - if (oldLink) { - document.head.removeChild(oldLink); - } - document.head.appendChild(link); - } - - getAppdata=()=>{ - let url = "/setting.json"; - axios.get(url).then((response) => { - // console.log("app.js开始请求/setting.json"); - // console.log("获取当前定制信息"); - if(response){ - if(response.data){ - this.setState({ - mygetHelmetapi2:response.data.setting - }); - try { - if (response.data.setting.tab_logo_url) { - this.gettablogourldata(response); - } else { - this.gettablogourlnull(); - } - } catch (e) { - this.gettablogourlnull(); - } - - - } else { - - this.gettablogourlnull(); - - } - - } else { - this.gettablogourlnull(); - - } - - }).catch((error) => { - this.gettablogourlnull(); - - }); - }; - render() { - const isLogin = true; // 这里不会出现未登录的情况,服务端在服务端路由时发现如果是未登录,则跳转到登录页了。 - const {match,} = this.props; - - let {Addcoursestypes, - tojoinitemtype, - tojoinclasstitle, - Checkboxteacherchecked, - Checkboxstudentchecked, - Checkboxteachingchecked, - Checkboxteachertype, - Checkboxteachingtype, - code_notice, - checked_notice, - AccountProfiletype, - submitapplications, - submitapplicationsvalue, - user, - isRender, - showSearchOpentype, - headtypesonClickbool, - headtypess, - mygetHelmetapi2, - }=this.state; - /* - 用户名称 用户头像url - */ - let activeIndex = false; - let activeForums = false; - let activeShixuns = false; - let activePaths = false; - let coursestype=false; - let activePackages=false; - let activeMoopCases=false; - - - if (match.path === '/forums') { - activeForums = true; - } else if (match.path.startsWith('/shixuns')) { - activeShixuns = true; - }else if (match.path.startsWith('/paths')) { - activePaths = true; - } else if (match.path.startsWith('/courses')) { - coursestype = true; - }else if (match.path.startsWith('/crowdsourcing')) { - activePackages = true; - }else if(match.path.startsWith('/moop_cases')){ - activeMoopCases = true; - }else { - activeIndex = true; - } - - let headtypes='/'; - - // console.log("mygetHelmetapi2"); - // console.log(mygetHelmetapi2); - if(mygetHelmetapi2){ - if(mygetHelmetapi2.navbar){ - if(mygetHelmetapi2.navbar.length>0){ - // console.log("mygetHelmetapi2.navbar.length>0====-=-=--=-=-=-="); - // - // console.log(match.path); - if(match.path==='/'){ - if(headtypesonClickbool===false){ - headtypes=undefined; - }else{ - headtypes=headtypess; - } - - }else { - const developer = { - name: '开发者社区', - link: '/developer', - hidden: false - }; - mygetHelmetapi2.navbar.push(developer); - for(var i=0;i{ - var reg = RegExp(item.link); - if(shixun.match(reg)){ - if(item.hidden===true){ - shixuntype=true - } - } - if(paths.match(reg)){ - if(item.hidden===true){ - pathstype=true - } - } - if(courses.match(reg)){ - if(item.hidden===true){ - coursestypes=true - } - } - }) - } - return ( - -
    - - {isRender===true?this.Modifyloginvalue()} - {...this.props} - {...this.state} - />:""} - - {AccountProfiletype===true?this.hideAccountProfile()} - {...this.props} - {...this.state} - />:""} - this.headtypesonClick("/",false)} className={"fl mr30 ml25 mt10"}> - { - mygetHelmetapi2 === null ? - "" - : - mygetHelmetapi2===undefined||mygetHelmetapi2.nav_logo_url===null||mygetHelmetapi2.nav_logo_url===undefined? - 高校智能化教学与实训平台 - : - 高校智能化教学与实训平台 - } - - - - { - mygetHelmetapi2 === null ? - "" : - mygetHelmetapi2!==undefined&&mygetHelmetapi2.navbar!==null&&mygetHelmetapi2.navbar!==undefined&&mygetHelmetapi2.navbar.length>0? -
    -
      - {/*
    • 首页
    • */} - {/*
    • 实训路径
    • */} - { - mygetHelmetapi2.navbar && mygetHelmetapi2.navbar.map((item,key)=>{ - // console.log("headtypes"); - // console.log(headtypes);hidden - var str=new RegExp("http"); - var strbool=false; - //test方法返回值为(true或者false) - if(item.link){ - if(str.test(item.link)===true){ - strbool=true - }else{ - strbool=false - } - } - // console.log(item.hidden); - return( -
    • this.headtypesonClick(item.link,true)} className={`${headtypes===undefined?'pr':headtypes===item.link?'pr active':'pr'}`} style={item.hidden==false?{display: 'block'}:{display: 'none'}}> - { - strbool===true? - {item.name} - : - {item.name} - } -
    • - ) - }) - } - {/*
    • */} - {/* 实践课程*/} - {/*
    • */} - - {/*
    • 课堂
    • */} - {/*
    • */} - {/* /!*课堂*!/*/} - {/* 翻转课堂*/} - {/*
    • */} - - {/*
    • */} - {/* 实训项目*/} - {/* */} - {/* */} - {/*
    • */} - - - {/*
    • 教学案例
    • */} - {/*
    • */} - {/* 在线竞赛*/} - {/* */} - {/*
    • */} - {/*
    • 教学案例
    • */} - {/*
    • */} - {/*众包创新*/} - {/*
    • */} - {/*
    • 交流问答
    • */} -
    • 工程认证
    • - -
    • 0 ? 'block' : 'none'}}> - 职业路径 -
      0 ? 'block' : 'none'}}> -
        - {this.props.Headertop === undefined ? "" : this.props.Headertop.career_url.map((item, key) => { - return( -
      • {item.name}
      • - ) - }) - } -
      -
      -
    • -
    -
    - // :mygetHelmetapi2===undefined||mygetHelmetapi2.navbar===null||mygetHelmetapi2.navbar===undefined||mygetHelmetapi2.navbar.length===0? - //
    - // - //
      - // {/*
    • 首页
    • */} - // - // {/*
    • 实训路径
    • */} - //
    • - // 实践课程 - //
    • - // - // {/*
    • 课堂
    • */} - //
    • - // {/*课堂*/} - // 翻转课堂 - //
    • - // - //
    • - // 实训项目 - // {/**/} - // {/**/} - //
    • - // - //
    • 0 ? 'block' : 'none'}}> - // 职业路径 - //
      0 ? 'block' : 'none'}}> - //
        - // {this.props.Headertop === undefined ? "" : this.props.Headertop.career_url.map((item, key) => { - // return( - //
      • {item.name}
      • - // ) - // }) - // } - //
      - //
      - //
    • - // - // {/*
    • 教学案例
    • */} - //
    • - // 在线竞赛 - // {/**/} - //
    • - //
    • 教学案例
    • - // {/*
    • */} - // {/*众包创新*/} - // {/*
    • */} - //
    • 交流问答
    • - //
    • 工程认证
    • - //
    - //
    - : -
    - -
      - {/*
    • 首页
    • */} - - {/*
    • 实训路径
    • */} -
    • - 实践课程 -
    • - - {/*
    • 课堂
    • */} -
    • - {/*课堂*/} - 翻转课堂 -
    • - -
    • - 实训项目 - {/**/} - {/**/} -
    • - -
    • 0 ? 'block' : 'none'}}> - 职业路径 -
      0 ? 'block' : 'none'}}> -
        - {this.props.Headertop === undefined ? "" : this.props.Headertop.career_url.map((item, key) => { - return( -
      • {item.name}
      • - ) - }) - } -
      -
      -
    • - - {/*
    • 教学案例
    • */} -
    • - 在线竞赛 - {/**/} -
    • -
    • 教学案例
    • - {/*
    • */} - {/*众包创新*/} - {/*
    • */} -
    • 交流问答
    • -
    • 工程认证
    • -
    -
    - } - - - - - - - -
    -
    - {/**/} -
    - - 实训 - - -
    - {/**/} - {/*搜索框*/} - {showSearchOpentype===true?
    this.hideshowSearchOpen(e)} onMouseLeave={()=>this.setevaluatinghides()}> - this.onKeywordSearchKeyDowns()} - onSearch={(value) => this.onKeywordSearchKeyDown(value)} - // onPressEnter={this.onKeywordSearchKeyDown} - style={{ width: 300,height:32}} - autoFocus={true} - /> -
    :""} - - {/**/} - {/*/!**!/*/} - {/**/} - - {/**/} - {/* TODO 需要服务端接口提供最近搜索 -
    -
    最近搜索
    - - -
    */} -
    -
    - - {/* - <%= link_to '登录', signin_path, :className => "mr5" %> - - <%= link_to '注册', user_join_path, :className => "ml5" %> - */} - { user===undefined? - - this.educoderlogin()} className="mr5 color-white">登录 - - 注册 - :user.login===""? - this.educoderlogin()} className="mr5 color-white">登录 - - 注册 - : -
    - - - - - -
    - } - {/*href="https://www.educoder.net/login"*/} -
    - {/*{ loadHeader()}*/} - {showSearchOpentype===true?"":this.props.user&&this.props.user.main_site===true?this.showSearchOpen(e)}> - {/*"/images/educoder/icon/search.svg" - */} - - - :""} - - {/*
    */} -
    - - - - -
    -
    - - {coursestypes===true&&this.props.user&&this.props.user.main_site===false?"":} -
    -
    - - {this.props.user&&this.props.user.main_site===true? :""} - - -
    -
    -
      -
      -

      - {submitapplicationsvalue} -

      -
      -
    • - 取消 - 确定 -
    • - -
    -
    -
    -
    - -
    - -
    - - ); - } -} - -export default NewHeader; - diff --git a/public/react/src/tpm/SiderBar.js b/public/react/src/tpm/SiderBar.js deleted file mode 100644 index 9312b24fd..000000000 --- a/public/react/src/tpm/SiderBar.js +++ /dev/null @@ -1,143 +0,0 @@ -import React, { Component } from 'react'; -import { getImageUrl} from 'educoder'; -import './TPMIndex.css'; - -const $ = window.$; - -$(window).resize(function(){ - rightSlider(); -}); - -$(window).scroll(function(){ - if($(".gotop").length>0){ - if($(document).scrollTop()>0){ - $(".-task-sidebar .gotop").show(); - $(".gotop").click(function(){ - $("html,body").scrollTop(0); - }); - } - if($(document).scrollTop()==0){ - $(".-task-sidebar .gotop").hide(); - } - } -}); - -function rightSlider(){ - var poi=parseInt((parseInt($(window).width())- 1200 )/2)-81; - // console.log(parseInt($(window).width())+" "+poi); - if(poi>0){ - $(".-task-sidebar").css("right",poi); - }else{ - $(".-task-sidebar").css("right","0px"); - } - $(".-task-sidebar").show(); -} - - -function _initSider() { - var $descSide = $("
    ").appendTo("body"); - $(".-task-sidebar>div").hover(function(){ - //移入显示二维码 - if($(this).hasClass("scan")){ - $(".scan_ewm").show().css({right:"75px",opacity:0}).stop().animate({ - right:"45px",opacity:1 - }) - return; - } - var $tool = $(this).attr("tooltips"); - $descSide.html($tool+"
    "); - $descSide.data('_dom', this) - $descSide.show().css({ - left:$(this).offset().left - $descSide.width()-30, - opacity:0, - top:$(this).offset().top - }).stop().animate({ - left:$(this).offset().left - $descSide.width()-5, - opacity:1 - },400); - },function(){ - if($(this).hasClass("scan")){ - $(".scan_ewm").stop().animate({right:"75px",opacity:0},200).hide(); - } - $descSide.stop().animate({ - left:$(this).offset().left - $descSide.width()-30, - opacity:0 - },200).hide(); - }); - rightSlider(); - - $(window).scroll(function() { - if ($descSide.height()) { - var hoverIcon = $descSide.data('_dom') - $descSide.css('top', $(hoverIcon).offset().top) - } - }) -} - -class SiderBar extends Component { - constructor(props) { - super(props) - - } - - componentDidMount() { - _initSider(); - - } - - render() { - - // console.log(this.props) - return ( - -
    - {this.props.mygetHelmetapi&&this.props.mygetHelmetapi.main_site===true?
    -
    - - - -
    - -
    - - - -
    - - - -
    - -

    -

    - - -

    微信扫一扫

    -

    关注公众号

    - -

    -

    -
    - -
    - - - -
    -
    :""} - - -
    - ); - } -} - -export default SiderBar; diff --git a/public/react/src/tpm/TPMBanner.js b/public/react/src/tpm/TPMBanner.js deleted file mode 100644 index b660001c6..000000000 --- a/public/react/src/tpm/TPMBanner.js +++ /dev/null @@ -1,1056 +0,0 @@ -import React, { Component } from 'react'; - -import { Redirect } from 'react-router'; - -import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import { Rating ,Progress} from "@icedesign/base"; - -import {Modal,Input,Radio,Pagination,message,Spin,Icon,Tooltip,Rate} from 'antd'; - -import AccountProfile from"../user/AccountProfile"; - -import 'antd/lib/pagination/style/index.css'; - -import axios from 'axios' - -import Modals from '../modals/Modals'; - -import './shixuns/css/TPMBanner.css'; - -let $ = window.$; - -const Search = Input.Search; - -const RadioGroup = Radio.Group; - -class TPMBanner extends Component { - constructor(props) { - super(props) - this.state={ - Forkvisible: false, - Senttothetype:false, - Senttothevcalue:undefined, - courses_count:1, - course_list:[], - pagenum:1, - publishbox:"", - publishboxstatus:0, - pages:1, - Issuevisible:false, - evaluation_set_position:[], - tag_position:[], - Forkauthentication:false, - can_fork:undefined, - certi_url:undefined, - showradios:false, - startbtn:false, - Searchvalue:"", - startshixunCombattype:false, - shixunsmessage:"", - shixunsreplace:false, - hidestartshixunsreplacevalue:"", - isIE:false, - Forkvisibletype: false, - isSpin:false, - Senttothevcaluetype:false - } - } - - // star_info:[0, 0, 0, 0, 0, 0], - // star_infos:[0, 0, 0, 0, 0, 0], - // shixunsDetails:{}, - // shixunId: undefined, - // componentWillReceiveProps(newProps, newContext){ - // this.setState({ - // shixunsDetails: newProps.shixunsDetails - // }); - // } - - IEVersion=()=>{ - var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串 - var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器 - var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //判断是否IE的Edge浏览器 - var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1; - if(isIE) { - var reIE = new RegExp("MSIE (\\d+\\.\\d+);"); - reIE.test(userAgent); - var fIEVersion = parseFloat(RegExp["$1"]); - if(fIEVersion == 7) { - return 7; - } else if(fIEVersion == 8) { - return 8; - } else if(fIEVersion == 9) { - return 9; - } else if(fIEVersion == 10) { - return 10; - } else { - return 6;//IE版本<=7 - } - } else if(isEdge) { - return 'edge';//edge - } else if(isIE11) { - return 11; //IE11 - }else{ - return -1;//不是ie浏览器 - } - } - componentDidMount() { - let thiisie=this.IEVersion(); - if(thiisie!=-1){ - this.setState({ - isIE:true - }) - }else{ - this.setState({ - isIE:false - }) - } - } - /* - * Fork - * */ - copyForkvisible = () => { - let {shixunsDetails} = this.props; - if (shixunsDetails.can_fork === null) { - this.setState({ - Forkvisible: true - }) - } else { - this.setState({ - Forkvisible: false, - Forkauthentication: true, - can_fork: shixunsDetails.can_fork.can_fork, - certi_url: shixunsDetails.can_fork.certi_url, - }) - } - - } - - hideForkvisible = () => { - this.setState({ - Forkvisible: false, - Forkauthentication:false - }) - } - - addForkvisible = () => { - this.setState({ - Forkvisibletype: true, - }) - let id = this.props.match.params.shixunId; - let url = "/shixuns/" + id + "/copy.json"; - axios.post(url).then((response) => { - if(response.data.status===401){ - - }else{ - this.setState({ - Forkvisible: false, - Forkauthentication: false, - // Forkvisibletype:false - }) - window.location.href = "/shixuns/" + response.data.shixun + "/challenges"; - } - - }).catch((error) => { - console.log(error) - }); - - } - /* - * 发送至按钮 - * */ - Senttothe=()=>{ - if(this.props.checkIfLogin()===false){ - this.props.showLoginDialog() - return - } - - // if(this.props.checkIfProfileCompleted()===false){ - // this.setState({ - // AccountProfiletype:true - // }) - // return - // } - // - // if(this.props.checkIfProfessionalCertification()===false){ - // this.setState({ - // AccountProfiletype:true - // }) - // return - // } - let id = this.props.match.params.shixunId; - let url="/shixuns/" + id +"/search_user_courses.json"; - this.setState({ - Senttothetype:true - }) - - axios.get(url, { - params: { - page:1, - limit:10 - }}).then((response) => { - this.setState({ - courses_count:response.data.courses_count, - course_list:response.data.course_list - }) - }).catch((error) => { - console.log(error) - }); - } - - SenttotheSearch=(value)=>{ - let id = this.props.match.params.shixunId; - let url="/shixuns/" + id +"/search_user_courses.json?search="+value; - axios.get(encodeURI(url), { - params: { - page:1, - limit:10 - }}).then((response) => { - this.setState({ - courses_count:response.data.courses_count, - course_list:response.data.course_list, - pages:1, - Searchvalue:value - }) - }).catch((error) => { - console.log(error) - }); - } - - onChangeSenttothevcalue=(e)=>{ - this.setState({ - Senttothevcalue:e.target.value - }) - } - onChangesendeSenttothe=(pageNumber)=>{ - let{Searchvalue}=this.state; - let id = this.props.match.params.shixunId; - let url="/shixuns/" + id +"/search_user_courses.json?search="+Searchvalue; - axios.get(url, { - params: { - page:pageNumber, - limit:10 - }}).then((response) => { - this.setState({ - courses_count:response.data.courses_count, - course_list:response.data.course_list, - pagenum: pageNumber, - pages: pageNumber - }) - }).catch((error) => { - console.log(error) - }); - } - sendeSenttothevcalue=()=>{ - - let {Senttothevcalue}=this.state; - - if(Senttothevcalue===undefined){ - this.setState({ - Senttothevcaluetype:true - }) - return - } - let id = this.props.match.params.shixunId; - let url="/shixuns/" + id +"/send_to_course.json"; - axios.post(url,{ - course_id:Senttothevcalue - }).then((response) => { - - this.props.showSnackbar(response.data.message); - this.setState({ - Senttothetype:false, - Searchvalue:"", - pages:1 - }) - // window.location.href = response.data.url; - // response.data.course_id - this.props.history.replace(response.data.first_category_url); - - }).catch((error) => { - console.log(error) - }); - - } - - hideSenttothevcalue=()=>{ - this.setState({ - Senttothetype:false, - Searchvalue:"", - pages:1 - }) - - - } - - /* - * 撤销发布按钮 - * */ - - ModalCancel=()=>{ - this.setState({ - Modalstype:false - }) - } - ModalSave=()=>{ - let id = this.props.match.params.shixunId; - let url="/shixuns/" + id +"/cancel_publish.json"; - axios.get(url).then((response) => { - this.props.showSnackbar(response.data.message); - window.location.reload() - }).catch((error) => { - console.log(error) - }); - } - cancel_publish=()=>{ - this.setState({ - Modalstype:true, - Modalstopval:"是否确认撤销发布?", - ModalCancel:this.ModalCancel, - ModalSave:this.ModalSave, - }) - } - - - /* - * 申请发布按钮 - * */ - applyrelease=()=>{ - let id = this.props.match.params.shixunId; - let url="/shixuns/" + id +"/publish.json"; - axios.get(url).then((response) => { - let evaluation_set_position - if(response.data.evaluation_set_position===null){ - evaluation_set_position=[] - }else{ - evaluation_set_position=response.data.evaluation_set_position - } - this.setState({ - Issuevisible:true, - tag_position:response.data.tag_position, - evaluation_set_position:evaluation_set_position, - publishboxstatus:response.data.status, - }) - }).catch((error) => { - console.log(error) - }); - }; - - hiddenIssuevisible=(val)=>{ - this.setState({ - Issuevisible:false - }) - if(val===0||val===1){ - window.location.reload() - } - - } - - //重置按钮 - // resetshixunCombat=(id)=>{ - // let zrl="/myshixuns/"+id+"/reset_my_game.json"; - // axios.get(zrl).then((response) => { - // window.location.href = "/shixuns/" + response.data.shixun_identifier + "/challenges"; - // message.success('重置成功'); - // }).catch((error) => { - // console.log(error) - // }); - // } - - // reset_my_game - hidestartshixunsreplace=(url)=>{ - this.setState({ - isSpin:true, - }) - axios.get(url).then((response) => { - if(response.status===200){ - // let path="/shixuns/"+response.data.shixun_identifier+"/challenges"; - // this.props.history.push(path); - message.success('重置成功,正在进入实训!'); - this.startshixunCombat(response.data.shixun_identifier, 1); - this.setState({ - shixunsreplace:false, - isSpin:false, - }) - - // message.success('重置成功,正在进入实训!'); - // this.startshixunCombat(); - }} - ).catch((error) => { - this.setState({ - startbtn:false, - shixunsreplace:false, - isSpin:false - }) - }); - - } - - - //开始实战按钮 - startshixunCombat=(id, reset)=>{ - - if(this.props.checkIfLogin()===false){ - this.props.showLoginDialog() - return - } - - if(this.props.checkIfProfileCompleted()===false){ - this.setState({ - AccountProfiletype:true - }) - return - } - - // if(this.props.checkIfProfessionalCertification()===false){ - // this.setState({ - // AccountProfiletype:true - // }) - // return - // } - - let {shixunsDetails} = this.props - if( shixunsDetails.shixun_status>1){ - this.setState({ - startbtn:true, - hidestartshixunsreplacevalue:"" - }) - }else{ - this.setState({ - hidestartshixunsreplacevalue:"" - }) - } - - - let url="/shixuns/"+id+"/shixun_exec.json" ; - if (reset) { - url += '?reset=' + reset - } - axios.get(url).then((response) => { - if(response.status===200){ - if(response.data.status===-2){ - // this.resetshixunCombat(response.data.message); - this.setState({ - startbtn:false, - shixunsreplace:true, - hidestartshixunsreplacevalue:response.data.message+".json" - }) - // this.shixunexec(response.data.message+".json") - }else if(response.data.status===-1){ - console.log(response) - }else if(response.data.status===-3){ - this.setState({ - shixunsmessage:response.data.message, - startshixunCombattype:true, - startbtn:false - }) - }else{ - // let path="/tasks/"+response.data.game_identifier; - // this.props.history.push(path); - - - // this.context.router.history.push(path); - if(response.data.status!=401){ - window.location.href = "/tasks/"+response.data.game_identifier; - } - - } - } - }).catch((error) => { - this.setState({ - startbtn:false - }) - }); - } - - tocertification=()=>{ - let{certi_url}=this.state; - this.setState({ - Forkauthentication:false - }) - window.location.href=certi_url; - } - - SenttotheValue=(e)=>{ - this.setState({ - Searchvalue:e.target.value - }) - } - - hidestartshixunCombattype=()=>{ - this.setState({ - startshixunCombattype:false - }) - } - - hideAccountProfile=()=>{ - this.setState({ - AccountProfiletype:false - }) - } - - - showonMouseOver=()=>{ - $("#ratePanel").show(); - this.setState({ - showradios:true - }) - } - - hideonMouseOut=()=>{ - $("#ratePanel").hide(); - this.setState({ - showradios:false - }) - } - - render() { - let { - Forkvisible, - Senttothetype, - Senttothevcalue, - evaluation_set_position, - Forkauthentication, - can_fork, - certi_url, - tag_position, - courses_count, - course_list, - Issuevisible, - publishboxstatus, - showradios, - startbtn, - Searchvalue, - startshixunCombattype, - shixunsmessage, - pages, - shixunsreplace, - hidestartshixunsreplacevalue, - Forkvisibletype, - AccountProfiletype, - isIE} = this.state; - let {shixunsDetails, shixunId, star_info, star_infos} = this.props; - let challengeBtnTipText = ''; - let challengeBtnText = '模拟实战'; - // let star_info=[] - // if (shixunsDetails.status === 0) { - // - // } else if (shixunsDetails.status === 1) { - // - // } else if (shixunsDetails.status === 2) { - // challengeBtnTipText = '开始学习并完成实战任务' - // - // } - if(shixunsDetails!=undefined){ - if (shixunsDetails.shixun_status === 0 ) { - challengeBtnText = '继续实战' - } else if (shixunsDetails.shixun_status === 1) { - challengeBtnText = '查看实战' - } else if (shixunsDetails.shixun_status === 3) { - challengeBtnText = '继续实战' - }else{ - challengeBtnText = "开始实战" - } - } - - - // let list=shixunsDetails.task_operation; - // if(list!=undefined){ - // if (shixunsDetails.status === 0 ) { - // for(var i=0; i; - const MyRate = ({ defaultValue, ...rest }) => { - let myValue = defaultValue; - // console.log(myValue-Math.floor(myValue)) - // if (myValue < Math.ceil(myValue)) { - // myValue = Math.floor(myValue) + 0.5; - // } - - return ; - }; - return ( - - shixunsDetails===undefined?"": -
    -
    - - {AccountProfiletype===true?this.hideAccountProfile()} - {...this.props} - {...this.state} - />:""} - - - {this.state.Modalstype===true?:""} - -
    -

    - {shixunsDetails.name} - { - shixunsDetails.fork_from === undefined || shixunsDetails.fork_from === null ? "" : - - - - } - -

    -
    - {/**/} -
      -
    • - 学习人数 - {shixunsDetails.stu_num} -
    • - {/*
    • */} - {/*经验值*/} - {/*{shixunsDetails.experience}*/} - {/*
    • */} -
    • - 难度系数 - {shixunsDetails.diffcult} - -
    • -
    - -
    this.showonMouseOver()} onMouseOut={()=>this.hideonMouseOut()}> -
    学员评分
    -
    - -
    -
    this.hideonMouseOut()}> -
    - -
    -
    -
    - {star_infos[0]}分 - 总评分 -
    - {showradios === true ? - - : ""} -
    -
    -
    -
    -
    -
    - {showradios === true ? - - : ""} -
    - - {star_infos[1]}% -
    -
    -
    - {showradios === true ? - - : ""} -
    - - {star_infos[2]}% -
    -
    -
    - {showradios === true ? - - : ""} -
    - - {star_infos[3]}% -
    -
    -
    - {showradios === true ? - - : ""} -
    - - {star_infos[4]}% -
    -
    -
    - {showradios === true ? - - : ""} -
    - - {star_infos[5]}% -
    -
    -
    -
    -
    - -
    - - { - startbtn === false && shixunsDetails.shixun_status != -1 ? - - this.startshixunCombat(this.props.match.params.shixunId)} - className="fr user_default_btn task-btn-orange font-18" - id="shixun_operation" data-remote="true" - > - {shixunsDetails.task_operation === undefined ? "" : shixunsDetails.shixun_status > 1 ? shixunsDetails.task_operation[0] : "模拟实战"} - - - : "" - } - - -
    -

    目前该实训项目尚在内测中,将于{shixunsmessage}之后开放,谢谢!

    -
    -
    - {/*取消*/} - 知道啦 -
    - {/*

    */} - {/*知道了*/} - {/*

    */} -
    - - - -
    -

    实训已经更新了,正在为您重置!

    -
    - -
    -
    - - - - - - { - startbtn === true ? - 开启中 : "" - } - - {/*{*/} - {/*shixunsDetails.status=== 3 && shixunsDetails.task_operation[0]==="开始实战"?*/} - {/*{shixunsDetails.task_operation===undefined?"":shixunsDetails.task_operation[0]}:""*/} - {/*}*/} - - {shixunsDetails.shixun_status === 0 && this.props.identity < 5 ? - 申请发布 : "" - } - - - { - publishboxstatus === 0 ?
    -

    - 发布申请已提交,请等待管理员的审核
    -

    -
    : publishboxstatus === 1 ? -
    -

    - 发布申请已提交,请等待管理员的审核
    - • 我们将在1-2个工作日内完成审核 -

    -
    : publishboxstatus === 2 ?
    -

    - 第 - { - evaluation_set_position.map((item, key) => { - return ( - {item}, - ) - }) - } - 关评测设置尚未完成,无法申请发布 -

    -
    : publishboxstatus === 3 ? -
    -

    - 每一个关卡至少需要一个技能标签
    - 第 - { - tag_position.map((item, key) => { - return ( - {item}, - ) - }) - } - 关尚未设置技能标签,请补充 -

    -
    : -
    -

    - 尚未创建任务的实训,不能申请发布 -

    -
    - } - - -
    - - {shixunsDetails.shixun_status === 1 && this.props.identity < 5 ? - 撤销发布 : "" - } - - { - - - 发送至 - - - } - - -
    -
    - -
    - 选择的实训将会发送到指定课堂 -
    - -
    - this.SenttotheSearch(value)} - style={{width: '100%'}} - /> -
    - - -
    12?"cdefault ":"cdefault "}> -
    -
      - - { - course_list === undefined ? "" : course_list.map((item, key) => { - return ( - {item.name} - ) - }) - } - -
    -
    -
    - {this.state.Senttothevcaluetype===true?
    请选择你要发送的课堂
    :""} -
    12 ? "block" : "none"}}> - -
    - -
    -
    -
    -
    - 取消 - 确定 -
    - - -
    - -
    -
    -
    - - {shixunsDetails.shixun_status === 3 && - 已关闭 - } - - {shixunsDetails.shixun_status === -1 && - 已删除 - } - - - {this.props.identity < 8&&shixunsDetails.shixun_status != -1 ?
    - - - Fork - - - - - {Forkvisibletype===true? - - : -
    -

    复制将在后台执行,平台将为你创建
    一个新的同名实训和内容,请问是否继续?

    -
    -
    - 取消 - 确定 -
    -
    - } - - -
    - - -

    {can_fork}
    请问是否前往进行认证?

    -
    -
    - 取消 - 确定 -
    -
    - {!!shixunsDetails.fork_num && - - {shixunsDetails.fork_num} - - } - -
    :""} - -
    - -
    - -
    -
    正在等待管理员的审核。在审核通过前,可以随时撤销发布
    -
    - - ); - } -} - -export default TPMBanner; - diff --git a/public/react/src/tpm/TPMChallenge.js b/public/react/src/tpm/TPMChallenge.js deleted file mode 100644 index 847e8b965..000000000 --- a/public/react/src/tpm/TPMChallenge.js +++ /dev/null @@ -1,54 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import PropTypes from 'prop-types'; - -import { CircularProgress } from 'material-ui/Progress'; - -import './TPMShixunDiscuss.css' - -import Challenges from './shixunchild/Challenges/Challenges' - -import TPMRightSection from './component/TPMRightSection' - -import TPMNav from './component/TPMNav' - -class TPMChallenge extends Component { - constructor(props) { - super(props) - - } - - render() { - const { loadingContent, shixun, user, match - } = this.props; - return ( - -
    - -
    - - - -
    - -
    - -
    -
    -
    - - ); - } -} - -export default TPMChallenge; diff --git a/public/react/src/tpm/TPMChallengeContainer.js b/public/react/src/tpm/TPMChallengeContainer.js deleted file mode 100644 index a7c3c8a2b..000000000 --- a/public/react/src/tpm/TPMChallengeContainer.js +++ /dev/null @@ -1,34 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; -import TPMChallenge from './TPMChallenge'; -class TPMChallengeContainer extends Component { - constructor(props) { - super(props) - this.state = { - tpmLoading: true, - creator: { - owner_id: '', - } - } - } - - render() { - const { tpmLoading } = this.props; - const user = this.props.current_user; - - return ( - - - { tpmLoading ?
    : - - - } - -
    - ); - } -} - -export default TPMChallengeContainer; diff --git a/public/react/src/tpm/TPMCollaborators.js b/public/react/src/tpm/TPMCollaborators.js deleted file mode 100644 index cfab39ca5..000000000 --- a/public/react/src/tpm/TPMCollaborators.js +++ /dev/null @@ -1,53 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import PropTypes from 'prop-types'; - -import { CircularProgress } from 'material-ui/Progress'; - -import './TPMShixunDiscuss.css' - -import Collaborators from './shixunchild/Collaborators/Collaborators' -import TPMRightSection from './component/TPMRightSection' -import TPMNav from './component/TPMNav' - -class TPMCollaborators extends Component { - constructor(props) { - super(props) - } - - - render() { - const { loadingContent, creator, shixun, myshixun, recommend_shixuns, current_user, watched, - aboutFocus, user, match - } = this.props; - return ( - -
    - -
    - - - -
    - -
    - -
    -
    -
    - - ); - } -} - -export default TPMCollaborators; diff --git a/public/react/src/tpm/TPMCollaboratorsContainer.js b/public/react/src/tpm/TPMCollaboratorsContainer.js deleted file mode 100644 index 80049cee9..000000000 --- a/public/react/src/tpm/TPMCollaboratorsContainer.js +++ /dev/null @@ -1,47 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import PropTypes from 'prop-types'; - -import TPMCollaborators from './TPMCollaborators' - -import axios from 'axios'; - -class TPMChallengeContainer extends Component { - constructor(props) { - super(props) - this.state = { - } - } - - componentWillReceiveProps(newProps, newContext) { - - } - - componentDidMount() { - // this.props.showShixun(); - } - - - - render() { - const { tpmLoading } = this.props; - const user = this.props.current_user; - return ( - - { tpmLoading ?
    : - - - } -
    - ); - } -} - -export default TPMChallengeContainer; diff --git a/public/react/src/tpm/TPMFork/TPMForklist.js b/public/react/src/tpm/TPMFork/TPMForklist.js deleted file mode 100644 index 59d9d23b8..000000000 --- a/public/react/src/tpm/TPMFork/TPMForklist.js +++ /dev/null @@ -1,213 +0,0 @@ -import React, {Component} from 'react'; - -import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal,Pagination,Tooltip,Spin} from 'antd'; - -import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; - -// import "antd/dist/antd.css"; - -import { Rating } from "@icedesign/base"; - -import axios from 'axios'; - -import {getImageUrl, toPath, getUrl} from 'educoder' - -import './shixunCss/fork.css'; - -let origin = getUrl(); - -let path = getUrl("/editormd/lib/") - -const $ = window.$; - -let timeout; - -let currentValue; - - - -export default class TPMFork_listComponent extends Component { - constructor(props) { - super(props) - this.state = { - shixuns:undefined, - total_count:0, - shixunsID:undefined, - Forkvisible: true, - Forkcurrent: 1 - } - } - - - componentDidMount() { - let id = this.props.match.params.shixunId; - - let Url="/shixuns/"+id+"/fork_list.json"; - axios.get(Url, { - params: { - page:1, - limit:8 - } - }).then((response)=> { - this.setState({ - shixunsID:id, - shixuns:response.data.shixuns, - total_count:response.data.total_count, - Forkvisible:false - }) - }).catch((error)=>{ - console.log(error) - }); - } - - - TPMForkonChange=(pageNumber)=>{ - let id = this.props.match.params.shixunId; - this.setState({ - Forkvisible:true - }) - let Url="/shixuns/"+id+"/fork_list.json"; - axios.get(Url, { - params: { - page:pageNumber, - limit:8 - } - }).then((response)=> { - this.setState({ - shixunsID:id, - shixuns:response.data.shixuns, - total_count:response.data.total_count, - Forkvisible: false, - Forkcurrent: pageNumber - }) - }).catch((error)=>{ - console.log(error) - }); - } - render() { - - let {shixuns, total_count, shixunsID, Forkvisible, Forkcurrent} = this.state; - - const MyRate = ({ defaultValue, ...rest }) => { - let myValue = defaultValue; - // console.log(myValue-Math.floor(myValue)) - // if (myValue < Math.ceil(myValue)) { - // myValue = Math.floor(myValue) + 0.5; - // } - - return ; - }; - return ( - -
    - -
    - Fork实训列表 - 返回 -
    - - - {/**/} - -
    - - { shixuns===undefined?" ":shixuns.map((item,key)=>{ - return( -
    - -
    - {item.tag_name} - {/**/} -
    - -
    - -

    非试用内容,需要授权

    -
    - - - - - -
    -

    - - {item.name} - -

    - -

    - - - - {item.score_info===null?"5分":item.score_info+"分"} -

    - -

    - - - - {item.challenges_count} - - - - {/**/} - {/**/} - {/*{item.exp}*/} - {/**/} - {/**/} - - - - {item.stu_num} - - - - - {item.level} -

    - -
    -
    - ) - }) - } -
    - - {/*
    {total_count}
    */} -
    8 ? "block" : "none"}}> - {/*
    */} - -
    - - {/**/} -
    - - ) - } -} - - diff --git a/public/react/src/tpm/TPMFork/shixunCss/fork.css b/public/react/src/tpm/TPMFork/shixunCss/fork.css deleted file mode 100644 index 8cd2b9304..000000000 --- a/public/react/src/tpm/TPMFork/shixunCss/fork.css +++ /dev/null @@ -1,3 +0,0 @@ -.ml105 { - margin-left: 15%; -} \ No newline at end of file diff --git a/public/react/src/tpm/TPMFork/shixunCss/tag2.png b/public/react/src/tpm/TPMFork/shixunCss/tag2.png deleted file mode 100644 index 423d2f7e3..000000000 Binary files a/public/react/src/tpm/TPMFork/shixunCss/tag2.png and /dev/null differ diff --git a/public/react/src/tpm/TPMFork_listContainer.js b/public/react/src/tpm/TPMFork_listContainer.js deleted file mode 100644 index bbd55c2ee..000000000 --- a/public/react/src/tpm/TPMFork_listContainer.js +++ /dev/null @@ -1,50 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import PropTypes from 'prop-types'; - -import TPMForklist from './TPMForklist' - -import axios from 'axios'; - -class TPMRanking_listContainer extends Component { - constructor(props) { - super(props) - this.state = { - tpmLoading: true, - creator: { - owner_id: '' - } - } - } - - componentWillReceiveProps(newProps, newContext) { - - } - - componentDidMount() { - this.props.showShixun(); - } - - - render() { - const { tpmLoading } = this.props; - const user = this.props.current_user; - return ( - - { tpmLoading ?
    : - - - } -
    - ); - } -} - -export default TPMRanking_listContainer; diff --git a/public/react/src/tpm/TPMForklist.js b/public/react/src/tpm/TPMForklist.js deleted file mode 100644 index 251821209..000000000 --- a/public/react/src/tpm/TPMForklist.js +++ /dev/null @@ -1,63 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import PropTypes from 'prop-types'; - -import { CircularProgress } from 'material-ui/Progress'; - -import './TPMShixunDiscuss.css' - -import Shixunfork_list from './shixunchild/Shixunfork_list' -import TPMRightSection from './component/TPMRightSection' -import TPMNav from './component/TPMNav' - -class TPMForklist extends Component { - constructor(props) { - super(props) - - } - - componentWillReceiveProps(newProps, newContext) { - - } - - componentDidMount() { - - } - - - - render() { - const { loadingContent, creator, shixun, myshixun, recommend_shixuns, current_user, watched, - aboutFocus, user, match - } = this.props; - - return ( - -
    - -
    - - { loadingContent ? - : - - - } -
    - -
    - -
    -
    -
    - - ); - } -} - -export default TPMForklist; diff --git a/public/react/src/tpm/TPMIndex.css b/public/react/src/tpm/TPMIndex.css deleted file mode 100644 index bbec3d34d..000000000 --- a/public/react/src/tpm/TPMIndex.css +++ /dev/null @@ -1,229 +0,0 @@ -html{ - height: 100%; - overflow: hidden; -} -body { - overflow: auto !important; - font-family: "Microsoft YaHei"; -} - -#root { - /* ie兼容性 */ - position: relative; - min-height: 100%; -} -body>.-task-title { - opacity: 1 !important; -} -/*�����Ŵ󾵵�����·Ŵ󾵵�λ��*/ -#root .search-all { - width: 219px; -} - -/*Header START*/ -.newHeader .logoimg { - margin-top: 16px; - float: left; - width: 97px; -} -.head-right i { - font-size: 20px; - float: none !important; -} -.headIcon, #header_keyword_search { - padding-top: 13px !important; -} -.search-icon { - height: 30px !important; -} -.search-icon i { - font-size: 20px; -} -#header_keyword_search i { - color: #4cacff; -} -.ant-select-selection--multiple{ - padding-bottom: 0px!important; - padding-top:3px; -} -/* 先注释掉下面2个样式,这样写影响范围太广了,并不是所有的select都需要40px高 */ -/* .ant-select-selection--single{ - height:40px!important; -} -.ant-select-selection__rendered{ - line-height: 40px!important; -} */ -.ant-select-selection--multiple .ant-select-selection__rendered>ul>li, .ant-select-selection--multiple>ul>li{ - height: 25px!important; - line-height: 23px!important; - margin-bottom:3px; - margin-top:0px; -} -/*Main START*/ - - -.newContainer{ - background: #fafafa!important; -} - -.ant-modal-title{ - font-size: 16px; - font-weight: bold !important; - color: #333; -} - -.ant-modal-title{ - text-align: center; -} -/*.ant-modal{*/ - /*top:10rem !important;*/ -/*}*/ - -@-moz-document url-prefix() { - .ant-radio-inner { - width: 17px !important; - height: 17px !important; - } -} -/* IE只能用padding,不能用上下居中 */ -.shixunDetail_top{ - display: block!important; - padding-top: 48px; -} -.totalScore{ - display: block!important; - padding-top: 28px; -} -.head-nav ul#header-nav li{ - /*font-weight: 600;*/ -} - -/*.newFooter{*/ - /*position: fixed !important;*/ -/*}*/ - -.edu-menu-panel .edu-menu-listnew:hover .careersiconfont{ - color: #000 !important; -} - - -.newHeader { - background: #24292D !important; - height: 60px !important; -} - - -/*-------------------个人主页:右侧提示区域--------------------------*/ -.-task-sidebar{position:fixed;width:40px;height:180px;right:0;bottom:30px;z-index: 10;} -.-task-sidebar>div{height: 40px;line-height: 40px;box-sizing: border-box;width:40px;background:#4CACFF;color:#fff;font-size:20px;text-align:center;margin-bottom:5px;border-radius: 4px;} -.-task-sidebar>div i{ color:#fff;} -.-task-sidebar>div i:hover{color: #fff!important;} -.gotop{background-color: rgba(208,207,207,0.5)!important;padding: 0px!important;} -.-task-desc{background:#494949;width:90px;line-height: 36px;text-align: center; - position: absolute;color: #fff;font-size: 13px;z-index: 999999;opacity: 0;} -.-task-desc div{position: absolute;top:10px;right: -7px;height: 13px;} -.-task-desc div img{float: left} -.-task-sidebar .scan_ewm{ - position: absolute !important; - right: 45px !important; - bottom: 0px !important; - background-color: #494949 !important; - -webkit-box-sizing: border-box !important; - box-sizing: border-box !important; - font-size: 14px !important; - line-height: 16px !important; - display: none; - height: 213px !important; -} -.trangle_right{position: absolute;right: -5px;bottom: 15px;width: 0;height: 0px;border-top: 6px solid transparent;border-left: 5px solid #494949;border-bottom: 6px solid transparent} - -.HeaderSearch{ - margin-top: 18px; - margin-right: 20px; -} -.HeaderSearch .ant-input-search .ant-input{ - /*height:30px;*/ - background: #373e3f !important; - border: 1px solid #373e3f !important; - -} -.ant-input-search .ant-input-affix-wrapper{ - border:transparent; -} -.ant-input-affix-wrapper:hover .ant-input:not(.ant-input-disabled) { - /* 比较奇怪的需求,先注释掉了,如果需要启用,麻烦增加class限制,别影响别的地方的使用 */ - /* border-color: transparent; */ -} - -.ant-input:focus { - /*border-color: transparent;*/ - border-right-width: 1px !important; - outline: 0; - -webkit-box-shadow: 0 0 0 2px transparent; - box-shadow: 0 0 0 2px transparent; - border: 1px solid #d9d9d9; -} - -.HeaderSearch .ant-input-search .ant-input::-webkit-input-placeholder{ - color: #999; - font-size: 14px; -} - -.HeaderSearch .ant-input-search .ant-input:-moz-placeholder { - color: #999; - font-size: 14px; -} - -.HeaderSearch .ant-input-search .ant-input::-moz-placeholder{ - color: #999; - font-size: 14px; -} - -.HeaderSearch .ant-input-search .ant-input:-ms-input-placeholder{ - color: #999; - font-size: 14px; -} - -.HeaderSearch .ant-input-search .ant-input-suffix .anticon-search { - color: #999; -} - -.HeaderSearch .ant-input-search .ant-input{ - color: #fff; -} - -.HeaderSearch .ant-input-search .ant-input-suffix{ - background: transparent !important; -} - -.roundedRectangles{ - position: absolute; - top: 10px; - right: -22px; -} - -.HeaderSearch{ - width: 325px; - /*right: 20px;*/ -} -.HeaderSearch .ant-input-search{ - right: 20px; -} -.mainheighs{ - height: 100%; - display: block; -} - -.ml18a{ - margin-left:18%; -} - -.logoimg{ - float: left; - min-width: 40px; - height:40px; -} - -.headwith100b{ - width: 100%; -} \ No newline at end of file diff --git a/public/react/src/tpm/TPMIndex.js b/public/react/src/tpm/TPMIndex.js deleted file mode 100644 index 9b3308e04..000000000 --- a/public/react/src/tpm/TPMIndex.js +++ /dev/null @@ -1,416 +0,0 @@ -import React, { Component } from 'react'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import Loading from '../../Loading'; - -import Loadable from 'react-loadable'; - -import { TPMIndexHOC } from './TPMIndexHOC'; - -import { SnackbarHOC } from 'educoder'; - -import TPMBanner from './TPMBanner'; - -import axios from 'axios'; - -import TPMShixunDiscussContainer from './TPMShixunDiscussContainer'; - -import TPMRepositoryComponent from './TPMRepositoryComponent'; - -import TPMRepositoryCommits from './shixunchild/Repository/TPMRepositoryCommits'; - -import TPMsettings from './TPMsettings/TPMsettings'; - -import TPMChallengeComponent from './TPMChallengeContainer'; -import TPMPropaedeuticsComponent from './TPMPropaedeuticsComponent'; -import TPMRanking_listComponent from './TPMRanking_listContainer'; -import TPMCollaboratorsComponent from './TPMCollaboratorsContainer'; -import Audit_situationComponent from './Audit_situationComponent'; - -import '../page/tpiPage.css' - -const $ = window.$ -//任务 -// const TPMChallengeComponent = Loadable({ -// loader: () => import('./TPMChallengeContainer'), -// loading: Loading, -// }) - -//背景知识 -// const TPMPropaedeuticsComponent = Loadable({ -// loader: () => import('./TPMPropaedeuticsComponent'), -// loading: Loading, -// }) - -//版本库 -// const TPMRepositoryComponent = Loadable({ -// loader: () => import('./TPMRepositoryComponent'), -// loading: Loading, -// }) - -// const TPMRepositoryComponent = Loadable({ -// loader: () => import('./TPMRepositoryComponent'), -// loading: Loading, -// }) - -//合作 -// const TPMCollaboratorsComponent = Loadable({ -// loader: () => import('./TPMCollaboratorsContainer'), -// loading: Loading, -// }) - - -//评论 -// const TPMShixunDiscussComponent = Loadable({ -// loader: () => import('./TPMShixunDiscussContainer'), -// loading: Loading, -// }) - -//排行版 -// const TPMRanking_listComponent = Loadable({ -// loader: () => import('./TPMRanking_listContainer'), -// loading: Loading, -// }) - -// //编辑实训 -// const TPMModifysettings = Loadable({ -// loader: () =>import('./modules/tpm/TPMsettings/TPMsettings'), -// loading: Loading, -// }) - -//新建实训 -const TPMchallengesnew = Loadable({ - loader: () => import('./challengesnew/TPMchallengesnew'), - loading: Loading, -}) - -//新建tab2 -const TPMevaluation = Loadable({ - loader: () => import('./challengesnew/TPMevaluation'), - loading: Loading, -}) - -//新建tab3答案 -// const TPManswer = Loadable({ -// loader: () => import('./challengesnew/TPManswer'), -// loading: Loading, -// }) -const TPManswer = Loadable({ - loader: () => import('./challengesnew/TPManswer2'), - loading: Loading, -}) - -//选择题 -const TPMquestion = Loadable({ - loader: () => import('./challengesnew/TPMquestion'), - loading: Loading, -}) - -//fork列表 -const TPMFork_listComponent = Loadable({ - loader: () => import('./TPMFork/TPMForklist'), - loading: Loading, -}) -//背景知识修改 -const TPMUpdatepropaede = Loadable({ - loader: () => import('./TPMUpdatepropaede/TPMUpdatepropaede'), - loading: Loading, -}) - - - -// 版本库添加文件 -const AddFile = Loadable({ - loader: () => import('./shixunchild/Repository/RepositoryAddFile'), - loading: Loading, -}) - -const interceptorUrlArray = ['repository.json', 'commits.json', 'propaedeutics.json' - , 'challenges.json', 'discusses.json', 'ranking_list.json', 'collaborators.json'] -const cacheInterceptorUrlMap = {} -class TPMIndex extends Component { - constructor(props) { - super(props) - this.state = { - loadingContent: false, - power: false, - shixunsDetails: {}, - shixunId: undefined, - star_info: [0, 0, 0, 0, 0, 0], - star_infos: [0, 0, 0, 0, 0, 0], - identity:undefined, - TPMRightSectionData:undefined, - PropaedeuticsList: undefined, - } - } - - componentDidMount = () => { - - let id = this.props.match.params.shixunId; - - // let collaborators = `/shixuns/` + id + `/propaedeutics.json`; - // - // axios.get(collaborators).then((response) => { - // if (response.status === 200) { - // if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - // - // }else{ - // this.setState({ - // PropaedeuticsList: response.data, - // shixunId: id - // }); - // } - // - // } - // }).catch((error) => { - // console.log(error) - // }); - - let Url = `/shixuns/` + id + `.json`; - axios.get(Url).then((response) => { - if (response.status === 200) { - document.title=response.data.name; - let newstar_info = []; - // let start1= - for (var i = 0; i < response.data.score_info.length; i++) { - - if (i === 0) { - newstar_info.push(response.data.score_info[i]) - } else { - newstar_info.push((response.data.score_info[i] / 100) * 5) - } - } - let newstar_infos = response.data.score_info; - this.setState({ - shixunsDetails: response.data, - shixunId: id, - star_info: newstar_info, - star_infos: newstar_infos, - power: response.data.power, - identity: response.data.identity, - propaedeutics:response.data.propaedeutics, - status: response.data.shixun_status, - secret_repository: response.data.secret_repository, - - }); - } - }).catch((error) => { - this.setState({ - shixunsDetails: undefined, - shixunId: undefined, - star_info: undefined, - star_infos: undefined, - power: undefined, - identity: undefined, - status: undefined, - propaedeutics:undefined - }); - }); - - this.tpmContentRequestInterceptor = axios.interceptors.request.use((config) => { - let url = config.url; - // console.log('tpmContentRequestInterceptor:', url) - for ( let i = 0; i < interceptorUrlArray.length; i++ ) { - if (url.indexOf(interceptorUrlArray[i]) != -1) { - url = url.split('?')[0] - console.log('loadingContent, url:', url) - - this.setState({ loadingContent: true }) - - cacheInterceptorUrlMap[url] = true - } - } - return config; - }, function (error) { - return Promise.reject(error); - }); - - // Add a response interceptor - this.tpmContentResponseInterceptor = axios.interceptors.response.use((response) => { - // console.log('loadingContent finished, url:', response.config.url) - // TODO 依赖了api这个前缀 - let url = response.config.url.split('api')[1]; - url = url.split('?')[0] - if (cacheInterceptorUrlMap[url]) { - - this.setState({ loadingContent: false }) - delete cacheInterceptorUrlMap[response.url] - } - return response; - }, function (error) { - // Do something with response error - return Promise.reject(error); - }); - - - //右侧数据 - let shixunsDetailsURL=`/shixuns/`+id+`/show_right.json`; - axios.get(shixunsDetailsURL).then((response)=> { - this.setState({ - TPMRightSectionData: response.data - }); - }) - - } - componentWillUnmount = () => { - axios.interceptors.request.eject(this.tpmContentRequestInterceptor); - this.tpmContentRequestInterceptor = null; - axios.interceptors.request.eject(this.tpmContentResponseInterceptor); - this.tpmContentResponseInterceptor = null; - } - - - setLoadingContent = (isLoadingContent) => { - this.setState({ loadingContent: isLoadingContent }) - } - - // TpmTPMBannertype(type){ - // - // } - - render() { - let url = window.location.href; - let flag = url.indexOf("add_file")>-1; - return ( -
    - { - !flag && - - } - - - - () - }> - () - }> - - () - }> - - () - }> - - () - }> - () - }> - - {/* */} - - () - }> - - - () - }> - - - {/* */} - - - (this.initForumState(data)} - setSearchValue={this.setSearchValue} - setHotLabelIndex={this.setHotLabelIndex} - />) - }> - - - () - }> - - - () - }> - - () - }> - - () - }> - - () - }> - - {/*评测设置*/} - () - }> - - - {/*参考答案*/} - () - }> - - {/*新建关卡*/} - () - }> - - {/*编辑关卡*/} - () - }> - - {/*新建选择题*/} - () - }> - - {/*修改选择题*/} - () - }> - - {/*修改选择题*/} - () - }> - - () - }> - - - {/**/} - - -
    - ); - } -} - -export default SnackbarHOC() (TPMIndexHOC ( TPMIndex )); diff --git a/public/react/src/tpm/TPMIndexHOC.js b/public/react/src/tpm/TPMIndexHOC.js deleted file mode 100644 index d353ceba7..000000000 --- a/public/react/src/tpm/TPMIndexHOC.js +++ /dev/null @@ -1,754 +0,0 @@ -import React, { Component } from 'react'; - -import PropTypes from 'prop-types'; - -import NewHeader from './NewHeader' -import NewFooter from './NewFooter' -import SiderBar from './SiderBar' -import { getUrl, downloadFile } from 'educoder' -import axios from 'axios'; -import { Spin } from 'antd'; -import './TPMIndex.css'; -import LoginDialog from '../login/LoginDialog'; -import AccountProfile from '../user/AccountProfile'; - -import Trialapplication from "../login/Trialapplication"; -// import "antd/dist/antd.css"; -// import '../../css/educoder/edu-common.css' -// import '../../css/educoder/edu-all.css' -// import '../../css/educoder/edu-main.css' - -const $ = window.$; -const versionNum = '0001'; -// let _url_origin = getUrl() -let _url_origin=''; -if(window.location.port === "3007"){ - _url_origin="http://pre-newweb.educoder.net"; -} - -// let _url_origin=`https://www.educoder.net`; - -if (!window['indexHOCLoaded']) { - window.indexHOCLoaded = true; - //解决首屏加载问题 - - // $('head').append($('') - // .attr('href', `${_url_origin}/stylesheets/educoder/antd.min.css?1525440977`)); - $('head').append($('') - .attr('href', `${_url_origin}/stylesheets/css/edu-common.css?1`)); - - $('head').append($('') - .attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?1`)); - - // index.html有加载 - $('head').append($('') - .attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?1`)); - - - // $('head').append($('') - // .attr('href', `${_url_origin}/stylesheets/educoder/css_min_all.css?1525440977`)); - // 加timeout 为了覆盖掉antd的样式 - // setTimeout(() => { - // $('head').append( $('') - // .attr('href', `${_url_origin}/stylesheets/css/edu-common.css?1525440977`) ); - - // $('head').append( $('') - // .attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?1525440977`) ); - // $('head').append( $('') - // .attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?1525440977`) ); - // }, 1000); - - $("script").append('') - .attr('src', `${_url_origin}/javascripts/jquery-1.8.3-ui-1.9.2-ujs-2.0.3.js?_t=${versionNum}`); - -} - // `${_url_origin}/javascripts/jquery-1.8.3-ui-1.9.2-ujs-2.0.3.js?_t=${versionNum}` -// TODO css加载完成后再打开页面,行为和tpm其他页面一致 -export function TPMIndexHOC(WrappedComponent) { - // 这里如果extends WrappedComponent 会出现 WrappedComponent mount twice的问题 - return class II extends React.Component { - constructor(props) { - super(props) - window.$('#root').css('position', 'relative') - - this.state = { - tpmLoading: true, - resLoading: true, - Headertop:undefined, - Footerdown:undefined, - coursedata: {}, - - isRender: false, - AccountProfiletype: false, - - globalLoading: false, - dataquerys:{}, - isloginCancel:undefined, - mygetHelmetapi: null, - } - } - - // header里面需要有user - initCommonState(user) { - // 更新头像后,需要改变参数,不然会被图片缓存影响到 --> 后台已加 ?t=${new Date().getTime() - const newUser = Object.assign({}, {...user}, { image_url: `${user.image_url}`}); - this.setState({ - user: newUser, - current_user: newUser - }) - } - showShixun = () => { - const { shixunId } = this.props.match.params - const url = `/api/v1/shixuns/${shixunId}/show_shixun` - - this.setState({ tpmLoading: true }) - axios.get(url, - { - withCredentials: true - } - ).then((response) => { - if (response.data && response.data.shixun) { - this.initCommonState(response.data.current_user) - response.data.tpmLoading = false; - this.setState(response.data); - } - - }).catch((error) => { - console.log(error) - }) - } - aboutFocus = () => { - const { creator, watched } = this.state - /*http://localhost:3000/api/v1/users/155/watch?object_id=156&object_type=user*/ - - const focusUrl = `/api/v1/users/${creator.owner_id}/${watched ? 'unwatch' : 'watch'}?object_id=${creator.owner_id}&object_type=user` - - axios.get(focusUrl,{ - }) - .then((response) => { - const status = response.data.status; - if(status == 1){ - const new_author_info = Object.assign({}, creator) - this.setState({ - watched: !watched - }) - } - }).catch((error) => { - console.log(error) - }) - } - - keyupListener = (e) => { - if (e.key === "Escape") { - this.setState({ globalLoading: false }) - } - } - componentWillUnmount() { - window.removeEventListener('keyup', this.keyupListener) - } - - componentDidMount() { - // console.log("TPMIndexHOC========"); - // console.log(this.props); - window.addEventListener('keyup', this.keyupListener) - - if(this.props.match.path==="/"){ - // document.title="创新源于实践"; - }else if(this.props.match.path==="/403"){ - document.title="你没有权限访问"; - }else if(this.props.match.path==="/nopage"){ - document.title="没有找到该页面"; - }else if(this.props.match.path==="/shixuns"){ - document.title="实训项目"; - }else if(this.props.match.path==="/paths"){ - document.title="实践课程"; - }else if(this.props.match.path==="/courses"){ - document.title="翻转课堂"; - } - - - $.ajaxSetup({ - cache: true - }); - - //帮助后台传参数 - const query = this.props.location.search; - // const type = query.split('?chinaoocTimestamp='); - // console.log("Eduinforms12345"); - // console.log(this.foo(query)); - // console.log(JSON.stringify(this.foo(query))); - var dataqueryss={} - try { - var foqus=this.foo(query); - if(JSON.stringify(foqus) ==="{}"){ - this.setState({ - dataquerys:{}, - }); - }else{ - this.setState({ - dataquerys:foqus, - }); - dataqueryss=foqus; - } - }catch (e) { - this.setState({ - dataquerys:{}, - }) - } - this.fetchUsers(dataqueryss); - - let url=`/users/get_navigation_info.json`; - axios.get(url, { - - }).then((response) => { - // console.log("开始请求/get_navigation_info.json"); - // console.log(response); - if(response!=undefined){ - if(response.status===200){ - this.setState({ - Headertop:response.data.top, - Footerdown:response.data.down - }) - } - } - }); - ///请求定制化的信息 - this.getAppdata(); - } - /** - 课堂权限相关方法,暂时写这里了 ----------------------------------------START - ADMIN = 0 # 超级管理员 - CREATOR = 1 # 课程创建者 - PROFESSOR = 2 # 课程老师 - ASSISTANT_PROFESSOR = 3 # 课程助教 - STUDENT = 4 # 学生 - NORMAL = 5 # 普通用户 - - v2 - # 课程权限判断 - ADMIN = 0 # 超级管理员 - BUSINESS = 1 # 运营人员 - CREATOR = 2 # 课程创建者 课堂管理员 - PROFESSOR = 3 # 课程老师 - ASSISTANT_PROFESSOR = 4 # 课程助教 - STUDENT = 5 # 学生 - NORMAL = 6 # 普通用户 - Anonymous = 7 # 普未登录 - */ - //超管0 - isSuperAdmin = () => { - // return false - return this.state.coursedata&&this.state.coursedata.course_identity === 0 - } - isCourseAdmin = () => { - return this.state.coursedata&&this.state.coursedata.course_identity === 2 - } - //超管、运维0-1 - isClassManagement = () => { - return this.state.coursedata&&this.state.coursedata.course_identity < 2 - } - //超管、运维、课堂管理0-2 - isAdminOrCreator = () => { - return this.state.coursedata&&this.state.coursedata.course_identity < 3 - } - //超管、运维、课堂管理、老师0-3 - isAdminOrTeacher = () => { - return this.state.coursedata&&this.state.coursedata.course_identity < 4 - } - // 超管、运维、课堂管理、老师、助教0-4 - isAdmin = () => { - return this.state.coursedata&&this.state.coursedata.course_identity < 5 - } - // 学生5 - isStudent = () => { - return this.state.coursedata&&this.state.coursedata.course_identity === 5 - } - // 超管、运维、课堂管理、老师、助教、学生0-5 - isAdminOrStudent = () => { - return this.state.coursedata&&this.state.coursedata.course_identity <= 5 - } - // 游客未登录/非课堂成员6> - isNotMember = () => { - return this.state.coursedata&&this.state.coursedata.course_identity >= 6 - } - //课堂是否已结束 - isCourseEnd = () => { - return this.state.current_user ? this.state.current_user.course_is_end : false - } - - // setTrialapplication = ()=>{ - // this.setState({ - // isRenders:true - // }) - // - // } - - //获取数据为空的时候 - gettablogourlnull = () => { - this.setState({ - mygetHelmetapi: undefined - }); - document.title = "EduCoder"; - var link = document.createElement('link'), - oldLink = document.getElementById('dynamic-favicon'); - link.id = 'dynamic-favicon'; - link.rel = 'shortcut icon'; - link.href = "/react/build/./favicon.ico"; - if (oldLink) { - document.head.removeChild(oldLink); - } - document.head.appendChild(link); - }; - - //获取数据的时候 - gettablogourldata = (response) => { - document.title = response.data.setting.name; - var link = document.createElement('link'), - oldLink = document.getElementById('dynamic-favicon'); - link.id = 'dynamic-favicon'; - link.rel = 'shortcut icon'; - link.href = '/' + response.data.setting.tab_logo_url; - if (oldLink) { - document.head.removeChild(oldLink); - } - document.head.appendChild(link); - } - //获取当前定制信息 - getAppdata = () => { - let url = "/setting.json"; - axios.get(url).then((response) => { - // console.log("app.js开始请求/setting.json"); - // console.log("获取当前定制信息"); - if (response) { - if (response.data) { - this.setState({ - mygetHelmetapi: response.data.setting - }); - try { - if (response.data.setting.tab_logo_url) { - this.gettablogourldata(response); - } else { - this.gettablogourlnull(); - } - } catch (e) { - this.gettablogourlnull(); - } - - - } else { - - this.gettablogourlnull(); - - } - - } else { - this.gettablogourlnull(); - - } - - }).catch((error) => { - this.gettablogourlnull(); - - }); - }; - /** - 课堂权限相关方法,暂时写这里了 ----------------------------------------END - */ - fetchUser = () => { - let url = `/users/get_user_info.json` - let courseId; - let query = this.props.location.pathname; - const type = query.split('/'); - if (type[1] == 'courses' && type[2]) { - courseId = parseInt(type[2]) - // url += `?course_id=${courseId}` - } - var datay={}; - if(JSON.stringify(this.state.dataquerys) ==="{}"){ - datay={ - course_id:isNaN(courseId)?undefined:courseId, - school:1 - } - }else{ - datay={ - course_id:isNaN(courseId)?undefined:courseId, - school:1, - chinaoocTimestamp:this.state.dataquerys.chinaoocTimestamp, - websiteName:this.state.dataquerys.websiteName, - chinaoocKey:this.state.dataquerys.chinaoocKey, - } - } - axios.get(url,{params: - datay - }, - { - // withCredentials: true - } - ).then((response) => { - /* - { - "username": "黄井泉", - "login": "Hjqreturn", - "user_id": 12, - "image_url": "avatar/User/12", - "admin": true, - "is_teacher": false, - "tidding_count": 0 - } - */ - if(response=== undefined){ - return - } - if (response.data) { - this.initCommonState(response.data) - this.setState({ - tpmLoading: false, - coursedata: { - course_identity: response.data.course_identity >= 0 ? response.data.course_identity : undefined, - course_public: response.data.course_public, - name: response.data.course_name, - userid:response.data.user_id - }, - - }) - - } - - }).catch((error) => { - console.log(error) - }) - }; - fetchUsers = (yslurlobject) => { - let url = `/users/get_user_info.json` - let courseId; - let query = this.props.location.pathname; - const type = query.split('/'); - if (type[1] == 'courses' && type[2]) { - courseId = parseInt(type[2]) - // url += `?course_id=${courseId}` - } - var datay={}; - if(JSON.stringify(yslurlobject) ==="{}"){ - datay={ - course_id:isNaN(courseId)?undefined:courseId, - school:1 - } - }else{ - datay={ - course_id:isNaN(courseId)?undefined:courseId, - school:1, - chinaoocTimestamp:yslurlobject.chinaoocTimestamp, - websiteName:yslurlobject.websiteName, - chinaoocKey:yslurlobject.chinaoocKey, - } - } - axios.get(url,{params: - datay - }, - { - // withCredentials: true - } - ).then((response) => { - /* - { - "username": "黄井泉", - "login": "Hjqreturn", - "user_id": 12, - "image_url": "avatar/User/12", - "admin": true, - "is_teacher": false, - "tidding_count": 0 - } - */ - if(response=== undefined){ - return - } - if (response.data) { - this.initCommonState(response.data) - this.setState({ - tpmLoading: false, - coursedata: { - course_identity: response.data.course_identity >= 0 ? response.data.course_identity : undefined, - course_public: response.data.course_public, - name: response.data.course_name, - userid:response.data.user_id - }, - - }) - - } - - }).catch((error) => { - console.log(error) - }) - }; - //截取url 数据的 - foo=(url)=> { - var json = {}; - var regExp = /[\?\&](\w+)(=?)(\w*)/g; - var arr; - do { - arr = regExp.exec(url); - // console.log(arr); // arr = [完整的字符串, key, 等号或'', value或''] - - if (arr) { - var key = arr[1]; - var value = arr[3]; - // arr[2] === ''时, value = undefined - if (!arr[2]) - value = undefined; - - json[key] = value; - } - } while (arr); - - return json; - }; - hideLoginDialog = () => { - this.setState({ - isRender: false, - isloginCancel:undefined - }) - } - showLoginDialog = () => { - this.setState({ - isRender: true, - isloginCancel:"iscancel" - }) - } - //验证登录是否成功方法 - checkIfLogin = () => { - return this.state.current_user && this.state.current_user.login != '' - } - - hideAccountProfile = () => { - this.setState({ - AccountProfiletype: false - }) - } - showProfileCompleteDialog = () => { - this.dialogObj = {} - this.setState({ - AccountProfiletype: true - }) - } - //验证是否完善资料 - checkIfProfileCompleted = () => { - return this.state.current_user && this.state.current_user.profile_completed - } - showProfessionalCertificationDialog = () => { - this.dialogObj = { - content: '您需要去完成您的职业认证,才能使用此功能', - okText: '立即完成', - okHref: '/account/certification' - } - this.setState({ - AccountProfiletype: true, - }) - } - checkIfProfessionalCertification = () => { - return this.state.current_user && this.state.current_user.professional_certification - } - - - ShowOnlinePdf = (url) => { - return axios({ - method:'get', - url:url, - responseType: 'arraybuffer', - }).then((result)=>{ - var binaryData = []; - binaryData.push(result.data); - this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); - window.open(this.url); - }) - } - DownloadFileA=(title,url)=>{ - let link = document.createElement('a'); - document.body.appendChild(link); - link.href =url; - link.download = title; - //兼容火狐浏览器 - let evt = document.createEvent("MouseEvents"); - evt.initEvent("click", false, false); - link.dispatchEvent(evt); - document.body.removeChild(link); - } - - DownloadOpenPdf=(type,url)=>{ - type===true?window.open(url):window.location.href=url; - } - slowDownload = (url, tip) => { - this._gLoadingTip = tip || '正在生成文件,请稍后...'; - this.setState({ globalLoading: true }) - const fileUrl = url; - downloadFile({ - url: fileUrl, - successCallback: (url) => { - this.setState({ globalLoading: false }) - console.log('successCallback') - }, - failCallback: (responseHtml, url) => { - this.setState({ globalLoading: false }) - console.log('failCallback') - } - }) - } - yslslowCheckresults =(tip) =>{ - this._gLoadingTip = tip || '成绩计算中,请稍候...'; - this.setState({ globalLoading: true }) - } - yslslowCheckresultsNo =() =>{ - this.setState({ globalLoading: false }) - } - - showGlobalLoading = (tip) => { - this._gLoadingTip = tip || '加载中,请稍后...'; - this.setState({ globalLoading: true }) - } - hideGlobalLoading = () => { - this.setState({ globalLoading: false }) - } - - MdifHasAnchorJustScorll=()=>{ - //mdhash滚动 - let anchor = decodeURI(this.props.location.hash).replace('#', ''); - // 对应id的话, 滚动到相应位置 - if (!!anchor) { - let anchorElement = document.getElementsByName(anchor); - if (anchorElement) { - if (anchorElement.length>0){ - anchorElement[anchorElement.length-1].scrollIntoView(); - } - } - } - } - - render() { - let{Headertop,Footerdown, isRender, AccountProfiletype,mygetHelmetapi}=this.state; - const common = { - isSuperAdmin:this.isSuperAdmin, - isAdminOrCreator:this.isAdminOrCreator, - isClassManagement:this.isClassManagement, - isCourseAdmin:this.isCourseAdmin, - - isAdmin: this.isAdmin, - isAdminOrTeacher: this.isAdminOrTeacher, - isStudent: this.isStudent, - isAdminOrStudent: this.isAdminOrStudent, - isNotMember: this.isNotMember, - isCourseEnd: this.isCourseEnd, - - isUserid:this.state.coursedata&&this.state.coursedata.userid, - fetchUser: this.fetchUser, - - showLoginDialog: this.showLoginDialog, - checkIfLogin: this.checkIfLogin, - showProfileCompleteDialog: this.showProfileCompleteDialog, - checkIfProfileCompleted: this.checkIfProfileCompleted, - checkIfProfessionalCertification: this.checkIfProfessionalCertification, - showProfessionalCertificationDialog: this.showProfessionalCertificationDialog, - - ShowOnlinePdf:(url)=>this.ShowOnlinePdf(url), - DownloadFileA:(title,url)=>this.DownloadFileA(title,url), - DownloadOpenPdf:(type,url)=>this.DownloadOpenPdf(type,url), - - slowDownload: this.slowDownload, - showGlobalLoading: this.showGlobalLoading, - hideGlobalLoading: this.hideGlobalLoading, - yslslowCheckresults:this.yslslowCheckresults, - yslslowCheckresultsNo:this.yslslowCheckresultsNo, - MdifHasAnchorJustScorll:this.MdifHasAnchorJustScorll - - }; - // console.log("this.props.mygetHelmetapi"); - // console.log(this.props.mygetHelmetapi); - return ( -
    - {isRender===true ? this.hideLoginDialog()} - {...this.props} - {...this.state} - /> : ""} - {/* AccountProfile 也用作职业认证 */} - {AccountProfiletype===true ? this.hideAccountProfile()} - {...this.props} - {...this.state} - {...this.dialogObj} - />:""} - - {/* 注释掉了1440 影响到了手机屏幕的展示 */} - - - - - -
    - this.initCommonState(user)} - {...this.props} {...this.state} - showShixun={this.showShixun} aboutFocus={this.aboutFocus} - {...common} - > - - -
    - -
    - - - -
    - ); - } - } -} \ No newline at end of file diff --git a/public/react/src/tpm/TPMPropaedeutics.js b/public/react/src/tpm/TPMPropaedeutics.js deleted file mode 100644 index 88a05fde7..000000000 --- a/public/react/src/tpm/TPMPropaedeutics.js +++ /dev/null @@ -1,74 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import PropTypes from 'prop-types'; - -import { CircularProgress } from 'material-ui/Progress'; - -import './TPMShixunDiscuss.css' - -import Propaedeutics from './shixunchild/Propaedeutics/Propaedeu_tics' - -import TPMRightSection from './component/TPMRightSection' - -import TPMNav from './component/TPMNav' - -import axios from 'axios'; - -class TPMPropaedeutics extends Component { - constructor(props) { - super(props) - this.state = { - shixunId: undefined - } - } - - componentWillReceiveProps(newProps, newContext) { - } - - componentDidMount() { - - - } - - - render() { - const { loadingContent, creator, shixun, myshixun, recommend_shixuns, current_user, watched, - aboutFocus, user, match - } = this.props; - // - return ( - -
    - -
    - - - - -
    - -
    - -
    -
    -
    - - ); - } -} - -export default TPMPropaedeutics; diff --git a/public/react/src/tpm/TPMPropaedeuticsComponent.js b/public/react/src/tpm/TPMPropaedeuticsComponent.js deleted file mode 100644 index 7c3eadb89..000000000 --- a/public/react/src/tpm/TPMPropaedeuticsComponent.js +++ /dev/null @@ -1,39 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import PropTypes from 'prop-types'; - -import TPMPropaedeutics from './TPMPropaedeutics' - -import axios from 'axios'; - -class TPMPropaedeuticsComponent extends Component { - constructor(props) { - super(props) - this.state = { - // tpmLoading: true, - // creator: { - // owner_id: '' - // } - } - } - - render() { - const { tpmLoading } = this.props; - - return ( - - { tpmLoading ?
    : - - - } -
    - - - ); - } -} - -export default TPMPropaedeuticsComponent ; diff --git a/public/react/src/tpm/TPMRanking_list.js b/public/react/src/tpm/TPMRanking_list.js deleted file mode 100644 index 7171692a7..000000000 --- a/public/react/src/tpm/TPMRanking_list.js +++ /dev/null @@ -1,59 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import PropTypes from 'prop-types'; - -import { CircularProgress } from 'material-ui/Progress'; - -import './TPMShixunDiscuss.css' - -import Ranking_list from './shixunchild/Ranking_list/Ranking_list' -import TPMRightSection from './component/TPMRightSection' -import TPMNav from './component/TPMNav' - -class TPMRanking_list extends Component { - constructor(props) { - super(props) - - } - - render() { - const { loadingContent, creator, shixun, myshixun, recommend_shixuns, current_user, watched, - aboutFocus, user, match - } = this.props; - - // - return ( - -
    - -
    - - - - - -
    - -
    - -
    -
    -
    - - ); - } -} - -export default TPMRanking_list; diff --git a/public/react/src/tpm/TPMRanking_listContainer.js b/public/react/src/tpm/TPMRanking_listContainer.js deleted file mode 100644 index 98841b1ab..000000000 --- a/public/react/src/tpm/TPMRanking_listContainer.js +++ /dev/null @@ -1,37 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import PropTypes from 'prop-types'; - -import TPMRanking_list from './TPMRanking_list' - -import axios from 'axios'; - -class TPMRanking_listContainer extends Component { - constructor(props) { - super(props) - this.state = { - } - } - - render() { - const { tpmLoading } = this.props; - const user = this.props.current_user; - - return ( - - { tpmLoading ?
    : - - - } -
    - ); - } -} - -export default TPMRanking_listContainer; diff --git a/public/react/src/tpm/TPMRepository.js b/public/react/src/tpm/TPMRepository.js deleted file mode 100644 index 0f8e31258..000000000 --- a/public/react/src/tpm/TPMRepository.js +++ /dev/null @@ -1,58 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import PropTypes from 'prop-types'; - -import { CircularProgress } from 'material-ui/Progress'; - -import './TPMShixunDiscuss.css' - -import Repository from './shixunchild/Repository/Repository' -import TPMRightSection from './component/TPMRightSection' -import TPMNav from './component/TPMNav' - -// import RepositoryChooseModal from './component/modal/RepositoryChooseModal' - -class TPMRepository extends Component { - constructor(props) { - super(props) - } - - - render() { - const { loadingContent, creator, shixun, myshixun, recommend_shixuns, current_user, watched, - aboutFocus, user, match, isContentWidth100 - } = this.props; - - return ( - -
    - {/* 可能会影响到其他页面的样式,需要测试、协商 */} -
    - - {/* */} - { loadingContent ? - : - - } -
    - - { !isContentWidth100 &&
    - -
    } -
    -
    - - ); - } -} - -export default TPMRepository; diff --git a/public/react/src/tpm/TPMRepositoryComponent.js b/public/react/src/tpm/TPMRepositoryComponent.js deleted file mode 100644 index 027f3f705..000000000 --- a/public/react/src/tpm/TPMRepositoryComponent.js +++ /dev/null @@ -1,229 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import PropTypes from 'prop-types'; - -import TPMRepository from './TPMRepository' - -import axios from 'axios'; - -import { trace_collapse, info } from 'educoder' - -import RepositoryCodeEditor from './shixunchild/Repository/RepositoryCodeEditor' - - -class TPMRepositoryComponent extends Component { - constructor(props) { - super(props) - this.nameTypeMap = {} - let pathArray = [] - var splitArray = window.location.pathname.split('shixun_show/'); - if (splitArray[1]) { - pathArray = splitArray[1].split('/') - if (pathArray[pathArray.length - 1] == '') { - // 有可能是这么访问的: http://localhost:3007/shixuns/3ozvy5f8/repository/fsu7tkaw/master/shixun_show/src/ - pathArray.length = pathArray.length - 1; - } - } - this.state = { - repositoryLoading: true, - pathArray: pathArray, - isContentWidth100: this._isFileInPathArray(pathArray) - } - } - componentDidUpdate(prevProps, prevState) { - if (this.props.secret_repository_tab != prevProps.secret_repository_tab) { - this.fetchRepo() - } - } - - - componentDidMount = () => { - - this.fetchRepo() - } - setContentWidth100 = (flag) => { - const newFileContent = flag === false ? '' : this.state.fileContent - this.setState({ - // isCodeFile - isContentWidth100: flag, - fileContent: newFileContent - }) - } - saveCode = (content) => { - const path = this.state.pathArray.join('/') - let id = this.props.match.params.shixunId; - let url = `/shixuns/${id}/update_file.json`; - axios.post(url, { - path: path, - content - }).then((response) => { - if(response.status === 200){ - this.setState({ - fileContent: response.data.content, - repositoryLoading: false - }); - } - trace_collapse('tpm save code res: ', response) - this.props.showSnackbar('文件保存成功') - - }).catch((error)=>{ - console.log(error) - }); - } - fetchCode = (newPathArray) => { - const path = newPathArray.join('/') - - // https://testeduplus2.educoder.net/shixuns/3ozvy5f8/file_content.json - this.setContentWidth100(true) - this.setState({ repositoryLoading: true, pathArray: newPathArray }) - let id = this.props.match.params.shixunId; - let url = `/shixuns/${id}/file_content.json`; - axios.post(url, { - path: path, - secret_repository: this.props.secret_repository_tab - }).then((response) => { - trace_collapse('repository res: ', response) - - if (response.data.status == -1) { - this.props.showSnackbar('无法找到对应的资源,请变更地址或联系管理员!') - return; - } - if(response.status === 200){ - this.setState({ - fileContent: response.data.content, - repositoryLoading: false - }); - this.props.history - .replace(`${this.props.match.url}/master/shixun_show/${newPathArray.join('/')}`) - } - - }).catch((error)=>{ - this.props.showSnackbar('无法找到对应的资源,请变更地址或联系管理员!') - console.log(error) - }); - } - _isFileName = (name) => { - return name.indexOf('.') !== -1 - } - _isFileInPathArray = (array) => { - if (!array || array.length === 0) { - return false - } - return this.nameTypeMap[array[array.length - 1]] !== 'tree' && this._isFileName( array[array.length - 1] ) - } - // listItem 如果是num,则是通过面包屑点击过来的,取pathArray的子集 - fetchRepo = (listItem) => { - const { pathArray } = this.state; - let newPathArray = pathArray.slice(0) - - if (listItem === 0 || listItem) { - this.setContentWidth100(false) - this.nameTypeMap[listItem.name] = listItem.type - if (typeof listItem == 'number') { // 参数是数字的话,做截取 - // if (this._isFileName(newPathArray[listItem])) { // 面包屑中的文件不让点击了 - // listItem--; - // } - newPathArray = newPathArray.slice(0, listItem) - } else if (listItem.type === 'tree') { - newPathArray.push(listItem.name) - } else if (listItem.type === 'blob') { - newPathArray.push(listItem.name) - this.setState({ pathArray: newPathArray }) - this.fetchCode(newPathArray) - return; - } - } - // https://testeduplus2.educoder.net/shixuns/3ozvy5f8/repository.json - this.setState({ repositoryLoading: true, pathArray: newPathArray }) - let urlNewPathArray = newPathArray; - let fileInPathArray = false; - if (newPathArray.length) { - fileInPathArray = this.nameTypeMap[newPathArray[newPathArray.length - 1]] ? this.nameTypeMap[newPathArray[newPathArray.length - 1]] !== 'tree' - : (listItem ? listItem.type !== 'tree' : this._isFileName( newPathArray[newPathArray.length - 1] )) - if ( fileInPathArray ) { - urlNewPathArray = newPathArray.slice(0, newPathArray.length - 1) - } - } - const path = urlNewPathArray.join('/') - - let id = this.props.match.params.shixunId; - let url = `/shixuns/${id}/${this.props.secret_repository_tab ? 'secret_repository' : 'repository'}.json`; - // this.props.setLoadingContent(true) - axios.post(url, { - path: path ? path : '' - }).then((response) => { - // this.props.setLoadingContent(false) - - const trees = response.data.trees - const treeIsFileMap = {} - if (!trees || !Array.isArray(trees)) { - // this.props.showSnackbar('无法找到对应的资源,请变更地址或联系管理员!') - // return; - } else { - trees.forEach(item => { - treeIsFileMap[item.name] = item.type == 'blob' - }) - } - if(response.status === 200){ - this.setState({ - treeIsFileMap, - ...response.data, - repositoryLoading: false - }); - this.props.history - .replace(`${this.props.match.url}` + - (newPathArray.length ? `/master/shixun_show/${newPathArray.join('/')}` : '')) - } - - // 初始化时,repo接口完毕后需要看是否需要fetchCode - if (fileInPathArray) { - this.fetchCode(newPathArray) - } - // info(response) - trace_collapse('repository res: ', response) - - }).catch((error)=>{ - console.log(error) - }); - } - - - render() { - const { isContentWidth100 } = this.state; - - // 需要重构 - return ( - - { !isContentWidth100 ? - - : -
    - {/* 可能会影响到其他页面的样式,需要测试、协商 */} -
    - -
    -
    - } - -
    - - - ); - } -} - -export default TPMRepositoryComponent ; diff --git a/public/react/src/tpm/TPMShixunDiscuss.css b/public/react/src/tpm/TPMShixunDiscuss.css deleted file mode 100644 index 3af4ec269..000000000 --- a/public/react/src/tpm/TPMShixunDiscuss.css +++ /dev/null @@ -1,47 +0,0 @@ -.tpmComment .-fit { - position: inherit; -} -.tpmComment .rc-pagination { - margin-left: auto; - margin-right: auto; - margin-top: 12px; - margin-bottom: 20px; -} -.tpmComment .paginationSection { - background: #FAFAFA; -} -.tpmComment .comment_item_cont.df.clearfix:nth-last-child(1) { - border-bottom: none; -} - -/*.tpmComment .fl.edu-back-white {*/ -/*min-height: 600px;*/ -/*}*/ - - -.user_watch_btn { - cursor: pointer; -} - - -/*md编辑器*/ -.tpmComment .commentItemMDEditor a.task-btn { - background: #4cacff!important; - margin-right: 16px; - margin-top: 16px; -} -/* md编辑器 resizeBar*/ - .tpmComment .commentItemMDEditor .editor__resize { - transform: translateX(-176%) -} - -#ratePanel > div > div > div.fr div.rateYo.fl.mt3 { - height: 20px; - line-height: 20px; - cursor: default; - width: 110px; -} - -.tpmComment .icon-jiangli { - /* margin-top: 2px; */ -} \ No newline at end of file diff --git a/public/react/src/tpm/TPMShixunDiscuss.js b/public/react/src/tpm/TPMShixunDiscuss.js deleted file mode 100644 index 9350060cc..000000000 --- a/public/react/src/tpm/TPMShixunDiscuss.js +++ /dev/null @@ -1,72 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import PropTypes from 'prop-types'; - -import { CircularProgress } from 'material-ui/Progress'; - -import './TPMShixunDiscuss.css' - -import ShixunDiscuss from './shixunchild/ShixunDiscuss/ShixunDiscuss' -import TPMRightSection from './component/TPMRightSection' -import TPMNav from './component/TPMNav' - -import Comments from '../comment/Comments' -import { commentHOC } from '../comment/CommentsHOC' - -class TPMShixunDiscuss extends Component { - constructor(props) { - super(props) - - } - - componentWillReceiveProps(newProps, newContext) { - } - - componentDidMount() { - // TODO 加了HOC后 mount了两次 - this.props.fetchCommentIfNotFetched && - this.props.fetchCommentIfNotFetched(); - } - - render() { - const { loadingContent, creator, shixun, myshixun, recommend_shixuns, current_user, watched, - aboutFocus, user, match - } = this.props; - - return ( - -
    - -
    - - { loadingContent ? - : - - // onPaginationChange={this.onPaginationChange} - // - } -
    - -
    - -
    -
    -
    - - ); - } -} - -export default commentHOC ( TPMShixunDiscuss ); diff --git a/public/react/src/tpm/TPMShixunDiscussContainer.js b/public/react/src/tpm/TPMShixunDiscussContainer.js deleted file mode 100644 index 535840772..000000000 --- a/public/react/src/tpm/TPMShixunDiscussContainer.js +++ /dev/null @@ -1,45 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import PropTypes from 'prop-types'; - -import TPMShixunDiscuss from './TPMShixunDiscuss' - -import axios from 'axios'; - -class TPMShixunDiscussContainer extends Component { - constructor(props) { - super(props) - this.state = { - } - } - - componentWillReceiveProps(newProps, newContext) { - - } - - componentDidMount() { - - } - - render() { - const { tpmLoading } = this.props; - const user = this.props.current_user; - return ( - - { tpmLoading ?
    : - - - } -
    - ); - } -} - -export default TPMShixunDiscussContainer; diff --git a/public/react/src/tpm/TPMUpdatepropaede/TPMUpdatepropaede.js b/public/react/src/tpm/TPMUpdatepropaede/TPMUpdatepropaede.js deleted file mode 100644 index 63872b133..000000000 --- a/public/react/src/tpm/TPMUpdatepropaede/TPMUpdatepropaede.js +++ /dev/null @@ -1,100 +0,0 @@ -import React, {Component} from 'react'; - -import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal} from 'antd'; - -import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; - -import axios from 'axios'; - -import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; - -import {getUrl} from 'educoder'; - - - -export default class TPMUpdatepropaede extends Component { - constructor(props) { - super(props) - this.neweditanswerRef=React.createRef(); - this.state = { - shixunId:undefined, - } - } - - componentDidMount() { - let id = this.props.match.params.shixunId; - let url="/shixuns/"+id+"/propaedeutics.json"; - axios.get(url).then((response) => { - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - - }else{ - this.setState({ - shixunId:id, - }) - if(response.data.content[0]!=null){ - this.setState({ - editanswersRefval:response.data.content, - }) - this.neweditanswerRef.current.setValue(response.data.content) - }else{ - this.setState({ - editanswersRefval:"", - }) - this.neweditanswerRef.current.setValue('') - } - } - }).catch((error) => { - console.log(error) - }); - - } - - updatepropaedeuticsvalue=()=>{ - let id = this.props.match.params.shixunId; - let url="/shixuns/"+id+"/update_propaedeutics.json"; - const update_propaedeuticsvalue = this.neweditanswerRef.current.getValue().trim(); - axios.post(url,{ - content:update_propaedeuticsvalue - } - ).then((response) => { - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - - }else{ - this.props.showSnackbar(response.data.message); - } - }).catch((error) => { - console.log(error) - }); - } - render() { - let {shixunId} = this.state; - return ( - -
    - -
    -
    - 背景知识 - 返回 -
    - -
    - -
    -
    - -
    - 保存 - 取消 -
    - -
    -
    - ) - } -} - - diff --git a/public/react/src/tpm/TPMsettings/TPMsettings.js b/public/react/src/tpm/TPMsettings/TPMsettings.js deleted file mode 100644 index 7acaf98d6..000000000 --- a/public/react/src/tpm/TPMsettings/TPMsettings.js +++ /dev/null @@ -1,2437 +0,0 @@ -import React, { Component } from 'react'; - -import MonacoEditor from 'react-monaco-editor'; - -//MonacoDiffEditor 对比模式 -import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal,Icon,DatePicker,Breadcrumb,Upload,Button,notification, Tooltip} from 'antd'; - -// import "antd/dist/antd.css"; - -import locale from 'antd/lib/date-picker/locale/zh_CN'; - -import moment from 'moment'; - -import axios from 'axios'; - -import './css/TPMsettings.css'; - -import { getImageUrl, toPath, getUrl ,appendFileSizeToUploadFileAll, getUploadActionUrl} from 'educoder'; - -let origin = getUrl(); - -let path = getUrl("/editormd/lib/") - -const $ = window.$; - -let timeout; - -let currentValue; - -const Option = Select.Option; - -const RadioGroup = Radio.Group; -const confirm = Modal.confirm; -// 处理整点 半点 -// 取传入时间往后的第一个半点 -export function handleDateStrings(dateString) { - if (!dateString) return dateString; - const ar = dateString.split(':') - if (ar[1] == '00' || ar[1] == '30') { - return dateString - } - const miniute = parseInt(ar[1]); - if (miniute < 30 || miniute == 60) { - return [ar[0], '30'].join(':') - } - if (miniute < 60) { - // 加一个小时 - const tempStr = [ar[0], '00'].join(':'); - const format = "YYYY-MM-DD HH:mm"; - const _moment = moment(tempStr, format) - _moment.add(1, 'hours') - return _moment.format(format) - } - - return dateString -} - -// 恢复数据 -function md_rec_data(k,mdu,id, editor){ - if(window.sessionStorage.getItem(k+mdu) !== null){ - editor.setValue(window.sessionStorage.getItem(k+mdu)); - md_clear_data(k,mdu,id); - } -} - -// 保存数据 -function md_add_data(k,mdu,d){ - window.sessionStorage.setItem(k+mdu,d); -} - -// 清空保存的数据 -function md_clear_data(k,mdu,id){ - window.sessionStorage.removeItem(k+mdu); - var id1 = "#e_tip_"+id; - var id2 = "#e_tips_"+id; - if(k == 'content'){ - $(id2).html(""); - }else{ - $(id1).html(""); - } -} - -function md_elocalStorage(editor,mdu,id){ - if (window.sessionStorage){ - var oc = window.sessionStorage.getItem('content'+mdu); - if(oc !== null ){ - $("#e_tips_"+id).data('editor', editor); - var h = '您上次有已保存的数据,是否恢复 ? / 不恢复'; - $("#e_tips_"+id).html(h); - } - setInterval(function() { - var d = new Date(); - var h = d.getHours(); - var m = d.getMinutes(); - var s = d.getSeconds(); - h = h < 10 ? '0' + h : h; - m = m < 10 ? '0' + m : m; - s = s < 10 ? '0' + s : s; - if(editor.getValue().trim() != ""){ - md_add_data("content",mdu,editor.getValue()); - var id1 = "#e_tip_"+id; - var id2 = "#e_tips_"+id; - - $(id1).html(" 数据已于 " + h + ':' + m + ':' + s +" 保存 "); - $(id2).html(""); - } - },10000); - - }else{ - $("#e_tip_"+id).after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!'); - } -} - -function create_editorMD(id, width, high, placeholder, imageUrl,initValue, callback) { - var editorName = window.editormd(id, { - width: width, - height: high, - path: path, // "/editormd/lib/" - markdown : initValue, - syncScrolling: "single", - tex: true, - tocm: true, - emoji: true, - taskList: true, - codeFold: true, - searchReplace: true, - htmlDecode: "style,script,iframe", - sequenceDiagram: true, - autoFocus: false, - placeholder: placeholder, - toolbarIcons: function () { - // Or return editormd.toolbarModes[name]; // full, simple, mini - // Using "||" set icons align right. - return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"] - }, - toolbarCustomIcons: { - testIcon: "
    ", - testIcon1: "
    " - }, - //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 - saveHTMLToTextarea: true, - // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标 - dialogMaskOpacity: 0.6, - imageUpload: true, - imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], - imageUploadURL: imageUrl,//url - onload: function () { - // this.previewing(); - $("#" + id + " [type=\"latex\"]").bind("click", function () { - editorName.cm.replaceSelection("```latex"); - editorName.cm.replaceSelection("\n"); - editorName.cm.replaceSelection("\n"); - editorName.cm.replaceSelection("```"); - var __Cursor = editorName.cm.getDoc().getCursor(); - editorName.cm.setCursor(__Cursor.line - 1, 0); - }); - - $("#" + id + " [type=\"inline\"]").bind("click", function () { - editorName.cm.replaceSelection("`$$$$`"); - var __Cursor = editorName.cm.getDoc().getCursor(); - editorName.cm.setCursor(__Cursor.line, __Cursor.ch - 3); - editorName.cm.focus(); - }); - $("[type=\"inline\"]").attr("title", "行内公式"); - $("[type=\"latex\"]").attr("title", "多行公式"); - - callback && callback() - } - }); - return editorName; -} - - -function updatamakedown(id){ - setTimeout(()=>{ - var shixunDescr = window.editormd.markdownToHTML(id, { - htmlDecode: "style,script,iframe", - taskList: true, - tex: true, - flowChart: true, - sequenceDiagram: true - }); - $("#"+id+" p:first").addClass("ReactMarkdown"); - $('#collaborators_list_info').show() - }, 200) -} - -function range(start, end) { - const result = []; - for (let i = start; i < end; i++) { - result.push(i); - } - return result; -} -function disabledDateTime() { - return { - // disabledHours: () => range(0, 24).splice(4, 20), - disabledMinutes: () => range(1, 30).concat(range(31, 60)), - // disabledSeconds: () => [0, 60], - }; -} - -function disabledDate(current) { - return current && current < moment().endOf('day').subtract(1, 'days'); -} -export default class TPMsettings extends Component { - constructor(props) { - super(props) - this.state = { - fileList: [], - commandLine: 0, - Openpublic: 0, - settingsData: undefined, - webssh: 0, - use_scope: 0, - shixunsstatus: 0, - shixunsID: undefined, - exec_time: undefined, - trainee: undefined, - can_copy: undefined, - task_pass: undefined, - test_set_permission: undefined, - code_edit_permission: undefined, - hide_code: undefined, - code_hidden: undefined, - forbid_copy: undefined, - vnc: undefined, - name: undefined, - scope_partment: undefined, - scopetype: false, - departmentslist: undefined, - description: '', - evaluate_script:undefined, - standard_scripts: undefined, - choice_main_type: "", - choice_small_type: [], - choice_standard_scripts:undefined, - editordescriptios: undefined, - editorevaluate_scripts: undefined, - choice_standard_scriptssum: undefined, - visibleTemplate: false, - Executiveordervalue: "", - Compilecommandvalue: "", - Executivetyoe: false, - postapplyvisible: false, - sendsure_applyvalue: undefined, - postapplytitle: false, - shixunnametype: false, - shixunmaintype: false, - evaluate_scripttype: false, - exec_timetype: false, - traineetype: false, - standard_scriptsModal:false, - standard_scriptsModals:false, - SelectTheCommandtype:false, - multi_webssh:false, - status:0, - opers:false, - operss:false, - testscripttiptype:false, - opersss:false, - operateshixunstype:false, - opening_time:"", - opensmail:false, - scope_partmenttype:false, - newuse_scope:undefined, - scope_partments:0, - shixun_service_configs:undefined, - shixun_service_configlist:undefined, - pod_exist_time: undefined, - pod_exist_timetype: false, - shixunmemoMDvalue:"", - language:"", - deleteisnot:true - } - } - descriptionMD=(initValue, id)=> { - - this.contentChanged = false; - const placeholder = ""; -// amp; -// 编辑时要传memoId - const imageUrl = `/api/attachments.json`; -// 创建editorMd - - const description_editormd =create_editorMD(id, '100%', 400, placeholder, imageUrl, initValue,()=> { - setTimeout(() => { - description_editormd.resize() - description_editormd.cm && description_editormd.cm.refresh() - }, 500) - - if (initValue != undefined) { - description_editormd.setValue(initValue) - } - description_editormd.cm.on("change", (_cm, changeObj) => { - console.log('....contentChanged') - this.contentChanged = true; - }) - }); - md_elocalStorage(description_editormd, `MemoQuestion_${id}`, `${id}Question`); - this.description_editormd = description_editormd; - window.description_editormd = description_editormd; - } - - evaluate_scriptMD=(initValue, id)=> { - this.contentChanged = false; - const placeholder = ""; -// amp; -// 编辑时要传memoId - const imageUrl = `/api/attachments.json`; -// 创建editorMd - - const evaluate_script_editormd =create_editorMD(id, '100%', 400, placeholder, imageUrl, initValue,()=> { - setTimeout(() => { - evaluate_script_editormd.resize() - evaluate_script_editormd.cm && evaluate_script_editormd.cm.refresh() - }, 500) - - if (initValue != undefined) { - evaluate_script_editormd.setValue(initValue) - } - evaluate_script_editormd.cm.on("change", (_cm, changeObj) => { - console.log('....contentChanged') - this.contentChanged = true; - }) - }); - md_elocalStorage(evaluate_script_editormd, `MemoQuestion_${id}`, `${id}Question`); - this.evaluate_script_editormd = evaluate_script_editormd; - window.evaluate_script_editormd = evaluate_script_editormd; - - } - - - - componentDidMount() { - - let id=this.props.match.params.shixunId; - - let Url=`/shixuns/`+id+`/settings.json`; - - axios.get(Url).then((response)=> { - // alert(response.data.shixun.choice_standard_scripts) - if(response.status===200){ - this.setState({ - shixunsID: id, - settingsData: response.data, - webssh: response.data.shixun.webssh, - use_scope: response.data.shixun.use_scope, - shixunsstatus: response.data.shixun.status, - exec_time: response.data.shixun.exec_time, - trainee: response.data.shixun.trainee, - can_copy: response.data.shixun.can_copy, - task_pass: response.data.shixun.task_pass, - test_set_permission: response.data.shixun.test_set_permission, - hide_code: response.data.shixun.hide_code, - code_edit_permission: response.data.shixun.code_edit_permission, - code_hidden: response.data.shixun.code_hidden, - is_secret_repository: response.data.shixun.is_secret_repository, - init_is_secret_repository: response.data.shixun.is_secret_repository, - forbid_copy: response.data.shixun.forbid_copy, - vnc: response.data.shixun.vnc, - vnc_evaluate: response.data.shixun.vnc_evaluate, - name: response.data.shixun.name, - scope_partment: response.data.shixun.scope_partment, - description: response.data.shixun.description, - evaluate_script: response.data.shixun.evaluate_script, - choice_main_type: response.data.shixun.choice_main_type, - choice_small_type: response.data.shixun.choice_small_type, - choice_standard_scripts: response.data.shixun.choice_standard_scripts, - standard_scripts:response.data.shixun.standard_scripts, - multi_webssh:response.data.shixun.multi_webssh, - status:response.data.shixun.status, - opening_time:response.data.shixun.opening_time, - newuse_scope:response.data.shixun.use_scope, - scope_partments: response.data.shixun.scope_partment.length, - shixunmemoMDvalue:response.data.shixun.evaluate_script, - shixun_service_configs:response.data.shixun.shixun_service_configs, - shixun_service_configlist:response.data.shixun.shixun_service_configs, - }) - - // if(response.data.status===403){ - // message: "您没有权限进行该操作" - // this.setState({ - // :true - // message403:response.data.message - // }) - // } - - - if(response.data.shixun.multi_webssh===true){ - this.setState({ - SelectTheCommandtype:true - }) - }else{ - this.setState({ - SelectTheCommandtype:false - }) - } - if (response.data.shixun.scope_partment.length > 0) { - this.setState({ - scopetype: true - }) - } - // console.log(response.data.shixun.description) - // console.log(response.data.shixun.evaluate_script) - // console.log(response.data.shixun.description) - // this.props.identity<4&&this.props.status==0||this.props.identity===1&&this.props.status==2 - - - // this.evaluate_scriptMD(response.data.shixun.evaluate_script, "shixunmemoMD"); - - this.descriptionMD(response.data.shixun.description, "shixundescription"); - - // this.bigClass() - // if (response.data.shixun.status === 2) { - // - // } else if (response.data.shixun.status === 1) { - // this.props.showSnackbar("这个实训已发布不能修改!"); - // } else if (response.data.shixun.status === 3) { - // this.props.showSnackbar("这个实训已关闭不能修改!"); - // } - } - - }); - - - 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 - }); - } - } - }).catch((error) => { - console.log(error) - }); - - - - } - - SelectshixunCommand=(e)=>{ - // console.log( e.target.value) - const webssh = e.target.value - if (webssh == 2) { - this.setState({ - webssh: webssh, - SelectTheCommandtype: true, - multi_webssh:false - }); - } else { - if (this.state.init_is_secret_repository && !this.state.vnc && this.state.is_secret_repository == true) { - this.confirmDeleteSecretRepo({ - onOk: () => { - this.setState({ - webssh: webssh, - SelectTheCommandtype: false, - multi_webssh:false - }); - } - }) - } else { - if (!this.state.vnc) { - this.setState({ - is_secret_repository: false, - }) - } - this.setState({ - webssh: webssh, - SelectTheCommandtype: false, - multi_webssh:false - }); - } - } - - // this.setState({ - // webssh: webssh, - // }); - // if(webssh===2){ - // this.setState({ - // SelectTheCommandtype: true, - // multi_webssh:false - // }); - // }else{ - // this.setState({ - // SelectTheCommandtype: false, - // multi_webssh:false - // }); - // } - } - - SelectOpenpublic=(e)=>{ - this.setState({ - Openpublic: e.target.value - }); - } - - can_copy=(e)=>{ - let sum = "" - if (e.target.checked === false) { - sum = 0 - } else if (e.target.checked === true) { - sum = 1 - } - this.setState({ - can_copy: sum, - }); - - } - - task_pass=(e)=>{ - - let sum = "" - if (e.target.checked === false) { - sum = 0 - } else if (e.target.checked === true) { - sum = 1 - } - this.setState({ - task_pass: sum, - }); - } - - test_set_permission=(e)=>{ - let sum = "" - if (e.target.checked === false) { - sum = 0 - } else if (e.target.checked === true) { - sum = 1 - } - this.setState({ - test_set_permission: sum, - }); - - } - - hide_code=(e)=>{ - let sum = "" - if (e.target.checked === false) { - sum = 0 - } else if (e.target.checked === true) { - sum = 1 - } - this.setState({ - hide_code: sum, - }); - - } - code_edit_permission = (e) => { - this.setState({ - code_edit_permission: e.target.checked - }) - } - code_hidden=(e)=>{ - let sum = "" - if (e.target.checked === false) { - sum = 0 - } else if (e.target.checked === true) { - sum = 1 - } - this.setState({ - code_hidden: sum, - }); - - } - confirmDeleteSecretRepo = ({title, onOk}) => { - confirm({ - title: title ||
    -
    已创建的私密版本库及其内容,将在“保存”时被删除。
    -
    是否确认取消勾选?
    -
    , - okText: '确定', - cancelText: '取消', - onOk: () => { - this.setState({ is_secret_repository: false }) - onOk && onOk() - }, - onCancel() { - }, - }); - } - is_secret_repository = (e) => { - const checked = e.target.checked - if (!checked) { - if (this.state.init_is_secret_repository) { - this.confirmDeleteSecretRepo({ - }) - } else { - this.setState({ is_secret_repository: false }) - } - } else { - this.setState({ is_secret_repository: true }) - } - } - forbid_copy = (e) => { - let sum = "" - if (e.target.checked === false) { - sum = 0 - } else if (e.target.checked === true) { - sum = 1 - } - this.setState({ - forbid_copy: sum, - }); - } - shixun_vnc_evaluate=(e) => { - this.setState({ - vnc_evaluate: e.target.checked, - }); - - } - - shixun_vnc=(e)=>{ - // let sum = "" - // if (e.target.checked === false) { - // sum = 0 - // } else if (e.target.checked === true) { - // sum = 1 - // } - const vnc = e.target.checked; - if (!vnc) { - if (this.state.init_is_secret_repository && this.state.webssh != 2 && this.state.is_secret_repository == true) { - this.confirmDeleteSecretRepo({ - onOk: () => { - this.setState({ - vnc: e.target.checked, - vnc_evaluate: false, - }); - } - }) - } else { - if (this.state.webssh != 2) { - this.setState({ - is_secret_repository: false - }) - } - this.setState({ - vnc: e.target.checked, - vnc_evaluate: false, - }); - } - } else { - this.setState({ - vnc: e.target.checked, - vnc_evaluate: false, - }); - } - } - shixunsname = (e) => { - // let {shixunsstatus}=this.state; - // if(shixunsstatus>0){ - // return - // } - this.setState({ - name: e.target.value, - shixunnametype:false - }) - } - - bigClass = (value) => { - // choice_main_type - // choice_small_type - let {settingsData,shixun_service_configs,choice_main_type,choice_small_type}=this.state; - - let list=[] - list.push(choice_main_type) - choice_small_type.map((item,key)=>{ - list.push(item) - }) - - let newshixun_service_configs=shixun_service_configs; - - let newshixun_service_configsagin=[] - - newshixun_service_configs.map((item,key)=>{ - list.map((its,index)=>{ - if(item.mirror_repository_id===its){ - newshixun_service_configsagin.push(item) - } - }) - }) - - - settingsData.shixun.main_type.some((item,key)=> { - if (item.id === value) { - newshixun_service_configsagin[0]={ - mirror_repository_id:value, - name:item.type_name, - cpu_limit:1, - lower_cpu_limit:0.1, - memory_limit:1024, - request_limit:10 - } - return true - } - } - ) - let url = `/shixuns/get_mirror_script.json?mirror_id=`+value; - axios.get(url).then((response) => { - if (response.status === 200) { - // console.log(response.data) - this.setState({ - choice_main_type: value, - standard_scripts:response.data, - choice_standard_scripts:null, - shixun_service_configs:newshixun_service_configsagin, - shixun_service_configlist:newshixun_service_configsagin, - }) - } - }).catch((error) => { - console.log(error) - }); - - - - } - Deselectlittle=(value)=>{ - - let {shixun_service_configs,choice_small_type}=this.state; - let newshixun_service_configs=shixun_service_configs; - let newchoice_small_type=choice_small_type; - - newshixun_service_configs.some((item,key)=> { - if (item.mirror_repository_id === value) { - newshixun_service_configs.splice(key, 1) - return true - } - } - ) - - newchoice_small_type.some((item,key)=> { - if (item === value) { - newchoice_small_type.splice(key, 1) - return true - } - } - ) - - - this.setState({ - choice_small_type: newchoice_small_type, - shixun_service_configs:newshixun_service_configs, - shixun_service_configlist:newshixun_service_configs, - }) - } - littleClass = (value) => { - - let {settingsData,shixun_service_configs,choice_small_type,choice_main_type}=this.state; - let newshixun_service_configs=shixun_service_configs; - let newchoice_small_type=choice_small_type; - // if(Array.isArray(value)===true){ - // value.map((item,key)=>{ - // settingsData.shixun.small_type.some((items,keys)=> { - // if (items.id === item) { - // newshixun_service_configs.push({ - // mirror_repository_id:value, - // name:items.type_name, - // cpu_limit:1, - // lower_cpu_limit:0.1, - // memory_limit:1024, - // request_limit:10 - // }) - // return true - // } - // } - // ) - // }) - // } - - let list=[] - list.push(choice_main_type) - choice_small_type.map((item,key)=>{ - list.push(item) - }) - - let newshixun_service_configsagin=[] - - newshixun_service_configs.map((item,key)=>{ - list.map((its,index)=>{ - if(item.mirror_repository_id===its){ - newshixun_service_configsagin.push(item) - } - }) - }) - - settingsData.shixun.small_type.some((items,keys)=> { - if (items.id === value) { - newshixun_service_configsagin.push({ - mirror_repository_id:value, - name:items.type_name, - cpu_limit:1, - lower_cpu_limit:0.1, - memory_limit:1024, - request_limit:10 - }) - return true - } - } - ) - - newchoice_small_type.push(value) - - this.setState({ - choice_small_type: newchoice_small_type, - shixun_service_configs:newshixun_service_configsagin, - shixun_service_configlist:newshixun_service_configsagin, - }) - } - onPodExistTimeChange = (e) => { - this.setState({ - pod_exist_time: e.target.value, - pod_exist_timetype: false, - }) - } - Timevalue = (e) => { - this.setState({ - exec_time: e.target.value - }) - } - SelectOpenpublic = (e) => { - this.setState({ - scopetype: false, - use_scope: e.target.value, - }); - if (e.target.value === 1) { - this.setState({ - scopetype: true - }); - } - - } - deleteScopeInput = (key) => { - let {scope_partment} = this.state; - let datalist = scope_partment; - datalist.splice(key, 1); - this.setState({ - scope_partment: datalist - }); - } - - shixunScopeInput = (e) => { - let {scope_partment} = this.state; - let datalist = scope_partment; - if (datalist===undefined) { - datalist=[] - } - - datalist.push(e) - // else { - // datalist[id] = e - // } - this.setState({ - scope_partment: datalist - }); - } - // adduse_scopeinput = () => { - // let {scope_partment} = this.state; - // let array = scope_partment; - // let newarray = "" - // array.push(newarray) - // this.setState({ - // scope_partment: array, - // }); - // } - submit_edit_shixun = () => { - if (this.saving == true) return; - this.saving = true; - if(this.state.status===-1){ - this.props.showSnackbar("该实训已被删除,保存失败!"); - return - } - - let { - name, choice_main_type, choice_small_type, choice_standard_scripts, scope_partment, choice_standard_scriptssum, vnc_evaluate, - evaluate_script, webssh, use_scope, trainee, can_copy, task_pass, test_set_permission, hide_code, code_hidden, forbid_copy, vnc,multi_webssh, - opening_time,shixunmemoMDvalue,shixun_service_configlist, is_secret_repository, code_edit_permission - } = this.state; - - let newshixun_service_configlist = shixun_service_configlist.map(v => { - let v1 = Object.assign({},v); - delete v1.name; - return v1 - }); - - // let operateauthority= - // this.props.identity===1?true:this.props.identity<5&&this.state.status==0?true:false; - // this.props.identity<5&&this.state.status==0||this.props.identity===1&&this.state.status==2||this.props.identity===1&&this.state.status==1; - - const description_editormd = this.description_editormd.getValue(); - - let evaluate_script_editormd; - - if(this.state.status==0||this.state.status==1||this.state.status==2&&this.props.identity===1){ - // evaluate_script_editormd = this.evaluate_script_editormd.getValue(); - evaluate_script_editormd = shixunmemoMDvalue - }else{ - evaluate_script_editormd = evaluate_script; - } - - - - if (name === "") { - this.setState({ - shixunnametype: true - }) - $('html').animate({ - scrollTop: 10 - }, 1000); - return - } - if (choice_main_type === "") { - this.setState({ - shixunmaintype: true - }) - $('html').animate({ - scrollTop: 800 - }, 1000); - return - } - if (evaluate_script_editormd === "") { - this.setState({ - evaluate_scripttype: true - }) - $('html').animate({ - scrollTop: 1200 - }, 1000); - return - } - if(use_scope===1){ - - if(scope_partment===undefined||scope_partment.length===0){ - this.setState({ - scope_partmenttype: true - }) - $('html').animate({ - scrollTop: 2500 - }, 1000); - this.props.showSnackbar("公开程度,指定单位为空"); - return - } - } - // if (exec_time === "") { - // this.setState({ - // exec_timetype: true - // }) - // $('html').animate({ - // scrollTop: 1500 - // }, 1000); - // return - // } - - // if (!pod_exist_time) { - // this.setState({ - // pod_exist_timetype: true - // }) - // $("html, body").animate({ scrollTop: $('#pod_exist_time').offset().top - 100 }, 1000) - // return - // } - - if (trainee === "") { - this.setState({ - traineetype: true - }) - return - } - - let id = this.props.match.params.shixunId; - - let newmulti_webssh=multi_webssh; - - - if(newmulti_webssh===null){ - newmulti_webssh=false - } - - //exec_time: exec_time, - let Url = `/shixuns/` + id + `.json`; - let data = { - shixun:{ - - name: name, - webssh: webssh, - use_scope: use_scope, - can_copy: can_copy, - vnc: vnc===null?undefined:vnc, - vnc_evaluate: vnc_evaluate===null?undefined:vnc_evaluate, - test_set_permission: test_set_permission, - code_hidden: code_hidden, - code_edit_permission: code_edit_permission, - trainee: trainee, - task_pass: task_pass, - hide_code: hide_code, - forbid_copy: forbid_copy, - multi_webssh:newmulti_webssh, - opening_time:opening_time, - mirror_script_id:choice_standard_scriptssum===undefined?choice_standard_scripts:choice_standard_scriptssum, - }, - shixun_info:{ - description: description_editormd, - evaluate_script: evaluate_script_editormd, - }, - is_secret_repository: is_secret_repository, - main_type: choice_main_type, - small_type: choice_small_type, - scope_partment: scope_partment, - shixun_service_configs:newshixun_service_configlist - } - - axios.put(Url, data).then((response) => { - // console.log(response) - this.saving = false; - if(response.status){ - if (response.data.status === -1) { - this.props.showSnackbar(response.data.message); - return - } else { - window.location.href = "/shixuns/" + response.data.shixun_identifier + "/challenges"; - } - } - - }).catch((error) => { - console.log(error) - this.saving = false; - }) - - - } - shixunsfetch = (value, callback) => { - if (timeout) { - clearTimeout(timeout); - timeout = null; - } - currentValue = value; - - function fake() { - let departmentsUrl = `/shixuns/departments.json?q=` + currentValue; - axios.get(departmentsUrl).then((response) => { - callback(response.data.shools_name); - }).catch((error) => { - console.log(error) - }); - } - - timeout = setTimeout(fake, 300); - } - shixunHandleSearch = (value) => { - this.shixunsfetch(value, departmentslist => this.setState({departmentslist})); - } - - - - - shixunsclose = () => { - let id = this.props.match.params.shixunId; - let cul = `/shixuns/` + id + `/close.json`; - axios.post(cul).then((response) => { - if(response.data.status===1){ - this.props.showSnackbar("操作成功"); - this.setState({ - operateshixunstype: false, - }); - - window.location.href = "/shixuns/" + id + "/challenges"; - } - }).catch((error) => { - console.log(error) - }) - } - - shixunsdel= () => { - let id = this.props.match.params.shixunId; - let cul = `/shixuns/` + id +`.json`; - - axios.delete(cul).then((response) => { - if(response.data.status===1){ - this.props.showSnackbar("操作成功"); - this.setState({ - operateshixunstype: false, - }); - - window.location.href = "/shixuns"; - } - }).catch((error) => { - console.log(error) - }) - } - - Executiveorder = (e) => { - this.setState({ - Executiveordervalue: e.target.value - }) - } - - Compilecommand = (e) => { - this.setState({ - Compilecommandvalue: e.target.value - }) - } - - handleCancelTemplate = (e) => { - this.setState({ - Executiveordervalue: "", - Compilecommandvalue: "", - visibleTemplate: false - }) - } - - hideModalTemplate = (e) => { - let id = this.props.match.params.shixunId; - let {Executiveordervalue, Compilecommandvalue} = this.state; - - if (Executiveordervalue === "") { - this.setState({ - Executivetyoe: true, - }); - return - } - // Executiveordervalue=String(Executiveordervalue); - // Compilecommandvalue=String(Compilecommandvalue); - let trl = `/shixuns/${id}/get_custom_script.json?compile=${Executiveordervalue}&excutive=${Compilecommandvalue}` - axios.get(trl).then((response) => { - // this.evaluate_scriptMD(response.data.shixun_script, "shixunmemoMD"); - this.setState({ - shixunmemoMDvalue:response.data.shixun_script - }) - }).catch((error) => { - console.log(error) - }); - this.setState({ - visibleTemplate: false - }) - } - - showModal = () => { - this.setState({ - visibleTemplate: true, - }); - } - Selecttrainee = (value) => { - this.setState({ - trainee: value, - }); - } - - post_apply = () => { - this.setState({ - postapplyvisible: true - }) - } - - sendsure_applyvalues = (e) => { - this.setState({ - sendsure_applyvalue: e.target.value - }) - } - - setlanguagewrite = (e)=>{ - this.setState({ - languagewrite: e.target.value - }) - } - - setsystemenvironment = (e) => { - this.setState({ - systemenvironment: e.target.value - }) - } - - settestcoderunmode = (e) => { - this.setState({ - testcoderunmode: e.target.value - }) - - } - - sendsure_apply = () => { - let {languagewrite,systemenvironment,testcoderunmode} = this.state; - // console.log("点击确定") - // console.log("languagewrite"+languagewrite); - // console.log("systemenvironment"+systemenvironment); - // console.log("testcoderunmode"+testcoderunmode); - - // let attachment_ids = undefined - // if (this.state.fileList) { - // attachment_ids = this.state.fileList.map(item => { - // return item.response ? item.response.id : item.id - // }) - // } - if(languagewrite === undefined || languagewrite === "" ){ - // this.props.showNotification(`请填写该镜像是基于什么语言`); - this.setState({ - languagewritetype:true - }) - return - } - if(systemenvironment === undefined || systemenvironment === ""){ - // this.props.showNotification(`请填写该镜像是基于什么语言系统环境`); - this.setState({ - systemenvironmenttype:true - }) - return; - - } - if(testcoderunmode === undefined || testcoderunmode === "") { - // this.props.showNotification(`请填写该镜像中测试代码运行方式`); - this.setState({ - testcoderunmodetype:true - }) - return; - } - var attachment_ids=undefined; - if (this.state.fileList) { - attachment_ids = this.state.fileList.map(item => { - return item.response ? item.response.id : item.id - }) - } - - if( attachment_ids === undefined || attachment_ids.length===0){ - - // notification.open( - // { - // message: '提示', - // description: - // '请上传附件!', - // - // } - // ) - this.setState({ - attachmentidstype:true - }) - return; - } - // console.log("attachment_ids"+attachment_ids); - - // alert(languagewrite +" "+systemenvironment +" "+testcoderunmode + " "+attachment_ids); - - var data={ - language:languagewrite, - runtime:systemenvironment, - run_method:testcoderunmode, - attachment_id:attachment_ids[0], - } - var url =`/shixuns/apply_shixun_mirror.json`; - axios.post(url,data - ).then((response) => { - - try { - if (response.data) { - // const { id } = response.data; - // if (id) { - if(this.state.file !== undefined){ - console.log("549"); - // this.deleteAttachment(this.state.file); - this.setState({ - file:undefined, - deleteisnot:true, - languagewrite:"", - systemenvironment:"", - testcoderunmode:"", - fileList:[] - }) - }else { - this.setState({ - file:undefined, - deleteisnot:true, - languagewrite:"", - systemenvironment:"", - testcoderunmode:"", - fileList:[] - }) - } - // this.props.showNotification('提交成功!'); - notification.open( - { - message: '提示', - description: - '提交成功!', - - } - ) - this.sendhideModaly() - // this.props.history.push(`/courses/${cid}/graduation_topics`); - // } - } - }catch (e) { - - } - - }) - - } - - sendhideModaly = () => { - this.setState({ - postapplyvisible: false, - }) - if(this.state.file !== undefined){ - console.log("580"); - // this.deleteAttachment(this.state.file); - this.setState({ - file:undefined, - deleteisnot:true, - languagewrite:"", - systemenvironment:"", - testcoderunmode:"", - fileList:[] - }) - }else { - this.setState({ - file:undefined, - deleteisnot:true, - languagewrite:"", - systemenvironment:"", - testcoderunmode:"", - fileList:[] - }) - } - } - - yeshidemodel = () => { - this.setState({ - postapplytitle: false - }) - } - - SelectScput = (value, e) => { - this.setState({ - choice_standard_scriptssum: value, - language:e.props.name, - choice_standard_scripts: {id:e.props.value,value:""}, - standard_scriptsModal:true - }) - } - - hidestandard_scriptsModal=()=>{ - this.setState({ - standard_scriptsModal:false, - standard_scriptsModals:false - }) - } - - get_mirror_script=()=>{ - let {choice_standard_scriptssum}=this.state; - let id = this.props.match.params.shixunId; - let pul = "/shixuns/" + id + "/get_script_contents.json?script_id=" + choice_standard_scriptssum; - axios.get(pul).then((response) => { - if(response.status===200){ - // this.evaluate_scriptMD(response.data.content, "shixunmemoMD"); - this.setState({ - standard_scriptsModal:false, - standard_scriptsModals:true, - shixunmemoMDvalue:response.data.content - }) - } - - }).catch((error) => { - console.log(error) - }) - } - - - SelectTheCommandonChange=(e)=>{ - this.setState({ - multi_webssh:e.target.checked - }) - } - - bigopen=()=>{ - this.setState({ - opers:true - }) - - } - - bigopens=()=>{ - this.setState({ - opers:false, - operss:false, - opersss:false, - opensmail:false - }) - - } - bigopensmal=(e)=>{ - this.setState({ - opensmail:true - }) - - } - sbigopen=(e)=>{ - this.setState({ - operss:true - }) - - } - - sbigopens=()=>{ - this.setState({ - operss:false - }) - } - sbigopenss=(e)=>{ - this.setState({ - opersss:true - }) - - } - - sbigopensss=()=>{ - this.setState({ - opersss:false - }) - } - testscripttip=(val)=>{ - if(val===0){ - this.setState({ - testscripttiptype:true - }) - }else if(val===1){ - this.setState({ - testscripttiptype:false - }) - } - } - - operateshixuns=(value)=>{ - this.setState({ - operateshixunstype:true, - delType:value - }) - } - - hideoperateshixuns=()=>{ - this.setState({ - operateshixunstype:false - }) - } - onChangeTimePicker =(value, dateString)=> { - this.setState({ - opening_time: dateString=== ""?"":moment(handleDateStrings(dateString)) - }) - } - - getshixunmemoMDvalue=(value, e)=>{ - - this.setState({ - shixunmemoMDvalue:value - }) - } - - setConfigsInputs=(e,keys,str)=>{ - - let {shixun_service_configs}=this.state; - let newshixun_service_configs=shixun_service_configs; - newshixun_service_configs.map((item,key)=>{ - if(key===keys){ - switch (str) { - case 1: - item.cpu_limit=e.target.value - break; - case 2: - item.lower_cpu_limit=e.target.value - break; - case 3: - item.memory_limit=e.target.value - break; - case 4: - item.request_limit=e.target.value - break; - } - } - }) - - this.setState({ - shixun_service_configs:newshixun_service_configs, - shixun_service_configlist:newshixun_service_configs, - }) - - } - - handleChange = (info) => { - let {fileList}=this.state; - - if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') { - console.log("handleChange1"); - - // if(fileList.length===0){ - let fileLists = info.fileList; - this.setState({ fileList:fileLists, - deleteisnot:false}); - // } - } - } - - onAttachmentRemove = (file) => { - if(!file.percent || file.percent == 100){ - confirm({ - title: '确定要删除这个附件吗?', - okText: '确定', - cancelText: '取消', - // content: 'Some descriptions', - onOk: () => { - console.log("665") - this.deleteAttachment(file) - }, - onCancel() { - console.log('Cancel'); - }, - }); - return false; - } - - } - - deleteAttachment = (file) => { - console.log(file); - let id=file.response ==undefined ? file.id : file.response.id - const url = `/attachments/${id}.json` - axios.delete(url, { - }) - .then((response) => { - if (response.data) { - const { status } = response.data; - if (status == 0) { - // console.log('--- success') - - this.setState((state) => { - - const index = state.fileList.indexOf(file); - const newFileList = state.fileList.slice(); - newFileList.splice(index, 1); - return { - fileList: newFileList, - deleteisnot:true - }; - }); - } - } - }) - .catch(function (error) { - console.log(error); - }); - } - - - - render() { - let { - postapplyvisible, - postapplytitle, - shixunnametype, - shixunmaintype, - evaluate_scripttype, - traineetype, - standard_scripts, - name, - settingsData, - webssh, - is_secret_repository, - use_scope, - shixunsID, - can_copy, - choice_standard_scripts, - Executiveordervalue, - Executivetyoe, - Compilecommandvalue, - task_pass, - test_set_permission, - hide_code, - forbid_copy, - code_edit_permission, - code_hidden, - vnc, - vnc_evaluate, - scopetype, - scope_partment, - departmentslist, - trainee, - choice_main_type, - choice_small_type, - standard_scriptsModal, - standard_scriptsModals, - SelectTheCommandtype, - testscripttiptype, - operateshixunstype, - opening_time, - scope_partmenttype, - newuse_scope, - scope_partments, - shixunmemoMDvalue,delType, - shixun_service_configs, - fileList, - } = this.state; - - let options; - - if (departmentslist != undefined) { - options = this.state.departmentslist.map((d, k) => { - return ( - - ) - }) - } - const uploadProps = { - width: 600, - fileList, - multiple: true, - // https://github.com/ant-design/ant-design/issues/15505 - // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 - // showUploadList: false, - action: `${getUploadActionUrl()}`, - onChange: this.handleChange, - onRemove: this.onAttachmentRemove, - beforeUpload: (file, fileList) => { - if (this.state.fileList.length >= 1) { - return false - } - // console.log('beforeUpload', file.name); - const isLt150M = file.size / 1024 / 1024 < 50; - if (!isLt150M) { - // this.props.showNotification(`文件大小必须小于50MB`); - notification.open( - { - message: '提示', - description: - '文件大小必须小于50MB', - - } - ) - } - if(this.state.file !== undefined){ - console.log("763") - this.setState({ - file:file - }) - }else { - this.setState({ - file:file - }) - } - - console.log("handleChange2"); - return isLt150M; - }, - } - const dateFormat = 'YYYY-MM-DD HH:mm:ss'; - let operateauthority=this.props.identity===1?true:this.props.identity<5&&this.state.status==0?true:false; - - return ( -
    - - 实训详情 - 配置 - - -
    -
    - 配置 - { - this.props.identity===1&&this.state.status==2? - this.operateshixuns(2)}> - 永久关闭 - :"" - } - { - this.props.identity < 5 && this.state.status==0? - this.operateshixuns(1)}> - 删除实训 - :"" - } - { - this.props.identity == 1 && this.state.status == 2 ? - this.operateshixuns(1)}> - 删除实训 - :"" - } - - -
    - {delType===1?

    是否确认删除 ?

    :

    关闭后,
    用户不能再开始挑战了是否确认关闭 ?

    } -
    -
    - 取消 - {delType===1?确定:确定} -
    -
    - -
    - -
    - -

    实训名称

    - -
    - * -
    -
    - {settingsData === undefined ? "" : - } -
    -
    - 必填项 -
    -
    - - -
    - -
    -
    - -
    - -

    简介

    - -
    - -
    -
    -
    -

    -

    -
    - -
    -
    -

    技术平台

    - - -
    - * -
    - -

    - 列表中没有? - 申请新建 -

    - - -
    -
  • - - -
  • -
    {this.state.languagewritetype===true?"请填写该镜像语言":""}
    -
  • - - -
  • -
    {this.state.systemenvironmenttype===true?"请填写该镜像语言系统环境":""}
    -
  • - - - -
  • -
    {this.state.testcoderunmodetype===true?"请填写该镜像测试代码运行方式":""}
    -
  • - -
    - - - 上传附件 - (单个文件50M以内) - -
    -
  • -
    - {this.state.attachmentidstype===true?"请上传附件":""} -
    -
  • - this.sendhideModaly()} - >取消 - -
  • -
    -
    - -
    - - - - - -
    -

    新建申请已提交,请等待管理员的审核

    -
  • 我们将在1-2个工作日内与您联系 -
  • -
    -
    - 知道啦 -
    -
    -
    -
    - -
    - -
    -
    - 必填项 -
    - {/*

    请在配置页面完成后续的评测脚本设置操作

    */} - -
    -
    - {/*
    */} - {/*
    */} -
    -

    评测脚本

    -
    - - -
    -

    原有脚本将被新的脚本覆盖,无法撤销

    -

    是否确认执行覆盖操作

    -
    - - -
    - - -

    评测脚本生成成功!

    - -
    - - { - this.props.identity<5||this.props.power==true? - 使用自定义脚本 : "" - } -
    - this.testscripttip(0)}> -
    - -
    -

    - 使用自定义模板,平台无法自动更新脚本,
    - 请在关卡创建完后手动更新脚本中的必填参
    - 数和以下2个数组元素:
    - challengeProgramNames
    - sourceClassNames

    - 示例:有2个关卡的实训

    - 各关卡的待编译文件为:
    - src/step1/HelloWorld.java
    - src/step2/Other.java

    - 各关卡的编译后生成的执行文件为:
    - step1.HelloWorld
    - step2.Other

    - 则数组元素更新如下:
    - challengeProgramNames=("src/step1/
    - HelloWorld.java" "src/step2/Other.java")
    - sourceClassNames=("step1.HelloWorld
    - " "step2.Other")

    - 其它参数可按实际需求定制 -

    -
    -

    - this.testscripttip(1)}>知道了 -

    -
    -
    - - -
    -
  • - - -

    执行命令不能为空

    -
  • - -
  • - - -
  • -
    -
    -
    -
    - -
    -
    - * -
    - - -
    - {/**/} - -
    - - - {/*
    */} - {/*{evaluate_script===undefined?"":evaluate_script}*/} - - {/*
    */} - - - -
    - -
    -
    -
    - - 必填项 -
    -

    -

    -
    -
    - - {/*
    */} - {/***/} - - {/*

    程序最大执行时间

    */} - - {/* 秒*/} - - {/*
    */} - {/*必填项*/} - {/*
    */} - {/*
    */} - - {/*
    - * - -

    Pod存活时间

    - - - -
    - 必填项 -
    -
    */} - - -
    -

    命令行

    - - 无命令行窗口 (选中则不给学员的实践任务提供命令窗口) - 命令行练习窗口 (选中则给学员提供用于练习操作的命令行窗口) - 命令行评测窗口 (选中则给学员提供用于关卡评测的命令行窗口) - - 多个命令行窗口(选中则允许学员同时开启多个命令行窗口) - - -
    - -
    -

    公开程度

    - - 对所有公开 (选中则所有已被试用授权的用户可以学习) - 对指定单位公开 (选中则下方指定单位的已被试用授权的用户可以学习) - - -
    -
    -
    -
    -
    - -
    - (搜索并选中添加单位名称) -
    - {/*+*/} - {/*添加*/} -
    - -
    - - {/*{*/} - {/*scope_partment===undefined?"":scope_partment.map((item,key)=>{*/} - {/*return(*/} - {/*
    */} - {/*this.deleteScopeInput(key)} style={{ color: 'rgba(0,0,0,.25)' }} />}*/} - {/*value={item}*/} - {/*/>*/} - {/*
    */} - - {/*)*/} - {/*})*/} - {/*}*/} -
    - - - 请选择需要公开的单位 - -
    -
    -
    - -
    -

    发布信息

    - -
    - * - 面向学员: - -
    - -
    - 实训难易度定位,不限定用户群体 -
    - 必填项 -
    - -
    -
    - 复制: - - - - -
    - -
    - 跳关: - - - - -
    -
    - 测试集解锁: - - - - -
    - - {!code_hidden && !hide_code &&
    - 代码开放修改: - - - - -
    } - -
    - 隐藏代码窗口: - - - - -
    - -
    - 代码目录隐藏: - - - - -
    - - { (vnc || webssh == 2) &&
    - 私密版本库: - - - - -
    } - -
    - 禁用复制粘贴: - - - - -
    - -
    - 开启时间: - - - - -
    - - {this.props.identity<3?
    - VNC图形化: - - - - -
    :""} - {this.props.identity<3 && vnc ?
    - VNC图形化评测: - - - - -
    :""} - - - -
    - - {this.props.identity<3?
    -

    服务配置

    - { shixun_service_configs&&shixun_service_configs.map((item,key)=>{ - - return( -
    -
    -
    - {item.name} - {/*this.Deselectlittle(item.mirror_repository_id)}>*/} -
    -
    - -
    - this.setConfigsInputs(e,key,1)} - className="panel-box-sizing task-form-100 task-height-40" placeholder="请输入类别名称" /> -
    -
    -
    -
    - -
    - this.setConfigsInputs(e,key,2)} - className="panel-box-sizing task-form-100 task-height-40" placeholder="请输入类别名称" /> -
    -
    -
    -
    - -
    - this.setConfigsInputs(e,key,3)} - className="panel-box-sizing task-form-100 task-height-40" placeholder="请输入类别名称" /> -
    -
    -
    -
    - -
    - this.setConfigsInputs(e,key,4)} - className="panel-box-sizing task-form-100 task-height-40" placeholder="请输入类别名称" /> -
    - -
    -
    -
    -
    - ) - - })} -
    :""} - -

    - { - // this.props.identity<4&&this.props.status==0? - this.props.identity<5? -

    - 保存 - 取消 -
    :"" - } - -

    - -
    - ); - } -} - - diff --git a/public/react/src/tpm/TPMsettings/css/TPMsettings.css b/public/react/src/tpm/TPMsettings/css/TPMsettings.css deleted file mode 100644 index 8047bbde8..000000000 --- a/public/react/src/tpm/TPMsettings/css/TPMsettings.css +++ /dev/null @@ -1,113 +0,0 @@ -.radioStyle{ - display: block; - height: 30px; - } -#settingsMarkdown{ - background:transparent; -} -#challenge_begin{ - height: 30px; - line-height: 30px; -} -#shixundescription .CodeMirror{ - margin-top: 31px !important; - height: 364px !important; -} -#shixundescription .editormd-preview{ - width:578px !important; - top: 40px !important; - height: 364px !important; -} - -#shixunmemoMD .CodeMirror{ - margin-top: 31px !important; - height: 578px !important; -} - -#shixunmemoMD .editormd-preview{ - width: 578px !important; - top: 40px !important; - height: 578px !important; -} - -.radioStyle { - display: block; - height: 30px; -} - -a.white-btn.use_scope-btn:hover { - color: #FFF !important; -} - -.shixunScopeInput { - width: 218px; - height: 33px; - display: block; - margin-bottom: 15px; -} - -.ant-modal-title { - text-align: center; -} - -a.newuse_scope-btn:hover { - border: 1px solid #F06200; - color: #fff !important; - background: #FF7500; -} - -a.newuse_scope-btn { - border: 1px solid #FF7500; - color: #FF7500 !important; -} - -.tpmprompt { - padding-left: 20px; - margin-top: -4px; -} -.ml36{ - margin-left: 26px; -} - -#shixunmemoMD{ - width:98% !important; - height: 620px !important; -} -#shixunmemoMDs{ - width: 98% !important; - height: 420px !important; -} -#shixunmemoMDs .CodeMirror { - /* width: 548px !important; */ - margin-top: 31px !important; - height: 402px !important; -} -.pdr20{ - padding-right:20px; -} - -.nonemodel{ - width: 59%; - height: 468px; - /*background: rgba(0, 0, 0, 0.65);*/ - background: #f5f5f5; - position: absolute; - z-index: 100; - opacity: 0.5; - left: 21.5%; -} - -.shixunmemoMDdiv{ - width: 99%; - height: 615px; -} - -.shixunspanred{ - margin-left: 142px; - margin-top: 5px; - margin-bottom: 5px; -} - -.ml82{ - margin-left:82px; -} diff --git a/public/react/src/tpm/beian.png b/public/react/src/tpm/beian.png deleted file mode 100755 index 9f763946d..000000000 Binary files a/public/react/src/tpm/beian.png and /dev/null differ diff --git a/public/react/src/tpm/challengesnew/TPMMDEditor.js b/public/react/src/tpm/challengesnew/TPMMDEditor.js deleted file mode 100644 index 11b88a037..000000000 --- a/public/react/src/tpm/challengesnew/TPMMDEditor.js +++ /dev/null @@ -1,355 +0,0 @@ -import React, {Component} from 'react'; - -import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal} from 'antd'; - -import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; - -// import "antd/dist/antd.css"; - -import { getImageUrl, toPath, getUrl } from 'educoder'; -import '../../courses/css/Courses.css' - -import axios from 'axios'; - -import './css/TPMchallengesnew.css'; -require('codemirror/lib/codemirror.css'); - -let origin = getUrl(); - -let path = '/editormd/lib/' - path = getUrl("/editormd/lib/") -const $ = window.$; - -let timeout; - -let currentValue; - -const Option = Select.Option; - -const RadioGroup = Radio.Group; - - - -// 保存数据 -function md_add_data(k,mdu,d){ - window.sessionStorage.setItem(k+mdu,d); -} - -// 清空保存的数据 -function md_clear_data(k,mdu,id){ - window.sessionStorage.removeItem(k+mdu); - var id1 = "#e_tip_"+id; - var id2 = "#e_tips_"+id; - if(k == 'content'){ - $(id2).html(" "); - }else{ - $(id1).html(" "); - } -} -window.md_clear_data = md_clear_data -// editor 存在了jquery对象上,应用不需要自己写md_rec_data方法了 -function md_rec_data(k, mdu, id) { - if (window.sessionStorage.getItem(k + mdu) !== null) { - var editor = $("#e_tips_" + id).data('editor'); - editor.setValue(window.sessionStorage.getItem(k + mdu)); - // debugger; - // /shixuns/b5hjq9zm/challenges/3977/tab=3 setValue可能导致editor样式问题 - md_clear_data(k, mdu, id); - } -} -window.md_rec_data = md_rec_data; - -function md_elocalStorage(editor,mdu,id){ - if (window.sessionStorage){ - var oc = window.sessionStorage.getItem('content'+mdu); - if(oc !== null && oc != editor.getValue()){ - console.log("#e_tips_"+id) - $("#e_tips_"+id).data('editor', editor); - var h = '您上次有已保存的数据,是否恢复 ? / 不恢复'; - $("#e_tips_"+id).html(h); - } - setInterval(function() { - var d = new Date(); - var h = d.getHours(); - var m = d.getMinutes(); - var s = d.getSeconds(); - h = h < 10 ? '0' + h : h; - m = m < 10 ? '0' + m : m; - s = s < 10 ? '0' + s : s; - if(editor.getValue().trim() != ""){ - md_add_data("content",mdu,editor.getValue()); - var id1 = "#e_tip_"+id; - var id2 = "#e_tips_"+id; - - var textStart = " 数据已于 " - var text = textStart + h + ':' + m + ':' + s +" 保存 "; - // 占位符 - var oldHtml = $(id2).html(); - if (oldHtml && oldHtml != ' ' && oldHtml.startsWith(textStart) == false) { - $(id2).html( oldHtml.split(' (')[0] + ` (${text})`); - } else { - $(id2).html(text); - } - // $(id2).html(""); - } - },10000); - - }else{ - $("#e_tip_"+id).after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!'); - } -} - - -function create_editorMD(id, width, high, placeholder, imageUrl, callback, initValue, - onchange, watch, { noStorage, showNullButton, emoji }, that) { - // 还是出现了setting只有一份,被共用的问题 - - var editorName = window.editormd(id, { - width: width, - height: high===undefined?400:high, - path: path, // "/editormd/lib/" - markdown : initValue, - - dialogLockScreen: false, - watch:watch===undefined?true:watch, - syncScrolling: "single", - tex: true, - tocm: true, - emoji: !!emoji , - taskList: true, - codeFold: true, - searchReplace: true, - htmlDecode: "style,script,iframe", - sequenceDiagram: true, - autoFocus: false, - - // mine - - toolbarIcons: function (mdEditor) { - let react_id = `react_${mdEditor.id}`; - const __that = window[react_id] - - // Or return editormd.toolbarModes[name]; // full, simple, mini - // Using "||" set icons align right. - const icons = ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "link", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"]; - // 试卷处用到的填空题新增按钮 - if (__that.props.showNullButton) { - icons.push('nullBtton') - } - return icons - }, - toolbarCustomIcons: { - testIcon: "
    ", - testIcon1: "
    ", - nullBtton: "
    点击插入填空项
    ", - }, - //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 - saveHTMLToTextarea: true, - // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标 - dialogMaskOpacity: 0.6, - placeholder: placeholder, - imageUpload: true, - imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], - imageUploadURL: imageUrl,//url - onchange: onchange, - onload: function() { - let _id = this.id // 如果要使用this,这里不能使用箭头函数 - let _editorName = this; - let react_id = `react_${_editorName.id}`; - const __that = window[react_id] - - // this.previewing(); - // let _id = id; - $("#" + _id + " [type=\"latex\"]").bind("click", function () { - _editorName.cm.replaceSelection("```latex"); - _editorName.cm.replaceSelection("\n"); - _editorName.cm.replaceSelection("\n"); - _editorName.cm.replaceSelection("```"); - var __Cursor = _editorName.cm.getDoc().getCursor(); - _editorName.cm.setCursor(__Cursor.line - 1, 0); - }); - - $("#" + _id + " [type=\"inline\"]").bind("click", function () { - _editorName.cm.replaceSelection("`$$$$`"); - var __Cursor = _editorName.cm.getDoc().getCursor(); - _editorName.cm.setCursor(__Cursor.line, __Cursor.ch - 3); - _editorName.cm.focus(); - }); - $("[type=\"inline\"]").attr("title", "行内公式"); - $("[type=\"latex\"]").attr("title", "多行公式"); - - if (__that.props.showNullButton) { - const NULL_CH = '▁' - // const NULL_CH = '〇' - // const NULL_CH = '🈳' - - $("#" + _id + " [type=\"nullBtton\"]").bind("click", function () { - _editorName.cm.replaceSelection(NULL_CH); - // var __Cursor = _editorName.cm.getDoc().getCursor(); - // _editorName.cm.setCursor(__Cursor.line - 1, 0); - }); - } - - if (noStorage == true) { - - } else { - md_elocalStorage(_editorName, `MDEditor__${_id}`, _id); - } - - callback && callback(_editorName) - } - }); - return editorName; -} - - -export default class TPMMDEditor extends Component { - constructor(props) { - super(props) - this.state = { - initValue: '' - } - } - componentDidUpdate(prevProps, prevState) { - // 不能加,影响了试卷填空题 - // if (this.props.initValue != prevProps.initValue) { - // this.answers_editormd.setValue(this.props.initValue) - // } - } - - // react_mdEditor_ - componentDidMount = () => { - const { mdID, initValue, placeholder, showNullButton} = this.props; - - let _id = `mdEditor_${mdID}` - this.contentChanged = false; - const _placeholder = placeholder || ""; - // amp; - // 编辑时要传memoId - const imageUrl = `/api/attachments.json`; - // 创建editorMd - let react_id = `react_${_id}`; - // 将实例存到了window - window[react_id] = this - const answers_editormd = create_editorMD(_id, '100%', this.props.height, _placeholder, imageUrl, (_editorName) => { - const __editorName = _editorName; - react_id = `react_${__editorName.id}`; - const that = window[react_id] - - // 一个延迟的recreate或resize,不加这段代码,md初始化可能会出现样式问题 - setTimeout(() => { - if (that.props.needRecreate == true) { - __editorName.recreate() // 注意 必须在setValue之前触发,不然会清空 - } else { - __editorName.resize() - } - console.log('timeout', __editorName.id) - __editorName.cm && __editorName.cm.refresh() - }, that.props.refreshTimeout || 500) - if (this.props.noSetValueOnInit) { - that.onEditorChange() - } else { - if (that.props.initValue != undefined && that.props.initValue != '') { - __editorName.setValue(that.props.initValue) - } - if (that.state.initValue) { - __editorName.setValue(that.state.initValue) - } - } - - __editorName.cm.on("change", (_cm, changeObj) => { - that.contentChanged = true; - if (that.state.showError) { - that.setState({showError: false}) - } - that.onEditorChange() - }) - that.props.onCMBlur && __editorName.cm.on('blur', () => { - that.props.onCMBlur() - }) - that.props.onCMBeforeChange && __editorName.cm.on('beforeChange', (cm,change) => { - that.props.onCMBeforeChange(cm,change) - }) - that.answers_editormd = __editorName; - // 这里应该可以去掉了,方便调试加的 - window[__editorName.id+'_'] = __editorName; - }, initValue, this.onEditorChange,this.props.watch, { - noStorage: this.props.noStorage, - showNullButton: this.props.showNullButton, - emoji: this.props.emoji - }, this); - - } - // 用在form里时,validate失败时出现一个红色边框 - showError = () => { - this.setState({showError: true}) - } - onEditorChange = () => { - if (!this.answers_editormd) return; - const val = this.answers_editormd.getValue(); - //console.log('onEditorChange', this.props.id, val) - try { - this.props.onChange && this.props.onChange(val) - } catch(e) { - // http://localhost:3007/courses/1309/common_homeworks/6566/setting - // 从这个页面,跳转到编辑页面,再在编辑页面点击返回的时候,这里会报错 - console.error('出错') - console.error(e) - } - } - resize = () => { - if (!this.answers_editormd) { // 还未初始化 - return; - } - this.answers_editormd.resize() - this.answers_editormd.cm && this.answers_editormd.cm.refresh() - this.answers_editormd.cm.focus() - } - - getValue = () => { - try { - return this.answers_editormd.getValue() - } catch (e) { - return '' - } - } - setValue = (val) => { - try { - this.answers_editormd.setValue(val) - } catch (e) { - // TODO 这里多实例的时候,前一个实例的state会被后面这个覆盖 参考NewWork.js http://localhost:3007/courses/1309/homework/9300/edit/1 - // 未初始化 - this.setState({ initValue: val }) - } - } - - render() { - - let { - showError - } = this.state; - let { mdID, className, noStorage, imageExpand } = this.props; - let _style = {} - if (showError) { - _style.border = '1px solid red' - } - return ( - -
    - {/* padding10-20 */} -
    - -
    -
    -
    -
    -
    - {noStorage == true ? ' ' :

     

    } - {/* {noStorage == true ? ' ' :

     

    } */} -
    -
    - ) - } -} - - diff --git a/public/react/src/tpm/challengesnew/TPManswer.js b/public/react/src/tpm/challengesnew/TPManswer.js deleted file mode 100644 index bc9523422..000000000 --- a/public/react/src/tpm/challengesnew/TPManswer.js +++ /dev/null @@ -1,366 +0,0 @@ -import React, {Component} from 'react'; - -import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal} from 'antd'; - -import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; - -// import "antd/dist/antd.css"; - -import { getImageUrl, toPath, getUrl } from 'educoder'; - -import axios from 'axios'; - -import './css/TPMchallengesnew.css'; - -let origin = getUrl(); - -let path = getUrl("/editormd/lib/") - -const $ = window.$; - -let timeout; - -let currentValue; - -const Option = Select.Option; - -const RadioGroup = Radio.Group; - - -// 恢复数据 -function md_rec_data(k,mdu,id, editor){ - if(window.sessionStorage.getItem(k+mdu) !== null){ - editor.setValue(window.sessionStorage.getItem(k+mdu)); - md_clear_data(k,mdu,id); - } -} - -// 保存数据 -function md_add_data(k,mdu,d){ - window.sessionStorage.setItem(k+mdu,d); -} - -// 清空保存的数据 -function md_clear_data(k,mdu,id){ - window.sessionStorage.removeItem(k+mdu); - var id1 = "#e_tip_"+id; - var id2 = "#e_tips_"+id; - if(k == 'content'){ - $(id2).html(""); - }else{ - $(id1).html(""); - } -} - -function md_elocalStorage(editor,mdu,id){ - if (window.sessionStorage){ - var oc = window.sessionStorage.getItem('content'+mdu); - if(oc !== null ){ - console.log("#e_tips_"+id) - $("#e_tips_"+id).data('editor', editor); - var h = '您上次有已保存的数据,是否恢复 ? / 不恢复'; - $("#e_tips_"+id).html(h); - } - setInterval(function() { - var d = new Date(); - var h = d.getHours(); - var m = d.getMinutes(); - var s = d.getSeconds(); - h = h < 10 ? '0' + h : h; - m = m < 10 ? '0' + m : m; - s = s < 10 ? '0' + s : s; - if(editor.getValue().trim() != ""){ - md_add_data("content",mdu,editor.getValue()); - var id1 = "#e_tip_"+id; - var id2 = "#e_tips_"+id; - - $(id1).html(" 数据已于 " + h + ':' + m + ':' + s +" 保存 "); - $(id2).html(""); - } - },10000); - - }else{ - $("#e_tip_"+id).after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!'); - } -} - - -function create_editorMD(id, width, high, placeholder, imageUrl, callback) { - var editorName = window.editormd(id, { - width: width, - height: high, - path: path, // "/editormd/lib/" - - syncScrolling: "single", - tex: true, - tocm: true, - emoji: true, - taskList: true, - codeFold: true, - searchReplace: true, - htmlDecode: "style,script,iframe", - sequenceDiagram: true, - autoFocus: false, - toolbarIcons: function () { - // Or return editormd.toolbarModes[name]; // full, simple, mini - // Using "||" set icons align right. - return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"] - }, - toolbarCustomIcons: { - testIcon: "
    ", - testIcon1: "
    " - }, - //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 - saveHTMLToTextarea: true, - // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标 - dialogMaskOpacity: 0.6, - placeholder: placeholder, - imageUpload: true, - imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], - imageUploadURL: imageUrl,//url - onload: function () { - // this.previewing(); - $("#" + id + " [type=\"latex\"]").bind("click", function () { - editorName.cm.replaceSelection("```latex"); - editorName.cm.replaceSelection("\n"); - editorName.cm.replaceSelection("\n"); - editorName.cm.replaceSelection("```"); - var __Cursor = editorName.cm.getDoc().getCursor(); - editorName.cm.setCursor(__Cursor.line - 1, 0); - }); - - $("#" + id + " [type=\"inline\"]").bind("click", function () { - editorName.cm.replaceSelection("`$$$$`"); - var __Cursor = editorName.cm.getDoc().getCursor(); - editorName.cm.setCursor(__Cursor.line, __Cursor.ch - 3); - editorName.cm.focus(); - }); - $("[type=\"inline\"]").attr("title", "行内公式"); - $("[type=\"latex\"]").attr("title", "多行公式"); - - md_elocalStorage(editorName, `answers__${id}`, "Memoanswers"); - - callback && callback() - } - }); - return editorName; -} - - -export default class TPManswer extends Component { - constructor(props) { - super(props) - this.state = { - choice_url: undefined, - practice_url: undefined, - go_back_url: undefined, - value: 1, - answer:"", - id:undefined, - checkpointId:undefined, - power: false, - prev_challenge: undefined, - next_challenge: undefined, - } - } - - answerMD(initValue, id) { - - this.contentChanged = false; - const placeholder = ""; - // amp; - // 编辑时要传memoId - const imageUrl = `/api/attachments.json`; - // 创建editorMd - - const answers_editormd = create_editorMD(id, '100%', 400, placeholder, imageUrl, () => { - setTimeout(() => { - answers_editormd.resize() - answers_editormd.cm && answers_editormd.cm.refresh() - }, 500) - - if (initValue != undefined) { - answers_editormd.setValue(initValue) - } - answers_editormd.cm.on("change", (_cm, changeObj) => { - console.log('....contentChanged') - this.contentChanged = true; - }) - }); - this.answers_editormd = answers_editormd; - window.answers_editormd = answers_editormd; - - } - - componentDidMount() { - let id = this.props.match.params.shixunId; - let checkpointId=this.props.match.params.checkpointId; - - let newchoice_url= "/shixuns/"+id+"/challenges/newquestion"; - let newpractice_url= "/shixuns/"+id+"/challenges/new"; - let newgo_back_url="/shixuns/"+id+"/challenges"; - this.setState({ - shixunId:id, - checkpointId:checkpointId - }) - - - let url = "/shixuns/" + id + "/challenges/" + checkpointId + "/edit.json?tab=2"; - axios.get(url).then((response) => { - let newprev_challenge = response.data.prev_challenge; - let next_challenge = response.data.next_challenge; - if (newprev_challenge != undefined) { - if(newprev_challenge.st===0){ - newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editcheckpoint"; - }else{ - newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editquestion"; - } - } - if (next_challenge != undefined) { - - if(next_challenge.st===0){ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editcheckpoint"; - }else{ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editquestion"; - } - } - this.setState({ - answer:response.data.answer, - power: response.data.power, - choice_url: newchoice_url, // 导航中的新建选择题url - practice_url: newpractice_url, //string 导航中新建实践题url - go_back_url: newgo_back_url, //string 导航中的返回url - position: response.data.position, //int 关卡位置,导航栏中的第几关 - prev_challenge: newprev_challenge, - next_challenge: next_challenge, - }) - - if(response.data.power===false){ - this.props.showSnackbar("没有权限修改"); - } - if(response.data.answer===undefined||response.data.answer===null){ - this.answerMD("", "answerMD"); - }else{ - this.answerMD(response.data.answer, "answerMD"); - } - - }).catch((error) => { - console.log(error) - }); - } - - challenge_answer_submit=()=> { - let id = this.props.match.params.shixunId; - let{checkpointId}=this.state; - let url = "/shixuns/"+id+"/challenges/"+checkpointId+".json"; - const answer_editormdvalue = this.answers_editormd.getValue(); - - axios.put(url,{ - tab:2, - identifier:id, - id:checkpointId, - challenge:{ - answer:answer_editormdvalue - } - } - ).then((response) => { - this.props.showSnackbar(response.data.messages); - - }).catch((error) => { - console.log(error) - }); - } - - render() { - - let { - choice_url, - practice_url, - go_back_url, - position, - task_pass_default, - submit_url, - shixunId, - checkpointId, - power, - prev_challenge, - next_challenge, - } = this.state; - let tab1url="/shixuns/" + shixunId + "/challenges/"+checkpointId+"/editcheckpoint"; - let tab2url="/shixuns/" + shixunId + "/challenges/"+checkpointId+"/tab=2"; - let tab3url="/shixuns/" + shixunId + "/challenges/"+checkpointId+"/tab=3"; - // console.log(this.props) - return ( - -
    -
    - - - - 第{position}关 - 返回 - - {prev_challenge === undefined ? "" : - 上一关 - } - - {next_challenge === undefined ? "" : - 下一关 - } - - + 实践类型 - + 选择题类型 - -
    - -
    - -
  • - 本关任务 -
  • - -
  • - 评测设置 -
  • - -
  • - 参考答案 -
  • -
    - -
    - -
    -

    参考答案

    -
    -
    - -
    -
    -
    -
    -

    -

    -
    - -
    - -
    4||this.props.identity===undefined||power===false?"none":"block"}}> - 提交 - 取消 -
    -
    -
    - ) - } -} - - diff --git a/public/react/src/tpm/challengesnew/TPManswer2.js b/public/react/src/tpm/challengesnew/TPManswer2.js deleted file mode 100644 index 6cbfcd081..000000000 --- a/public/react/src/tpm/challengesnew/TPManswer2.js +++ /dev/null @@ -1,368 +0,0 @@ -import React, {Component} from 'react'; - -import {Input, InputNumber, Select, Radio, Checkbox, Popconfirm, message, Modal, Tooltip} from 'antd'; - -import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; - -// import "antd/dist/antd.css"; - -import { getImageUrl, toPath, getUrl } from 'educoder'; - -import axios from 'axios'; - -import './css/TPMchallengesnew.css'; - -import TPMMDEditor from './TPMMDEditor'; - - -let origin = getUrl(); - -let path = getUrl("/editormd/lib/") - -const $ = window.$; - -let timeout; - -let currentValue; - -const Option = Select.Option; - -const RadioGroup = Radio.Group; - -// const testAnswers = [{ -// "id": 4337, -// "name": "解题思路1", -// "contents": "答案的解题思路1", -// "level": 1, -// "score": 25 -// }, -// { -// "id": 4338, -// "name": "解题思路2", -// "contents": "答案的解题思路2", -// "level": 2, -// "score": 25 -// }] -export default class TPManswer extends Component { - constructor(props) { - super(props) - this.state = { - choice_url: undefined, - practice_url: undefined, - go_back_url: undefined, - value: 1, - answer:"", - id:undefined, - checkpointId:undefined, - power: false, - prev_challenge: undefined, - next_challenge: undefined, - answers: [] //testAnswers - } - } - - componentDidMount() { - let id = this.props.match.params.shixunId; - let checkpointId=this.props.match.params.checkpointId; - - let newchoice_url= "/shixuns/"+id+"/challenges/newquestion"; - let newpractice_url= "/shixuns/"+id+"/challenges/new"; - let newgo_back_url="/shixuns/"+id+"/challenges"; - this.setState({ - shixunId:id, - checkpointId:checkpointId - }) - - - let url = "/shixuns/" + id + "/challenges/" + checkpointId + "/edit.json?tab=2"; - axios.get(url).then((response) => { - let newprev_challenge = response.data.prev_challenge; - let next_challenge = response.data.next_challenge; - if (newprev_challenge != undefined) { - if(newprev_challenge.st===0){ - newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editcheckpoint"; - }else{ - newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editquestion"; - } - } - if (next_challenge != undefined) { - - if(next_challenge.st===0){ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editcheckpoint"; - }else{ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editquestion"; - } - } - this.setState({ - answer:response.data.answer, - power: response.data.power, - choice_url: newchoice_url, // 导航中的新建选择题url - practice_url: newpractice_url, //string 导航中新建实践题url - go_back_url: newgo_back_url, //string 导航中的返回url - position: response.data.position, //int 关卡位置,导航栏中的第几关 - prev_challenge: newprev_challenge, - next_challenge: next_challenge, - }) - - if(response.data.power===false){ - this.props.showSnackbar("没有权限修改"); - } - // if(response.data.answer===undefined||response.data.answer===null){ - // this.answerMD("", "answerMD"); - // }else{ - // this.answerMD(response.data.answer, "answerMD"); - // } - - }).catch((error) => { - console.log(error) - }); - - - let urlAnswer = `/shixuns/${id}/challenges/${checkpointId}/answer.json`; - axios.get(urlAnswer).then((response) => { - if (response.data.status === 401) { - - } else if (response.data) { - this.setState({ answers: response.data }) - } - }) - } - - challenge_answer_submit=()=> { - // `levelSection${index}` - // this.refs.md0 - const { answers } = this.state; - const answersParams = answers.slice(0) - console.log(answersParams) - let isValidate = true; - let totalScore = 0; - answersParams.forEach( (item, index) => { - if (!isValidate) { - return; - } - const sectionId = `#levelSection${index}`; - const mdContnet = this.refs[`md${index}`].getValue().trim();; - item.contents = mdContnet; - item.name = item.name.trim() - totalScore += item.score; - delete item.id; - if (!item.name) { - this.props.showSnackbar("请先填写参考答案名称"); - isValidate = false; - } else if (!mdContnet) { - this.props.showSnackbar("请先填写参考答案内容"); - isValidate = false; - } - if (!isValidate) { - $("html, body").animate({ scrollTop: $(`${sectionId}`).offset().top - 100}) - } - }) - if (!isValidate) { - return; - } - if (answersParams.length != 0 && totalScore != 100) { - this.props.showSnackbar("请先保证占比和为100%"); - return; - } - let id = this.props.match.params.shixunId; - let {checkpointId} = this.state; - let url = `/shixuns/${id}/challenges/${checkpointId}/crud_answer.json`; - - axios.post(url,{ - challenge_answer: answersParams - } - ).then((response) => { - if (response.data) { - if (response.data.message) { - this.props.showSnackbar(response.data.message); - } - if (response.data.status == 1) { - $("html").animate({ scrollTop: 0 }) - } - } - - }).catch((error) => { - console.log(error) - }); - } - onNameChange = (e, index) => { - const newAnswer = Object.assign({}, this.state.answers[index]) - newAnswer.name = e.target.value - const newAnswers = this.state.answers.slice(0) - newAnswers[index] = newAnswer - this.setState({ answers: newAnswers}) - } - onScoreChange = (val, index) => { - const newAnswer = Object.assign({}, this.state.answers[index]) - newAnswer.score = val - const newAnswers = this.state.answers.slice(0) - newAnswers[index] = newAnswer - this.setState({ answers: newAnswers}) - } - answerOnChange = (val, index) => { - if (!this.state.answers[index]) { - // 1、2、3删除2会走到这里 - return; - } - const newAnswer = Object.assign({}, this.state.answers[index]) - newAnswer.contents = val - const newAnswers = this.state.answers.slice(0) - newAnswers[index] = newAnswer - this.setState({ answers: newAnswers}) - } - addAnswer = () => { - const newAnswers = this.state.answers.slice(0) - newAnswers.push({ - "name": `解题思路${newAnswers.length + 1}`, - "contents": "", - "score": 10 - }) - this.setState({ answers: newAnswers }) - } - - delanswers=(index)=>{ - let {answers}=this.state; - let newanswers=answers; - newanswers.splice(index,1) - this.setState({ - answers:newanswers - }, () => { - for(let i = index; i < newanswers.length; i ++) { - this.refs[`md${i}`].setValue(newanswers[i].contents) - } - }) - } - render() { - - let { - choice_url, - practice_url, - go_back_url, - position, - task_pass_default, - submit_url, - shixunId, - checkpointId, - power, - prev_challenge, - next_challenge, - answers, - } = this.state; - let tab1url="/shixuns/" + shixunId + "/challenges/"+checkpointId+"/editcheckpoint"; - let tab2url="/shixuns/" + shixunId + "/challenges/"+checkpointId+"/tab=2"; - let tab3url="/shixuns/" + shixunId + "/challenges/"+checkpointId+"/tab=3"; - // console.log(this.props) - return ( - -
    -
    - - - - 第{position}关 - 返回 - - {prev_challenge === undefined ? "" : - 上一关 - } - - {next_challenge === undefined ? "" : - 下一关 - } - - + 实践类型 - + 选择题类型 - -
    - -
    - -
  • - 本关任务 -
  • - -
  • - 评测设置 -
  • - -
  • - 参考答案 -
  • -
    - -
    - -
    -

    - 可以将参考答案分级设置,让学员自行选择级别,每级查看后按照比例扣分值(学员已完成任务再查看,则不影响原因已获得的成绩) -

    -

    - 示例:级别1,扣减分值占比25%;级别2,扣减分值占比35%;级别3,扣减分值占比40%;则学员选择查看级别1的答案,将被扣减25%的分值; - 选择查看级别2的答案,将被扣减60%的分值;选择查看级别3的答案,将被扣减100%的分值。 -

    - - - - { - answers.map((answer, index) => { - return
    - * -

    级别{index + 1}

    - - this.delanswers(index)}> - - - -
    -
    - 名称: - this.onNameChange(e, index)}> - - 扣减分值占比: - this.onScoreChange(e, index)} >% -
    -
    - 参考答案: - this.answerOnChange(val, index)}> -
    -
    -
    - }) - } - -
    4||this.props.identity===undefined||power===false?"none":"block"}}> - 新增 -
    -
    - - -
    - -
    4||this.props.identity===undefined||power===false?"none":"block"}}> - 提交 - 取消 -
    -
    -
    - ) - } -} - - diff --git a/public/react/src/tpm/challengesnew/TPMchallengesnew.js b/public/react/src/tpm/challengesnew/TPMchallengesnew.js deleted file mode 100644 index 9da0b79f5..000000000 --- a/public/react/src/tpm/challengesnew/TPMchallengesnew.js +++ /dev/null @@ -1,615 +0,0 @@ -import React, {Component} from 'react'; - -import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal} from 'antd'; - -import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; - -// import "antd/dist/antd.css"; - -import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; - -import axios from 'axios'; - -import './css/TPMchallengesnew.css'; - -import { getImageUrl, toPath } from 'educoder'; - -import {getUrl} from 'educoder'; - -let origin = getUrl(); - -let path = getUrl("/editormd/lib/") - -const $ = window.$; - -let timeout; - -let currentValue; - -const Option = Select.Option; - -const RadioGroup = Radio.Group; - -export default class TPMchallengesnew extends Component { - constructor(props) { - super(props) - this.exercisememoMDRef=React.createRef(); - this.state = { - choice_url: undefined, - practice_url: undefined, - go_back_url: undefined, - task_pass_default: undefined, - submit_url: undefined, - shixunCreatePracticeGroup: 1, - optionsums:[100,200], - activetype:0, - setopen: false, - shixunCreatePractice: undefined, - onshixunsmarkvalue: 100, - shixunsskillvalue: undefined, - shixunsskillvaluelist: [], - tab2url: "", - tab3url: "", - prev_challenge:undefined, - next_challenge:undefined, - power: false, - shixunCreatePracticetype: false, - shixunsskillvaluelisttype: false, - marktype:false, - editPracticesendtype:false, - CreatePracticesendtype:false, - exec_time:20, - shixunExec_timeType:false - } - } - - - componentDidMount() { - let id = this.props.match.params.shixunId; - let checkpointId=this.props.match.params.checkpointId; - - let newchoice_url= "/shixuns/"+id+"/challenges/newquestion"; - let newpractice_url= "/shixuns/"+id+"/challenges/new"; - let newgo_back_url="/shixuns/"+id+"/challenges" - if(checkpointId===undefined){ - //新建模式 - let url = "/shixuns/" + id + "/challenges/new.json" - axios.get(url).then((response) => { - this.setState({ - choice_url: newchoice_url, - practice_url: newpractice_url, - go_back_url: newgo_back_url, - position: response.data.position, - task_pass_default: response.data.task_pass_default, - submit_url: response.data.submit_url, - checkpointId:checkpointId, - exercisememoMDRefval:response.data.task_pass_default - }) - - this.exercisememoMDRef.current.setValue(response.data.task_pass_default||'') - }).catch((error) => { - console.log(error) - }); - }else{ - //编辑模式 - let url="/shixuns/"+id+"/challenges/"+checkpointId+".json?tab=0"; - axios.get(url).then((response) => { - - let optionsum; - if(response.data.difficulty===1){ - optionsum=[100,200]; - }else if(response.data.difficulty===2){ - optionsum=[300,400,500,600]; - }else if(response.data.difficulty===3){ - optionsum=[700,800,900,1000] - } - let newprev_challenge=response.data.prev_challenge; - let next_challenge=response.data.next_challenge; - if (newprev_challenge != undefined) { - if(newprev_challenge.st===0){ - newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editcheckpoint"; - }else{ - newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editquestion"; - } - } - if (next_challenge != undefined) { - if(next_challenge.st===0){ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editcheckpoint"; - }else{ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editquestion"; - } - } - this.setState({ - power: response.data.power, - prev_challenge:newprev_challenge, - next_challenge:next_challenge, - choice_url: newchoice_url, - practice_url: newpractice_url, - go_back_url: newgo_back_url, - shixunCreatePractice:response.data.subject, - position:response.data.position, - shixunCreatePracticeGroup:response.data.difficulty, - optionsums:optionsum, - onshixunsmarkvalue:response.data.score, - shixunsskillvaluelist:response.data.tags, - checkpointId:checkpointId, - exec_time:response.data.exec_time, - tab2url: "/shixuns/" + id + "/challenges/"+checkpointId+"/tab=2", - tab3url: "/shixuns/" + id + "/challenges/"+checkpointId+"/tab=3", - exercisememoMDRefval:response.data.task_pass - }) - if(response.data.power===false){ - this.props.showSnackbar("你没有权限修改"); - } - - this.exercisememoMDRef.current.setValue(response.data.task_pass||'') - }).catch((error) => { - console.log(error) - }); - - } - - } - - onshixunCreatePracticeChange = (e) => { - let optionsum; - let onshixunsmark; - if(e.target.value===1){ - optionsum=[100,200]; - onshixunsmark=100; - }else if(e.target.value===2){ - optionsum=[300,400,500,600]; - onshixunsmark=300; - }else if(e.target.value===3){ - optionsum=[700,800,900,1000] - onshixunsmark=700; - } - this.setState({ - shixunCreatePracticeGroup: e.target.value, - optionsums:optionsum, - onshixunsmarkvalue:onshixunsmark - }) - } - - shixunCreatePractice = (e) => { - this.setState({ - shixunCreatePractice: e.target.value - }) - } - - CreatePracticesend = () => { - - - this.setState({ - CreatePracticesendtype:true - }) - - if(this.props.status===2){ - this.props.showSnackbar("该实训已经发布不能新建") - this.setState({ - CreatePracticesendtype:false - }) - return - } - let {shixunCreatePractice, shixunCreatePracticeGroup, onshixunsmarkvalue, shixunsskillvaluelist,exec_time} = this.state; - if (shixunCreatePractice === undefined||shixunCreatePractice=="") { - this.setState({ - shixunCreatePracticetype: true - }) - this.props.showSnackbar("任务名称为空") - $('html').animate({ - scrollTop: 10 - }, 1000); - - this.setState({ - CreatePracticesendtype:false - }) - return - } - - if (shixunsskillvaluelist.length === 0) { - this.setState({ - shixunsskillvaluelisttype: true, - CreatePracticesendtype:false - }) - this.props.showSnackbar("技能标签为空") - return - } - if(exec_time===null||exec_time===undefined||exec_time===""){ - - this.setState({ - shixunExec_timeType:false - }) - return - } - - const exercise_editormdvalue = this.exercisememoMDRef.current.getValue().trim(); - let id = this.props.match.params.shixunId; - - let url = "/shixuns/" + id + "/challenges.json"; - - axios.post(url, { - identifier:id, - subject: shixunCreatePractice, - task_pass: exercise_editormdvalue, - difficulty: shixunCreatePracticeGroup, - score: onshixunsmarkvalue, - challenge_tag: shixunsskillvaluelist, - st: 0, - exec_time:exec_time - }).then((response) => { - if (response.data.status === 1) { - // $("html").animate({ scrollTop: 0 }) - - window.location.href=`/shixuns/${id}/challenges/${response.data.challenge_id}/editcheckpoint`; - // this.setState({ - // setopen: true, - // CreatePracticesendtype:false, - // tab2url: "/shixuns/" + id + "/challenges/"+response.data.challenge_id+"/tab=2", - // tab3url: "/shixuns/" + id + "/challenges/"+response.data.challenge_id+"/tab=3", - // }) - - } - // this.props.showSnackbar(response.data.messages); - }).catch((error) => { - console.log(error) - }); - - - - } - - onshixunsmark = (value) => { - this.setState({ - onshixunsmarkvalue: value - }) - } - - shixunsskill = (e) => { - this.setState({ - shixunsskillvalue: e.target.value - }) - } - - clickshixunsskill = () => { - - let {shixunsskillvalue, shixunsskillvaluelist} = this.state; - if (shixunsskillvalue === "") { - return - } else if (shixunsskillvalue === undefined) { - return - } - - if(shixunsskillvalue == "" || shixunsskillvalue == undefined || shixunsskillvalue == null || (shixunsskillvalue.length>0 && shixunsskillvalue.trim().length == 0)){ - message.error("输入为空,不能保存!"); - return - } - - let list = shixunsskillvaluelist; - list.push(shixunsskillvalue); - this.setState({ - shixunsskillvaluelist: list, - shixunsskillvalue: "" - }) - } - - delshixunsskilllist = (key) => { - let {shixunsskillvaluelist} = this.state; - let newshixunsskillvaluelist = shixunsskillvaluelist; - newshixunsskillvaluelist.splice(key, 1); - this.setState({ - shixunsskillvaluelist: newshixunsskillvaluelist - }) - } - - editPracticesend=()=>{ - - this.setState({ - editPracticesendtype:true - }) - - let {shixunCreatePractice, shixunCreatePracticeGroup, onshixunsmarkvalue, shixunsskillvaluelist,checkpointId,exec_time} = this.state; - - const exercise_editormdvalue = this.exercisememoMDRef.current.getValue().trim(); - - let id = this.props.match.params.shixunId; - - let url = "/shixuns/"+id+"/challenges/"+checkpointId+".json"; - - if (shixunCreatePractice === undefined||shixunCreatePractice=="") { - // this.setState({ - // shixunCreatePracticetype: true - // }) - this.props.showSnackbar("任务名称为空") - $('html').animate({ - scrollTop: 10 - }, 1000); - this.setState({ - editPracticesendtype:false - }) - return - } - - if (shixunsskillvaluelist.length === 0) { - // this.setState({ - // shixunsskillvaluelisttype: true - // }) - this.props.showSnackbar("技能标签为空") - this.setState({ - editPracticesendtype:false - }) - return - } - - if(exec_time===null||exec_time===undefined||exec_time===""){ - - this.setState({ - shixunExec_timeType:false - }) - return - } - axios.put(url, { - tab:0, - identifier:id, - id:checkpointId, - challenge:{ - subject: shixunCreatePractice, - task_pass: exercise_editormdvalue, - difficulty: shixunCreatePracticeGroup, - score: onshixunsmarkvalue, - exec_time:exec_time - }, - challenge_tag:shixunsskillvaluelist - }).then((response) => { - this.props.showSnackbar(response.data.messages); - if (response.data.status === 1) { - this.setState({ - setopen: true, - editPracticesendtype:false, - tab2url: "/shixuns/" + id + "/challenges/"+checkpointId+"/tab=2", - tab3url: "/shixuns/" + id + "/challenges/"+checkpointId+"/tab=3", - }) - // window.location.href = "/shixuns/" + id + "/challenges/"+response.data.challenge_id+"/tab=2" - } - }).catch((error) => { - console.log(error) - }); - - - } - - onshixunsmarks=()=> { - this.setState({ - marktype:true - }) - } - - onshixunsmarkss=()=> { - this.setState({ - marktype:false - }) - } - - setexec_time=(e)=>{ - this.setState({ - exec_time:e.target.value - }) - } - render() { - - let shixuntype = this.props.match.params.type; - - - let {marktype, - shixunCreatePracticetype, shixunsskillvaluelisttype, - choice_url, practice_url, go_back_url, position, task_pass_default, submit_url, setopen,checkpointId,prev_challenge,next_challenge,power, - shixunCreatePractice, shixunCreatePracticeGroup, onshixunsmarkvalue, shixunsskillvalue, shixunsskillvaluelist, tab2url, tab3url,optionsums, - CreatePracticesendtype,editPracticesendtype - } = this.state; - - let options; - if(optionsums!=undefined){ - options = optionsums.map((d, k) => { - return ( - - ) - }) - } - - return ( - -
    - - -
    - -
  • - 本关任务 -
  • - -
  • - {tab2url === "" ? 评测设置 : 评测设置} -
  • - -
  • - {tab3url === "" ? 参考答案 : 参考答案} - -
  • -
    - -
    -
    -

    任务名称

    -
    - * -
    - -
    -
    - 必填项 -
    -
    -
    -
    - - -
    - -

    过关任务

    - - - -

    -

    -
    - - -
    -

    难度系数

    -
    - - - 简单 - 中等 - 困难 - - -
    -

    奖励经验值

    -
    - * - - - -

    - 如果学员答题错误,则不能得到相应的经验值
    - 如果学员成功得到经验值,那么将同时获得等值的金币奖励,如:+10经验值、+10金币 -

    - - 必填项 -
    -
    - - -
    -

    技能标签

    -
    - * -
    - - {/*+ 添加*/} -
    学员答题正确将获得技能,否则不能获得技能
    -
    - - { - shixunsskillvaluelist===undefined?"":shixunsskillvaluelist.length === 0 ? "" : shixunsskillvaluelist.map((itme, key) => { - return ( -
  • {itme} - this.delshixunsskilllist(key)}>× -
  • - ) - }) - } - - -
    -
    - - 必填项 -
    -
    - -
    -

    服务配置

    -
    - * - -
    - -
    - 必填项 -
    -
    -
    - -
    4||this.props.identity===undefined?"none":'block'}} - > - {checkpointId===undefined?提交: - 提交} - 取消 -
    -
    -
    - ) - } -} - - diff --git a/public/react/src/tpm/challengesnew/TPMevaluation.js b/public/react/src/tpm/challengesnew/TPMevaluation.js deleted file mode 100644 index f29e9311e..000000000 --- a/public/react/src/tpm/challengesnew/TPMevaluation.js +++ /dev/null @@ -1,1213 +0,0 @@ -import React, {Component} from 'react'; - -import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal,Button,Icon,Tooltip} from 'antd'; - -import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; - -// import "antd/dist/antd.css"; - -import axios from 'axios'; - -import { getImageUrl, toPath } from 'educoder'; - -import './css/TPMchallengesnew.css'; - -import {getUrl} from 'educoder'; - -let origin = getUrl(); - -let path = getUrl("/editormd/lib/") - -const $ = window.$; - -let timeout; - -let currentValue; - -const Option = Select.Option; - -const RadioGroup = Radio.Group; - -const { TextArea } = Input; - -function create_editorMD(id, width, high, placeholder, imageUrl, callback) { - var editorName = window.editormd(id, { - width: width, - height: high, - path: path, // "/editormd/lib/" - - syncScrolling: "single", - tex: true, - tocm: true, - emoji: true, - taskList: true, - codeFold: true, - searchReplace: true, - htmlDecode: "style,script,iframe", - sequenceDiagram: true, - autoFocus: false, - toolbarIcons: function () { - // Or return editormd.toolbarModes[name]; // full, simple, mini - // Using "||" set icons align right. - return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"] - }, - toolbarCustomIcons: { - testIcon: "
    ", - testIcon1: "
    " - }, - //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 - saveHTMLToTextarea: true, - // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标 - dialogMaskOpacity: 0.6, - placeholder: placeholder, - imageUpload: true, - imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], - imageUploadURL: imageUrl,//url - onload: function () { - // this.previewing(); - $("#" + id + " [type=\"latex\"]").bind("click", function () { - editorName.cm.replaceSelection("```latex"); - editorName.cm.replaceSelection("\n"); - editorName.cm.replaceSelection("\n"); - editorName.cm.replaceSelection("```"); - var __Cursor = editorName.cm.getDoc().getCursor(); - editorName.cm.setCursor(__Cursor.line - 1, 0); - }); - - $("#" + id + " [type=\"inline\"]").bind("click", function () { - editorName.cm.replaceSelection("`$$$$`"); - var __Cursor = editorName.cm.getDoc().getCursor(); - editorName.cm.setCursor(__Cursor.line, __Cursor.ch - 3); - editorName.cm.focus(); - }); - $("[type=\"inline\"]").attr("title", "行内公式"); - $("[type=\"latex\"]").attr("title", "多行公式"); - - window.md_elocalStorage(editorName, `exercise__${id}`, "Memochallengesnew"); - - callback && callback() - } - }); - return editorName; -} - - -export default class TPMevaluation extends Component { - constructor(props) { - super(props) - this.state = { - choice_url: undefined, - practice_url: undefined, - go_back_url: undefined, - task_pass_default: undefined, - submit_url: undefined, - value: 1, - evaluationlist:[], - shixunId:undefined, - power:false, - shixunfilepath:undefined, - evaluationvisible:false, - trees:undefined, - path:"", - main:[], - saveshixunfilepath:undefined, - selectpath:undefined, - shixunfilepathplay:undefined, - shixunfileexpectpicturepath:undefined, - shixunfilestandardpicturepath:undefined, - shixunfilepicturepath:undefined, - pathoptionvalue:-1, - showrepositoryurltiptype: false, - prev_challenge: undefined, - next_challenge: undefined, - StudentTaskPapers:false, - StudentTaskDocs:false, - selectpatharr:[], - handpathopt:false, - scorevalue:false, - markvalue:true, - scoretype:undefined, - web_route:null - } - } - - - exerciseMD(initValue, id) { - - this.contentChanged = false; - const placeholder = ""; -// amp; -// 编辑时要传memoId - const imageUrl = `/api/attachments.json`; -// 创建editorMd - - const exercise_editormd = create_editorMD(id, '100%', 400, placeholder, imageUrl, () => { - setTimeout(() => { - exercise_editormd.resize() - exercise_editormd.cm && exercise_editormd.cm.refresh() - }, 500) - - if (initValue != undefined) { - exercise_editormd.setValue(initValue) - } - exercise_editormd.cm.on("change", (_cm, changeObj) => { - console.log('....contentChanged') - this.contentChanged = true; - }) - }); - this.exercise_editormd = exercise_editormd; - window.exercise_editormd = exercise_editormd; - - } - - componentDidMount() { - let id = this.props.match.params.shixunId; - let checkpointId=this.props.match.params.checkpointId; - this.setState({ - shixunId:id, - checkpointId:checkpointId - }) - let newchoice_url= "/shixuns/"+id+"/challenges/newquestion"; - let newpractice_url= "/shixuns/"+id+"/challenges/new"; - let newgo_back_url="/shixuns/"+id+"/challenges"; - - let url = "/shixuns/" + id + "/challenges/" + checkpointId + "/edit.json?tab=1"; - axios.get(url).then((response) => { - let newprev_challenge = response.data.prev_challenge; - let next_challenge = response.data.next_challenge; - if (newprev_challenge != undefined) { - if(newprev_challenge.st===0){ - newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editcheckpoint"; - }else{ - newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editquestion"; - } - } - if (next_challenge != undefined) { - - if(next_challenge.st===0){ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editcheckpoint"; - }else{ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editquestion"; - } - } - let newevaluationlist=[] - if(response.data.test_sets.length===0){ - let newlist=[ - {hidden:0,input:"",output:"",score:50}, - {hidden:0,input:"",output:"",score:50} - ] - newevaluationlist=newlist - }else{ - newevaluationlist=response.data.test_sets - } - - this.setState({ - power: response.data.power, - evaluationlist:newevaluationlist, - shixunfilepath:response.data.path, - shixunfilepathplay:response.data.exec_path, - pathoptionvalue:response.data.show_type, - shixunfileexpectpicturepath:response.data.original_picture_path, - shixunfilestandardpicturepath:response.data.expect_picture_path, - shixunfilepicturepath:response.data.picture_path, - prev_challenge: newprev_challenge, - next_challenge: next_challenge, - choice_url: newchoice_url, // 导航中的新建选择题url - practice_url: newpractice_url, //string 导航中新建实践题url - go_back_url: newgo_back_url, //string 导航中的返回url - position: response.data.position, //int 关卡位置,导航栏中的第几关 - scorevalue:response.data.test_set_score, - markvalue:response.data.test_set_average, - web_route:response.data.web_route, - has_web_route:response.data.has_web_route - }) - this.evaluationoninputvalueonload(); - if(response.data.power===false){ - this.props.showSnackbar("你没有权限修改"); - } - if(response.data.answer===undefined){ - this.answerMD("", "answerMD"); - }else{ - this.answerMD(response.data.answer, "answerMD"); - } - - }).catch((error) => { - console.log(error) - }); - - } - - - setevaluationlist=(newevaluationlist)=>{ - this.setState({ - evaluationlist:newevaluationlist - }) - console.log(newevaluationlist) - } - - - addevaluationon=()=>{ - let {evaluationlist,markvalue}=this.state; - let newevaluationlist=evaluationlist; - newevaluationlist.push({hidden:0,input:"",output:"",score:0}); - newevaluationlist=this.oneditevaluationlist(newevaluationlist,markvalue); - this.setevaluationlist(newevaluationlist); - } - - del_test_array=(key)=>{ - let {evaluationlist,markvalue}=this.state; - let newevaluationlist=evaluationlist; - newevaluationlist.splice(key,1); - newevaluationlist=this.oneditevaluationlist(newevaluationlist,markvalue); - this.setevaluationlist(newevaluationlist); - } - - getfilepath=(e,shixunfilepath,type)=>{ - this.setState({ - evaluationvisible: true, - selectpath:e.target.value, - selectpatharr:[], - pathtype:type - }); - let id = this.props.match.params.shixunId; - let url ="/shixuns/"+id+"/repository.json"; - axios.post(url,{ - path: "" - }).then((response) => { - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - - }else{ - this.setState({ - trees:response.data.trees, - saveshixunfilepath:shixunfilepath, - path:"", - main:[], - }) - } - - }).catch((error) => { - console.log(error) - }); - } - - sendgetfilepath=(newpath,type,newpathtype)=>{ - let id = this.props.match.params.shixunId; - let{path,main,pathtype}=this.state; - let ary=main; - let paths=path; - - this.setState({ - selectpatharr:[], - }) - if(paths===""&&type==="tree"){ - newpath=newpath+"/"; - paths=""; - if(main.length===0){ - ary.push({val:"根目录/",path:""},{val:newpath,path:paths+newpath}) - }else{ - ary.push({val:newpath,path:paths+newpath}) - } - - }else if(paths!=""&&type==="tree"){ - newpath=newpath+"/"; - ary.push({val:newpath,path:paths+newpath}) - } - - - let url ="/shixuns/"+id+"/repository.json"; - if(type==="tree"){ - - axios.post(url,{ - path: paths+newpath - }).then((response) => { - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - - }else{ - this.setState({ - trees:response.data.trees, - path:paths+newpath, - main:ary, - // selectpath:"" - }) - } - - }).catch((error) => { - console.log(error) - }); - } - - if(pathtype===2){ - this.setState({ - selectpath: newpathtype, - }) - } - } - - goblakepath=(path,key)=>{ - let {main,selectpath,pathtype} =this.state; - let newmain=[] - for(var i=0;i<=key;i++){ - newmain.push(main[i]) - } - let id = this.props.match.params.shixunId; - let url ="/shixuns/"+id+"/repository.json"; - axios.post(url,{ - path: path - }).then((response) => { - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - - }else { - this.setState({ - trees: response.data.trees, - path: path, - main: newmain, - // selectpath:selectpath - }) - } - }).catch((error) => { - console.log(error) - }); - - if(pathtype===2){ - let paths = path.substring(0,path.length-1); - console.log(paths) - this.setState({ - selectpath: paths, - }) - } - - - } - - - - - - // delesavegetfilepath=(value)=>{ - // let {selectpatharr} = this.state - // let newarr =selectpatharr; - // let newselectpath=""; - // for(var i=0; i{ - let {selectpath,saveshixunfilepath,pathtype} = this.state - - if(pathtype===1){ - let newselectpath; - - if(saveshixunfilepath==="shixunfilepathplay"){ - newselectpath=value - }else{ - const type = selectpath.split(';'); - let types=false; - for(var i=0; i1&&arrtype===false){ - // for(var i=0; i{ - let {saveshixunfilepath,selectpath}=this.state; - this.setState({ - evaluationvisible: false, - [saveshixunfilepath]:selectpath - }); - } - evaluationhideModal=()=>{ - this.setState({ - evaluationvisible: false, - }); - } - handpathoptionvalue=(value)=>{ - this.setState({ - pathoptionvalue:value, - shixunfileexpectpicturepath:undefined, - shixunfilestandardpicturepath:undefined, - shixunfilepicturepath:undefined - }) - } - showrepositoryurltip=(type)=>{ - if(type===1){ - this.setState({ - showrepositoryurltiptype:true - }) - }else{ - this.setState({ - showrepositoryurltiptype:false - }) - } - } - - evaluationonChange=(e,key)=>{ - let {evaluationlist}=this.state; - let newevaluationlist=evaluationlist; - let newtype; - if(e===1){ - newtype=0; - }else{ - newtype=1; - } - // newevaluationlist[key].is_public=newtype; - // for(var i=0; i{ - let {evaluationlist,scoretype}=this.state; - - if(scoretype===key){ - this.setState({ - scoretype:undefined - }) - } - let newevaluationlist=evaluationlist; - let sum =parseInt(e.target.value); - if(isNaN(sum)){ - sum=0 - } - newevaluationlist[key].score=sum; - - this.setState({ - evaluationlist:newevaluationlist, - markvalue:false - }) - this.setevaluationlist(newevaluationlist); - } - - // 修改测试集的匹配规则 - changeEvaluationRule=(e,key)=>{ - let {evaluationlist}=this.state; - let newevaluationlist=evaluationlist; - newevaluationlist[key].match_rule=e.target.value - this.setevaluationlist(newevaluationlist); - } - - evaluationoninputvalue=(e,key,type)=>{ - $.fn.autoHeight = function(){ - function autoHeight(elem){ - elem.style.height = 'auto'; - elem.style.maxHeight = '140px'; - elem.scrollTop = 0; //防抖动 - elem.style.height = elem.scrollHeight + 'px'; - } - this.each(function(){ - autoHeight(this); - $(this).on('keyup', function(){ - autoHeight(this); - }); - }); - } - $('textarea[autoHeight]').autoHeight(); - - let {evaluationlist}=this.state; - let newevaluationlist=evaluationlist; - if(type==="sr"){ - newevaluationlist[key].input=e.target.value - }else if(type==="yq"){ - // 统一转成\r\n - newevaluationlist[key].output= e.target.value ? e.target.value.replace(/\r?\n/g, "\r\n") : e.target.value - } - this.setevaluationlist(newevaluationlist); - } - - - evaluationoninputvalueonload=()=>{ - $.fn.autoHeight = function(){ - function autoHeight(elem){ - elem.style.height = 'auto'; - elem.style.maxHeight = '140px'; - elem.scrollTop = 0; //防抖动 - elem.style.height = elem.scrollHeight + 'px'; - } - this.each(function(){ - autoHeight(this); - $(this).on('keyup', function(){ - autoHeight(this); - }); - }); - } - $('textarea[autoHeight]').autoHeight(); - } - submitarbitrationevaluation=()=>{ - let{evaluationlist,shixunfilepath,shixunfilepathplay,shixunfileexpectpicturepath,shixunfilestandardpicturepath,shixunfilepicturepath,pathoptionvalue,scorevalue,markvalue,web_route}=this.state; - - - let newscorevalue; - if(scorevalue===false){ - newscorevalue=false - }else{ - //判断占比 - newscorevalue=true - - let sum=0; - for(var i=0; i100){ - this.props.showSnackbar("测试集的评分占比不能大于100"); - this.setState({ - scoretype:i - }) - return - } - sum=sum+evaluationlist[i].score - } - - if(sum>100||sum<100){ - this.props.showSnackbar("测试集的评分占比之和必须等于100"); - return - } - - - } - if(shixunfilepath===undefined||shixunfilepath===""||shixunfilepath===null){ - this.props.showSnackbar("学员任务文件路径为空"); - this.setState({ - StudentTaskPapers:true - }) - $('html').animate({ - scrollTop: 120 - }, 1000); - return - } - - if(shixunfilepathplay===undefined||shixunfilepathplay===""||shixunfilepathplay===null){ - this.props.showSnackbar("评测执行文件路径为空"); - this.setState({ - StudentTaskDocs:true - }) - $('html').animate({ - scrollTop: 130 - }, 1000); - return - } - - if(evaluationlist.length===0){ - this.props.showSnackbar("测试集不能为空"); - return - } - let id = this.props.match.params.shixunId; - let{checkpointId}=this.state; - let url = "/shixuns/"+id+"/challenges/"+checkpointId+".json"; - let newchallenge={ - path:shixunfilepath, - exec_path:shixunfilepathplay, - show_type:pathoptionvalue, - original_picture_path:pathoptionvalue===-1?undefined:shixunfileexpectpicturepath===undefined?null:shixunfileexpectpicturepath, - expect_picture_path:pathoptionvalue===-1?undefined:shixunfilestandardpicturepath===undefined?null:shixunfilestandardpicturepath, - picture_path:pathoptionvalue===-1?undefined:shixunfilepicturepath===undefined?null:shixunfilepicturepath, - test_set_score:newscorevalue, - test_set_average:markvalue, - web_route:web_route===null?undefined:web_route - } - axios.put(url,{ - tab:1, - challenge:newchallenge, - test_set:evaluationlist - } - ).then((response) => { - this.props.showSnackbar(response.data.messages); - // if(response.data.status===1){ - // window.location.href = "/shixuns/" + id + "/challenges/"+response.data.challenge_id+"/tab=3" - // } - }).catch((error) => { - console.log(error) - }); - } - handpathoptionvalues=()=>{ - this.setState({ - handpathopt:true - }) - } - handpathoptionvaluess=()=>{ - this.setState({ - handpathopt:false - }) - } - saveselectpath=(e)=>{ - - this.setState({ - selectpath:e.target.value - }) - - } - updatepath=(e,name,type)=>{ - this.setState({ - [name]:e.target.value, - pathtype:type - }) - } - - - oneditevaluationlist=(newevaluationlist,markvalue)=>{ - - if(markvalue===true){ - if(100%newevaluationlist.length===0){ - let sum=100/newevaluationlist.length; - for(var i=0; i{ - - let {markvalue,evaluationlist}=this.state; - let newevaluationlist=evaluationlist; - - if(e.target.value===true){ - newevaluationlist=this.oneditevaluationlist(newevaluationlist,markvalue) - } - - this.setState({ - scorevalue: e.target.value, - evaluationlist:newevaluationlist - }); - - this.setevaluationlist(newevaluationlist); - } - - //均匀比例 - onChangemarkvalue=(e)=>{ - let {evaluationlist}=this.state; - - if(e.target.value===true){ - let newevaluationlist=evaluationlist; - newevaluationlist=this.oneditevaluationlist(newevaluationlist,e.target.value); - this.setevaluationlist(newevaluationlist); - } - - this.setState({ - markvalue: e.target.value, - }); - - } - - updatewebroute=(e)=>{ - this.setState({ - web_route:e.target.value - }) - } - render() { - - let { - choice_url, - practice_url, - go_back_url, - position, - evaluationlist, - shixunId, - checkpointId, - power, - shixunfileexpectpicturepath, - shixunfilestandardpicturepath, - shixunfilepicturepath, - shixunfilepath, - evaluationvisible, - trees, - path, - main, - selectpath, - shixunfilepathplay, - pathoptionvalue, - showrepositoryurltiptype, - prev_challenge, - next_challenge, - StudentTaskPapers, - StudentTaskDocs, - web_route, - scorevalue, - markvalue, - scoretype, - has_web_route - } = this.state; - - let tab1url="/shixuns/" + shixunId + "/challenges/"+checkpointId+"/editcheckpoint"; - let tab2url="/shixuns/" + shixunId + "/challenges/"+checkpointId+"/tab=2"; - let tab3url="/shixuns/" + shixunId + "/challenges/"+checkpointId+"/tab=3"; - // console.log(this.props) - const radioStyle = { - display: 'block', - height: '30px', - lineHeight: '30px', - marginLeft: '20px', - }; - return ( - -
    -
    - - - - 第{position}关 - 返回 - - {prev_challenge === undefined ? "" : - 上一关 - } - - {next_challenge === undefined ? "" : - 下一关 - } - - 4||this.props.identity===undefined||this.props.status===2||this.props.status===1? "none":'block'}} - data-tip-down="新增代码编辑类型的任务">+ 实践类型 - 4||this.props.identity===undefined||this.props.status===2||this.props.status===1?"none":'block'}} - data-tip-down="新增选择题类型的任务">+ 选择题类型 - -
    - -
    - -
  • - 本关任务 -
  • - -
  • - 评测设置 -
  • - -
  • - 参考答案 -
  • -
    - -

    - 请先上传本关任务的所有代码文件、标准图片等所有必要的文件到 - 版本库 -

    - - -
    -
    -

    学员任务文件

    -
    - * -
    - this.updatepath(e,"shixunfilepath",1)} - onClick={(e)=>this.getfilepath(e,"shixunfilepath",1)} - /> -

    该文件将直接显示给学生,需要学生在其中填写代码

    -
    -
    - 必填项 -
    -
    -
    -
    - -
    -
    - -
    - - this.saveselectpath(e)} - value={selectpath}/> -
    - - this.evaluationenter()}>确定 - this.evaluationhideModal()}>取消 -
    -
    -
    - -
    -
    -

    评测执行文件

    -
    - * -
    - this.updatepath(e,"shixunfilepathplay",1)} - onClick={(e)=>this.getfilepath(e,"shixunfilepathplay",1)} - /> -

    该文件由平台执行,用来测试平台学员代码是否正确

    -
    -
    - 必填项 -
    -
    -
    -
    - - -
    -
    -

    效果展现方式

    -
    - - this.showrepositoryurltip(1)}> -
    - -
    -

    - 图片:处理或输出图片类型的任务,请选填此项
    - 可以通过设置图片路径和学员答案文件路径,展示代码对应的图片效果

    - apk/exe:写可执行文件的任务,请选填此项
    - 可以通过设置学员答案文件路径,展示二维码以供扫码下载

    - txt:输出txt文档类型的任务,请选填此项
    - 可以通过学员答案文件路径设置,展示txt文件内容

    - html:web类型的任务,请选填此项
    - 可以通过Web路由设置,展示html效果预览页 -

    -

    this.showrepositoryurltip(2)} - >知道了 -

    -
    -
    -

    该选项用来配置学员评测本关任务时,查看效果页上需要展现的文件类型

    -
    -
    - - {pathoptionvalue===4&&web_route!=null||pathoptionvalue===4&&has_web_route===true?
    -
    -

    Web路由

    -
    -
    - this.updatewebroute(e)} - placeholder="网站类型实训,请填写Web路由地址。例:java/mypage"/> -
    -
    -
    -
    :""} - - {pathoptionvalue===1||pathoptionvalue===5||pathoptionvalue===6?
    -
    -

    待处理文件路径

    -
    -
    - this.updatepath(e,"shixunfileexpectpicturepath",2)} - onClick={(e)=>this.getfilepath(e,"shixunfileexpectpicturepath",2)} - /> -

    - 该路径下的文件将在学员评测本关任务时,作为原始文件显示在查看效果页,供学员参考;任务为文件处理时请指定该路径,并注意与程序文件所在文件夹分开。 -

    -
    -
    -
    -
    -
    :""} - - - {pathoptionvalue===1||pathoptionvalue===5||pathoptionvalue===6?
    -
    -

    标准答案文件路径

    -
    -
    - this.updatepath(e,"shixunfilestandardpicturepath",2)} - onClick={(e)=>this.getfilepath(e,"shixunfilestandardpicturepath",2)} - /> -

    - 该路径下的文件将在学员评测本关任务时,作为参考答案显示在查看效果页,供学员参考;任务输出结果为文件时请指定该路径,并注意与程序文件所在文件夹分开。 -

    -
    -
    -
    -
    -
    :""} - - - {pathoptionvalue===-1?"":
    -
    -

    学员答案文件路径

    -
    -
    - this.updatepath(e,"shixunfilepicturepath",2)} - onClick={(e)=>this.getfilepath(e,"shixunfilepicturepath",2)} - placeholder="请在版本库中指定用来保存学员代码实际输出结果的路径。例:src/step1/outputfiles"/> -

    - 学员评测本关任务时生成的文件将保存在该路径下,并作为实际输出显示在查看效果页,供学员确认;任务输出结果为文件时请指定该路径,并注意与程序文件所在文件夹分开。 -

    -
    -
    -
    -
    -
    } - - -
    -
    - {/*

    测试集

    */} -

    测试集和系统评分规则

    -

    - 得分规范: - - - 通过全部测试集 - (学员评测,仅当所有测试集都正确时,才获得一次性奖励) - - - 通过部分测试集 - (学员评测,当至少有一组测试集正确时,即可获得其对应比例的奖励) - -

    - -

    - - 系统评分占比: - - 均分比例 - 自定义比例 - - - -

    - -
    -
    - -
    - - {evaluationlist===undefined?"":evaluationlist.length===0?"":evaluationlist.map((item,key)=>{ - return( -
    -

    - * - 组{key+1} - - {/*checked={item.is_public===1?false:true}*/} - - this.editpercentage(e,key)} - value={item.score} /> - % - - - this.evaluationonChange(item.hidden,key)} checked={item.hidden===1?true:false}>隐藏 - - - - this.del_test_array(key)}> - - - -

    - - -
    - 匹配规则: - this.changeEvaluationRule(e,key)}> - 完全匹配 - 末尾匹配 - -
    -
    - ) - })} - -
    -
    - -

    - - 新增测试集 - -

    -

    温馨提示:建议公开测试集和隐藏测试集结合使用,降低作弊的几率;隐藏测试集,在“提交评测”时也将被自动检测

    -
    -
    -
    - - -
    4||this.props.identity===undefined||power===false?"none":"block"}}> - 提交 - 取消 -
    - - -
    -
    - ) - } -} - - diff --git a/public/react/src/tpm/challengesnew/TPMquestion.js b/public/react/src/tpm/challengesnew/TPMquestion.js deleted file mode 100644 index b76e17b17..000000000 --- a/public/react/src/tpm/challengesnew/TPMquestion.js +++ /dev/null @@ -1,1052 +0,0 @@ -import React, {Component} from 'react'; - -import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal,Tooltip,notification} from 'antd'; - -import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; - -// import "antd/dist/antd.css"; - -import axios from 'axios'; - -import { getImageUrl, toPath } from 'educoder'; - -import './css/TPMchallengesnew.css'; - -import {getUrl} from 'educoder'; - -import TpmQuestionMain from './TpmQuestionMain'; - -import TpmQuestionNew from './TpmQuestionNew'; - -import TpmQuestionEdit from './TpmQuestionEdit'; - -let origin = getUrl(); - -let path = getUrl("/editormd/lib/") - -const $ = window.$; - -const Option = Select.Option; - -const RadioGroup = Radio.Group; - -var letterArr = []; -for (var i = 65, j = 0; i < 91; i++, j++) { - letterArr[j] = String.fromCharCode(i); -} - - -export default class TPMquestion extends Component { - constructor(props) { - super(props) - this.contentMdRef = React.createRef(); - this.newquestioMDMdRef = React.createRef(); - this.newquestioMDMdCont=React.createRef(); - this.neweditanswerRef=React.createRef(); - this.editanswersRef=React.createRef(); - this.state = { - choice_url: undefined, - practice_url: undefined, - go_back_url: undefined, - position: undefined, - task_pass_default: undefined, - submit_url: undefined, - questionsInputvalue:undefined, - questionaddsum:0, - questionaddarray:[], - questionaddtype:true, - activetype:"", - questionlists:[{str:"A",val:"",type:false},{str:"B",val:"",type:false},{str:"C",val:"",type:false},{str:"D",val:"",type:false}], - answeshixunsGroup: 1, - answeoptions:[10,20], - answeonshixunsmark:10, - shixunssanswerkillvalue:"", - shixunsskillanswerlist:[], - challenge_id:"", - challenge_choose_id:undefined, - questionlistss:[], - newcnttype:false, - newquestioMDvaluetype:false, - challenge_tagtype:false, - editquestionaddtype:false, - mancheckpointId:undefined, - power:false, - questionInputvaluetype:false, - questioMD:"", - standard_answer:"", - subject:"", - newquestioMDvaluetypes:false, - questionInputvaluetypes:false, - prev_challenge:undefined, - next_challenge:undefined, - newcnttypesum:1, - marktype:false, - answer:"", - sumittype:false - } - } - - - questionInputvalue=(e)=>{ - this.setState({ - questionsInputvalue: e.target.value - }) - } - - componentDidMount() { - if(this.props.status===2){ - - } - let id = this.props.match.params.shixunId; - let checkpointId=this.props.match.params.checkpointId; - - this.setState({ - mancheckpointId:id, - }) - - let newchoice_url= "/shixuns/"+id+"/challenges/newquestion"; - let newpractice_url= "/shixuns/"+id+"/challenges/new"; - let newgo_back_url="/shixuns/"+id+"/challenges"; - - if(this.props.match.params.choose_id===undefined){ - if(checkpointId===undefined){ - //新建模式 - let nurl = "/shixuns/" + id + "/challenges/new.json" - axios.get(nurl).then((response) => { - - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - - }else { - this.setState({ - choice_url: newchoice_url, - practice_url: newpractice_url, - go_back_url: newgo_back_url, - position: response.data.position, - task_pass_default: response.data.task_pass_default, - submit_url: response.data.submit_url, - power:true, - activetype:"first", - - }) - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - this.setState({ - contentMdRefval:"" - }) - } else { - - this.setState({ - contentMdRefval:response.data.task_pass_default - }) - this.contentMdRef.current.setValue(response.data.task_pass_default || '') - } - this.shixunsautoHeight() - } - - }).catch((error) => { - console.log(error) - }); - - }else{ - //编辑模式 - let url = "/shixuns/"+ id +"/challenges/"+checkpointId+"/edit.json?st=1" - axios.get(url).then((response) => { - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - - }else { - let newprev_challenge=response.data.prev_challenge; - let next_challenge=response.data.next_challenge; - if (newprev_challenge != undefined) { - if(newprev_challenge.st===0){ - newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editcheckpoint"; - }else{ - newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editquestion"; - } - } - if (next_challenge != undefined) { - if(next_challenge.st===0){ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editcheckpoint"; - }else{ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editquestion"; - } - } - this.setState({ - questionaddtype:false, - newquestionaddtype:false, - activetype:"first", - prev_challenge:newprev_challenge, - next_challenge:next_challenge, - questionsInputvalue:response.data.subject, - questionaddarray:response.data.chooses, - challenge_id:response.data.id, - mancheckpointId:checkpointId, - position: response.data.position, - choice_url: newchoice_url, - practice_url: newpractice_url, - go_back_url: newgo_back_url, - power:response.data.power, - // questioMD:response.data.task_pass, - answer:response.data.answer - - }) - - this.setState({ - contentMdRefval:response.data.task_pass - }) - // this.contentMdRef.current.setValue(response.data.task_pass || '') - if(response.data.chooses.length===0){ - // 新建选择题时,没法切回 ‘本关任务’ tab - // this.questionadd() - } - - this.shixunsautoHeight() - } - - }).catch((error) => { - console.log(error) - }); - } - - }else{ - $('html').animate({ - scrollTop:10 - }, 500); - - let{challenge_id} =this.state; - - let id = this.props.match.params.shixunId; - let url = "/shixuns/"+ id +"/challenges/"+checkpointId+"/edit.json?st=1" - axios.get(url).then((response) => { - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - - }else { - let newprev_challenge=response.data.prev_challenge; - let next_challenge=response.data.next_challenge; - if (newprev_challenge != undefined) { - if(newprev_challenge.st===0){ - newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editcheckpoint"; - }else{ - newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editquestion"; - } - } - if (next_challenge != undefined) { - if(next_challenge.st===0){ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editcheckpoint"; - }else{ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editquestion"; - } - } - this.setState({ - questionaddtype:false, - newquestionaddtype:false, - prev_challenge:newprev_challenge, - next_challenge:next_challenge, - questionsInputvalue:response.data.subject, - questionaddarray:response.data.chooses, - challenge_id:response.data.id, - mancheckpointId:checkpointId, - position: response.data.position, - choice_url: newchoice_url, - practice_url: newpractice_url, - go_back_url: newgo_back_url, - power:response.data.power, - // questioMD:response.data.task_pass, - - }) - - this.setState({ - contentMdRefval:response.data.task_pass - }) - // this.contentMdRef.current.setValue(response.data.task_pass || '') - if(response.data.chooses.length===0){ - this.questionadd() - } - this.shixunsautoHeight() - } - - }).catch((error) => { - console.log(error) - }); - - let zrl ='/shixuns/'+this.props.match.params.shixunId+'/challenges/'+this.props.match.params.checkpointId+'/edit_choose_question.json?choose_id='+this.props.match.params.choose_id; - axios.get(zrl).then((response) => { - if(response.status===200){ - let choose_contents=response.data.choose_contents; - let newchoose_contentslist=[] - for(var i=0; i { - }); - - } - } - - clickquestionsumit=()=>{ - this.setState({ - sumittype:true - }) - let checkpointId=this.props.match.params.checkpointId; - if(this.props.status===2&&checkpointId===undefined){ - this.props.showSnackbar("该实训已经发布不能新建") - this.setState({ - sumittype:false - }) - return - } - let {questionsInputvalue} =this.state; - // const exercise_editormdvalue = this.questio_editormd.getValue(); - const exercise_editormdvalue = this.contentMdRef.current.getValue().trim(); - let id = this.props.match.params.shixunId; - - if(questionsInputvalue===undefined||questionsInputvalue===null||questionsInputvalue===""){ - this.setState({ - questionInputvaluetype:true - }) - $('html').animate({ - scrollTop: 10 - }, 1000); - this.setState({ - sumittype:false - }) - return - } - - - if(exercise_editormdvalue===null ||exercise_editormdvalue===""){ - this.setState({ - questionInputvaluetypes:true - }) - $('html').animate({ - scrollTop: 500 - }, 1000); - this.setState({ - sumittype:false - }) - return - } - if(checkpointId===undefined){ - - let url = "/shixuns/" + id + "/challenges.json"; - - axios.post(url, { - identifier:id, - subject: questionsInputvalue, - task_pass: exercise_editormdvalue, - st: 1 - }).then((response) => { - this.props.showSnackbar(response.data.messages); - // if(response.data.status===1){ - // - // this.setState({ - // questionaddtype:false, - // challenge_id:response.data.challenge_id - // }) - // - // this.questionadd() - // } - window.location.href = '/shixuns/'+id+'/challenges/'+response.data.challenge_id+'/editquestion'; - - }).catch((error) => { - console.log(error) - }); - }else{ - let url ="/shixuns/"+id+"/challenges/"+checkpointId+".json"; - axios.put(url, { - tab:0, - subject: questionsInputvalue, - task_pass: exercise_editormdvalue, - }).then((response) => { - if(response.data.status===1){ - this.setState({ - questionaddtype:false, - challenge_id:response.data.challenge_id - }) - } - $('html').animate({ - scrollTop: 10 - }, 200); - this.props.showSnackbar(response.data.messages); - window.location.href = '/shixuns/'+id+'/challenges/'+response.data.challenge_id+'/editquestion'; - }).catch((error) => { - console.log(error) - }); - } - - } - - questionall=()=>{ - // this.setState({ - // activetype:"first", - // newquestionaddtype:false, - // editquestionaddtype:false, - // questionaddtype:false - // }) - - window.location.href = '/shixuns/'+this.props.match.params.shixunId+'/challenges/'+this.props.match.params.checkpointId+'/editquestion'; - } - questionadd=()=>{ - - let{questionaddarray}=this.state; - - let questionaddsums=questionaddarray.length; - - if(questionaddsums-1>9){ - this.props.showSnackbar("选择题目最大支持设置9道题") - return - } - - let questionaddarrays=questionaddarray; - - questionaddarrays.map((item,key)=>{ - if(item.choose_id===0){ - questionaddarrays.splice(key,1) - } - }) - - questionaddarrays.push({type:0,choose_id:0}); - this.setState({ - activetype:0, - questionaddarray:questionaddarrays, - questionaddtype:true, - editquestionaddtype:false, - newquestionaddtype:true, - questionlists:[{str:"A",val:"",type:false},{str:"B",val:"",type:false},{str:"C",val:"",type:false},{str:"D",val:"",type:false}], - answeshixunsGroup: 1, - answeoptions:[10,20], - answeonshixunsmark:10, - shixunssanswerkillvalue:"", - shixunsskillanswerlist:[], - contentMdRefval:"", - newquestioMDMdContval:"", - }) - - - setTimeout(() => { - this.newquestioMDMdRef.current.setValue('') - }, 1000) - setTimeout(() => { - this.newquestioMDMdCont.current.setValue('') - }, 1500) - // this.shixunsautoHeight() - } - - editquestionlists=(newquestionlists)=>{ - let newlist=newquestionlists; - let list=[] - for(var i=0; i{ - let{questionlists} = this.state; - let newquestionlists=questionlists; - let newli={str:letterArr[questionlists.length],val:"",type:false}; - newquestionlists.push(newli); - this.editquestionlists(newquestionlists); - } - - - delquestionlists=(key)=>{ - let{questionlists} = this.state; - let newquestionlists=questionlists; - newquestionlists.splice(key,1); - for(var i=0; i{ - let{questionlists} = this.state; - let newquestionlists=questionlists; - if(newquestionlists[key].type===true){ - newquestionlists[key].type=false; - }else if(newquestionlists[key].type===false){ - newquestionlists[key].type=true; - } - - this.editquestionlists(newquestionlists); - } - - onshixunGroupanswe=(e)=> { - let optionsum; - let onshixunsmark; - if(e.target.value===1){ - optionsum=[10,20]; - onshixunsmark=10; - }else if(e.target.value===2){ - optionsum=[30,40,50,60]; - onshixunsmark=30; - }else if(e.target.value===3){ - optionsum=[70,80,90,100] - onshixunsmark=70; - } - this.setState({ - answeshixunsGroup: e.target.value, - answeoptions:optionsum, - answeonshixunsmark:onshixunsmark - }) - } - shixunssanswerkill = (e) => { - this.setState({ - shixunssanswerkillvalue: e.target.value - }) - - } - clickshixunsanswerskill = () => { - - let {shixunssanswerkillvalue, shixunsskillanswerlist} = this.state; - if (shixunssanswerkillvalue === "") { - return - } else if (shixunssanswerkillvalue === undefined) { - return - } - - if(shixunssanswerkillvalue == "" || shixunssanswerkillvalue == undefined || shixunssanswerkillvalue == null || (shixunssanswerkillvalue.length>0 && shixunssanswerkillvalue.trim().length == 0)){ - message.error("输入为空,不能保存!"); - return - } - - let list = shixunsskillanswerlist; - list.push(shixunssanswerkillvalue); - this.setState({ - shixunsskillanswerlist: list, - shixunssanswerkillvalue: "" - }) - } - delshixunssnswerllist=(key)=>{ - let {shixunsskillanswerlist} = this.state; - let newshixunsskillanswerlist = shixunsskillanswerlist; - newshixunsskillanswerlist.splice(key, 1); - this.setState({ - shixunsskillanswerlist: newshixunsskillanswerlist - }) - } - onInputoquestionption=(e,key)=>{ - - $.fn.autoHeight = function(){ - function autoHeight(elem){ - elem.style.height = 'auto'; - elem.style.maxHeight = '140px'; - elem.scrollTop = 0; //防抖动 - elem.style.height = elem.scrollHeight + 'px'; - } - this.each(function(){ - autoHeight(this); - $(this).on('keyup', function(){ - autoHeight(this); - }); - }); - } - $("#"+e.target.id).autoHeight(); - - let {questionlists}=this.state; - let newquestionlists=questionlists; - newquestionlists[key].val=e.target.value; - this.editquestionlists(newquestionlists); - } - - onshixunsansweSelect=(value)=>{ - this.setState({ - answeonshixunsmark: value - }) - } - - answer_subit=(sumtype,challenge_choose_id)=>{ - $('html').animate({ - scrollTop:10 - }, 500); - - let {challenge_id,questionlists,shixunsskillanswerlist,answeonshixunsmark,answeshixunsGroup,questionaddarray} =this.state; - if(challenge_id===undefined){ - message.error("关卡id为空"); - return - } - let newquestionlists=questionlists; - let newlist=""; - let newtype=[]; - let newcnt=[]; - let list=0; - for(var i=0; i { - console.log(error) - }); - }else{ - - let newquestioMDvalue = this.newquestioMDMdRef.current.getValue().trim(); - if(newquestioMDvalue===""||newquestioMDvalue==="请输入选择题的题干内容"){ - this.setState({ - newquestioMDvaluetype:true, - }) - $('html').animate({ - scrollTop:100 - }, 200); - message.error("题干为空"); - return - } - let newnewanswerMDvalue = this.newquestioMDMdCont.current.getValue().trim(); - - if(newnewanswerMDvalue===""||newnewanswerMDvalue===" "){ - newnewanswerMDvalue=undefined - } - url="/shixuns/" + id + "/challenges/" + challenge_id + "/create_choose_question.json"; - axios.post(url, { - challenge_choose: {subject: newquestioMDvalue, answer: newnewanswerMDvalue, standard_answer:newlist , score: answeonshixunsmark, difficult: answeshixunsGroup}, - challenge_tag: shixunsskillanswerlist, - question: {cnt: newcnt}, - choice: {answer: newtype} - }).then((response) => { - - let questionaddsums=questionaddarray.length; - let questionaddarrays=questionaddarray; - questionaddarrays[questionaddsums-1].choose_id=response.data.challenge_choose_id; - if(newlist.length===1){ - questionaddarrays[questionaddsums-1].type=1; - }else if(newlist.length>1){ - questionaddarrays[questionaddsums-1].type=2; - } - this.setState({ - challenge_choose_id:response.data.challenge_choose_id, - questionaddtype:false, - editquestionaddtype:false, - newquestioMDvaluetype:false, - newquestioMDvaluetypes:false, - questionaddarray:questionaddarrays - }) - $('html').animate({ - scrollTop: 10 - }, 200); - - notification.open({ - message: '提示', - description: - '新建成功,请点击右侧加号继续添加', - }); - window.location.href=`/shixuns/${id}/challenges/${checkpointId}/editquestion/${response.data.challenge_choose_id}`; - - // this.getanswer_subitlist() - // this.gochooseid("/shixuns/"+this.props.match.params.shixunId+"/challenges/"+this.props.match.params.checkpointId+"/editquestion"+"/"+response.data.challenge_choose_id) - }).catch((error) => { - console.log(error) - }); - } - - - } - - questionlist=(key,challenge_choose_id,type)=>{ - $('html').animate({ - scrollTop:10 - }, 500); - - let{challenge_id} =this.state; - - if(challenge_choose_id===""||type===0){ - - - // this.neweditanswerRef.current.setValue('') - // this.editanswersRef.current.setValue('') - this.setState({ - activetype:challenge_choose_id, - editquestionaddtype:true, - questionaddtype:true, - newquestionaddtype:false, - questionlists:[{str:"A",val:"",type:false},{str:"B",val:"",type:false},{str:"C",val:"",type:false},{str:"D",val:"",type:false}], - answeshixunsGroup: 1, - answeoptions:[10,20], - answeonshixunsmark:10, - shixunssanswerkillvalue:"", - shixunsskillanswerlist:[], - neweditanswerRefval:'', - editanswersRefval:'' - }) - this.newquestioMDMdRef.current.setValue('') - this.newquestioMDMdCont.current.setValue('') - }else{ - let id = this.props.match.params.shixunId; - let url ='/shixuns/'+id+'/challenges/'+challenge_id+'/edit_choose_question.json?choose_id='+challenge_choose_id; - axios.get(url).then((response) => { - if(response.status===200){ - let choose_contents=response.data.choose_contents; - let newchoose_contentslist=[] - for(var i=0; i { - }); - - } - - } - - shixunsautoHeight=()=>{ - $.fn.autoHeight = function(){ - function autoHeight(elem){ - elem.style.height = 'auto'; - elem.style.maxHeight = '140px'; - elem.scrollTop = 0; //防抖动 - if(elem.scrollHeight===0){ - elem.style.height = 62 + 'px'; - }else{ - - elem.style.height = elem.scrollHeight + 'px'; - } - - } - this.each(function(){ - autoHeight(this); - $(this).on('keyup', function(){ - autoHeight(this); - }); - }); - } - $('textarea[autoHeight]').autoHeight(); - } - - gochooseid=(url)=>{ - window.location.href =url - // window.location.Reload(url) - // this.props.history.replace( url ); - // this.props.history.push( url ); - // 返回 - // this.props.history.goBack(); - } - - render() { - - let {choice_url, - practice_url, - go_back_url, - position, - answeoptions, - questionaddarray, - questionaddtype, - activetype, - newquestionaddtype, - editquestionaddtype, - challenge_choose_id, - prev_challenge, - next_challenge, - answer, - - } = this.state; - - let options; - - - options = answeoptions.map((d, k) => { - return ( - - ) - }) - - return ( - -
    - - -
    - - -
  • - 本关任务 -
  • -
    - - { - questionaddarray.length===0?"":questionaddarray.map((item,key)=>{ - return( -
  • this.questionlist(key,item.choose_id,item.type):""} - > - - { - item.choose_id!=0? - this.gochooseid("/shixuns/"+this.props.match.params.shixunId+"/challenges/"+this.props.match.params.checkpointId+"/editquestion"+"/"+item.choose_id)}> - {key+1}.{item.type===2?"多选题":item.type===1?"单选题":'选择题'} - :activetype==="first"?"":{key+1}.{item.type===2?"多选题":item.type===1?"单选题":'选择题'} - } - -
  • - ) - }) - } - - -
  • - - + - -
  • - -
    - - {/*x选择题首页*/} - {activetype==="first"?this.questionInputvalue(e)} - clickquestionsumit={(e)=>this.clickquestionsumit(e)} - - />:""} - - {/*新建*/} - - {newquestionaddtype===true? - this.selquestionlists(key)} - onInputoquestionption={(e,key)=>this.onInputoquestionption(e,key)} - delquestionlists={(key)=>this.delquestionlists(key)} - addquestionlists={(e)=>this.addquestionlists(e)} - onshixunGroupanswe={(e)=>this.onshixunGroupanswe(e)} - onshixunsansweSelect={(e)=>this.onshixunsansweSelect(e)} - shixunssanswerkill={(e)=>this.shixunssanswerkill(e)} - clickshixunsanswerskill={(e)=>this.clickshixunsanswerskill(e)} - delshixunssnswerllist={(key)=>this.delshixunssnswerllist(key)} - answer_subit={()=>this.answer_subit()} - />:""} - - - {/*修改*/} - {editquestionaddtype===true? - this.selquestionlists(key)} - onInputoquestionption={(e,key)=>this.onInputoquestionption(e,key)} - delquestionlists={(key)=>this.delquestionlists(key)} - addquestionlists={(e)=>this.addquestionlists(e)} - onshixunGroupanswe={(e)=>this.onshixunGroupanswe(e)} - onshixunsansweSelect={(e)=>this.onshixunsansweSelect(e)} - shixunssanswerkill={(e)=>this.shixunssanswerkill(e)} - clickshixunsanswerskill={(e)=>this.clickshixunsanswerskill(e)} - delshixunssnswerllist={(key)=>this.delshixunssnswerllist(key)} - answer_subit={()=>this.answer_subit("edit",challenge_choose_id)} - /> - :""} - -
    -
    - ) - } -} - diff --git a/public/react/src/tpm/challengesnew/TpmQuestionEdit.js b/public/react/src/tpm/challengesnew/TpmQuestionEdit.js deleted file mode 100644 index d0e6f98bd..000000000 --- a/public/react/src/tpm/challengesnew/TpmQuestionEdit.js +++ /dev/null @@ -1,229 +0,0 @@ -import React, {Component} from 'react'; - -import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal,Tooltip} from 'antd'; - -import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; - -import axios from 'axios'; - -import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; - -const Option = Select.Option; - -const RadioGroup = Radio.Group; - -export default class TpmQuestionEdit extends Component { - constructor(props) { - super(props) - this.state = { - - } - } - - componentDidMount() { - - } - delecbtns=()=>{ - let url=`/shixuns/${this.props.match.params.shixunId}/challenges/${this.props.match.params.checkpointId}/destroy_challenge_choose.json`; - axios.delete((url), { data: { - choose_id:this.props.match.params.choose_id - }}) - .then((result)=>{ - if(result.data.status===1){ - window.location.href=`/shixuns/${this.props.match.params.shixunId}/challenges/${this.props.match.params.checkpointId}/editquestion`; - } - }) - } - - render() { - - return ( -
    - -
    -
    -

    题干

    -
    - * -
    - -
    - - -
    - 必填项 -
    - -
    -

    -

    -
    - { - this.props.questionlists===undefined||this.props.questionlists.length===0?"":this.props.questionlists.map((item,key)=>{ - return( -
  • - - - this.props.delquestionlists(key)}> - - -
  • - ) - }) - } -

    - this.props.addquestionlists()} - className="fl edu-default-btn edu-greyline-btn mb20 option_icon_add">新增选项 - - - {this.props.newcnttypesum===0?"请选择答案":"选项内容不能为空"} - -

    -
  • - - -
  • -
    -
    -
    - - -
    -
    -

    参考答案

    -
    -
    - -
    -
    - 必填项 -
    -
    -

    -

    -
    -
    - -
    -

    难度系数

    -
    - - this.props.onshixunGroupanswe(e)}> - 简单 - 中等 - 困难 - - -
    -

    奖励经验值

    -
    - * - - -

    - 如果学员答题错误,则不能得到相应的经验值
    - 如果学员成功得到经验值,那么将同时获得等值的金币奖励,如:+10经验值、+10金币 -

    - - 必填项 -
    -
    - -
    -

    技能标签

    -
    - * -
    - this.props.shixunssanswerkill(e)} - value={this.props.shixunssanswerkillvalue} - onPressEnter={(e)=>this.props.clickshixunsanswerskill(e)} - onBlur={(e)=>this.props.clickshixunsanswerskill(e)} - /> - {/*+ 添加*/} -
    学员答题正确将获得技能,否则不能获得技能 - - 必填项 - -
    -
    - - { - this.props.shixunsskillanswerlist.length === 0 ? "" : this.props.shixunsskillanswerlist.map((itme, key) => { - return ( -
  • {itme} - this.props.delshixunssnswerllist(key)}>× -
  • - ) - }) - } - - -
    - -
    - -
    -
    - - -
    4||this.props.identity===undefined||this.props.power===false?"none":"block"}}> - this.props.answer_subit()}>提交 - 取消 - - this.delecbtns()} - className="delectshixuncdbtn fr">删除 -
    - -
    - - ) - } -} - - - diff --git a/public/react/src/tpm/challengesnew/TpmQuestionMain.js b/public/react/src/tpm/challengesnew/TpmQuestionMain.js deleted file mode 100644 index 614842ab8..000000000 --- a/public/react/src/tpm/challengesnew/TpmQuestionMain.js +++ /dev/null @@ -1,84 +0,0 @@ -import React, {Component} from 'react'; - -import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; -import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; - - -export default class TpmQuestionMain extends Component { - constructor(props) { - super(props) - this.state = { - - } - } - - componentDidMount() { - - } - - - render() { - return ( -
    -
    -
    -

    任务名称

    -
    - * -
    - -
    -
    - 必填项 -
    -
    -
    -
    - - -
    -

    过关任务

    -
    - * -
    - -
    -
    - 必填项 -
    -
    -

    -

    -
    - - -
    4 || this.props.identity === undefined || this.props.power === false ? "none" : "block"}}> - 提交 - 取消 - -
    - -
    - - ) - } - } - - - diff --git a/public/react/src/tpm/challengesnew/TpmQuestionNew.js b/public/react/src/tpm/challengesnew/TpmQuestionNew.js deleted file mode 100644 index 861c4f879..000000000 --- a/public/react/src/tpm/challengesnew/TpmQuestionNew.js +++ /dev/null @@ -1,219 +0,0 @@ -import React, {Component} from 'react'; - -import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal,Tooltip} from 'antd'; - -import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; - -import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; - -const Option = Select.Option; - -const RadioGroup = Radio.Group; - -export default class TpmQuestionNew extends Component { - constructor(props) { - super(props) - this.state = { - - } - } - - componentDidMount() { - - } - - - render() { - // console.log( this.props.questionlists) - return ( -
    - -
    -
    -

    题干

    -
    - * -
    - -
    - - -
    - 必填项 -
    - -
    -

    -

    - - -
    - { - this.props.questionlists===undefined||this.props.questionlists.length===0?"":this.props.questionlists.map((item,key)=>{ - return( -
  • - - - this.props.delquestionlists(key)}> - - - - - -
  • - ) - }) - } -

    - this.props.addquestionlists()} - className="fl edu-default-btn edu-greyline-btn mb20 option_icon_add">新增选项 - - - {this.props.newcnttypesum===0?"请选择答案":"选项内容不能为空"} - -

    -
  • - - -
  • -
    -
    -
    - - -
    -
    -

    参考答案

    -
    -
    - -
    -
    - 必填项 -
    -
    -

    -

    - -
    -
    - -
    -

    难度系数

    -
    - - this.props.onshixunGroupanswe(e)} - > - 简单 - 中等 - 困难 - - -
    -

    奖励经验值

    -
    - * - - - -

    - 如果学员答题错误,则不能得到相应的经验值
    - 如果学员成功得到经验值,那么将同时获得等值的金币奖励,如:+10经验值、+10金币 -

    - - 必填项 -
    -
    - -
    -

    技能标签

    -
    - * -
    - this.props.shixunssanswerkill(e)} - value={this.props.shixunssanswerkillvalue} - onPressEnter={(e)=>this.props.clickshixunsanswerskill(e)} - onBlur={(e)=>this.props.clickshixunsanswerskill(e)} - /> - {/*+ 添加*/} -
    学员答题正确将获得技能,否则不能获得技能 - - 必填项 - -
    -
    - - { - this.props.shixunsskillanswerlist.length === 0 ? "" : this.props.shixunsskillanswerlist.map((itme, key) => { - return ( -
  • {itme} - this.props.delshixunssnswerllist(key)}>× -
  • - ) - }) - } - - -
    - -
    - -
    -
    - - -
    4||this.props.identity===undefined||this.props.power===false?"none":"block"}}> - 提交 - 取消 -
    - -
    - - ) - } -} - - - diff --git a/public/react/src/tpm/challengesnew/css/TPMchallengesnew.css b/public/react/src/tpm/challengesnew/css/TPMchallengesnew.css deleted file mode 100644 index 37a65ef97..000000000 --- a/public/react/src/tpm/challengesnew/css/TPMchallengesnew.css +++ /dev/null @@ -1,269 +0,0 @@ -.CodeMirror-scroll { - overflow: auto !important; - margin-bottom: -30px; - margin-right: -30px; - padding-bottom: 30px; - height: 100%; - outline: none; - position: relative; -} -a.white-btn.orange-btn:hover { - border: 1px solid #F06200; - color: #FFF !important; -} -.flex1 a.white-btn.orange-btn:hover { - border: 1px solid #F06200; - color: #FFF !important; -} - -/*.challenge_nav li a{*/ - /*color:#000 !important;*/ -/*}*/ - -.questionli{ - width: 95%; - margin-left: 37px; -} -#directory_file{ - height:200px; - overflow-y:auto; - background:#f5f5f5; - padding:10px; -} -.directory_filepath{ - width:120px; - text-align:left; -} - -a{ - text-decoration: none; - color: #05101a; -} -.repository_url_tippostion{ - position: absolute; - left: 22%; - width: 500px; - top: 100%; -} - -.top-black-trangleft { - display: block; - border-width: 8px; - position: absolute; - top: -16px; - /* right: 4px; */ - border-style: dashed solid dashed dashed; - border-color: transparent transparent rgba(5,16,26,0.6) transparent; - font-size: 0; - line-height: 0; -} - -#exercisememoMD .CodeMirror { - margin-top: 31px !important; - height: 370px !important; - /*width: 579px !important;*/ -} - -#exercisememoMD .editormd-preview { - top: 40px !important; - height: 370px !important; - width: 578px !important; -} -#exercisememoMD{ - /*height: 700px !important;*/ -} -#questioMD{ - /*width: 95% !important;*/ - height: 417px !important; - margin-left: 0% !important; -} - - -#questioMD .CodeMirror { - /*width: 550.5px !important;*/ - margin-top: 31px !important; - height: 374px !important; -} - -#questioMD .editormd-preview { - top: 40px !important; - height: 375px !important; - width: 550px !important; -} - -#newquestioMD .CodeMirror { - /*width: 549px !important;*/ - margin-top: 31px !important; - height: 364px !important; -} - -#newquestioMD .editormd-preview { - top: 40px !important; - height: 364px !important; - width: 578px !important; -} - -#challenge_choose_answer .CodeMirror { - margin-top: 31px !important; - height: 364px !important; - /*width: 578px !important;*/ -} - - -#challenge_choose_answer .editormd-preview { - top: 40px !important; - height: 364px !important; - width: 578px !important; -} - -#neweditanswer .CodeMirror { - margin-top: 31px !important; - height: 364px !important; - /*width: 549.5px !important;*/ -} - -#neweditanswer .editormd-preview { - top: 40px !important; - height: 364px !important; - width: 551px !important; -} - -#repository_url_tip { - top: 30px !important; - left: 249px !important; - width: 292px !important; -} - -#editanswers .CodeMirror{ - /*width: 548px !important;*/ - height: 358px !important; - margin-top: 30px !important; -} -#editanswers .editormd-preview{ - width: 578px !important; - height: 358px !important; - -} -#newquestioMDs .CodeMirror{ - /*width: 510px !important;*/ - height: 358px !important; - margin-top: 30px !important; -} - -#newquestioMDs .editormd-preview{ - width: 578px !important; - height: 358px !important; -} - -.choose_names{ - width: 80px; - margin-left: 20px; -} - -#answerMD .CodeMirror{ - /*width: 569px !important;*/ - height: 600px !important; - margin-top: 30px !important; -} - -#answerMD .editormd-preview{ - width: 578px !important; - height: 600px !important; -} - -#answerMD { - height: 600px !important; -} - -.textareavalue{ - width: 100%; - padding: 5px; - - box-sizing: border-box; -} -.greyInput{ - width: 107%; -} -.greyInpus{ - width: 100%; -} - -.pdr20{ - padding-right:20px; -} - -.winput-240-40s { - background-color: #F5F5F5; -} - - -.winput-240-40s:focus{ - background-color: #fff; -} -.input-100-45{ - background-color: #F5F5F5; -} -.input-100-45:focus{ - background-color: #fff; - } - -.wind100{ - width:100% !important; -} - -.color-bule-tip { - color: #5485f7 !important; -} -.martopf4{ - margin-top:-4px; -} - -.headdfgf{ - display: block; - width: 100px; - height: 30px; - line-height: 30px; - float: left; -} - -.color979797{ - color: #979797 !important; -} - -.border-left{ - width: 0; - height: 0; - border-bottom: 6px solid transparent; - border-right: 6px solid #cccbcb; - border-top: 6px solid transparent; - position: absolute; - left: 30px; - top: 12px; -} -.border-left span{ - display: block; - width: 0; - height: 0; - border-bottom: 6px solid transparent; - border-right: 6px solid #fff; - border-top: 6px solid transparent; - position: absolute; - left: 1px; - top: -6px; - z-index: 10; -} -.fillTip{ - position: absolute; - left: 36px; - top: 2px; - width: 125px; - font-size: 12px; - display: block; - padding: 5px; - border: 1px solid #eaeaea; - border-radius: 5px; - box-sizing: border-box; - height: 32px; - line-height: 20px; - font-family: "微软雅黑","宋体"; -} \ No newline at end of file diff --git a/public/react/src/tpm/challengesnew/editorMD.js b/public/react/src/tpm/challengesnew/editorMD.js deleted file mode 100644 index 50f15b601..000000000 --- a/public/react/src/tpm/challengesnew/editorMD.js +++ /dev/null @@ -1,122 +0,0 @@ -import React, {Component} from 'react'; - -import {getUrl} from 'educoder'; - -let path = getUrl("/editormd/lib/"); - -const $ = window.$; - -function create_editorMD(id, width, high, placeholder, imageUrl, callback) { - var editorName = window.editormd(id, { - width: width, - height: high, - path: path, // "/editormd/lib/" - - syncScrolling: "single", - tex: true, - tocm: true, - emoji: true, - taskList: true, - codeFold: true, - searchReplace: true, - htmlDecode: "style,script,iframe", - sequenceDiagram: true, - autoFocus: false, - toolbarIcons: function () { - // Or return editormd.toolbarModes[name]; // full, simple, mini - // Using "||" set icons align right. - return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"] - }, - toolbarCustomIcons: { - testIcon: "
    ", - testIcon1: "
    " - }, - //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 - saveHTMLToTextarea: true, - // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标 - dialogMaskOpacity: 0.6, - placeholder: placeholder, - imageUpload: true, - imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], - imageUploadURL: imageUrl,//url - onload: function () { - // this.previewing(); - $("#" + id + " [type=\"latex\"]").bind("click", function () { - editorName.cm.replaceSelection("```latex"); - editorName.cm.replaceSelection("\n"); - editorName.cm.replaceSelection("\n"); - editorName.cm.replaceSelection("```"); - var __Cursor = editorName.cm.getDoc().getCursor(); - editorName.cm.setCursor(__Cursor.line - 1, 0); - }); - - $("#" + id + " [type=\"inline\"]").bind("click", function () { - editorName.cm.replaceSelection("`$$$$`"); - var __Cursor = editorName.cm.getDoc().getCursor(); - editorName.cm.setCursor(__Cursor.line, __Cursor.ch - 3); - editorName.cm.focus(); - }); - $("[type=\"inline\"]").attr("title", "行内公式"); - $("[type=\"latex\"]").attr("title", "多行公式"); - - window.md_elocalStorage(editorName, `MemoQuestion_${id}`, `${id}Question`); - - callback && callback() - } - }); - return editorName; -} - - -export default class TPMeditorMD extends Component { - constructor(props) { - super(props) - - } - componentDidMount() { - - - } - - questioMD=(initValue, id)=> { - - this.contentChanged = false; - const placeholder = ""; -// amp; -// 编辑时要传memoId - // const imageUrl = `/upload_with_markdown?container_id=&container_type=Memo`; - const imageUrl = `/api/attachments.json`; -// 创建editorMd - - let questio_editormd = create_editorMD(id, '100%', 400, placeholder, imageUrl, () => { - setTimeout(() => { - questio_editormd.resize() - questio_editormd.cm && questio_editormd.cm.refresh() - }, 500) - - if (initValue != undefined) { - questio_editormd.setValue(initValue) - } - questio_editormd.cm.on("change", (_cm, changeObj) => { - console.log('....contentChanged') - this.contentChanged = true; - }) - }); - this.questio_editormd = questio_editormd; - window.questio_editormd = questio_editormd; - - } - - componentWillReceiveProps(newProps) { - this.questioMD(newProps.value,newProps.id) - } - render() { - return ( -
    - -
    -
    -
    - ) - } -} diff --git a/public/react/src/tpm/component/TPMNav.js b/public/react/src/tpm/component/TPMNav.js deleted file mode 100644 index ff8f57aa5..000000000 --- a/public/react/src/tpm/component/TPMNav.js +++ /dev/null @@ -1,57 +0,0 @@ -import React, { Component } from 'react'; - -import { BrowserRouter as Router, Route, Link } from "react-router-dom"; - -class TPMNav extends Component { - - render() { - const { user, match, shixun, secret_repository } = this.props; - let isAdminOrCreator = false; - if (user) { - isAdminOrCreator = user.admin || user.manager - } - const shixunId = match.params.shixunId; - // const challengesPath = `/shixuns/${shixunId}/challenges`; - // console.log(this.props.propaedeutics) - const challengesPath = `/shixuns/${shixunId}/challenges`; - // console.log(match.path) - return ( -
    - 任务 - - { - this.props.propaedeutics===undefined?"":this.props.propaedeutics===false?"":背景知识 - } - - { this.props.identity >4||this.props.identity===undefined ?"":版本库} - {this.props.identity >4||this.props.identity===undefined ?"": secret_repository && 私密版本库} - - 合作者 - - 评论 - - 排行榜 - - {this.props.identity >2||this.props.identity===undefined?"":审核情况} - - 4||this.props.identity===undefined ? "none" : 'block'}} - >配置 -
    - ); - } -} - -export default TPMNav; diff --git a/public/react/src/tpm/component/TPMRightSection.js b/public/react/src/tpm/component/TPMRightSection.js deleted file mode 100644 index 4306fc6e3..000000000 --- a/public/react/src/tpm/component/TPMRightSection.js +++ /dev/null @@ -1,205 +0,0 @@ -import React, { Component } from 'react'; - -import { BrowserRouter as Router, Route, Link } from "react-router-dom"; - -import axios from 'axios'; - -import { getImageUrl,} from "educoder"; - -import './TPMright.css'; - -import {Icon,Tooltip} from 'antd'; - -// import "antd/dist/antd.css"; - -class TPMRightSection extends Component { - constructor(props) { - super(props) - this.state = { - - TPMRightSection:false, - clickNewsubscripttype:false - } - } - - // componentDidMount() { - // let id=this.props.match.params.shixunId; - // - // let shixunsDetailsURL=`/shixuns/`+id+`/show_right.json`; - // - // axios.get(shixunsDetailsURL).then((response)=> { - // if(response.status===200){ - // this.setState({ - // TPMRightSectionData: response.data - // }); - // } - // }).catch((error)=>{ - // console.log(error) - // }); - // } - - // shouldComponentUpdate(nextProps, nextState) { - // return nextProps.TPMRightSectionData !== this.state.TPMRightSectionData - // } - clickNewsubscript=(val)=>{ - if(val===0){ - this.setState({ - TPMRightSection:true, - clickNewsubscripttype:true - }) - }else{ - this.setState({ - TPMRightSection:false, - clickNewsubscripttype:false - }) - } - - } - render() { - let {TPMRightSection,clickNewsubscripttype}=this.state; - let {TPMRightSectionData}=this.props - - return ( -
    - { - TPMRightSectionData===undefined?"": -
    -
    -

    创建者

    -
    - - 头像 - -
    - -

    {TPMRightSectionData===undefined?"":TPMRightSectionData.creator===undefined?"":TPMRightSectionData.creator.name}

    -
    - 发布 {TPMRightSectionData.user_shixuns_count} - {/*粉丝 {TPMRightSectionData.fans_count}*/} - {/* 取消关注 */} -
    - -
    -
    -
    - { - TPMRightSectionData === undefined ? "" :TPMRightSectionData.tags===undefined?"": TPMRightSectionData.tags.length === 0 ? "" : -
    -

    技能标签 {TPMRightSectionData.tags.length}

    -
    -
    - { TPMRightSectionData.tags.map((item,key)=>{ - return( - {item.tag_name} - )}) - } -
    -
    - - -
    15&&clickNewsubscripttype===false?"newsubscript mb9 color-grey-9":"newsubscript mb9 color-grey-9 none"} - - data-tip-down="显示全部" - onClick={()=>this.clickNewsubscript(0)}>... -
    - - -
    this.clickNewsubscript(1)}> -
    - -
    - - - } - - -
    -

    所属课程

    -
    - { - TPMRightSectionData===undefined?"":TPMRightSectionData.paths===undefined?"":TPMRightSectionData.paths.map((i,k)=>{ - - return( - -
    - - - 实训 - - -
    - {i.name} -

    - - - {i.stages_count} - - - {/**/} - {/*{i.score_count}*/} - {/**/} - - - {i.members_count} - - -

    -
    - -
    - - ) - }) - } -
    -
    - - {TPMRightSectionData === undefined?"":TPMRightSectionData.paths===undefined?"":TPMRightSectionData.paths.length === 0 ? "" : - this.props.user&&this.props.user.main_site===true?
    -

    推荐实训

    -
    - { - TPMRightSectionData===undefined?"":TPMRightSectionData.recommands===undefined?"":TPMRightSectionData.recommands.map((item,key)=>{ - return( -
    - - 69?1526971094 - -
    - - {item.name} - -

    - {item.stu_num} 人学习 -

    -

    {item.level}

    -
    -
    - ) - }) - } -
    -
    :"" - } -
    - } -
    - ) - - - } -} - -export default TPMRightSection; diff --git a/public/react/src/tpm/component/TPMright.css b/public/react/src/tpm/component/TPMright.css deleted file mode 100644 index c664d75c4..000000000 --- a/public/react/src/tpm/component/TPMright.css +++ /dev/null @@ -1,79 +0,0 @@ -/*b新标签*/ -.newedu-filter-btn{ - display: block; - float: left; - padding: 0 9px; - /*height: 28px;*/ - line-height: 28px; - border-radius: 14px; - background-color: #F5F5F5; - color: #666; - margin-right: 10px; - margin-bottom: 9px; -} -.newedbox{ - /*flex-wrap: wrap;*/ - /*display: -webkit-flex; !* Safari *!*/ - /*display: flex;*/ - width: 360px; - position:relative; - overflow: hidden; -} -.newsubscript{ - position: absolute; - right: 23px; - bottom: 16px; - cursor: pointer; -} -.newsubscript:hover{ - color:deepskyblue; -} -.edu-filter-btn29BD8B{ - display: block; - float: left; - padding: 0 9px; - height: 28px; - line-height: 28px; - border-radius: 14px; - background-color: #29BD8B; - color: #FFF; - margin-right: 10px; - margin-bottom: 9px; -} -.relative{ - position:relative; -} -.newedboxheight{ - max-height: 177px; - overflow-y: hidden; -} -.newminheight{ - /*max-height: 670px;*/ - max-height: 300px; - overflow-y: auto; -} - -.delSubentry{ - font-size:7px; - font-family:MicrosoftYaHei; - font-weight:400; - color:rgba(76,172,255,1); - line-height:9px; - cursor: pointer; -} -.operationalter .delSubentry{ - font-size:15px !important; - line-height: 25px; -} -/*临时的tpi关闭按钮样式*/ -.headerRight a { - color: #1a3f5f; -} -/*实训做成弹窗a标签样式调整*/ -.-task-list-title a:link, .-task-list-title a:visited {color: #bcc6cd;} -.-task-list-title a:hover{ - color: #459be5; -} -.headerLeft .-header-right{ - height: 32px; -} \ No newline at end of file diff --git a/public/react/src/tpm/component/modal/RepositoryChooseModal.js b/public/react/src/tpm/component/modal/RepositoryChooseModal.js deleted file mode 100644 index 4b72ae2bd..000000000 --- a/public/react/src/tpm/component/modal/RepositoryChooseModal.js +++ /dev/null @@ -1,153 +0,0 @@ -// import React, { useState, useEffect, memo } from 'react'; -// import axios from 'axios' -// import { Modal, Input } from 'antd'; - -// function RepositoryChooseModal(props) { -// const [trees, setTrees] = useState([]) -// const [path, setPath] = useState('') -// const [pathArray, setPathArray] = useState([{val: "根目录/", path: ""}]) -// const [modalVisible, setModalVisible] = useState(true) - -// useEffect(() => { -// repository('') -// }, []) -// function onOk() { - -// } -// function onCancel() { - -// } -// /** -// 点nav 会传入key -// 点item 会传入 newPath - -// item => name, type type tree/leaf -// */ -// const repository=(item, key, newPath)=>{ -// let newPathArray = [] // -// // -// if (key) { -// for(var i=0; i<=key; i++){ -// newPathArray.push(pathArray[i]) -// } -// } else if (item) { -// newPathArray = pathArray.slice(0) -// newPathArray.push({val: item.name, path: pathArray[pathArray.length - 1] + "/" + item.name}) -// } - -// const path = item || key ? newPathArray[newPathArray.length - 1] : '' - -// let id = props.match.params.shixunId; -// let url ="/shixuns/"+id+"/repository.json"; -// axios.post(url,{ -// path: path -// }).then((response) => { -// if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - -// }else{ -// setTrees(response.data.trees) -// setPath(path) -// pathArray(newPathArray) -// } - -// }).catch((error) => { -// console.log(error) -// }); -// } -// const savegetfilepath=(value)=>{ -// const state = {} -// let {selectpath,saveshixunfilepath,pathtype} = state - -// if(pathtype===1){ -// let newselectpath; - -// if(saveshixunfilepath==="shixunfilepathplay"){ -// newselectpath=value -// }else{ -// const type = selectpath.split(';'); -// let types=false; -// for(var i=0; i{ - -// } -// function sendgetfilepath() { - -// } -// return ( -// -//
    -//
    -// -//
    -// -// saveselectpath(e)} -// value={path}/> -//
    - -// onOk()}>确定 -// onCancel()}>取消 -//
    -//
    -//
    -// ) - -// } - -// export default RepositoryChooseModal \ No newline at end of file diff --git a/public/react/src/tpm/newshixuns/Newshixuns.js b/public/react/src/tpm/newshixuns/Newshixuns.js deleted file mode 100644 index 1eaee9ad6..000000000 --- a/public/react/src/tpm/newshixuns/Newshixuns.js +++ /dev/null @@ -1,1356 +0,0 @@ -import React, {Component} from 'react'; - -import {TPMIndexHOC} from '../TPMIndexHOC'; - -import {SnackbarHOC,appendFileSizeToUploadFileAll, getUploadActionUrl} from 'educoder'; - -import {Input, Select, Radio, Checkbox, Modal, Icon, DatePicker,Upload,Button,message,Form,notification,Tooltip} from 'antd'; - -// import "antd/dist/antd.css"; - -import locale from 'antd/lib/date-picker/locale/zh_CN'; - -import axios from 'axios'; - -import './css/Newshixuns.css'; - -import {getUrl} from 'educoder' - -import moment from 'moment'; - -let path = getUrl("/editormd/lib/") - -const $ = window.$; - -let timeout; - -let currentValue; - -const Option = Select.Option; - -const RadioGroup = Radio.Group; -const confirm = Modal.confirm; - - -// 处理整点 半点 -// 取传入时间往后的第一个半点 -export function handleDateStrings(dateString) { - if (!dateString) return dateString; - const ar = dateString.split(':') - if (ar[1] == '00' || ar[1] == '30') { - return dateString - } - const miniute = parseInt(ar[1]); - if (miniute < 30 || miniute == 60) { - return [ar[0], '30'].join(':') - } - if (miniute < 60) { - // 加一个小时 - const tempStr = [ar[0], '00'].join(':'); - const format = "YYYY-MM-DD HH:mm"; - const _moment = moment(tempStr, format) - _moment.add(1, 'hours') - return _moment.format(format) - } - - return dateString -} - - - -// 恢复数据 -function md_rec_data(k, mdu, id, editor) { - if (window.sessionStorage.getItem(k + mdu) !== null) { - editor.setValue(window.sessionStorage.getItem(k + mdu)); - md_clear_data(k, mdu, id); - } -} - -// 保存数据 -function md_add_data(k, mdu, d) { - window.sessionStorage.setItem(k + mdu, d); -} - -// 清空保存的数据 -function md_clear_data(k, mdu, id) { - window.sessionStorage.removeItem(k + mdu); - var id1 = "#e_tip_" + id; - var id2 = "#e_tips_" + id; - if (k == 'content') { - $(id2).html(""); - } else { - $(id1).html(""); - } -} - -function md_elocalStorage(editor, mdu, id) { - if (window.sessionStorage) { - var oc = window.sessionStorage.getItem('content' + mdu); - if (oc !== null) { - $("#e_tips_" + id).data('editor', editor); - var h = '您上次有已保存的数据,是否恢复 ? / 不恢复'; - $("#e_tips_" + id).html(h); - } - setInterval(function () { - var d = new Date(); - var h = d.getHours(); - var m = d.getMinutes(); - var s = d.getSeconds(); - h = h < 10 ? '0' + h : h; - m = m < 10 ? '0' + m : m; - s = s < 10 ? '0' + s : s; - if (editor.getValue().trim() != "") { - md_add_data("content", mdu, editor.getValue()); - var id1 = "#e_tip_" + id; - var id2 = "#e_tips_" + id; - - $(id1).html(" 数据已于 " + h + ':' + m + ':' + s + " 保存 "); - $(id2).html(""); - } - }, 10000); - - } else { - $("#e_tip_" + id).after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!'); - } -} - - -function create_editorMD(id, width, high, placeholder, imageUrl, callback) { - var editorName = window.editormd(id, { - width: width, - height: high, - path: path, // "/editormd/lib/" - - syncScrolling: "single", - tex: true, - tocm: true, - emoji: true, - taskList: true, - codeFold: true, - searchReplace: true, - htmlDecode: "style,script,iframe", - sequenceDiagram: true, - autoFocus: false, - toolbarIcons: function () { - // Or return editormd.toolbarModes[name]; // full, simple, mini - // Using "||" set icons align right. - return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"] - }, - toolbarCustomIcons: { - testIcon: "
    ", - testIcon1: "
    " - }, - //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 - saveHTMLToTextarea: true, - // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标 - dialogMaskOpacity: 0.6, - placeholder: placeholder, - imageUpload: true, - imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], - imageUploadURL: imageUrl,//url - onload: function () { - // this.previewing(); - $("#" + id + " [type=\"latex\"]").bind("click", function () { - editorName.cm.replaceSelection("```latex"); - editorName.cm.replaceSelection("\n"); - editorName.cm.replaceSelection("\n"); - editorName.cm.replaceSelection("```"); - var __Cursor = editorName.cm.getDoc().getCursor(); - editorName.cm.setCursor(__Cursor.line - 1, 0); - }); - - $("#" + id + " [type=\"inline\"]").bind("click", function () { - editorName.cm.replaceSelection("`$$$$`"); - var __Cursor = editorName.cm.getDoc().getCursor(); - editorName.cm.setCursor(__Cursor.line, __Cursor.ch - 3); - editorName.cm.focus(); - }); - $("[type=\"inline\"]").attr("title", "行内公式"); - $("[type=\"latex\"]").attr("title", "多行公式"); - - md_elocalStorage(editorName, `memoNew_${id}`, "memoNew"); - - callback && callback() - } - }); - return editorName; -} - -function range(start, end) { - const result = []; - for (let i = start; i < end; i++) { - result.push(i); - } - return result; -} -function disabledDateTime() { - return { - // disabledHours: () => range(0, 24).splice(4, 20), - disabledMinutes: () => range(1, 30).concat(range(31, 60)), - // disabledSeconds: () => [0, 60], - }; -} - -function disabledDate(current) { - return current && current < moment().endOf('day').subtract(1, 'days'); -} -class Newshixuns extends Component { - constructor(props) { - super(props) - this.state = { - fileList: [], - newshixunlist: undefined, - departmentslist: undefined, - name: "", - main_type: "", - small_type: "", - trainee: "", - webssh: 0, - use_scope: 0, - can_copy: "", - scope_partment: undefined, - vnc: "", - scopetype: false, - postapplyvisible: false, - sendsure_applyvalue: undefined, - postapplytitle: false, - shixun_nametype: false, - main_types: false, - trainee_types: false, - SelectTheCommandtype: false, - opers: false, - operss: false, - TimePickervalue: "", - opensmail: false, - onSearchvalue: "", - scope_partmenttype: false, - languagewrite: undefined, - systemenvironment:undefined, - testcoderunmode:undefined, - file:undefined, - deleteisnot:true, - languagewritetype:false, - systemenvironmenttype:false, - testcoderunmodetype:false, - attachmentidstype:false, - datalisttype:false, - bottonloading:false - } - } - - initMD(initValue) { - this.contentChanged = false; - const placeholder = ""; - // amp; - // 编辑时要传memoId - const imageUrl = `/api/attachments.json`; - // 创建editorMd - - const taskpass_editormd = create_editorMD("memoMD", '100%', 400, placeholder, imageUrl, () => { - setTimeout(() => { - taskpass_editormd.resize() - taskpass_editormd.cm && taskpass_editormd.cm.refresh() - }, 500) - - if (initValue) { - taskpass_editormd.setValue(initValue) - } - taskpass_editormd.cm.on("change", (_cm, changeObj) => { - // console.log('....contentChanged') - this.contentChanged = true; - }) - }); - this.taskpass_editormd = taskpass_editormd; - window.taskpass_editormd = taskpass_editormd; - - } - - componentDidMount() { - let newshixunUrl = `/shixuns/new.json`; - axios.get(newshixunUrl).then((response) => { - if (response.status === 200) { - if (response.data.message===undefined) { - this.setState({ - newshixunlist: response.data - }); - this.initMD(response.data.sample[0][1]); - } - - } - }).catch((error) => { - console.log(error) - }); - - 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 - }); - } - } - }).catch((error) => { - console.log(error) - }); - } - - setlanguagewrite = (e)=>{ - this.setState({ - languagewrite: e.target.value - }) - } - - setsystemenvironment = (e) => { - this.setState({ - systemenvironment: e.target.value - }) - } - settestcoderunmode = (e) => { - this.setState({ - testcoderunmode: e.target.value - }) - - } - shixunname = (e) => { - this.setState({ - name: e.target.value, - shixun_nametype: false - }); - } - - bigClass = (value) => { - this.setState({ - main_type: value - }) - } - - littleClass = (value) => { - this.setState({ - small_type: value - }) - } - - Selectthestudent = (value) => { - this.setState({ - trainee: value - }) - } - - SelectTheCommand = (e) => { - this.setState({ - webssh: e.target.value, - }); - - if (e.target.value === 2) { - this.setState({ - SelectTheCommandtype: true, - multi_webssh: false - }); - } else { - this.setState({ - SelectTheCommandtype: false, - multi_webssh: false - }); - } - } - - Selectpublic = (e) => { - this.setState({ - scopetype: false, - use_scope: e.target.value, - }); - if (e.target.value === 1) { - this.setState({ - scopetype: true - }); - } - - } - - Teacherscopy = (e) => { - let sum = "" - if (e.target.checked === false) { - sum = 0 - } else if (e.target.checked === true) { - sum = 1 - } - this.setState({ - can_copy: sum, - }); - } - - TeachersUbuntu = (e) => { - let sum = "" - if (e.target.checked === false) { - sum = 0 - } else if (e.target.checked === true) { - sum = 1 - } - this.setState({ - vnc: sum, - }); - } - - adduse_scopeinput = () => { - let {scope_partment} = this.state; - let array = scope_partment; - let newarray = "" - array.push(newarray) - this.setState({ - scope_partment: array, - }); - } - - shixunScopeInput = (e, id) => { - let types=false - let {scope_partment} = this.state; - let datalist = scope_partment; - if (datalist === undefined) { - datalist = [] - } - - datalist.map((item,key)=>{ - if(e===item){ - types=true - this.setState({ - datalisttype:true - }) - return - } - }) - - if(types===false){ - datalist.push(e) - this.setState({ - scope_partment: datalist, - onSearchvalue: "" - }); - } - - - } - - deleteScopeInput = (key) => { - let {scope_partment} = this.state; - let datalist = scope_partment; - datalist.splice(key, 1); - this.setState({ - scope_partment: datalist - }); - } - - //提交数据 - submit_new_shixun = () => { - const mdVal = this.taskpass_editormd.getValue(); - let {can_copy, main_type, name, scope_partment, small_type, trainee, use_scope, vnc, webssh, multi_webssh, TimePickervalue} = this.state; - let Url = `/shixuns.json` - if (name === "") { - this.setState({ - shixun_nametype: true - }) - this.props.showSnackbar("实训名称为空"); - $('html').animate({ - scrollTop: 10 - }, 1000); - return - } - if (main_type === "") { - this.setState({ - main_types: true - }) - $('html').animate({ - scrollTop: 700 - }, 1000); - this.props.showSnackbar("请选择技术平台大类别"); - - return - } - - if (use_scope === 1) { - if (scope_partment === undefined || scope_partment.length === 0) { - this.setState({ - scope_partmenttype: true - }) - $('html').animate({ - scrollTop: 900 - }, 1000); - this.props.showSnackbar("公开程度,指定单位为空"); - return - } - } - if (trainee === "") { - this.setState({ - trainee_types: true - }) - // $('html').animate({ - // scrollTop: 700 - // }, 1000); - this.props.showSnackbar("请选择发布信息"); - return - } - let newmulti_webssh = multi_webssh; - if (newmulti_webssh === true) { - newmulti_webssh = 1 - } else { - newmulti_webssh = "" - } - this.setState({ - bottonloading:true - }) - axios.post(Url, { - name: name, - can_copy: can_copy, - description: mdVal, - main_type: main_type, - scope_partment: scope_partment, - small_type: small_type, - trainee: trainee, - use_scope: use_scope, - vnc: vnc, - webssh: webssh, - multi_webssh: newmulti_webssh, - task_pass: 1, - opening_time: TimePickervalue - } - ).then((response) => { - if (response.status === 200) { - window.location.href = "/shixuns/" + response.data.shixun_identifier + "/challenges"; - // window.open("/shixuns/"+response.data.shixun_identifier+"/challenges"); - }else{ - this.setState({ - bottonloading:false - }) - } - }).catch((error) => { - console.log(error) - this.setState({ - bottonloading:false - }) - }) - } - - - shixunsfetch = (value, callback) => { - if (timeout) { - clearTimeout(timeout); - timeout = null; - } - currentValue = value; - - function fake() { - let departmentsUrl = `/shixuns/departments.json?q=` + currentValue; - axios.get(departmentsUrl).then((response) => { - if (response.data.message===undefined) { - callback(response.data.shools_name); - } - }).catch((error) => { - console.log(error) - }); - } - - timeout = setTimeout(fake, 300); - } - - shixunHandleSearch = (value) => { - - this.shixunsfetch(value, departmentslist => this.setState({departmentslist})); - - this.setState({ - onSearchvalue: "" - }) - } - - post_apply = () => { - this.setState({ - postapplyvisible: true - }) - } - sendsure_apply = () => { - let {languagewrite,systemenvironment,testcoderunmode} = this.state; - // console.log("点击确定") - // console.log("languagewrite"+languagewrite); - // console.log("systemenvironment"+systemenvironment); - // console.log("testcoderunmode"+testcoderunmode); - - // let attachment_ids = undefined - // if (this.state.fileList) { - // attachment_ids = this.state.fileList.map(item => { - // return item.response ? item.response.id : item.id - // }) - // } - if(languagewrite === undefined || languagewrite === "" ){ - // this.props.showNotification(`请填写该镜像是基于什么语言`); - this.setState({ - languagewritetype:true - }) - return - } - if(systemenvironment === undefined || systemenvironment === ""){ - // this.props.showNotification(`请填写该镜像是基于什么语言系统环境`); - this.setState({ - systemenvironmenttype:true - }) - return; - - } - if(testcoderunmode === undefined || testcoderunmode === "") { - // this.props.showNotification(`请填写该镜像中测试代码运行方式`); - this.setState({ - testcoderunmodetype:true - }) - return; - } - var attachment_ids=undefined; - if (this.state.fileList) { - attachment_ids = this.state.fileList.map(item => { - return item.response ? item.response.id : item.id - }) - } - - if( attachment_ids === undefined || attachment_ids.length===0){ - - // notification.open( - // { - // message: '提示', - // description: - // '请上传附件!', - // - // } - // ) - this.setState({ - attachmentidstype:true - }) - return; - } - // console.log("attachment_ids"+attachment_ids); - - // alert(languagewrite +" "+systemenvironment +" "+testcoderunmode + " "+attachment_ids); - - var data={ - language:languagewrite, - runtime:systemenvironment, - run_method:testcoderunmode, - attachment_id:attachment_ids[0], - } - var url =`/shixuns/apply_shixun_mirror.json`; - axios.post(url,data - ).then((response) => { - - try { - if (response.data) { - // const { id } = response.data; - // if (id) { - if(this.state.file !== undefined){ - console.log("549"); - // this.deleteAttachment(this.state.file); - this.setState({ - file:undefined, - deleteisnot:true, - languagewrite:"", - systemenvironment:"", - testcoderunmode:"", - fileList:[] - }) - }else { - this.setState({ - file:undefined, - deleteisnot:true, - languagewrite:"", - systemenvironment:"", - testcoderunmode:"", - fileList:[] - }) - } - // this.props.showNotification('提交成功!'); - notification.open( - { - message: '提示', - description: - '提交成功!', - - } - ) - this.sendhideModaly() - // this.props.history.push(`/courses/${cid}/graduation_topics`); - // } - } - }catch (e) { - - } - - }) - - } - sendhideModaly = () => { - this.setState({ - postapplyvisible: false, - }) - if(this.state.file !== undefined){ - console.log("580"); - // this.deleteAttachment(this.state.file); - this.setState({ - file:undefined, - deleteisnot:true, - languagewrite:"", - systemenvironment:"", - testcoderunmode:"", - fileList:[] - }) - }else { - this.setState({ - file:undefined, - deleteisnot:true, - languagewrite:"", - systemenvironment:"", - testcoderunmode:"", - fileList:[] - }) - } - } - sendsure_applyvalues = (e) => { - this.setState({ - sendsure_applyvalue: e.target.value - }) - } - yeshidemodel = () => { - this.setState({ - postapplytitle: false - }) - } - - SelectTheCommandonChange = (e) => { - this.setState({ - multi_webssh: e.target.checked - }) - } - - - bigopen = (e) => { - this.setState({ - opers: true - }) - - } - - bigopens = (e) => { - this.setState({ - opers: false, - operss: false, - opensmail: false - }) - - } - - bigopensmal = (e) => { - this.setState({ - opensmail: true - }) - - } - - sbigopen = (e) => { - this.setState({ - operss: true - }) - - } - - // sbigopens=()=>{ - // this.setState({ - // operss:false - // }) - // } - - onChangeTimePicker = (value, dateString) => { - this.setState({ - TimePickervalue: dateString=== ""?"":moment(handleDateStrings(dateString)) - }) - } - - // 附件相关 START - handleChange = (info) => { - if(info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') { - let {fileList} = this.state; - - if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') { - console.log("handleChange1"); - // if(fileList.length===0){ - let fileLists = info.fileList; - this.setState({ - // fileList:appendFileSizeToUploadFileAll(fileList), - fileList: fileLists, - deleteisnot: false - }); - // } - } - } - } - onAttachmentRemove = (file) => { - if(!file.percent || file.percent == 100){ - confirm({ - title: '确定要删除这个附件吗?', - okText: '确定', - cancelText: '取消', - // content: 'Some descriptions', - onOk: () => { - console.log("665") - this.deleteAttachment(file) - }, - onCancel() { - console.log('Cancel'); - }, - }); - return false; - } - - } - deleteAttachment = (file) => { - console.log(file); - let id=file.response ==undefined ? file.id : file.response.id - const url = `/attachments/${id}.json` - axios.delete(url, { - }) - .then((response) => { - if (response.data) { - const { status } = response.data; - if (status == 0) { - // console.log('--- success') - - this.setState((state) => { - - const index = state.fileList.indexOf(file); - const newFileList = state.fileList.slice(); - newFileList.splice(index, 1); - return { - fileList: newFileList, - deleteisnot:true - }; - }); - } - } - }) - .catch(function (error) { - console.log(error); - }); - } - - - handleSubmit=()=>{ - // console.log(this.state.languagewrite) - // console.log(this.state.systemenvironment) - // console.log(this.state.testcoderunmode) - var attachment_ids; - if (this.state.fileList) { - attachment_ids = this.state.fileList.map(item => { - return item.response ? item.response.id : item.id - }) - } - // console.log(attachment_ids); - // var data={ - // language:"", - // runtime:"", - // run_method:"", - // attachment_id:"", - // } - // axios.post(url,data - // ).then((response) => { - // if (response.data) { - // // const { id } = response.data; - // // if (id) { - // this.props.showNotification('提交成功!'); - // // this.props.history.push(`/courses/${cid}/graduation_topics`); - // // } - // } - // }) - - - - } - render() { - const { getFieldDecorator } = this.props.form; - let {testcoderunmode ,systemenvironment,languagewrite,deleteisnot, fileList,TimePickervalue, scope_partmenttype, opensmail, newshixunlist, name, scope_partment, departmentslist, postapplyvisible, sendsure_applyvalue, postapplytitle, shixun_nametype, main_types, trainee_types, SelectTheCommandtype, opers, datalisttype, onSearchvalue} = this.state; - let options - if (departmentslist != undefined) { - options = this.state.departmentslist.map((d, k) => { - return ( - - ) - }) - } - const uploadProps = { - width: 600, - fileList, - multiple: true, - // https://github.com/ant-design/ant-design/issues/15505 - // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 - // showUploadList: false, - action: `${getUploadActionUrl()}`, - onChange: this.handleChange, - onRemove: this.onAttachmentRemove, - beforeUpload: (file, fileList) => { - - if (this.state.fileList.length >= 1) { - return false - } - // console.log('beforeUpload', file.name); - const isLt150M = file.size / 1024 / 1024 < 50; - if (!isLt150M) { - // this.props.showNotification(`文件大小必须小于50MB`); - notification.open( - { - message: '提示', - description: - '文件大小必须小于50MB', - - } - ) - } - if(this.state.file !== undefined){ - console.log("763") - this.setState({ - file:file - }) - }else { - this.setState({ - file:file - }) - } - - console.log("handleChange2"); - return isLt150M; - }, - } - // const uploadProps = { - // width: 600, - // fileList, - // multiple: true, - // // https://github.com/ant-design/ant-design/issues/15505 - // // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 - // // showUploadList: false, - // action: `${getUrl()}/api/attachments.json`, - // onChange: this.handleChange, - // onRemove: this.onAttachmentRemove, - // beforeUpload: (file) => { - // // console.log('beforeUpload', file.name); - // const isLt50M = file.size / 1024 / 1024 < 50; - // if (!isLt50M) { - // this.props.showNotification('文件大小必须小于150MB!'); - // } - // return isLt50M; - // }, - // }; - - return ( - -
    -
    -
    - -
    -

    - 创建实训 - {this.props.user&&this.props.user.main_site===true?实训制作指南:""} -

    - -
    -

    实训名称

    -
    - * -
    - - - 必填项 - -
    - -
    -
    - -
    - - -
    - -

    简介

    - -
    -
    - -
    -
    -

    -

    -
    - -
    -

    技术平台

    -
    - * -
    - -

    - 列表中没有? - 申请新建 -

    - - - {/**/} -
    -
  • - - -
  • -
    {this.state.languagewritetype===true?"请填写该镜像语言":""}
    -
  • - - -
  • -
    {this.state.systemenvironmenttype===true?"请填写该镜像语言系统环境":""}
    -
  • - - - -
  • -
    {this.state.testcoderunmodetype===true?"请填写该镜像测试代码运行方式":""}
    -
  • - -
    - - - 上传附件 - (单个文件50M以内) - - -
    - -
  • -
    - {this.state.attachmentidstype===true?"请上传附件":""} -
    -
  • - this.sendhideModaly()} - >取消 - -
  • -
    -
    - {/**/} -
    - - - - -
    -

    新建申请已提交,请等待管理员的审核

    -
  • 我们将在1-2个工作日内与您联系 -
  • -
    -
    - 知道啦 -
    -
    -
    -
    -
    - -
    -

    请在配置页面完成后续的评测脚本设置操作

    -
    - 必填项 -
    -
    -
    - - -
    -

    命令行

    -
    - - 无命令行窗口 (选中则不给学员的实践任务提供命令窗口) - 命令行练习窗口 (选中则给学员提供用于练习操作的命令行窗口) - 命令行评测窗口 (选中则给学员提供用于关卡评测的命令行窗口) - - 多个命令行窗口(选中则允许学员同时开启多个命令行窗口) - - -
    -
    - - -
    -

    公开程度

    -
    - - 对所有公开 (选中则所有已被试用授权的用户可以学习) - 对指定单位公开 (选中则下方指定单位的已被试用授权的用户可以学习) - - -
    -
    -
    -
    -
    - -
    - (搜索选中添加单位名称) - {this.state.datalisttype===true?请勿选择重复单位:""} - {/*+ 添加*/} -
    -
    - -
    -
    - { - scope_partment === undefined ? "" : scope_partment.map((item, key) => { - return ( -
  • {item} - this.deleteScopeInput(key)}>× -
  • - ) - }) - } -
    - {/*{*/} - {/*scope_partment===undefined?"":scope_partment.map((item,key)=>{*/} - {/*return(*/} - {/*
    */} - {/*this.deleteScopeInput(key)} style={{ color: 'rgba(0,0,0,.25)' }} />}*/} - {/*value={item}*/} - {/*/>*/} - {/*
    */} - - {/*)*/} - {/*})*/} - {/*}*/} -
    - - - - 请选择需要公开的单位 - -
    -
    -
    -
    - - -
    -

    发布信息

    -
    -
    - *面向学员: -
    - -
    - 实训难易度定位,不限定用户群体 -
    - 必填项 -
    -
    -
    -
  • - 复制: - - -
  • -
    - 开启时间: -
  • - - -
  • -
    -
    - {/*
    */} - {/*

    VNC图形化

    */} - {/*
  • */} - {/**/} - {/**/} - {/*
  • */} - {/*
    */} - - -
    - - 取消 -
    - - -
    -
    -
    - - ); - } -} -const NewshixunsNew = Form.create({ name: 'newshixunsnew' })(Newshixuns); -export default SnackbarHOC()(TPMIndexHOC(NewshixunsNew)); - - - - - - diff --git a/public/react/src/tpm/newshixuns/TPMNewshixuns/TPMNewshixuns.js b/public/react/src/tpm/newshixuns/TPMNewshixuns/TPMNewshixuns.js deleted file mode 100644 index 8b102651f..000000000 --- a/public/react/src/tpm/newshixuns/TPMNewshixuns/TPMNewshixuns.js +++ /dev/null @@ -1,19 +0,0 @@ -import React, { Component } from 'react'; - -import axios from 'axios'; - -export default class TPMNewshixuns extends Component { - constructor(props) { - super(props) - this.state = { - - } - } - render() { - return ( - - ); - } -} - - diff --git a/public/react/src/tpm/newshixuns/css/Newshixuns.css b/public/react/src/tpm/newshixuns/css/Newshixuns.css deleted file mode 100644 index e241dcf0d..000000000 --- a/public/react/src/tpm/newshixuns/css/Newshixuns.css +++ /dev/null @@ -1,397 +0,0 @@ -/* BASICS */ - -.CodeMirror { - /* Set height, width, borders, and global font properties here */ - font-family: monospace; - height: 300px; - color: black; - direction: ltr; -} - -/* PADDING */ - -.CodeMirror-lines { - padding: 4px 0; /* Vertical padding around content */ -} -.CodeMirror pre { - padding: 0 4px; /* Horizontal padding of content */ -} - -.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { - background-color: white; /* The little square between H and V scrollbars */ -} - -/* GUTTER */ - -.CodeMirror-gutters { - border-right: 1px solid #ddd; - background-color: #f7f7f7; - white-space: nowrap; -} -.CodeMirror-linenumbers {} -.CodeMirror-linenumber { - padding: 0 3px 0 5px; - min-width: 20px; - text-align: right; - color: #999; - white-space: nowrap; -} - -.CodeMirror-guttermarker { color: black; } -.CodeMirror-guttermarker-subtle { color: #999; } - -/* CURSOR */ - -.CodeMirror-cursor { - border-left: 1px solid black; - border-right: none; - width: 0; -} -/* Shown when moving in bi-directional text */ -.CodeMirror div.CodeMirror-secondarycursor { - border-left: 1px solid silver; -} -.cm-fat-cursor .CodeMirror-cursor { - width: auto; - border: 0 !important; - background: #7e7; -} -.cm-fat-cursor div.CodeMirror-cursors { - z-index: 1; -} -.cm-fat-cursor-mark { - background-color: rgba(20, 255, 20, 0.5); - -webkit-animation: blink 1.06s steps(1) infinite; - animation: blink 1.06s steps(1) infinite; -} -.cm-animate-fat-cursor { - width: auto; - border: 0; - -webkit-animation: blink 1.06s steps(1) infinite; - animation: blink 1.06s steps(1) infinite; - background-color: #7e7; -} -@-webkit-keyframes blink { - 0% {} - 50% { background-color: transparent; } - 100% {} -} -@keyframes blink { - 0% {} - 50% { background-color: transparent; } - 100% {} -} - -/* Can style cursor different in overwrite (non-insert) mode */ -.CodeMirror-overwrite .CodeMirror-cursor {} - -.cm-tab { display: inline-block; text-decoration: inherit; } - -.CodeMirror-rulers { - position: absolute; - left: 0; right: 0; top: -50px; bottom: -20px; - overflow: hidden; -} -.CodeMirror-ruler { - border-left: 1px solid #ccc; - top: 0; bottom: 0; - position: absolute; -} - -/* DEFAULT THEME */ - -.cm-s-default .cm-header {color: blue;} -.cm-s-default .cm-quote {color: #090;} -.cm-negative {color: #d44;} -.cm-positive {color: #292;} -.cm-header, .cm-strong {font-weight: bold;} -.cm-em {font-style: italic;} -.cm-link {text-decoration: underline;} -.cm-strikethrough {text-decoration: line-through;} - -.cm-s-default .cm-keyword {color: #708;} -.cm-s-default .cm-atom {color: #219;} -.cm-s-default .cm-number {color: #164;} -.cm-s-default .cm-def {color: #00f;} -.cm-s-default .cm-variable, -.cm-s-default .cm-punctuation, -.cm-s-default .cm-property, -.cm-s-default .cm-operator {} -.cm-s-default .cm-variable-2 {color: #05a;} -.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;} -.cm-s-default .cm-comment {color: #a50;} -.cm-s-default .cm-string {color: #a11;} -.cm-s-default .cm-string-2 {color: #f50;} -.cm-s-default .cm-meta {color: #555;} -.cm-s-default .cm-qualifier {color: #555;} -.cm-s-default .cm-builtin {color: #30a;} -.cm-s-default .cm-bracket {color: #997;} -.cm-s-default .cm-tag {color: #170;} -.cm-s-default .cm-attribute {color: #00c;} -.cm-s-default .cm-hr {color: #999;} -.cm-s-default .cm-link {color: #00c;} - -.cm-s-default .cm-error {color: #f00;} -.cm-invalidchar {color: #f00;} - -.CodeMirror-composing { border-bottom: 2px solid; } - -/* Default styles for common addons */ - -div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;} -div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;} -.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); } -.CodeMirror-activeline-background {background: #e8f2ff;} - -/* STOP */ - -/* The rest of this file contains styles related to the mechanics of - the editor. You probably shouldn't touch them. */ - -.CodeMirror { - position: relative; - overflow: hidden; - background: white; -} - -.CodeMirror-scroll { - overflow: scroll !important; /* Things will break if this is overridden */ - /* 30px is the magic margin used to hide the element's real scrollbars */ - /* See overflow: hidden in .CodeMirror */ - margin-bottom: -30px; margin-right: -30px; - padding-bottom: 30px; - height: 100%; - outline: none; /* Prevent dragging from highlighting the element */ - position: relative; -} -.CodeMirror-sizer { - position: relative; - border-right: 30px solid transparent; -} - -/* The fake, visible scrollbars. Used to force redraw during scrolling - before actual scrolling happens, thus preventing shaking and - flickering artifacts. */ -.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { - position: absolute; - z-index: 6; - display: none; -} -.CodeMirror-vscrollbar { - right: 0; top: 0; - overflow-x: hidden; - overflow-y: scroll; -} -.CodeMirror-hscrollbar { - bottom: 0; left: 0; - overflow-y: hidden; - overflow-x: scroll; -} -.CodeMirror-scrollbar-filler { - right: 0; bottom: 0; -} -.CodeMirror-gutter-filler { - left: 0; bottom: 0; -} - -.CodeMirror-gutters { - position: absolute; left: 0; top: 0; - min-height: 100%; - z-index: 3; -} -.CodeMirror-gutter { - white-space: normal; - height: 100%; - display: inline-block; - vertical-align: top; - margin-bottom: -30px; -} -.CodeMirror-gutter-wrapper { - position: absolute; - z-index: 4; - background: none !important; - border: none !important; -} -.CodeMirror-gutter-background { - position: absolute; - top: 0; bottom: 0; - z-index: 4; -} -.CodeMirror-gutter-elt { - position: absolute; - cursor: default; - z-index: 4; -} -.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent } -.CodeMirror-gutter-wrapper ::selection { background-color: transparent } -.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent } - -.CodeMirror-lines { - cursor: text; - min-height: 1px; /* prevents collapsing before first draw */ -} -.CodeMirror pre { - /* Reset some styles that the rest of the page might have set */ border-radius: 0; - border-width: 0; - background: transparent; - font-family: inherit; - font-size: inherit; - margin: 0; - white-space: pre; - word-wrap: normal; - line-height: inherit; - color: inherit; - z-index: 2; - position: relative; - overflow: visible; - -webkit-tap-highlight-color: transparent; - -webkit-font-variant-ligatures: contextual; - font-variant-ligatures: contextual; -} -.CodeMirror-wrap pre { - word-wrap: break-word; - white-space: pre-wrap; - word-break: normal; -} - -.CodeMirror-linebackground { - position: absolute; - left: 0; right: 0; top: 0; bottom: 0; - z-index: 0; -} - -.CodeMirror-linewidget { - position: relative; - z-index: 2; - padding: 0.1px; /* Force widget margins to stay inside of the container */ -} - -.CodeMirror-widget {} - -.CodeMirror-rtl pre { direction: rtl; } - -.CodeMirror-code { - outline: none; -} - -/* Force content-box sizing for the elements where we expect it */ -.CodeMirror-scroll, -.CodeMirror-sizer, -.CodeMirror-gutter, -.CodeMirror-gutters, -.CodeMirror-linenumber { - -webkit-box-sizing: content-box; - box-sizing: content-box; -} - -.CodeMirror-measure { - position: absolute; - width: 100%; - height: 0; - overflow: hidden; - visibility: hidden; -} - -.CodeMirror-cursor { - position: absolute; - pointer-events: none; -} -.CodeMirror-measure pre { position: static; } - -div.CodeMirror-cursors { - visibility: hidden; - position: relative; - z-index: 3; -} -div.CodeMirror-dragcursors { - visibility: visible; -} - -.CodeMirror-focused div.CodeMirror-cursors { - visibility: visible; -} - -.CodeMirror-selected { background: #d9d9d9; } -.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; } -.CodeMirror-crosshair { cursor: crosshair; } -.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; } -.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; } -.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; } - -.cm-searching { - background-color: #ffa; - background-color: rgba(255, 255, 0, .4); -} - -/* Used to force a border model for a node */ -.cm-force-border { padding-right: .1px; } - -@media print { - /* Hide the cursor when printing */ - .CodeMirror div.CodeMirror-cursors { - visibility: hidden; - } -} - -/* See issue #2901 */ -.cm-tab-wrap-hack:after { content: ''; } - -/* Help users use markselection to safely style text background */ -span.CodeMirror-selectedtext { background: none; } - - - - -.radioStyle{ - display: block; - height: 30px; - } -a.white-btn.use_scope-btn:hover{ - -} -.shixunScopeInput{ - width:218px; - height:33px; - display:block; - margin-bottom:15px; -} - -#memoMD .CodeMirror { - /*width: 576px !important;*/ - margin-top: 31px !important; - height: 364px !important; -} - -#memoMD .editormd-preview { - width: 578px !important; - top: 40px !important; - height: 364px !important; -} - -.ml36{ - margin-left: 26px; -} -#person-unit a.white-btn.use_scope-btn:hover { - border: 1px solid #F06200; - color:#FFF !important; -} - -.shixunspanred{ - margin-left: 142px; - margin-top: 5px; - margin-bottom: 5px; -} - -.ml82{ - margin-left: 82px; -} - -.ant-btn-primary.active, .ant-btn-primary:active { - color: #fff; - background-color: #096dd9; - border-color: #096dd9; -} - -.ant-btn:hover, .ant-btn:focus, .ant-btn:active, .ant-btn.active{ - background-color: #4CACFF; -} \ No newline at end of file diff --git a/public/react/src/tpm/roundedRectangle.png b/public/react/src/tpm/roundedRectangle.png deleted file mode 100755 index 0d2d0b0dc..000000000 Binary files a/public/react/src/tpm/roundedRectangle.png and /dev/null differ diff --git a/public/react/src/tpm/shixunchild/Challenges/Challenges.js b/public/react/src/tpm/shixunchild/Challenges/Challenges.js deleted file mode 100644 index 1470d45db..000000000 --- a/public/react/src/tpm/shixunchild/Challenges/Challenges.js +++ /dev/null @@ -1,676 +0,0 @@ -import React, { Component } from 'react'; - -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames'; - -import { getImageUrl ,markdownToHTML, configShareForCustom} from 'educoder' - -import { CircularProgress } from 'material-ui/Progress'; - -import { Modal, Spin, Tooltip ,message,Icon} from 'antd'; - -import 'antd/lib/pagination/style/index.css'; - -import '../shixunchildCss/Challenges.css' - -import axios from 'axios'; - -import AccountProfile from"../../../user/AccountProfile"; - -const $ = window.$; - -class Challenges extends Component { - constructor(props) { - super(props) - this.state = { - ChallengesDataList: undefined, - operate: true, - startbtns: false, - sumid: "", - sumidtype: false, - startshixunCombattype:false, - shixunsreplace:false, - shixunsmessage:"", - hidestartshixunsreplacevalue:"", - operationstrue:false, - isSpin:false, - } - } - - ChallengesList = () => { - let id = this.props.match.params.shixunId; - let ChallengesURL = `/shixuns/` + id + `/challenges.json`; - - axios.get(ChallengesURL).then((response) => { - if (response.status === 200) { - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - - }else{ - configShareForCustom(this.props.shixunsDetails.name, response.data.description) - this.setState({ - ChallengesDataList: response.data, - sumidtype: false, - }); - } - } - }).catch((error) => { - console.log(error) - }); - } - - componentDidMount() { - setTimeout(this.ChallengesList(), 1000); - } - - updatamakedown = (id) => { - setTimeout(() => { - var shixunDescr = window.editormd.markdownToHTML(id, { - htmlDecode: "style,script,iframe", - taskList: true, - tex: true, - flowChart: true, - sequenceDiagram: true - }); - $("#" + id + " p:first").addClass("ReactMarkdown"); - }, 200) - } - - // 关卡的上移下移操作 - operations = (sumid, type) => { - this.setState({ - operationstrue:true - }) - let { ChallengesDataList } = this.state; - let operationUrl; - if (type === "up") { - operationUrl = "/shixuns/" + ChallengesDataList.shixun_identifier + "/challenges/" + sumid + "/index_up.json"; - } else if (type === "down") { - operationUrl = "/shixuns/" + ChallengesDataList.shixun_identifier + "/challenges/" + sumid + "/index_down.json"; - } - if (this.state.operate) { - - this.setState({ - operate: false - }); - axios.get(operationUrl).then((response) => { - if (response.status === 200) { - this.setState({ - operate: true, - operationstrue:false - }); - this.ChallengesList(); - - } - }).catch((error) => { - console.log(error); - this.setState({ - operate: true, - operationstrue:false - }); - this.ChallengesList() - }) - } - } - delOperations = (sumid) => { - this.setState({ - sumid: sumid, - sumidtype: true - }) - } - - clonedelOperationss = () => { - this.setState({ - sumidtype: false - }) - } - delOperationss = () => { - let { ChallengesDataList, sumid } = this.state; - let operationUrl = "/shixuns/" + ChallengesDataList.shixun_identifier + "/challenges/" + sumid+".json" - - if (this.state.operate) { - this.setState({ - operate: false, - sumidtype: false - }) - axios.delete(operationUrl, { - withCredentials: true - }).then((response) => { - if (response.status === 200) { - this.setState({ - operate: true, - sumidtype: false - }); - this.ChallengesList(); - } - this.ChallengesList() - }).catch((error) => { - console.log(error); - this.setState({ - operate: true, - sumidtype: false - }); - this.ChallengesList() - }) - } - } - - startgameid=(id)=>{ - - let url = "/shixuns/" + id + "/shixun_exec.json"; - axios.get(url).then((response) => { - - if (response.data.status === -2) { - this.setState({ - shixunsreplace:true, - hidestartshixunsreplacevalue:response.data.message+".json" - }) - } else if (response.data.status === -1) { - console.log(response) - }else if(response.data.status===-3){ - this.setState({ - shixunsmessage:response.data.message, - startshixunCombattype:true, - }) - } else { - window.location.href = "/tasks/" + response.data.game_identifier; - // window.location.href = path - // let path="/tasks/"+response.data.game_identifier; - // this.props.history.push(path); - } - }).catch((error) => { - - }); - - - } - - hidestartshixunsreplace=(url)=>{ - this.setState({ - isSpin:true, - }) - axios.get(url).then((response) => { - if(response.status===200){ - // let path="/shixuns/"+response.data.shixun_identifier+"/challenges"; - // this.props.history.push(path); - message.success('重置成功,正在进入实训!'); - this.startgameid(response.data.shixun_identifier); - this.setState({ - shixunsreplace:false, - isSpin:false, - }) - - // message.success('重置成功,正在进入实训!'); - // this.startshixunCombat(); - }} - ).catch((error) => { - - }); - - } - - //编辑实训题目选择题 - EditTraining=(type, ids, path)=>{ - let { ChallengesDataList } = this.state; - window.location.href = "/shixuns/" + ChallengesDataList.shixun_identifier + "/challenges/" + ids + path; - } - - //开始实战按钮 - startshixunCombat = (type, ids, id) => { - - if(this.props.checkIfLogin()===false){ - this.props.showLoginDialog() - return - } - - if(this.props.checkIfProfileCompleted()===false){ - this.setState({ - AccountProfiletype:true - }) - return - } - - // if(this.props.checkIfProfessionalCertification()===false){ - // this.setState({ - // AccountProfiletype:true - // }) - // return - // } - - - let { ChallengesDataList } = this.state; - // let id = this.props.match.params.shixunId; - this.setState({ - startbtns: true - }) - let url = "/shixuns/" + ChallengesDataList.shixun_identifier + "/shixun_exec.json?challenge_id="+id; - axios.get(url).then((response) => { - - if (response.data.status === -2) { - this.setState({ - startbtns:false, - shixunsreplace:true, - hidestartshixunsreplacevalue:response.data.message+".json" - }) - } else if (response.data.status === -1) { - this.setState({ - startbtns: false - }) - console.log(response) - }else if(response.data.status===-3){ - this.setState({ - shixunsmessage:response.data.message, - startshixunCombattype:true, - startbtns:false - }) - } else { - window.location.href = "/tasks/" + response.data.game_identifier; - // window.location.href = path - // let path="/tasks/"+response.data.game_identifier; - // this.props.history.push(path); - } - }).catch((error) => { - - }); - - - // if(path===null){ - // }else{ - // if (type > 4 || type === false) { - // window.location.href = path; - // } else { - // - // } - // } - - - } - hidestartshixunCombattype=()=>{ - this.setState({ - startshixunCombattype:false - }) - } - - hideAccountProfile=()=>{ - this.setState({ - AccountProfiletype:false - }) - } - - render() { - let { ChallengesDataList, startbtns, sumidtype ,startshixunCombattype,shixunsreplace,shixunsmessage,hidestartshixunsreplacevalue,operationstrue,AccountProfiletype} = this.state; - let { loadingContent } = this.props; - if (ChallengesDataList != undefined) { - this.updatamakedown("ReactMarkdown") - } - let id = this.props.match.params.shixunId; - const antIcon = ; - return ( - - {AccountProfiletype===true?this.hideAccountProfile()} - {...this.props} - {...this.state} - />:""} - - {loadingContent ? - : - -
    -

    - {this.props.identity < 5 && ChallengesDataList&&ChallengesDataList.shixun_status=== 0 ? - - - - 实践任务 - - - : "" - } - {this.props.identity < 5 && ChallengesDataList&&ChallengesDataList.shixun_status=== 0 ? - - - - 选择题任务 - - : "" - } -

    -

    - 简介 - - - - - - -

    - -
    -

    - {ChallengesDataList === undefined ? "" :ChallengesDataList&&ChallengesDataList.description===null?"": -

    - } -

    - - {/* - - */} -
    - -

    - 全部任务 - {this.props.identity < 5 && ChallengesDataList&&ChallengesDataList.shixun_status=== 0 ? - - - - 实践任务 - - - : "" - } - {this.props.identity < 5 && ChallengesDataList&&ChallengesDataList.shixun_status=== 0 ? - - - - 选择题任务 - - : "" - } -

    - -
    - {ChallengesDataList === undefined ?
    -
    - -

    暂时还没有相关数据哦!

    -
    -
    : ChallengesDataList.challenge_list === undefined ? -
    -
    - -

    暂时还没有相关数据哦!

    -
    -
    - : ChallengesDataList.challenge_list.length === 0 ? -
    -
    - -

    暂时还没有相关数据哦!

    -
    -
    - : ChallengesDataList.challenge_list.map((item, key) => { - - let newstatus = 2; - if(ChallengesDataList.challenge_list[key - 1]!=undefined){ - newstatus=ChallengesDataList.challenge_list[key - 1].status; - } - return ( -
    - -
    - - {item.st === 0 ? - - - - : - - - - } - - 第{key+1}关 - - {this.props.identity<5? - item.st === 1 ? - this.EditTraining(this.props.identity, item.challenge_id, "/editquestion")} - className="font-16 color05101a">{item.name} - : - this.EditTraining(this.props.identity, item.challenge_id, "/editcheckpoint")} - className="font-16 color05101a">{item.name}: this.startshixunCombat(this.props.identity, item.challenge_id, "/editcheckpoint")} - className="font-16 color05101a">{item.name} - } - - - - - - - - {item.delete_url != undefined && - - this.delOperations(item.challenge_id)} - style={{ display:this.props.user.admin===true?"block":this.props.identity < 5 && ChallengesDataList.shixun_status === 0 ? "block" : 'none' }} - className="fl ring-op-green mr25"> - - - - } - - - {item.up_url != undefined && - - this.operations(item.challenge_id, "up")} - style={{ display:this.props.user.admin===true?"block":this.props.identity < 5 && ChallengesDataList.shixun_status === 0 ? "block" : 'none' }} - className="fl ring-op-green mr25"> - - - - } - {item.down_url != undefined && - - this.operations(item.challenge_id, "down")} - style={{ display: this.props.user.admin===true?"block":this.props.identity < 5 && ChallengesDataList.shixun_status=== 0 ? "block" : 'none' }} - className="fl ring-op-green mr25"> - - - - - } - - { - item.st === 1 ? - - - - - - : - - - - - - - } - - -
    -
    - {item.passed_count} 人完成挑战 - {item.playing_count} 人正在挑战 - 完成挑战可获得经验值 {item.score} - - - {/*判断比较复杂 有排第一不能是灰色按钮*/} - {item.status === 2 ? - this.startshixunCombat(false,undefined, item.challenge_id)} - // onClick={() => this.startshixunCombat(false)} - title={"查看挑战关卡"} - >已完成 : "" - } - - { - ChallengesDataList.allow_skip === true && item.status === 1? - this.startshixunCombat(false,undefined, item.challenge_id)} - // onClick={() => this.startshixunCombat(false)} - >直接挑战 : "" - } - - - { - ChallengesDataList.allow_skip === false ? item.status === 1? - - this.startshixunCombat(false,undefined, item.challenge_id)} - style={{marginTop: '-2px'}}>直接挑战 - :"":"" - - } - - - - { - item.status === 0 ? - - this.startshixunCombat(false,undefined, item.challenge_id):""} - style={{marginTop: '-2px'}}>直接挑战 - :"" - } - - - -
    -
    - ) - })} -
    - - - - - - -
    -

    目前该实训项目尚在内测中,将于{shixunsmessage}之后开放,谢谢!

    -
    -
    - {/*取消*/} - 知道了啦 -
    - {/*

    */} - {/*知道了*/} - {/*

    */} -
    - - - -
    -

    实训已经更新了,正在为您重置!

    -
    - -
    -
    -
    - } -
    - - ) - } -} - -export default Challenges; - // { - // ChallengesDataList.allow_skip === false ? item.status === 1 && newstatus === 2 ? - // - // this.startshixunCombat(false,undefined, item.challenge_id)} - // style={{marginTop: '-2px'}}>直接挑战 - // - // - // : item.status === 1 && newstatus === 1 ? - // - // this.startshixunCombat(false,undefined, item.challenge_id)} - // style={{marginTop: '-2px'}}>直接挑战 - // : "" : "" - // - // } \ No newline at end of file diff --git a/public/react/src/tpm/shixunchild/Collaborators/Collaborators.css b/public/react/src/tpm/shixunchild/Collaborators/Collaborators.css deleted file mode 100644 index 31917086f..000000000 --- a/public/react/src/tpm/shixunchild/Collaborators/Collaborators.css +++ /dev/null @@ -1,9 +0,0 @@ -.height40 { - height: 30px; - line-height: 30px; -} - -.line27{ - line-height: 27px; - vertical-align: 1px; -} \ No newline at end of file diff --git a/public/react/src/tpm/shixunchild/Collaborators/Collaborators.js b/public/react/src/tpm/shixunchild/Collaborators/Collaborators.js deleted file mode 100644 index d67599bf1..000000000 --- a/public/react/src/tpm/shixunchild/Collaborators/Collaborators.js +++ /dev/null @@ -1,658 +0,0 @@ -import React, { Component } from 'react'; - -import { Redirect } from 'react-router'; - -import {Modal, Button, Radio, Input, Checkbox,message,Spin, Icon} from 'antd'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames'; - -import { CircularProgress } from 'material-ui/Progress'; - -import { getImageUrl, toPath } from 'educoder' - -import axios from 'axios'; - -import NoneData from "../../../courses/coursesPublic/NoneData"; - -import './Collaborators.css'; - - -const $ = window.$; - -const RadioGroup = Radio.Group; - -const Search = Input.Search; - -class Collaborators extends Component { - constructor(props) { - super(props) - this.state = { - collaboratorList: [], - Collaboratorsvisible: false, - Collaboratorsvisibleadmin: false, - value: 1, - page: 1, - Searchadmin: undefined, - allChangechecked: false, - Collaboratorslist: [], - Collaboratorslisttype: false, - collaborators_deletetype: false, - collaborators_deletevalue: null, - onSearchcalue:"", - collaboratorListsum:10, - collaboratorListsumtype:true, - user_name:undefined, - school_name:undefined, - spinnings:false, - useristrue:false - } - } - componentDidMount() { - let id=this.props.match.params.shixunId; - - let collaborators=`/shixuns/`+id+`/collaborators.json`; - axios.get(collaborators).then((response)=> { - if(response.status===200){ - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - - }else{ - this.setState({ - collaboratorList: response.data - }); - } - - } - }).catch((error)=>{ - console.log(error) - }); - } - - updatacomponentDiddata = () => { - let id = this.props.match.params.shixunId; - - let collaborators = `/shixuns/` + id + `/collaborators.json`; - axios.get(collaborators).then((response) => { - if (response.status === 200) { - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - - }else{ - this.setState({ - collaboratorList: response.data - }); - } - } - }).catch((error) => { - console.log(error) - }); - } - CollaboratorsshowModal = (type) => { - - if (type === "cooperation") { - this.setState({ - Collaboratorsvisibleadmin: false, - Collaboratorslist:[], - Searchadmin:[] - }); - } else if (type === "admin") { - this.setState({ - Collaboratorsvisible: false, - Collaboratorslist:[], - Searchadmin:[] - }); - } else if (type === "collaborators_deletetype") { - this.setState({ - collaborators_deletetype: false, - }); - } - } - - showCollaboratorsvisible = (type) => { - - this.setState({ - Collaboratorslist: [], - Searchadmin:undefined, - onSearchcalue:"" - }) - let admintype = this.props.identity; - if (admintype>4) { - this.props.showSnackbar("您没有权限"); - return - } - if (type === "cooperation") { - this.setState({ - Collaboratorsvisibleadmin: true, - }); - } else if ("admin") { - let id = this.props.match.params.shixunId; - let url = "/shixuns/" + id + "/change_manager.json"; - axios.get(url).then((response) => { - if (response.status === 200) { - // this.setState({ - // Collaboratorsvisible: true - // }) - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - - }else{ - this.setState({ - Collaboratorsvisible: true, - Collaboratorslist: response.data - }) - } - } - }).catch((error) => { - console.log(error) - }); - - } - } - - onChange = (e) => { - this.setState({ - value: e.target.value, - }); - } - onSearchadmins=(e)=>{ - this.setState({ - onSearchcalue:e.target.value - }) - } - onSearchadmin = (value) => { - - let {collaboratorList,user_name,school_name} = this.state; - this.setState({ - // Searchadmin: undefined, - spinnings:true, - }) - // if (value === "") { - // this.setState({ - // Searchadmin: [], - // collaboratorList: collaboratorList - // }) - // } else { - // - // } - let id = this.props.match.params.shixunId; - let url = "/shixuns/" + id + "/add_collaborators.json"; - axios.get(url,{params:{ - user_name:user_name , - school_name:school_name, - }}).then((response) => { - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - this.setState({ - spinnings:false - }) - }else{ - let newlist = response.data.users; - for (var i = 0; i < newlist.length; i++) { - newlist[i].checked = false - } - this.setState({ - Searchadmin: newlist, - collaboratorList: collaboratorList, - spinnings:false - }) - } - - }).catch((error) => { - console.log(error) - }); - } - - selectChangenickname = (e, key) => { - - let {Searchadmin} = this.state; - let newlist = Searchadmin; - for (var i = 0; i < newlist.length; i++) { - newlist[key].checked = e.target.checked - } - - let arrlist = []; - let alltype = false; - for (var z = 0; z < newlist.length; z++) { - if (newlist[z].checked === true) { - arrlist.push(newlist[z]) - } - } - - if (Searchadmin.length === arrlist.length) { - alltype = true - } else { - alltype = false - } - - if(newlist.length===0){ - this.setState({ - Searchadmin: newlist, - allChangechecked: alltype, - }) - }else{ - this.setState({ - Searchadmin: newlist, - allChangechecked: alltype, - useristrue:false - }) - } - - - } - allChange = (e) => { - - let {Searchadmin} = this.state; - let newlist = Searchadmin; - for (var i = 0; i < newlist.length; i++) { - newlist[i].checked = e.target.checked - } - this.setState({ - Searchadmin: newlist, - allChangechecked: e.target.checked - }) - } - submit_add_collaborators_form = () => { - - let id = this.props.match.params.shixunId; - let {Searchadmin,collaboratorList} = this.state; - let newlist = Searchadmin; - let user_ids = [] - if (newlist.length === 0) { - this.setState({ - Collaboratorslisttype: true - }) - return - } - for (var i = 0; i < newlist.length; i++) { - if (newlist[i].checked === true) { - user_ids.push(newlist[i].user_id) - } - } - - for(var i=0; i { - this.updatacomponentDiddata(); - this.props.showSnackbar(response.data.message); - this.setState({ - Collaboratorsvisibleadmin: false, - Collaboratorslist:[], - Searchadmin:[] - }) - }).catch((error) => { - console.log(error) - }); - } - addadminredio = (e) => { - this.setState({ - addadminrediovalue: e - }) - - } - submit_addadminredio = () => { - - let {addadminrediovalue} = this.state; - - let id = this.props.match.params.shixunId; - - let url = "/shixuns/" + id + "/change_manager.json"; - if(addadminrediovalue===undefined){ - this.setState({ - Collaboratorsvisible: false, - Collaboratorslist:[], - Searchadmin:[] - }); - this.props.showSnackbar("所选人员为空,没有更换成功"); - this.CollaboratorsshowModal("admin") - return - } - - - axios.post(url, { - user_id: addadminrediovalue - }).then((response) => { - this.setState({ - Collaboratorsvisible: false, - Collaboratorslist:[], - Searchadmin:[] - }); - this.updatacomponentDiddata(); - this.props.showSnackbar(response.data.message); - }).catch((error) => { - console.log(error) - }); - } - - collaborators_delete = (value) => { - this.setState({ - collaborators_deletetype: true, - collaborators_deletevalue: value - }) - - } - collaborators_deletes = () => { - let {collaborators_deletevalue} = this.state; - if (collaborators_deletevalue === null) { - return - } - let id = this.props.match.params.shixunId; - let url = "/shixuns/" + id + "/collaborators_delete.json?user_id=" + collaborators_deletevalue; - axios.delete(url).then((response) => { - if (this.props.current_user.user_id == collaborators_deletevalue) { - this.props.history.push('/shixuns') - return; - } - this.props.showSnackbar(response.data.message); - this.updatacomponentDiddata(); - this.setState({ - collaborators_deletetype: false - }) - }).catch((error) => { - console.log(error) - }); - } - - loadMore=()=>{ - let {collaboratorList}=this.state; - this.setState({ - collaboratorListsum:collaboratorList.length, - collaboratorListsumtype:false - }) - } - - - contentViewScrolledit=(e)=>{ - - //滑动到底判断 - let newscrollTop=parseInt(e.currentTarget.scrollTop); - let allclientHeight=e.currentTarget.clientHeight+newscrollTop; - - if(e.currentTarget.scrollHeight-allclientHeight===0||e.currentTarget.scrollHeight-allclientHeight===1||e.currentTarget.scrollHeight-allclientHeight===-1){ - let {page,collaboratorList,user_name,school_name,Searchadmin} = this.state; - let newpage=page+1; - let newSearchadmin=Searchadmin - let id = this.props.match.params.shixunId; - let url = "/shixuns/" + id + "/add_collaborators.json"; - axios.get(url,{params:{ - user_name:user_name , - school_name:school_name, - page:newpage - }}).then((response) => { - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - - }else{ - let newlist = response.data.users; - for (var i = 0; i < newlist.length; i++) { - newlist[i].checked = false - newSearchadmin.push(newlist[i]) - } - - this.setState({ - Searchadmin: newSearchadmin, - collaboratorList: collaboratorList, - page:newpage - }) - } - - }).catch((error) => { - console.log(error) - }); - - } - - } - - render() { - let { - collaboratorList, - Collaboratorsvisible, - Collaboratorsvisibleadmin, - Searchadmin, - allChangechecked, - Collaboratorslist, - Collaboratorslisttype, - collaborators_deletetype, - onSearchcalue, - collaboratorListsum, - collaboratorListsumtype, - user_name, - school_name, - useristrue - } = this.state; - let {loadingContent} = this.props; - const radioStyle = { - display: 'block', - height: '30px', - lineHeight: '30px', - }; - - const antIcon = ; - - console.log(Searchadmin) - return ( - -

    - this.showCollaboratorsvisible("cooperation")} - className="edu-default-btn edu-greenback-btn fr mr20 height40" - data-remote="true"> - + 添加合作者 - - this.showCollaboratorsvisible("admin")} - style={{display:this.props.identity===1?"block":"none"}} - data-remote="true" - className="edu-default-btn edu-greenback-btn fr mr20 height40">更换管理员 -

    - - - -
    - 选择的成员将会成为新的管理员
    您将不再拥有管理员的权限,但您仍是合作团队的一员 -
    - - -
    -
      -
    • - - - { - Collaboratorslist.length === 0 ? "" : Collaboratorslist.map((item, key) => { - return ( - this.addadminredio(item.user_id)}>{item.name} - ) - }) - } - - -
    • -
    -
    - - - -
    - - {Collaboratorsvisibleadmin===true? - {/* this.onSearchadmin(value)}*/} - {/*onInput={this.onSearchadmins}*/} - {/*style={{width: '100%'}}*/} - {/*/>*/} - 姓名或手机号: - - {this.setState({user_name: e.target.value})}} - style={{ width: '215px'}} - > - 单位: - {this.setState({school_name: e.target.value})}} - style={{ width: '215px'}} - > - - - this.onSearchadmin()} - style={{ height: '30px', lineHeight: '30px', width: '70px'}} - >搜索 -

    - 姓名 - 职业 - 单位 -

    -
    - -
    -
      - {Searchadmin === undefined ?
    • - 请试试搜索一下 -
    • :Searchadmin.length === 0 ?: Searchadmin.map((item, key) => { - return ( -
    • - this.selectChangenickname(e, key)} - id={item.user_id}> - {item.nickname} - {item.identify} - {item.school_name} -
    • - ) - }) - - } -
    -
    -
    -
    -
    - - - 全选 -
    - 请至少选择一个用户 -
    -
    - - -
    - {useristrue===true?请先选择用户:""} - -
    :""} - -
    - { - collaboratorList===undefined?"":collaboratorList.map((item,key)=>{ - if(key - - 用户头像 -
    -

    - {item.user.name} - - {item.user.shixun_manager === true ? "(管理员)" : ""} -

    - -

    {item.user.identity}{item.user.school_name}

    - -

    - 发布  {item.user.user_shixuns_count} - {/*粉丝  */} - {/*{item.user.fans_count}*/} - {/**/} -

    - - {/*

    {item.user.brief_introduction}

    */} - - -
    - - {item.user.shixun_manager === true ? "" : this.collaborators_delete(item.user.user_id)}>删除} - {/*取消关注*/} -
    - - ) - } - }) - } - -
    -
    确定要删除吗?
    -
    - - -
    -
    - -
    10&&collaboratorListsumtype===true?"":"none"} - style={{textAlign:'center',borderTop:'1px solid #eee'}}> - 加载更多 -
    - -
    - - ); - } -} - -export default Collaborators; diff --git a/public/react/src/tpm/shixunchild/Propaedeutics/Propaedeu_tics.js b/public/react/src/tpm/shixunchild/Propaedeutics/Propaedeu_tics.js deleted file mode 100644 index f40e9fa63..000000000 --- a/public/react/src/tpm/shixunchild/Propaedeutics/Propaedeu_tics.js +++ /dev/null @@ -1,114 +0,0 @@ -import React, { Component } from 'react'; - -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames'; - -import { getImageUrl, toPath } from 'educoder'; - -import { Tooltip } from 'antd'; - -import axios from 'axios'; - -import { CircularProgress } from 'material-ui/Progress'; - -const $ = window.$; - -class Propaedeutics extends Component { - constructor(props) { - super(props) - this.state={ - PropaedeuticsListcontent:undefined, - shixunId:undefined - } - } - - componentDidMount() { - let id = this.props.match.params.shixunId; - this.setState({ - shixunId:id - }) - let url="/shixuns/"+id+"/propaedeutics.json"; - axios.get(url).then((response) => { - - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - - }else{ - if(response.data.content!=null){ - this.setState({ - PropaedeuticsListcontent:response.data.content - }) - }else{ - this.setState({ - PropaedeuticsListcontent:"" - }) - } - } - }).catch((error) => { - console.log(error) - }); - - } - - updatamakedown=(id)=>{ - setTimeout(()=>{ - var shixunDescr = window.editormd.markdownToHTML(id, { - htmlDecode: "style,script,iframe", - taskList: true, - tex: true, - flowChart: true, - sequenceDiagram: true - }); - $("#"+id+" p:first").addClass("ReactMarkdown"); - $('#collaborators_list_info').show() - }, 200) - } - render() { - let {loadingContent} = this.props; - let {PropaedeuticsListcontent,shixunId}=this.state - - if(PropaedeuticsListcontent!=undefined){ - this.updatamakedown("ReactMarkdown") - } - - return ( - -

    - - - - -

    - { - loadingContent ? - : -
    - {PropaedeuticsListcontent===undefined?"": -

    - - {PropaedeuticsListcontent === undefined ||PropaedeuticsListcontent === ""? -

    -
    -
    - -

    暂时还没有相关数据哦!

    -
    -
    -
    - :} - -

    - } -
    - } -
    - ); - } -} - -export default Propaedeutics; diff --git a/public/react/src/tpm/shixunchild/Ranking_list/Ranking_list.js b/public/react/src/tpm/shixunchild/Ranking_list/Ranking_list.js deleted file mode 100644 index 0e5d0498b..000000000 --- a/public/react/src/tpm/shixunchild/Ranking_list/Ranking_list.js +++ /dev/null @@ -1,145 +0,0 @@ -import React, { Component } from 'react'; - -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames'; - -import { getImageUrl, toPath } from 'educoder'; - -import { CircularProgress } from 'material-ui/Progress'; - -import axios from 'axios'; - -const $ = window.$; - -class Ranking_list extends Component { - constructor(props) { - super(props) - this.state = { - Ranking_listData:[] - } - } - - Ranking_listList = (id) => { - let Ranking_listURL = `/shixuns/` + id + `/ranking_list.json`; - axios.get(Ranking_listURL).then((response) => { - if (response.status === 200) { - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { - - }else{ - this.setState({ - Ranking_listData: response.data - }); - } - } - - }).catch((error) => { - console.log(error) - }); - } - - componentDidMount() { - let id = this.props.match.params.shixunId; - setTimeout(this.Ranking_listList(id), 1000); - } - checkAddZone=(num)=>{ - return num<10 ? '0' + num.toString() : num - } - dateTimeFormatter=(t)=> { - if (!t) return '' - t = new Date(t).getTime() - t = new Date(t) - var year = t.getFullYear() - var month = (t.getMonth() + 1) - month = this.checkAddZone(month) - - var date = t.getDate() - date = this.checkAddZone(date) - - var hour = t.getHours() - hour = this.checkAddZone(hour) - - var min = t.getMinutes() - min = this.checkAddZone(min) - - return year + '-' + month + '-' + date + ' ' + hour + ':' + min - } - - formatSeconds=(value)=> { - var theTime = parseInt(value);// 秒 - var theTime1 = 0;// 分 - var theTime2 = 0;// 小时 - if(theTime > 60) { - theTime1 = parseInt(theTime/60); - theTime = parseInt(theTime%60); - if(theTime1 > 60) { - theTime2 = parseInt(theTime1/60); - theTime1 = parseInt(theTime1%60); - } - } - var result = ""+parseInt(theTime)+"秒"; - if(theTime1 > 0) { - result = ""+parseInt(theTime1)+"分"+result; - } - if(theTime2 > 0) { - result = ""+parseInt(theTime2)+"小时"+result; - } - return result; - } - - render() { - let { Ranking_listData } = this.state; - let { loadingContent } = this.props; - - // console.log(Ranking_listData) - return ( - - { loadingContent ? - : - -
    - {Ranking_listData===undefined||Ranking_listData.length===0? -
    - -

    我们在等你,不轻言放弃

    -
    - :Ranking_listData.map((item,key)=>{ - var keys=key+1 - return( -
    -
  • - - 2?"block":"none"}} - >{key+1} - - 头像 - - - {item.users.name} -
  • - -
  • {this.dateTimeFormatter(item.time)}通关
  • - {/*
  • */} - {/*/!*{item.accuracy} %准确率*!/*/} - {/*
  • */} -
  • {this.formatSeconds(item.use_time)}
  • -
  • +{item.gold}金币
  • -
    - ) - })} -
    - } -
    - - ); - } -} - -export default Ranking_list; diff --git a/public/react/src/tpm/shixunchild/Repository/Repository.js b/public/react/src/tpm/shixunchild/Repository/Repository.js deleted file mode 100644 index c477422e8..000000000 --- a/public/react/src/tpm/shixunchild/Repository/Repository.js +++ /dev/null @@ -1,266 +0,0 @@ -import React, { Component } from 'react'; - -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames'; - -import axios from 'axios'; - -import { trace, trace_collapse ,getImageUrl, toPath} from "educoder"; - -import RepositoryDirectories from './RepositoryDirectories' - -import { ActionBtn , NoneData } from 'educoder' -import RepositoryCombinePath from './RepositoryCombinePath' -const $ = window.$; - -// 点击按钮复制功能 -function jsCopy(){ - var e = document.getElementById("copy_rep_content"); - e.select(); - document.execCommand("Copy"); -} -/** - 提交记录 - 使用指南 - */ -class Repository extends Component { - constructor(props) { - super(props); - this.state={ - - } - } - componentDidMount() { - } - onRepoFileClick = (item) => { - - this.props.fetchRepo(item) - - } - render() { - let { match, author, git_url, lastest_commit,repositoryLoading, commits,trees,pathArray , TPMRightSectionData } = this.props; - - if (!author) { - author = {} - } - let userauthority=false; - if(this.props.author!=undefined){ - userauthority=this.props.author.login===""||this.props.author.user_id===""||this.props.author.login===null||this.props.author.user_id===null; - } - return ( - - {/* jfinalshop/WebRoot */} - {/*
    - - - 分支 1 - - Git使用指南 -
    */} - - { repositoryLoading ?
    : - -
    -
    -
    -
    -
    - {/*
    - -
    - -
    - - - - */} - - Git使用指南 - { - this.props.current_user && (this.props.current_user.admin ==true || (TPMRightSectionData && TPMRightSectionData.creator && TPMRightSectionData.creator.login == this.props.current_user.login)) ? - !this.props.secret_repository_tab && - +添加文件 - :"" - } - - - -
    - - - { - jsCopy() - }} data-tip-down="点击复制版本库地址" - className="fl ml5"> - - - - - {/* Git使用指南 */} - - - { $('#repository_url_tip').css('display') === 'none' - ? $('#repository_url_tip').show() - : $('#repository_url_tip').hide() }} - className="fl ml6 mt1"> - - - - -
    -
    - - {this.props.secret_repository_tab && - - } - -
    -
    - - - {/* 用户、最近提交时间 */} - { - trees === undefined || trees === null ||trees.length===0? : -
    - {commits===undefined?"":commits===null||commits.length===0?"":
    - {author.name} - {commits[0].author.name} - 提交于 - - {commits===undefined?"":commits[0].time} - :{commits===undefined?"":commits[0].title} - - - - 提交记录 - -
    } - -
    -
    - {/* 当前目录位置 */} - - -
    - { trees === undefined ?"": trees === null || trees.length===0?"":trees.map((item, index) => { - return ( -
  • - - - this.onRepoFileClick(item)}> -  {item.name} - - -
  • - ) - })} -
    -
    -
    -
    - } - - {/* 当前分支的文件 */} - -
    -
    - } -
    - - ); - } -} -/* - 提交记录 -
    - { RepositoryList===undefined?"":RepositoryList.commits.map((item,key)=>{ - // {"email":"李暾","title":"2\n","id":"80cb6fc55a14bdd64a9c99913f416966238ed3de","time":"49年前"} - return( -
    -
    {item.email}
    -
    {item.title}
    -
    {item.id}
    -
    {item.time}
    -
    - ) - }) } -
    - - - -
  • - - - 1-1.py - -
  • - - - -*/ - -export default Repository; diff --git a/public/react/src/tpm/shixunchild/Repository/RepositoryAddFile.js b/public/react/src/tpm/shixunchild/Repository/RepositoryAddFile.js deleted file mode 100644 index 9ca535bb4..000000000 --- a/public/react/src/tpm/shixunchild/Repository/RepositoryAddFile.js +++ /dev/null @@ -1,198 +0,0 @@ -import React, { Component } from 'react'; -import { ActionBtn } from 'educoder' - -import { Form , Modal , Input , Breadcrumb , Button } from 'antd' - -import { Link } from 'react-router-dom' - -import axios from 'axios' - -/** - ---------------------------- START - */ -function getModeByMirrorName(mirror_name) { - let mode = 'javascript' - if (mirror_name && mirror_name.length) { - for (let i = 0; i < mirror_name.length; i++) { - let modeVal = mirrorNameModeMap[mirror_name[i]]; - if (modeVal) { - mode = modeVal; - break; - } - } - } - return mode; -} -const _extraKeys = {"Alt-/": "autocomplete"}; -function createCMOptions(mirror_name) { - let mode = getModeByMirrorName(mirror_name) - - let cmOptions = { - lineNumbers: true, - mode: mode, - theme: "railscasts", - indentUnit:4, - matchBrackets: true, - autoRefresh: true, - smartIndent: true,//智能换行 - extraKeys: _extraKeys, - autofocus: true, - styleActiveLine: true, - lint: true, - gutters: ["CodeMirror-linenumbers", "breakpoints", "CodeMirror-lint-markers"] - }; - return cmOptions; -} - -const mirrorNameModeMap = { - 'JFinal': 'text/x-java', - 'Java': 'text/x-java', - 'Kotlin': 'text/x-kotlin', - 'C/C++' : 'text/x-c++src', - 'MachineLearning': { - name: "python", - version: 3, - singleLineStringErrors: false - }, - 'Python2.7': { - name: "python", - version: 3, - singleLineStringErrors: false - }, - 'Python3.6': { - name: "python", - version: 3, - singleLineStringErrors: false - }, -} -/** - ---------------------------- END -*/ - -class RepositoryAddFile extends Component { - constructor(props) { - super(props); - } - - componentDidMount(){ - let cmOptions = createCMOptions(this.props.mirror_name) - const extend_editor = window.CodeMirror.fromTextArea(window.$('#codemirror-file-edit')[0] - , cmOptions); - - // tpi没setValue也可以 - extend_editor.setValue('') - extend_editor.refresh(); - - // 拖拽也需要用 : window.editor_CodeMirror.refresh() - window.editor_tempCodeMirror = extend_editor; - this.extend_editor = extend_editor; - } - - checkPath= (rule, value, callback) =>{ - if(!value){ - callback('文件名不能为空'); - }else if (value == "/" || value.indexOf('.') == -1 ) { - callback('请输入正确的文件路径,如:src/HelloWorld.java'); - }else{ - callback(); - } - } - - handleSubmit = () =>{ - this.props.form.validateFieldsAndScroll((err, values) => { - if(!err){ - let shixunId = this.props.match.params.shixunId; - let url = `/shixuns/${shixunId}/add_file.json` - axios.post(url,{ - path:values.path, - message:values.message, - content:this.extend_editor.getValue() - }).then((result)=>{ - if(result){ - this.props.history.push(`${result.data.url}`) - } - }).catch((error)=>{ - console.log(error); - }) - } - }) - } - render(){ - const {getFieldDecorator} = this.props.form; - let { shixunId } = this.props.match.params; - return( -
    - -

    - - 实训项目 - 版本库 - 添加新文件 - -

    -
    -
    - - {getFieldDecorator('path', { - rules: [ - { - validator:this.checkPath - }] - })( - - )} - -
    -
    -

    - -

    - -
    - -
    - - - {getFieldDecorator('message', { - rules: [{required: true, message: "请输入提交信息"}], - })( - - )} - -
    -
    - - 取消 -
    - - -
    - ) - } -} -const WrappedRepositoryAddFile = Form.create({name: 'taskRepositoryAddFile'})(RepositoryAddFile); -// RouteHOC() -export default (WrappedRepositoryAddFile); \ No newline at end of file diff --git a/public/react/src/tpm/shixunchild/Repository/RepositoryCodeEditor.js b/public/react/src/tpm/shixunchild/Repository/RepositoryCodeEditor.js deleted file mode 100644 index 51f6e35f2..000000000 --- a/public/react/src/tpm/shixunchild/Repository/RepositoryCodeEditor.js +++ /dev/null @@ -1,185 +0,0 @@ -import React, { Component } from 'react'; - -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames'; - -import axios from 'axios'; - -import RepositoryDirectories from './RepositoryDirectories' - -import { trace_collapse } from 'educoder' - -import Popconfirm from 'antd/lib/popconfirm'; -import 'antd/lib/popconfirm/style/css'; - -import { message } from 'antd'; - -require('codemirror/lib/codemirror.css'); - -const $ = window.$; - - -/** - ---------------------------- START - */ -function getModeByMirrorName(mirror_name) { - let mode = 'javascript' - if (mirror_name && mirror_name.length) { - for (let i = 0; i < mirror_name.length; i++) { - let modeVal = mirrorNameModeMap[mirror_name[i]]; - if (modeVal) { - mode = modeVal; - break; - } - } - } - return mode; -} -const _extraKeys = {"Alt-/": "autocomplete"}; -function createCMOptions(mirror_name) { - let mode = getModeByMirrorName(mirror_name) - - let cmOptions = { - lineNumbers: true, - mode: mode, - theme: "railscasts", - indentUnit:4, - matchBrackets: true, - autoRefresh: true, - smartIndent: true,//智能换行 - extraKeys: _extraKeys, - autofocus: true, - styleActiveLine: true, - lint: true, - gutters: ["CodeMirror-linenumbers", "breakpoints", "CodeMirror-lint-markers"] - }; - return cmOptions; -} - -const mirrorNameModeMap = { - 'JFinal': 'text/x-java', - 'Java': 'text/x-java', - 'Kotlin': 'text/x-kotlin', - 'C/C++' : 'text/x-c++src', - 'MachineLearning': { - name: "python", - version: 3, - singleLineStringErrors: false - }, - 'Python2.7': { - name: "python", - version: 3, - singleLineStringErrors: false - }, - 'Python3.6': { - name: "python", - version: 3, - singleLineStringErrors: false - }, -} -/** - ---------------------------- END - */ - -class RepositoryCodeEditor extends Component { - constructor(props) { - super(props) - this.state = { - codeSaving: false - } - } - componentDidUpdate = (prevProps, prevState) => { - - if (this.props.fileContent && this.props.fileContent != prevProps.fileContent) { - // window.setTimeout(() => { - this.extend_editor.setValue(this.props.fileContent) - // }, 2000) - } - } - componentDidMount(){ - let cmOptions = createCMOptions(this.props.mirror_name) - const extend_editor = window.CodeMirror.fromTextArea(window.$('#codemirror-file-edit')[0] - , cmOptions); - - // tpi没setValue也可以 - extend_editor.setValue('') - extend_editor.refresh(); - - // 拖拽也需要用 : window.editor_CodeMirror.refresh() - window.editor_tempCodeMirror = extend_editor; - this.extend_editor = extend_editor; - } - - saveCode = () => { - const { shixunId, pathArray } = this.props; - const url = `/shixuns/${shixunId}/update_file.json` - const path = pathArray.join('/') - this.setState({ codeSaving: true }) - axios.post(url, { - secret_repository: this.props.secret_repository_tab, - content: this.extend_editor.getValue(), - // type: forTest === true ? 1 : 0, - path: path - } - ).then((response) => { - if (response.data.content) { - message.success('保存成功'); - this.setState({ codeSaving: false }) - } - }) - } - render() { - const { fileContent, match, saveCode } = this.props; - const { codeSaving } = this.state; - return ( - - -
    - - -
    -
    -
    -
    - { codeSaving ? - 保存中... - : this.saveCode(this.extend_editor.getValue())} - okText="确定" cancelText="取消"> - {/* onClick={this.saveCode} - onClick={() => saveCode(this.extend_editor.getValue())} - */} - 保存 - } -
    -
    -
    - - -
    - -
    -
    - -
    - - ); - } -} -export default RepositoryCodeEditor; diff --git a/public/react/src/tpm/shixunchild/Repository/RepositoryCombinePath.js b/public/react/src/tpm/shixunchild/Repository/RepositoryCombinePath.js deleted file mode 100644 index aba008e20..000000000 --- a/public/react/src/tpm/shixunchild/Repository/RepositoryCombinePath.js +++ /dev/null @@ -1,82 +0,0 @@ -import React, { Component } from 'react'; - -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames'; - -import axios from 'axios'; - -import { trace_collapse, WordsBtn } from 'educoder' - -import { message, Input } from 'antd'; - - -const $ = window.$; - - -class RepositoryCombinePath extends Component { - constructor(props) { - super(props) - this.state = { - value: this.props.secret_dir_path || '', - isEdit: false, - } - } - - onSave = () => { - const { shixunId, pathArray } = this.props; - const url = `/shixuns/${shixunId}/set_secret_dir.json` - - this.setState({ codeSaving: true }) - axios.post(url, { - secret_dir_path: this.state.value - } - ).then((response) => { - if (response.data) { - message.success('保存成功'); - this.setState({isEdit: false}) - } - }) - } - onChange = (e) => { - const { value } = e.target; - this.setState({ value }) - } - onEdit = () => { - this.setState({isEdit: true}, () => { - window.$('.combinePathEditRow input')[0].focus() - }); - } - render() { - const { fileContent, match, saveCode } = this.props; - const { isEdit, value } = this.state; - return ( - -
    - - 第一版本库合并路径: - - {!isEdit && 修改} - {isEdit && 保存} -
    - - - ); - } -} -export default RepositoryCombinePath; diff --git a/public/react/src/tpm/shixunchild/Repository/RepositoryDirectories.js b/public/react/src/tpm/shixunchild/Repository/RepositoryDirectories.js deleted file mode 100644 index 7c6eca37a..000000000 --- a/public/react/src/tpm/shixunchild/Repository/RepositoryDirectories.js +++ /dev/null @@ -1,66 +0,0 @@ -import React, { Component } from 'react'; - -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames'; - -import axios from 'axios'; - -import { trace_collapse } from 'educoder' -const $ = window.$; - - -class RepositoryDirectories extends Component { - constructor(props) { - super(props) - this.state = { - - } - } - componentDidMount() { - } - render() { - const { match, pathArray, fetchRepo - } = this.props; - let { RepositoryList } = this.state; - return ( - - - { pathArray.length !== 0 && -
    - fetchRepo(0)} - > - {match.params.shixunId} - - / - { pathArray.map((item, index) => { - // /shixuns/3ozvy5f8/repository/3ozvy5f8/master/shixun_show/src - return ( - - { this.props.nameTypeMap[item] === 'tree' || item.indexOf('.') === -1 - ? fetchRepo(index + 1)} - className="color-blue"> - {item} - : - - {item} - } - {index !== pathArray.length - 1 && /} - - ) - }) - } -
    } - -
    - - ); - } -} -export default RepositoryDirectories; diff --git a/public/react/src/tpm/shixunchild/Repository/TPMRepositoryCommits.js b/public/react/src/tpm/shixunchild/Repository/TPMRepositoryCommits.js deleted file mode 100644 index 663c5fcf3..000000000 --- a/public/react/src/tpm/shixunchild/Repository/TPMRepositoryCommits.js +++ /dev/null @@ -1,145 +0,0 @@ -import React, { Component } from 'react'; - -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames'; - -import axios from 'axios'; - -import TPMNav from '../../component/TPMNav' -import TPMRightSection from '../../component/TPMRightSection' -import { CircularProgress } from 'material-ui/Progress'; - -import { trace_collapse } from 'educoder' -const $ = window.$; - -// 点击按钮复制功能 -function jsCopy(){ - var e = document.getElementById("copy_rep_content"); - e.select(); - document.execCommand("Copy"); -} -class TPMRepositoryCommits extends Component { - constructor(props) { - super(props) - this.state = { - RepositoryList: undefined, - } - } - componentDidMount() { - let id = this.props.match.params.shixunId; - - let collaborators=`/shixuns/`+id+`/commits.json`; - axios.post(collaborators, { - secret_repository: this.props.secret_repository_tab - }).then((response)=> { - - if(response.status===200){ - this.setState({ - RepositoryList: response.data - }); - } - trace_collapse('repo commits res', response.data) - - }).catch((error)=>{ - console.log(error) - }); - - } - render() { - const { loadingContent, creator, shixun, myshixun, recommend_shixuns, current_user, watched, - aboutFocus, user, match - } = this.props; - let { RepositoryList } = this.state; - return ( - - -
    - {/* 可能会影响到其他页面的样式,需要测试、协商 */} -
    - - { loadingContent ? - - : - -
    -
    - - 提交记录 - - {/*  35 */} - - 返回 - -
    - - -
    -
      - { RepositoryList === undefined ? "" : RepositoryList.commits.map( (item, key)=>{ - return ( -
    • - {item.email} -

      - {item.title} -

      - {item.time} - -
      -
    • ) - }) - } -
    -
    -
    - } -
    - -
    - -
    -
    - - -
    - - ); - } -} - -/** - { RepositoryList === undefined ? "" : RepositoryList.commits.map( (item, key)=>{ - // {"email":"李暾","title":"2\n","id":"80cb6fc55a14bdd64a9c99913f416966238ed3de","time":"49年前"} - return ( -
    -
    {item.email}
    -
    {item.title}
    -
    {item.id}
    -
    {item.time}
    -
    - ) - }) - */ -export default TPMRepositoryCommits; diff --git a/public/react/src/tpm/shixunchild/ShixunDiscuss/ShixunDiscuss.js b/public/react/src/tpm/shixunchild/ShixunDiscuss/ShixunDiscuss.js deleted file mode 100644 index 4e9470f89..000000000 --- a/public/react/src/tpm/shixunchild/ShixunDiscuss/ShixunDiscuss.js +++ /dev/null @@ -1,170 +0,0 @@ -import React, { Component } from 'react'; - -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames'; - -import { getImageUrl, toPath } from 'educoder' - -import axios from 'axios'; - -const $ = window.$; - -class ShixunDiscuss extends Component { - constructor(props) { - super(props) - this.state = { - TPMRightSectionData: undefined - } - } - getshixunsDetailsList = (id) => { - let shixunsDetailsURL = `/shixuns/` + id + `/discusses.json`; - axios.get(shixunsDetailsURL).then((response) => { - if (response.status === 200) { - this.setState({ - TPMRightSectionData: response.data - }); - } - }).catch((error) => { - console.log(error) - }); - } - - componentDidMount() { - let id = this.props.match.params.shixunId; - setTimeout(this.getshixunsDetailsList(id), 1000); - } - render() { - let { TPMRightSectionData } = this.state; - - return ( -
    -
    -
    - - - { - TPMRightSectionData===undefined?"":TPMRightSectionData.map((item,key)=>{ - return( -
    -
    - - 用户头像 - -
    - -
    -
    -
    - -
    -
    - {item.user.name} - {item.time} - [第{item.round}关] -
    -
    - -
    -
    -

    {item.content}

    -
    -
    -
    -
    - - { - item.replies.map((i,k)=>{ - return( -
    -
    -
    -
    -
    - {i.user.name} - {i.time} -
    -

    - - - - - - - -

    -
    -
    -
    -
    -

    {i.content}

    -
    -
    -
    -
    -
    -
    - - ) - }) - } - - -

    - - - - - - - - - - - - - - - - - 3 - - -

    - - -
    -
    - - 0?1442652658 - -
    - -
    -
    - -
    -
    调整高度
    - 发送 -
    -
    -
    -
    -
    -
    - ) - }) - } - -
    -
    -
    - ) - } - } - - export default ShixunDiscuss; diff --git a/public/react/src/tpm/shixunchild/Shixunfork_list.js b/public/react/src/tpm/shixunchild/Shixunfork_list.js deleted file mode 100644 index f813441f1..000000000 --- a/public/react/src/tpm/shixunchild/Shixunfork_list.js +++ /dev/null @@ -1,69 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link} from "react-router-dom"; - -import { Switch } from 'antd'; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -import { TPMIndexHOC } from '../TPMIndexHOC' - -import { SnackbarHOC } from 'educoder' - -import ShixunCard from '.././shixuns/ShixunCard'; - -import { Pagination,Row,Col,Rate } from 'antd'; - - import './shixunchildCss/Shixunfork_list.css'; - -import 'antd/lib/rate/style/index.css'; - -const $ = window.$; - -class Shixunforklist extends Component { - constructor(props) { - super(props) - this.state = { - - } - } - - handleChange = (value) => { - console.log('Page: ', value); - // this.setState({ value }); - } - //JSX - render() { - const { match, history } = this.props - - return ( -
    - -
    -
    - Fork实训列表 - 返回 -
    - - - - - - -
    -
    -
      - -
    -
    -
    -
    -
    -
    - ); - } -} -export default SnackbarHOC() (TPMIndexHOC ( Shixunforklist )); diff --git a/public/react/src/tpm/shixunchild/shixunchildCss/Challenges.css b/public/react/src/tpm/shixunchild/shixunchildCss/Challenges.css deleted file mode 100644 index 493a95301..000000000 --- a/public/react/src/tpm/shixunchild/shixunchildCss/Challenges.css +++ /dev/null @@ -1,28 +0,0 @@ -.editormd-html-preview, .editormd-preview-container { - width: 95% !important; -} -.Finish_button{ - height: 30px; - line-height: 30px; - margin-top: -8px; -} -.startbtnModal .ant-modal-content{ - background: transparent; - box-shadow: 0 4px 12px transparent; -} - -.startbtnModal .ant-modal-content .ant-modal-body .ant-spin-spinning{ - margin-left: 45%; -} - -.color05101a{ - color:#05101a; -} - -.mtf3{ - margin-top: -3px; -} -.addshixuns{ - height: 27px; - line-height: 25px; -} \ No newline at end of file diff --git a/public/react/src/tpm/shixunchild/shixunchildCss/Shixunfork_list.css b/public/react/src/tpm/shixunchild/shixunchildCss/Shixunfork_list.css deleted file mode 100644 index d6ef5ebfe..000000000 --- a/public/react/src/tpm/shixunchild/shixunchildCss/Shixunfork_list.css +++ /dev/null @@ -1,6 +0,0 @@ -.ant-rate{ - color: #FFAA05 !important; -} -.ant-pagination-options-quick-jumper input{ - height: 22 !important; -} \ No newline at end of file diff --git a/public/react/src/tpm/shixuns/ShixunCard.js b/public/react/src/tpm/shixuns/ShixunCard.js deleted file mode 100644 index 9f62ed6b7..000000000 --- a/public/react/src/tpm/shixuns/ShixunCard.js +++ /dev/null @@ -1,200 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames'; - -import { Rating ,Pagination} from "@icedesign/base"; - -import {getImageUrl,setImagesUrl, toPath,getUrl} from 'educoder'; - -import { Spin,Icon,Tooltip ,Rate} from 'antd'; -import LoadingSpin from '../../../common/LoadingSpin'; -import './shixunCss/shixunCard.css'; - -// 引入业务组件样式 - -import axios from 'axios'; - -const $ = window.$; - -class ShixunCard extends Component { - constructor(props) { - super(props) - - this.state = { - startValue:[], - order_by:"", - page:1, - limit:16, - keyword:"", - status:0, - diff:0, - hideme:false, - tag_level:3, - tag_id:'' - } - - } - - PaginationonChange=(pageNumber)=> { - this.props.shixunsPage(pageNumber); - } - - render() { - let {middleshixundata, pagination, typepvisible, pages, totalcount} = this.props; - const MyRate = ({ defaultValue, ...rest }) => { - let myValue = defaultValue; - // console.log(myValue-Math.floor(myValue)) - // if (myValue < Math.ceil(myValue)) { - // myValue = Math.floor(myValue) + 0.5; - // } - - return ; - }; - return ( -
    - - - - { middleshixundata === undefined?"":middleshixundata.length === 0 ?
    - - -

    暂时还没有相关数据哦!

    -
    :""} - - -
    -
    -
    - {middleshixundata === undefined || middleshixundata.length === 0?" ":middleshixundata.map((item,key)=>{ - return( -
    - - { - item.tag_name === null ? "": -
    - {item.tag_name} - {/**/} -
    - } -
    - -

    非试用内容,需要授权

    -
    - - - {/**/} - - - {/*target="_blank"*/} - -
    -

    - - {item.name} - -

    - - {/*target="_blank"*/} - {/**/} -

    - - {/**/} - - - {item.score_info===null?"5分":item.score_info+"分"} -

    - -

    - - - {item.challenges_count} - - - - {/**/} - {/**/} - {/*{item.exp}*/} - {/**/} - {/**/} - - - - {item.stu_num} - - - - {item.level} -

    - -
    -
    - ) - }) - } - -
    - -
    - {/*totalcount*/} -
    - {/**/} - {/* 不加参数请求的时候,没返回总数了。加了个比较大的数字,让他可以翻页 */} - -
    - -
    - -
    -
    -
    - ) - } -} - -export default ShixunCard; diff --git a/public/react/src/tpm/shixuns/ShixunCardList.js b/public/react/src/tpm/shixuns/ShixunCardList.js deleted file mode 100644 index d95ef75fe..000000000 --- a/public/react/src/tpm/shixuns/ShixunCardList.js +++ /dev/null @@ -1,253 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route} from "react-router-dom"; - -import { Switch ,Input,Tooltip,Icon} from 'antd'; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -import 'antd/lib/switch/style/index.css' - -import './shixunCss/ShixunCardList.css'; - -import { on, off } from 'educoder' - -const $ = window.$; - -const Search = Input.Search; - -class ShixunCardList extends Component { - - constructor(props) { - super(props); - this.state={ - allevent:"desc", - mine:0, - InputValue: props.keyword || "", - typemy:0, - hots:0, - news:0, - shixunid:"", - upcircle:false, - typekeyid:undefined, - } - } - - componentDidUpdate = (prevProps, prevState) => { - if (this.props.keyword != prevProps.keyword) { - this.setState({ - InputValue: this.props.keyword - }) - } - } - componentDidMount = () => { - on('searchKeywordChange', (event, data) => { - // console.log(data) - this.Input_search(data) - }) - } - componentWillUnmount = () => { - off('searchKeywordChange') - } - - - latestHot=(e,key)=>{ - - let{upcircle,typekeyid}=this.state; - - let id = e.target.id; - $("#"+id).siblings().removeClass("active"); - $("#"+id).addClass("active"); - - let type; - - // if(id==="all"){ - // type="publish_time"; - // } - if(id==="hot"){ - type="hot"; - }else if(id==="new"){ - type="new"; - - } - if(typekeyid===key){ - if(upcircle===true){ - this.setState({ - upcircle:false, - }) - this.props.Shixunsupcircles("desc") - }else if(upcircle===false){ - this.setState({ - upcircle:true, - }) - this.props.Shixunsupcircles("asc") - } - }else{ - this.setState({ - typekeyid:key - }) - } - - //allevent - this.props.ShixunsState(false,type); - } - - - onSwitchChange=(e,key)=>{ - let id=e.target.id - $("#"+id).siblings().removeClass("active"); - $("#"+id).addClass("active"); - let {typemy,upcircle,typekeyid}=this.state; - - if(typekeyid===key){ - if(upcircle===true){ - this.setState({ - upcircle:false, - }) - this.props.Shixunsupcircles("desc") - }else if(upcircle===false){ - this.setState({ - upcircle:true - }) - this.props.Shixunsupcircles("asc") - } - }else{ - this.setState({ - typekeyid:key - }) - } - - - if(typemy===0){ - this.setState({ - typemy:1 - }) - }else{ - this.setState({ - typemy:0 - }) - } - // allevent - this.props.ShixunsSwitch(); - } - //输入框搜索 - Input_search = (value) => { - this.setState({ - InputValue: value - }) - this.props.OnSearchInput(value,true); - } - - Input_searchs = (e) => { - this.setState({ - InputValue: e.target.value - }) - this.props.OnSearchInput(e.target.value,false); - } - upcircles=(val)=>{ - if(val==="asc"){ - this.setState({ - upcircle:false, - }) - this.props.Shixunsupcircles("desc") - }else if(val==="desc"){ - this.setState({ - upcircle:true - }) - this.props.Shixunsupcircles("asc") - } - } - render(){ - let {mine,InputValue,upcircle}=this.state; - return ( -
    -
    - - {/*
    this.latestHot(e,1)}>全部*/} - {/*
    */} - {/*
    this.onSwitchChange(e,2)}>我的*/} - {/*
    */} - -
    this.latestHot(e,4)}>最新 -
    - -
    this.latestHot(e,3)}>最热 -
    - - - {/*
    this.upcircles("asc")}*/} - {/*>*/} - {/**/} - {/**/} - {/*/!**!/*/} - {/**/} - {/*
    */} - {/*
    this.upcircles("desc")}*/} - {/*style={{display:upcircle===true?"none":"block"}}*/} - {/*>*/} - {/**/} - {/**/} - {/*/!**!/*/} - {/**/} - {/*
    */} - - {/*
    */} - {/* this.Input_search(value)}*/} - {/*enterButton*/} - {/*/>*/} - - {/* this.Input_search(value)} - autoComplete="off" - > */} - {/*
    */} - {/*
    */} - {/*{*/} - {/*this.props.search_tags === null ? "" : this.props.search_tags*/} - {/*}*/} - {/*
    */} - {/*/!*
    */} - {/* *!/*/} - {/**/} - {/*
    */} - {/*隐藏我的*/} - - {/*
    */} - {/**/} -
    -
    - ); - } -} - -export default ShixunCardList; diff --git a/public/react/src/tpm/shixuns/ShixunSearchBar.js b/public/react/src/tpm/shixuns/ShixunSearchBar.js deleted file mode 100644 index f9c4a7936..000000000 --- a/public/react/src/tpm/shixuns/ShixunSearchBar.js +++ /dev/null @@ -1,292 +0,0 @@ -import React, { Component } from 'react'; - -import { Select, Input,Menu, Dropdown } from 'antd'; - -import 'antd/lib/style/index.css'; - -import 'antd/lib/select/style/index.css'; - -import 'antd/lib/input/style/index.css'; - -import './shixunCss/ShixunSearchBar.css'; - -import axios from 'axios'; - -const $ = window.$; - -const Option = Select.Option; - -const Search = Input.Search; - - -class ShixunSearchBar extends Component { - - constructor(props) { - super(props) - this.state = { - status: undefined, - diff: 0, - InputValue: undefined, - shixunhoverData: [], - shixunchildValues:'', - shixunsearchAllvalue:"a", - openStatus:false, - openLevel:false - } -} - - //状态筛选 - status_search = (value) => { - let newvalue = value; - if (newvalue === "0") { - newvalue = " " - } else if (newvalue === "1") { - newvalue = 2 - } else if (newvalue === "2") { - newvalue = 1 - } else if (newvalue === "3") { - newvalue = 3 - } - - this.setState({ - status: newvalue, - openStatus:false - }) - let list = [{'type': 1}, {'value': newvalue}]; - this.props.StatusEnquiry(list); -} - - //难度筛选 -diff_search = (value) => { - this.setState({ - diff: value, - openLevel:false - }) - let list=[{'type':2},{'value':value}]; - this.props.StatusEnquiry(list); -} - - //输入框搜索 -Input_search = (value) => { - this.setState({ - InputValue: value - }) - this.props.OnSearchInput(value); -} - //查询 -shixunsearchAll = (e) => { - let{shixunsearchAllvalue}=this.state; - let id = e.target.value; - - if(shixunsearchAllvalue===id){ - return - } - if(id===0){ - id=" " - this.setState({ - InputValue: " " - }) - this.props.OnSearchInput(""); - } - let list=[{'tag_level':1},{'tag_id':id}]; - if(id!=undefined){ - this.setState({ - shixunsearchAllvalue:id, - shixunchildValues:"" - }) - this.props.Updatasearchlist(list); - } - -} - - shixunsearchall=(e)=>{ - let{shixunsearchAllvalue}=this.state; - let id = "a"; - - if(shixunsearchAllvalue===id){ - return - } - this.setState({ - shixunsearchAllvalue:"a", - shixunchildValues:"" - }) - this.props.allUpdatashixunlist(); - } - - //选择Tab页详情 - getshixunchildValue = (e) => { - - debugger - let id = e.target.name; - let newid=e.target.id; - let list=[{'tag_level':2},{'tag_id':id}]; - if(id!=undefined||newid!=undefined){ - this.setState({ - shixunsearchAllvalue:newid - }) - this.props.Updatasearchlist(list); - } - } - -getshixunchildValues = (e) => { - let id = e.target.id; - let newid=e.target.name; - let list=[{'tag_level':3},{'tag_id':id}]; - if(id!=undefined||newid!=undefined){ - this.setState({ - shixunchildValues:id, - shixunsearchAllvalue:newid - }) - this.props.Updatasearchlist(list); - } - -} - -componentDidMount() { - let hoverUrlArr = []; - let hoverUrl = `/shixuns/menus.json`; - axios.get(hoverUrl - ).then((response) => { - hoverUrlArr = response.data; - // hoverUrlArr.reverse(); - this.setState({ - shixunhoverData: hoverUrlArr - }) - }).catch((error) => { - console.log(error) - }) -} - -render() { - let {shixunhoverData, shixunchildValues, shixunsearchAllvalue, InputValue,openStatus,openLevel} = this.state; - let {typepvisible} = this.props; - // //实训首页筛选的移入和点击事件 - // $(".shaiItem").hover(function(){ - // var hei=parseInt($(".shaiAllItem").height())-2; - // $(this).find(".subshaicontent").css("top", '34px'); - // $(this).find(".subshaicontent").show(); - // },function(){ - // $(this).find(".subshaicontent").hide(); - // }); - // - // $(".shaiItem").live("click",function(){ - // $(".shaiItem").removeClass("active"); - // $(this).addClass("active"); - // $(".subshaicontent").hide(); - // }); - // - // $(".subshaicontent").live("click", function(event){ - // $(".subshaicontent").hide(); - // event.stopPropagation(); - // }); - - let overlaymenu=(item,id)=>( - - { - item.map((list,k)=>{ - return( - -
    - {list.name} -
    - { - list.tags.map((tag,e)=>{ - return( - {tag.name} - ) - }) - } -
    -
    -
    - ) - }) - } -
    - ) - - return ( -
    -
    -
    -
    - 方向: -
    -
  • 全部
  • - - { - shixunhoverData.map((item,key)=>{ - return( - -
  • - {item.name} -
  • -
    - ) - }) - } - - -
    -
    -
    - 筛选: - { - - } -
    -
  • this.diff_search(0)}>全部难度
  • -
  • this.diff_search(1)}>初级学员
  • -
  • this.diff_search(2)}>中级学员
  • -
  • this.diff_search(3)}>高级学员
  • -
  • this.diff_search(4)}>顶级学员
  • -
    - -
    -
    -
    -
    - ); -} -} - -export default ShixunSearchBar; diff --git a/public/react/src/tpm/shixuns/ShixunsIndex.js b/public/react/src/tpm/shixuns/ShixunsIndex.js deleted file mode 100644 index 15579610d..000000000 --- a/public/react/src/tpm/shixuns/ShixunsIndex.js +++ /dev/null @@ -1,422 +0,0 @@ -import React, { Component } from 'react'; - -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import axios from 'axios'; - -import { Spin } from 'antd'; - -import { TPMIndexHOC } from '../TPMIndexHOC'; - -import { SnackbarHOC } from 'educoder'; - -import ShixunCardList from './ShixunCardList'; - -import ShixunSearchBar from './ShixunSearchBar'; - -import ShixunCard from './ShixunCard'; - -import UpgradeModals from '../../modals/UpgradeModals'; - -const queryString = require('query-string'); - -const $ = window.$; - -class ShixunsIndex extends Component { - constructor(props) { - super(props) - this.state={ - order_by: "new", - page:1, - limit:16, - keyword:"", - status:0, - diff:0, - tag_level: 1, - tag_id:'', - middleshixundata:[], - typepvisible:true, - pages:1, - search_tags:null, - parsedid:undefined, - newtag_level:undefined, - newpalce:undefined, - sort:"desc" - } - } - componentDidMount(){ - - const upsystem=`/users/system_update.json`; - axios.get(upsystem).then((response)=>{ - let updata=response.data; - this.setState({ - updata:updata - }) - }).catch((error)=>{ - console.log(error); - }) - - - - let _keyword; - if (window.__headSearchKeyword) { - this.setState({ keyword: window.__headSearchKeyword }) - _keyword = window.__headSearchKeyword - delete window.__headSearchKeyword - } - const parsed = queryString.parse(this.props.location.search); - if(parsed.id===undefined&&parsed.type===undefined){ - let {order_by, tag_level, tag_id, page, limit, keyword, status, diff} = this.state; - let params={ - order_by:order_by, - tag_level:tag_level, - tag_id:tag_id, - page:page, - limit:limit, - keyword: _keyword || keyword , - status:status, - diff:diff, - sort: "desc" - } - this.shixunresultend(params); - }else{ - let {order_by,page, limit, keyword, status, diff} = this.state; - let nawparsed=parsed.type; - let newpalce=parsed.palce; - if(nawparsed==="rep"){ - nawparsed=1 - } - else if(nawparsed==="sub"){ - nawparsed=2 - }else if(nawparsed==="tag"){ - nawparsed=3 - } - let params={ - order_by:order_by, - tag_level:nawparsed, - tag_id:parsed.id, - page:page, - limit:limit, - keyword: _keyword || keyword, - status:status, - diff:diff, - sort: "desc" - } - this.setState({ - parsedid:parsed.id, - newtag_level:nawparsed, - newpalce:newpalce - }) - this.shixunresultend(params); - } - - } - - allUpdatashixunlist=()=>{ - let{sort,order_by}=this.state; - - this.setState({ - tag_level: 1, - tag_id:'', - page: 1, - limit: 16, - keyword:'', - status: 0, - diff: 0, - }) - - let params={ - order_by:order_by, - tag_level: 1, - tag_id:'', - page: 1, - limit: 16, - keyword:'', - status: 0, - diff: 0, - sort:sort - } - this.shixunresultend(params) - } - Updatasearchlist=(value)=>{ - if (value[1].tag_id === " ") { - this.setState({ - keyword: "" - }) - } - this.setState({ - tag_level:value[0].tag_level, - tag_id:value[1].tag_id, - typepvisible:true - }) - - let {order_by, sort, limit, keyword, status, diff} = this.state; - - let params={ - order_by:order_by, - tag_level:value[0].tag_level, - tag_id:value[1].tag_id, - page:1, - limit:limit, - keyword:keyword, - status:status, - diff:diff, - sort:sort - } - - this.shixunresultend(params) - } - - StatusEnquiry=(key)=>{ - - let Vrl=`/shixuns.json`; - let newstatus; - let newdiff; - if(key[0].type===1){ - this.setState({ - status: key[1].value, - typepvisible:true - }) - newstatus=key[1].value; - newdiff=this.state.diff; - }else if(key[0].type===2){ - this.setState({ - diff: key[1].value, - typepvisible:true - }) - newdiff=key[1].value; - newstatus=this.state.status; - } - let params= { - order_by:this.state.order_by, - tag_level:this.state.tag_level, - tag_id:this.state.tag_id, - page:1, - limit:this.state.limit, - keyword:this.state.keyword, - status:newstatus, - diff:newdiff, - } - this.shixunresultend(params) - - } - - OnSearchInput=(value,type)=>{ - if(type===true){ - this.setState({ - keyword:value, - typepvisible:true, - pages:1 - }) - let {order_by, tag_level, tag_id, sort, limit, status, diff} = this.state; - let params= { - order_by:order_by, - tag_level:tag_level, - tag_id:tag_id, - page:1, - limit:limit, - keyword:value, - status:status, - diff:diff, - sort:sort - } - this.shixunresultend(params) - }else{ - this.setState({ - keyword:value, - pages:1 - }) - } - - - } - - ShixunsSwitch=()=>{ - //types - this.setState({ - order_by:"mine", - typepvisible:true, - pages:1, - }) - let{tag_level,tag_id,page,limit,keyword,status,diff,sort}=this.state; - let newsort=sort; - if(newsort===undefined){ - newsort="desc" - } - let params= { - order_by:"mine", - tag_level:tag_level, - tag_id:tag_id, - page:1, - limit:limit, - keyword:keyword, - status:status, - diff:diff, - sort:newsort - } - this.shixunresultend(params) - } - - - shixunsPage=(value)=>{ - this.setState({ - page:value, - typepvisible:true, - pages:value - }) - let {order_by, tag_level, tag_id, limit, keyword, status, diff,sort} = this.state; - let params= { - order_by:order_by, - tag_level:tag_level, - tag_id:tag_id, - page:value, - limit:limit, - keyword:keyword, - status:status, - diff:diff, - sort:sort - } - - let Url=`/shixuns.json`; - axios.get(Url,{ - params - }).then((response)=> { - if(response.status===200){ - this.setState({ - middleshixundata: response.data, - typepvisible:false, - }); - } - }).catch((error)=>{ - console.log(error) - }); - } - ShixunsState=(val,type)=>{ - // sort, - let {tag_level, tag_id, page, limit, keyword, status, diff,sort} = this.state; - let newsort=sort; - this.setState({ - order_by:type, - typepvisible:true, - pages:1, - // sort:sort - }) - - let params - // let vals=false - if(newsort===undefined){ - newsort="desc" - } - params= { - order_by:type, - tag_level:tag_level, - tag_id:tag_id, - page:1, - limit:limit, - keyword:keyword, - status:status, - diff:diff, - sort:newsort - } - this.shixunresultend(params) - } - - Shixunsupcircles=(sort)=>{ - console.log(sort) - this.setState({ - sort:sort - }) - let { - order_by, - tag_level, - tag_id, - limit, - keyword, - status, - diff, - } = this.state; - - - - let params= { - order_by:order_by, - tag_level:tag_level, - tag_id:tag_id, - page:1, - limit:limit, - keyword:keyword, - status:status, - diff:diff, - sort:sort - } - this.shixunresultend(params) - } - - - - - shixunresultend=(params)=>{ - let Url=`/shixuns.json`; - axios.get(Url,{ - params - }).then((response)=> { - // TODO 有keyword返回值时 显示一共有多少条记录 - if(response.status===200){ - this.setState({ - search_tags:response.data.search_tags, - middleshixundata: response.data, - typepvisible:false, - pages:1 - }); - } - }).catch((error)=>{ - console.log(error) - }); - } - render() { - let {middleshixundata, typepvisible, pages, search_tags, keyword,parsedid,newtag_level,newpalce} = this.state; - - // console.log(this.state.updata) - return ( -
    - {this.state.updata===undefined?"":} - {/**/} - - - - - - {/**/} -
    - ); - } -} - -export default SnackbarHOC() (TPMIndexHOC ( ShixunsIndex )); diff --git a/public/react/src/tpm/shixuns/css/TPMBanner.css b/public/react/src/tpm/shixuns/css/TPMBanner.css deleted file mode 100644 index fe059fccd..000000000 --- a/public/react/src/tpm/shixuns/css/TPMBanner.css +++ /dev/null @@ -1,114 +0,0 @@ -.shixunsdiffcult{ - width: 40px; - height: 21px; - overflow: hidden; - margin-left: 8px; - } - - .rateYo{ - text-align: center; - cursor: default; - width: 111px; - } - - a:link, a:visited { - color: #05101a; -} - -a:link{text-decoration:none;} - -a:visited{text-decoration:none;} - -a:hover{text-decoration:none;} - -a:active{text-decoration:none;} - - -.next-rating-overlay .next-icon{ - color: #FFA800!important; -} - -.displayblock{ - display:block; - text-align: center; - margin-bottom: 20px; -} - -.totalScore{ - justify-content: center; - align-items: center; - display: -webkit-flex; - height: 100%; -} - -.next-progress-line{ - width: 210px !important; - margin-left: 10px; - margin-top: 4px; -} - -.next-progress-line-overlay-normal{ - background-color: #FFA800 !important; -} -.next-rating-base-disabled{ - cursor: default!important; -} -/*#challenge_begin {*/ -/*!*height: 40px !important;*!*/ -/*line-height: 30px;*/ -/*}*/ -.ant-modal-title{ - font-size: 16px; - font-weight: bold !important; - color: #333; -} - -.ml60{ - margin-left:20px; -} - -.marginauto{ - margin:0 auto; -} -.margin152{ - margin-left: 152px; -} - -.margin-tp26{ - margin-top: -26px; -} -.edu-h315{ - height:315px; -} - -.height39 { - height: 39px !important; -} - -#commentsStar{ - margin-top: -7px; - width: 90px; - height: 80px; -} - -.startbtnModal .ant-modal-content{ - background: transparent; - box-shadow: 0 4px 12px transparent; -} - -.startbtnModal .ant-modal-content .ant-modal-body .ant-spin-spinning{ - margin-left: 45%; -} - -.mr51{ - margin-right:51px; -} - -.flexbannerright{ - display: flex; - justify-content: flex-end; -} - -.width360{ - width:360px; -} \ No newline at end of file diff --git a/public/react/src/tpm/shixuns/shixunCss/ShixunCardList.css b/public/react/src/tpm/shixuns/shixunCss/ShixunCardList.css deleted file mode 100644 index c806434f5..000000000 --- a/public/react/src/tpm/shixuns/shixunCss/ShixunCardList.css +++ /dev/null @@ -1,13 +0,0 @@ -#myshixuns_count{ - text-decoration:none !important; -} -#created_at{ - text-decoration:none !important; -} -.shixun_repertoire{ - cursor: pointer ; -} -.next-btn-medium:hover{ - color: #4CACFF; - border:1px solid #4CACFF; -} \ No newline at end of file diff --git a/public/react/src/tpm/shixuns/shixunCss/ShixunSearchBar.css b/public/react/src/tpm/shixuns/shixunCss/ShixunSearchBar.css deleted file mode 100644 index 9fba271ce..000000000 --- a/public/react/src/tpm/shixuns/shixunCss/ShixunSearchBar.css +++ /dev/null @@ -1,20 +0,0 @@ -.iconfontShixunSearchBar{ - z-index: 1000; - position: absolute; - right: 3px; - top: 0px; -} - -.diffSelect{ - margin-left:20px !important; - } - .ant-input-search-button{ - /*margin-right: 10px;*/ - border: 1px solid transparent; - } -.Mousebox{ - width: 800px !important; -} -.subshaicontent a{ - height:30px; -} \ No newline at end of file diff --git a/public/react/src/tpm/shixuns/shixunCss/shixunCard.css b/public/react/src/tpm/shixuns/shixunCss/shixunCard.css deleted file mode 100644 index 1ec00a26e..000000000 --- a/public/react/src/tpm/shixuns/shixunCss/shixunCard.css +++ /dev/null @@ -1,42 +0,0 @@ -.ml350 { - margin-left: 40%; -} - -.ml32 { - margin-left: 32%; -} - -.square-img{ - min-height: 210px; -} -.task-hide{ - margin-bottom: 0em; -} -.backFAFAFA{ - background:#FAFAFA; -} - -.demo { - width: 500px; - background-color: #0dcecb; - text-align: center; - padding:50px; -} -.next-loading { - margin-bottom: 5px; - width:100%; -} - -.next-rating-overlay .next-icon{ - color: #FFA800!important; -} - -.custom-pagination { - display: inline-block; - margin-left: 10px; -} - -.ml425{ - margin-left:42.5%; - margin-top:20px; -} \ No newline at end of file diff --git a/public/react/src/tpm/shixuns/shixunCss/tag2.png b/public/react/src/tpm/shixuns/shixunCss/tag2.png deleted file mode 100644 index 423d2f7e3..000000000 Binary files a/public/react/src/tpm/shixuns/shixunCss/tag2.png and /dev/null differ diff --git a/public/react/src/tpm/shixuns/shixusFunction/ShixunSearchBar.js b/public/react/src/tpm/shixuns/shixusFunction/ShixunSearchBar.js deleted file mode 100644 index 4211e3196..000000000 --- a/public/react/src/tpm/shixuns/shixusFunction/ShixunSearchBar.js +++ /dev/null @@ -1,142 +0,0 @@ -const $ = window.$; - - -$(function(){ - //实训首页筛选的移入和点击事件 - $(".shaiItem").hover(function(){ - var hei=parseInt($(".shaiAllItem").height())-2; - $(this).find(".subshaicontent").css("top",hei); - $(this).find(".subshaicontent").show(); - },function(){ - $(this).find(".subshaicontent").hide(); - }); - - $(".shaiItem").live("click",function(){ - $(".shaiItem").removeClass("active"); - $(this).addClass("active"); - $(".subshaicontent").hide(); - }); - - $(".subshaicontent").live("click", function(event){ - $(".subshaicontent").hide(); - event.stopPropagation(); - }); - - //最新、最热 - $(".bestChoose").click(function(){ - $(".bestChoose").removeClass("active"); - $(this).addClass("active"); - }) - - //实训路径选择导航条 - $(".path-nav li a").live("click",function(){ - $(".path-nav li").removeClass("active"); - $(this).parent().addClass("active"); - }) -}); - -//隐藏我的学习 - function clickControl(item, type){ - var wid=$(item).width(); - var wid1=$(".controlring").width(); - var hidden_course = 1; - if($(".controlring").css("left")=="1px"){ - $(".controlring").animate({left:parseInt(wid-wid1-1)+"px"}); - $(".controlblue").animate({width:wid+"px"}); - $("input[name='hidden_learn']").val('1'); - }else{ - $(".controlring").animate({left:"1px"}); - $(".controlblue").animate({width:"0px"}); - $("input[name='hidden_learn']").val(''); - hidden_course = 0; - } - if(type == "l_shixun"){ - $("#shixun_search_condition").submit(); - } else{ - $.get("/courses?select="+$("#select_type").val()+"&order="+$("#select_order").val()+"&hidden="+hidden_course); - } -} - -// 清空条件 - function clear_style(){ - $("#shixun_search_condition").find('input[type=hidden]').each(function() { - $(this).val(''); - }); -} - -// 精选实训的搜索 #type参数( status:实训状态; diff:实训难度; search:实训搜索; order:最新最热排序) -function filter_search(values, type){ - switch(type){ - case "status": - $("input[name='status']").val(values); - break; - case "diff": - $("input[name='diff']").val(values); - break; - case "search": - $("input[name='search']").val(values); - break; - } - $("#shixun_search_condition").submit(); -} - -// 点击实训体系名称 # type参数(rep:体系大类别; sub:体系子类别; tags 实训标签; order: 排序) -// # name参数: 列表显示使用 -// # values参数: 赋值给表单的值 -$(".shixun_repertoire").live("click", function(event){ - var type = $(this).attr("data-type"); - var name = $(this).attr("data-name"); - var values = $(this).attr("data-values"); - if(type != 'order'){ - $(".subshaicontent a").removeClass("active"); - $(".shaiItem").removeClass("active"); - $("input[name='repertoire'], input[name='sub_repertoire'], input[name='tag_repertoire']").val(''); - } - $(this).closest(".shaiItem").addClass("active"); - $(".subshaicontent").hide(); - $("#search_name").html(name); - - switch(type){ - case "rep": - $("input[name='repertoire']").val(values); - $("#shixun_search_input").val(""); - $("input[name='search']").val(""); - break; - case "sub": - $("input[name='sub_repertoire']").val(values); - break; - case "tag": - $("input[name='tag_repertoire']").val(values); - break; - case "order": - var $sort = $("input[name='sort']"); - var oldValue = $("input[name='order']").val(); - $("input[name='order']").val(values); - var newValue = $("input[name='order']").val(); - if(oldValue != newValue){ - $("input[name='sort']").val("desc"); - }else { - if($sort.val() == "desc"){ - $sort.val("asc"); - }else{ - $sort.val("desc"); - } - } - break; - } - $(this).addClass("active"); // 因为order需要判断样式因此写在switch之后 - $("#shixun_search_condition").submit(); - event.stopPropagation(); -}); - - -// 实训首页回车搜索 -$("#shixun_search_input").live("keyup", function(e){ - // 兼容FF和IE和Opera - var theEvent = e || window.event; - var code = theEvent.keyCode || theEvent.which || theEvent.charCode; - if (code == 13) { - //回车执行查询 - filter_search($(this).val(), "search"); - } -}); \ No newline at end of file