<% if @exercise_single_ques_count > 0 %>
From 65c7dafb8208a7b1f4a8211702eb4a4b0d168ff5 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 08:41:22 +0800
Subject: [PATCH 18/80] fix bug
---
.../exercise_export/blank_exercise.html.erb | 28 +++++++++------
.../exercise_export/exercise_user.html.erb | 34 +++++++++++--------
2 files changed, 36 insertions(+), 26 deletions(-)
diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb
index 759a2d2b0..45a086e6e 100644
--- a/app/templates/exercise_export/blank_exercise.html.erb
+++ b/app/templates/exercise_export/blank_exercise.html.erb
@@ -20,41 +20,47 @@
- <% if @exercise_single_ques_count > 0 %>
+
+ <% if @exercise_single_ques_count > 0 %>
单选题<%= @exercise_single_ques_count %>题,
共<%= @exercise_single_ques_scores %>分
<% end %>
- <% if @exercise_double_ques_count > 0 %>
+ <% if @exercise_double_ques_count > 0 %>
多选题<%= @exercise_double_ques_count %>题,
共<%= @exercise_double_ques_scores %>分
<% end %>
- <% if @exercise_ques_judge_count > 0 %>
+ <% if @exercise_ques_judge_count > 0 %>
判断题<%= @exercise_ques_judge_count %>题,
共<%= @exercise_ques_judge_scores %>分
<% end %>
- <% if @exercise_ques_null_count > 0 %>
+ <% if @exercise_ques_null_count > 0 %>
填空题<%= @exercise_ques_null_count %>题,
共<%= @exercise_ques_null_scores %>分
<% end %>
- <% if @exercise_ques_main_count > 0 %>
+ <% if @exercise_ques_main_count > 0 %>
主观题<%= @exercise_ques_main_count %>题,
共<%= @exercise_ques_main_scores %>分
<% end %>
- <% if @exercise_ques_shixun_count > 0 %>
+ <% if @exercise_ques_shixun_count > 0 %>
实训题<%= @exercise_ques_shixun_count %>题,
共<%= @exercise_ques_shixun_scores %>分
<% end %>
- <% if @exercise_ques_count > 0 %>
-
- 共<%= @exercise_ques_scores %>分
-
-
+
+
+
+ <% if @exercise_ques_count > 0 %>
+
合计<%= @exercise_ques_count %>题
+
+ 共<%= @exercise_ques_scores %>分
+
<% end %>
+
+
<% @exercise_questions.each do |q| %>
diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb
index 52a083eab..ba47d6b02 100644
--- a/app/templates/exercise_export/exercise_user.html.erb
+++ b/app/templates/exercise_export/exercise_user.html.erb
@@ -20,38 +20,42 @@
- <% if @exercise_single_ques_count > 0 %>
+
+ <% if @exercise_single_ques_count > 0 %>
单选题<%= @exercise_single_ques_count %>题,
共<%= @exercise_single_ques_scores %>分
<% end %>
- <% if @exercise_double_ques_count > 0 %>
+ <% if @exercise_double_ques_count > 0 %>
多选题<%= @exercise_double_ques_count %>题,
共<%= @exercise_double_ques_scores %>分
<% end %>
- <% if @exercise_ques_judge_count > 0 %>
+ <% if @exercise_ques_judge_count > 0 %>
判断题<%= @exercise_ques_judge_count %>题,
共<%= @exercise_ques_judge_scores %>分
<% end %>
- <% if @exercise_ques_null_count > 0 %>
+ <% if @exercise_ques_null_count > 0 %>
填空题<%= @exercise_ques_null_count %>题,
共<%= @exercise_ques_null_scores %>分
<% end %>
- <% if @exercise_ques_main_count > 0 %>
- 主观题<%= @exercise_ques_main_count %>题,
- 共<%= @exercise_ques_main_scores %>分
+ <% if @exercise_ques_main_count > 0 %>
+ 主观题<%= @exercise_ques_main_count %>题,
+ 共<%= @exercise_ques_main_scores %>分
<% end %>
- <% if @exercise_ques_shixun_count > 0 %>
- 实训题<%= @exercise_ques_shixun_count %>题,
- 共<%= @exercise_ques_shixun_scores %>分
+ <% if @exercise_ques_shixun_count > 0 %>
+ 实训题<%= @exercise_ques_shixun_count %>题,
+ 共<%= @exercise_ques_shixun_scores %>分
<% end %>
- <% if @exercise_ques_count > 0 %>
-
- 共<%= @exercise_ques_scores %>分
-
-
+
+
+ <% if @exercise_ques_count > 0 %>
+
合计<%= @exercise_ques_count %>题
+
+ 共<%= @exercise_ques_scores %>分
+
<% end %>
+
From 4267b8d32cf5eea0876e83fa833fedeb266813ca Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 08:46:36 +0800
Subject: [PATCH 19/80] fix bug
---
app/templates/exercise_export/exercise_export.css | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css
index 66bd565b1..cdb4adc32 100644
--- a/app/templates/exercise_export/exercise_export.css
+++ b/app/templates/exercise_export/exercise_export.css
@@ -2,6 +2,9 @@ body{
font-size:14px;
font-family: "微软雅黑","宋体";
}
+.container{
+ width:1200px;
+}
p{
margin:0;
}
From b6cd30946ae494b6ecbbe7411c0c91698296acab Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 08:49:48 +0800
Subject: [PATCH 20/80] fix bug
---
app/templates/exercise_export/blank_exercise.html.erb | 2 +-
app/templates/exercise_export/exercise_export.css | 10 ++++------
app/templates/exercise_export/exercise_user.html.erb | 2 +-
3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb
index 45a086e6e..37900d983 100644
--- a/app/templates/exercise_export/blank_exercise.html.erb
+++ b/app/templates/exercise_export/blank_exercise.html.erb
@@ -19,7 +19,7 @@
-
+
<% if @exercise_single_ques_count > 0 %>
单选题<%= @exercise_single_ques_count %>题,
diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css
index cdb4adc32..6e2ecd8b3 100644
--- a/app/templates/exercise_export/exercise_export.css
+++ b/app/templates/exercise_export/exercise_export.css
@@ -2,9 +2,7 @@ body{
font-size:14px;
font-family: "微软雅黑","宋体";
}
-.container{
- width:1200px;
-}
+
p{
margin:0;
}
@@ -335,9 +333,9 @@ textarea{
.mt-2{
margin-top:-2px;
}
-/*.width100{*/
- /*width:100%;*/
-/*}*/
+.width100{
+ width:100%;
+}
.ex-scores{
/*width:100%;*/
display:inline-block;
diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb
index ba47d6b02..9b2fef1e0 100644
--- a/app/templates/exercise_export/exercise_user.html.erb
+++ b/app/templates/exercise_export/exercise_user.html.erb
@@ -19,7 +19,7 @@
-
+
<% if @exercise_single_ques_count > 0 %>
单选题<%= @exercise_single_ques_count %>题,
From 402562144dbb0978aa60452443af9c7656138c35 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 08:53:17 +0800
Subject: [PATCH 21/80] fix bug
---
app/templates/exercise_export/exercise_export.css | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css
index 6e2ecd8b3..e34eefedc 100644
--- a/app/templates/exercise_export/exercise_export.css
+++ b/app/templates/exercise_export/exercise_export.css
@@ -338,7 +338,7 @@ textarea{
}
.ex-scores{
/*width:100%;*/
- display:inline-block;
+ /*display:inline-block;*/
word-break: break-all;
}
From 7be1a7901cfd806612e59758181c1f5a6d6b3170 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 08:56:16 +0800
Subject: [PATCH 22/80] fix bug
---
app/templates/exercise_export/exercise_export.css | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css
index e34eefedc..2e5f77a11 100644
--- a/app/templates/exercise_export/exercise_export.css
+++ b/app/templates/exercise_export/exercise_export.css
@@ -337,8 +337,8 @@ textarea{
width:100%;
}
.ex-scores{
- /*width:100%;*/
- /*display:inline-block;*/
+ width:100%;
+ display:inline-block;
word-break: break-all;
}
From 684084cc6387dc56e2b9195bd7dbd8c69cf8572a Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 09:02:43 +0800
Subject: [PATCH 23/80] fix bug
---
app/controllers/exercises_controller.rb | 2 +-
app/templates/exercise_export/blank_exercise.html.erb | 2 +-
app/templates/exercise_export/exercise_user.html.erb | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index 3c364b979..aee99fbab 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1335,7 +1335,7 @@ class ExercisesController < ApplicationController
def export_exercise
@request_url = request.base_url
@exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC")
- filename = "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf"
+ filename = "#{@exercise.user.real_name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf"
stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css"
render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets
end
diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb
index 37900d983..48bb1567f 100644
--- a/app/templates/exercise_export/blank_exercise.html.erb
+++ b/app/templates/exercise_export/blank_exercise.html.erb
@@ -19,7 +19,7 @@
-
+
<% if @exercise_single_ques_count > 0 %>
单选题<%= @exercise_single_ques_count %>题,
diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb
index 9b2fef1e0..42d25dd1b 100644
--- a/app/templates/exercise_export/exercise_user.html.erb
+++ b/app/templates/exercise_export/exercise_user.html.erb
@@ -19,7 +19,7 @@
-
+
<% if @exercise_single_ques_count > 0 %>
单选题<%= @exercise_single_ques_count %>题,
From 5d3cb93b35f6b1319423f7d017d178d9d721bb96 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 09:10:22 +0800
Subject: [PATCH 24/80] fi xbug
---
app/templates/exercise_export/exercise_user.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb
index 42d25dd1b..934ca6586 100644
--- a/app/templates/exercise_export/exercise_user.html.erb
+++ b/app/templates/exercise_export/exercise_user.html.erb
@@ -17,7 +17,7 @@
-
+
From e178f32db50613624c0fbaba460ccd6245133b03 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 09:32:22 +0800
Subject: [PATCH 25/80] fix bug
---
app/controllers/exercises_controller.rb | 2 +-
app/controllers/zips_controller.rb | 4 ++--
app/services/exercise_user_pdf_service.rb | 4 ++--
app/services/export_exercises_service.rb | 2 +-
.../exercise_export/blank_exercise.html.erb | 19 ++++++++-----------
.../exercise_export/exercise_export.css | 4 ++--
.../exercise_export/exercise_user.html.erb | 16 +++++++---------
7 files changed, 23 insertions(+), 28 deletions(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index aee99fbab..ff4dc6be9 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1335,7 +1335,7 @@ class ExercisesController < ApplicationController
def export_exercise
@request_url = request.base_url
@exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC")
- filename = "#{@exercise.user.real_name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf"
+ filename = "#{@exercise.user.real_name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d_%H%M')}.pdf"
stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css"
render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets
end
diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb
index c20546701..51761d023 100644
--- a/app/controllers/zips_controller.rb
+++ b/app/controllers/zips_controller.rb
@@ -49,12 +49,12 @@ class ZipsController < ApplicationController
@course = @exercise.course
default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed
- @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。
+ @ex_users = default_ex_users.limit 2 #仅导出已提交的,截止后则是全部为提交的。
#可以分班选择
if group_id.present?
exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数
user_ids = exercise_students.pluck(:user_id).reject(&:blank?).uniq
- @ex_users = @ex_users.where(user_id: user_ids)
+ @ex_users = @ex_users.where(user_id: user_ids).limit 2
end
default_ex_users_size = @ex_users.size
diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb
index f0f7c1ac1..73711192f 100644
--- a/app/services/exercise_user_pdf_service.rb
+++ b/app/services/exercise_user_pdf_service.rb
@@ -15,8 +15,8 @@ class ExerciseUserPdfService
end
def filename
- user_course = @course.course_members.find_by(user_id:@ex_user_user.id).course_group_name
- exercise_user_name = user_course + "_" + exercise.exercise_name + "_" + @ex_user_user.real_name
+ user_course = @course.course_members.find_by(user_id:@ex_user_user.id)&.course_group_name
+ exercise_user_name = "#{@ex_user_user.real_name}_#{user_course.present? ? user_course : "未分班"}_#{exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M')}"
"#{exercise_user_name.strip}.pdf"
end
diff --git a/app/services/export_exercises_service.rb b/app/services/export_exercises_service.rb
index f83323d7e..3aac67713 100644
--- a/app/services/export_exercises_service.rb
+++ b/app/services/export_exercises_service.rb
@@ -10,7 +10,7 @@ class ExportExercisesService
end
def filename
- exercise_export_name = exercise.user.real_name + "_" + exercise.exercise_name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
+ exercise_export_name = "#{exercise.user.real_name}_#{exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M')}"
"#{exercise_export_name.strip}.zip"
end
diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb
index 48bb1567f..bb7b28f22 100644
--- a/app/templates/exercise_export/blank_exercise.html.erb
+++ b/app/templates/exercise_export/blank_exercise.html.erb
@@ -17,37 +17,34 @@
-
+
-
-
- <% if @exercise_single_ques_count > 0 %>
+
+ <% if @exercise_single_ques_count > 0 %>
单选题<%= @exercise_single_ques_count %>题,
共<%= @exercise_single_ques_scores %>分
<% end %>
- <% if @exercise_double_ques_count > 0 %>
+ <% if @exercise_double_ques_count > 0 %>
多选题<%= @exercise_double_ques_count %>题,
共<%= @exercise_double_ques_scores %>分
<% end %>
- <% if @exercise_ques_judge_count > 0 %>
+ <% if @exercise_ques_judge_count > 0 %>
判断题<%= @exercise_ques_judge_count %>题,
共<%= @exercise_ques_judge_scores %>分
<% end %>
- <% if @exercise_ques_null_count > 0 %>
+ <% if @exercise_ques_null_count > 0 %>
填空题<%= @exercise_ques_null_count %>题,
共<%= @exercise_ques_null_scores %>分
<% end %>
- <% if @exercise_ques_main_count > 0 %>
+ <% if @exercise_ques_main_count > 0 %>
主观题<%= @exercise_ques_main_count %>题,
共<%= @exercise_ques_main_scores %>分
<% end %>
- <% if @exercise_ques_shixun_count > 0 %>
+ <% if @exercise_ques_shixun_count > 0 %>
实训题<%= @exercise_ques_shixun_count %>题,
共<%= @exercise_ques_shixun_scores %>分
<% end %>
-
-
<% if @exercise_ques_count > 0 %>
合计<%= @exercise_ques_count %>题
diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css
index 2e5f77a11..e34eefedc 100644
--- a/app/templates/exercise_export/exercise_export.css
+++ b/app/templates/exercise_export/exercise_export.css
@@ -337,8 +337,8 @@ textarea{
width:100%;
}
.ex-scores{
- width:100%;
- display:inline-block;
+ /*width:100%;*/
+ /*display:inline-block;*/
word-break: break-all;
}
diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb
index 934ca6586..847820d57 100644
--- a/app/templates/exercise_export/exercise_user.html.erb
+++ b/app/templates/exercise_export/exercise_user.html.erb
@@ -19,33 +19,31 @@
-
-
- <% if @exercise_single_ques_count > 0 %>
+
+ <% if @exercise_single_ques_count > 0 %>
单选题<%= @exercise_single_ques_count %>题,
共<%= @exercise_single_ques_scores %>分
<% end %>
- <% if @exercise_double_ques_count > 0 %>
+ <% if @exercise_double_ques_count > 0 %>
多选题<%= @exercise_double_ques_count %>题,
共<%= @exercise_double_ques_scores %>分
<% end %>
- <% if @exercise_ques_judge_count > 0 %>
+ <% if @exercise_ques_judge_count > 0 %>
判断题<%= @exercise_ques_judge_count %>题,
共<%= @exercise_ques_judge_scores %>分
<% end %>
- <% if @exercise_ques_null_count > 0 %>
+ <% if @exercise_ques_null_count > 0 %>
填空题<%= @exercise_ques_null_count %>题,
共<%= @exercise_ques_null_scores %>分
<% end %>
- <% if @exercise_ques_main_count > 0 %>
+ <% if @exercise_ques_main_count > 0 %>
主观题<%= @exercise_ques_main_count %>题,
共<%= @exercise_ques_main_scores %>分
<% end %>
- <% if @exercise_ques_shixun_count > 0 %>
+ <% if @exercise_ques_shixun_count > 0 %>
实训题<%= @exercise_ques_shixun_count %>题,
共<%= @exercise_ques_shixun_scores %>分
<% end %>
-
<% if @exercise_ques_count > 0 %>
From ce2344eecd1ebc4bc703ded6434655e8ec31970a Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 09:44:14 +0800
Subject: [PATCH 26/80] fix bug
---
app/controllers/zips_controller.rb | 4 ++--
app/templates/exercise_export/blank_exercise.html.erb | 2 +-
app/templates/exercise_export/exercise_export.css | 1 +
app/templates/exercise_export/exercise_user.html.erb | 2 +-
4 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb
index 51761d023..c20546701 100644
--- a/app/controllers/zips_controller.rb
+++ b/app/controllers/zips_controller.rb
@@ -49,12 +49,12 @@ class ZipsController < ApplicationController
@course = @exercise.course
default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed
- @ex_users = default_ex_users.limit 2 #仅导出已提交的,截止后则是全部为提交的。
+ @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。
#可以分班选择
if group_id.present?
exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数
user_ids = exercise_students.pluck(:user_id).reject(&:blank?).uniq
- @ex_users = @ex_users.where(user_id: user_ids).limit 2
+ @ex_users = @ex_users.where(user_id: user_ids)
end
default_ex_users_size = @ex_users.size
diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb
index bb7b28f22..5e763d1cc 100644
--- a/app/templates/exercise_export/blank_exercise.html.erb
+++ b/app/templates/exercise_export/blank_exercise.html.erb
@@ -19,7 +19,7 @@
-
+
<% if @exercise_single_ques_count > 0 %>
单选题<%= @exercise_single_ques_count %>题,
共<%= @exercise_single_ques_scores %>分
diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css
index e34eefedc..119d92a05 100644
--- a/app/templates/exercise_export/exercise_export.css
+++ b/app/templates/exercise_export/exercise_export.css
@@ -340,6 +340,7 @@ textarea{
/*width:100%;*/
/*display:inline-block;*/
word-break: break-all;
+ line-height:2;
}
diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb
index 847820d57..1c91baec2 100644
--- a/app/templates/exercise_export/exercise_user.html.erb
+++ b/app/templates/exercise_export/exercise_user.html.erb
@@ -19,7 +19,7 @@
-
+
<% if @exercise_single_ques_count > 0 %>
单选题<%= @exercise_single_ques_count %>题,
共<%= @exercise_single_ques_scores %>分
From 95255749bd4f98eb2c3ddcd55e5df52b67546052 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 2 Jul 2019 11:23:49 +0800
Subject: [PATCH 27/80] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/homework_commons_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb
index aaffc34a6..af1dffe71 100644
--- a/app/controllers/homework_commons_controller.rb
+++ b/app/controllers/homework_commons_controller.rb
@@ -272,7 +272,7 @@ class HomeworkCommonsController < ApplicationController
def update_student_score
work = @homework.student_works.find_by(user_id: current_user.id)
myshixun = Myshixun.find_by(shixun_id: params[:shixun_id], user_id: current_user.id)
- ActiveRecord::Base.transaction do
+ ActiveRecord::Base.transaction do
begin
if work && myshixun && (work.update_time.nil? || work.update_time < myshixun.updated_at)
challenge_settings = @homework.homework_challenge_settings
From c3885ec64c6f9982452c8b1ca0deba763135a889 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 2 Jul 2019 11:43:02 +0800
Subject: [PATCH 28/80] =?UTF-8?q?=E6=89=93=E5=8D=B0=E6=97=A5=E5=BF=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/shixuns_controller.rb | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index 0d913a0a1..767129026 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -280,7 +280,6 @@ class ShixunsController < ApplicationController
@small_type = shixun_small_type
end
- # 注意这里传参都应该使用params[:shixun]['name']这种格式
def create
# 评测脚本的一些操作
main_type, sub_type = params[:main_type], params[:small_type]
@@ -388,7 +387,8 @@ class ShixunsController < ApplicationController
ShixunMirrorRepository.create(:shixun_id => @shixun.id, :mirror_repository_id => mirror)
end
end
-
+ logger.info("#######shixun_params: ##{shixun_params}")
+ logger.info("#######shixun_info_params: ##{shixun_info_params}")
@shixun.update_attributes(shixun_params)
@shixun.shixun_info.update_attributes(shixun_info_params)
@shixun.shixun_schools.delete_all
@@ -735,7 +735,7 @@ private
def shixun_params
raise("实训名称不能为空") if params[:shixun][:name].blank?
params.require(:shixun).permit(:name, :trainee, :webssh, :can_copy, :use_scope, :vnc, :test_set_permission,
- :task_pass, :repo_name, :multi_webssh, :opening_time, :mirror_script_id, :code_hidden,
+ :task_pass, :multi_webssh, :opening_time, :mirror_script_id, :code_hidden,
:hide_code, :forbid_copy)
end
def shixun_info_params
From 61747f8e840675f796de679fcf99b48cef8807a7 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 12:25:44 +0800
Subject: [PATCH 29/80] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=95=E5=8D=B7?=
=?UTF-8?q?=E5=92=8C=E9=97=AE=E5=8D=B7=E7=AD=94=E9=A2=98=E5=88=97=E8=A1=A8?=
=?UTF-8?q?=E7=9A=84=E6=90=9C=E7=B4=A2=E6=9D=A1=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/exercises_controller.rb | 10 ++--------
app/controllers/polls_controller.rb | 10 +++-------
2 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index ff4dc6be9..2761523a6 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1278,14 +1278,8 @@ class ExercisesController < ApplicationController
#搜索
if params[:search].present?
- search_content = params[:search]
- #搜索用户的nickname,如果存在则返回,否则继续查询用户的真实姓名或学生号
- nick_name_search = @exercise_users_list.where(user_id: User.where('CONCAT(users.lastname, users.firstname) like ?',"%#{search_content}%"))
- if nick_name_search.present?
- @exercise_users_list = nick_name_search
- else
- @exercise_users_list = @exercise_users_list.joins(user: [:user_extension]).where('user_extensions.student_id like ? OR user_extensions.student_realname like ?',"%#{search_content}%","%#{search_content}%")
- end
+
+ @exercise_users_list = @exercise_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
end
@export_ex_users = @exercise_users_list
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index cd9679972..90ca1778e 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -1026,13 +1026,9 @@ class PollsController < ApplicationController
#搜索
if search_content.present?
- #搜索用户的nickname,如果存在则返回,否则继续查询用户的真实姓名或学生号
- nick_name_search = @poll_users_list.where(user_id: User.where('CONCAT(users.lastname, users.firstname) like ?',"%#{search_content}%"))
- if nick_name_search.present?
- @poll_users_list = nick_name_search
- else
- @poll_users_list = @poll_users_list.joins(user: [:user_extension]).where('user_extensions.student_id like ? OR user_extensions.student_realname like ?',"%#{search_content}%","%#{search_content}%")
- end
+
+ @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%")
+
end
@poll_users_size = @poll_users_list.count
From 50c7e9815e7d71ab46e641c07ad94b72968c0c9c Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 13:43:19 +0800
Subject: [PATCH 30/80] fix bug
---
app/controllers/polls_controller.rb | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index 90ca1778e..24aa54309 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -953,12 +953,14 @@ class PollsController < ApplicationController
@poll_publish_count = get_user_permission_course(poll_ids,2).count
@poll_unpublish_count = get_user_permission_course(poll_ids,1).count
@course_all_members = @course.students
+ logger.info("#######F___________poll_user_ids________________####{@poll.poll_users.pluck(:id)}")
@poll_group_counts = @course.course_groups_count
if @user_course_identity < Course::STUDENT #当前为老师,而且老师只能查看自己班级的/课堂的问卷
@poll_current_user_status = 0
- @poll_users_list = @poll.all_poll_users(current_user.id).distinct #该老师分班的全部学生
+ @poll_users_list = @poll.all_poll_users(current_user.id) #该老师分班的全部学生
get_poll_answers(@poll_users_list)
+ logger.info("#######F__________@poll_users_list________________####{@poll_users_list.pluck(:id)}")
if @poll_list_status == 1
@poll_course_groups =[]
@@ -1026,9 +1028,7 @@ class PollsController < ApplicationController
#搜索
if search_content.present?
-
@poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%")
-
end
@poll_users_size = @poll_users_list.count
From b1e13758d3d1c127b4153460b1ec04e70d1ebcd1 Mon Sep 17 00:00:00 2001
From: p31729568
Date: Tue, 2 Jul 2019 13:53:00 +0800
Subject: [PATCH 31/80] add school and department api for option
---
app/controllers/departments_controller.rb | 11 +++++++++++
app/controllers/schools_controller.rb | 4 ++++
app/models/department.rb | 22 +++++++++++++++++++++
app/models/school.rb | 24 +++++++++++++++++++++++
config/routes.rb | 6 +++++-
5 files changed, 66 insertions(+), 1 deletion(-)
create mode 100644 app/controllers/departments_controller.rb
diff --git a/app/controllers/departments_controller.rb b/app/controllers/departments_controller.rb
new file mode 100644
index 000000000..f0fa8fe2c
--- /dev/null
+++ b/app/controllers/departments_controller.rb
@@ -0,0 +1,11 @@
+class DepartmentsController < ApplicationController
+ def for_option
+ render_ok(departments: Department.cached_names_data(current_school))
+ end
+
+ private
+
+ def current_school
+ @_current_school ||= School.find(params[:id])
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb
index 11932be42..ea94f4c69 100644
--- a/app/controllers/schools_controller.rb
+++ b/app/controllers/schools_controller.rb
@@ -9,4 +9,8 @@ class SchoolsController < ApplicationController
render_ok(school_names: schools.pluck(:name))
end
+
+ def for_option
+ render_ok(schools: School.cached_names_data)
+ end
end
diff --git a/app/models/department.rb b/app/models/department.rb
index 15a8a7c1b..bf5c3a90e 100644
--- a/app/models/department.rb
+++ b/app/models/department.rb
@@ -2,4 +2,26 @@ class Department < ApplicationRecord
belongs_to :school
has_many :department_members, dependent: :destroy
+
+ after_create_commit :reset_data_cache
+ after_update_commit :reset_data_cache
+
+ def self.cached_names_data(school)
+ Rails.cache.fetch(names_data_cache_key(school.id), expires_in: 7.days) do
+ school.departments.select(:id, :name).as_json
+ end
+ end
+
+ private
+
+ def reset_data_cache
+ # 清除部门名称缓存
+ if new_record? || name_previously_changed?
+ Rails.cache.delete(self.class.names_data_cache_key(school_id))
+ end
+ end
+
+ def self.names_data_cache_key(school_id)
+ "schools/#{school_id}/department_names_data"
+ end
end
diff --git a/app/models/school.rb b/app/models/school.rb
index af04ed0c7..983a93735 100644
--- a/app/models/school.rb
+++ b/app/models/school.rb
@@ -1,4 +1,6 @@
class School < ApplicationRecord
+ has_many :departments, dependent: :destroy
+
has_many :shixun_schools, :dependent => :destroy
has_many :shixuns, :through => :shixun_schools
@@ -8,6 +10,9 @@ class School < ApplicationRecord
has_many :ec_major_schools, :dependent => :destroy
has_many :ec_majors, :through => :ec_major_schools
+ after_create_commit :reset_data_cache
+ after_update_commit :reset_data_cache
+
# 学校管理员
def manager?(user)
ec_school_users.exists?(user_id: user.id)
@@ -28,4 +33,23 @@ class School < ApplicationRecord
def manage_permission?(user)
manager?(user) || major_manager?(user) || course_manager?(user)
end
+
+ def self.cached_names_data
+ Rails.cache.fetch(names_data_cache_key, expires_in: 7.days) do
+ School.select(:id, :name).as_json
+ end
+ end
+
+ private
+
+ def reset_data_cache
+ # 清除学校名称缓存
+ if new_record? || name_previously_changed?
+ Rails.cache.delete(self.class.names_data_cache_key)
+ end
+ end
+
+ def self.names_data_cache_key
+ 'schools/names_data'
+ end
end
diff --git a/config/routes.rb b/config/routes.rb
index 0f47cda76..a27dde1f3 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -576,9 +576,13 @@ Rails.application.routes.draw do
resources :schools do
member do
+ resources :departments, only: [] do
+ get :for_option, on: :collection
+ end
end
collection do
- get "school_list"
+ get :school_list
+ get :for_option
end
scope module: :ecs do
From 1cbd20b57add58f719a7cefbf7f07af8320378d1 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 13:58:43 +0800
Subject: [PATCH 32/80] fix bug
---
app/controllers/polls_controller.rb | 2 ++
app/models/poll.rb | 6 +++---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index 24aa54309..e1ea02016 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -961,6 +961,8 @@ class PollsController < ApplicationController
@poll_users_list = @poll.all_poll_users(current_user.id) #该老师分班的全部学生
get_poll_answers(@poll_users_list)
logger.info("#######F__________@poll_users_list________________####{@poll_users_list.pluck(:id)}")
+ logger.info("#######F__________@users_ids________________####{PollUser.where(id:@poll_users_list.pluck(:id)).pluck(:user_id)}")
+
if @poll_list_status == 1
@poll_course_groups =[]
diff --git a/app/models/poll.rb b/app/models/poll.rb
index f72239ba7..7e71505ba 100644
--- a/app/models/poll.rb
+++ b/app/models/poll.rb
@@ -52,12 +52,12 @@ class Poll < ApplicationRecord
# 统一设置,为当前老师有权限的分班学生,分班设置,也为当前老师有权限的分班的学生
def all_poll_users(user_id)
- poll_users = self.poll_users
+ poll_all_users = poll_users
group_ids = poll_published_ids(user_id)
if group_ids.present?
- poll_users = poll_users.where(user_id: course.students.where(course_group_id: group_ids).pluck(:user_id))
+ poll_all_users = poll_all_users.where(user_id: course.students.where(course_group_id: group_ids).pluck(:user_id).uniq)
end
- poll_users
+ poll_all_users
end
#当前用户已发布的班级id和试卷分组已发布的班级id的交集
From 3d6ab9da88fe236d4aff0d344789e15b4c65efec Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 14:02:58 +0800
Subject: [PATCH 33/80] fix bug
---
app/controllers/polls_controller.rb | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index e1ea02016..810bf55c1 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -1029,15 +1029,20 @@ class PollsController < ApplicationController
end
#搜索
- if search_content.present?
- @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%")
- end
+ # if search_content.present?
+ # @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%")
+ # end
+
+ logger.info("#######F_______@poll_users_list_last___@users_ids________________####{@poll_users_list.pluck(:id)}")
+
@poll_users_size = @poll_users_list.count
# 分页
@page = params[:page] || 1
@limit = params[:limit] || 20
@poll_users_list = @poll_users_list.page(@page).per(@limit)
+ logger.info("#######F_______@poll_users_list_after_page___@users_ids________________####{@poll_users_list.pluck(:id)}")
+
else
@poll_users_list = []
@poll_users_size = 0
From 8269367f4737ef49753bfebcb81e4680718cacc6 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 14:21:16 +0800
Subject: [PATCH 34/80] fix bug
---
app/controllers/polls_controller.rb | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index 810bf55c1..7ac288d7d 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -1029,20 +1029,19 @@ class PollsController < ApplicationController
end
#搜索
- # if search_content.present?
- # @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%")
- # end
+ if search_content.present?
+ @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%")
+ end
logger.info("#######F_______@poll_users_list_last___@users_ids________________####{@poll_users_list.pluck(:id)}")
@poll_users_size = @poll_users_list.count
# 分页
- @page = params[:page] || 1
- @limit = params[:limit] || 20
- @poll_users_list = @poll_users_list.page(@page).per(@limit)
+ page = params[:page] || 1
+ limit = params[:limit] || 20
+ @poll_users_list = @poll_users_list.page(page).per(limit)
logger.info("#######F_______@poll_users_list_after_page___@users_ids________________####{@poll_users_list.pluck(:id)}")
-
else
@poll_users_list = []
@poll_users_size = 0
From 910c0b13b3fe2e0fae05258c94426b4229a91671 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 2 Jul 2019 14:23:20 +0800
Subject: [PATCH 35/80] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AE=9E=E8=AE=AD?=
=?UTF-8?q?=E5=8F=82=E6=95=B0=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/shixuns_controller.rb | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index 767129026..65d671856 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -387,8 +387,6 @@ class ShixunsController < ApplicationController
ShixunMirrorRepository.create(:shixun_id => @shixun.id, :mirror_repository_id => mirror)
end
end
- logger.info("#######shixun_params: ##{shixun_params}")
- logger.info("#######shixun_info_params: ##{shixun_info_params}")
@shixun.update_attributes(shixun_params)
@shixun.shixun_info.update_attributes(shixun_info_params)
@shixun.shixun_schools.delete_all
@@ -407,6 +405,8 @@ class ShixunsController < ApplicationController
# 超级管理员和运营人员才能保存 中间层服务器pod信息的配置
if current_user.admin? || current_user.business?
@shixun.shixun_service_configs.destroy_all
+ ActionController::Parameters.permit_all_parameters = true
+ logger.info("##--;;;;---#{params[:shixun_service_configs]}")
params[:shixun_service_configs].each do |config|
@shixun.shixun_service_configs.create!(config)
end
@@ -738,6 +738,7 @@ private
:task_pass, :multi_webssh, :opening_time, :mirror_script_id, :code_hidden,
:hide_code, :forbid_copy)
end
+
def shixun_info_params
raise("实训描述不能为空") if params[:shixun_info][:description].blank?
raise("评测脚本不能为空") if params[:shixun_info][:evaluate_script].blank?
From 857f2dcb3e169d27fcf804e919b0f3ac66d2ee55 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 14:43:56 +0800
Subject: [PATCH 36/80] fix bug
---
app/controllers/exercises_controller.rb | 2 +-
app/controllers/polls_controller.rb | 11 +++--------
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index 2761523a6..a793c673c 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1238,7 +1238,7 @@ class ExercisesController < ApplicationController
@teacher_unreview_count = 0
#筛选/分类,排序
order = params[:order]
- if @exercise_users_list.present? && @exercise_users_list.count > 0
+ if @exercise_users_list.present? && @exercise_users_list.size > 0
teacher_reviews = @exercise_users_list.exercise_review
teacher_unreviews = @exercise_users_list.exercise_unreview
@teacher_review_count = teacher_reviews.count #已评阅
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index 7ac288d7d..6a8edee71 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -953,17 +953,12 @@ class PollsController < ApplicationController
@poll_publish_count = get_user_permission_course(poll_ids,2).count
@poll_unpublish_count = get_user_permission_course(poll_ids,1).count
@course_all_members = @course.students
- logger.info("#######F___________poll_user_ids________________####{@poll.poll_users.pluck(:id)}")
@poll_group_counts = @course.course_groups_count
if @user_course_identity < Course::STUDENT #当前为老师,而且老师只能查看自己班级的/课堂的问卷
@poll_current_user_status = 0
@poll_users_list = @poll.all_poll_users(current_user.id) #该老师分班的全部学生
get_poll_answers(@poll_users_list)
- logger.info("#######F__________@poll_users_list________________####{@poll_users_list.pluck(:id)}")
- logger.info("#######F__________@users_ids________________####{PollUser.where(id:@poll_users_list.pluck(:id)).pluck(:user_id)}")
-
-
if @poll_list_status == 1
@poll_course_groups =[]
else
@@ -1033,15 +1028,15 @@ class PollsController < ApplicationController
@poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%")
end
- logger.info("#######F_______@poll_users_list_last___@users_ids________________####{@poll_users_list.pluck(:id)}")
-
+ logger.info("#######F_______@poll_users_list_last___@users_ids________________####{@poll_users_list.pluck(:user_id)}")
@poll_users_size = @poll_users_list.count
+
# 分页
page = params[:page] || 1
limit = params[:limit] || 20
@poll_users_list = @poll_users_list.page(page).per(limit)
- logger.info("#######F_______@poll_users_list_after_page___@users_ids________________####{@poll_users_list.pluck(:id)}")
+ logger.info("#######F_______@poll_users_list_after_page___@users_ids________________####{@poll_users_list.pluck(:user_id)}")
else
@poll_users_list = []
@poll_users_size = 0
From 23333a8186e50f1ab51d0fc17fd8de027f5cdd80 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 2 Jul 2019 14:55:59 +0800
Subject: [PATCH 37/80] =?UTF-8?q?=E6=89=93=E5=8D=B0=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/polls_controller.rb | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index 6a8edee71..d928d1df5 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -1005,12 +1005,6 @@ class PollsController < ApplicationController
if @poll_users_list.present? && @poll_users_list.count > 0
- if order == "student_id"
- @poll_users_list = @poll_users_list.joins(user: [:user_extension]).order("user_extensions.student_id DESC")
- else
- @poll_users_list = @poll_users_list.order("end_at DESC")
- end
-
#答题状态的选择
if choose_type.present?
@poll_users_list = @poll_users_list.commit_by_status(choose_type)
@@ -1027,8 +1021,12 @@ class PollsController < ApplicationController
if search_content.present?
@poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%")
end
-
- logger.info("#######F_______@poll_users_list_last___@users_ids________________####{@poll_users_list.pluck(:user_id)}")
+ if order == "student_id"
+ @poll_users_list = @poll_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC")
+ else
+ @poll_users_list = @poll_users_list.order("end_at DESC")
+ end
+ logger.info("#######user_id: ####{@poll_users_list.pluck(:user_id).sort}")
@poll_users_size = @poll_users_list.count
@@ -1036,7 +1034,7 @@ class PollsController < ApplicationController
page = params[:page] || 1
limit = params[:limit] || 20
@poll_users_list = @poll_users_list.page(page).per(limit)
- logger.info("#######F_______@poll_users_list_after_page___@users_ids________________####{@poll_users_list.pluck(:user_id)}")
+ logger.info("#####page_user: #{@poll_users_list.pluck(:user_id).sort}")
else
@poll_users_list = []
@poll_users_size = 0
From 91d875c36b9bbab0a02b12cbd900b297f2cb861d Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 2 Jul 2019 15:01:20 +0800
Subject: [PATCH 38/80] =?UTF-8?q?=E6=89=93=E5=8D=B0=E6=97=A5=E5=BF=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/polls_controller.rb | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index d928d1df5..50784ee74 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -1024,9 +1024,9 @@ class PollsController < ApplicationController
if order == "student_id"
@poll_users_list = @poll_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC")
else
- @poll_users_list = @poll_users_list.order("end_at DESC")
+ @poll_users_list = @poll_users_list.joins(user: :user_extension).order("end_at DESC")
end
- logger.info("#######user_id: ####{@poll_users_list.pluck(:user_id).sort}")
+ logger.info("#######user_id: ####{@poll_users_list.pluck(:id, :user_id)}")
@poll_users_size = @poll_users_list.count
@@ -1034,7 +1034,7 @@ class PollsController < ApplicationController
page = params[:page] || 1
limit = params[:limit] || 20
@poll_users_list = @poll_users_list.page(page).per(limit)
- logger.info("#####page_user: #{@poll_users_list.pluck(:user_id).sort}")
+ logger.info("#####page_user: #{@poll_users_list.pluck(:id, :user_id)}")
else
@poll_users_list = []
@poll_users_size = 0
From 2b2257b181dc5dd2ce7e92547565f91da74b1112 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 15:16:24 +0800
Subject: [PATCH 39/80] fix bug
---
app/controllers/homework_commons_controller.rb | 3 ++-
app/controllers/polls_controller.rb | 11 ++++++-----
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb
index af1dffe71..2478633a1 100644
--- a/app/controllers/homework_commons_controller.rb
+++ b/app/controllers/homework_commons_controller.rb
@@ -186,7 +186,7 @@ class HomeworkCommonsController < ApplicationController
end
@work_count = @student_works.size
- @work_excel = @student_works
+ @work_excel = @student_works.includes(:student_works_scores)
@students = @course.students
# 分页参数
@@ -207,6 +207,7 @@ class HomeworkCommonsController < ApplicationController
tip_exception(403, "无权限操作")
else
if @work_excel.present?
+ @homework = @homework.includes()
student_work_to_xlsx(@work_excel,@homework)
exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index 6a8edee71..81e6cedaa 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -1005,11 +1005,6 @@ class PollsController < ApplicationController
if @poll_users_list.present? && @poll_users_list.count > 0
- if order == "student_id"
- @poll_users_list = @poll_users_list.joins(user: [:user_extension]).order("user_extensions.student_id DESC")
- else
- @poll_users_list = @poll_users_list.order("end_at DESC")
- end
#答题状态的选择
if choose_type.present?
@@ -1028,6 +1023,12 @@ class PollsController < ApplicationController
@poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%")
end
+ if order == "student_id"
+ @poll_users_list = @poll_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC")
+ else
+ @poll_users_list = @poll_users_list.order("end_at DESC")
+ end
+
logger.info("#######F_______@poll_users_list_last___@users_ids________________####{@poll_users_list.pluck(:user_id)}")
@poll_users_size = @poll_users_list.count
From 925ff7fd09d2319b8d71032e2879e852c218467a Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 15:21:10 +0800
Subject: [PATCH 40/80] fix bug
---
app/controllers/polls_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index a7e039944..84af9b584 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -1025,7 +1025,7 @@ class PollsController < ApplicationController
if order == "student_id"
@poll_users_list = @poll_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC")
else
- @poll_users_list = @poll_users_list.order("end_at DESC")
+ @poll_users_list = @poll_users_list.joins(user: :user_extension).order("end_at DESC")
end
logger.info("#######F_______@poll_users_list_last___@users_ids________________####{@poll_users_list.pluck(:user_id)}")
From bf8e88c39396931b0c2cc9cfc012403ecde67ea6 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 2 Jul 2019 15:28:57 +0800
Subject: [PATCH 41/80] =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/shixuns_controller.rb | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index 65d671856..3a4592b2f 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -405,11 +405,7 @@ class ShixunsController < ApplicationController
# 超级管理员和运营人员才能保存 中间层服务器pod信息的配置
if current_user.admin? || current_user.business?
@shixun.shixun_service_configs.destroy_all
- ActionController::Parameters.permit_all_parameters = true
- logger.info("##--;;;;---#{params[:shixun_service_configs]}")
- params[:shixun_service_configs].each do |config|
- @shixun.shixun_service_configs.create!(config)
- end
+ @shixun.shixun_service_configs.create!(service_config_params[:shixun_service_configs])
end
rescue Exception => e
uid_logger_error(e.message)
@@ -745,6 +741,11 @@ private
params.require(:shixun_info).permit(:description, :evaluate_script)
end
+
+ def service_config_params
+ params.permit(shixun_service_configs: [:cpu_limit, :lower_cpu_limit, :memory_limit, :request_limit, :mirror_repository_id])
+ end
+
def find_shixun
@shixun = Shixun.find_by_identifier(params[:identifier])
if @shixun.blank?
From c22ec7dff21c85adf3d6f11fcbbeb35213f5b851 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 2 Jul 2019 16:10:38 +0800
Subject: [PATCH 42/80] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=AD=9B=E9=80=89?=
=?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/models/repertoire.rb | 4 ++--
app/models/sub_repertoire.rb | 4 +++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/app/models/repertoire.rb b/app/models/repertoire.rb
index 400cef494..5c6ffebff 100644
--- a/app/models/repertoire.rb
+++ b/app/models/repertoire.rb
@@ -1,6 +1,6 @@
class Repertoire < ApplicationRecord
-
- has_many :sub_repertoires
+ default_scope :order => 'updated_at desc'
+ has_many :sub_repertoires, :dependent => :destroy, :order => "sub_repertoires.updated_at desc"
has_many :tag_repertoires, through: :sub_repertoires
end
diff --git a/app/models/sub_repertoire.rb b/app/models/sub_repertoire.rb
index d94db66c7..aa99494b1 100644
--- a/app/models/sub_repertoire.rb
+++ b/app/models/sub_repertoire.rb
@@ -1,3 +1,5 @@
class SubRepertoire < ApplicationRecord
- has_many :tag_repertoires
+ belongs_to :repertoire
+ has_many :tag_repertoires, :dependent => :destroy, :order => "tag_repertoires.updated_at desc"
+
end
From a53c20e02892d01ae72ffd514024ce879ed9a7f3 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 16:13:35 +0800
Subject: [PATCH 43/80] fix bug
---
app/controllers/exercises_controller.rb | 31 +++++++++++--------
.../homework_commons_controller.rb | 4 +--
app/controllers/polls_controller.rb | 30 ++++++++++++------
app/helpers/export_helper.rb | 4 +--
app/views/polls/commit_result.xlsx.axlsx | 8 ++---
5 files changed, 46 insertions(+), 31 deletions(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index a793c673c..18b8fbb2f 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1173,6 +1173,7 @@ class ExercisesController < ApplicationController
ActiveRecord::Base.transaction do
begin
@current_user_id = current_user.id
+ @exercise = @exercise.includes(:exercise_questions)
exercise_ids = [@exercise.id]
@exercise_status = @exercise.get_exercise_status(current_user.id)
@course_all_members = @course.students
@@ -1254,14 +1255,6 @@ class ExercisesController < ApplicationController
end
end
- if order == "student_id"
- @exercise_users_list = @exercise_users_list.joins(user: [:user_extension]).order("user_extensions.student_id DESC")
- elsif order == "score"
- @exercise_users_list = @exercise_users_list.order("#{order} DESC")
- else
- @exercise_users_list = @exercise_users_list.order("end_at DESC, start_at DESC")
- end
-
#答题状态的选择
if params[:commit_status].present?
choose_type = params[:commit_status]
@@ -1282,9 +1275,17 @@ class ExercisesController < ApplicationController
@exercise_users_list = @exercise_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
end
+ if order == "student_id"
+ @exercise_users_list = @exercise_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC")
+ elsif order == "score"
+ @exercise_users_list = @exercise_users_list.joins(user: :user_extension).order("#{order} DESC")
+ else
+ @exercise_users_list = @exercise_users_list.order("end_at DESC, start_at DESC")
+ end
+
@export_ex_users = @exercise_users_list
- @exercise_users_size = @exercise_users_list.count
+ @exercise_users_size = @exercise_users_list.size
# 分页
@page = params[:page] || 1
@@ -1296,10 +1297,14 @@ class ExercisesController < ApplicationController
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
else
- get_export_users(@exercise,@course,@export_ex_users)
- exercise_export_name =
- "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
- render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
+ if @exercise_users_size.size > 0
+ normal_status(-1,"暂无用户提交")
+ else
+ get_export_users(@exercise,@course,@export_ex_users)
+ exercise_export_name =
+ "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
+ render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
+ end
end
}
end
diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb
index 2478633a1..dc4d6b117 100644
--- a/app/controllers/homework_commons_controller.rb
+++ b/app/controllers/homework_commons_controller.rb
@@ -186,7 +186,7 @@ class HomeworkCommonsController < ApplicationController
end
@work_count = @student_works.size
- @work_excel = @student_works.includes(:student_works_scores)
+ @work_excel = @student_works.includes(:student_works_scores, user: :user_extension, myshixun: :games)
@students = @course.students
# 分页参数
@@ -207,7 +207,7 @@ class HomeworkCommonsController < ApplicationController
tip_exception(403, "无权限操作")
else
if @work_excel.present?
- @homework = @homework.includes()
+ @homework = @homework.includes(:shixuns,:homework_detail_manual)
student_work_to_xlsx(@work_excel,@homework)
exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index 84af9b584..151a2a098 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -18,7 +18,7 @@ class PollsController < ApplicationController
before_action :check_user_id_start_answer,only: [:start_answer]
before_action :check_poll_question_complete,only: [:commit_poll] #问卷提交前来判断问题是否完成
before_action :check_poll_commit_result,only: [:commit_result]
- before_action :get_all_polls_commit, only: [:commit_result] #该问卷全部的用户
+ # before_action :get_all_polls_commit, only: [:commit_result] #该问卷全部的用户
before_action :get_left_banner_id, only:[:common_header,:start_answer,:new,:edit,:index]
include PollsHelper
@@ -920,19 +920,32 @@ class PollsController < ApplicationController
def commit_result
ActiveRecord::Base.transaction do
begin
+ # @poll_questions = @poll.poll_questions.order("question_number ASC")
+ # 全部页面,需返回
+ # @poll_questions_count = @poll_questions.size
# 分页
+ @poll = @poll.includes(:poll_users,user: :user_extension,)
+ @poll_users = @poll.poll_users
+ @poll_commit_ids = @poll_users.commit_by_status(1).pluck(:user_id) #问卷提交用户的id
@page = params[:page] || 1
@limit = params[:limit] || 10
@poll_export_questions = @poll_questions.order("question_number ASC")
+
@poll_questions = @poll_questions.page(@page).per(@limit)
respond_to do |format|
format.json
format.xlsx{
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
+ elsif @poll_export_questions.size == 0 || (@poll_users.where("commit_status = ?",1).size == 0)
+ normal_status(-1,"暂时没有提交的用户")
else
- polls_export_name = current_user.real_name + "_" + @course.name + "_" + @poll.polls_name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
- render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {poll_questions:@poll_export_questions}
+ polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
+ render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {
+ poll_questions:@poll_export_questions,
+ poll:@poll,
+ poll_users: @poll_users,
+ poll_commit_ids:@poll_commit_ids}
end
}
end
@@ -1028,15 +1041,12 @@ class PollsController < ApplicationController
@poll_users_list = @poll_users_list.joins(user: :user_extension).order("end_at DESC")
end
- logger.info("#######F_______@poll_users_list_last___@users_ids________________####{@poll_users_list.pluck(:user_id)}")
-
@poll_users_size = @poll_users_list.count
# 分页
page = params[:page] || 1
limit = params[:limit] || 20
@poll_users_list = @poll_users_list.page(page).per(limit)
- logger.info("#####page_user: #{@poll_users_list.pluck(:id, :user_id)}")
else
@poll_users_list = []
@poll_users_size = 0
@@ -1146,10 +1156,10 @@ class PollsController < ApplicationController
def get_questions_count
@poll_questions = @poll.poll_questions&.includes(:poll_answers,:poll_votes).order("question_number ASC")
- @poll_questions_count = @poll_questions.count # 全部的题目数
- @poll_question_singles = @poll_questions.ques_count(1).all.count # 单选题
- @poll_question_doubles = @poll_questions.ques_count(2).all.count # 多选题
- @poll_question_mains = @poll_questions.ques_count(3).all.count #主观题
+ @poll_questions_count = @poll_questions.size # 全部的题目数
+ @poll_question_singles = @poll_questions.ques_count(1).all.size # 单选题
+ @poll_question_doubles = @poll_questions.ques_count(2).all.size # 多选题
+ @poll_question_mains = @poll_questions.ques_count(3).all.size #主观题
end
def check_poll_question_complete #commit_poll 的权限
diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb
index b6720c66c..211b31660 100644
--- a/app/helpers/export_helper.rb
+++ b/app/helpers/export_helper.rb
@@ -262,14 +262,14 @@ module ExportHelper
end
export_ex_users.each_with_index do |e_user,index|
user_info = e_user.user
- user_course_id = user_info.course_members.course_find_by_ids("course_id",course.id).first
+ user_course_id = user_info.course_members.course_find_by_ids("course_id",course.id)&.first
if user_course_id.present?
get_course_group_id = user_course_id.course_group_id
if get_course_group_id.present? && get_course_group_id != 0
user_course_info = CourseGroup.by_group_ids(get_course_group_id)
user_course = user_course_info.first.name
else
- user_course = "--"
+ user_course = "未分班"
end
else
user_course = "--"
diff --git a/app/views/polls/commit_result.xlsx.axlsx b/app/views/polls/commit_result.xlsx.axlsx
index 3ea0571cb..6ce00388c 100644
--- a/app/views/polls/commit_result.xlsx.axlsx
+++ b/app/views/polls/commit_result.xlsx.axlsx
@@ -9,7 +9,7 @@ wb.styles do |s|
sheet.sheet_view.show_grid_lines = false
poll_users_info = %w(序号)
poll_ques_titles = poll_questions.pluck(:question_title).map {|k| strip_export_title(k) if k.present?}
- poll_un_anony = @poll.un_anonymous
+ poll_un_anony = poll.un_anonymous
if poll_un_anony #是否匿名,默认为false
user_info = %w(登陆名 真实姓名 邮箱 学号)
else
@@ -18,13 +18,13 @@ wb.styles do |s|
poll_users_info = poll_users_info + user_info + poll_ques_titles
poll_questions.each do |q|
if q.question_type != 3 #问题不为主观题
- question_vote_user = q.poll_votes.find_current_vote("user_id",@poll_commit_ids).count #该问题的有效填写量
+ question_vote_user = q.poll_votes.find_current_vote("user_id",poll_commit_ids).count #该问题的有效填写量
sheet_row = ["第#{q.question_number}题"] #选择题答案选项的数组
sheet_answer_row = ["小计"] #选择题回答的答案人数,数组
sheet_answer_percent = ["比例"]
sheet_answer_useful = ["有效填写人次",question_vote_user]
q.poll_answers.each do |a| #问卷的答案选项
- answer_users_count = a.poll_votes.find_current_vote("user_id",@poll_commit_ids).count
+ answer_users_count = a.poll_votes.find_current_vote("user_id",poll_commit_ids).count
answer_percent = number_to_percentage((answer_users_count.to_f / question_vote_user.to_f)*100,precision:1)
sheet_row.push(a.answer_text)
sheet_answer_row.push(answer_users_count)
@@ -49,7 +49,7 @@ wb.styles do |s|
end #each_with_index
sheet.add_row poll_users_info, :height =>15, :style => blue_cell
- @poll.poll_users.each_with_index do |u,index|
+ poll_users.each_with_index do |u,index|
u_user = u.user
user_answer_array = []
poll_questions.each do |q|
From ad092d91e1b1ad5feb9d7256f0b988b07958775b Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 2 Jul 2019 16:14:17 +0800
Subject: [PATCH 44/80] =?UTF-8?q?=E6=8A=A5=E9=94=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/repertoire.rb | 2 +-
app/models/sub_repertoire.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/models/repertoire.rb b/app/models/repertoire.rb
index 5c6ffebff..995d52d0b 100644
--- a/app/models/repertoire.rb
+++ b/app/models/repertoire.rb
@@ -1,6 +1,6 @@
class Repertoire < ApplicationRecord
default_scope :order => 'updated_at desc'
- has_many :sub_repertoires, :dependent => :destroy, :order => "sub_repertoires.updated_at desc"
+ has_many :sub_repertoires, ->{order("sub_repertoires.updated_at desc")}, :dependent => :destroy
has_many :tag_repertoires, through: :sub_repertoires
end
diff --git a/app/models/sub_repertoire.rb b/app/models/sub_repertoire.rb
index aa99494b1..9f7079cfc 100644
--- a/app/models/sub_repertoire.rb
+++ b/app/models/sub_repertoire.rb
@@ -1,5 +1,5 @@
class SubRepertoire < ApplicationRecord
belongs_to :repertoire
- has_many :tag_repertoires, :dependent => :destroy, :order => "tag_repertoires.updated_at desc"
+ has_many :tag_repertoires, ->{order("tag_repertoires.updated_at desc")} ,:dependent => :destroy
end
From 2ab15ddf5c4eaa2c3e0c8c3ccb29080b563d51eb Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 2 Jul 2019 16:16:16 +0800
Subject: [PATCH 45/80] =?UTF-8?q?=E6=8A=A5=E9=94=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/repertoire.rb | 2 +-
app/models/sub_repertoire.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/models/repertoire.rb b/app/models/repertoire.rb
index 995d52d0b..5c37eb3b6 100644
--- a/app/models/repertoire.rb
+++ b/app/models/repertoire.rb
@@ -1,6 +1,6 @@
class Repertoire < ApplicationRecord
default_scope :order => 'updated_at desc'
- has_many :sub_repertoires, ->{order("sub_repertoires.updated_at desc")}, :dependent => :destroy
+ has_many :sub_repertoires, ->{order(updated_at: :desc)}, :dependent => :destroy
has_many :tag_repertoires, through: :sub_repertoires
end
diff --git a/app/models/sub_repertoire.rb b/app/models/sub_repertoire.rb
index 9f7079cfc..d6a6c1b3d 100644
--- a/app/models/sub_repertoire.rb
+++ b/app/models/sub_repertoire.rb
@@ -1,5 +1,5 @@
class SubRepertoire < ApplicationRecord
belongs_to :repertoire
- has_many :tag_repertoires, ->{order("tag_repertoires.updated_at desc")} ,:dependent => :destroy
+ has_many :tag_repertoires, ->{order(updated_at: :desc)} ,:dependent => :destroy
end
From 91661cbee857109803c17d6a917a64c1f10d1f35 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 2 Jul 2019 16:18:08 +0800
Subject: [PATCH 46/80] =?UTF-8?q?=E6=8A=A5=E9=94=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/repertoire.rb | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/models/repertoire.rb b/app/models/repertoire.rb
index 5c37eb3b6..d76a022c5 100644
--- a/app/models/repertoire.rb
+++ b/app/models/repertoire.rb
@@ -1,5 +1,4 @@
class Repertoire < ApplicationRecord
- default_scope :order => 'updated_at desc'
has_many :sub_repertoires, ->{order(updated_at: :desc)}, :dependent => :destroy
has_many :tag_repertoires, through: :sub_repertoires
From 03797ce1fa82333ab085c58d0a0327425c6c973a Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 16:51:27 +0800
Subject: [PATCH 47/80] ifx bug
---
app/controllers/exercises_controller.rb | 4 ++--
app/controllers/polls_controller.rb | 2 +-
app/controllers/zips_controller.rb | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index 18b8fbb2f..b3cf1f0be 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1173,7 +1173,7 @@ class ExercisesController < ApplicationController
ActiveRecord::Base.transaction do
begin
@current_user_id = current_user.id
- @exercise = @exercise.includes(:exercise_questions)
+ @exercise = @exercise
exercise_ids = [@exercise.id]
@exercise_status = @exercise.get_exercise_status(current_user.id)
@course_all_members = @course.students
@@ -1297,7 +1297,7 @@ class ExercisesController < ApplicationController
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
else
- if @exercise_users_size.size > 0
+ if @exercise_users_size == 0
normal_status(-1,"暂无用户提交")
else
get_export_users(@exercise,@course,@export_ex_users)
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index 151a2a098..eb03345e7 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -924,7 +924,7 @@ class PollsController < ApplicationController
# 全部页面,需返回
# @poll_questions_count = @poll_questions.size
# 分页
- @poll = @poll.includes(:poll_users,user: :user_extension,)
+ # @poll = @poll.includes(:poll_users,user: :user_extension)
@poll_users = @poll.poll_users
@poll_commit_ids = @poll_users.commit_by_status(1).pluck(:user_id) #问卷提交用户的id
@page = params[:page] || 1
diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb
index c20546701..a70d4c332 100644
--- a/app/controllers/zips_controller.rb
+++ b/app/controllers/zips_controller.rb
@@ -62,7 +62,7 @@ class ZipsController < ApplicationController
if default_ex_users_size == 0
normal_status(-1,"导出失败,暂时没有已提交的学生")
elsif default_ex_users_size > 100
- normal_status(-1,"导出数量超过100,请分班导出或联系网站管理员导出")
+ normal_status(-2,"100")
end
end
rescue Exception => e
From df714555fcf1aead83378154a8d66031fef3cd6c Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 2 Jul 2019 17:07:23 +0800
Subject: [PATCH 48/80] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=85=B3=E5=8D=A1?=
=?UTF-8?q?=E6=A0=87=E7=AD=BE=E7=9A=84model=E5=85=B3=E7=B3=BB=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/challenge_tag.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/models/challenge_tag.rb b/app/models/challenge_tag.rb
index 6f176cc67..83b743adc 100644
--- a/app/models/challenge_tag.rb
+++ b/app/models/challenge_tag.rb
@@ -1,5 +1,5 @@
class ChallengeTag < ApplicationRecord
belongs_to :challenge, counter_cache: true
- belongs_to :challenge_choose
+ belongs_to :challenge_choose, optional: true
end
From 178a448f54d0bacd20f7cff301bcea605231985d Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 2 Jul 2019 17:08:38 +0800
Subject: [PATCH 49/80] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E5=88=97=E8=A1=A8?=
=?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=88=90=E7=BB=A9=E7=9A=84=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/courses_controller.rb | 72 +++++++++----------
.../graduation_tasks_controller.rb | 2 +-
.../homework_commons_controller.rb | 2 +-
app/helpers/export_helper.rb | 22 ++----
app/models/exercise.rb | 3 +-
app/models/graduation_task.rb | 3 +-
app/models/graduation_work.rb | 2 +-
app/models/homework_common.rb | 3 +-
app/models/poll.rb | 2 +-
9 files changed, 48 insertions(+), 63 deletions(-)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index cef2a1785..bae37d92a 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -969,22 +969,17 @@ class CoursesController < ApplicationController
@all_members = @course.students
end
if name.present?
- nick_name_search = @all_members.joins(:user).where("nickname like ?","%#{name}%")
- if nick_name_search.present?
- @all_members = nick_name_search
- else
- @all_members = @all_members.joins(user: [:user_extension]).where('user_extensions.student_id like ? OR user_extensions.student_realname like ?',"%#{name}%","%#{name}%")
- end
+ @all_members = @all_members.joins(user: [:user_extension]).where('concat(users.lastname, users.firstname) like ? or user_extensions.student_id like ?',"%#{name}%","%#{name}%")
end
- @c_homeworks = @course.homework_commons.homework_published.order("publish_time asc, created_at asc")
- @c_exercises = @course.exercises.is_exercise_published.order("publish_time asc, created_at asc")
- @c_polls = @course.polls.publish_or_not.order("publish_time asc, created_at asc")
- @c_tasks = @course.graduation_tasks.task_published.order("publish_time asc, created_at asc")
+ @c_homeworks = @course.homework_commons.homework_published.order("homework_commons.publish_time asc, homework_commons.created_at asc")
+ @c_exercises = @course.exercises.is_exercise_published.order("exercises.publish_time asc, exercises.created_at asc")
+ @c_polls = @course.polls.publish_or_not.order("polls.publish_time asc, polls.created_at asc")
+ @c_tasks = @course.graduation_tasks.task_published.order("graduation_tasks.publish_time asc, graduation_tasks.created_at asc")
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
else
- member_to_xlsx(@course,@all_members,@c_homeworks,@c_exercises,@c_tasks,@c_polls)
+ member_to_xlsx(@course, @all_members, @c_homeworks, @c_exercises, @c_tasks, @c_polls)
filename = current_user.real_name + "_" + @course.name + "_全部成绩" + Time.now.strftime('%Y%m%d_%H%M%S')
render xlsx: "#{filename.strip.first(30)}",template: "courses/export_member_scores_excel.xlsx.axlsx",
locals: {course_info:@course_info, activity_level:@user_activity_level,
@@ -1058,14 +1053,14 @@ class CoursesController < ApplicationController
def member_to_xlsx(course,all_members,homeworks,exercises,tasks,polls)
#课堂的作业信息
- shixun_homeworks = homeworks.search_homework_type(4) #全部实训作业
+ shixun_homeworks = homeworks.search_homework_type(4).includes(:score_student_works) #全部实训作业
shixun_titles = shixun_homeworks.pluck(:name) + ["总得分"]
- common_homeworks = homeworks.search_homework_type(1) #全部普通作业
+ common_homeworks = homeworks.search_homework_type(1).includes(:score_student_works) #全部普通作业
common_titles = common_homeworks.pluck(:name)+ ["总得分"]
- group_homeworks = homeworks.search_homework_type(3) #全部分组作业
+ group_homeworks = homeworks.search_homework_type(3).includes(:score_student_works) #全部分组作业
group_titles = group_homeworks.pluck(:name)+ ["总得分"]
- task_titles = tasks.pluck(:name)+ ["总得分"]
- exercise_titles = exercises.pluck(:exercise_name)+ ["总得分"]
+ task_titles = tasks.includes(:score_graduation_works).pluck(:name) + ["总得分"]
+ exercise_titles = exercises.includes(:score_exercise_users).pluck(:exercise_name) + ["总得分"]
total_user_score_array = [] #学生总成绩集合
#课堂信息
@@ -1114,7 +1109,7 @@ class CoursesController < ApplicationController
course_user_level = []
course_activity_title = "课堂活跃度统计"
user_cell_head = %w(排名 真实姓名 登录名 邮箱 学号 分班 作业完成数(*10) 试卷完成数(*10) 问卷完成数(*7) 资源发布数(*5) 帖子发布数(*2) 帖子回复数(*1) 作业回复数(*1) 活跃度)
- all_members.each do |u|
+ all_members.includes(user: :user_extension).each do |u|
#用户的基本信息
user = u.user
user_login = user.login
@@ -1174,12 +1169,11 @@ class CoursesController < ApplicationController
#实训作业
if shixun_homeworks.count > 0
shixun_homeworks.each do |s|
- user_student_work = s.student_works.homework_by_user(user.id) #当前用户的对该作业的回答
- if user_student_work.blank?
+ user_student_work = s.score_student_works.find_by_user_id(user.id) #当前用户的对该作业的回答
+ if user_student_work.nil?
h_score = 0.0 #该作业的得分为0
else
- user_stu_work = user_student_work.first
- h_score = user_stu_work.work_score.nil? ? 0.0 : user_stu_work.work_score #用户对该作业的分数
+ h_score = user_student_work.work_score.nil? ? 0.0 : user_student_work.work_score #用户对该作业的分数
end
shixun_score_array.push(h_score)
end
@@ -1191,12 +1185,11 @@ class CoursesController < ApplicationController
#普通作业
if common_homeworks.count > 0
common_homeworks.each do |c|
- user_student_work_1 = c.student_works.homework_by_user(user.id) #当前用户的对该作业的回答
- if user_student_work_1.blank?
+ user_student_work_1 = c.score_student_works.find_by_user_id(user.id) #当前用户的对该作业的回答
+ if user_student_work_1.nil?
h_score_1 = 0.0 #该作业的得分为0
else
- user_stu_work_1 = user_student_work_1.first
- h_score_1 = user_stu_work_1.work_score.nil? ? 0.0 : user_stu_work_1.work_score #用户对该作业的分数
+ h_score_1 = user_student_work_1.work_score.nil? ? 0.0 : user_student_work_1.work_score #用户对该作业的分数
end
common_score_array.push(h_score_1)
end
@@ -1208,12 +1201,11 @@ class CoursesController < ApplicationController
#分组作业
if group_homeworks.count > 0
group_homeworks.each do |g|
- user_student_work_3 = g.student_works.homework_by_user(user.id) #当前用户的对该作业的回答
- if user_student_work_3.blank?
+ user_student_work_3 = g.score_student_works.find_by_user_id(user.id) #当前用户的对该作业的回答
+ if user_student_work_3.nil?
h_score_3 = 0.0 #该作业的得分为0
else
- user_stu_work_3 = user_student_work_3.first
- h_score_3 = user_stu_work_3.work_score.nil? ? 0.0 : user_stu_work_3.work_score #用户对该作业的分数
+ h_score_3 = user_student_work_3.work_score.nil? ? 0.0 : user_student_work_3.work_score #用户对该作业的分数
end
group_score_array.push(h_score_3)
end
@@ -1225,11 +1217,11 @@ class CoursesController < ApplicationController
#毕设作业
if tasks.count > 0
tasks.each do |task|
- graduation_works = task.graduation_works.find_by_task_user(user.id)
- if graduation_works.empty?
+ graduation_work = task.score_graduation_works.find_by_user_id(user.id)
+ if graduation_work.nil?
t_score = 0.0
else
- t_score = graduation_works.first.work_score.nil? ? 0.0 : graduation_works.first.work_score
+ t_score = graduation_work.work_score.nil? ? 0.0 : graduation_work.work_score
end
task_score_array.push(t_score)
end
@@ -1241,11 +1233,11 @@ class CoursesController < ApplicationController
#试卷
if exercises.count > 0
exercises.each do |ex|
- exercise_works = ex.exercise_users.exercise_commit_users(user.id)
- if exercise_works.empty?
+ exercise_work = ex.score_exercise_users.find_by_user_id(user.id)
+ if exercise_work.nil?
e_score = 0.0
else
- e_score = exercise_works.first.score.nil? ? 0.0 : exercise_works.first.score
+ e_score = exercise_work.score.nil? ? 0.0 : exercise_work.score
end
exercise_score_array.push(e_score)
end
@@ -1285,7 +1277,7 @@ class CoursesController < ApplicationController
#实训作业
if count_1 > 0
shixun_homeworks.each_with_index do |s,index|
- all_student_works = s.student_works.has_committed.order("work_score desc") #该实训题的全部用户回答
+ all_student_works = s.score_student_works #该实训题的全部用户回答
title_no = index.to_i + 1
student_work_to_xlsx(all_student_works,s)
shixun_work_display_name = (title_no.to_s + "." + s.name).strip.first(30)
@@ -1297,7 +1289,7 @@ class CoursesController < ApplicationController
#普通作业
if count_2 > 0
common_homeworks.each_with_index do |c,index|
- all_student_works = c.student_works.has_committed.order("work_score desc") #当前用户的对该作业的回答
+ all_student_works = c.score_student_works #当前用户的对该作业的回答
title_no = count_1 + index.to_i + 1
student_work_to_xlsx(all_student_works,c)
@@ -1311,7 +1303,7 @@ class CoursesController < ApplicationController
#分组作业
if count_3 > 0
group_homeworks.each_with_index do |c,index|
- all_student_works = c.student_works.has_committed.order("work_score desc") #当前用户的对该作业的回答
+ all_student_works = c.score_student_works #当前用户的对该作业的回答
title_no = count_1 + count_2 + index.to_i + 1
student_work_to_xlsx(all_student_works,c)
work_name = (title_no.to_s + "." + c.name).strip.first(30)
@@ -1323,7 +1315,7 @@ class CoursesController < ApplicationController
#毕设任务
if count_4 > 0
tasks.each_with_index do |c,index|
- all_student_works = c.graduation_works.has_committed.order("work_score desc") #当前用户的对该作业的回答
+ all_student_works = c.score_graduation_works #当前用户的对该作业的回答
title_no = count_1 + count_2 + count_3 + index.to_i + 1
graduation_work_to_xlsx(all_student_works,c,current_user)
work_name = (title_no.to_s + "." + c.name).strip.first(30)
@@ -1336,7 +1328,7 @@ class CoursesController < ApplicationController
#试卷的导出
if count_5 > 0
exercises.each_with_index do |c,index|
- all_student_works = c.exercise_users.exercise_user_committed #当前用户的对该作业的回答
+ all_student_works = c.score_exercise_users #当前用户的对该作业的回答
title_no = count_1 + count_2 + count_3 + count_4 + index.to_i + 1
get_export_users(c,course,all_student_works)
work_name = (title_no.to_s + "." + c.exercise_name).strip.first(30)
diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb
index 454f23c81..41ddb7659 100644
--- a/app/controllers/graduation_tasks_controller.rb
+++ b/app/controllers/graduation_tasks_controller.rb
@@ -145,7 +145,7 @@ class GraduationTasksController < ApplicationController
file = decode64(zipfile[0][:base64file])
send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
else
- tip_exception(status == -1 ? "文件大小超过500M,请通过微信或者QQ联系管理员辅助您打包下载" : "无附件可下载")
+ tip_exception(status == -2 ? "500" : "无附件可下载")
end
end
}
diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb
index af1dffe71..ca8d6364d 100644
--- a/app/controllers/homework_commons_controller.rb
+++ b/app/controllers/homework_commons_controller.rb
@@ -229,7 +229,7 @@ class HomeworkCommonsController < ApplicationController
file = decode64(zipfile[0][:base64file])
send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
else
- tip_exception(status == -1 ? "文件大小超过500M,请通过微信或者QQ联系管理员辅助您打包下载" : "无附件可下载")
+ tip_exception(status == -2 ? "500M" : "无附件可下载")
end
end
}
diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb
index b6720c66c..31fadc265 100644
--- a/app/helpers/export_helper.rb
+++ b/app/helpers/export_helper.rb
@@ -37,7 +37,7 @@ module ExportHelper
end
normal_head_b_cells = %w(最终成绩 提交时间 更新时间 评语)
@work_head_cells = (head_cells_format + group_cells + normal_head_cells + head_cells_add + allow_late_cell + normal_head_b_cells).reject(&:blank?)
- works.each_with_index do |w, index|
+ works.includes(student_works_scores: :user).each_with_index do |w, index|
w_user = w.user
w_1 = (index + 1)
w_2 = w_user.login
@@ -118,7 +118,7 @@ module ExportHelper
end
shixun_time_cells = %w(最终成绩 更新时间 提交耗时 评语)
@work_head_cells = (head_cells_format + shixun_head_cells + eff_score_cell + shixun_time_cells).reject(&:blank?)
- works.each_with_index do |w, index|
+ works.includes(:myshixun).each_with_index do |w, index|
myshixun = w.try(:myshixun)
w_user = w.user
w_1 = (index + 1)
@@ -262,18 +262,8 @@ module ExportHelper
end
export_ex_users.each_with_index do |e_user,index|
user_info = e_user.user
- user_course_id = user_info.course_members.course_find_by_ids("course_id",course.id).first
- if user_course_id.present?
- get_course_group_id = user_course_id.course_group_id
- if get_course_group_id.present? && get_course_group_id != 0
- user_course_info = CourseGroup.by_group_ids(get_course_group_id)
- user_course = user_course_info.first.name
- else
- user_course = "--"
- end
- else
- user_course = "--"
- end
+ member = course.students.find_by_user_id(e_user.user_id)
+ user_course = member.try(:course_group_name)
user_obj_score = e_user.objective_score < 0.0 ? 0.0 : e_user.objective_score.round(1).to_s
user_suj_score = e_user.subjective_score < 0.0 ? 0.0 : e_user.subjective_score.round(1).to_s
user_score = e_user.score.present? ? e_user.score.round(1).to_s : 0.0
@@ -375,11 +365,11 @@ module ExportHelper
end
if file_size > MAX_DOWN_SIZE
- status = -1
+ status = -2
elsif file_count > 0
status = 0
else
- status = -2
+ status = -1
end
status
end
diff --git a/app/models/exercise.rb b/app/models/exercise.rb
index 60409e51d..ed003286b 100644
--- a/app/models/exercise.rb
+++ b/app/models/exercise.rb
@@ -3,7 +3,8 @@ class Exercise < ApplicationRecord
belongs_to :exercise_bank, optional: true
belongs_to :user
- has_many :exercise_users, :dependent => :delete_all
+ has_many :exercise_users, -> { where("is_delete = 0") }, :dependent => :delete_all
+ has_many :score_exercise_users, -> { where("is_delete = 0 and commit_status != 0").order("score desc") }, class_name: "ExerciseUser"
has_many :exercise_questions, :dependent => :delete_all
has_many :exercise_group_settings, :dependent => :delete_all
has_many :tidings, as: :container
diff --git a/app/models/graduation_task.rb b/app/models/graduation_task.rb
index d85f9782d..030978817 100644
--- a/app/models/graduation_task.rb
+++ b/app/models/graduation_task.rb
@@ -16,7 +16,8 @@ class GraduationTask < ApplicationRecord
has_many :graduation_task_group_assignations, dependent: :destroy
has_many :graduation_work_comment_assignations, dependent: :destroy
- has_many :graduation_works, -> { where("is_delete != 1") }
+ has_many :graduation_works, -> { where("is_delete = 0") }
+ has_many :score_graduation_works, -> { where("is_delete = 0 and work_status != 0").order("work_score desc") }, class_name: "GraduationWork"
has_many :graduation_work_scores
belongs_to :gtask_bank, optional: true
diff --git a/app/models/graduation_work.rb b/app/models/graduation_work.rb
index e9be0a43e..093e409a9 100644
--- a/app/models/graduation_work.rb
+++ b/app/models/graduation_work.rb
@@ -53,7 +53,7 @@ class GraduationWork < ApplicationRecord
# 分班名
def class_grouping_name
- CourseMember.find_by(user_id: self.user_id, course_id: self.course_id, role: 4).try(:course_group).try(:name) || '未分班'
+ CourseMember.find_by(course_id: self.course_id, user_id: self.user_id, role: 4).try(:course_group).try(:name) || '未分班'
end
# 分组名
diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb
index 3e0bec5fe..193d9aa6c 100644
--- a/app/models/homework_common.rb
+++ b/app/models/homework_common.rb
@@ -3,7 +3,8 @@ class HomeworkCommon < ApplicationRecord
enum homework_type: { normal: 1, program: 2, group: 3, practice: 4 }, _suffix: true
has_many :homework_group_settings, dependent: :destroy
has_many :published_settings, -> { group_published }, class_name: "HomeworkGroupSetting"
- has_many :student_works, -> { where("is_delete != 1") }
+ has_many :student_works, -> { where("is_delete = 0") }
+ has_many :score_student_works, -> { where("is_delete = 0 and work_status != 0").order("work_score desc") }, class_name: "StudentWork"
has_one :homework_detail_manual, dependent: :destroy
# 分组作业的设置
diff --git a/app/models/poll.rb b/app/models/poll.rb
index f72239ba7..1920dd939 100644
--- a/app/models/poll.rb
+++ b/app/models/poll.rb
@@ -5,7 +5,7 @@ class Poll < ApplicationRecord
# belongs_to :exercise_bank
has_many :poll_questions,dependent: :delete_all
- has_many :poll_users, :dependent => :delete_all
+ has_many :poll_users, -> { where("is_delete != 1") }, :dependent => :delete_all
has_many :users, :through => :poll_users #该文件被哪些用户提交答案过
has_many :poll_group_settings, :dependent => :delete_all
has_many :course_acts, class_name: 'CourseActivity', as: :course_act, dependent: :delete_all
From 8f2be183f6885306961d41ff118198f6286458c6 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 17:11:46 +0800
Subject: [PATCH 50/80] fix bug
---
app/controllers/exercises_controller.rb | 15 +++++++++------
app/controllers/polls_controller.rb | 13 +++++--------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index b3cf1f0be..1d81ed4c2 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1173,7 +1173,7 @@ class ExercisesController < ApplicationController
ActiveRecord::Base.transaction do
begin
@current_user_id = current_user.id
- @exercise = @exercise
+ @exercise = @exercise.joins(:exercise_questions,:exercise_users)
exercise_ids = [@exercise.id]
@exercise_status = @exercise.get_exercise_status(current_user.id)
@course_all_members = @course.students
@@ -1271,16 +1271,17 @@ class ExercisesController < ApplicationController
#搜索
if params[:search].present?
-
@exercise_users_list = @exercise_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
end
+ exercise_user_joins = @exercise_users_list.joins(user: :user_extension)
+
if order == "student_id"
- @exercise_users_list = @exercise_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC")
+ @exercise_users_list = exercise_user_joins.order("user_extensions.student_id DESC")
elsif order == "score"
- @exercise_users_list = @exercise_users_list.joins(user: :user_extension).order("#{order} DESC")
+ @exercise_users_list = exercise_user_joins.order("#{order} DESC")
else
- @exercise_users_list = @exercise_users_list.order("end_at DESC, start_at DESC")
+ @exercise_users_list = exercise_user_joins.order("end_at DESC, start_at DESC")
end
@export_ex_users = @exercise_users_list
@@ -1297,9 +1298,11 @@ class ExercisesController < ApplicationController
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
else
- if @exercise_users_size == 0
+ if @export_ex_users.exercise_user_committed.size == 0
normal_status(-1,"暂无用户提交")
else
+ @exercise = @exercise.includes(:exercise_questions)
+ @export_ex_users = @export_ex_users.joins(user: :user_extension)
get_export_users(@exercise,@course,@export_ex_users)
exercise_export_name =
"#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index eb03345e7..44cdc6512 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -920,11 +920,6 @@ class PollsController < ApplicationController
def commit_result
ActiveRecord::Base.transaction do
begin
- # @poll_questions = @poll.poll_questions.order("question_number ASC")
- # 全部页面,需返回
- # @poll_questions_count = @poll_questions.size
- # 分页
- # @poll = @poll.includes(:poll_users,user: :user_extension)
@poll_users = @poll.poll_users
@poll_commit_ids = @poll_users.commit_by_status(1).pluck(:user_id) #问卷提交用户的id
@page = params[:page] || 1
@@ -937,7 +932,7 @@ class PollsController < ApplicationController
format.xlsx{
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
- elsif @poll_export_questions.size == 0 || (@poll_users.where("commit_status = ?",1).size == 0)
+ elsif (@poll.polls_status == 1) || (@poll_export_questions.size == 0) || (@poll_commit_ids.size == 0)
normal_status(-1,"暂时没有提交的用户")
else
polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
@@ -1035,10 +1030,12 @@ class PollsController < ApplicationController
@poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%")
end
+ poll_users_joins = @poll_users_list.joins(user: :user_extension)
+
if order == "student_id"
- @poll_users_list = @poll_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC")
+ @poll_users_list = poll_users_joins.order("user_extensions.student_id DESC")
else
- @poll_users_list = @poll_users_list.joins(user: :user_extension).order("end_at DESC")
+ @poll_users_list = poll_users_joins.order("end_at DESC")
end
@poll_users_size = @poll_users_list.count
From 35b91d96d896e57ee9d07e598fbefc8e1cdbf5f7 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 17:15:44 +0800
Subject: [PATCH 51/80] fix bug
---
app/controllers/exercises_controller.rb | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index 1d81ed4c2..d19de52c4 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1173,7 +1173,6 @@ class ExercisesController < ApplicationController
ActiveRecord::Base.transaction do
begin
@current_user_id = current_user.id
- @exercise = @exercise.joins(:exercise_questions,:exercise_users)
exercise_ids = [@exercise.id]
@exercise_status = @exercise.get_exercise_status(current_user.id)
@course_all_members = @course.students
@@ -1302,7 +1301,7 @@ class ExercisesController < ApplicationController
normal_status(-1,"暂无用户提交")
else
@exercise = @exercise.includes(:exercise_questions)
- @export_ex_users = @export_ex_users.joins(user: :user_extension)
+ @export_ex_users = @export_ex_users.includes(user: :user_extension)
get_export_users(@exercise,@course,@export_ex_users)
exercise_export_name =
"#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
From 7a9a78d918390aa84854347ecca19ec296fd70dc Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 2 Jul 2019 17:34:21 +0800
Subject: [PATCH 52/80] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/courses_controller.rb | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index bae37d92a..2d379b555 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -1169,7 +1169,7 @@ class CoursesController < ApplicationController
#实训作业
if shixun_homeworks.count > 0
shixun_homeworks.each do |s|
- user_student_work = s.score_student_works.find_by_user_id(user.id) #当前用户的对该作业的回答
+ user_student_work = s.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答
if user_student_work.nil?
h_score = 0.0 #该作业的得分为0
else
@@ -1185,7 +1185,7 @@ class CoursesController < ApplicationController
#普通作业
if common_homeworks.count > 0
common_homeworks.each do |c|
- user_student_work_1 = c.score_student_works.find_by_user_id(user.id) #当前用户的对该作业的回答
+ user_student_work_1 = c.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答
if user_student_work_1.nil?
h_score_1 = 0.0 #该作业的得分为0
else
@@ -1201,7 +1201,7 @@ class CoursesController < ApplicationController
#分组作业
if group_homeworks.count > 0
group_homeworks.each do |g|
- user_student_work_3 = g.score_student_works.find_by_user_id(user.id) #当前用户的对该作业的回答
+ user_student_work_3 = g.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答
if user_student_work_3.nil?
h_score_3 = 0.0 #该作业的得分为0
else
@@ -1217,7 +1217,7 @@ class CoursesController < ApplicationController
#毕设作业
if tasks.count > 0
tasks.each do |task|
- graduation_work = task.score_graduation_works.find_by_user_id(user.id)
+ graduation_work = task.score_graduation_works.select{|work| work.user_id == user.id}.first
if graduation_work.nil?
t_score = 0.0
else
@@ -1233,7 +1233,7 @@ class CoursesController < ApplicationController
#试卷
if exercises.count > 0
exercises.each do |ex|
- exercise_work = ex.score_exercise_users.find_by_user_id(user.id)
+ exercise_work = ex.score_exercise_users.select{|work| work.user_id == user.id}.first
if exercise_work.nil?
e_score = 0.0
else
From 254a643b4f8ab7eb2145726813c01bfdb4fbcd7b Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Tue, 2 Jul 2019 18:10:08 +0800
Subject: [PATCH 53/80] fix bug
---
app/controllers/exercises_controller.rb | 2 --
.../graduation_tasks_controller.rb | 10 ++++--
.../homework_commons_controller.rb | 3 +-
app/controllers/zips_controller.rb | 19 +++++++---
.../batch_export_shixun_report_service.rb | 36 ++++++++++---------
5 files changed, 43 insertions(+), 27 deletions(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index d19de52c4..79bed2d25 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1300,8 +1300,6 @@ class ExercisesController < ApplicationController
if @export_ex_users.exercise_user_committed.size == 0
normal_status(-1,"暂无用户提交")
else
- @exercise = @exercise.includes(:exercise_questions)
- @export_ex_users = @export_ex_users.includes(user: :user_extension)
get_export_users(@exercise,@course,@export_ex_users)
exercise_export_name =
"#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb
index 41ddb7659..1931c26a0 100644
--- a/app/controllers/graduation_tasks_controller.rb
+++ b/app/controllers/graduation_tasks_controller.rb
@@ -129,9 +129,13 @@ class GraduationTasksController < ApplicationController
if @user_course_identity >= Course::STUDENT
tip_exception(403, "无权限操作")
else
- graduation_work_to_xlsx(@work_excel,@task,current_user)
- exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @task.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
- render xlsx: "#{exercise_export_name.strip.first(30)}",template: "graduation_tasks/tasks_list.xlsx.axlsx",locals: {table_columns:@head_cells_column, task_users:@task_cells_column}
+ if @work_count > 1
+ graduation_work_to_xlsx(@work_excel,@task,current_user)
+ exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@task.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
+ render xlsx: "#{exercise_export_name.strip.first(30)}",template: "graduation_tasks/tasks_list.xlsx.axlsx",locals: {table_columns:@head_cells_column, task_users:@task_cells_column}
+ else
+ normal_status(-1,"暂无提交的学生!")
+ end
end
}
format.zip{
diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb
index b3953c7dd..89e301f93 100644
--- a/app/controllers/homework_commons_controller.rb
+++ b/app/controllers/homework_commons_controller.rb
@@ -206,8 +206,7 @@ class HomeworkCommonsController < ApplicationController
if @user_course_identity >= Course::STUDENT
tip_exception(403, "无权限操作")
else
- if @work_excel.present?
- @homework = @homework.includes(:shixuns,:homework_detail_manual)
+ if @work_count > 1
student_work_to_xlsx(@work_excel,@homework)
exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb
index a70d4c332..e88f4d552 100644
--- a/app/controllers/zips_controller.rb
+++ b/app/controllers/zips_controller.rb
@@ -6,9 +6,11 @@ class ZipsController < ApplicationController
before_action :require_admin_or_teacher
def shixun_report
- student_work_ids = Array.wrap(params[:student_work_ids])
+ # student_work_ids = Array.wrap(params[:student_work_ids])
+
+ # service = BatchExportShixunReportService.new(@homework, @student_work_ids)
+ service = BatchExportShixunReportService.new(@homework, @all_student_works)
- service = BatchExportShixunReportService.new(@homework, student_work_ids)
filename = filename_for_content_disposition(service.filename)
send_file service.zip, filename: filename, type: 'application/zip'
@@ -57,9 +59,9 @@ class ZipsController < ApplicationController
@ex_users = @ex_users.where(user_id: user_ids)
end
- default_ex_users_size = @ex_users.size
+ default_ex_users_size = @ex_users&.size
- if default_ex_users_size == 0
+ if default_ex_users_size.blank? || default_ex_users_size == 0
normal_status(-1,"导出失败,暂时没有已提交的学生")
elsif default_ex_users_size > 100
normal_status(-2,"100")
@@ -75,5 +77,14 @@ class ZipsController < ApplicationController
def load_homework
@homework = HomeworkCommon.find(params[:homework_common_id])
@course = @homework.course
+ ##7。2 -hs新增
+ @member = @course.course_member(current_user.id)
+ @all_student_works = @homework.teacher_works(@member)
+ student_work_sizes = @all_student_works&.size
+ if student_work_sizes.blank? || student_work_sizes == 0
+ normal_status(-1,"导出失败,暂时没有已提交的学生")
+ elsif student_work_sizes > 100
+ normal_status(-2,"100")
+ end
end
end
diff --git a/app/services/batch_export_shixun_report_service.rb b/app/services/batch_export_shixun_report_service.rb
index 6ea38b23f..ebb273a87 100644
--- a/app/services/batch_export_shixun_report_service.rb
+++ b/app/services/batch_export_shixun_report_service.rb
@@ -3,11 +3,15 @@ class BatchExportShixunReportService
MAX_BATCH_LIMIT = 20
- attr_reader :homework, :student_work_ids
+ # attr_reader :homework, :student_work_ids
+ attr_reader :homework, :all_student_works
- def initialize(homework, student_work_ids)
+
+ def initialize(homework, all_student_works)
@homework = homework
- @student_work_ids = student_work_ids
+ # @student_work_ids = student_work_ids
+ @all_student_works = all_student_works
+
end
def filename
@@ -15,8 +19,8 @@ class BatchExportShixunReportService
end
def zip
- validate!
- student_works = homework.student_works.where(id: student_work_ids).includes(:myshixun, user: :user_extension)
+ # validate!
+ student_works = all_student_works.includes(:myshixun, user: :user_extension)
if student_works.count.zero?
raise Error, '请选择要导出的学生实训报告'
@@ -41,15 +45,15 @@ class BatchExportShixunReportService
end
end
- private
-
- def validate!
- if student_work_ids.size.zero?
- raise Error, '请选择学生实训作业'
- end
-
- if student_work_ids.size > MAX_BATCH_LIMIT
- raise Error, '导出实训报告太多,请分批导出'
- end
- end
+ # private
+ #
+ # def validate!
+ # if student_work_ids.size.zero?
+ # raise Error, '请选择学生实训作业'
+ # end
+ #
+ # if student_work_ids.size > MAX_BATCH_LIMIT
+ # raise Error, '导出实训报告太多,请分批导出'
+ # end
+ # end
end
From 74e613e8045c063c235220e936b9a239c160ee2a Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 3 Jul 2019 09:21:08 +0800
Subject: [PATCH 54/80] =?UTF-8?q?pdf=E6=89=B9=E9=87=8F=E5=AF=BC=E5=87=BA?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=AD=9B=E9=80=89=E5=8F=82=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/zips_controller.rb | 43 +++++++++++++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)
diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb
index e88f4d552..984bef6d2 100644
--- a/app/controllers/zips_controller.rb
+++ b/app/controllers/zips_controller.rb
@@ -49,9 +49,26 @@ class ZipsController < ApplicationController
normal_status(-1,"试卷不存在")
else
@course = @exercise.course
-
default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed
@ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。
+
+ #是否评阅
+ if params[:review].present?
+ review_type = params[:review].first.to_i #已评,则数据为1,未评,则数据为0,前端传过来的为数组
+ if review_type == 1
+ @ex_users = @ex_users.where("subjective_score >= ?",0.0)
+ else
+ @ex_users = @ex_users.where("subjective_score < ?",0.0)
+ end
+ end
+
+ #答题状态的选择
+ if params[:commit_status].present? && (params[:commit_status].to_i == 1)
+ @exercise_users_list = @exercise_users_list.where(commit_status:params[:commit_status])
+ elsif params[:commit_status].present? && (params[:commit_status].to_i == 0)
+ normal_status(-1,"仅支持导出已提交的学生!")
+ end
+
#可以分班选择
if group_id.present?
exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数
@@ -59,6 +76,11 @@ class ZipsController < ApplicationController
@ex_users = @ex_users.where(user_id: user_ids)
end
+ #搜索
+ if params[:search].present?
+ @ex_users = @ex_users.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
+ end
+
default_ex_users_size = @ex_users&.size
if default_ex_users_size.blank? || default_ex_users_size == 0
@@ -80,6 +102,25 @@ class ZipsController < ApplicationController
##7。2 -hs新增
@member = @course.course_member(current_user.id)
@all_student_works = @homework.teacher_works(@member)
+ work_status = params[:work_status]
+ group_id = params[:course_group]
+
+ if work_status.present? && !work_status.include?(0)
+ @all_student_works = @all_student_works.where(work_status:work_status)
+ elsif work_status.present? && work_status.include?(0)
+ normal_status(-1,"仅支持导出已提交的学生!")
+ end
+
+ if group_id.present?
+ group_user_ids = @course.students.where(course_group_id: params[:course_group]).pluck(:user_id)
+ @all_student_works = @all_student_works.where(user_id: group_user_ids)
+ end
+
+ unless params[:search].blank?
+ @all_student_works = @all_student_works.joins(user: :user_extension).where("concat(lastname, firstname) like ?
+ or student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
+ end
+
student_work_sizes = @all_student_works&.size
if student_work_sizes.blank? || student_work_sizes == 0
normal_status(-1,"导出失败,暂时没有已提交的学生")
From dfe784a051c14398029a9aaae96ecfbd51471cae Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 3 Jul 2019 09:38:22 +0800
Subject: [PATCH 55/80] fix bug
---
app/controllers/exercises_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index 79bed2d25..d8278faff 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1297,7 +1297,7 @@ class ExercisesController < ApplicationController
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
else
- if @export_ex_users.exercise_user_committed.size == 0
+ if (@exercise_users_size == 0) ||( @export_ex_users&.exercise_user_committed.size == 0)
normal_status(-1,"暂无用户提交")
else
get_export_users(@exercise,@course,@export_ex_users)
From 8768f4cb237abde1eda6f9e9221d8049f8e8e2ab Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 3 Jul 2019 09:43:04 +0800
Subject: [PATCH 56/80] fix bug
---
app/controllers/exercises_controller.rb | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index d8278faff..72e075d31 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1291,13 +1291,15 @@ class ExercisesController < ApplicationController
@page = params[:page] || 1
@limit = params[:limit] || 20
@exercise_users_list = @exercise_users_list.page(@page).per(@limit)
+ logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}")
+ logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}")
respond_to do |format|
format.json
format.xlsx{
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
else
- if (@exercise_users_size == 0) ||( @export_ex_users&.exercise_user_committed.size == 0)
+ if (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
normal_status(-1,"暂无用户提交")
else
get_export_users(@exercise,@course,@export_ex_users)
@@ -1316,9 +1318,6 @@ class ExercisesController < ApplicationController
format.xlsx{
normal_status(-1,"暂无用户提交")
}
- format.zip{
- normal_status(-1,"暂无用户提交")
- }
end
end
From 09a2eca61846b1ef58154a3352a08d2d756557fb Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Wed, 3 Jul 2019 09:58:59 +0800
Subject: [PATCH 57/80] =?UTF-8?q?fork=E5=AE=9E=E8=AE=AD=E5=90=8C=E6=AD=A5?=
=?UTF-8?q?=E5=A4=8D=E5=88=B6=E5=8F=82=E8=80=83=E7=AD=94=E6=A1=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/shixuns_controller.rb | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index 3a4592b2f..b91ce9580 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -203,6 +203,13 @@ class ShixunsController < ApplicationController
new_challenge.user_id = User.current.id
new_challenge.shixun_id = @new_shixun.id
new_challenge.save!
+ # 同步参考答案
+ challenge.challenge_answers.each do |answer|
+ new_answer = Challenge.new
+ new_answer = answer.attributes.dup.except("id","challenge_id")
+ new_answer.challenge_id = new_challenge.id
+ new_answer.save!
+ end
if challenge.st == 0 # 评测题
# 同步测试集
if challenge.test_sets.present?
From 14dc08892ce247719bbc6e3a200b93690b9f0740 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 3 Jul 2019 10:14:16 +0800
Subject: [PATCH 58/80] =?UTF-8?q?=E9=AA=8C=E8=AF=81=20format.xlsx=E4=B8=8B?=
=?UTF-8?q?=E7=9A=84render=20json=E6=98=AF=E5=90=A6=E6=9C=89=E6=95=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/exercises_controller.rb | 45 +++++++++++++++++--------
1 file changed, 31 insertions(+), 14 deletions(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index 72e075d31..a1db41d79 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1291,23 +1291,40 @@ class ExercisesController < ApplicationController
@page = params[:page] || 1
@limit = params[:limit] || 20
@exercise_users_list = @exercise_users_list.page(@page).per(@limit)
- logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}")
- logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}")
respond_to do |format|
format.json
+ if @user_course_identity > Course::ASSISTANT_PROFESSOR
+ tip_exception(403,"无权限操作")
+ elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
+ logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}")
+ logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}")
+
+
+ normal_status(-1,"暂无用户提交")
+ else
+ format.xlsx{
+ get_export_users(@exercise,@course,@export_ex_users)
+ exercise_export_name =
+ "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
+ render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
+ }
+ end
format.xlsx{
- if @user_course_identity > Course::ASSISTANT_PROFESSOR
- tip_exception(403,"无权限操作")
- else
- if (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
- normal_status(-1,"暂无用户提交")
- else
- get_export_users(@exercise,@course,@export_ex_users)
- exercise_export_name =
- "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
- render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
- end
- end
+ # if @user_course_identity > Course::ASSISTANT_PROFESSOR
+ # tip_exception(403,"无权限操作")
+ # else
+ # if (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
+ # logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}")
+ # logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}")
+ #
+ # normal_status(-1,"暂无用户提交")
+ # else
+ # get_export_users(@exercise,@course,@export_ex_users)
+ # exercise_export_name =
+ # "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
+ # render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
+ # end
+ # end
}
end
else
From d7649d04421ab02105d40d987072a75a2d46f254 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 3 Jul 2019 10:16:18 +0800
Subject: [PATCH 59/80] fix bug
---
app/controllers/exercises_controller.rb | 46 ++++++++-----------------
1 file changed, 15 insertions(+), 31 deletions(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index a1db41d79..038d9a87c 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1293,38 +1293,22 @@ class ExercisesController < ApplicationController
@exercise_users_list = @exercise_users_list.page(@page).per(@limit)
respond_to do |format|
format.json
- if @user_course_identity > Course::ASSISTANT_PROFESSOR
- tip_exception(403,"无权限操作")
- elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
- logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}")
- logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}")
-
-
- normal_status(-1,"暂无用户提交")
- else
- format.xlsx{
- get_export_users(@exercise,@course,@export_ex_users)
- exercise_export_name =
- "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
- render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
- }
- end
format.xlsx{
- # if @user_course_identity > Course::ASSISTANT_PROFESSOR
- # tip_exception(403,"无权限操作")
- # else
- # if (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
- # logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}")
- # logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}")
- #
- # normal_status(-1,"暂无用户提交")
- # else
- # get_export_users(@exercise,@course,@export_ex_users)
- # exercise_export_name =
- # "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
- # render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
- # end
- # end
+ if @user_course_identity > Course::ASSISTANT_PROFESSOR
+ tip_exception(403,"无权限操作")
+ else
+ if (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
+ logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}")
+ logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}")
+
+ normal_status(-1,"暂无用户提交")
+ else
+ get_export_users(@exercise,@course,@export_ex_users)
+ exercise_export_name =
+ "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
+ render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
+ end
+ end
}
end
else
From 9fc9bf97e56bbbaf6d2fc4bda6e089c90c4fae44 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 3 Jul 2019 10:23:43 +0800
Subject: [PATCH 60/80] fix bug
---
app/controllers/exercises_controller.rb | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index 038d9a87c..a10e5ad1b 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1291,6 +1291,7 @@ class ExercisesController < ApplicationController
@page = params[:page] || 1
@limit = params[:limit] || 20
@exercise_users_list = @exercise_users_list.page(@page).per(@limit)
+ tip_exception(403,"无权限操作")
respond_to do |format|
format.json
format.xlsx{
From 39f75a0dc75de9401453b8da6ab3b332ba8d92a4 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 3 Jul 2019 10:30:46 +0800
Subject: [PATCH 61/80] fix bug
---
app/controllers/exercises_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index a10e5ad1b..090386361 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1291,7 +1291,7 @@ class ExercisesController < ApplicationController
@page = params[:page] || 1
@limit = params[:limit] || 20
@exercise_users_list = @exercise_users_list.page(@page).per(@limit)
- tip_exception(403,"无权限操作")
+ logger.info("###########______________format.xlsx_______#######{format.xlsx}")
respond_to do |format|
format.json
format.xlsx{
From ca4c84d6c2f6f6b425bf0e59f2cd2eb33133f5c9 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 3 Jul 2019 10:35:09 +0800
Subject: [PATCH 62/80] fix bug
---
app/controllers/exercises_controller.rb | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index 090386361..a050e7eaa 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1291,7 +1291,10 @@ class ExercisesController < ApplicationController
@page = params[:page] || 1
@limit = params[:limit] || 20
@exercise_users_list = @exercise_users_list.page(@page).per(@limit)
- logger.info("###########______________format.xlsx_______#######{format.xlsx}")
+ if params[:format] == "xlsx"
+ logger.info("###########______________format.xlsx______111111111_#######")
+
+ end
respond_to do |format|
format.json
format.xlsx{
From 92006341b66a9a21e878982206b30a0108238eea Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 3 Jul 2019 10:48:12 +0800
Subject: [PATCH 63/80] fix bug
---
app/controllers/exercises_controller.rb | 56 ++++++++++++-------------
app/controllers/polls_controller.rb | 42 ++++++++++++-------
2 files changed, 54 insertions(+), 44 deletions(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index a050e7eaa..2fcf45cda 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1291,39 +1291,37 @@ class ExercisesController < ApplicationController
@page = params[:page] || 1
@limit = params[:limit] || 20
@exercise_users_list = @exercise_users_list.page(@page).per(@limit)
- if params[:format] == "xlsx"
- logger.info("###########______________format.xlsx______111111111_#######")
-
- end
- respond_to do |format|
- format.json
- format.xlsx{
- if @user_course_identity > Course::ASSISTANT_PROFESSOR
- tip_exception(403,"无权限操作")
- else
- if (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
- logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}")
- logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}")
-
- normal_status(-1,"暂无用户提交")
- else
- get_export_users(@exercise,@course,@export_ex_users)
- exercise_export_name =
- "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
- render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
- end
- end
- }
- end
else
@exercise_users_list = []
+ @export_ex_users = @exercise_users_list
@exercise_users_size = 0
- respond_to do |format|
- format.json
- format.xlsx{
- normal_status(-1,"暂无用户提交")
- }
+ end
+
+ if params[:format] == "xlsx"
+ if @user_course_identity > Course::ASSISTANT_PROFESSOR
+ tip_exception(403,"无权限操作")
+ elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
+ normal_status(-1,"暂无用户提交")
+ else
+ respond_to do |format|
+ format.xlsx{
+ get_export_users(@exercise,@course,@export_ex_users)
+ exercise_export_name =
+ "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
+ render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
+ }
+ end
end
+ # else
+ # respond_to do |format|
+ # format.json
+ # format.xlsx{
+ # get_export_users(@exercise,@course,@export_ex_users)
+ # exercise_export_name =
+ # "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
+ # render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
+ # }
+ # end
end
rescue Exception => e
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index 44cdc6512..7075ac0ef 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -927,23 +927,35 @@ class PollsController < ApplicationController
@poll_export_questions = @poll_questions.order("question_number ASC")
@poll_questions = @poll_questions.page(@page).per(@limit)
- respond_to do |format|
- format.json
- format.xlsx{
- if @user_course_identity > Course::ASSISTANT_PROFESSOR
- tip_exception(403,"无权限操作")
- elsif (@poll.polls_status == 1) || (@poll_export_questions.size == 0) || (@poll_commit_ids.size == 0)
- normal_status(-1,"暂时没有提交的用户")
- else
- polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
- render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {
- poll_questions:@poll_export_questions,
- poll:@poll,
- poll_users: @poll_users,
- poll_commit_ids:@poll_commit_ids}
+ if params[:format] == "xlsx"
+ if @user_course_identity > Course::ASSISTANT_PROFESSOR
+ tip_exception(403,"无权限操作")
+ elsif (@poll.polls_status == 1) || (@poll_export_questions.size == 0) || (@poll_commit_ids.size == 0)
+ normal_status(-1,"暂无用户提交")
+ else
+ respond_to do |format|
+ format.xlsx{
+ polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
+ render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {
+ poll_questions:@poll_export_questions,
+ poll:@poll,
+ poll_users: @poll_users,
+ poll_commit_ids:@poll_commit_ids}
+ }
end
- }
+ end
end
+ # respond_to do |format|
+ # format.json
+ # format.xlsx{
+ # polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
+ # render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {
+ # poll_questions:@poll_export_questions,
+ # poll:@poll,
+ # poll_users: @poll_users,
+ # poll_commit_ids:@poll_commit_ids}
+ # }
+ # end
rescue Exception => e
uid_logger_error(e.message)
tip_exception("页面调用失败!")
From e6f5a2b13a314ab4ec6625cd7ea19f545a0b38b8 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 3 Jul 2019 10:58:24 +0800
Subject: [PATCH 64/80] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84xlsx=E9=94=99?=
=?UTF-8?q?=E8=AF=AF=E6=8F=90=E7=A4=BA=E7=9A=84=E6=B7=BB=E5=8A=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/exercises_controller.rb | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index 2fcf45cda..c5cf7390f 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1298,9 +1298,16 @@ class ExercisesController < ApplicationController
end
if params[:format] == "xlsx"
+ logger.info("#######___________params_xlsx____________##########")
+ logger.info("#######___________@exercise_users_size____________##########{@exercise_users_size}")
+ logger.info("#######___________@export_ex_users&.exercise_user_committed.size____________##########{@export_ex_users&.exercise_user_committed.size}")
+
+
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
+ logger.info("#######___________@exercise_users_size == 0____________##########")
+
normal_status(-1,"暂无用户提交")
else
respond_to do |format|
@@ -1312,18 +1319,7 @@ class ExercisesController < ApplicationController
}
end
end
- # else
- # respond_to do |format|
- # format.json
- # format.xlsx{
- # get_export_users(@exercise,@course,@export_ex_users)
- # exercise_export_name =
- # "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
- # render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
- # }
- # end
end
-
rescue Exception => e
uid_logger_error(e.message)
tip_exception("页面调用失败!")
From 1b4103a54b1377da8dbd17d661b33681fff65f07 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Wed, 3 Jul 2019 11:00:29 +0800
Subject: [PATCH 65/80] =?UTF-8?q?copy=E5=8F=82=E8=80=83=E7=AD=94=E6=A1=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/shixuns_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index b91ce9580..265398833 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -205,7 +205,7 @@ class ShixunsController < ApplicationController
new_challenge.save!
# 同步参考答案
challenge.challenge_answers.each do |answer|
- new_answer = Challenge.new
+ new_answer = ChallengeAnswer.new
new_answer = answer.attributes.dup.except("id","challenge_id")
new_answer.challenge_id = new_challenge.id
new_answer.save!
From 04dc476b8854cd3f03178017f030e4c099c37296 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Wed, 3 Jul 2019 11:02:45 +0800
Subject: [PATCH 66/80] =?UTF-8?q?copy=E5=8F=82=E8=80=83=E7=AD=94=E6=A1=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/shixuns_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index 265398833..fdd55e6cf 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -206,7 +206,7 @@ class ShixunsController < ApplicationController
# 同步参考答案
challenge.challenge_answers.each do |answer|
new_answer = ChallengeAnswer.new
- new_answer = answer.attributes.dup.except("id","challenge_id")
+ new_answer = new_answer.attributes.dup.except("id","challenge_id")
new_answer.challenge_id = new_challenge.id
new_answer.save!
end
From af4922ea72ac791332f2fea62e96bc243b25049c Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Wed, 3 Jul 2019 11:05:31 +0800
Subject: [PATCH 67/80] 1
---
app/controllers/shixuns_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index fdd55e6cf..265398833 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -206,7 +206,7 @@ class ShixunsController < ApplicationController
# 同步参考答案
challenge.challenge_answers.each do |answer|
new_answer = ChallengeAnswer.new
- new_answer = new_answer.attributes.dup.except("id","challenge_id")
+ new_answer = answer.attributes.dup.except("id","challenge_id")
new_answer.challenge_id = new_challenge.id
new_answer.save!
end
From 35c3cc1e2937ac9d86e6653601676f8ecbac82b2 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Wed, 3 Jul 2019 11:07:29 +0800
Subject: [PATCH 68/80] =?UTF-8?q?copy=E5=AE=9E=E8=AE=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/shixuns_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index 265398833..5a1773a10 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -206,7 +206,7 @@ class ShixunsController < ApplicationController
# 同步参考答案
challenge.challenge_answers.each do |answer|
new_answer = ChallengeAnswer.new
- new_answer = answer.attributes.dup.except("id","challenge_id")
+ new_answer.attributes = answer.attributes.dup.except("id","challenge_id")
new_answer.challenge_id = new_challenge.id
new_answer.save!
end
From 275030bb6a3221f7eaa91bb14231d1928713438a Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 3 Jul 2019 11:07:31 +0800
Subject: [PATCH 69/80] fix bug
---
app/controllers/exercises_controller.rb | 27 ++++++++++---------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index c5cf7390f..dd19c36d1 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1298,28 +1298,23 @@ class ExercisesController < ApplicationController
end
if params[:format] == "xlsx"
- logger.info("#######___________params_xlsx____________##########")
- logger.info("#######___________@exercise_users_size____________##########{@exercise_users_size}")
- logger.info("#######___________@export_ex_users&.exercise_user_committed.size____________##########{@export_ex_users&.exercise_user_committed.size}")
-
-
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
- logger.info("#######___________@exercise_users_size == 0____________##########")
-
normal_status(-1,"暂无用户提交")
- else
- respond_to do |format|
- format.xlsx{
- get_export_users(@exercise,@course,@export_ex_users)
- exercise_export_name =
- "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
- render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
- }
- end
+
end
end
+
+ respond_to do |format|
+ format.json
+ format.xlsx{
+ get_export_users(@exercise,@course,@export_ex_users)
+ exercise_export_name =
+ "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
+ render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
+ }
+ end
rescue Exception => e
uid_logger_error(e.message)
tip_exception("页面调用失败!")
From cece1eee5f0b48a1964c4f1049c773d87a08037e Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Wed, 3 Jul 2019 11:08:36 +0800
Subject: [PATCH 70/80] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=88=90=E7=BB=A9?=
=?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/controllers/courses_controller.rb | 222 +++++++++++++++-----------
app/helpers/export_helper.rb | 21 +--
app/models/myshixun.rb | 2 +-
3 files changed, 143 insertions(+), 102 deletions(-)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 2d379b555..26e70f471 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -959,18 +959,20 @@ class CoursesController < ApplicationController
def export_member_scores_excel
ActiveRecord::Base.transaction do
begin
- name = params[:name] ? "#{params[:name].strip}" : "" #用户名或学生学号id搜索
+ search = params[:search] ? "#{params[:search].strip}" : "" #用户名或学生学号id搜索
group_id = params[:group_id] #分班的班级id
- if group_id && group_id != "0" && group_id != "-1"
- @all_members = @course.students.course_find_by_ids("course_group_id",group_id)
- elsif group_id && group_id == "0" # 未分班
- @all_members = @course.course_members.ungroup_students
- else
- @all_members = @course.students
- end
- if name.present?
- @all_members = @all_members.joins(user: [:user_extension]).where('concat(users.lastname, users.firstname) like ? or user_extensions.student_id like ?',"%#{name}%","%#{name}%")
- end
+ # if group_id && group_id != "0" && group_id != "-1"
+ # @all_members = @course.students.course_find_by_ids("course_group_id",group_id)
+ # elsif group_id && group_id == "0" # 未分班
+ # @all_members = @course.course_members.ungroup_students
+ # else
+ # @all_members = @course.students
+ # end
+ # if name.present?
+ # @all_members = @all_members.joins(user: [:user_extension]).where('concat(users.lastname, users.firstname) like ? or user_extensions.student_id like ?',"%#{name}%","%#{name}%")
+ # end
+
+ @all_members = student_act_score group_id, search
@c_homeworks = @course.homework_commons.homework_published.order("homework_commons.publish_time asc, homework_commons.created_at asc")
@c_exercises = @course.exercises.is_exercise_published.order("exercises.publish_time asc, exercises.created_at asc")
@@ -981,7 +983,7 @@ class CoursesController < ApplicationController
else
member_to_xlsx(@course, @all_members, @c_homeworks, @c_exercises, @c_tasks, @c_polls)
filename = current_user.real_name + "_" + @course.name + "_全部成绩" + Time.now.strftime('%Y%m%d_%H%M%S')
- render xlsx: "#{filename.strip.first(30)}",template: "courses/export_member_scores_excel.xlsx.axlsx",
+ render xlsx: "#{format_sheet_name filename.strip.first(30)}",template: "courses/export_member_scores_excel.xlsx.axlsx",
locals: {course_info:@course_info, activity_level:@user_activity_level,
course_scores:@course_user_scores,shixun_works:@shixun_work_arrays,
common_works:@common_work_arrays,group_works:@group_work_arrays,task_works:@task_work_arrays,
@@ -1051,16 +1053,68 @@ class CoursesController < ApplicationController
end
end
- def member_to_xlsx(course,all_members,homeworks,exercises,tasks,polls)
+ def student_act_score group_id, search
+ sql_select = %Q{SELECT cm.*,(
+ SELECT SUM(student_works.work_score)
+ FROM student_works,homework_commons
+ WHERE student_works.homework_common_id = homework_commons.id
+ AND homework_commons.course_id = #{@course.id}
+ AND student_works.user_id = cm.user_id
+ ) AS score,
+ (SELECT SUM(gw.work_score) FROM graduation_works gw,graduation_tasks gt WHERE gw.graduation_task_id = gt.id
+ AND gt.course_id = #{@course.id} AND gw.user_id = cm.user_id) AS graduation_score,
+ (SELECT SUM(exercise_users.score) FROM exercise_users,exercises WHERE exercise_users.exercise_id = exercises.id
+ AND exercises.course_id = #{@course.id} AND exercise_users.user_id = cm.user_id) AS ex_score,
+ (SELECT max(student_id) FROM user_extensions WHERE user_extensions.user_id = cm.user_id) AS student_id,
+ (SELECT max(message_num) FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = cm.user_id) AS message_num,
+ (SELECT max(message_reply_num) FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = cm.user_id) AS message_reply_num,
+ (SELECT max(resource_num) FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = cm.user_id) AS resource_num,
+ (SELECT max(homework_journal_num) FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = cm.user_id) AS homework_journal_num,
+ (SELECT COUNT(gw.id) FROM graduation_works AS gw, graduation_tasks AS gt WHERE gw.graduation_task_id = gt.id AND gt.course_id = #{@course.id} AND gw.work_status != 0 AND gw.user_id = cm.user_id) AS graduation_num,
+ (SELECT COUNT(ss.id) FROM student_works AS ss ,homework_commons AS hc WHERE ss.homework_common_id = hc.id AND hc.course_id = #{@course.id} AND ss.work_status != 0 AND ss.user_id = cm.user_id) AS homework_num,
+ (SELECT COUNT(eu.id) FROM exercise_users AS eu,exercises WHERE eu.exercise_id = exercises.id AND exercises.course_id = #{@course.id} AND eu.commit_status = 1 AND eu.user_id = cm.user_id) AS exercise_num,
+ (SELECT COUNT(pu.id) FROM poll_users AS pu, polls WHERE pu.poll_id = polls.id AND polls.course_id = #{@course.id} AND pu.commit_status = 1 AND pu.user_id = cm.user_id) AS poll_num
+ FROM course_members cm}
+ if search.present? && group_id.present?
+ sql_select += %Q{ join users on cm.user_id = users.id
+ joins user_extensions ue on ue.user_id = users.id
+ WHERE cm.role = 4 and cm.course_id = #{@course.id} and cm.course_group_id = #{group_id} and
+ (concat(users.lastname, users.firstname) like '%#{search}%' or ue.student_id like '%#{search}%') ORDER BY score desc}
+
+ elsif search.present?
+ ql_select += %Q{ join users on cm.user_id = users.id
+ joins user_extensions ue on ue.user_id = users.id
+ WHERE cm.role = 4 and
+ (concat(users.lastname, users.firstname) like '%#{search}%' or ue.student_id like '%#{search}%') ORDER BY score desc}
+ elsif group_id.present?
+ sql_select += %Q{ WHERE cm.role = 4 and cm.course_id = #{@course.id} and cm.course_group_id = #{group_id} ORDER BY score desc}
+ else
+ sql_select += %Q{ WHERE cm.role = 4 and cm.course_id = #{@course.id} ORDER BY score desc}
+ end
+ act_scores = CourseMember.find_by_sql(sql_select)
+ act_scores
+ end
+
+ def member_to_xlsx(course,all_members,homeworks,exercises,tasks)
#课堂的作业信息
- shixun_homeworks = homeworks.search_homework_type(4).includes(:score_student_works) #全部实训作业
+ shixun_homeworks = homeworks.search_homework_type(4) #全部实训作业
shixun_titles = shixun_homeworks.pluck(:name) + ["总得分"]
- common_homeworks = homeworks.search_homework_type(1).includes(:score_student_works) #全部普通作业
+ shixun_homeworks = shixun_homeworks.includes(:score_student_works)
+
+ common_homeworks = homeworks.search_homework_type(1) #全部普通作业
common_titles = common_homeworks.pluck(:name)+ ["总得分"]
+ common_homeworks = common_homeworks.includes(:score_student_works)
+
group_homeworks = homeworks.search_homework_type(3).includes(:score_student_works) #全部分组作业
group_titles = group_homeworks.pluck(:name)+ ["总得分"]
- task_titles = tasks.includes(:score_graduation_works).pluck(:name) + ["总得分"]
- exercise_titles = exercises.includes(:score_exercise_users).pluck(:exercise_name) + ["总得分"]
+ group_homeworks = group_homeworks.includes(:score_student_works)
+
+ task_titles = tasks.pluck(:name) + ["总得分"]
+ tasks = tasks.includes(:score_graduation_works)
+
+ exercise_titles = exercises.pluck(:exercise_name) + ["总得分"]
+ exercises = exercises.includes(:score_exercise_users)
+
total_user_score_array = [] #学生总成绩集合
#课堂信息
@@ -1075,7 +1129,7 @@ class CoursesController < ApplicationController
course_teacher_member = course.course_members.course_user_role(%i[CREATOR])
course_teacher = course_teacher_member.present? ? course_teacher_member.first.user.real_name : "--"
course_class_counts = course.course_groups_count
- course_students_count = course.students.count
+ course_students_count = course.students.size
course_1 = ["课堂编号",course_id]
course_2 = ["课程名称",course_list_name]
course_3 = ["课堂名称",course_name]
@@ -1100,16 +1154,11 @@ class CoursesController < ApplicationController
@course_info += [course_info_title,course_main_info,course_group_info]
#课堂活跃度
- course_homework_ids = homeworks.pluck(:id) #该课堂的全部作业id
- course_graduate_task_ids = tasks.pluck(:id) #该课堂的全部毕业任务id
- course_exercise_ids = exercises.pluck(:id) #课堂的全部试卷数
- course_poll_ids = polls.pluck(:id) #课堂的全部问卷数
- course_board_ids = course.boards.pluck(:id) #课堂的全部讨论区
@user_activity_level = []
course_user_level = []
course_activity_title = "课堂活跃度统计"
user_cell_head = %w(排名 真实姓名 登录名 邮箱 学号 分班 作业完成数(*10) 试卷完成数(*10) 问卷完成数(*7) 资源发布数(*5) 帖子发布数(*2) 帖子回复数(*1) 作业回复数(*1) 活跃度)
- all_members.includes(user: :user_extension).each do |u|
+ all_members.each do |u|
#用户的基本信息
user = u.user
user_login = user.login
@@ -1121,15 +1170,14 @@ class CoursesController < ApplicationController
user_work_scores = []
#课堂活跃度统计
- user_homeworks_num = user.student_works.find_by_homework(course_homework_ids).has_committed.count #完成的作业数
- user_graduate_num = user.graduation_works.find_by_task(course_graduate_task_ids).has_committed.count #毕业任务完成数
- user_exercise_num = user.exercise_users.search_by_exercise(course_exercise_ids).commit_exercise_by_status(1).count #根据试卷的id来查找
- user_poll_num = user.poll_users.search_by_poll(course_poll_ids).commit_by_status(1).count #已完成问卷
- user_file_num = user.attachments.search_by_container(course.id).count
- user_messages = user.messages
- user_messages_num = user_messages.root_nodes.find_by_boards(course_board_ids).count #帖子发布数
- user_reply_num = user_messages.reply_nodes.find_by_boards(course_board_ids).count #帖子回复数
- user_work_reply_num = user.journals_for_messages.search_by_jour_type("HomeworkCommon",course_homework_ids).count #作业回复数的数量
+ user_homeworks_num = u.homework_num.to_i #完成的作业数
+ user_graduate_num = u.graduation_num.to_i #毕业任务完成数
+ user_exercise_num = u.exercise_num.to_i #根据试卷的id来查找
+ user_poll_num = u.poll_num.to_i #已完成问卷
+ user_file_num = u.resource_num.to_i
+ user_messages_num = u.message_num.to_i #帖子发布数
+ user_reply_num = u.message_reply_num.to_i #帖子回复数
+ user_work_reply_num = u.homework_journal_num.to_i #作业回复数的数量
c_works_num = (user_homeworks_num + user_graduate_num)*10
c_exercise_num = user_exercise_num*10
c_poll_num = user_poll_num*7
@@ -1167,7 +1215,7 @@ class CoursesController < ApplicationController
exercise_score_array = []
#实训作业
- if shixun_homeworks.count > 0
+ if shixun_homeworks.size > 0
shixun_homeworks.each do |s|
user_student_work = s.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答
if user_student_work.nil?
@@ -1183,7 +1231,7 @@ class CoursesController < ApplicationController
user_work_scores += user_info_array + shixun_score_array #单个用户的实训作业得分信息
#普通作业
- if common_homeworks.count > 0
+ if common_homeworks.size > 0
common_homeworks.each do |c|
user_student_work_1 = c.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答
if user_student_work_1.nil?
@@ -1199,7 +1247,7 @@ class CoursesController < ApplicationController
user_work_scores += common_score_array #单个用户的普通作业得分信息
#分组作业
- if group_homeworks.count > 0
+ if group_homeworks.size > 0
group_homeworks.each do |g|
user_student_work_3 = g.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答
if user_student_work_3.nil?
@@ -1215,7 +1263,7 @@ class CoursesController < ApplicationController
user_work_scores += group_score_array #单个用户的分组作业得分信息
#毕设作业
- if tasks.count > 0
+ if tasks.size > 0
tasks.each do |task|
graduation_work = task.score_graduation_works.select{|work| work.user_id == user.id}.first
if graduation_work.nil?
@@ -1231,7 +1279,7 @@ class CoursesController < ApplicationController
user_work_scores += task_score_array #单个用户的分组作业得分信息
#试卷
- if exercises.count > 0
+ if exercises.size > 0
exercises.each do |ex|
exercise_work = ex.score_exercise_users.select{|work| work.user_id == user.id}.first
if exercise_work.nil?
@@ -1269,73 +1317,63 @@ class CoursesController < ApplicationController
@common_work_arrays = []
@task_work_arrays = []
@exercise_work_arrays = []
- count_1 = shixun_homeworks.count
- count_2 = common_homeworks.count
- count_3 = group_homeworks.count
- count_4 = tasks.count
- count_5 = exercises.count
+ count_1 = shixun_homeworks.size
+ count_2 = common_homeworks.size
+ count_3 = group_homeworks.size
+ count_4 = tasks.size
+ count_5 = exercises.size
#实训作业
- if count_1 > 0
- shixun_homeworks.each_with_index do |s,index|
- all_student_works = s.score_student_works #该实训题的全部用户回答
- title_no = index.to_i + 1
- student_work_to_xlsx(all_student_works,s)
- shixun_work_display_name = (title_no.to_s + "." + s.name).strip.first(30)
- shixun_work_content = [shixun_work_display_name,@work_head_cells,@work_cells_column]
- @shixun_work_arrays.push(shixun_work_content)
- end
+ shixun_homeworks.each_with_index do |s,index|
+ all_student_works = s.score_student_works #该实训题的全部用户回答
+ title_no = index.to_i + 1
+ student_work_to_xlsx(all_student_works,s)
+ shixun_work_display_name = format_sheet_name (title_no.to_s + "." + s.name).strip.first(30)
+ shixun_work_content = [shixun_work_display_name,@work_head_cells,@work_cells_column]
+ @shixun_work_arrays.push(shixun_work_content)
end
#普通作业
- if count_2 > 0
- common_homeworks.each_with_index do |c,index|
- all_student_works = c.score_student_works #当前用户的对该作业的回答
- title_no = count_1 + index.to_i + 1
- student_work_to_xlsx(all_student_works,c)
-
- work_name = (title_no.to_s + "." + c.name).strip.first(30)
- work_content = [work_name,@work_head_cells,@work_cells_column]
- @common_work_arrays.push(work_content)
- title_no
- end
+ common_homeworks.each_with_index do |c,index|
+ all_student_works = c.score_student_works #当前用户的对该作业的回答
+ title_no = count_1 + index.to_i + 1
+ student_work_to_xlsx(all_student_works,c)
+
+ work_name = format_sheet_name (title_no.to_s + "." + c.name).strip.first(30)
+ work_content = [work_name,@work_head_cells,@work_cells_column]
+ @common_work_arrays.push(work_content)
+ title_no
end
#分组作业
- if count_3 > 0
- group_homeworks.each_with_index do |c,index|
- all_student_works = c.score_student_works #当前用户的对该作业的回答
- title_no = count_1 + count_2 + index.to_i + 1
- student_work_to_xlsx(all_student_works,c)
- work_name = (title_no.to_s + "." + c.name).strip.first(30)
- work_content = [work_name,@work_head_cells,@work_cells_column]
- @group_work_arrays.push(work_content)
- end
+ group_homeworks.each_with_index do |c,index|
+ all_student_works = c.score_student_works #当前用户的对该作业的回答
+ title_no = count_1 + count_2 + index.to_i + 1
+ student_work_to_xlsx(all_student_works,c)
+ work_name = format_sheet_name (title_no.to_s + "." + c.name).strip.first(30)
+ work_content = [work_name,@work_head_cells,@work_cells_column]
+ @group_work_arrays.push(work_content)
end
#毕设任务
- if count_4 > 0
- tasks.each_with_index do |c,index|
- all_student_works = c.score_graduation_works #当前用户的对该作业的回答
- title_no = count_1 + count_2 + count_3 + index.to_i + 1
- graduation_work_to_xlsx(all_student_works,c,current_user)
- work_name = (title_no.to_s + "." + c.name).strip.first(30)
- # work_content = [work_name,@work_head_cells,@work_cells_column]
- work_content = [work_name,@head_cells_column,@task_cells_column]
- @task_work_arrays.push(work_content)
- end
+ tasks.each_with_index do |c,index|
+ all_student_works = c.score_graduation_works #当前用户的对该作业的回答
+ title_no = count_1 + count_2 + count_3 + index.to_i + 1
+ graduation_work_to_xlsx(all_student_works,c,current_user)
+ work_name = format_sheet_name (title_no.to_s + "." + c.name).strip.first(30)
+ # work_content = [work_name,@work_head_cells,@work_cells_column]
+ work_content = [work_name,@head_cells_column,@task_cells_column]
+ @task_work_arrays.push(work_content)
end
#试卷的导出
- if count_5 > 0
- exercises.each_with_index do |c,index|
- all_student_works = c.score_exercise_users #当前用户的对该作业的回答
- title_no = count_1 + count_2 + count_3 + count_4 + index.to_i + 1
- get_export_users(c,course,all_student_works)
- work_name = (title_no.to_s + "." + c.exercise_name).strip.first(30)
- # work_content = [work_name,@work_head_cells,@work_cells_column]
- work_content = [work_name,@table_columns,@user_columns]
- @exercise_work_arrays.push(work_content)
- end
+ exercises.each_with_index do |c,index|
+ all_student_works = c.score_exercise_users #当前用户的对该作业的回答
+ title_no = count_1 + count_2 + count_3 + count_4 + index.to_i + 1
+ get_export_users(c,course,all_student_works)
+ work_name = format_sheet_name (title_no.to_s + "." + c.exercise_name).strip.first(30)
+ # work_content = [work_name,@work_head_cells,@work_cells_column]
+ work_content = [work_name,@table_columns,@user_columns]
+ @exercise_work_arrays.push(work_content)
end
end
end
diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb
index 31fadc265..edb2b7e74 100644
--- a/app/helpers/export_helper.rb
+++ b/app/helpers/export_helper.rb
@@ -37,14 +37,14 @@ module ExportHelper
end
normal_head_b_cells = %w(最终成绩 提交时间 更新时间 评语)
@work_head_cells = (head_cells_format + group_cells + normal_head_cells + head_cells_add + allow_late_cell + normal_head_b_cells).reject(&:blank?)
- works.includes(student_works_scores: :user).each_with_index do |w, index|
+ works.includes(user: :user_extension, student_works_scores: :user).each_with_index do |w, index|
w_user = w.user
w_1 = (index + 1)
w_2 = w_user.login
w_3 = w_user.real_name
w_3_1 = w_user.mail
w_4 = w_user.student_id.present? ? w_user.student_id : "--"
- course_name = course.course_member(w.user_id).try(:course_group_name)
+ course_name = course.students.find_by(user_id: w.user_id).try(:course_group_name)
w_5 = course_name.present? ? course_name : "--"
#0: 未提交, 1 按时提交, 2 延迟提交
if w.work_status == 0
@@ -118,7 +118,7 @@ module ExportHelper
end
shixun_time_cells = %w(最终成绩 更新时间 提交耗时 评语)
@work_head_cells = (head_cells_format + shixun_head_cells + eff_score_cell + shixun_time_cells).reject(&:blank?)
- works.includes(:myshixun).each_with_index do |w, index|
+ works.includes(:student_works_scores, user: :user_extension, myshixun: :games).each_with_index do |w, index|
myshixun = w.try(:myshixun)
w_user = w.user
w_1 = (index + 1)
@@ -126,7 +126,7 @@ module ExportHelper
w_3 = w_user.real_name
w_3_1 = w_user.mail
w_4 = w_user.student_id.present? ? w_user.student_id : "--"
- course_name = course.course_member(w.user_id).try(:course_group_name)
+ course_name = course.students.find_by(user_id: w.user_id).try(:course_group_name)
w_5 = course_name.present? ? course_name : "--"
#0: 未提交, 1 按时提交, 2 延迟提交
if w.work_status == 0
@@ -138,7 +138,7 @@ module ExportHelper
else
w_6 = "--"
end
- w_7 = w.work_status == 0 ? '--' : myshixun.try(:passed_count).to_s+"/"+shixun.challenges.count.to_s
+ w_7 = w.work_status == 0 ? '--' : myshixun.try(:passed_count).to_s+"/"+shixun.challenges_count.to_s
w_8 = myshixun ? myshixun.try(:passed_time) == "--" ? "--" : format_time(myshixun.try(:passed_time)) : "--" # 通关时间
w_9 = myshixun ? (myshixun.try(:passed_count) > 0 ? myshixun.total_spend_time : '--') : "--" #总耗时
w_10 = myshixun ? myshixun.output_times : 0 #评测次数
@@ -204,7 +204,7 @@ module ExportHelper
@head_cells_column = head_cells_format
@task_cells_column = []
- items.each_with_index do |work,index|
+ items.includes(user: :user_extension).each_with_index do |work,index|
w_1 = (index+1)
w_user = work.user
w_2 = w_user.login
@@ -260,7 +260,7 @@ module ExportHelper
else
@table_columns = @table_columns + %w(最终成绩 开始答题时间 提交时间)
end
- export_ex_users.each_with_index do |e_user,index|
+ export_ex_users.includes(user: :user_extension).each_with_index do |e_user,index|
user_info = e_user.user
member = course.students.find_by_user_id(e_user.user_id)
user_course = member.try(:course_group_name)
@@ -295,7 +295,7 @@ module ExportHelper
@topic_body_cells = []
if students.count > 0
- students.each_with_index do |student, index|
+ students.includes(user: :user_extension).each_with_index do |student, index|
user = student.user
student_topic = course.student_graduation_topics.user_topics_accept(user.id).first
if student_topic.present?
@@ -308,7 +308,7 @@ module ExportHelper
w_2 = user.login
w_3 = user.real_name
w_3_1 = user.mail
- w_4 = user.user_extension.student_id
+ w_4 = user.student_id
w_5 = student.course_group_name
w_6 = topic.present? ? topic.name : "--"
w_7 = topic.present? ? topic.teacher.full_name : "--"
@@ -504,4 +504,7 @@ module ExportHelper
attach.filename
end
+ def format_sheet_name name
+ name = name.gsub(":", "-")
+ end
end
diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb
index d8f294a39..31cc53200 100644
--- a/app/models/myshixun.rb
+++ b/app/models/myshixun.rb
@@ -18,7 +18,7 @@ class Myshixun < ApplicationRecord
end
def output_times
- games.sum(:evaluate_count)
+ games.pluck(:evaluate_count).sum.to_i
end
def repo_path
From ad7f287faccca9b38b35e7e2a2375b99feed5686 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Wed, 3 Jul 2019 11:10:14 +0800
Subject: [PATCH 71/80] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=88=90=E7=BB=A9?=
=?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/controllers/courses_controller.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 26e70f471..4e4d0284a 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -976,12 +976,12 @@ class CoursesController < ApplicationController
@c_homeworks = @course.homework_commons.homework_published.order("homework_commons.publish_time asc, homework_commons.created_at asc")
@c_exercises = @course.exercises.is_exercise_published.order("exercises.publish_time asc, exercises.created_at asc")
- @c_polls = @course.polls.publish_or_not.order("polls.publish_time asc, polls.created_at asc")
+ # @c_polls = @course.polls.publish_or_not.order("polls.publish_time asc, polls.created_at asc")
@c_tasks = @course.graduation_tasks.task_published.order("graduation_tasks.publish_time asc, graduation_tasks.created_at asc")
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
else
- member_to_xlsx(@course, @all_members, @c_homeworks, @c_exercises, @c_tasks, @c_polls)
+ member_to_xlsx(@course, @all_members, @c_homeworks, @c_exercises, @c_tasks)
filename = current_user.real_name + "_" + @course.name + "_全部成绩" + Time.now.strftime('%Y%m%d_%H%M%S')
render xlsx: "#{format_sheet_name filename.strip.first(30)}",template: "courses/export_member_scores_excel.xlsx.axlsx",
locals: {course_info:@course_info, activity_level:@user_activity_level,
From dd49b9e9adca84254a5fc552acb5a0920354fa8a Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 3 Jul 2019 11:26:16 +0800
Subject: [PATCH 72/80] =?UTF-8?q?=20xlsx=E5=AF=BC=E5=87=BA=E7=9A=84?=
=?UTF-8?q?=E5=88=A4=E6=96=AD=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/courses_controller.rb | 2 +
app/controllers/exercises_controller.rb | 22 ++--
.../graduation_tasks_controller.rb | 104 ++++++++++++------
.../homework_commons_controller.rb | 86 ++++++++++-----
app/controllers/polls_controller.rb | 11 --
5 files changed, 137 insertions(+), 88 deletions(-)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 2d379b555..6d1964840 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -978,6 +978,8 @@ class CoursesController < ApplicationController
@c_tasks = @course.graduation_tasks.task_published.order("graduation_tasks.publish_time asc, graduation_tasks.created_at asc")
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
+ elsif @all_members.size == 0
+ normal_status(-1,"课堂暂时没有学生")
else
member_to_xlsx(@course, @all_members, @c_homeworks, @c_exercises, @c_tasks, @c_polls)
filename = current_user.real_name + "_" + @course.name + "_全部成绩" + Time.now.strftime('%Y%m%d_%H%M%S')
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index dd19c36d1..07113792d 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1300,21 +1300,19 @@ class ExercisesController < ApplicationController
if params[:format] == "xlsx"
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
- elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
+ elsif (@exercise_status == 1) || (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
normal_status(-1,"暂无用户提交")
-
+ else
+ respond_to do |format|
+ format.xlsx{
+ get_export_users(@exercise,@course,@export_ex_users)
+ exercise_export_name =
+ "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
+ render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
+ }
+ end
end
end
-
- respond_to do |format|
- format.json
- format.xlsx{
- get_export_users(@exercise,@course,@export_ex_users)
- exercise_export_name =
- "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
- render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
- }
- end
rescue Exception => e
uid_logger_error(e.message)
tip_exception("页面调用失败!")
diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb
index 1931c26a0..23344e7fc 100644
--- a/app/controllers/graduation_tasks_controller.rb
+++ b/app/controllers/graduation_tasks_controller.rb
@@ -123,51 +123,83 @@ class GraduationTasksController < ApplicationController
@work_count = @work_list.count
@work_excel = @work_list
@work_list = @work_list.page(page).per(limit)
- respond_to do |format|
- format.json
- format.xlsx{
- if @user_course_identity >= Course::STUDENT
- tip_exception(403, "无权限操作")
- else
- if @work_count > 1
- graduation_work_to_xlsx(@work_excel,@task,current_user)
- exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@task.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
- render xlsx: "#{exercise_export_name.strip.first(30)}",template: "graduation_tasks/tasks_list.xlsx.axlsx",locals: {table_columns:@head_cells_column, task_users:@task_cells_column}
- else
- normal_status(-1,"暂无提交的学生!")
- end
- end
- }
- format.zip{
- if @user_course_identity >= Course::STUDENT
- tip_exception(403, "无权限操作")
+
+ if params[:format] == "xlsx"
+ if @user_course_identity >= Course::STUDENT
+ tip_exception(403, "无权限操作")
+ elsif @work_count == 0
+ normal_status(-1,"暂无提交的学生!")
+ else
+ student_work_to_xlsx(@work_excel,@homework)
+ exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
+
+ render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals:
+ {table_columns: @work_head_cells,task_users: @work_cells_column}
+ end
+ elsif params[:format] == "zip"
+ if @user_course_identity >= Course::STUDENT
+ tip_exception(403, "无权限操作")
+ else
+ zip_works = @work_excel.where("work_status > 0")
+ status = checkfileSize(zip_works)
+ if status == 0
+ zipfile = zip_homework_common @homework, zip_works
+ file = decode64(zipfile[0][:base64file])
+ send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
else
- zip_works = @work_excel.where("work_status > 0")
- status = checkfileSize(zip_works)
- if status == 0
- zipfile = zip_homework_common @task, zip_works
- file = decode64(zipfile[0][:base64file])
- send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
- else
- tip_exception(status == -2 ? "500" : "无附件可下载")
- end
+ tip_exception(status == -2 ? "500M" : "无附件可下载")
end
- }
+ end
end
+ #
+ # respond_to do |format|
+ # format.json
+ # format.xlsx{
+ # if @user_course_identity >= Course::STUDENT
+ # tip_exception(403, "无权限操作")
+ # else
+ # if @work_count > 1
+ # graduation_work_to_xlsx(@work_excel,@task,current_user)
+ # exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@task.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
+ # render xlsx: "#{exercise_export_name.strip.first(30)}",template: "graduation_tasks/tasks_list.xlsx.axlsx",locals: {table_columns:@head_cells_column, task_users:@task_cells_column}
+ # else
+ # normal_status(-1,"暂无提交的学生!")
+ # end
+ # end
+ # }
+ # format.zip{
+ # if @user_course_identity >= Course::STUDENT
+ # tip_exception(403, "无权限操作")
+ # else
+ # zip_works = @work_excel.where("work_status > 0")
+ # status = checkfileSize(zip_works)
+ # if status == 0
+ # zipfile = zip_homework_common @task, zip_works
+ # file = decode64(zipfile[0][:base64file])
+ # send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
+ # else
+ # tip_exception(status == -2 ? "500" : "无附件可下载")
+ # end
+ # end
+ # }
+ # end
else
@work_list = @work
@view_work = false
@work_count = @work_list.count
@all_work_count = @work_list.count
- respond_to do |format|
- format.json
- format.xlsx{
- normal_status(-1,"作业未发布")
- }
- format.zip{
- normal_status(-1,"作业未发布")
- }
+ if params[:format] == "xlsx" || params[:format] == "zip"
+ normal_status(-1,"作业未发布")
end
+ # respond_to do |format|
+ # format.json
+ # format.xlsx{
+ # normal_status(-1,"作业未发布")
+ # }
+ # format.zip{
+ # normal_status(-1,"作业未发布")
+ # }
+ # end
end
end
diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb
index 89e301f93..5de65210f 100644
--- a/app/controllers/homework_commons_controller.rb
+++ b/app/controllers/homework_commons_controller.rb
@@ -200,40 +200,68 @@ class HomeworkCommonsController < ApplicationController
end
# @members = @course.students.where(user_id: @student_works.pluck(:user_id)).includes(:course_group)
end
- respond_to do |format|
- format.json
- format.xlsx{
- if @user_course_identity >= Course::STUDENT
- tip_exception(403, "无权限操作")
- else
- if @work_count > 1
- student_work_to_xlsx(@work_excel,@homework)
- exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
- render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals:
- {table_columns: @work_head_cells,task_users: @work_cells_column}
- else
- normal_status(-1,"暂无提交的学生!")
- end
+ if params[:format] == "xlsx"
+ if @user_course_identity >= Course::STUDENT
+ tip_exception(403, "无权限操作")
+ elsif @work_count == 0
+ normal_status(-1,"暂无提交的学生!")
+ else
+ student_work_to_xlsx(@work_excel,@homework)
+ exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
- end
- }
- format.zip{
- if @user_course_identity >= Course::STUDENT
- tip_exception(403, "无权限操作")
+ render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals:
+ {table_columns: @work_head_cells,task_users: @work_cells_column}
+ end
+ elsif params[:format] == "zip"
+ if @user_course_identity >= Course::STUDENT
+ tip_exception(403, "无权限操作")
+ else
+ zip_works = @work_excel.where("work_status > 0")
+ status = checkfileSize(zip_works)
+ if status == 0
+ zipfile = zip_homework_common @homework, zip_works
+ file = decode64(zipfile[0][:base64file])
+ send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
else
- zip_works = @work_excel.where("work_status > 0")
- status = checkfileSize(zip_works)
- if status == 0
- zipfile = zip_homework_common @homework, zip_works
- file = decode64(zipfile[0][:base64file])
- send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
- else
- tip_exception(status == -2 ? "500M" : "无附件可下载")
- end
+ tip_exception(status == -2 ? "500M" : "无附件可下载")
end
- }
+ end
end
+ # respond_to do |format|
+ # format.json
+ # format.xlsx{
+ # if @user_course_identity >= Course::STUDENT
+ # tip_exception(403, "无权限操作")
+ # else
+ # if @work_count > 1
+ # student_work_to_xlsx(@work_excel,@homework)
+ # exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
+ #
+ # render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals:
+ # {table_columns: @work_head_cells,task_users: @work_cells_column}
+ # else
+ # normal_status(-1,"暂无提交的学生!")
+ # end
+ #
+ # end
+ # }
+ # format.zip{
+ # if @user_course_identity >= Course::STUDENT
+ # tip_exception(403, "无权限操作")
+ # else
+ # zip_works = @work_excel.where("work_status > 0")
+ # status = checkfileSize(zip_works)
+ # if status == 0
+ # zipfile = zip_homework_common @homework, zip_works
+ # file = decode64(zipfile[0][:base64file])
+ # send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
+ # else
+ # tip_exception(status == -2 ? "500M" : "无附件可下载")
+ # end
+ # end
+ # }
+ # end
end
end
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index 7075ac0ef..244cdf57f 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -945,17 +945,6 @@ class PollsController < ApplicationController
end
end
end
- # respond_to do |format|
- # format.json
- # format.xlsx{
- # polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
- # render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {
- # poll_questions:@poll_export_questions,
- # poll:@poll,
- # poll_users: @poll_users,
- # poll_commit_ids:@poll_commit_ids}
- # }
- # end
rescue Exception => e
uid_logger_error(e.message)
tip_exception("页面调用失败!")
From d80b7d924523c715ba0a3341a29d49096fa5dc46 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Wed, 3 Jul 2019 11:26:19 +0800
Subject: [PATCH 73/80] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=88=90=E7=BB=A9?=
=?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/controllers/courses_controller.rb | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 4e4d0284a..5d8c1408f 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -991,7 +991,7 @@ class CoursesController < ApplicationController
end
rescue Exception => e
uid_logger_error(e.message)
- tip_exception("没有权限")
+ tip_exception(e.message)
raise ActiveRecord::Rollback
end
end
@@ -1061,15 +1061,11 @@ class CoursesController < ApplicationController
AND homework_commons.course_id = #{@course.id}
AND student_works.user_id = cm.user_id
) AS score,
- (SELECT SUM(gw.work_score) FROM graduation_works gw,graduation_tasks gt WHERE gw.graduation_task_id = gt.id
- AND gt.course_id = #{@course.id} AND gw.user_id = cm.user_id) AS graduation_score,
- (SELECT SUM(exercise_users.score) FROM exercise_users,exercises WHERE exercise_users.exercise_id = exercises.id
- AND exercises.course_id = #{@course.id} AND exercise_users.user_id = cm.user_id) AS ex_score,
(SELECT max(student_id) FROM user_extensions WHERE user_extensions.user_id = cm.user_id) AS student_id,
- (SELECT max(message_num) FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = cm.user_id) AS message_num,
- (SELECT max(message_reply_num) FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = cm.user_id) AS message_reply_num,
- (SELECT max(resource_num) FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = cm.user_id) AS resource_num,
- (SELECT max(homework_journal_num) FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = cm.user_id) AS homework_journal_num,
+ (SELECT count(messages.id) FROM messages join boards on messages.board_id = boards.id WHERE boards.course_id = #{@course.id} AND messages.author_id = cm.user_id and messages.parent_id is null) AS message_num,
+ (SELECT count(messages.id) FROM messages join boards on messages.board_id = boards.id WHERE boards.course_id = #{@course.id} AND messages.author_id = cm.user_id and messages.parent_id is not null) AS message_reply_num,
+ (SELECT count(attachments.id) FROM attachments WHERE container_id = #{@course.id} and container_type = "Course" AND attachments.author_id = cm.user_id) AS resource_num,
+ (SELECT count(jfm.id) FROM journals_for_messages AS jfm, homework_commons hs WHERE jfm.jour_id = hs.id AND jfm.user_id = cm.user_id and jfm.jour_type = "HomeworkCommon" and hs.course_id = #{@course.id}) AS homework_journal_num,
(SELECT COUNT(gw.id) FROM graduation_works AS gw, graduation_tasks AS gt WHERE gw.graduation_task_id = gt.id AND gt.course_id = #{@course.id} AND gw.work_status != 0 AND gw.user_id = cm.user_id) AS graduation_num,
(SELECT COUNT(ss.id) FROM student_works AS ss ,homework_commons AS hc WHERE ss.homework_common_id = hc.id AND hc.course_id = #{@course.id} AND ss.work_status != 0 AND ss.user_id = cm.user_id) AS homework_num,
(SELECT COUNT(eu.id) FROM exercise_users AS eu,exercises WHERE eu.exercise_id = exercises.id AND exercises.course_id = #{@course.id} AND eu.commit_status = 1 AND eu.user_id = cm.user_id) AS exercise_num,
From 0a48259433bda039d08363c559f7f2eb5b46298e Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Wed, 3 Jul 2019 11:27:11 +0800
Subject: [PATCH 74/80] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=88=90=E7=BB=A9?=
=?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/controllers/courses_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 5d8c1408f..5c03dffee 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -1160,7 +1160,7 @@ class CoursesController < ApplicationController
user_login = user.login
user_name = user.real_name
user_mail = user.mail
- user_stu_id = user.student_id.present? ? (user.student_id.to_s + "\t") : "--"
+ user_stu_id = u.student_id.present? ? (u.student_id.to_s + "\t") : "--"
user_course_group = u.course_group_name
user_info_array = [user_login,user_name,user_mail,user_stu_id,user_course_group] #用户的信息集合
user_work_scores = []
From 515b6aef09aa4433140305143ebb0700e7787266 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 3 Jul 2019 12:15:30 +0800
Subject: [PATCH 75/80] fix bug
---
app/controllers/homework_commons_controller.rb | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb
index 5de65210f..6cffa866d 100644
--- a/app/controllers/homework_commons_controller.rb
+++ b/app/controllers/homework_commons_controller.rb
@@ -202,6 +202,7 @@ class HomeworkCommonsController < ApplicationController
end
if params[:format] == "xlsx"
+ logger.info("#########______@work_count_________#######{@work_count}")
if @user_course_identity >= Course::STUDENT
tip_exception(403, "无权限操作")
elsif @work_count == 0
From 9e720b3d00ac61573eb97ab3987fbd7bcb3e639b Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 3 Jul 2019 12:24:09 +0800
Subject: [PATCH 76/80] fix bug
---
.../graduation_tasks_controller.rb | 9 ++++----
.../graduation_topics_controller.rb | 2 +-
.../homework_commons_controller.rb | 23 +++++++++++++------
3 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb
index 23344e7fc..a518ac954 100644
--- a/app/controllers/graduation_tasks_controller.rb
+++ b/app/controllers/graduation_tasks_controller.rb
@@ -130,11 +130,10 @@ class GraduationTasksController < ApplicationController
elsif @work_count == 0
normal_status(-1,"暂无提交的学生!")
else
- student_work_to_xlsx(@work_excel,@homework)
- exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
- render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals:
- {table_columns: @work_head_cells,task_users: @work_cells_column}
+ graduation_work_to_xlsx(@work_excel,@task,current_user)
+ exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@task.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
+ render xlsx: "#{exercise_export_name.strip.first(30)}",template: "graduation_tasks/tasks_list.xlsx.axlsx",locals: {table_columns:@head_cells_column, task_users:@task_cells_column}
end
elsif params[:format] == "zip"
if @user_course_identity >= Course::STUDENT
@@ -143,7 +142,7 @@ class GraduationTasksController < ApplicationController
zip_works = @work_excel.where("work_status > 0")
status = checkfileSize(zip_works)
if status == 0
- zipfile = zip_homework_common @homework, zip_works
+ zipfile = zip_homework_common @task, zip_works
file = decode64(zipfile[0][:base64file])
send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
else
diff --git a/app/controllers/graduation_topics_controller.rb b/app/controllers/graduation_topics_controller.rb
index c611069a8..2c9132520 100644
--- a/app/controllers/graduation_topics_controller.rb
+++ b/app/controllers/graduation_topics_controller.rb
@@ -269,7 +269,7 @@ class GraduationTopicsController < ApplicationController
course = @course
students = course.students.joins(user: :user_extension).order("user_extensions.student_id")
graduation_topic_to_xlsx(students,course)
- exercise_export_name = current_user.real_name + "_" + course.name + "_毕设选题" + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
+ exercise_export_name = "#{current_user.real_name}_#{course.name}_毕设选题_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "graduation_topics/export.xlsx.axlsx",locals: {table_columns:@topic_head_cells,topic_users:@topic_body_cells}
end
diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb
index 6cffa866d..50ec4f7db 100644
--- a/app/controllers/homework_commons_controller.rb
+++ b/app/controllers/homework_commons_controller.rb
@@ -208,11 +208,16 @@ class HomeworkCommonsController < ApplicationController
elsif @work_count == 0
normal_status(-1,"暂无提交的学生!")
else
- student_work_to_xlsx(@work_excel,@homework)
- exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
+ respond_to do |format|
+ format.xlsx{
+ student_work_to_xlsx(@work_excel,@homework)
+ exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
+
+ render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals:
+ {table_columns: @work_head_cells,task_users: @work_cells_column}
+ }
+ end
- render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals:
- {table_columns: @work_head_cells,task_users: @work_cells_column}
end
elsif params[:format] == "zip"
if @user_course_identity >= Course::STUDENT
@@ -221,9 +226,13 @@ class HomeworkCommonsController < ApplicationController
zip_works = @work_excel.where("work_status > 0")
status = checkfileSize(zip_works)
if status == 0
- zipfile = zip_homework_common @homework, zip_works
- file = decode64(zipfile[0][:base64file])
- send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
+ respond_to do |format|
+ format.zip{
+ zipfile = zip_homework_common @homework, zip_works
+ file = decode64(zipfile[0][:base64file])
+ send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
+ }
+ end
else
tip_exception(status == -2 ? "500M" : "无附件可下载")
end
From 44e4496928a1a8ae9a7fcc4c363070d8f60428fb Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 3 Jul 2019 12:56:43 +0800
Subject: [PATCH 77/80] =?UTF-8?q?xlsx=E5=AF=BC=E5=87=BA=E7=9A=84=E6=9D=A1?=
=?UTF-8?q?=E4=BB=B6=E5=88=A4=E6=96=AD=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../graduation_tasks_controller.rb | 65 +++++--------------
.../graduation_topics_controller.rb | 15 +++--
.../homework_commons_controller.rb | 49 ++------------
app/helpers/export_helper.rb | 11 +++-
4 files changed, 40 insertions(+), 100 deletions(-)
diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb
index a518ac954..aebd8b092 100644
--- a/app/controllers/graduation_tasks_controller.rb
+++ b/app/controllers/graduation_tasks_controller.rb
@@ -125,15 +125,19 @@ class GraduationTasksController < ApplicationController
@work_list = @work_list.page(page).per(limit)
if params[:format] == "xlsx"
+ complete_works = @work_excel.where("work_status > 0").size
if @user_course_identity >= Course::STUDENT
tip_exception(403, "无权限操作")
- elsif @work_count == 0
+ elsif complete_works == 0
normal_status(-1,"暂无提交的学生!")
else
-
- graduation_work_to_xlsx(@work_excel,@task,current_user)
- exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@task.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
- render xlsx: "#{exercise_export_name.strip.first(30)}",template: "graduation_tasks/tasks_list.xlsx.axlsx",locals: {table_columns:@head_cells_column, task_users:@task_cells_column}
+ respond_to do |format|
+ format.xlsx{
+ graduation_work_to_xlsx(@work_excel,@task,current_user)
+ exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@task.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
+ render xlsx: "#{exercise_export_name.strip.first(30)}",template: "graduation_tasks/tasks_list.xlsx.axlsx",locals: {table_columns:@head_cells_column, task_users:@task_cells_column}
+ }
+ end
end
elsif params[:format] == "zip"
if @user_course_identity >= Course::STUDENT
@@ -142,46 +146,18 @@ class GraduationTasksController < ApplicationController
zip_works = @work_excel.where("work_status > 0")
status = checkfileSize(zip_works)
if status == 0
- zipfile = zip_homework_common @task, zip_works
- file = decode64(zipfile[0][:base64file])
- send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
+ respond_to do |format|
+ format.zip{
+ zipfile = zip_homework_common @task, zip_works
+ file = decode64(zipfile[0][:base64file])
+ send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
+ }
+ end
else
tip_exception(status == -2 ? "500M" : "无附件可下载")
end
end
end
- #
- # respond_to do |format|
- # format.json
- # format.xlsx{
- # if @user_course_identity >= Course::STUDENT
- # tip_exception(403, "无权限操作")
- # else
- # if @work_count > 1
- # graduation_work_to_xlsx(@work_excel,@task,current_user)
- # exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@task.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
- # render xlsx: "#{exercise_export_name.strip.first(30)}",template: "graduation_tasks/tasks_list.xlsx.axlsx",locals: {table_columns:@head_cells_column, task_users:@task_cells_column}
- # else
- # normal_status(-1,"暂无提交的学生!")
- # end
- # end
- # }
- # format.zip{
- # if @user_course_identity >= Course::STUDENT
- # tip_exception(403, "无权限操作")
- # else
- # zip_works = @work_excel.where("work_status > 0")
- # status = checkfileSize(zip_works)
- # if status == 0
- # zipfile = zip_homework_common @task, zip_works
- # file = decode64(zipfile[0][:base64file])
- # send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
- # else
- # tip_exception(status == -2 ? "500" : "无附件可下载")
- # end
- # end
- # }
- # end
else
@work_list = @work
@view_work = false
@@ -190,15 +166,6 @@ class GraduationTasksController < ApplicationController
if params[:format] == "xlsx" || params[:format] == "zip"
normal_status(-1,"作业未发布")
end
- # respond_to do |format|
- # format.json
- # format.xlsx{
- # normal_status(-1,"作业未发布")
- # }
- # format.zip{
- # normal_status(-1,"作业未发布")
- # }
- # end
end
end
diff --git a/app/controllers/graduation_topics_controller.rb b/app/controllers/graduation_topics_controller.rb
index 2c9132520..b20b767a4 100644
--- a/app/controllers/graduation_topics_controller.rb
+++ b/app/controllers/graduation_topics_controller.rb
@@ -266,11 +266,16 @@ class GraduationTopicsController < ApplicationController
# 导出功能
def export
- course = @course
- students = course.students.joins(user: :user_extension).order("user_extensions.student_id")
- graduation_topic_to_xlsx(students,course)
- exercise_export_name = "#{current_user.real_name}_#{course.name}_毕设选题_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
- render xlsx: "#{exercise_export_name.strip.first(30)}",template: "graduation_topics/export.xlsx.axlsx",locals: {table_columns:@topic_head_cells,topic_users:@topic_body_cells}
+ begin
+ course = @course
+ students = course.students.joins(user: :user_extension).order("user_extensions.student_id")
+ graduation_topic_to_xlsx(students,course)
+ exercise_export_name = "#{current_user.real_name}_#{course.name}_毕设选题_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
+ render xlsx: "#{exercise_export_name.strip.first(30)}",template: "graduation_topics/export.xlsx.axlsx",locals: {table_columns:@topic_head_cells,topic_users:@topic_body_cells}
+ rescue Exception => e
+ uid_logger(e.message)
+ missing_template
+ end
end
private
diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb
index 50ec4f7db..2d52b6aa0 100644
--- a/app/controllers/homework_commons_controller.rb
+++ b/app/controllers/homework_commons_controller.rb
@@ -108,14 +108,8 @@ class HomeworkCommonsController < ApplicationController
@all_member_count = student_works.size
if @homework.publish_time.nil? || @homework.publish_time > Time.now
@student_works = []
- respond_to do |format|
- format.json
- format.xlsx{
- normal_status(-1,"作业未发布")
- }
- format.zip{
- normal_status(-1,"作业未发布")
- }
+ if params[:format] == "xlsx" || params[:format] == "zip"
+ normal_status(-1,"作业未发布")
end
else
if @user_course_identity == Course::STUDENT
@@ -202,10 +196,10 @@ class HomeworkCommonsController < ApplicationController
end
if params[:format] == "xlsx"
- logger.info("#########______@work_count_________#######{@work_count}")
+ complete_works = @work_excel.where("work_status > 0").size
if @user_course_identity >= Course::STUDENT
tip_exception(403, "无权限操作")
- elsif @work_count == 0
+ elsif complete_works == 0
normal_status(-1,"暂无提交的学生!")
else
respond_to do |format|
@@ -217,7 +211,6 @@ class HomeworkCommonsController < ApplicationController
{table_columns: @work_head_cells,task_users: @work_cells_column}
}
end
-
end
elsif params[:format] == "zip"
if @user_course_identity >= Course::STUDENT
@@ -238,40 +231,6 @@ class HomeworkCommonsController < ApplicationController
end
end
end
- # respond_to do |format|
- # format.json
- # format.xlsx{
- # if @user_course_identity >= Course::STUDENT
- # tip_exception(403, "无权限操作")
- # else
- # if @work_count > 1
- # student_work_to_xlsx(@work_excel,@homework)
- # exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
- #
- # render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals:
- # {table_columns: @work_head_cells,task_users: @work_cells_column}
- # else
- # normal_status(-1,"暂无提交的学生!")
- # end
- #
- # end
- # }
- # format.zip{
- # if @user_course_identity >= Course::STUDENT
- # tip_exception(403, "无权限操作")
- # else
- # zip_works = @work_excel.where("work_status > 0")
- # status = checkfileSize(zip_works)
- # if status == 0
- # zipfile = zip_homework_common @homework, zip_works
- # file = decode64(zipfile[0][:base64file])
- # send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
- # else
- # tip_exception(status == -2 ? "500M" : "无附件可下载")
- # end
- # end
- # }
- # end
end
end
diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb
index edb2b7e74..a23cb8a65 100644
--- a/app/helpers/export_helper.rb
+++ b/app/helpers/export_helper.rb
@@ -217,7 +217,16 @@ module ExportHelper
else
w_6 = nil
end
- w_7 = work.work_status
+ w_status = work.work_status.to_i
+ if w_status == 0
+ w_7 = "未提交"
+ elsif w_status == 1
+ w_7 = "按时提交"
+ elsif w_status == 2
+ w_7 = "延时提交"
+ else
+ w_7 = "--"
+ end
if task_project_boolean #关联项目
w_project = project_info work, current_user, @user_course_identity #因为课堂引用了export_helper
w_8 = w_project[:name]
From af2f6ae95e4581c1aeebfc76055911fb1c23ea28 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 3 Jul 2019 13:46:52 +0800
Subject: [PATCH 78/80] fix bug
---
app/controllers/zips_controller.rb | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb
index 984bef6d2..3b9fa7c02 100644
--- a/app/controllers/zips_controller.rb
+++ b/app/controllers/zips_controller.rb
@@ -101,14 +101,12 @@ class ZipsController < ApplicationController
@course = @homework.course
##7。2 -hs新增
@member = @course.course_member(current_user.id)
- @all_student_works = @homework.teacher_works(@member)
+ @all_student_works = @homework.teacher_works(@member).where("work_status > 0")
work_status = params[:work_status]
group_id = params[:course_group]
- if work_status.present? && !work_status.include?(0)
+ if work_status.present?
@all_student_works = @all_student_works.where(work_status:work_status)
- elsif work_status.present? && work_status.include?(0)
- normal_status(-1,"仅支持导出已提交的学生!")
end
if group_id.present?
From d3927146dcb2b2a227971d00a306ee903d6759df Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Wed, 3 Jul 2019 14:20:35 +0800
Subject: [PATCH 79/80] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/courses_controller.rb | 30 +++++++++++++++++----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 5c03dffee..fbc1c04cf 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -1062,14 +1062,22 @@ class CoursesController < ApplicationController
AND student_works.user_id = cm.user_id
) AS score,
(SELECT max(student_id) FROM user_extensions WHERE user_extensions.user_id = cm.user_id) AS student_id,
- (SELECT count(messages.id) FROM messages join boards on messages.board_id = boards.id WHERE boards.course_id = #{@course.id} AND messages.author_id = cm.user_id and messages.parent_id is null) AS message_num,
- (SELECT count(messages.id) FROM messages join boards on messages.board_id = boards.id WHERE boards.course_id = #{@course.id} AND messages.author_id = cm.user_id and messages.parent_id is not null) AS message_reply_num,
- (SELECT count(attachments.id) FROM attachments WHERE container_id = #{@course.id} and container_type = "Course" AND attachments.author_id = cm.user_id) AS resource_num,
- (SELECT count(jfm.id) FROM journals_for_messages AS jfm, homework_commons hs WHERE jfm.jour_id = hs.id AND jfm.user_id = cm.user_id and jfm.jour_type = "HomeworkCommon" and hs.course_id = #{@course.id}) AS homework_journal_num,
- (SELECT COUNT(gw.id) FROM graduation_works AS gw, graduation_tasks AS gt WHERE gw.graduation_task_id = gt.id AND gt.course_id = #{@course.id} AND gw.work_status != 0 AND gw.user_id = cm.user_id) AS graduation_num,
- (SELECT COUNT(ss.id) FROM student_works AS ss ,homework_commons AS hc WHERE ss.homework_common_id = hc.id AND hc.course_id = #{@course.id} AND ss.work_status != 0 AND ss.user_id = cm.user_id) AS homework_num,
- (SELECT COUNT(eu.id) FROM exercise_users AS eu,exercises WHERE eu.exercise_id = exercises.id AND exercises.course_id = #{@course.id} AND eu.commit_status = 1 AND eu.user_id = cm.user_id) AS exercise_num,
- (SELECT COUNT(pu.id) FROM poll_users AS pu, polls WHERE pu.poll_id = polls.id AND polls.course_id = #{@course.id} AND pu.commit_status = 1 AND pu.user_id = cm.user_id) AS poll_num
+ (SELECT count(messages.id) FROM messages join boards on messages.board_id = boards.id WHERE boards.course_id = #{@course.id}
+ AND messages.author_id = cm.user_id and messages.parent_id is null) AS message_num,
+ (SELECT count(messages.id) FROM messages join boards on messages.board_id = boards.id WHERE boards.course_id = #{@course.id}
+ AND messages.author_id = cm.user_id and messages.parent_id is not null) AS message_reply_num,
+ (SELECT count(attachments.id) FROM attachments WHERE container_id = #{@course.id} and container_type = "Course"
+ AND attachments.author_id = cm.user_id) AS resource_num,
+ (SELECT count(jfm.id) FROM journals_for_messages AS jfm, homework_commons hs WHERE jfm.jour_id = hs.id AND
+ jfm.user_id = cm.user_id and jfm.jour_type = "HomeworkCommon" and hs.course_id = #{@course.id}) AS homework_journal_num,
+ (SELECT COUNT(gw.id) FROM graduation_works AS gw, graduation_tasks AS gt WHERE gw.graduation_task_id = gt.id AND
+ gt.course_id = #{@course.id} AND gw.work_status != 0 AND gw.user_id = cm.user_id) AS graduation_num,
+ (SELECT COUNT(ss.id) FROM student_works AS ss ,homework_commons AS hc WHERE ss.homework_common_id = hc.id AND
+ hc.course_id = #{@course.id} AND ss.work_status != 0 AND ss.user_id = cm.user_id) AS homework_num,
+ (SELECT COUNT(eu.id) FROM exercise_users AS eu,exercises WHERE eu.exercise_id = exercises.id AND exercises.course_id = #{@course.id}
+ AND eu.commit_status = 1 AND eu.user_id = cm.user_id) AS exercise_num,
+ (SELECT COUNT(pu.id) FROM poll_users AS pu, polls WHERE pu.poll_id = polls.id AND polls.course_id = #{@course.id}
+ AND pu.commit_status = 1 AND pu.user_id = cm.user_id) AS poll_num
FROM course_members cm}
if search.present? && group_id.present?
sql_select += %Q{ join users on cm.user_id = users.id
@@ -1078,7 +1086,7 @@ class CoursesController < ApplicationController
(concat(users.lastname, users.firstname) like '%#{search}%' or ue.student_id like '%#{search}%') ORDER BY score desc}
elsif search.present?
- ql_select += %Q{ join users on cm.user_id = users.id
+ sql_select += %Q{ join users on cm.user_id = users.id
joins user_extensions ue on ue.user_id = users.id
WHERE cm.role = 4 and
(concat(users.lastname, users.firstname) like '%#{search}%' or ue.student_id like '%#{search}%') ORDER BY score desc}
@@ -1101,7 +1109,7 @@ class CoursesController < ApplicationController
common_titles = common_homeworks.pluck(:name)+ ["总得分"]
common_homeworks = common_homeworks.includes(:score_student_works)
- group_homeworks = homeworks.search_homework_type(3).includes(:score_student_works) #全部分组作业
+ group_homeworks = homeworks.search_homework_type(3) #全部分组作业
group_titles = group_homeworks.pluck(:name)+ ["总得分"]
group_homeworks = group_homeworks.includes(:score_student_works)
@@ -1179,7 +1187,7 @@ class CoursesController < ApplicationController
c_poll_num = user_poll_num*7
c_file_num = user_file_num*5
c_message_num = user_messages_num*2
- c_reply_num = user_reply_num*2
+ c_reply_num = user_reply_num
user_activity_levels = c_works_num + c_exercise_num + c_poll_num + c_file_num + c_message_num + c_reply_num + user_work_reply_num
user_ac_level = {
u_1: user_name,
From 19ef46f0778775dd80ea25812209b4b8c056f20d Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 3 Jul 2019 14:21:53 +0800
Subject: [PATCH 80/80] fix bug
---
app/controllers/graduation_tasks_controller.rb | 2 +-
app/controllers/homework_commons_controller.rb | 2 +-
app/controllers/zips_controller.rb | 11 ++++++++---
app/services/export_shixun_report_service.rb | 3 ++-
4 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb
index aebd8b092..a89a81798 100644
--- a/app/controllers/graduation_tasks_controller.rb
+++ b/app/controllers/graduation_tasks_controller.rb
@@ -129,7 +129,7 @@ class GraduationTasksController < ApplicationController
if @user_course_identity >= Course::STUDENT
tip_exception(403, "无权限操作")
elsif complete_works == 0
- normal_status(-1,"暂无提交的学生!")
+ normal_status(-1,"暂无用户提交!")
else
respond_to do |format|
format.xlsx{
diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb
index 2d52b6aa0..fe2adba45 100644
--- a/app/controllers/homework_commons_controller.rb
+++ b/app/controllers/homework_commons_controller.rb
@@ -200,7 +200,7 @@ class HomeworkCommonsController < ApplicationController
if @user_course_identity >= Course::STUDENT
tip_exception(403, "无权限操作")
elsif complete_works == 0
- normal_status(-1,"暂无提交的学生!")
+ normal_status(-1,"暂无用户提交!")
else
respond_to do |format|
format.xlsx{
diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb
index 3b9fa7c02..8553cbb44 100644
--- a/app/controllers/zips_controller.rb
+++ b/app/controllers/zips_controller.rb
@@ -44,9 +44,12 @@ class ZipsController < ApplicationController
ActiveRecord::Base.transaction do
begin
@exercise = Exercise.includes(:exercise_users,:exercise_questions).find_by(id:params[:exercise_id])
+ @exercise_status = @exercise.get_exercise_status(current_user.id)
group_id = params[:exercise_group_id]
if @exercise.blank?
normal_status(-1,"试卷不存在")
+ elsif @exercise_status == 1
+ normal_status(-1,"试卷未发布")
else
@course = @exercise.course
default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed
@@ -66,7 +69,7 @@ class ZipsController < ApplicationController
if params[:commit_status].present? && (params[:commit_status].to_i == 1)
@exercise_users_list = @exercise_users_list.where(commit_status:params[:commit_status])
elsif params[:commit_status].present? && (params[:commit_status].to_i == 0)
- normal_status(-1,"仅支持导出已提交的学生!")
+ normal_status(-1,"暂无用户提交!")
end
#可以分班选择
@@ -84,7 +87,7 @@ class ZipsController < ApplicationController
default_ex_users_size = @ex_users&.size
if default_ex_users_size.blank? || default_ex_users_size == 0
- normal_status(-1,"导出失败,暂时没有已提交的学生")
+ normal_status(-1,"暂无用户提交")
elsif default_ex_users_size > 100
normal_status(-2,"100")
end
@@ -98,6 +101,8 @@ class ZipsController < ApplicationController
def load_homework
@homework = HomeworkCommon.find(params[:homework_common_id])
+
+
@course = @homework.course
##7。2 -hs新增
@member = @course.course_member(current_user.id)
@@ -121,7 +126,7 @@ class ZipsController < ApplicationController
student_work_sizes = @all_student_works&.size
if student_work_sizes.blank? || student_work_sizes == 0
- normal_status(-1,"导出失败,暂时没有已提交的学生")
+ normal_status(-1,"暂无用户提交")
elsif student_work_sizes > 100
normal_status(-2,"100")
end
diff --git a/app/services/export_shixun_report_service.rb b/app/services/export_shixun_report_service.rb
index 8358d422e..4c8dab6aa 100644
--- a/app/services/export_shixun_report_service.rb
+++ b/app/services/export_shixun_report_service.rb
@@ -45,7 +45,8 @@ class ExportShixunReportService
@games = @work.myshixun.games.includes(:challenge, :game_codes,:outputs) if @work.myshixun
# 用户最大评测次数
- @user_evaluate_count = @games.inject(0){|sum, g| sum + g.outputs.pluck(:query_index).first } if @games
+ @user_evaluate_count = @games.pluck(:evaluate_count).sum if @games
+ # @user_evaluate_count = @games.inject(0){|sum, g| sum + g.outputs.pluck(:query_index)&.first } if @games
# 图形效率图的数据
@echart_data = student_efficiency(homework, @work)
@myself_eff = @echart_data[:efficiency_list].find { |item| item.last == @user.id }