From 2b4c3e9efc6a5e66137dca53a3b4dc9abee4ee61 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 20 Nov 2019 16:39:35 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E7=9A=84api=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/weapps/courses_controller.rb | 2 +- app/helpers/weapps/courses_helper.rb | 43 +++++++++++++++++-- .../weapps/courses/students.json.jbuilder | 12 +----- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/app/controllers/weapps/courses_controller.rb b/app/controllers/weapps/courses_controller.rb index a36d56402..685a81423 100644 --- a/app/controllers/weapps/courses_controller.rb +++ b/app/controllers/weapps/courses_controller.rb @@ -46,7 +46,7 @@ class Weapps::CoursesController < Weapps::BaseController @applications_size = CourseMessage.unhandled_join_course_requests_by_course(@course).size - @teacher_list = @teacher_list.preload(user: [user_extension: :school]).order("CONVERT(CONCAT(users.lastname, users.firstname) USING gbk) COLLATE gbk_chinese_ci asc") + @teacher_list = @teacher_list.preload(user: [user_extension: :school]) end # 批量删除教师或助教 diff --git a/app/helpers/weapps/courses_helper.rb b/app/helpers/weapps/courses_helper.rb index cc1b5b112..a58127c4c 100644 --- a/app/helpers/weapps/courses_helper.rb +++ b/app/helpers/weapps/courses_helper.rb @@ -12,12 +12,33 @@ module Weapps::CoursesHelper school: teacher_user.school_name, image_url: url_to_avatar(teacher_user)} pinyin = Pinyin.t(name.strip, splitter: '') first_char = pinyin[0] - puts first_char - if first_char.ord >= 97 && first_char.ord <= 122 - letter = (first_char.ord - 32).chr.to_s + letter = first_letter first_char + if data.pluck(:letter).include?(letter) + data.select{|a|a[:letter]==letter}.first[:items] << item else - letter = '#' + data << {letter: letter, items: [item]} end + end + end + data = data.sort do |a, b| + [a[:letter]] <=> [b[:letter]] + end + return data + end + + + def student_list students, excellent + data = [] + students.each do |student| + if student.user.present? + student_user = student.user + name = student_user.real_name + phone = excellent ? "" : student_user.hidden_phone + item = {name: name, course_member_id: student.id, login: student_user.login, user_id: student.user_id, + student_id: student_user.student_id, image_url: url_to_avatar(student_user), phone: phone} + pinyin = Pinyin.t(name.strip, splitter: '') + first_char = pinyin[0] + letter = first_letter first_char if data.pluck(:letter).include?(letter) data.select{|a|a[:letter]==letter}.first[:items] << item else @@ -25,6 +46,20 @@ module Weapps::CoursesHelper end end end + data = data.sort do |a, b| + [a[:letter]] <=> [b[:letter]] + end return data end + + def first_letter char + if char.ord >= 97 && char.ord <= 122 + letter = (char.ord - 32).chr.to_s + elsif char.ord >= 65 && char.ord <= 90 + letter = char + else + letter = '#' + end + letter + end end \ No newline at end of file diff --git a/app/views/weapps/courses/students.json.jbuilder b/app/views/weapps/courses/students.json.jbuilder index fa0cbb972..5aaaee0aa 100644 --- a/app/views/weapps/courses/students.json.jbuilder +++ b/app/views/weapps/courses/students.json.jbuilder @@ -1,12 +1,2 @@ -json.students do - json.array! @students do |student| - json.user_id student.user_id - json.login student.user.try(:login) - json.name student.user.try(:real_name) - json.student_id student.user.try(:student_id) - json.course_member_id student.id - json.user_phone @course.excellent ? "" : student.user.hidden_phone - json.image_url url_to_avatar(student.user) - end -end +json.students student_list @students, @course.excellent json.students_count @students_count \ No newline at end of file From 4b7d59e8da8a4edaf3d05e490f20ab8e3556244f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 20 Nov 2019 16:44:46 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=95=88=E7=8E=87=E5=88=86=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_commons_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 062e4877f..55b184ba0 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -577,8 +577,8 @@ class HomeworkCommonsController < ApplicationController tip_exception("缺少answer_open_evaluation参数") if params[:answer_open_evaluation].nil? tip_exception("缺少work_efficiency参数") if params[:work_efficiency].nil? tip_exception("缺少eff_score参数") if params[:work_efficiency] && params[:eff_score].blank? - tip_exception("效率分不能小于等于0") if params[:eff_score] && params[:eff_score].to_i <= 0 - tip_exception("效率分不能大于总分值") if params[:eff_score] && params[:eff_score].to_i > params[:total_score].to_i + tip_exception("效率分不能小于等于0") if params[:eff_score] && params[:eff_score].to_f <= 0 + tip_exception("效率分不能大于总分值") if params[:eff_score] && params[:eff_score].to_f.round(2) > params[:total_score].to_f.round(2) tip_exception("缺少shixun_evaluation参数") if params[:shixun_evaluation].blank? tip_exception("缺少challenge_settings参数") if params[:challenge_settings].blank? # tip_exception("缺少challenge_id参数") if params[:challenge_settings][:challenge_id].blank? @@ -586,12 +586,12 @@ class HomeworkCommonsController < ApplicationController # tip_exception("challenge_id参数的长度与challenge_score参数的长度不匹配") if # params[:challenge_settings][:challenge_score].length != params[:challenge_settings][:challenge_id].length - current_eff_score = @homework.eff_score + current_eff_score = @homework.eff_score.to_f.round(2) @homework.total_score = params[:total_score] @homework.work_efficiency = params[:work_efficiency] - @homework.eff_score = params[:work_efficiency] ? params[:eff_score].to_i : 0 + @homework.eff_score = params[:work_efficiency] ? params[:eff_score].to_f.round(2) : 0 - update_eff_score = current_eff_score != @homework.eff_score + update_eff_score = current_eff_score.round(2) != @homework.eff_score.round(2) if @homework_detail_manual.answer_open_evaluation != params[:answer_open_evaluation] @homework_detail_manual.answer_open_evaluation = params[:answer_open_evaluation] From 64147444fd20874d762942b4359580aa4c01f768 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 20 Nov 2019 16:47:52 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=A7=81=E5=AF=86=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=BA=93=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/gits_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/gits_controller.rb b/app/controllers/gits_controller.rb index c9659302e..e87f3302f 100644 --- a/app/controllers/gits_controller.rb +++ b/app/controllers/gits_controller.rb @@ -49,6 +49,10 @@ class GitsController < ApplicationController repo_name = username + "/" + shixunname uid_logger("git start: repo_name is #{repo_name}") shixun = Shixun.select([:id, :user_id, :repo_name, :identifier]).where(repo_name: repo_name).first + if shixun.blank? + shixun_id = ShixunSecretRepository.where(repo_name: repo_name).pluck(:shixun_id).first + shixun = Shixun.select([:id, :user_id, :repo_name, :identifier]).find_by(id: shixun_id) + end uid_logger("git start auth: shixun identifier is #{shixun.try(:identifier)}") uid_logger("git start auth: systemuser is #{system_user.try(:login)}")