diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 22e7636c4..363e5780d 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -1045,7 +1045,7 @@ class HomeworkCommonsController < ApplicationController def end_homework tip_exception("请至少选择一个分班") if params[:group_ids].blank? && @course.course_groups.size != 0 - time = Time.now.strftime("%Y-%m-%d %H:%M:%S") + time = Time.now # 已发布且未截止的作业才能立即截止 @@ -1086,7 +1086,7 @@ class HomeworkCommonsController < ApplicationController homework.end_time = time end - homework_detail_manual.update_attributes!(comment_status: 2) if homework.end_time <= time + # homework_detail_manual.update_attributes!(comment_status: 2) if homework.end_time <= time # 实训作业的作品需要计算是否迟交 if homework.homework_type == "practice" diff --git a/app/queries/optional_item_query.rb b/app/queries/optional_item_query.rb index 54cd0eed0..61ebf8b69 100644 --- a/app/queries/optional_item_query.rb +++ b/app/queries/optional_item_query.rb @@ -22,14 +22,16 @@ class OptionalItemQuery < ApplicationQuery items = ItemBank.where(container_id: hacks.pluck(:id), container_type: "Hack").or(ItemBank.where(id: items.pluck(:id))) end - # 来源 public = source.present? ? source.to_i : 1 - public = public == 2 ? [0, 1] : public - items = items.where(public: public) + if public == 1 + items = items.where(public: 1) + elsif public == 0 + items = items.where(user_id: User.current.id) + end # 难度 - difficulty = difficulty ? difficulty.to_i : 1 - items = items.where(difficulty: difficulty) + diff = difficulty ? difficulty.to_i : 1 + items = items.where(difficulty: diff) items end end \ No newline at end of file diff --git a/app/services/update_homework_publish_setting_service.rb b/app/services/update_homework_publish_setting_service.rb index 61902cd80..431246563 100644 --- a/app/services/update_homework_publish_setting_service.rb +++ b/app/services/update_homework_publish_setting_service.rb @@ -73,9 +73,11 @@ class UpdateHomeworkPublishSettingService < ApplicationService # 作业在"提交中"状态时 else - if homework.end_time > Time.now && homework.unified_setting + # 实训作业截止时间已过也可修改截止时间,其他作业暂不支持修改 + if (homework.homework_type == "practice" || homework.end_time > Time.now) && homework.unified_setting tip_exception("截止时间不能为空") if params[:end_time].blank? - tip_exception("截止时间不能早于当前时间") if params[:end_time].to_time <= Time.now + tip_exception("截止时间必须晚于发布时间") if params[:publish_time].to_time >= homework.publish_time + # tip_exception("截止时间不能早于当前时间") if params[:end_time].to_time <= Time.now tip_exception("截止时间不能晚于课堂结束时间(#{course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if course.end_date.present? && params[:end_time].to_time > course.end_date.end_of_day @@ -93,19 +95,29 @@ class UpdateHomeworkPublishSettingService < ApplicationService # 如果该发布规则 没有已发布的分班则需判断发布时间 tip_exception("发布时间不能早于等于当前时间") if setting[:publish_time].to_time <= Time.now && group_settings.group_published.count == 0 - tip_exception("截止时间不能早于等于当前时间") if setting[:end_time].to_time <= Time.now && group_settings.none_end.count > 0 + # tip_exception("截止时间不能早于等于当前时间") if setting[:end_time].to_time <= Time.now && group_settings.none_end.count > 0 tip_exception("截止时间不能早于发布时间") if setting[:publish_time].to_time > setting[:end_time].to_time tip_exception("截止时间不能晚于课堂结束时间(#{course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if course.end_date.present? && setting[:end_time].to_time > course.end_date.end_of_day group_settings.none_published.update_all(publish_time: setting[:publish_time]) - group_settings.none_end.update_all(end_time: setting[:end_time]) + # 实训作业截止时间已过也可修改截止时间,其他作业暂不支持修改 + if homework.homework_type == "practice" + group_settings.update_all(end_time: setting[:end_time]) + else + group_settings.none_end.update_all(end_time: setting[:end_time]) + end end homework.end_time = homework.max_group_end_time end end + if homework.end_time > Time.now && homework.homework_detail_manual.try(:comment_status) > 1 + homework.homework_detail_manual.update_attributes!(comment_status: 1) + end + homework.save! + UpdateShixunWorkScoreJob.perform_later(homework.id) HomeworkCommonPushNotifyJob.perform_later(homework.id, publish_group_ids) if send_tiding end diff --git a/lib/tasks/homework_publishtime.rake b/lib/tasks/homework_publishtime.rake index a57b97eab..6ba4d7bba 100644 --- a/lib/tasks/homework_publishtime.rake +++ b/lib/tasks/homework_publishtime.rake @@ -66,7 +66,7 @@ namespace :homework_publishtime do .where("homework_type = 4 and end_time <= '#{Time.now}'") homework_commons.each do |homework| # homework_challenge_settings = homework.homework_challenge_settings - homework.homework_detail_manual.update_column("comment_status", 2) + # homework.homework_detail_manual.update_column("comment_status", 2) if homework.allow_late if homework.unified_setting diff --git a/public/react/src/modules/courses/poll/PollDetailTabForthRules.js b/public/react/src/modules/courses/poll/PollDetailTabForthRules.js index 26c641248..884f93b24 100644 --- a/public/react/src/modules/courses/poll/PollDetailTabForthRules.js +++ b/public/react/src/modules/courses/poll/PollDetailTabForthRules.js @@ -463,7 +463,7 @@ class PollDetailTabForthRules extends Component{ disabledTime={disabledDateTime} disabledDate={disabledDate} disabled={ - this.props.isAdmin()===true?this.props.type==="Shixun"?false: + this.props.isAdmin()===true?this.props.type==="Shixun"?!flagPageEdit: this.props.type==="Exercise"||this.props.type==="polls"? rule.e_timeflag === undefined ? rule.publish_time === null ? false : moment(rule.end_time, dataformat) <= moment() ?this.props.isAdmin()?!flagPageEdit: true : !flagPageEdit : rule.e_timeflag == true ? this.props.isAdmin()?!flagPageEdit :true : !flagPageEdit: rule.e_timeflag === undefined ? rule.publish_time === null ? false : moment(rule.end_time, dataformat) <= moment() ? true : !flagPageEdit : rule.e_timeflag == true ? true : !flagPageEdit:true diff --git a/public/react/src/modules/paths/statics/index.js b/public/react/src/modules/paths/statics/index.js index d8e222d02..03a57d665 100644 --- a/public/react/src/modules/paths/statics/index.js +++ b/public/react/src/modules/paths/statics/index.js @@ -64,6 +64,7 @@ const App = (props) => { width:150, dataIndex: 'student_count', align: 'center', + defaultSortOrder: 'descend', sorter: (a, b) => a.student_count - b.student_count, // sorter: (a, b) => a.age - b.age }, @@ -183,6 +184,7 @@ const App = (props) => { align: 'center', with: 130, render: (val) => val + '', + defaultSortOrder: 'descend', sorter: (a, b) => a.passed_games_count - b.passed_games_count }, {