+<% define_admin_breadcrumbs do %>
+ <% add_admin_breadcrumb('数据变化报表', admins_school_statistics_path) %>
+<% end %>
+
+
+
<%= render(partial: 'admins/salesman_channels/shared/list') %>
diff --git a/app/views/admins/salesman_channels/shared/_list.html.erb b/app/views/admins/salesman_channels/shared/_list.html.erb
index 12100ce48..4e276b115 100644
--- a/app/views/admins/salesman_channels/shared/_list.html.erb
+++ b/app/views/admins/salesman_channels/shared/_list.html.erb
@@ -19,16 +19,16 @@
<%= channel.school_name %>
- <%= channel.teacher_count %>
+ <%= channel.teacher_count(@start_time, @end_time, @keyword) %>
|
- <%= channel.student_count %>
+ <%= channel.student_count(@start_time, @end_time, @keyword) %>
|
- <%= channel.course_count %>
+ <%= channel.course_count(@start_time, @end_time, @keyword) %>
|
- <%= channel.shixuns_count %>
+ <%= channel.shixuns_count(@start_time, @end_time, @keyword) %>
|
<%= delete_link '删除', admins_salesman_channel_path(channel, salesman_id: channel.salesman_id, element: ".salesman-channel-item-#{channel.id}"), class: 'delete-salesman-action' %>
From e7774d04dd0f9df4598bff2ccca2a9bde956975a Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Mon, 24 Feb 2020 16:39:32 +0800
Subject: [PATCH 15/25] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=B7=B2=E6=88=AA?=
=?UTF-8?q?=E6=AD=A2=E4=B9=9F=E5=8F=AF=E4=BF=AE=E6=94=B9=E6=88=AA=E6=AD=A2?=
=?UTF-8?q?=E6=97=B6=E9=97=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../update_homework_publish_setting_service.rb | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/app/services/update_homework_publish_setting_service.rb b/app/services/update_homework_publish_setting_service.rb
index bb77a88ec..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,13 +95,18 @@ 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
@@ -110,6 +117,7 @@ class UpdateHomeworkPublishSettingService < ApplicationService
end
homework.save!
+ UpdateShixunWorkScoreJob.perform_later(homework.id)
HomeworkCommonPushNotifyJob.perform_later(homework.id, publish_group_ids) if send_tiding
end
From de135d0dcd44da06ad50d0745d8f03eec2d70df8 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Mon, 24 Feb 2020 17:04:50 +0800
Subject: [PATCH 16/25] =?UTF-8?q?=E6=99=BA=E8=83=BD=E7=BB=84=E5=8D=B7?=
=?UTF-8?q?=E5=8F=AF=E9=80=89=E9=A2=98=E6=95=B0=E4=B8=8D=E5=AF=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/queries/optional_item_query.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/queries/optional_item_query.rb b/app/queries/optional_item_query.rb
index 54cd0eed0..ea3bca043 100644
--- a/app/queries/optional_item_query.rb
+++ b/app/queries/optional_item_query.rb
@@ -28,8 +28,8 @@ class OptionalItemQuery < ApplicationQuery
items = items.where(public: public)
# 难度
- 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
From 422494867b501b9ad0cea150c607fd329676b824 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Mon, 24 Feb 2020 17:40:03 +0800
Subject: [PATCH 17/25] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../react/src/modules/courses/poll/PollDetailTabForthRules.js | 2 +-
public/react/src/modules/paths/statics/index.js | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
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
},
{
From 213fb8cd0906a1ae667c8bd94e3671c178c08852 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Mon, 24 Feb 2020 17:45:43 +0800
Subject: [PATCH 18/25] =?UTF-8?q?=E6=99=BA=E8=83=BD=E7=BB=84=E5=8D=B7?=
=?UTF-8?q?=E7=9A=84=E5=8F=AF=E9=80=89=E9=A2=98=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/queries/optional_item_query.rb | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/app/queries/optional_item_query.rb b/app/queries/optional_item_query.rb
index ea3bca043..61ebf8b69 100644
--- a/app/queries/optional_item_query.rb
+++ b/app/queries/optional_item_query.rb
@@ -22,10 +22,12 @@ 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
# 难度
diff = difficulty ? difficulty.to_i : 1
From 5438edf8e988a5cffb220c36eb7587b2d862f8e8 Mon Sep 17 00:00:00 2001
From: jingquan huang
Date: Mon, 24 Feb 2020 17:59:34 +0800
Subject: [PATCH 19/25] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E6=90=9C=E7=B4=A2?=
=?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/queries/admins/subject_query.rb | 4 ++--
app/views/admins/subject_settings/index.html.erb | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/queries/admins/subject_query.rb b/app/queries/admins/subject_query.rb
index dc459885b..0415deb9f 100644
--- a/app/queries/admins/subject_query.rb
+++ b/app/queries/admins/subject_query.rb
@@ -18,9 +18,9 @@ class Admins::SubjectQuery < ApplicationQuery
status =
case params[:status].to_s.strip
when "editing" then {status: 0}
- when "processed" then {status: 2, public: 0}
+ when "applying" then {status: 2, public: [0, 1]}
when "pending" then {public: 1}
- when "publiced" then {public: 2}
+ when "published" then {public: 2}
end
subjects = subjects.where(status) if status
diff --git a/app/views/admins/subject_settings/index.html.erb b/app/views/admins/subject_settings/index.html.erb
index bcd2a2fc8..b46c1d90d 100644
--- a/app/views/admins/subject_settings/index.html.erb
+++ b/app/views/admins/subject_settings/index.html.erb
@@ -6,7 +6,7 @@
<%= form_tag(admins_subject_settings_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
- <% status_options = [['全部', ''], ['编辑中', 'pending'], ['审核中', 'applying'], ['已发布', 'published']] %>
+ <% status_options = [['全部', ''], ['编辑中', 'pending'], ['审核中', 'applying'], ['已公开', 'published']] %>
<%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
From aea1542fda6ef3c51cccd0c60be14b70ef8e7631 Mon Sep 17 00:00:00 2001
From: jingquan huang
Date: Mon, 24 Feb 2020 18:38:52 +0800
Subject: [PATCH 20/25] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcheck=E6=8C=89=E9=92=AE?=
=?UTF-8?q?=E5=9C=A8=E5=88=B7=E6=96=B0=E7=9A=84=E6=97=B6=E5=80=99=E4=B8=8D?=
=?UTF-8?q?=E8=83=BD=E7=94=A8=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../admins/subject_settings/index.js | 16 ----------------
.../subject_settings/shared/_td.html.erb | 18 ++++++++++++++++++
2 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/app/assets/javascripts/admins/subject_settings/index.js b/app/assets/javascripts/admins/subject_settings/index.js
index 80fc91f47..cbd90f37b 100644
--- a/app/assets/javascripts/admins/subject_settings/index.js
+++ b/app/assets/javascripts/admins/subject_settings/index.js
@@ -30,22 +30,6 @@ $(document).on('turbolinks:load', function () {
});
- $(".action-container").on("change", '.subject-mobile-form', function () {
- var s_id = $(this).attr("data-id");
- var s_value = $(this).val();
- var s_name = $(this).attr("name");
- var json = {};
- var s_index = $(this).parent("td").siblings(".shixun-line-no").text();
- json[s_name] = s_value;
- json["page_no"] = s_index;
- $.ajax({
- url: "/admins/subject_settings/update_mobile_show?subject_id=" + s_id,
- type: "POST",
- dataType:'script',
- data: json
- });
- });
-
$(".subject-setting-list-container").on("change", '.subject-setting-form', function () {
var s_id = $(this).attr("data-id");
var s_value = $(this).val();
diff --git a/app/views/admins/subject_settings/shared/_td.html.erb b/app/views/admins/subject_settings/shared/_td.html.erb
index ed8216bbb..d02355a36 100644
--- a/app/views/admins/subject_settings/shared/_td.html.erb
+++ b/app/views/admins/subject_settings/shared/_td.html.erb
@@ -26,4 +26,22 @@
multiple: true,
maximumSelectionLength: 3,
placeholder: '请选择课程体系'});
+
+
+ $(".action-container").on("change", '.subject-mobile-form', function () {
+ var s_id = $(this).attr("data-id");
+ var s_value = $(this).val();
+ var s_name = $(this).attr("name");
+ var json = {};
+ var s_index = $(this).parent("td").siblings(".shixun-line-no").text();
+ json[s_name] = s_value;
+ json["page_no"] = s_index;
+ $.ajax({
+ url: "/admins/subject_settings/update_mobile_show?subject_id=" + s_id,
+ type: "POST",
+ dataType:'script',
+ data: json
+ });
+ });
+
\ No newline at end of file
From 44f2bf858fc6f411a564479941eb2201cf38d828 Mon Sep 17 00:00:00 2001
From: jingquan huang
Date: Mon, 24 Feb 2020 18:42:51 +0800
Subject: [PATCH 21/25] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=AF=BE=E7=A8=8B?=
=?UTF-8?q?=E7=8A=B6=E6=80=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/admins/subject_settings/shared/_td.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/admins/subject_settings/shared/_td.html.erb b/app/views/admins/subject_settings/shared/_td.html.erb
index d02355a36..94d34f42d 100644
--- a/app/views/admins/subject_settings/shared/_td.html.erb
+++ b/app/views/admins/subject_settings/shared/_td.html.erb
@@ -5,7 +5,7 @@
金课
|
<%= display_text subject.repertoire&.name %> |
-
<%= display_text subject.status == 2 ? "已发布" : "未发布" %> |
+
<%= display_text subject.public == 2 ? "已公开" : ((subject.public == 1 && subject.status == 2) ? "审核中" : "未发布") %> |
<%= select_tag(:sub_disciplines, options_for_select(@sub_disciplines, subject.sub_disciplines.pluck(:id)),multiple:true,class:"form-control subject-setting-form",data:{id:subject.id},id:"tags-chosen-#{subject.id}") %>
|
From 8fc243ca07ea9f41ab7b8332dd02176a57cac3dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Mon, 24 Feb 2020 20:11:59 +0800
Subject: [PATCH 22/25] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../courses/poll/PollDetailTabForthRules.js | 18 ++++++++++++++----
.../shixunHomework/Trainingjobsetting.js | 15 ++++++++-------
2 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/public/react/src/modules/courses/poll/PollDetailTabForthRules.js b/public/react/src/modules/courses/poll/PollDetailTabForthRules.js
index 884f93b24..707c757fd 100644
--- a/public/react/src/modules/courses/poll/PollDetailTabForthRules.js
+++ b/public/react/src/modules/courses/poll/PollDetailTabForthRules.js
@@ -263,8 +263,13 @@ class PollDetailTabForthRules extends Component{
flag1=false;
}
else if(!arr.e_timeflag && moment(arr.end_time,dataformat) <= moment()){
- arr.end_flag="截止时间不能早于当前时间"
- flag1=false;
+ if(this.props.type==="Shixun"){
+
+ }else{
+ arr.end_flag="截止时间不能早于当前时间"
+ flag1=false;
+ }
+
}else if(!arr.e_timeflag && moment(arr.end_time,dataformat) <= moment(arr.publish_time,dataformat)){
arr.end_flag="截止时间不能早于发布时间"
flag1=false;
@@ -314,8 +319,13 @@ class PollDetailTabForthRules extends Component{
flag2=false;
}
else if(moment(arr.end_time,dataformat) <= moment()){
- arr.end_flag="截止时间不能早于当前时间"
- flag2=false;
+ if(this.props.type==="Shixun"){
+
+ }else{
+ arr.end_flag="截止时间不能早于当前时间"
+ flag2=false;
+ }
+
}else if(moment(arr.end_time,dataformat) <= moment(arr.publish_time,dataformat)){
arr.end_flag="截止时间不能早于发布时间"
flag2=false;
diff --git a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js
index 405291691..a6cefb466 100644
--- a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js
+++ b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js
@@ -468,13 +468,13 @@ class Trainingjobsetting extends Component {
if (moment(this.state.end_time, "YYYY-MM-DD HH:mm") <= moment()) {
//截止时间小于当前时间
- this.scrollToAnchor("publishtimeid");
- this.setState({
- unit_e_tip: "截止时间不能早于当前时间",
- p_flag: true,
- borredss: "bor-reds",
- })
- return;
+ // this.scrollToAnchor("publishtimeid");
+ // this.setState({
+ // unit_e_tip: "截止时间不能早于当前时间",
+ // p_flag: true,
+ // borredss: "bor-reds",
+ // })
+ // return;
}
if (moment(this.state.end_time, "YYYY-MM-DD HH:mm") <= moment(this.state.publish_time, "YYYY-MM-DD HH:mm")) {
//截止时间小于发布时间
@@ -787,6 +787,7 @@ class Trainingjobsetting extends Component {
.then((result) => {
if (result.data.status == 0) {
// console.log(JSON.stringify(result));
+ this.getTrainingjobsetting(true);
this.props.showNotification(`更新成功`);
this.setState({
flagPageEditsbox: false,
From d4c699b6293e21cac76cea7af25f7eaa5cf85c5c Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Mon, 24 Feb 2020 20:36:51 +0800
Subject: [PATCH 23/25] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/services/update_homework_publish_setting_service.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/services/update_homework_publish_setting_service.rb b/app/services/update_homework_publish_setting_service.rb
index 431246563..86e348daf 100644
--- a/app/services/update_homework_publish_setting_service.rb
+++ b/app/services/update_homework_publish_setting_service.rb
@@ -76,7 +76,7 @@ class UpdateHomeworkPublishSettingService < ApplicationService
# 实训作业截止时间已过也可修改截止时间,其他作业暂不支持修改
if (homework.homework_type == "practice" || homework.end_time > Time.now) && homework.unified_setting
tip_exception("截止时间不能为空") if params[:end_time].blank?
- tip_exception("截止时间必须晚于发布时间") if params[:publish_time].to_time >= homework.publish_time
+ tip_exception("截止时间必须晚于发布时间") if params[:end_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
From b04ed6fd2886f67c8fc73077b2d2e2ca1ac32b13 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Mon, 24 Feb 2020 20:42:43 +0800
Subject: [PATCH 24/25] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/services/update_homework_publish_setting_service.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/services/update_homework_publish_setting_service.rb b/app/services/update_homework_publish_setting_service.rb
index 86e348daf..0f61bcd75 100644
--- a/app/services/update_homework_publish_setting_service.rb
+++ b/app/services/update_homework_publish_setting_service.rb
@@ -76,7 +76,7 @@ class UpdateHomeworkPublishSettingService < ApplicationService
# 实训作业截止时间已过也可修改截止时间,其他作业暂不支持修改
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 >= homework.publish_time
+ tip_exception("截止时间必须晚于发布时间") if params[:end_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
From 6e174c51f821523665ce194d82a3ce43e67daac8 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Mon, 24 Feb 2020 21:01:13 +0800
Subject: [PATCH 25/25] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BD=9C=E4=B8=9A?=
=?UTF-8?q?=E7=9A=84=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/services/homeworks_service.rb | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/app/services/homeworks_service.rb b/app/services/homeworks_service.rb
index c70535e17..5483eed83 100644
--- a/app/services/homeworks_service.rb
+++ b/app/services/homeworks_service.rb
@@ -133,8 +133,10 @@ class HomeworksService
# 计算实训作品学生的效率分
def update_student_eff_score homework
if homework.work_efficiency && homework.max_efficiency != 0
+ max_efficiency = homework.student_works.where("compelete_status != 0").pluck(:efficiency).max
+ homework.update_column("max_efficiency", max_efficiency)
homework.student_works.where("compelete_status != 0").each do |student_work|
- eff_score = student_work.efficiency / homework.max_efficiency * homework.eff_score
+ eff_score = student_work.efficiency / max_efficiency * homework.eff_score
student_work.eff_score = format("%.2f", eff_score)
student_work.late_penalty = student_work.work_status == 1 ? 0 : homework.late_penalty
unless student_work.ultimate_score
@@ -333,7 +335,10 @@ class HomeworksService
work.compelete_status = myshixun_endtime < setting_time.end_time ? 2 : 3
# 如果作业的最大效率值有变更则更新所有作品的效率分
- homework.update_column("max_efficiency", work.efficiency) if homework.work_efficiency && homework.max_efficiency < work.efficiency
+ if homework.work_efficiency && homework.max_efficiency < work.efficiency
+ homework.max_efficiency = work.efficiency
+ homework.save(validate: false)
+ end
else
work.compelete_status = 1 # 未通关
end