From 9aedab22d853966081a1af613eac080f0dfd0c11 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 30 May 2019 11:13:49 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0190530025028_migrate_homework_end_time.rb | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 db/migrate/20190530025028_migrate_homework_end_time.rb diff --git a/db/migrate/20190530025028_migrate_homework_end_time.rb b/db/migrate/20190530025028_migrate_homework_end_time.rb new file mode 100644 index 00000000..50b496d7 --- /dev/null +++ b/db/migrate/20190530025028_migrate_homework_end_time.rb @@ -0,0 +1,93 @@ +class MigrateHomeworkEndTime < ActiveRecord::Migration + def up + homework = HomeworkCommon.where(id: 18615).first + if homework.present? + transaction do + homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '#{homework.end_time}'").each do |work| + work.work_status = 1 + work.late_penalty = 0 + score = work.final_score + work.eff_score - work.late_penalty + work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score + work.save + end + end + end + + homework = HomeworkCommon.where(id: 18614).first + if homework.present? + homework.update_column('end_time', '2019-05-20 00:00:00') + transaction do + homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-05-20 00:00:00'").each do |work| + work.work_status = 1 + work.late_penalty = 0 + score = work.final_score + work.eff_score - work.late_penalty + work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score + work.save + end + end + end + + homework = HomeworkCommon.where(id: 18617).first + if homework.present? + homework.update_column('end_time', '2019-05-29 00:00:00') + homework.save + transaction do + homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-05-29 00:00:00'").each do |work| + work.work_status = 1 + work.late_penalty = 0 + score = work.final_score + work.eff_score - work.late_penalty + work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score + work.save + end + end + end + + homework = HomeworkCommon.where(id: 18616).first + if homework.present? + homework.update_column('end_time', '2019-06-10 00:00:00') + homework.save + transaction do + homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-06-10 00:00:00'").each do |work| + work.work_status = 1 + work.late_penalty = 0 + score = work.final_score + work.eff_score - work.late_penalty + work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score + work.save + end + end + end + + homework = HomeworkCommon.where(id: 25901).first + if homework.present? + homework.update_column('end_time', '2019-06-16 00:00:00') + homework.save + transaction do + homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-06-16 00:00:00'").each do |work| + work.work_status = 1 + work.late_penalty = 0 + score = work.final_score + work.eff_score - work.late_penalty + work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score + work.save + end + end + end + + homework = HomeworkCommon.where(id: 25902).first + if homework.present? + homework.update_column('end_time', '2019-06-17 00:00:00') + homework.save + transaction do + homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-06-17 00:00:00'").each do |work| + work.work_status = 1 + work.late_penalty = 0 + score = work.final_score + work.eff_score - work.late_penalty + work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score + work.save + end + end + end + end + + def down + end +end From 09647a26832983e9574a7916aa40e5e5bea54e12 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 30 May 2019 12:39:36 +0800 Subject: [PATCH 02/16] =?UTF-8?q?D=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20190530025028_migrate_homework_end_time.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/db/migrate/20190530025028_migrate_homework_end_time.rb b/db/migrate/20190530025028_migrate_homework_end_time.rb index 50b496d7..cff8d8d8 100644 --- a/db/migrate/20190530025028_migrate_homework_end_time.rb +++ b/db/migrate/20190530025028_migrate_homework_end_time.rb @@ -6,7 +6,7 @@ class MigrateHomeworkEndTime < ActiveRecord::Migration homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '#{homework.end_time}'").each do |work| work.work_status = 1 work.late_penalty = 0 - score = work.final_score + work.eff_score - work.late_penalty + score = work.final_score.to_f + work.eff_score.to_f - work.late_penalty.to_f work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score work.save end @@ -20,7 +20,7 @@ class MigrateHomeworkEndTime < ActiveRecord::Migration homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-05-20 00:00:00'").each do |work| work.work_status = 1 work.late_penalty = 0 - score = work.final_score + work.eff_score - work.late_penalty + score = work.final_score.to_f + work.eff_score.to_f - work.late_penalty.to_f work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score work.save end @@ -35,7 +35,7 @@ class MigrateHomeworkEndTime < ActiveRecord::Migration homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-05-29 00:00:00'").each do |work| work.work_status = 1 work.late_penalty = 0 - score = work.final_score + work.eff_score - work.late_penalty + score = work.final_score.to_f + work.eff_score.to_f - work.late_penalty.to_f work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score work.save end @@ -50,7 +50,7 @@ class MigrateHomeworkEndTime < ActiveRecord::Migration homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-06-10 00:00:00'").each do |work| work.work_status = 1 work.late_penalty = 0 - score = work.final_score + work.eff_score - work.late_penalty + score = work.final_score.to_f + work.eff_score.to_f - work.late_penalty.to_f work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score work.save end @@ -65,7 +65,7 @@ class MigrateHomeworkEndTime < ActiveRecord::Migration homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-06-16 00:00:00'").each do |work| work.work_status = 1 work.late_penalty = 0 - score = work.final_score + work.eff_score - work.late_penalty + score = work.final_score.to_f + work.eff_score.to_f - work.late_penalty.to_f work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score work.save end @@ -80,7 +80,7 @@ class MigrateHomeworkEndTime < ActiveRecord::Migration homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-06-17 00:00:00'").each do |work| work.work_status = 1 work.late_penalty = 0 - score = work.final_score + work.eff_score - work.late_penalty + score = work.final_score.to_f + work.eff_score.to_f - work.late_penalty.to_f work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score work.save end From 1c051ba24d1b9f702983cb756977ff8b94fffc31 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 30 May 2019 12:54:19 +0800 Subject: [PATCH 03/16] =?UTF-8?q?D=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...44812_migrate_shixun_student_work_score.rb | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 db/migrate/20190530044812_migrate_shixun_student_work_score.rb diff --git a/db/migrate/20190530044812_migrate_shixun_student_work_score.rb b/db/migrate/20190530044812_migrate_shixun_student_work_score.rb new file mode 100644 index 00000000..446a2652 --- /dev/null +++ b/db/migrate/20190530044812_migrate_shixun_student_work_score.rb @@ -0,0 +1,28 @@ +class MigrateShixunStudentWorkScore < ActiveRecord::Migration + def up + homeworks = HomeworkCommon.where(id: [18615, 18614, 18617, 18616, 25901, 25902]) + homeworks.each do |homework| + transaction do + challeng_ids = homework.homework_challenge_settings.map(&:challenge_id) + homework.student_works.where("work_status > 0").each do |work| + myshixun = work.myshixun + games = myshixun.games.where(:challenge_id => challeng_ids) + myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil + if myshixun_endtime.present? && myshixun_endtime < homework.end_time + work.work_status = 1 + work.late_penalty = 0 + else + work.work_status = 2 + work.late_penalty = homework.late_penalty + end + score = work.final_score.to_f + work.eff_score.to_f - work.late_penalty.to_f + work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score + work.save + end + end + end + end + + def down + end +end From dc0cc0beb8029c68a300abaa3f51b77c76155206 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 30 May 2019 13:12:09 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...58_migrate_shixun_student_work_score_2.rb} | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) rename db/migrate/{20190530044812_migrate_shixun_student_work_score.rb => 20190530050358_migrate_shixun_student_work_score_2.rb} (50%) diff --git a/db/migrate/20190530044812_migrate_shixun_student_work_score.rb b/db/migrate/20190530050358_migrate_shixun_student_work_score_2.rb similarity index 50% rename from db/migrate/20190530044812_migrate_shixun_student_work_score.rb rename to db/migrate/20190530050358_migrate_shixun_student_work_score_2.rb index 446a2652..4eb869b4 100644 --- a/db/migrate/20190530044812_migrate_shixun_student_work_score.rb +++ b/db/migrate/20190530050358_migrate_shixun_student_work_score_2.rb @@ -1,19 +1,22 @@ -class MigrateShixunStudentWorkScore < ActiveRecord::Migration +class MigrateShixunStudentWorkScore2 < ActiveRecord::Migration def up homeworks = HomeworkCommon.where(id: [18615, 18614, 18617, 18616, 25901, 25902]) homeworks.each do |homework| transaction do - challeng_ids = homework.homework_challenge_settings.map(&:challenge_id) homework.student_works.where("work_status > 0").each do |work| - myshixun = work.myshixun - games = myshixun.games.where(:challenge_id => challeng_ids) - myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil - if myshixun_endtime.present? && myshixun_endtime < homework.end_time + if homework.end_time > Time.now work.work_status = 1 work.late_penalty = 0 - else - work.work_status = 2 - work.late_penalty = homework.late_penalty + else + myshixun = work.myshixun + + if myshixun.status == 1 && myshixun.try(:done_time) < homework.end_time + work.work_status = 1 + work.late_penalty = 0 + else + work.work_status = 2 + work.late_penalty = homework.late_penalty + end end score = work.final_score.to_f + work.eff_score.to_f - work.late_penalty.to_f work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score From 4c92bab9285226585a4ca012be8ae32cfbc0709b Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Thu, 30 May 2019 23:09:03 +0800 Subject: [PATCH 05/16] _resizeTpiPanel --- public/react/public/js/js_min_all.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/react/public/js/js_min_all.js b/public/react/public/js/js_min_all.js index 0aa8e44a..19daead5 100644 --- a/public/react/public/js/js_min_all.js +++ b/public/react/public/js/js_min_all.js @@ -153,9 +153,10 @@ var EXPAND = 0; // 放大 var SHRINK = 1; // 缩小 var repositoryTabHeight = 40 -function _resizeTpiPanel = () { - $("#game_left_contents").width('400px'); - $("#game_right_contents").width( $(".labelN").width() - 400 + 'px'); +function _resizeTpiPanel () { + var _total = $(".labelN").width(); + $("#game_left_contents").width( _total * 0.35 + 'px'); + $("#game_right_contents").width( _total * 0.65 + 'px'); } $(function(){ function update_rows_and_cols(rows) { From c389f0f2a620eab27356334da98f021f9e98d83d Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 31 May 2019 10:18:17 +0800 Subject: [PATCH 06/16] modify school active user count --- app/models/school_daily_active_user.rb | 3 +++ app/models/school_daily_report.rb | 2 ++ app/services/management/school_data_grow_service.rb | 5 ++++- app/tasks/statistic_school_daily_report_task.rb | 9 +++++++-- app/views/managements/schools/_data_grow_list.html.erb | 8 +++++--- .../20190531011258_create_school_daily_active_users.rb | 10 ++++++++++ 6 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 app/models/school_daily_active_user.rb create mode 100644 db/migrate/20190531011258_create_school_daily_active_users.rb diff --git a/app/models/school_daily_active_user.rb b/app/models/school_daily_active_user.rb new file mode 100644 index 00000000..0edd00fa --- /dev/null +++ b/app/models/school_daily_active_user.rb @@ -0,0 +1,3 @@ +class SchoolDailyActiveUser < ActiveRecord::Base + belongs_to :school_daily_report +end \ No newline at end of file diff --git a/app/models/school_daily_report.rb b/app/models/school_daily_report.rb index 494eacfd..6b24d8be 100644 --- a/app/models/school_daily_report.rb +++ b/app/models/school_daily_report.rb @@ -1,3 +1,5 @@ class SchoolDailyReport < ActiveRecord::Base belongs_to :school + + has_many :school_daily_active_users, dependent: :delete_all end \ No newline at end of file diff --git a/app/services/management/school_data_grow_service.rb b/app/services/management/school_data_grow_service.rb index 44fc45e1..7afe87af 100644 --- a/app/services/management/school_data_grow_service.rb +++ b/app/services/management/school_data_grow_service.rb @@ -6,7 +6,7 @@ class Management::SchoolDataGrowService attr_reader :params sort_columns :teacher_increase_count, :student_increase_count, - :course_increase_count, :shixun_increase_count, :active_user_count, + :course_increase_count, :shixun_increase_count, :uniq_active_user_count, :shixun_homework_count, :shixun_evaluate_count, default_by: :teacher_increase_count, default_direction: :desc @@ -27,6 +27,7 @@ class Management::SchoolDataGrowService 'SUM(shixun_increase_count) shixun_increase_count,'\ 'SUM(shixun_homework_count) shixun_homework_count,'\ 'SUM(shixun_evaluate_count) shixun_evaluate_count,'\ + 'COUNT(distinct(au.user_id)) uniq_active_user_count,'\ 'SUM(active_user_count) active_user_count' ) @@ -45,6 +46,7 @@ class Management::SchoolDataGrowService 'SUM(shixun_increase_count) shixun_increase_count,'\ 'SUM(shixun_homework_count) shixun_homework_count,'\ 'SUM(shixun_evaluate_count) shixun_evaluate_count,'\ + 'COUNT(distinct(au.user_id)) uniq_active_user_count,'\ 'SUM(active_user_count) active_user_count' ).first end @@ -60,6 +62,7 @@ class Management::SchoolDataGrowService end reports = School.joins("LEFT JOIN school_daily_reports sdr ON sdr.school_id = schools.id AND #{date_condition}") + reports = reports.joins("LEFT JOIN school_daily_active_users au ON au.school_daily_report_id = sdr.id") keyword = params[:keyword].try(:to_s).try(:strip) if keyword.present? diff --git a/app/tasks/statistic_school_daily_report_task.rb b/app/tasks/statistic_school_daily_report_task.rb index 440d4a97..8e5103a3 100644 --- a/app/tasks/statistic_school_daily_report_task.rb +++ b/app/tasks/statistic_school_daily_report_task.rb @@ -9,7 +9,9 @@ class StatisticSchoolDailyReportTask student_count = users.where(created_on: yesterday, user_extensions: { identity: User::STUDENT }).count # 活跃用户 - active_user_count = users.where(last_login_on: yesterday).count + active_user_ids = users.where(last_login_on: yesterday).pluck(:id) + active_user_count = active_user_ids.size + # 新增课堂 course_count = school.courses.where(created_at: yesterday).count @@ -38,7 +40,10 @@ class StatisticSchoolDailyReportTask shixun_homework_count: shixun_homework_count, shixun_evaluate_count: shixun_evaluate_count, shixun_increase_count: shixun_count, active_user_count: active_user_count, date: current_date } - SchoolDailyReport.create!(create_params) + report = SchoolDailyReport.create!(create_params) + values = '(' + active_user_ids.join(", #{report.id}),(") + ", #{report.id})" + user_sql = "INSERT INTO school_daily_active_users(user_id, school_daily_report_id) VALUES#{values}" + SchoolDailyActiveUser.connection.execute(user_sql) end end diff --git a/app/views/managements/schools/_data_grow_list.html.erb b/app/views/managements/schools/_data_grow_list.html.erb index 51371f4e..c69ca60b 100644 --- a/app/views/managements/schools/_data_grow_list.html.erb +++ b/app/views/managements/schools/_data_grow_list.html.erb @@ -12,7 +12,9 @@ 新增实训<%= @grow_summary.shixun_increase_count || 0 %>个, 新增实训作业<%= @grow_summary.shixun_homework_count || 0 %>个, 新增实训评测<%= @grow_summary.shixun_evaluate_count || 0 %>个, - 活跃用户<%= @grow_summary.active_user_count || 0 %>个 + 活跃用户 + <%= @grow_summary.uniq_active_user_count.to_i.zero? ? @grow_summary.active_user_count.to_i : @grow_summary.uniq_active_user_count.to_i %> + 个 @@ -27,7 +29,7 @@ - + @@ -42,7 +44,7 @@ - + <% end %> diff --git a/db/migrate/20190531011258_create_school_daily_active_users.rb b/db/migrate/20190531011258_create_school_daily_active_users.rb new file mode 100644 index 00000000..e03ef5e9 --- /dev/null +++ b/db/migrate/20190531011258_create_school_daily_active_users.rb @@ -0,0 +1,10 @@ +class CreateSchoolDailyActiveUsers < ActiveRecord::Migration + def change + create_table :school_daily_active_users do |t| + t.integer :school_daily_report_id + t.integer :user_id + end + + add_index :school_daily_active_users, :school_daily_report_id + end +end From da6cdb5f58ef886b0f908d18582419ac63c943e8 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 31 May 2019 10:19:46 +0800 Subject: [PATCH 07/16] fix school daily report task --- app/tasks/statistic_school_daily_report_task.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/tasks/statistic_school_daily_report_task.rb b/app/tasks/statistic_school_daily_report_task.rb index 8e5103a3..8a038718 100644 --- a/app/tasks/statistic_school_daily_report_task.rb +++ b/app/tasks/statistic_school_daily_report_task.rb @@ -41,9 +41,12 @@ class StatisticSchoolDailyReportTask shixun_increase_count: shixun_count, active_user_count: active_user_count, date: current_date } report = SchoolDailyReport.create!(create_params) - values = '(' + active_user_ids.join(", #{report.id}),(") + ", #{report.id})" - user_sql = "INSERT INTO school_daily_active_users(user_id, school_daily_report_id) VALUES#{values}" - SchoolDailyActiveUser.connection.execute(user_sql) + + if active_user_ids.present? + values = '(' + active_user_ids.join(", #{report.id}),(") + ", #{report.id})" + user_sql = "INSERT INTO school_daily_active_users(user_id, school_daily_report_id) VALUES#{values}" + SchoolDailyActiveUser.connection.execute(user_sql) + end end end From c164b299c9b89dcdb00f8a16883afeb28d5449a5 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 31 May 2019 11:18:27 +0800 Subject: [PATCH 08/16] VNCDisplay --- public/react/package.json | 1 + .../react/src/context/TPIContextProvider.js | 2 +- public/react/src/modules/page/MainContent.js | 8 +- public/react/src/modules/page/VNCDisplay.js | 154 ++++++++++++++++++ 4 files changed, 162 insertions(+), 3 deletions(-) create mode 100644 public/react/src/modules/page/VNCDisplay.js diff --git a/public/react/package.json b/public/react/package.json index 107f53c9..a6ac3da8 100644 --- a/public/react/package.json +++ b/public/react/package.json @@ -3,6 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { + "@novnc/novnc": "^1.1.0", "antd": "^3.6.5", "autoprefixer": "7.1.6", "axios": "^0.18.0", diff --git a/public/react/src/context/TPIContextProvider.js b/public/react/src/context/TPIContextProvider.js index 9beea340..75d6b0e2 100644 --- a/public/react/src/context/TPIContextProvider.js +++ b/public/react/src/context/TPIContextProvider.js @@ -426,7 +426,7 @@ pop_box_new(htmlvalue, 480, 182); // const response = {} // response.data = {"tpm_modified":false,"tpm_cases_modified":false,"hide_code":false,"forbid_copy":false,"output_sets":{"test_sets":"{\"is_public\":1,\"result\":null,\"actual_output\":null,\"compile_success\":null,\"input\":\"9\",\"output\":\"3\\r\\n\"},{\"is_public\":1,\"result\":null,\"actual_output\":null,\"compile_success\":null,\"input\":\"110.25\",\"output\":\"10.5\\r\\n\"},{\"is_public\":0,\"result\":null,\"actual_output\":null,\"compile_success\":null,\"input\":\"-100\",\"output\":\"\\u65e0\\u7b97\\u672f\\u5e73\\u65b9\\u6839\\r\\n\"}","had_test_count":0,"test_sets_count":3,"had_passed_testsests_error_count":0},"latest_output":null,"mirror_name":["C/C++"],"multi_webssh":false,"has_answer":true,"st":0,"discusses_count":8,"game_count":3,"myshixun":{"id":140292,"shixun_id":49,"identifier":"ihprfcq2ta","gpid":156599,"status":0,"user_id":116,"commit_id":"5955e66e34b3b70913b4cb2f62ec5d84cdbe26c9","modify_time":"2017-10-13T15:14:34+08:00","reset_time":"2017-10-13T15:14:34+08:00","system_tip":false},"challenge":{"id":81,"subject":"\u6c42\u4e00\u4e2a\u6570\u7684\u7b97\u672f\u5e73\u65b9\u6839","position":2,"shixun_id":49,"st":0,"score":100,"path":"src/step2/SquareRoot.cpp","task_pass":"[TOC]\r\n\r\n---\r\n\r\n####\u4efb\u52a1\u63cf\u8ff0\r\n\u672c\u5173\u4efb\u52a1\u662f\u901a\u8fc7\u8c03\u7528`sqrt`\u51fd\u6570\u6765\u5b9a\u4e49\u4e00\u4e2a\u6c42\u7b97\u672f\u5e73\u65b9\u6839\u7684\u51fd\u6570\u5e76\u4ee5\u6b64\u6765\u8ba1\u7b97\u4e00\u4e2a\u6570\u7684\u7b97\u672f\u5e73\u65b9\u6839\u3002\r\n\r\n####\u76f8\u5173\u77e5\u8bc6\r\n\u5982\u679c\u4e00\u4e2a\u975e\u8d1f\u6570`x`\u7684\u5e73\u65b9\u7b49\u4e8e`a`\uff0c\u5373`$$x^2 = a$$`\uff0c`(a \u2265 0)`\uff0c\u90a3\u4e48\u8fd9\u4e2a\u975e\u8d1f\u6570`x`\u53eb\u505a`a`\u7684\u7b97\u672f\u5e73\u65b9\u6839\u3002`a`\u7684\u7b97\u672f\u5e73\u65b9\u6839\u8bb0\u4e3a`$$\\sqrt{a}$$`\uff0c\u8bfb\u4f5c`\u6839\u53f7a`\uff0c`a`\u53eb\u505a\u88ab\u5f00\u65b9\u6570\u3002\r\n\r\nC++\u4e2d\uff0c\u53ef\u4ee5\u8c03\u7528\u5e93\u51fd\u6570`sqrt()`\u6765\u6c42\u4e00\u4e2a\u6570\u7684\u7b97\u672f\u5e73\u65b9\u6839\u3002\r\n\r\n####\u7f16\u7a0b\u8981\u6c42\r\n\u672c\u5173\u7684\u7f16\u7a0b\u4efb\u52a1\u662f\u901a\u8fc7\u8c03\u7528`sqrt()`\u51fd\u6570\u6765\u8865\u5168`step2/SquareRoot.cpp`\u6587\u4ef6\u4e2d\u7684`SquareRoot(float n)`\u51fd\u6570\uff0c\u4ee5\u5b9e\u73b0\u8ba1\u7b97\u4e00\u4e2a\u6570\u7684\u7b97\u672f\u5e73\u65b9\u6839\u7684\u8981\u6c42\u3002\r\n\r\n\u6ce8\u610f\uff1a\r\n* \u5982\u679c\u8f93\u5165\u7684\u6570\u6ca1\u6709\u7b97\u6570\u5e73\u65b9\u6839\uff0c\u8fd4\u56de`-1`\u3002\r\n* \u5177\u4f53\u8bf7\u53c2\u89c1\u540e\u7eed\u6d4b\u8bd5\u6837\u4f8b\u3002\r\n\r\n\u672c\u5173\u6d89\u53ca\u7684\u4ee3\u7801\u6587\u4ef6`step2/SquareRoot.cpp`\u4e2d\u7684`SquareRoot`\u51fd\u6570\u7684\u4ee3\u7801\u6846\u67b6\u5982\u4e0b\uff1a\r\n\r\n```cpp\r\n#include \r\n\r\n// \u6c42n\u7684\u7b97\u672f\u5e73\u65b9\u6839\r\ndouble SquareRoot(float n)\r\n{\r\n // \u8bf7\u5728\u6b64\u6dfb\u52a0\u4ee3\u7801\uff0c\u8865\u5168\u51fd\u6570SquareRoot\r\n /********** Begin *********/\r\n\r\n\r\n /********** End **********/\r\n}\r\n```\r\n\r\n####\u6d4b\u8bd5\u8bf4\u660e\r\n\u672c\u5173\u7684\u6d4b\u8bd5\u6587\u4ef6\u662f`step2/SquareRootTest.cpp`\uff0c\u6d4b\u8bd5\u8fc7\u7a0b\u5982\u4e0b\uff1a\r\n1. \u5e73\u53f0\u7f16\u8bd1`step2/SquareRootTest.cpp`\uff0c\u7136\u540e\u94fe\u63a5\u76f8\u5173\u7a0b\u5e8f\u5e93\u5e76\u751f\u6210`SquareRootTest.exe`\uff1b\r\n2. \u5e73\u53f0\u8fd0\u884c`SquareRootTest.exe`\uff0c\u5e76\u4ee5\u6807\u51c6\u8f93\u5165\u65b9\u5f0f\u63d0\u4f9b\u6d4b\u8bd5\u8f93\u5165\uff1b\r\n3. \u5e73\u53f0\u83b7\u53d6`SquareRootTest.exe`\u7684\u8f93\u51fa\uff0c\u7136\u540e\u5c06\u5176\u4e0e\u9884\u671f\u8f93\u51fa\u5bf9\u6bd4\uff0c\u5982\u679c\u4e00\u81f4\u5219\u6d4b\u8bd5\u901a\u8fc7\uff1b\u5426\u5219\u6d4b\u8bd5\u5931\u8d25\u3002\r\n\r\n\u4ee5\u4e0b\u662f\u5e73\u53f0\u5bf9`step2/SquareRootTest.cpp`\u7684\u6837\u4f8b\u6d4b\u8bd5\u96c6\uff1a\r\n\r\n\u6d4b\u8bd5\u8f93\u5165\uff1a`9`\r\n\u9884\u671f\u8f93\u51fa\uff1a`3`\r\n\r\n\u6d4b\u8bd5\u8f93\u5165\uff1a`110.25`\r\n\u9884\u671f\u8f93\u51fa\uff1a`10.5`\r\n\r\n\u6d4b\u8bd5\u8f93\u5165\uff1a`-8`\r\n\u9884\u671f\u8f93\u51fa\uff1a`-1`\r\n\r\n\u5f00\u59cb\u4f60\u7684\u4efb\u52a1\u5427\uff0c\u795d\u4f60\u6210\u529f\uff01\r\n","modify_time":null,"web_route":null,"answer":null},"game":{"id":448025,"status":0,"myshixun_id":140292,"user_id":116,"final_score":0,"challenge_id":81,"identifier":"gih9uzwn8xfc","answer_open":0,"test_sets_view":false,"cost_time":0,"star":0,"modify_time":null,"open_time":"2019-05-30T11:00:19+08:00","updated_at":"2019-05-30T11:00:19+08:00"},"shixun":{"id":49,"name":"C++\u4e4b\u6574\u6570\u8ba1\u7b97\u57fa\u7840","gpid":2018,"modify_time":"2017-10-13T15:14:34+08:00","reset_time":"2017-10-13T15:14:34+08:00","language":"C++","propaedeutics":"####C++\u53d1\u5c55\u5386\u7a0b\r\nC++\u662f\u4e00\u79cd\u901a\u7528\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u5b83\u4e0d\u4f46\u62e5\u6709\u6570\u636e\u5c01\u88c5\u3001\u6570\u636e\u9690\u85cf\u3001\u7ee7\u627f\u3001\u91cd\u7528\u3001\u91cd\u8f7d\u4ee5\u53ca\u591a\u6001\u7b49\u7279\u6027\uff0c\u8fd8\u652f\u6301\u8fc7\u7a0b\u5316\u7a0b\u5e8f\u8bbe\u8ba1\u3001\u9762\u5411\u5bf9\u8c61\u7a0b\u5e8f\u8bbe\u8ba1\u3001\u6cdb\u578b\u7a0b\u5e8f\u8bbe\u8ba1\u7b49\u591a\u79cd\u7a0b\u5e8f\u8bbe\u8ba1\u98ce\u683c\uff0c\u540c\u65f6\u8fd8\u63d0\u4f9b\u4e86\u5e95\u5c42\u5185\u5b58\u64cd\u4f5c\u7684\u529f\u80fd\u3002\u5176\u8bbe\u8ba1\u4eae\u70b9\u5728\u4e8e\u4f7f\u7528\u6027\u80fd\uff0c\u6548\u7387\u548c\u7075\u6d3b\u6027\uff0c\u662f\u8fc4\u4eca\u4e3a\u6b62\u6700\u53d7\u5e7f\u5927\u7a0b\u5e8f\u5458\u6b22\u8fce\u7684\u7f16\u7a0b\u8bed\u8a00\u4e4b\u4e00\u3002\r\n\r\n1979\u5e74\uff0c\u4e39\u9ea6\u8ba1\u7b97\u673a\u79d1\u5b66\u5bb6Bjarne Stroustrup\u535a\u58eb\u5728\u7f8e\u56fdAT&T\u8d1d\u5c14\u5b9e\u9a8c\u5ba4\u5f00\u59cb\u4e86\u4ece\u4e8b\u5c06C\u6539\u826f\u4e3a\u5e26\u7c7b\u7684C\uff08C with classes\uff09\u7684\u5de5\u4f5c\u30021983\u5e74\u8be5\u8bed\u8a00\u88ab\u6b63\u5f0f\u547d\u540d\u4e3aC++\uff0c\u5b83\u7684\u547d\u540d\u6765\u6e90\u4e8eC\u8bed\u8a00\u4e2d\u7684\u201c++\u201d\u8fd0\u7b97\u7b26\uff0c\u8fd9\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u547d\u540d\u7ea6\u5b9a\uff0c\u5374\u5145\u5206\u5c55\u793a\u4e86\u5176\u4eceC\u8bed\u8a00\u6539\u8fdb\u7684\u5386\u53f2\uff0c\u66f4\u5f70\u663e\u4e86\u4e00\u79cd\u66f4\u52a0\u5f3a\u5927\u7684\u8ba1\u7b97\u673a\u7f16\u7a0b\u8bed\u8a00\u3002\r\n![](/attachments/download/169261)\r\n\r\nStroustrup\u535a\u58eb\u521b\u9020C++\u7684\u52a8\u673a\u4e3b\u8981\u6765\u6e90\u4e8e\u4ed6\u5728\u535a\u58eb\u671f\u95f4\u7684\u7f16\u7a0b\u7ecf\u9a8c\uff0c\u5c3d\u7ba1\u4ed6\u4f7f\u7528\u8fc7Simula\u548cALGOL\uff0c\u4e5f\u63a5\u89e6\u8fc7C\uff0c\u4f46\u4ed6\u7684\u521d\u8877\u662f\u9700\u8981\u4e00\u95e8\u7f16\u7a0b\u7b80\u5355\u3001\u6b63\u786e\u53ef\u9760\u3001\u9ad8\u6548\u8fd0\u884c\u4e14\u53ef\u79fb\u690d\u7684\u8bed\u8a00\uff0c\u56e0\u6b64\uff0c\u901a\u7528\u6027\u5f3a\u3001\u5feb\u901f\u3001\u4fbf\u643a\u4e14\u5e7f\u6cdb\u4f7f\u7528\u7684C\u8bed\u8a00\u88ab\u9009\u4e2d\u3002 \r\n\r\n####C++\u8bed\u8a00\u7279\u6027\r\n* \u652f\u6301\u6570\u636e\u5c01\u88c5\u548c\u6570\u636e\u9690\u85cf\r\nC++\u4e2d\uff0c\u7c7b\u662f\u652f\u6301\u6570\u636e\u5c01\u88c5\u7684\u5de5\u5177\uff0c\u5bf9\u8c61\u5219\u662f\u6570\u636e\u5c01\u88c5\u7684\u5b9e\u73b0\u3002C++\u901a\u8fc7\u65b0\u5efa\u7528\u6237\u5b9a\u4e49\u7c7b\u6765\u652f\u6301\u6570\u636e\u5c01\u88c5\u548c\u6570\u636e\u9690\u85cf\u3002\r\n\r\n* \u652f\u6301\u7ee7\u627f\u548c\u91cd\u7528\r\nC++\u7ee7\u627f\u548c\u91cd\u7528\u7684\u601d\u60f3\u662f\u5728\u73b0\u6709\u7c7b\u7684\u57fa\u7840\u4e0a\u58f0\u660e\u65b0\u7c7b\u578b\u3002\u901a\u8fc7\u7ee7\u627f\u548c\u91cd\u7528\u53ef\u4ee5\u66f4\u6709\u6548\u5730\u7ec4\u7ec7\u7a0b\u5e8f\u7ed3\u6784\uff0c\u660e\u786e\u7c7b\u95f4\u5173\u7cfb\uff0c\u5e76\u5145\u5206\u5229\u7528\u5df2\u6709\u7c7b\u6765\u5b8c\u6210\u66f4\u590d\u6742\u3001\u6df1\u5165\u7684\u5f00\u53d1\u3002\r\n\r\n* \u652f\u6301\u591a\u6001\u6027\r\nC++\u7684\u591a\u6001\u6027\u4e3a\u6bcf\u4e2a\u7c7b\u6307\u5b9a\u4e86\u8868\u73b0\u884c\u4e3a\uff0c\u4f7f\u5f97\u4e00\u4e2a\u5bf9\u8c61\u53ef\u4ee5\u6709\u72ec\u7279\u7684\u8868\u73b0\u65b9\u5f0f\uff0c\u800c\u53e6\u4e00\u4e2a\u5bf9\u8c61\u6709\u53e6\u4e00\u79cd\u8868\u73b0\u65b9\u5f0f\u3002\r\n\r\n####C++\u77e5\u8bc6\u70b9\u9884\u89c8\r\n\u4f5c\u4e3a\u4e00\u95e8\u6bd4C\u66f4\u5f3a\u5927\u7684\u901a\u7528\u7f16\u7a0b\u8bed\u8a00\uff0cC++\u6db5\u76d6\u4e86\u66f4\u4e3a\u4e30\u5bcc\u7684\u77e5\u8bc6\u70b9\uff0c\u5982\uff1a\u57fa\u672c\u6982\u5ff5\uff0c\u8f93\u5165\u548c\u8f93\u51fa\uff0c\u63a7\u5236\u8bed\u53e5\uff0c\u6570\u7ec4\uff0c\u51fd\u6570\uff0c\u6307\u9488\uff0c\u7ed3\u6784\u3001\u8054\u5408\u548c\u679a\u4e3e\uff0c\u94fe\u8868\uff0c\u7c7b\u548c\u5bf9\u8c61\uff0c\u7c7b\u548c\u5bf9\u8c61\u7684\u4f7f\u7528\uff0c\u8fd0\u7b97\u7b26\u91cd\u8f7d\uff0c\u7ee7\u627f\uff0c\u591a\u6001\uff0c\u5f02\u5e38\uff0c\u6a21\u677f\u7b49\u3002\u5177\u4f53\u5982\u4e0b\uff1a\r\n\r\n* \u57fa\u672c\u6982\u5ff5\uff1a\u5b57\u7b26\u96c6\u548c\u5173\u952e\u5b57\u3001\u57fa\u672c\u6570\u636e\u7c7b\u578b\u3001\u5e38\u91cf\u4e0e\u53d8\u91cf\u3001\u7c7b\u578b\u8f6c\u6362\u3001\u8fd0\u7b97\u7b26\u4e0e\u8868\u8fbe\u5f0f\u3002\r\n\r\n* \u8f93\u5165\u548c\u8f93\u51fa\uff1a\u6807\u51c6\u8f93\u5165\u8f93\u51fa\u51fd\u6570\u3001\u683c\u5f0f\u5316\u8f93\u5165\u8f93\u51fa\u51fd\u6570\u3001\u7528\u6d41\u8fdb\u884c\u8f93\u5165/\u8f93\u51fa\u3001\u6d41\u64cd\u7eb5\u7b97\u5b50\u3002\r\n\r\n* \u63a7\u5236\u8bed\u53e5\uff1a\u9009\u62e9\u8bed\u53e5\uff08`if\u3001if-else\u3001switch`\uff09\u3001\u5faa\u73af\u8bed\u53e5\uff08`for\u3001while\u3001do-while`\uff09\u3001\u8df3\u8f6c\u8bed\u53e5\uff08`break\u3001continue\u3001goto`\uff09\u3002\r\n\r\n* \u6570\u7ec4\uff1a\u4e00\u7ef4\u6570\u7ec4\u3001\u4e8c\u7ef4\u6570\u7ec4\u3001\u591a\u7ef4\u6570\u7ec4\u3001\u5b57\u7b26\u4e32\u3002\r\n\r\n* \u51fd\u6570\uff1a\u9884\u5b9a\u4e49\u51fd\u6570\u3001\u51fd\u6570\u7684\u5b9a\u4e49\u548c\u8c03\u7528\u3001\u51fd\u6570\u91cd\u8f7d\u3001\u5b58\u50a8\u7c7b\u522b\u3001\u4f5c\u7528\u57df\u3001\u9012\u5f52\u51fd\u6570\u3001\u9884\u5904\u7406\u6307\u4ee4\u3002\r\n\r\n* \u6307\u9488\uff1a\u6307\u9488\u7684\u5b9a\u4e49\u3001\u6307\u9488\u7684\u8fd0\u7b97\u3001\u6307\u9488\u4e0e\u6570\u7ec4\u3001\u5b57\u7b26\u6307\u9488\u4e0e\u5b57\u7b26\u6570\u7ec4\u3001\u6307\u9488\u4e0e`const`\u9650\u5b9a\u7b26\u3001\u6307\u9488\u4e0e\u5f15\u7528\u3001\u52a8\u6001\u5185\u5b58\u5206\u914d\u3001\u51fd\u6570\u6307\u9488\u3002\r\n\r\n* \u7ed3\u6784\u3001\u8054\u5408\u548c\u679a\u4e3e\uff1a\u7ed3\u6784\u7684\u5b9a\u4e49\u3001\u7ed3\u6784\u4e0e\u51fd\u6570\u3001\u7ed3\u6784\u4e0e\u6570\u7ec4\u3001\u7ed3\u6784\u4e0e\u6307\u9488\u3001\u8054\u5408\u7684\u5b9a\u4e49\u548c\u4f7f\u7528\u3001\u679a\u4e3e\u548c\u679a\u4e3e\u578b\u53d8\u91cf\u7684\u5b9a\u4e49\u3002\r\n\r\n* \u94fe\u8868\uff1a\u5355\u9879\u94fe\u8868\u3001\u53cc\u5411\u94fe\u8868\u3002\r\n\r\n* \u7c7b\u548c\u5bf9\u8c61\uff1a\u7c7b\u548c\u5bf9\u8c61\u7684\u5b9a\u4e49\u3001\u6784\u9020\u51fd\u6570\u3001\u6790\u6784\u51fd\u6570\u3002\r\n\r\n* \u7c7b\u548c\u5bf9\u8c61\u7684\u4f7f\u7528\uff1a\u7c7b\u7684\u590d\u5408\u3001`this`\u6307\u9488\u3001`const`\u7279\u6027\u3001\u53cb\u5143\u51fd\u6570\u548c\u53cb\u5143\u7c7b\u3002\r\n\r\n* \u8fd0\u7b97\u7b26\u91cd\u8f7d\uff1a\u8fd0\u7b97\u7b26\u91cd\u8f7d\u7684\u6982\u5ff5\u3001\u8fd0\u7b97\u7b26\u6210\u5458\u51fd\u6570\u4e0e\u53cb\u5143\u51fd\u6570\u3001\u5355\u76ee\u8fd0\u7b97\u7b26\u91cd\u8f7d\u3001\u91cd\u8f7d\u6d41\u63d2\u5165\u548c\u6d41\u63d0\u53d6\u8fd0\u7b97\u7b26\u3001\u53cc\u76ee\u8fd0\u7b97\u7b26\u91cd\u8f7d\u3001\u8d4b\u503c\u8fd0\u7b97\u7b26\u91cd\u8f7d\u3001\u7c7b\u578b\u4e4b\u95f4\u7684\u8f6c\u6362\u3002\r\n\r\n* \u7ee7\u627f\uff1a\u7ee7\u627f\u7684\u5b9a\u4e49\u3001\u7c7b\u6307\u9488\u3001\u591a\u91cd\u7ee7\u627f\u3002\r\n\r\n* \u591a\u6001\uff1a\u865a\u51fd\u6570\u3001\u62bd\u8c61\u57fa\u7c7b\u548c\u7eaf\u865a\u51fd\u6570\u3001\u865a\u6790\u6784\u51fd\u6570\u3002\r\n\r\n* \u5f02\u5e38\uff1a\u5f02\u5e38\u7684\u629b\u51fa\u548c\u4f20\u64ad\u3001\u5f02\u5e38\u7684\u6355\u83b7\u548c\u5904\u7406\u3002\r\n\r\n* \u6a21\u677f\uff1a\u51fd\u6570\u6a21\u677f\u3001\u7c7b\u6a21\u677f\u3002\r\n\r\n####C++\u4e0e\u5176\u4ed6\u7f16\u7a0b\u8bed\u8a00\u7684\u5bf9\u6bd4\r\nC++\u8bed\u8a00\u4e0e\u5176\u4ed6\u4e3b\u6d41\u7f16\u7a0b\u8bed\u8a00\u7684\u5bf9\u6bd4\u5982\u4e0b\uff1a\r\n![](/attachments/download/169262)\r\n\r\n![](/attachments/download/169266)\r\n\u5f53\u7136\uff0c\u4e0a\u8ff0\u56fe\u8868\u5217\u51fa\u7684\u7f16\u7a0b\u8bed\u8a00\u4e00\u76f4\u5904\u4e8e\u53d1\u5c55\u548c\u53d8\u5316\u4e2d\uff0c\u5176\u4e2d\u7684\u5bf9\u6bd4\u4ec5\u4f9b\u53c2\u8003\u3002\u6211\u4eec\u5728\u9009\u62e9\u4e00\u79cd\u5f00\u53d1\u8bed\u8a00\u65f6\uff0c\u4e0d\u4ec5\u8981\u8003\u8651\u8bed\u8a00\u672c\u8eab\u7684\u7279\u6027\uff0c\u5f88\u591a\u65f6\u5019\u8fd8\u9700\u8981\u8003\u8651\u5f00\u53d1\u56e2\u961f\u7684\u7279\u70b9\uff0c\u5df2\u6709\u8f6f\u4ef6\u8d44\u4ea7\u7684\u7f16\u7a0b\u8bed\u8a00\u548c\u67b6\u6784\uff0c\u5f53\u5730\u7a0b\u5e8f\u5458\u4eba\u624d\u7684\u5206\u5e03\u7279\u70b9\u7b49\u5404\u79cd\u56e0\u7d20\u3002\r\n\r\n####\u53c2\u8003\u6587\u732e\r\n* \u738b\u633a\u3001\u5468\u4f1a\u5e73\u3001\u8d3e\u4e3d\u4e3d\u3001\u5f90\u9521\u5c71\u8457\uff0cC++\u7a0b\u5e8f\u8bbe\u8ba1\uff08\u7b2c3\u7248\uff09\uff0c\u6e05\u534e\u5927\u5b66\u51fa\u7248\u793e\uff0c2015\u5e742\u6708\u7b2c3\u7248\r\n* \u8c2d\u6d69\u5f3a\u8457\uff0cC++\u9762\u5411\u5bf9\u8c61\u7a0b\u5e8f\u8bbe\u8ba1\uff08\u7b2c2\u7248\uff09\uff0c\u6e05\u534e\u5927\u5b66\u51fa\u7248\u793e\uff0c2014\u5e747\u6708\u7b2c2\u7248\r\n* Wikipeida, C++, https://en.wikipedia.org/wiki/C%2B%2B\r\n* \u767e\u5ea6\u767e\u79d1, C++, http://baike.baidu.com/item/C++","status":2,"identifier":"nf9ja46l","test_set_permission":true,"hide_code":false,"forbid_copy":false,"hidden":false,"webssh":0,"user_id":6,"code_hidden":false,"task_pass":false,"exec_time":40,"multi_webssh":false,"vnc":false},"record":null,"grade":50,"prev_game":"25razqibyps6","next_game":"p9ea4h8zx7fg","username":"\u77f3\u5934","image_url":"avatars/User/b","user_url":"/users/shitou","praise_count":0,"user_praise":false,"time_limit":40,"tomcat_url":"http://10.9.63.225","is_teacher":false,"power":1,"myshixun_manager":true,"vnc":false} // response.data.shixun.vnc = true - // response.data.vnc_url = 'http://www.baidu.com' + // response.data.vnc_url = 'http://117.50.12.63:43149/vnc_lite.html?password=headless' // response.data.shixun.zip_path = 'asdfasdfasfd' // this._handleResponseData(response.data) // return; diff --git a/public/react/src/modules/page/MainContent.js b/public/react/src/modules/page/MainContent.js index abe0f7cf..a0ac70f1 100644 --- a/public/react/src/modules/page/MainContent.js +++ b/public/react/src/modules/page/MainContent.js @@ -13,7 +13,7 @@ import ChooseEvaluateView from './main/ChooseEvaluateView' import { CircularProgress } from 'material-ui/Progress'; import Button from 'material-ui/Button'; - +import VNCDisplay from './VNCDisplay' import './tpiPage.css'; import './tpiPageForMobile.css'; const $ = window.$; @@ -79,7 +79,11 @@ class MainContent extends Component { background: #fff; } `} - { showIframeContent ? : + {/* */} + { showIframeContent && vnc_url ? + : {/* 旧版本、评测等待提示--更新提示块*/} {/*
diff --git a/public/react/src/modules/page/VNCDisplay.js b/public/react/src/modules/page/VNCDisplay.js new file mode 100644 index 00000000..6b4b0323 --- /dev/null +++ b/public/react/src/modules/page/VNCDisplay.js @@ -0,0 +1,154 @@ +import React, { Component } from 'react'; + +import RFB from '@novnc/novnc/lib/rfb.js'; + +const $ = window.$; +// const showIframeContent = window.location.search.indexOf('vnc=1') != -1; +class VNCDisplay extends Component { + componentDidMount() { + console.log(RFB) + + let rfb; + let desktopName; + // When this function is called we have + // successfully connected to a server + function connectedToServer(e) { + status("Connected to " + desktopName); + } + // This function is called when we are disconnected + function disconnectedFromServer(e) { + if (e.detail.clean) { + status("Disconnected"); + } else { + status("Something went wrong, connection is closed"); + } + } + // When this function is called, the server requires + // credentials to authenticate + function credentialsAreRequired(e) { + const password = prompt("Password Required:"); + rfb.sendCredentials({ password: password }); + } + // When this function is called we have received + // a desktop name from the server + function updateDesktopName(e) { + desktopName = e.detail.name; + } + // Since most operating systems will catch Ctrl+Alt+Del + // before they get a chance to be intercepted by the browser, + // we provide a way to emulate this key sequence. + function sendCtrlAltDel() { + rfb.sendCtrlAltDel(); + return false; + } + // Show a status text in the top bar + function status(text) { + document.getElementById('status').textContent = text; + } + // This function extracts the value of one variable from the + // query string. If the variable isn't defined in the URL + // it returns the default value instead. + function readQueryVariable(name, defaultValue) { + // A URL with a query parameter can look like this: + // https://www.example.com?myqueryparam=myvalue + // + // Note that we use location.href instead of location.search + // because Firefox < 53 has a bug w.r.t location.search + const re = new RegExp('.*[?&]' + name + '=([^&#]*)'), + match = document.location.href.match(re); + if (typeof defaultValue === 'undefined') { defaultValue = null; } + if (match) { + // We have to decode the URL since want the cleartext value + return decodeURIComponent(match[1]); + } + return defaultValue; + } + document.getElementById('sendCtrlAltDelButton') + .onclick = sendCtrlAltDel; + // Read parameters specified in the URL query string + // By default, use the host and port of server that served this file + + // const host = readQueryVariable('host', window.location.hostname); + // let port = readQueryVariable('port', window.location.port); + // const password = readQueryVariable('password', ''); + + const { vnc_url } = this.props; + // http://117.50.12.63:43149/vnc_lite.html?password=headless + let _ar1 = vnc_url.split('/'); + let ipAndPort = _ar1[2].split(':') + let passwordAr = _ar1[3].split('password=') + const host = ipAndPort[0] + let port = ipAndPort[1] + const password = passwordAr[1].split('&')[0] + + const path = readQueryVariable('path', 'websockify'); + // | | | | | | + // | | | Connect | | | + // v v v v v v + status("Connecting"); + // Build the websocket URL used to connect + let url; + if (window.location.protocol === "https:") { + url = 'wss'; + } else { + url = 'ws'; + } + url += '://' + host; + if(port) { + url += ':' + port; + } + url += '/' + path; + // Creating a new RFB object will start a new connection + rfb = new RFB(document.getElementById('screen'), url, + { credentials: { password: password } }); + // Add listeners to important events from the RFB module + rfb.addEventListener("connect", connectedToServer); + rfb.addEventListener("disconnect", disconnectedFromServer); + rfb.addEventListener("credentialsrequired", credentialsAreRequired); + rfb.addEventListener("desktopname", updateDesktopName); + // Set parameters that can be changed on an active connection + rfb.viewOnly = readQueryVariable('view_only', false); + rfb.scaleViewport = readQueryVariable('scale', false); + } + + render() { + const { challenge, vnc_url } = this.props + + + return ( +
+ +
+
Loading
+
Send CtrlAltDel
+
+
+
+ ); + } +} + +export default VNCDisplay; From 939b575871621a308822a573b5e62c594b0f328a Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 31 May 2019 11:24:47 +0800 Subject: [PATCH 09/16] b --- app/views/common/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/common/index.html.erb b/app/views/common/index.html.erb index 35c63ca6..5f0516c8 100644 --- a/app/views/common/index.html.erb +++ b/app/views/common/index.html.erb @@ -1 +1 @@ -Educoder
\ No newline at end of file +Educoder
\ No newline at end of file From 1ca7b99e7b103a0d64718e8f53bf5295d08d72a3 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 31 May 2019 12:09:57 +0800 Subject: [PATCH 10/16] http --- public/react/src/modules/page/VNCDisplay.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/react/src/modules/page/VNCDisplay.js b/public/react/src/modules/page/VNCDisplay.js index 6b4b0323..e6dff2f4 100644 --- a/public/react/src/modules/page/VNCDisplay.js +++ b/public/react/src/modules/page/VNCDisplay.js @@ -88,11 +88,11 @@ class VNCDisplay extends Component { status("Connecting"); // Build the websocket URL used to connect let url; - if (window.location.protocol === "https:") { - url = 'wss'; - } else { + // if (window.location.protocol === "https:") { + // url = 'wss'; + // } else { url = 'ws'; - } + // } url += '://' + host; if(port) { url += ':' + port; From 57171297c1eec4721dbfd1eb34b2fb38f1f0fe0e Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 31 May 2019 12:13:24 +0800 Subject: [PATCH 11/16] b --- app/views/common/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/common/index.html.erb b/app/views/common/index.html.erb index 5f0516c8..e833bafa 100644 --- a/app/views/common/index.html.erb +++ b/app/views/common/index.html.erb @@ -1 +1 @@ -Educoder
\ No newline at end of file +Educoder
\ No newline at end of file From 1fc9ff448f6f6b4e699007a2fbf74afe6b9cd427 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 31 May 2019 14:16:14 +0800 Subject: [PATCH 12/16] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/cnmoocs_service.rb | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index 72318905..bce54650 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -3,60 +3,49 @@ class CnmoocsService include GamesHelper def get_resources_data params - page = params[:pageNo].to_i - limit = params[:pageSize] || 16 - offset = page * limit.to_i + resources = [] if params[:level].to_s == "1" subjects = Subject.find_by_sql("SELECT subjects.id, subjects.name, subjects.status, COUNT(myshixuns.id) AS myshixun_member_count FROM myshixuns, stage_shixuns, subjects WHERE myshixuns.shixun_id = stage_shixuns.shixun_id AND stage_shixuns.subject_id = subjects.id AND `subjects`.`hidden` = 0 AND `subjects`.`status` = 2 - GROUP BY subjects.id ORDER BY myshixun_member_count DESC limit #{offset},#{limit}") + GROUP BY subjects.id ORDER BY myshixun_member_count DESC") + subjects.each do |subject| resources << {resourceId: subject.id, parentId: nil, resourceName: subject.name, accessType: 0, nodeType: 0, resourceType: 2} end - totalCount = Subject.where(:status => 2, :hidden => 0).count - count = subjects.count + elsif params[:level].to_s == "2" return {error: -1, messages: "请求二级及其更高目录时,parentId不能为空"} if params[:parentId].blank? - stages = Stage.where(:subject_id => params[:parentId]).offset(offset).limit(limit) + stages = Stage.where(:subject_id => params[:parentId]) stages.each do |stage| resources << {resourceId: stage.id, parentId: params[:parentId], resourceName: stage.name, accessType: 0, nodeType: 0, resourceType: 2} end - totalCount = Stage.where(:subject_id => params[:parentId]).count - count = stages.count + elsif params[:level].to_s == "3" return {error: -1, messages: "请求二级及其更高目录时,parentId不能为空"} if params[:parentId].blank? shixun_ids = StageShixun.where(:stage_id => params[:parentId]).pluck(:shixun_id) - shixuns = Shixun.where(:id => shixun_ids).offset(offset).limit(limit) + shixuns = Shixun.where(:id => shixun_ids) shixuns.each do |shixun| resources << {resourceId: shixun.id, parentId: params[:parentId], resourceName: shixun.name, accessType: 2, nodeType: 1, resourceType: 1} end - totalCount = Shixun.where(:id => shixun_ids).count - count = shixuns.count + end - pageCount = ((totalCount / limit.to_f) == (totalCount / limit)) ? (totalCount / limit) : ((totalCount / limit) + 1) {error: 0, messages: "请求成功", - page: {count: count, totalCount: totalCount, pageNo: page, pageSize: limit, pageCount: pageCount}, data: {resources: resources} } end def search_resources params - page = params[:pageNo].to_i - limit = params[:pageSize] || 16 - offset = page * limit.to_i shixuns = Shixun.select([:id, :identifier, :name, :myshixuns_count, :averge_star, :challenges_count, :trainee]). where(status: 2, hidden: 0).where("name like ?", "%#{params[:name]}%") - shixun_count = shixuns.count - pageCount = ((shixun_count / limit.to_f) == (shixun_count / limit)) ? (shixun_count / limit) : ((shixun_count / limit) + 1) - shixuns = shixuns.order("myshixuns_count desc").offset(offset).limit(limit) + + shixuns = shixuns.order("myshixuns_count desc") shixun_list = shixun_data shixuns {error: 0, messages: "请求成功", - page: {count: shixuns.count, totalCount: shixun_count, pageNo: page, pageSize: limit, pageCount: pageCount}, data: shixun_list } end From f1c0c402ebc757f82bcc854eafccc47c62e48087 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 31 May 2019 16:49:45 +0800 Subject: [PATCH 13/16] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/zip_service.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/services/zip_service.rb b/app/services/zip_service.rb index 759c7afa..8864999d 100644 --- a/app/services/zip_service.rb +++ b/app/services/zip_service.rb @@ -50,10 +50,11 @@ module ZipService bid_homework_path = [] digests = [] members = exercise.course.members - exercise_users.each do |exercise_user| + exercise_users.each_with_index do |exercise_user, index| member = members.where(:user_id => exercise_user.user_id).first group_name = member.try(:course_group_id).to_i == 0 ? '未分班' : member.course_group.name - export_file_name = "#{group_name}-#{exercise.course_id}-#{exercise.exercise_name}-#{exercise_user.user.user_extensions.student_id}-#{exercise_user.user.show_real_name}" + ".pdf" + # export_file_name = "#{group_name}-#{exercise.course_id}-#{exercise.exercise_name}-#{exercise_user.user.user_extensions.student_id}-#{exercise_user.user.show_real_name}" + ".pdf" + export_file_name = "#{exercise.course_id}-#{index+1}" + ".pdf" out_file = export_user_exercise(exercise, exercise_user, export_file_name) file_name = File::expand_path(out_file) From bf178e6647cc61b38cec807a2205427b3f4445b7 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 31 May 2019 16:52:56 +0800 Subject: [PATCH 14/16] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/zip_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/zip_service.rb b/app/services/zip_service.rb index 8864999d..ef71063e 100644 --- a/app/services/zip_service.rb +++ b/app/services/zip_service.rb @@ -52,7 +52,7 @@ module ZipService members = exercise.course.members exercise_users.each_with_index do |exercise_user, index| member = members.where(:user_id => exercise_user.user_id).first - group_name = member.try(:course_group_id).to_i == 0 ? '未分班' : member.course_group.name + group_name = member.try(:course_group_id).to_i == 0 ? '未分班' : member.course_group.try(:name) # export_file_name = "#{group_name}-#{exercise.course_id}-#{exercise.exercise_name}-#{exercise_user.user.user_extensions.student_id}-#{exercise_user.user.show_real_name}" + ".pdf" export_file_name = "#{exercise.course_id}-#{index+1}" + ".pdf" out_file = export_user_exercise(exercise, exercise_user, export_file_name) From 1f3cf342bad46378897b30f69e4047522aa92550 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 31 May 2019 17:02:09 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/zip_service.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/services/zip_service.rb b/app/services/zip_service.rb index ef71063e..cb278e98 100644 --- a/app/services/zip_service.rb +++ b/app/services/zip_service.rb @@ -50,11 +50,10 @@ module ZipService bid_homework_path = [] digests = [] members = exercise.course.members - exercise_users.each_with_index do |exercise_user, index| + exercise_users.each do |exercise_user| member = members.where(:user_id => exercise_user.user_id).first group_name = member.try(:course_group_id).to_i == 0 ? '未分班' : member.course_group.try(:name) - # export_file_name = "#{group_name}-#{exercise.course_id}-#{exercise.exercise_name}-#{exercise_user.user.user_extensions.student_id}-#{exercise_user.user.show_real_name}" + ".pdf" - export_file_name = "#{exercise.course_id}-#{index+1}" + ".pdf" + export_file_name = "#{group_name}-#{exercise.course_id}-#{exercise.exercise_name}-#{exercise_user.user.user_extensions.student_id}-#{exercise_user.user.show_real_name}" + ".pdf" out_file = export_user_exercise(exercise, exercise_user, export_file_name) file_name = File::expand_path(out_file) From 39c07c7b300fa8bd6a6133765e20141b91da7c35 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 31 May 2019 19:09:12 +0800 Subject: [PATCH 16/16] ttt --- app/api/mobile/apis/cnmooc.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/mobile/apis/cnmooc.rb b/app/api/mobile/apis/cnmooc.rb index 7745cf8e..fb736737 100644 --- a/app/api/mobile/apis/cnmooc.rb +++ b/app/api/mobile/apis/cnmooc.rb @@ -3,7 +3,7 @@ module Mobile module Apis class Cnmooc < Grape::API - before {cnmooc_access_key!} + # before {cnmooc_access_key!} content_type :json, 'application/json;charset=UTF-8' resources :cnmoocs do
<%= sort_tag('新增实训', name: 'shixun_increase_count', path: school_data_grow_managements_path) %> <%= sort_tag('新增实训作业', name: 'shixun_homework_count', path: school_data_grow_managements_path) %> <%= sort_tag('新增实训评测', name: 'shixun_evaluate_count', path: school_data_grow_managements_path) %><%= sort_tag('活跃用户', name: 'active_user_count', path: school_data_grow_managements_path) %><%= sort_tag('活跃用户', name: 'uniq_active_user_count', path: school_data_grow_managements_path) %>
<%= report.shixun_increase_count.to_i %> <%= report.shixun_homework_count.to_i %> <%= report.shixun_evaluate_count.to_i %><%= report.active_user_count.to_i %><%= report.uniq_active_user_count.to_i.zero? ? report.active_user_count.to_i : report.uniq_active_user_count.to_i %>