From 1192a3c93d8c5f1561f93b7de8fdb161110785a7 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 26 Mar 2019 11:00:38 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E6=88=90=E7=BB=A9?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=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 | 26 +++++++----- app/helpers/application_helper.rb | 61 +++++++++++++++++++++++++++ app/helpers/student_work_helper.rb | 61 --------------------------- 3 files changed, 76 insertions(+), 72 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index c2132bf1..92ee602b 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1190,9 +1190,9 @@ class CoursesController < ApplicationController @all_members = searchmember_by_name(student_homework_score(0, 0, 10,"desc"), q) end - @homeworks = @course.homework_commons.where("publish_time <= '#{Time.now}'").order("publish_time asc") - @exercises = @course.exercises.where("publish_time <= '#{Time.now}'").order("publish_time asc") - @tasks = @course.graduation_tasks.where("publish_time <= '#{Time.now}'").order("publish_time asc") + @homeworks = @course.homework_commons.where("publish_time <= '#{Time.now}'").order("IF(ISNULL(publish_time),0,1), publish_time DESC, created_at DESC") + @exercises = @course.exercises.where("publish_time <= '#{Time.now}'").order("IF(ISNULL(publish_time),0,1), publish_time DESC, created_at DESC") + @tasks = @course.graduation_tasks.where("publish_time <= '#{Time.now}'").order("IF(ISNULL(publish_time),0,1), publish_time DESC, created_at DESC") respond_to do |format| format.xls { @@ -2425,7 +2425,7 @@ class CoursesController < ApplicationController sheet1[count_row,column+=1] = member.course_group_id == 0 ? "暂无" : member.course_group.name # current_col = 5 shixun_score = 0 - homeworks.where(:homework_type => 4).each do |homework| + homeworks.where(:homework_type => 4).includes(:student_works).each do |homework| student_works = homework.student_works.where("user_id = #{member.user.id}") if student_works.empty? sheet1[count_row,column+=1] = 0 @@ -2437,7 +2437,7 @@ class CoursesController < ApplicationController # current_col += 1 end common_score = 0 - homeworks.where(:homework_type => 1).each do |homework| + homeworks.where(:homework_type => 1).includes(:student_works).each do |homework| student_works = homework.student_works.where("user_id = #{member.user.id}") if student_works.empty? sheet1[count_row,column+=1] = 0 @@ -2449,7 +2449,7 @@ class CoursesController < ApplicationController # current_col += 1 end group_score = 0 - homeworks.where(:homework_type => 3).each do |homework| + homeworks.where(:homework_type => 3).includes(:student_works).each do |homework| student_works = homework.student_works.where("user_id = #{member.user.id}") if student_works.empty? sheet1[count_row,column+=1] = 0 @@ -2461,7 +2461,7 @@ class CoursesController < ApplicationController # current_col += 1 end exercise_score = 0 - exercises.each do |exercise| + exercises.includes(:exercise_users).each do |exercise| exercise_user = exercise.exercise_users.where("user_id = #{member.user.id}") if exercise_user.empty? sheet1[count_row,column+=1] = 0 @@ -2474,7 +2474,7 @@ class CoursesController < ApplicationController end graduation_score = 0 - tasks.each do |task| + tasks.includes(:graduation_works).each do |task| graduation_works = task.graduation_works.where("user_id = #{member.user.id}") if graduation_works.empty? sheet1[count_row,column+=1] = 0 @@ -2550,7 +2550,7 @@ class CoursesController < ApplicationController count_row += 1 end - homeworks.where(:homework_type => 4).each_with_index do |home, i| + homeworks.where(:homework_type => 4).includes(:student_works).each_with_index do |home, i| sheet = book.create_worksheet :name => "实训作业第#{i+1}次" sheet[0,0] = "课程编号" sheet[0,1] = course.id @@ -2567,6 +2567,10 @@ class CoursesController < ApplicationController sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) count_row = 5 items = home.student_works.where("work_status != 0").order("work_score desc") + if items.count == 0 && home.publish_time < Time.now && !course.is_end + update_shixun_work_status home + items = StudentWork.where("work_status != 0 and homework_common_id = #{home.id}").order("work_score desc") + end items.each_with_index do |stu, j| sheet[count_row,0]= j + 1 sheet[count_row,1] = stu.user.show_real_name @@ -2580,7 +2584,7 @@ class CoursesController < ApplicationController end end - homeworks.where(:homework_type => 1).each_with_index do |home, i| + homeworks.where(:homework_type => 1).includes(:student_works).each_with_index do |home, i| sheet = book.create_worksheet :name => "普通作业第#{i+1}次" sheet[0,0] = "课程编号" sheet[0,1] = course.id @@ -2627,7 +2631,7 @@ class CoursesController < ApplicationController end - homeworks.where(:homework_type => 3).each_with_index do |home, i| + homeworks.where(:homework_type => 3).includes(:student_works).each_with_index do |home, i| sheet = book.create_worksheet :name => "分组作业第#{i+1}次" sheet[0,0] = "课程编号" sheet[0,1] = course.id diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 79732e10..bb413608 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -6521,6 +6521,67 @@ def visible_task_count course, is_teacher task_count end +def update_shixun_work_status homework + shixun = homework.shixuns.first + student_works = homework.student_works.where(:work_status => 0) + homework_challenge_settings = homework.homework_challenge_settings + challeng_ids = homework_challenge_settings.map(&:challenge_id) + # 取已发布的作品 + if homework.unified_setting + student_works = student_works + else + setting = homework.homework_group_settings.where("publish_time < '#{Time.now}'") + if setting.blank? + student_works = student_works.where("0=1") + else + users = homework.course.members.where(:course_group_id => setting.map(&:course_group_id)) + student_works = student_works.where(:user_id => users.map(&:user_id)) + end + end + # 已发布作品且状态为未提交的作品 如果有开启过实训则更新状态 + myshixuns = Myshixun.where(:shixun_id => shixun.id, :user_id => student_works.map(&:user_id)) + myshixuns.each do |myshixun| + work = student_works.where(:user_id => myshixun.user_id).first + member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{work.user_id}").first + setting_time = homework_group_setting homework, member.try(:course_group_id) + games = myshixun.games.where(:challenge_id => challeng_ids) + myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil + compelete_status = 0 + if myshixun_endtime.present? && myshixun_endtime < setting_time.end_time + if myshixun_endtime < setting_time.publish_time + compelete_status = 2 + else + compelete_status = 1 + end + end + if setting_time.end_time > Time.now + work.update_attributes(:work_status => 1, :late_penalty => 0, :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status) + else + work.update_attributes(:work_status => ((myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)) ? 1 : 2), :late_penalty => (myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) ? 0 : homework.late_penalty), :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status) + end + set_shixun_final_score work, homework.homework_detail_manual.answer_open_evaluation, homework_challenge_settings + end + # 更新所有学生的效率分 + update_student_eff_score HomeworkCommon.where(:id => homework.id).first +=begin + student_works.each do |work| + if work.work_status == 0 + myshixun = Myshixun.where(:shixun_id => shixun.id, :user_id => work.user_id).first + if myshixun + member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{User.current.id}").first + setting_time = homework_group_setting homework, member.try(:course_group_id) + if setting_time.end_time > Time.now + work.update_attributes(:work_status => 1, :late_penalty => 0, :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id) + else + work.update_attributes(:work_status => ((myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)) ? 1 : 2), :late_penalty => (myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) ? 0 : homework.late_penalty), :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id) + end + end + end + set_shixun_final_score work, homework.homework_detail_manual.answer_open_evaluation, homework_challenge_settings + end +=end +end + #成绩计算 def set_final_score homework,student_work if homework && homework.homework_detail_manual && !student_work.ultimate_score diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index c40a9a54..94b8348d 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -3,67 +3,6 @@ include UserScoreHelper module StudentWorkHelper - def update_shixun_work_status homework - shixun = homework.homework_commons_shixuns.shixun - student_works = homework.student_works.where(:work_status => 0) - homework_challenge_settings = homework.homework_challenge_settings - challeng_ids = homework_challenge_settings.map(&:challenge_id) - # 取已发布的作品 - if homework.unified_setting - student_works = student_works - else - setting = homework.homework_group_settings.where("publish_time < '#{Time.now}'") - if setting.blank? - student_works = student_works.where("0=1") - else - users = homework.course.members.where(:course_group_id => setting.map(&:course_group_id)) - student_works = student_works.where(:user_id => users.map(&:user_id)) - end - end - # 已发布作品且状态为未提交的作品 如果有开启过实训则更新状态 - myshixuns = Myshixun.where(:shixun_id => shixun.id, :user_id => student_works.map(&:user_id)) - myshixuns.each do |myshixun| - work = student_works.where(:user_id => myshixun.user_id).first - member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{work.user_id}").first - setting_time = homework_group_setting homework, member.try(:course_group_id) - games = myshixun.games.where(:challenge_id => challeng_ids) - myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil - compelete_status = 0 - if myshixun_endtime.present? && myshixun_endtime < setting_time.end_time - if myshixun_endtime < setting_time.publish_time - compelete_status = 2 - else - compelete_status = 1 - end - end - if setting_time.end_time > Time.now - work.update_attributes(:work_status => 1, :late_penalty => 0, :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status) - else - work.update_attributes(:work_status => ((myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)) ? 1 : 2), :late_penalty => (myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) ? 0 : homework.late_penalty), :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status) - end - set_shixun_final_score work, homework.homework_detail_manual.answer_open_evaluation, homework_challenge_settings - end - # 更新所有学生的效率分 - update_student_eff_score HomeworkCommon.where(:id => homework.id).first -=begin - student_works.each do |work| - if work.work_status == 0 - myshixun = Myshixun.where(:shixun_id => shixun.id, :user_id => work.user_id).first - if myshixun - member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{User.current.id}").first - setting_time = homework_group_setting homework, member.try(:course_group_id) - if setting_time.end_time > Time.now - work.update_attributes(:work_status => 1, :late_penalty => 0, :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id) - else - work.update_attributes(:work_status => ((myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)) ? 1 : 2), :late_penalty => (myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) ? 0 : homework.late_penalty), :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id) - end - end - end - set_shixun_final_score work, homework.homework_detail_manual.answer_open_evaluation, homework_challenge_settings - end -=end - end - #获取当前用户的项目列表 def user_projects_option projects = User.current.projects.visible From b4bbac6fae0698c569f2f707fdb2459183e69202 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 26 Mar 2019 11:29:59 +0800 Subject: [PATCH 2/6] =?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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 92ee602b..c7909c94 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1190,9 +1190,9 @@ class CoursesController < ApplicationController @all_members = searchmember_by_name(student_homework_score(0, 0, 10,"desc"), q) end - @homeworks = @course.homework_commons.where("publish_time <= '#{Time.now}'").order("IF(ISNULL(publish_time),0,1), publish_time DESC, created_at DESC") - @exercises = @course.exercises.where("publish_time <= '#{Time.now}'").order("IF(ISNULL(publish_time),0,1), publish_time DESC, created_at DESC") - @tasks = @course.graduation_tasks.where("publish_time <= '#{Time.now}'").order("IF(ISNULL(publish_time),0,1), publish_time DESC, created_at DESC") + @homeworks = @course.homework_commons.where("publish_time <= '#{Time.now}'").order("publish_time asc, created_at asc") + @exercises = @course.exercises.where("publish_time <= '#{Time.now}'").order("publish_time asc, created_at asc") + @tasks = @course.graduation_tasks.where("publish_time <= '#{Time.now}'").order("publish_time asc, created_at asc") respond_to do |format| format.xls { From 4cd1f7c305f7f9031ae050de80c314ff6b38a235 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 26 Mar 2019 11:46:20 +0800 Subject: [PATCH 3/6] =?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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index c7909c94..43b0076f 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -2390,8 +2390,8 @@ class CoursesController < ApplicationController sheet1[4,3] = "学号" sheet1[4,4] = "分班" current_col = 4 - for i in 0 ... homeworks.where(:homework_type => 4).count - sheet1[4,current_col+=1] = "实训作业第"+(i+1).to_s+"次" + homeworks.where(:homework_type => 4).each do |homework| + sheet1[4,current_col+=1] = "#{homework.name}" end for i in 0 ... homeworks.where(:homework_type => 1).count sheet1[4,current_col+=1] = "普通作业第"+(i+1).to_s+"次" @@ -2551,7 +2551,7 @@ class CoursesController < ApplicationController end homeworks.where(:homework_type => 4).includes(:student_works).each_with_index do |home, i| - sheet = book.create_worksheet :name => "实训作业第#{i+1}次" + sheet = book.create_worksheet :name => "#{home.name}" sheet[0,0] = "课程编号" sheet[0,1] = course.id sheet[1,0] = "课程名称" From 49cf70f38fe7eaddf8fd56accb75b86c0b15f681 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 26 Mar 2019 15:33:14 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E3=80=90=E7=94=9F=E4=BA=A7=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E3=80=91=E5=AE=9E=E8=AE=AD=E9=85=8D=E7=BD=AE=E9=A1=B5?= =?UTF-8?q?=E7=9A=84=E8=AF=84=E6=B5=8B=E8=84=9A=E6=9C=AC=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E6=97=A0=E6=B3=95=E6=B8=85=E7=A9=BA=EF=BC=8C?= =?UTF-8?q?=E5=BF=85=E9=A1=BB=E9=80=9A=E8=BF=87=E9=87=8D=E6=96=B0=E6=8A=80?= =?UTF-8?q?=E6=9C=AF=E5=B9=B3=E5=8F=B0=E6=89=8D=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 15 ++++++++++----- app/views/shixuns/_settings_edit.html.erb | 3 ++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 18107cae..2f07b182 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -1163,11 +1163,16 @@ class ShixunsController < ApplicationController end def get_script_contents - mirrir_script = MirrorScript.find(params[:script_id]) - script = mirrir_script.try(:script) - description = mirrir_script.try(:description) - script = modify_shixun_script @shixun, script - render :json => {contents: script, description: description} + if params[:script_id].to_i == -1 + render :json => {contents: "", description: ""} + else + mirrir_script = MirrorScript.find(params[:script_id]) + script = mirrir_script.try(:script) + description = mirrir_script.try(:description) + script = modify_shixun_script @shixun, script + render :json => {contents: script, description: description} + end + end def get_common_script diff --git a/app/views/shixuns/_settings_edit.html.erb b/app/views/shixuns/_settings_edit.html.erb index b68a4f57..05ffd841 100644 --- a/app/views/shixuns/_settings_edit.html.erb +++ b/app/views/shixuns/_settings_edit.html.erb @@ -85,8 +85,9 @@
> - + "/>
+

<% @shixun.standrad_script.each do |script| %>

<%= script.script_type %>

<% end %> From a71e82ae787645c3625b9c419f2e87ff3e43f5cd Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 26 Mar 2019 16:13:23 +0800 Subject: [PATCH 5/6] https://www.trustie.net/issues/18634 --- app/services/shixuns_service.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/services/shixuns_service.rb b/app/services/shixuns_service.rb index ffec7924..f4842076 100644 --- a/app/services/shixuns_service.rb +++ b/app/services/shixuns_service.rb @@ -125,9 +125,21 @@ class ShixunsService praise_count = d.praise_tread.where(:praise_or_tread => 1).count user_praise= d.praise_tread.select{|pt| pt.user_id == current_user.id}.length > 0 ? true : false # 实训(TPM)的管理员可以看到隐藏的评论 - parents = {:id => d.id, :content => d.content, :time => time_from_now(d.created_at), :position => d.position, :user_id => d.user.try(:id), :reward => d.reward, - :image_url => url_to_avatar(d.user), :username => d.username, :user_login => d.user.try(:login), :shixun_id => dis.id, :hidden => d.hidden, - :manager => current_user.manager_of_shixun?(dis, current_user), :praise_count => praise_count, :user_praise => user_praise, :admin => current_user.admin?} + manager = current_user.manager_of_shixun?(dis, current_user) + game_url = + if manager + challenge_id = dis.challenges.where(position: d.position).pluck(:id).first + game_identifier = Game.where(user_id: current_user, + challenge_id: challenge_id).pluck(:identifier).first + "/tasks/#{game_identifier}" + else + "" + end + parents = {:id => d.id, :content => d.content, :time => time_from_now(d.created_at), :position => d.position, + :user_id => d.user.try(:id), :reward => d.reward, :image_url => url_to_avatar(d.user), + :username => d.username, :user_login => d.user.try(:login), :shixun_id => dis.id, :hidden => d.hidden, + :manager => manager, :praise_count => praise_count, game_url: game_url, + :user_praise => user_praise, :admin => current_user.admin?} # 现在没有二级回复,所以查询的时候直接从root_id取 children = Discuss.where(:root_id => d.id).includes(:user).reorder("created_at asc") From 59884af2f9f09f70350895d8be58a7e952135851 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 26 Mar 2019 16:25:13 +0800 Subject: [PATCH 6/6] =?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 | 52 +++++++++++++-------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 43b0076f..9a84fc6b 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -2431,8 +2431,8 @@ class CoursesController < ApplicationController sheet1[count_row,column+=1] = 0 else work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score - sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(2) - shixun_score += work_score < 0 ? 0 : work_score.round(2) + sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) + shixun_score += work_score < 0 ? 0 : work_score.round(1) end # current_col += 1 end @@ -2443,8 +2443,8 @@ class CoursesController < ApplicationController sheet1[count_row,column+=1] = 0 else work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score - sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(2) - common_score += work_score < 0 ? 0 : work_score.round(2) + sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) + common_score += work_score < 0 ? 0 : work_score.round(1) end # current_col += 1 end @@ -2455,8 +2455,8 @@ class CoursesController < ApplicationController sheet1[count_row,column+=1] = 0 else work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score - sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(2) - group_score += work_score < 0 ? 0 : work_score.round(2) + sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) + group_score += work_score < 0 ? 0 : work_score.round(1) end # current_col += 1 end @@ -2467,8 +2467,8 @@ class CoursesController < ApplicationController sheet1[count_row,column+=1] = 0 else work_score = exercise_user.first.score.nil? ? 0 : exercise_user.first.score - sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(2) - exercise_score += work_score < 0 ? 0 : work_score.round(2) + sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) + exercise_score += work_score < 0 ? 0 : work_score.round(1) end # current_col += 1 end @@ -2480,8 +2480,8 @@ class CoursesController < ApplicationController sheet1[count_row,column+=1] = 0 else work_score = graduation_works.first.work_score.nil? ? 0 : graduation_works.first.work_score - sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(2) - graduation_score += work_score < 0 ? 0 : work_score.round(2) + sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) + graduation_score += work_score < 0 ? 0 : work_score.round(1) end # current_col += 1 end @@ -2494,7 +2494,7 @@ class CoursesController < ApplicationController if tasks.count > 0 sheet1[count_row,column+=1] = graduation_score end - sheet1[count_row,column+=1] = sum.round(2) + sheet1[count_row,column+=1] = sum.round(1) count_row += 1 end @@ -2578,7 +2578,7 @@ class CoursesController < ApplicationController sheet[count_row,3] = stu.user.user_extensions.student_id sheet[count_row,4] = strip_html stu.description sheet[count_row,5] = stu.late_penalty - sheet[count_row,6] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,6] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) sheet[count_row,7] = format_time(stu.commit_time) count_row += 1 end @@ -2613,17 +2613,17 @@ class CoursesController < ApplicationController sheet[count_row,2] = stu.user.login sheet[count_row,3] = stu.user.user_extensions.student_id sheet[count_row,4] = strip_html stu.description - sheet[count_row,5] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2) - sheet[count_row,6] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(2) + sheet[count_row,5] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) + sheet[count_row,6] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) if home.anonymous_comment ==0 - sheet[count_row,7] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2) + sheet[count_row,7] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty - sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) sheet[count_row,11] = format_time(stu.commit_time) else sheet[count_row,7] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty - sheet[count_row,8] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,8] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) sheet[count_row,9] = format_time(stu.commit_time) end count_row += 1 @@ -2662,17 +2662,17 @@ class CoursesController < ApplicationController sheet[count_row,3] = stu.user.user_extensions.student_id sheet[count_row,4] = get_group_member_names home.student_works.where(:group_id => stu.group_id).pluck(:user_id) sheet[count_row,5] = strip_html stu.description - sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2) - sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(2) + sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) + sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) if home.anonymous_comment ==0 - sheet[count_row,8] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2) + sheet[count_row,8] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty sheet[count_row,10] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty - sheet[count_row,11] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,11] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) sheet[count_row,12] = format_time(stu.commit_time) else sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty - sheet[count_row,9] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,9] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) sheet[count_row,10] = format_time(stu.commit_time) end count_row += 1 @@ -2704,7 +2704,7 @@ class CoursesController < ApplicationController sheet[count_row,3] = stu.user.user_extensions.student_id sheet[count_row,4] = stu.objective_score == -1 ? "0.0" : format("%.1f",stu.objective_score) sheet[count_row,5] = stu.subjective_score == -1 ? "0.0" : format("%.1f",stu.subjective_score) - sheet[count_row,6] = stu.score.nil? ? '--' : stu.score.round(2) + sheet[count_row,6] = stu.score.nil? ? '--' : stu.score.round(1) sheet[count_row,7] = stu.commit_status == 0 ? l(:excel_no_answer) : format_time(stu.start_at) count_row += 1 end @@ -2745,12 +2745,12 @@ class CoursesController < ApplicationController sheet[count_row,column+=1] = get_group_member_names task.graduation_works.where(:group_id => stu.group_id).pluck(:user_id) end sheet[count_row,column+=1] = strip_html stu.description - sheet[count_row,column+=1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2) + sheet[count_row,column+=1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) if task.cross_comment - sheet[count_row,column+=1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(2) + sheet[count_row,column+=1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(1) end sheet[count_row,column+=1] = stu.late_penalty - sheet[count_row,column+=1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,column+=1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) sheet[count_row,column+=1] = format_time(stu.commit_time) count_row += 1 end