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 @@ 基础设置
-
+ <%= form_tag(admins_competition_competition_settings_path(unsafe_params), method: :post, class: 'basic-setting-form flex-1', remote: true) do %> +
+
+
+ 竞赛模式 +
+
+ <%= radio_button_tag(:mode, 1, @competition.mode == 1, class: 'form-radio-input') %> + +
+
-
+
+
+
+
+ <%= radio_button_tag(:mode, 2, @competition.mode == 2, class: 'form-radio-input') %> + +
+
+ <%= text_field_tag(:course_id, @competition.competition_mode_setting&.course_id, autocomplete: 'off', class: 'form-control', placeholder: '课堂id') %> +
+
+ +
+
+
+
+ <%= radio_button_tag(:mode, 3, @competition.mode == 3, class: 'form-radio-input') %> + +
+
+ <%= text_field_tag :start_time, @competition.competition_mode_setting&.start_time, autocomplete: 'off', class: 'form-control start-date mx-0 mr-2', placeholder: '统计数据的开始时间' %> + <%= text_field_tag :end_time, @competition.competition_mode_setting&.end_time, autocomplete: 'off', class: 'form-control end-date mx-0', placeholder: '统计数据的结束时间' %> +
+
+ +
+
+
+
+ <%= radio_button_tag(:mode, 4, @competition.mode == 4, class: 'form-radio-input') %> + +
+
+ +
+
+ URL +
+
+ <%= text_field_tag(:identifier, @competition.identifier, autocomplete: 'off', class: 'form-control', placeholder: '请输入url赛事网址') %> +
+
+ +
+
+ 主办方 +
+
+ +
+
+ +
+
+ 奖金 +
+
+
+
¥
+
+ <%= number_field_tag(:bonus, @competition.bonus, autocomplete: 'off', step: 1, min: 0, class: 'form-control', placeholder: '请输入总奖金额') %> +
+
+ +
+
+ 获奖人数 +
+
+ <%= number_field_tag(:bonus, @competition.bonus, autocomplete: 'off', step: 1, min: 0, class: 'form-control', placeholder: '请输入总奖金额') %> +
+
+ +
+
+ 描述 +
+
+ <%= text_area_tag(:description, @competition.description, class: 'form-control', placeholder: '请输入赛事简介') %> +
+
+ +
+
+
+
+ <%= javascript_void_link '保存', class: 'btn btn-primary submit-btn' %> +
+
+
+ + <% end %>
diff --git a/app/views/admins/user_statistics/shared/_list.html.erb b/app/views/admins/user_statistics/shared/_list.html.erb index 44076812d..5759d2f38 100644 --- a/app/views/admins/user_statistics/shared/_list.html.erb +++ b/app/views/admins/user_statistics/shared/_list.html.erb @@ -3,8 +3,8 @@ 姓名 单位部门 - <%= sort_tag('学习关卡数', name: 'study_challenge_count', path: admins_user_statistics_path) %> - <%= sort_tag('完成关卡数', name: 'finish_challenge_count', path: admins_user_statistics_path) %> + 学习关卡数<%#= sort_tag('学习关卡数', name: 'study_challenge_count', path: admins_user_statistics_path) %> + 完成关卡数<%#= sort_tag('完成关卡数', name: 'finish_challenge_count', path: admins_user_statistics_path) %> <%= sort_tag('学习实训数', name: 'study_shixun_count', path: admins_user_statistics_path) %> <%= sort_tag('完成实训数', name: 'finish_shixun_count', path: admins_user_statistics_path) %> 评测次数 diff --git a/app/views/homework_commons/settings.json.jbuilder b/app/views/homework_commons/settings.json.jbuilder index 75604de0c..f62dde87e 100644 --- a/app/views/homework_commons/settings.json.jbuilder +++ b/app/views/homework_commons/settings.json.jbuilder @@ -7,7 +7,7 @@ json.partial! "student_btn_check", locals: {identity: @user_course_identity, hom json.(@homework, :unified_setting, :publish_time, :end_time, :late_penalty, :allow_late, :late_time, :work_public, :score_open, :answer_public) -json.group_settings @course.course_groups do |group| +json.group_settings @course_groups do |group| json.group_id group.id json.group_name group.name json.publish_time group_homework_setting(@homework, group.id).try(:publish_time) diff --git a/db/migrate/20191022075223_migrate_competition_mode_default.rb b/db/migrate/20191022075223_migrate_competition_mode_default.rb new file mode 100644 index 000000000..d61d4aa68 --- /dev/null +++ b/db/migrate/20191022075223_migrate_competition_mode_default.rb @@ -0,0 +1,6 @@ +class MigrateCompetitionModeDefault < ActiveRecord::Migration[5.2] + def change + change_column_default :competitions, :mode, from: 0, to: 1 + Competition.all.update_all(mode: 1) + end +end diff --git a/db/migrate/20191022100044_add_awards_count_to_competition.rb b/db/migrate/20191022100044_add_awards_count_to_competition.rb new file mode 100644 index 000000000..ef6657ae6 --- /dev/null +++ b/db/migrate/20191022100044_add_awards_count_to_competition.rb @@ -0,0 +1,5 @@ +class AddAwardsCountToCompetition < ActiveRecord::Migration[5.2] + def change + add_column :competitions, :awards_count, :integer, default: 0 + end +end diff --git a/public/react/src/modules/courses/busyWork/PublishRightnow.js b/public/react/src/modules/courses/busyWork/PublishRightnow.js index 5b31986ee..ff0a1bbd3 100644 --- a/public/react/src/modules/courses/busyWork/PublishRightnow.js +++ b/public/react/src/modules/courses/busyWork/PublishRightnow.js @@ -46,17 +46,17 @@ class PublishRightnow extends Component{ } - showDialog = () => { + showDialog = (course_groups) => { const isPublish = this.props.isPublish; const isPublishtype = this.props.isPublishtype; const dateFormat = 'YYYY-MM-DD HH:mm'; - let showdatatype=isPublish===false||isPublishtype===undefined; + let showdatatype=isPublish===true&&isPublishtype===undefined; let showdatatypes=isPublish===true||isPublishtype===1; // getNextHalfHourOfMoment const startMoment = (moment()); this.setState({ modalname: showdatatypes ? "立即发布" : "立即截止", - modaltype:1, + modaltype:course_groups.length> 0 ? 1 : 2, visible:showdatatype?false:true, OneSelftype:showdatatype?true:false, Topval:showdatatypes ? "学生将立即收到作业" : "学生将不能再提交作品", @@ -172,7 +172,7 @@ class PublishRightnow extends Component{ this.setState({ visible : false }) return; } - this.showDialog() + this.showDialog(response.data.course_groups) this.setState({ course_groups: response.data.course_groups, starttimesend:response.data.end_time===undefined||response.data.end_time===null||response.data.end_time===""?undefined:response.data.end_time, @@ -231,7 +231,7 @@ class PublishRightnow extends Component{ typs={this.state.typs} />:""} {/*立即发布*/} - + />:""} { showActionButton && { showdatatypes ? "立即发布" : "立即截止" } } ) diff --git a/public/react/src/modules/courses/coursesPublic/HomeworkModal.js b/public/react/src/modules/courses/coursesPublic/HomeworkModal.js index ee19745c9..69eb937ff 100644 --- a/public/react/src/modules/courses/coursesPublic/HomeworkModal.js +++ b/public/react/src/modules/courses/coursesPublic/HomeworkModal.js @@ -235,10 +235,14 @@ class HomeworkModal extends Component{ @@ -251,7 +255,7 @@ class HomeworkModal extends Component{
  • { if (item.end_time === null) { - if(this.props.starttimesend===undefined){ - item.end_time = moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm"); - }else{ - item.end_time = moment(handleDateString(this.props.starttimesend)).format("YYYY-MM-DD HH:mm"); - } + // if(this.props.starttimesend===undefined){ + // item.end_time = moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm"); + // }else{ + // item.end_time = moment(handleDateString(this.props.starttimesend)).format("YYYY-MM-DD HH:mm"); + // } + item.end_time = moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm"); newarr.push(item) } else { newarr.push(item) @@ -97,11 +98,7 @@ class OneSelfOrderModal extends Component{ let course_groups=this.props.course_groups; course_groups.map((item,key)=>{ if(item.end_time===null){ - if(this.props.starttimesend===undefined){ - item.end_time = moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm"); - }else{ - item.end_time = moment(handleDateString(this.props.starttimesend)).format("YYYY-MM-DD HH:mm"); - } + item.end_time = moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm"); newarr.push(item) }else{ newarr.push(item) @@ -208,7 +205,7 @@ class OneSelfOrderModal extends Component{ if(moment(endtime,"YYYY-MM-DD HH:mm") <= moment(this.props.starttime,"YYYY-MM-DD HH:mm")){ this.setState({ endtimetype:true, - endtimetypevalue:"必须晚于发布时间" + endtimetypevalue:"必须晚于当前时间" }) return } @@ -236,7 +233,7 @@ class OneSelfOrderModal extends Component{ if(moment(items.end_time,"YYYY-MM-DD HH:mm") <= moment(this.props.starttime,"YYYY-MM-DD HH:mm")){ this.setState({ endtimetype:true, - endtimetypevalue:"必须晚于发布时间" + endtimetypevalue:"必须晚于当前时间" }) return } @@ -276,7 +273,7 @@ class OneSelfOrderModal extends Component{ render(){ let {group_ids,endtime,course_groups}=this.state; - // console.log(course_groups) + console.log(this.props.modaltype) let course_groupstype=course_groups===undefined||course_groups.length===0; // TODO course_groups为空时的处理 return( @@ -344,7 +341,7 @@ class OneSelfOrderModal extends Component{ {this.props.starttime===undefined|| this.props.starttime===""?"" - :

    + :

    {/**/} {/*发布时间:*/} {/*{this.props.starttime}*/} @@ -366,16 +363,17 @@ class OneSelfOrderModal extends Component{ onChange={this.onChangeTimeend} className={ this.state.endtimetype===true?"noticeTip":""} /> - {this.state.endtimetype===true?

    {this.state.endtimetypevalue}
    :""} + {/*
    (仅支持半点和整点)
    */} :""} +

    } {/* usingCheckBeforePost 为true的时候 全选所有分班 */}