From 0b587f72174846f5ac31f522582a3fcca6b22c6f Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Sat, 16 Mar 2019 09:11:36 +0800 Subject: [PATCH 01/47] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=AF=84=E6=B5=8B?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 36 +++++++++++++++++-- app/models/game.rb | 1 + app/models/run_code_message.rb | 5 +++ config/routes.rb | 1 + ...20190315093727_create_run_code_messages.rb | 11 ++++++ spec/factories/run_code_messages.rb | 5 +++ spec/models/run_code_message_spec.rb | 5 +++ 7 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 app/models/run_code_message.rb create mode 100644 db/migrate/20190315093727_create_run_code_messages.rb create mode 100644 spec/factories/run_code_messages.rb create mode 100644 spec/models/run_code_message_spec.rb diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index cf7e6ee9..cdc3d682 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -1,10 +1,10 @@ # encoding: utf-8 class MyshixunsController < ApplicationController layout 'base_myshixun' - skip_before_filter :verify_authenticity_token, :only => [:training_task_status, :close_webssh] - before_filter :require_login, :except => [:training_task_status, :close_webssh] + skip_before_filter :verify_authenticity_token, :only => [:training_task_status, :close_webssh, :code_runinng_message] + before_filter :require_login, :except => [:training_task_status, :close_webssh, :code_runinng_message] before_filter :check_authentication, :except => [:training_task_status, :close_webssh, :mul_test_home, :mul_test_user, - :mul_test_myshixun, :mul_test_shixun, :mul_test_start] + :mul_test_myshixun, :mul_test_shixun, :mul_test_start, :code_runinng_message] before_filter :find_myshixun, :only => [:show, :myshixun_reset, :open_webssh, :sync_reset_time, :destroy, :search_file_list, :vnc] DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z) @@ -435,6 +435,36 @@ class MyshixunsController < ApplicationController end + # 代码运行中的信息接口 + def code_runinng_message + begin + jsonTestDetails = JSON.parse(params[:jsonTestDetails]) + game_id = jsonTestDetails['buildID'] + message = jsonTestDetails['textMsg'] + logger.info("##################code_runinng_message:#{jsonTestDetails}") + logger.info("##################buildID: #{game_id}") + logger.info("##################textMsg: #{message}") + if game_id.present? && message.present? + game = Game.find game_id + msg = game.run_code_message + # 只有评测中的game才会创建和更新代码评测中的信息 + if game.status == 1 || game.status == 2 && game.retry_status == 1 + if msg.blank? + RunCodeMessage.create!(:game_id => game_id, :status => 1, :message => message) + else + msg.update_attributes(:status => (msg.status + 1), :message => message) + end + else + # 评测完成,初始化评测信息的状态 + msg.update_attributes(:status => 0, :message => nil) if msg.present? + end + render :json => {:data => "success"} + end + rescue Exception => e + render :json => {:data => "failed"} + end + end + # taskId 即返回的game id # 返回结果:params [:stauts] 0 表示成功,其它则失败 # msg 错误信息 diff --git a/app/models/game.rb b/app/models/game.rb index 9f92d109..47674541 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -13,6 +13,7 @@ class Game < ActiveRecord::Base has_many :challenge_samples has_many :game_codes, :dependent => :destroy has_many :evaluate_records, :dependent => :destroy + has_one :run_code_message, :dependent => :destroy include ApplicationHelper scope :min, lambda { select([:id, :status, :myshixun_id, :user_id, :final_score, :challenge_id, :identifier, diff --git a/app/models/run_code_message.rb b/app/models/run_code_message.rb new file mode 100644 index 00000000..191ead34 --- /dev/null +++ b/app/models/run_code_message.rb @@ -0,0 +1,5 @@ +class RunCodeMessage < ActiveRecord::Base + # attr_accessible :title, :body + belongs_to :game + +end diff --git a/config/routes.rb b/config/routes.rb index 79c46a54..2b8b4b60 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -464,6 +464,7 @@ RedmineApp::Application.routes.draw do ## oauth相关 get 'sigle_mul_test' get 'sigle_update_myshixun' match 'training_task_status', :via => [:get, :post] + match 'code_runinng_message', :via => [:get, :post] end resources :games, :path => "stages" do member do diff --git a/db/migrate/20190315093727_create_run_code_messages.rb b/db/migrate/20190315093727_create_run_code_messages.rb new file mode 100644 index 00000000..bbd91acd --- /dev/null +++ b/db/migrate/20190315093727_create_run_code_messages.rb @@ -0,0 +1,11 @@ +class CreateRunCodeMessages < ActiveRecord::Migration + def change + create_table :run_code_messages do |t| + t.integer :status + t.string :message + t.references :game + t.timestamps + end + end +end +mo \ No newline at end of file diff --git a/spec/factories/run_code_messages.rb b/spec/factories/run_code_messages.rb new file mode 100644 index 00000000..b52afbc3 --- /dev/null +++ b/spec/factories/run_code_messages.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :run_code_message do + + end +end diff --git a/spec/models/run_code_message_spec.rb b/spec/models/run_code_message_spec.rb new file mode 100644 index 00000000..6e5cb831 --- /dev/null +++ b/spec/models/run_code_message_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe RunCodeMessage, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From de2db8ce325ecff741c91ebf927c31ba59f71c3a Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Sat, 16 Mar 2019 09:22:24 +0800 Subject: [PATCH 02/47] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E8=AF=84=E6=B5=8B?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 2537c465..0e7af070 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -113,7 +113,7 @@ class StudentWorkController < ApplicationController pass_consume_time += (game.cost_time / 60.0).to_f end all_time += (game.cost_time / 60.0).to_f - user_total_score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i + user_total_score += game.final_score.to_i <= 0 ? 0 : game.challenge.score.to_i if myshixun.user_id == @work.user.id @game_user_query << [game.id, game.outputs.first.try(:query_index).to_i] end From 0a772dd67b666cb28362bd40076d3566eaa03e9e Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Sat, 16 Mar 2019 09:36:17 +0800 Subject: [PATCH 03/47] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 3 +++ app/services/games_service.rb | 13 ++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index cdc3d682..3b747970 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -567,6 +567,9 @@ class MyshixunsController < ApplicationController :create_pod => timeCost['createPod'], :pod_execute => timeCost['execute'], :test_cases => test_cases_time, :brige => timeCost['evaluateAllTime'], :return_back => return_back_time) end + # 清空代码评测信息 + msg = game.run_code_message + msg.update_column(:status => 0, :message => nil) if msg.present? logger.info("training_task_status start#4**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") render :json => {:data => "success"} rescue Exception => e diff --git a/app/services/games_service.rb b/app/services/games_service.rb index d7b56838..bcb1d61b 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -886,9 +886,16 @@ class GamesService next_game = Game.next_game(shixun.id, game.myshixun_id, game_challenge.position).try(:identifier) output_hash = {:test_sets => test_sets, :had_test_count => test_sets_count, :test_sets_count => test_sets_count, :had_passed_testsests_error_count => had_passed_testsests_error_count} - return {:grade => grade, :gold => score, :experience => experience, :status => game_status, :had_done => had_done, :position => game_challenge.position, - :port => port, :power => power, :record => record, :mirror_name => mirror_name, :picture => picture, :web_route => web_route, :latest_output => latest_output, - :star => game.star, :next_game => next_game, :prev_game => prev_game}.merge(output_hash) + + # 代码评测的信息 + running_code_status = game.run_code_message.try(:status) + running_code_message = game.run_code_message.try(:message) + + return {:grade => grade, :gold => score, :experience => experience, :status => game_status, :had_done => had_done, + :position => game_challenge.position, :port => port, :power => power, :record => record, + :mirror_name => mirror_name, :picture => picture, :web_route => web_route, :latest_output => latest_output, + :star => game.star, :next_game => next_game, :prev_game => prev_game, + :running_code_status => running_code_status, :running_code_message => running_code_message}.merge(output_hash) end # 记录实训花费的时间,前端是通过ent_time - open_time,所以最终只更新open_time即可 From d50a44dad61e694cd9bbe2ec8229e2160e44383f Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Sat, 16 Mar 2019 09:44:49 +0800 Subject: [PATCH 04/47] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20190315093727_create_run_code_messages.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/db/migrate/20190315093727_create_run_code_messages.rb b/db/migrate/20190315093727_create_run_code_messages.rb index bbd91acd..59aea2cc 100644 --- a/db/migrate/20190315093727_create_run_code_messages.rb +++ b/db/migrate/20190315093727_create_run_code_messages.rb @@ -7,5 +7,4 @@ class CreateRunCodeMessages < ActiveRecord::Migration t.timestamps end end -end -mo \ No newline at end of file +end \ No newline at end of file From d8c389757fe306d0e13a2913033beef8d84f6d36 Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Sat, 16 Mar 2019 09:53:40 +0800 Subject: [PATCH 05/47] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index bcb1d61b..cbc736d5 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -793,7 +793,10 @@ class GamesService # 如果没有超时并且正在评测中 # 判断评测中的状态有两种:1、如果之前没有通关的,只需判断status为1即可;如果通过关,则判断game的resubmit_identifier是否更新 if (params[:time_out] == "false") && ((params[:resubmit].blank? && game.status==1) || (params[:resubmit].present? && (params[:resubmit] != resubmit_identifier))) - return + # 代码评测的信息 + running_code_status = game.run_code_message.try(:status) + running_code_message = game.run_code_message.try(:message) + return {:running_code_status => running_code_status, :running_code_message => running_code_message} end Rails.logger.info("##### resubmit_identifier is #{resubmit_identifier}") @@ -887,15 +890,10 @@ class GamesService output_hash = {:test_sets => test_sets, :had_test_count => test_sets_count, :test_sets_count => test_sets_count, :had_passed_testsests_error_count => had_passed_testsests_error_count} - # 代码评测的信息 - running_code_status = game.run_code_message.try(:status) - running_code_message = game.run_code_message.try(:message) - return {:grade => grade, :gold => score, :experience => experience, :status => game_status, :had_done => had_done, :position => game_challenge.position, :port => port, :power => power, :record => record, :mirror_name => mirror_name, :picture => picture, :web_route => web_route, :latest_output => latest_output, - :star => game.star, :next_game => next_game, :prev_game => prev_game, - :running_code_status => running_code_status, :running_code_message => running_code_message}.merge(output_hash) + :star => game.star, :next_game => next_game, :prev_game => prev_game}.merge(output_hash) end # 记录实训花费的时间,前端是通过ent_time - open_time,所以最终只更新open_time即可 From 8b26219beeca31059f6edeab3085fdde58fa1c8e Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Sat, 16 Mar 2019 10:11:53 +0800 Subject: [PATCH 06/47] =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 3b747970..39bf615e 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -438,6 +438,7 @@ class MyshixunsController < ApplicationController # 代码运行中的信息接口 def code_runinng_message begin + logger.info("######################params: #{params}") jsonTestDetails = JSON.parse(params[:jsonTestDetails]) game_id = jsonTestDetails['buildID'] message = jsonTestDetails['textMsg'] From d1f536b19158e3fb90cd0c8cdda311f3f0df4e80 Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Sat, 16 Mar 2019 11:09:05 +0800 Subject: [PATCH 07/47] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 39bf615e..4f04cf68 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -449,6 +449,8 @@ class MyshixunsController < ApplicationController game = Game.find game_id msg = game.run_code_message # 只有评测中的game才会创建和更新代码评测中的信息 + logger.info("##################game: #{game.status}") + logger.info("##################retry_status: #{game.retry_status}") if game.status == 1 || game.status == 2 && game.retry_status == 1 if msg.blank? RunCodeMessage.create!(:game_id => game_id, :status => 1, :message => message) From d1b676e479dbdcba2cc6adbcec4b932b9f45efc7 Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Sat, 16 Mar 2019 11:46:48 +0800 Subject: [PATCH 08/47] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E5=BC=80=E5=A7=8B?= =?UTF-8?q?=E6=B8=85=E7=A9=BA=E4=B9=8B=E5=89=8D=E7=9A=84=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 5 +---- app/services/games_service.rb | 4 +++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 4f04cf68..77f768d1 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -570,13 +570,10 @@ class MyshixunsController < ApplicationController :create_pod => timeCost['createPod'], :pod_execute => timeCost['execute'], :test_cases => test_cases_time, :brige => timeCost['evaluateAllTime'], :return_back => return_back_time) end - # 清空代码评测信息 - msg = game.run_code_message - msg.update_column(:status => 0, :message => nil) if msg.present? logger.info("training_task_status start#4**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") render :json => {:data => "success"} rescue Exception => e - render :json => {:data => "failed"} + render :json => {:data => "failed, errer_message:#{e}"} logger.error("training_task_status error: #{e}") raise ActiveRecord::Rollback end diff --git a/app/services/games_service.rb b/app/services/games_service.rb index cbc736d5..74429880 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -498,7 +498,9 @@ class GamesService # 更新评测次数 game.update_column(:evaluate_count, (game.evaluate_count.to_i + 1)) - + # 清空代码评测信息 + msg = game.run_code_message + msg.update_column(:status => 0, :message => nil) if msg.present? # 更新时间是为了TPM端显示的更新,退出实训及访问实训的时候会更新 myshixun.update_column(:updated_at, Time.now) From 8dc5a6b2dfe1108b4c4d470996a8f5546569da86 Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Sat, 16 Mar 2019 11:56:44 +0800 Subject: [PATCH 09/47] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 74429880..33988146 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -500,7 +500,7 @@ class GamesService game.update_column(:evaluate_count, (game.evaluate_count.to_i + 1)) # 清空代码评测信息 msg = game.run_code_message - msg.update_column(:status => 0, :message => nil) if msg.present? + msg.update_column(:status => 0, :message => "") if msg.present? # 更新时间是为了TPM端显示的更新,退出实训及访问实训的时候会更新 myshixun.update_column(:updated_at, Time.now) From 93ed95b76727284b03144cf30e069328f085d111 Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Sat, 16 Mar 2019 15:08:09 +0800 Subject: [PATCH 10/47] =?UTF-8?q?=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 33988146..7f0e6df4 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -500,7 +500,7 @@ class GamesService game.update_column(:evaluate_count, (game.evaluate_count.to_i + 1)) # 清空代码评测信息 msg = game.run_code_message - msg.update_column(:status => 0, :message => "") if msg.present? + msg.update_attributes(:status => 0, :message => nil) if msg.present? # 更新时间是为了TPM端显示的更新,退出实训及访问实训的时候会更新 myshixun.update_column(:updated_at, Time.now) From 9fee0222ba9dd330efcb35942ff450e71259f39a Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 18 Mar 2019 09:43:22 +0800 Subject: [PATCH 11/47] ecloud auth --- app/controllers/ecloud_controller.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index 89a240c4..a391bcf4 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -17,7 +17,7 @@ require 'digest' class EcloudController < ApplicationController skip_before_filter :verify_authenticity_token - before_filter :check_sign, only: [:ps_new, :ps_update, :bs_new, :bs_update] + # before_filter :check_sign, only: [:ps_new, :ps_update, :bs_new, :bs_update] before_filter :save_para before_filter :user_setup @@ -105,6 +105,8 @@ class EcloudController < ApplicationController des_services = params['services'].select{|s| s['opttype'] == 1} if des_services.present? des_services.each do |ds| + + logger.info("666666#{ecloud.try(:id)}, 55555555#{ds['code']}") esd = EcloudService.where(ecloud_id: ecloud.try(:id), code: ds['code']).first esd.update_attributes!(opttype: ds['opttype'], begintime: ds['begintime'], endtime: ds['endtime']) end @@ -144,10 +146,10 @@ class EcloudController < ApplicationController # end render :json => {result: true, errmsg: ""} - rescue Exception => e - logger.error(e.message) - render :json => {code: 500, msg: "#{e.message}"} - raise ActiveRecord::Rollback + # rescue Exception => e + # logger.error(e.message) + # render :json => {code: 500, msg: "#{e.message}"} + # raise ActiveRecord::Rollback end end end From e7c8ca039fde5d480c772880aa0f5df4ce818956 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 21 Mar 2019 17:54:56 +0800 Subject: [PATCH 12/47] =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA=E7=9A=84?= =?UTF-8?q?=E5=8F=91=E9=80=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 2a4402b7..611b7803 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -54,7 +54,7 @@ class UsersController < ApplicationController accept_api_auth :index, :show, :create, :update, :destroy, :tag_save, :tag_saveEx #william - before_filter :require_login, :only => [:tag_save, :tag_saveEx] + before_filter :require_login, :only => [:tag_save, :tag_saveEx, :search_user_course, :search_user_project] #before_filter :refresh_changests, :only =>[:user_activities,:user_courses,:user_projects,:user_newfeedback] #visitor From bd98acb24e81e2de69df8956016f05f14b0eb64a Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Thu, 21 Mar 2019 17:55:19 +0800 Subject: [PATCH 13/47] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E6=9C=AA=E7=99=BB=E5=BD=95=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=8F=91=E9=80=81=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/poll/student_poll_list.html.erb | 388 ++++++++++----------- app/views/users/_course_boardlist.html.erb | 3 + 2 files changed, 195 insertions(+), 196 deletions(-) diff --git a/app/views/poll/student_poll_list.html.erb b/app/views/poll/student_poll_list.html.erb index d454fba3..2e570bc3 100644 --- a/app/views/poll/student_poll_list.html.erb +++ b/app/views/poll/student_poll_list.html.erb @@ -5,167 +5,163 @@ SearchByName_poll(); } } - - $(function () { - - });
-

- <%= link_to @course.name, course_path(@course),:class => "color-grey-9" %> > <%= link_to "问卷列表", poll_index_path(:course_id => @course.id),:class => "color-grey-9" %> > - #<%= get_poll_index(@poll, @course, @is_teacher) + 1 %> -

-
-

- <% unless @poll.is_public %> - - <% end %> - <%= @poll.polls_name %> +

+ <%= link_to @course.name, course_path(@course),:class => "color-grey-9" %> > <%= link_to "问卷列表", poll_index_path(:course_id => @course.id),:class => "color-grey-9" %> > + #<%= get_poll_index(@poll, @course, @is_teacher) + 1 %>

- <%= link_to "返回", poll_index_path(:course_id => @course.id), :class => "fr font-12 mr15 mt3 color-grey" %> -
-
+
+

+ <% unless @poll.is_public %> + + <% end %> + <%= @poll.polls_name %> +

+ <%= link_to "返回", poll_index_path(:course_id => @course.id), :class => "fr font-12 mr15 mt3 color-grey" %> +
+
  • 答题列表
  • <% if @is_teacher || (@poll.show_result == 1 && @poll.polls_status == 3) %> -
  • - 统计结果 -
  • +
  • + 统计结果 +
  • <% end %> <% if @is_teacher %> -
  • - 问卷内容 -
  • -
  • - 设置 -
  • - <% if @poll.polls_status > 1 %> - <%= link_to "导出统计", export_poll_poll_path(@poll, :course_id => @course.id, :format => 'xls'), :id => "export_poll_work", :class => "fr white-btn orange-btn mt10 ml15" %> - <% end %> - <% if @poll.polls_status < 3 %> - <%= link_to "编辑问卷", edit_poll_path(@poll, :course_id => @course.id), :class => "fr white-btn orange-btn mt10 ml15" %> - <% end %> - <% if @poll.polls_status == 1 || @poll.poll_group_settings.where("publish_time is null or publish_time > '#{Time.now}'").count > 0 %> - <%= link_to '立即发布', publish_notice_poll_path(@poll), :remote => true, :class => "white-btn orange-btn fr ml15 mt10" %> - <% end %> - <% if (@poll.polls_status == 2 && @poll.end_time > Time.now) || @poll.poll_group_settings.where("publish_time < '#{Time.now}' and end_time > '#{Time.now}'").count > 0 %> - <%= link_to '立即截止', end_notice_poll_path(@poll), :remote => true, :class => "white-btn orange-btn fr ml15 mt10" %> - <% end %> - <% if @poll.polls_status == 2 %> - 撤销发布 - <% end %> +
  • + 问卷内容 +
  • +
  • + 设置 +
  • + <% if @poll.polls_status > 1 %> + <%= link_to "导出统计", export_poll_poll_path(@poll, :course_id => @course.id, :format => 'xls'), :id => "export_poll_work", :class => "fr white-btn orange-btn mt10 ml15" %> + <% end %> + <% if @poll.polls_status < 3 %> + <%= link_to "编辑问卷", edit_poll_path(@poll, :course_id => @course.id), :class => "fr white-btn orange-btn mt10 ml15" %> + <% end %> + <% if @poll.polls_status == 1 || @poll.poll_group_settings.where("publish_time is null or publish_time > '#{Time.now}'").count > 0 %> + <%= link_to '立即发布', publish_notice_poll_path(@poll), :remote => true, :class => "white-btn orange-btn fr ml15 mt10" %> + <% end %> + <% if (@poll.polls_status == 2 && @poll.end_time > Time.now) || @poll.poll_group_settings.where("publish_time < '#{Time.now}' and end_time > '#{Time.now}'").count > 0 %> + <%= link_to '立即截止', end_notice_poll_path(@poll), :remote => true, :class => "white-btn orange-btn fr ml15 mt10" %> + <% end %> + <% if @poll.polls_status == 2 %> + 撤销发布 + <% end %> <% else %> -
  • - 查看设置 -
  • - <% if User.current.member_of_course?(@poll.course) %> -

    - <% poll_user = @poll.poll_users.where(:user_id => User.current).first %> - <% member = @poll.course.members.where(:user_id => User.current.id).first %> - <% setting_time = poll_group_setting @poll, member.try(:course_group) %> - <% if poll_user %> - <% if poll_user.commit_status > 0 %> - <%= link_to '查看答题', poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %> - <% elsif setting_time.publish_time < Time.now && setting_time.end_time > Time.now %> - <%= link_to (poll_user.start_at.nil? ? "开始答题" : "继续答题"), poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %> - <% end %> - <% elsif setting_time.publish_time < Time.now && setting_time.end_time > Time.now %> - <%= link_to "开始答题", poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %> - <% end %> -

    - <% end %> +
  • + 查看设置 +
  • + <% if User.current.member_of_course?(@poll.course) %> +

    + <% poll_user = @poll.poll_users.where(:user_id => User.current).first %> + <% member = @poll.course.members.where(:user_id => User.current.id).first %> + <% setting_time = poll_group_setting @poll, member.try(:course_group) %> + <% if poll_user %> + <% if poll_user.commit_status > 0 %> + <%= link_to '查看答题', poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %> + <% elsif setting_time.publish_time < Time.now && setting_time.end_time > Time.now %> + <%= link_to (poll_user.start_at.nil? ? "开始答题" : "继续答题"), poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %> + <% end %> + <% elsif setting_time.publish_time < Time.now && setting_time.end_time > Time.now %> + <%= link_to "开始答题", poll_path(@poll, :user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %> + <% end %> +

    + <% end %> <% end %>
-
+
<% if @is_teacher %> -
-
  • - - <% poll_curr_status = poll_curr_time @poll %> - <% if poll_curr_status[:status] != "" %> - <%= poll_curr_status[:status] %> - <% end %> - - <% if @poll.try(:polls_status) == 1 && @poll.publish_time %> - 将于 <%= format_time(@poll.publish_time).to_s %> 发布 - <% else %> - <%= poll_curr_status[:time] %> - <% end %> -
  • - - -
      +
    • - 答题状态: - - 不限 - - > - - > - + + <% poll_curr_status = poll_curr_time @poll %> + <% if poll_curr_status[:status] != "" %> + <%= poll_curr_status[:status] %> + <% end %> + + <% if @poll.try(:polls_status) == 1 && @poll.publish_time %> + 将于 <%= format_time(@poll.publish_time).to_s %> 发布 + <% else %> + <%= poll_curr_status[:time] %> + <% end %>
    • -
    • - 分班情况: - - 不限 - -
      - <% if @group_teacher %> - <% groups = @course.course_groups.where(:id => @member.teacher_course_groups.pluck(:course_group_id)) %> - <% else %> - <% groups = @course.course_groups %> - <% end %> - <% groups.each do |group| %> - > - - <% end %> - <% if !@group_teacher %> - - - <% end %> + + +
        +
      • + 答题状态: + + 不限 + + /> + + /> + +
      • +
      • + 分班情况: + + 不限 + +
        + <% if @group_teacher %> + <% groups = @course.course_groups.where(:id => @member.teacher_course_groups.pluck(:course_group_id)) %> + <% else %> + <% groups = @course.course_groups %> + <% end %> + <% groups.each do |group| %> + /> + + <% end %> + <% if !@group_teacher %> + + + <% end %> +
        +
      • +
      +
    • +
      +
      + + + × +
      +
    • -
    -
  • -
    -
    - - - × -
    - -
    -
  • -
    + <% elsif User.current.member_of_course?(@poll.course) %> - -
    -

    - <% poll_user = @poll.poll_users.where(:user_id => User.current).first %> - <% if poll_user %> - <% if poll_user.commit_status > 0 %> - 你已提交 - <% else %> - 你未提交 + +

    +

    + <% poll_user = @poll.poll_users.where(:user_id => User.current).first %> + <% if poll_user %> + <% if poll_user.commit_status > 0 %> + 你已提交 + <% else %> + 你未提交 + <% end %> <% end %> - <% end %> -

    +

    -

    - (<%= @has_commit_count %>人已交) - <% if @poll.polls_status == 2 && @poll.end_time > Time.now %> - <% end_time = @poll.end_time.to_time.to_i %> - 答题剩余时间:<%= (end_time - Time.now.to_i) / (24 * 60 * 60) %><%= ((end_time - Time.now.to_i) % (24 * 60 * 60)) / (60 * 60) %>小时<%= (((end_time - Time.now.to_i) % (24 * 60 * 60)) % (60 * 60)) / 60 %> - <% elsif @poll.polls_status == 3 %> - 提交已截止 - <% end %> -

    -
    +

    + (<%= @has_commit_count %>人已交) + <% if @poll.polls_status == 2 && @poll.end_time > Time.now %> + <% end_time = @poll.end_time.to_time.to_i %> + 答题剩余时间:<%= (end_time - Time.now.to_i) / (24 * 60 * 60) %><%= ((end_time - Time.now.to_i) % (24 * 60 * 60)) / (60 * 60) %>小时<%= (((end_time - Time.now.to_i) % (24 * 60 * 60)) % (60 * 60)) / 60 %> + <% elsif @poll.polls_status == 3 %> + 提交已截止 + <% end %> +

    +
    <% end %>
    @@ -196,71 +192,71 @@
    <% @poll.poll_questions.includes(:poll_answers).each_with_index do |poll_question, i| %> -
    -
    -

    - <% if poll_question.try(:is_necessary) == 1 %> - * - <% end %> - 第<%= poll_question.question_number %> - 题:[<%= poll_question.question_type_name %>] - <% if poll_question.question_type == 2 && (poll_question.min_choices != 0 || poll_question.max_choices != 0) %> - 可选 <%= poll_question.min_choices %> - <%= poll_question.max_choices %> 项 - <% end %> -

    -
    -
    <%= poll_question.question_title.html_safe %>
    - <% case poll_question.question_type %> - <% when 1 %> -
    - <% poll_answers = poll_question.poll_answers %> - <% poll_answers.each_with_index do |poll_answer, index| %> -
  • - <% if poll_answer.answer_text != '' %> - - - <% else %> - - - - - - <% end %> -
  • - <% end %> +
    +
    +

    + <% if poll_question.try(:is_necessary) == 1 %> + * + <% end %> + 第<%= poll_question.question_number %> + 题:[<%= poll_question.question_type_name %>] + <% if poll_question.question_type == 2 && (poll_question.min_choices != 0 || poll_question.max_choices != 0) %> + 可选 <%= poll_question.min_choices %> - <%= poll_question.max_choices %> 项 + <% end %> +

    - <% when 2 %> -
    - <% poll_answers = poll_question.poll_answers %> - <% poll_answers.each_with_index do |poll_answer, index| %> -
  • - <% if poll_answer.answer_text != '' %> - - - <% else %> - - - - - +
    <%= poll_question.question_title.html_safe %>
    + <% case poll_question.question_type %> + <% when 1 %> +
    + <% poll_answers = poll_question.poll_answers %> + <% poll_answers.each_with_index do |poll_answer, index| %> +
  • + <% if poll_answer.answer_text != '' %> + + + <% else %> + + + + + + <% end %> +
  • <% end %> - - <% end %> -
    - <% when 3 %> -
    - -
    - <% end %> -
    +
    + <% when 2 %> +
    + <% poll_answers = poll_question.poll_answers %> + <% poll_answers.each_with_index do |poll_answer, index| %> +
  • + <% if poll_answer.answer_text != '' %> + + + <% else %> + + + + + + <% end %> +
  • + <% end %> +
    + <% when 3 %> +
    + +
    + <% end %> +
    <% end %>
    -
    - <%= render :partial => "poll_setting" %> +
    + <%= render :partial => "poll_setting" %> +
    -