diff --git a/app/assets/javascripts/admins/competition_settings/index.js b/app/assets/javascripts/admins/competition_settings/index.js new file mode 100644 index 000000000..f02f845c4 --- /dev/null +++ b/app/assets/javascripts/admins/competition_settings/index.js @@ -0,0 +1,23 @@ +$(document).on('turbolinks:load', function(){ + if ($('body.admins-competition-settings-index-page').length > 0) { + + var baseOptions = { + autoclose: true, + language: 'zh-CN', + format: 'yyyy-mm-dd', + startDate: '2017-04-01', + endDate: '-1d' + }; + + var defineDateRangeSelect = function(element){ + var options = $.extend({inputs: $(element).find('.start-date, .end-date')}, baseOptions); + $(element).datepicker(options); + + $(element).find('.start-date').datepicker().on('changeDate', function(e){ + $(element).find('.end-date').datepicker('setStartDate', e.date); + }); + }; + + defineDateRangeSelect('.teaching-mode-date'); + } +}); \ No newline at end of file diff --git a/app/assets/stylesheets/admins/competition_settings.scss b/app/assets/stylesheets/admins/competition_settings.scss new file mode 100644 index 000000000..20468aaed --- /dev/null +++ b/app/assets/stylesheets/admins/competition_settings.scss @@ -0,0 +1,21 @@ +.admins-competition-settings-index-page { + .competition-mode-container { + .row { + height: 35px; + } + + .des-row { + height: auto; + } + + .form-control { + font-size: 14px; + } + + //.mode-input { + // input { + // width: 40%; + // } + //} + } +} \ No newline at end of file diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 168d05299..da2b9eb2d 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -439,6 +439,7 @@ class HomeworkCommonsController < ApplicationController def settings @user = current_user @work = @homework.user_work(current_user.id) if @user_course_identity == Course::STUDENT + @course_groups = @course.course_groups.where(id: @course.charge_group_ids(@user)) end def update_settings diff --git a/app/models/competition.rb b/app/models/competition.rb index 8b9d59ed2..708af2556 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -28,9 +28,9 @@ class Competition < ApplicationRecord def mode_type case mode when 1 - "课堂" - when 2 "实训" + when 2 + "课堂" when 3 "教学" when 4 @@ -94,9 +94,9 @@ class Competition < ApplicationRecord GROUP BY competition_stage_id order by competition_stage_id") end - def awards_count - competition_awards.pluck(:num)&.sum > 0 ? competition_awards.pluck(:num)&.sum : 20 - end + # def awards_count + # competition_awards.pluck(:num)&.sum > 0 ? competition_awards.pluck(:num)&.sum : 20 + # end private diff --git a/app/queries/admins/user_statistic_query.rb b/app/queries/admins/user_statistic_query.rb index d05656b3e..9f8fed952 100644 --- a/app/queries/admins/user_statistic_query.rb +++ b/app/queries/admins/user_statistic_query.rb @@ -36,8 +36,8 @@ class Admins::UserStatisticQuery < ApplicationQuery study_myshixun = Myshixun.where(user_id: ids) finish_myshixun = Myshixun.where(user_id: ids, status: 1) - study_challenge = Game.joins(:myshixun).where(myshixuns: { user_id: ids }).where(status: [0, 1, 2]) - finish_challenge = Game.joins(:myshixun).where(myshixuns: { user_id: ids }).where(status: 2) + study_challenge = Game.where(user_id: ids).where(status: [0, 1, 2]) + finish_challenge = Game.where(user_id: ids).where(status: 2) if time_range.present? study_myshixun = study_myshixun.where(updated_at: time_range) @@ -106,12 +106,12 @@ class Admins::UserStatisticQuery < ApplicationQuery when 'finish_challenge_count' then users = if time_range.present? - users.joins('LEFT JOIN myshixuns ON myshixuns.user_id = users.id') - .joins("LEFT JOIN games ON games.myshixun_id = myshixuns.id "\ + users#.joins('LEFT JOIN myshixuns ON myshixuns.user_id = users.id') + .joins("LEFT JOIN games ON games.user_id = users.id "\ "AND games.status = 2 AND games.updated_at BETWEEN '#{time_range.min}' AND '#{time_range.max}'") else - users.joins('LEFT JOIN myshixuns ON myshixuns.user_id = users.id') - .joins("LEFT JOIN games ON games.myshixun_id = myshixuns.id AND games.status = 2") + users#.joins('LEFT JOIN myshixuns ON myshixuns.user_id = users.id') + .joins("LEFT JOIN games ON games.user_id = users.id AND games.status = 2") end users.select("#{base_query_column}, COUNT(*) finish_challenge_count") diff --git a/app/views/admins/competition_settings/index.html.erb b/app/views/admins/competition_settings/index.html.erb index 4f53cb5d3..4c73609e4 100644 --- a/app/views/admins/competition_settings/index.html.erb +++ b/app/views/admins/competition_settings/index.html.erb @@ -10,9 +10,110 @@ 基础设置
+ :
{/**/} {/*发布时间:*/} {/*{this.props.starttime}*/} @@ -366,16 +363,17 @@ class OneSelfOrderModal extends Component{ onChange={this.onChangeTimeend} className={ this.state.endtimetype===true?"noticeTip":""} /> - {this.state.endtimetype===true?