From 887171cf7e14c4fb7ed92dd5f9af01349a73dc41 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 14 Aug 2019 10:53:31 +0800 Subject: [PATCH 001/100] =?UTF-8?q?=E5=AE=9E=E8=B7=B5=E8=AF=BE=E7=A8=8B?= =?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/subjects_controller.rb | 17 +++++++++------ app/views/subjects/right_banner.json.jbuilder | 21 +++++++++++++++++++ app/views/subjects/show.json.jbuilder | 19 +---------------- config/routes.rb | 1 + 4 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 app/views/subjects/right_banner.json.jbuilder diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index ce2154fea..21c670b93 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -83,19 +83,24 @@ class SubjectsController < ApplicationController @is_creator = current_user.creator_of_subject?(@subject) @is_manager = @user.manager_of_subject?(@subject) # 合作团队 - @members = @subject.subject_members.includes(:user) @shixuns = @subject.shixuns.published.pluck(:id) - challenge_ids = Challenge.where(shixun_id: @shixuns).pluck(:id) + + # 访问数变更 + @subject.increment!(:visits) + end + + def right_banner + @user = current_user + # 合作团队 + @members = @subject.subject_members.includes(:user) + shixuns = @subject.shixuns.published.pluck(:id) + challenge_ids = Challenge.where(shixun_id: shixuns).pluck(:id) # 实训路径中的所有实训标签 @tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq # 用户获取的实训标签 # @user_tags = @subject.shixuns.map(&:user_tags_name).flatten.uniq @user_tags = user_shixun_tags challenge_ids, @user.id @my_subject_progress = @subject.my_subject_progress - @challenge_count = challenge_ids.size - - # 访问数变更 - @subject.increment!(:visits) end def new diff --git a/app/views/subjects/right_banner.json.jbuilder b/app/views/subjects/right_banner.json.jbuilder new file mode 100644 index 000000000..9ca42c5bc --- /dev/null +++ b/app/views/subjects/right_banner.json.jbuilder @@ -0,0 +1,21 @@ + +json.members @members do |member| + json.partial! 'subject_member', locals: { user: member.user } + json.role member.role +end + +# 技能标签 +json.tags @tags do |tag| + unless tag.blank? + json.tag_name tag + json.status @user_tags.include?(tag) + end +end + +# 我的进展 +json.progress do + json.my_score @subject.my_subject_score + json.all_score @subject.all_score + json.learned @subject.my_subject_progress + json.time @subject.my_consume_time +end \ No newline at end of file diff --git a/app/views/subjects/show.json.jbuilder b/app/views/subjects/show.json.jbuilder index dd4244a15..587a7eaa4 100644 --- a/app/views/subjects/show.json.jbuilder +++ b/app/views/subjects/show.json.jbuilder @@ -12,23 +12,6 @@ json.allow_send @user.logged? json.allow_visit @subject.status > 1 || @is_manager json.allow_add_member @is_manager -json.members @members do |member| - json.partial! 'subject_member', locals: { user: member.user } - json.role member.role -end +if @subject.excellent -# 技能标签 -json.tags @tags do |tag| - unless tag.blank? - json.tag_name tag - json.status @user_tags.include?(tag) - end -end - -# 我的进展 -json.progress do - json.my_score @subject.my_subject_score - json.all_score @subject.all_score - json.learned @subject.my_subject_progress - json.time @subject.my_consume_time end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 45690fbad..e797a0e7e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -273,6 +273,7 @@ Rails.application.routes.draw do delete :delete_member post :up_member_position post :down_member_position + get :right_banner end collection do From 0396d28ef9a94eca7e456c91196465b32295c09c Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 14 Aug 2019 11:32:15 +0800 Subject: [PATCH 002/100] =?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/subjects_controller.rb | 1 + app/helpers/subjects_helper.rb | 2 ++ app/views/subjects/show.json.jbuilder | 8 +++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 21c670b93..b921eebb0 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -84,6 +84,7 @@ class SubjectsController < ApplicationController @is_manager = @user.manager_of_subject?(@subject) # 合作团队 @shixuns = @subject.shixuns.published.pluck(:id) + @courses = @subject.courses id if @subject.excellent # 访问数变更 @subject.increment!(:visits) diff --git a/app/helpers/subjects_helper.rb b/app/helpers/subjects_helper.rb index 606f72587..e77af9cbb 100644 --- a/app/helpers/subjects_helper.rb +++ b/app/helpers/subjects_helper.rb @@ -16,4 +16,6 @@ module SubjectsHelper ChallengeTag.joins("join games on challenge_tags.challenge_id = games.challenge_id"). where(challenge_id: challenge_ids, games: {status: 2, user_id: user_id}).pluck("challenge_tags.name").uniq end + + end diff --git a/app/views/subjects/show.json.jbuilder b/app/views/subjects/show.json.jbuilder index 587a7eaa4..2511fdadb 100644 --- a/app/views/subjects/show.json.jbuilder +++ b/app/views/subjects/show.json.jbuilder @@ -13,5 +13,11 @@ json.allow_visit @subject.status > 1 || @is_manager json.allow_add_member @is_manager if @subject.excellent - + @courses.each do |course| + json.start_date course.start_date.beginning_of_day + json.end_date course.end_date.end_of_day + json.student_count course.students.count + json.course_identity @user.course_identity(course) + json.course_status course + end end \ No newline at end of file From 48e06686eba94298d322291fbbf7934d771eeb7b Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 14 Aug 2019 14:59:51 +0800 Subject: [PATCH 003/100] =?UTF-8?q?=E5=AE=9E=E8=B7=B5=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E6=8E=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=87=91=E8=AF=BE=E7=9A=84=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 2 +- app/helpers/subjects_helper.rb | 15 ++++++++++++++- app/views/subjects/show.json.jbuilder | 12 +++++++----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index b921eebb0..6a381b258 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -84,7 +84,7 @@ class SubjectsController < ApplicationController @is_manager = @user.manager_of_subject?(@subject) # 合作团队 @shixuns = @subject.shixuns.published.pluck(:id) - @courses = @subject.courses id if @subject.excellent + @courses = @subject.courses if @subject.excellent # 访问数变更 @subject.increment!(:visits) diff --git a/app/helpers/subjects_helper.rb b/app/helpers/subjects_helper.rb index e77af9cbb..8aff41d25 100644 --- a/app/helpers/subjects_helper.rb +++ b/app/helpers/subjects_helper.rb @@ -17,5 +17,18 @@ module SubjectsHelper where(challenge_id: challenge_ids, games: {status: 2, user_id: user_id}).pluck("challenge_tags.name").uniq end - + # 金课的课堂状态 0:未开课,1:进行中,2:已结束 + def subject_course_status course + if course.is_end + {status: 2, time: ""} + elsif course.start_date && course.start_date > Date.today + {status: 0, time: ""} + elsif course.start_date && course.start_date <= Date.today && course.end_date >= Date.today + sum_week = ((course.end_date - course.start_date).to_i / 7.0).ceil + curr_week = ((Date.today - course.start_date).to_i / 7.0).ceil + {status: 1, time: "进行至第#{curr_week}周,共#{sum_week}周"} + else + {status: -1, time: ""} + end + end end diff --git a/app/views/subjects/show.json.jbuilder b/app/views/subjects/show.json.jbuilder index 2511fdadb..bf179b86d 100644 --- a/app/views/subjects/show.json.jbuilder +++ b/app/views/subjects/show.json.jbuilder @@ -1,4 +1,4 @@ -json.(@subject, :id, :name, :description, :learning_notes, :stages_count, :stage_shixuns_count, :shixuns_count) +json.(@subject, :id, :name, :description, :learning_notes, :stages_count, :stage_shixuns_count, :shixuns_count, :excellent) json.challenge_choose_count @subject.subject_challenge_choose_count json.challenges_count @subject.subject_challenge_count @@ -13,11 +13,13 @@ json.allow_visit @subject.status > 1 || @is_manager json.allow_add_member @is_manager if @subject.excellent - @courses.each do |course| - json.start_date course.start_date.beginning_of_day - json.end_date course.end_date.end_of_day + json.courses @courses do |course| + json.course_id course.id + json.first_category_url module_url(course.none_hidden_course_modules.first, course) + json.start_date course.start_date + json.end_date course.end_date json.student_count course.students.count json.course_identity @user.course_identity(course) - json.course_status course + json.course_status subject_course_status course end end \ No newline at end of file From 3a1490f1c4a4c95c7120af62c44ea425e57e63db Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 14 Aug 2019 15:47:59 +0800 Subject: [PATCH 004/100] =?UTF-8?q?=E5=BC=80=E5=90=AF=E6=8C=91=E6=88=98?= =?UTF-8?q?=E6=97=B6=E5=8A=A0=E5=85=A5=E8=AF=BE=E5=A0=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index fb999b879..343dd4b73 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -562,6 +562,17 @@ class ShixunsController < ApplicationController commit_id = commit["id"] end + # 如果该实训是金课中的实训,则将当前用户加入到当期开课的课堂 + if StageShixun.exists?(shixun_id: @shixun.id, subject_id: Subject.where(excellent: 1)) + subject = Subject.where(excellent: 1, id: StageShixun.where(shixun_id: @shixun.id).pluck(:subject_id)).take + if subject.courses.exists?("start_date is not null and start_date <= #{Date.today} and end_date is not null and end_date >= #{Date.today}") + course = subject.courses.where("start_date is not null and start_date <= #{Date.today} and end_date is not null and end_date >= #{Date.today}").take + unless CourseMember.exists?(course_id: course.id, user_id: current_user.id) + CourseMember.create!(course_id: course.id, user_id: current_user.id, role: 4) + end + end + end + ActiveRecord::Base.transaction do begin cloud_bridge = edu_setting('cloud_bridge') From d23f48dbc716f3af099ac3ea88f8cfaa35bd48f6 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 14 Aug 2019 17:10:54 +0800 Subject: [PATCH 005/100] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=97=B6=E8=87=AA=E5=8A=A8=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E8=AF=A5=E5=AE=9E=E8=AE=AD=E6=89=80=E5=9C=A8=E7=9A=84=E9=87=91?= =?UTF-8?q?=E8=AF=BE=E8=AF=BE=E5=A0=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 22 +++++++++++----------- dump.rdb | Bin 1888 -> 2086 bytes lib/tasks/publick_course.rake | 5 ++++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 343dd4b73..74942446e 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -555,21 +555,21 @@ class ShixunsController < ApplicationController # 判断实训是否全为选择题 is_choice_type = (min_challenges.size == min_challenges.select{|challenge| challenge.last == 1}.count) - if !is_choice_type - commit = GitService.commits(repo_path: @repo_path).try(:first) - uid_logger("First comit########{commit}") - tip_exception("开启实战前请先在版本库中提交代码") if commit.blank? - commit_id = commit["id"] - end + # if !is_choice_type + # commit = GitService.commits(repo_path: @repo_path).try(:first) + # uid_logger("First comit########{commit}") + # tip_exception("开启实战前请先在版本库中提交代码") if commit.blank? + # commit_id = commit["id"] + # end # 如果该实训是金课中的实训,则将当前用户加入到当期开课的课堂 if StageShixun.exists?(shixun_id: @shixun.id, subject_id: Subject.where(excellent: 1)) subject = Subject.where(excellent: 1, id: StageShixun.where(shixun_id: @shixun.id).pluck(:subject_id)).take - if subject.courses.exists?("start_date is not null and start_date <= #{Date.today} and end_date is not null and end_date >= #{Date.today}") - course = subject.courses.where("start_date is not null and start_date <= #{Date.today} and end_date is not null and end_date >= #{Date.today}").take - unless CourseMember.exists?(course_id: course.id, user_id: current_user.id) - CourseMember.create!(course_id: course.id, user_id: current_user.id, role: 4) - end + course = subject.courses.where("start_date is not null and start_date <= '#{Date.today}' and end_date is not null and end_date >= '#{Date.today}'").take + if course.present? && !CourseMember.exists?(course_id: course.id, user_id: current_user.id) + # 为了不影响后续操作,用create而不是create! + CourseMember.create(course_id: course.id, user_id: current_user.id, role: 4) + CourseAddStudentCreateWorksJob.perform_later(course.id, [current_user.id]) end end diff --git a/dump.rdb b/dump.rdb index c4edd44ed9369cb224d86d4db8d9b1e4349f94f5..f7b65ded0f6f907e3c844f02d8fb1c6dbac91345 100644 GIT binary patch delta 694 zcmWN~y-So~008j!p7%by^U~9b2I=ngJS)xTdcHpb1EHj)2n?bj;`w@qz=TwyL2QT? zhl-bWrxq;?w}u31Y-p(6Uc`h5B51La`~!accKTj5o}+<{k27};dKTw{hqGaJ`_uf} zsW*ke%MWifTg^rk4fRD)PZUl4%L?G>s9{QL#{>-48ptH`P#cC|;Eo$CWlS(e**cgk z5{gvz1KeH~9DAn_HZmoKq?$>Cy`n5xIqe<=cOal#2sA~P!}3wBD#WL#dux=JB1d| ziszf4^R3r;j2uK*c*sUO{ZLaCpu}l#0(q&!ne1IW)SP~Ku2fVonI8j>TYzEx zp|rnV&ko|z)<`?w0&+8oUw#xkzbADYhiXSxfxTY>7K9D995bdq`9Tzzso`+6EHv9o2=yJ z0$>u4SIgP^VzU(aiNWL9*P^{NkfIbCCONdiIj%Hj=er~Ay(^XS%%Z&)+(L3I!n>gu jGaL}yj?_f0Qv-_FvHc5`%_pVLg`R=cXRm+0SZe$S$+Ez@ delta 473 zcmV~$&1w@t007|4%&=lp?-BJ$Mp4=)EjKy!ZlItKau}@o3>CKC}Mj*8SgeTbse7Nthgd{dh2Z z*I2rCaHErT+EKLJilQ`%hR0O{JndudH7+DYrQ{NEAqmn7b7V`SH46+9%5Aj|uEvC6 zQ~d&Wt3iDJ-tI;BDA;N65A1aH3K3FBLkN`vNr~nn--tHs_R)Nn8ZCBC{x$0NAfwDU zPq0InNRPP21R16SQltz{Vh@#Jd?l-%#~1pe7j+Aq!cq;CW|FJ=Gg)&ysnx_*NtHGr{05YqA2k}ctlLFBe>*| zrOG1jn0L+=lp48`&&Dad872?&JCJe1e)#6HW7-IdjVPG0TpDZx5o`1LZk;yTToFN8 z^(^To9WPO+-X_KHY>7)`xe}<5&IxS@S9si;jbVCwt5^?idg*aQW+85I5-_J!2a0 Date: Wed, 14 Aug 2019 17:50:10 +0800 Subject: [PATCH 006/100] =?UTF-8?q?=E9=87=91=E8=AF=BE=E5=89=8D=E4=B8=80?= =?UTF-8?q?=E5=A4=A9=E7=BB=99=E6=8A=A5=E5=90=8D=E8=80=85=E5=8F=91=E6=B6=88?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/public_course_notice.rake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/tasks/public_course_notice.rake diff --git a/lib/tasks/public_course_notice.rake b/lib/tasks/public_course_notice.rake new file mode 100644 index 000000000..461dae797 --- /dev/null +++ b/lib/tasks/public_course_notice.rake @@ -0,0 +1,19 @@ +desc "开放课程开课前通知报名用户" +namespace :public_course_notice do + task :tiding => :environment do + Course.where(excellent: 1).where("start_date is not null and start_date = '#{Date.today}'").each do |course| + attrs = %i[user_id trigger_user_id status container_id container_type belong_container_id + belong_container_type tiding_type created_at updated_at] + + same_attrs = { + trigger_user_id: 0, container_id: course.id, container_type: 'PublicCourseStart', + belong_container_id: course.id, belong_container_type: 'Course', tiding_type: 'System', status: 0 + } + Tiding.bulk_insert(*attrs) do |worker| + course.students.each do |student| + worker.add same_attrs.merge(user_id: student.user_id) + end + end + end + end +end \ No newline at end of file From ed11f16a9e504d58959f9076f186b1d90cb0bcdf Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 14 Aug 2019 19:44:24 +0800 Subject: [PATCH 007/100] =?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/helpers/export_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index 5d36c465f..433c5ae7d 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -147,7 +147,7 @@ module ExportHelper end 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_9 = myshixun ? (myshixun.try(:passed_count).to_i > 0 ? myshixun.total_spend_time : '--') : "--" #总耗时 w_10 = myshixun ? myshixun.output_times : 0 #评测次数 w_11 = myshixun ? myshixun.total_score : "--" #获得经验值 w_12 = w.final_score.present? ? w.final_score : 0 @@ -163,7 +163,7 @@ module ExportHelper end w_15 = w.work_score.nil? ? "--" : w.work_score.round(1) w_16 = w.update_time ? format_time(w.update_time) : "--" "更新时间" - w_17 = (game_spend_time w.cost_time) + w_17 = w.cost_time ? (game_spend_time w.cost_time) : "--" teacher_comments = w.student_works_scores if teacher_comments.present? w_18 = "" From ced52a49fd05c4394365effef731c3119156c54a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 14 Aug 2019 19:46:37 +0800 Subject: [PATCH 008/100] =?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/helpers/export_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index 433c5ae7d..5cefc062f 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -146,7 +146,7 @@ module ExportHelper w_6 = "--" end 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_8 = myshixun ? myshixun.try(:passed_time).to_s == "--" ? "--" : format_time(myshixun.try(:passed_time)) : "--" # 通关时间 w_9 = myshixun ? (myshixun.try(:passed_count).to_i > 0 ? myshixun.total_spend_time : '--') : "--" #总耗时 w_10 = myshixun ? myshixun.output_times : 0 #评测次数 w_11 = myshixun ? myshixun.total_score : "--" #获得经验值 From 50fd29fa6558635883f83323551df98491f16699 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 15 Aug 2019 11:00:09 +0800 Subject: [PATCH 009/100] =?UTF-8?q?=E5=BC=80=E8=AF=BE=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/decorators/tiding_decorator.rb | 4 ++++ config/locales/tidings/zh-CN.yml | 1 + 2 files changed, 5 insertions(+) diff --git a/app/decorators/tiding_decorator.rb b/app/decorators/tiding_decorator.rb index ab9de4b76..81093dc12 100644 --- a/app/decorators/tiding_decorator.rb +++ b/app/decorators/tiding_decorator.rb @@ -380,4 +380,8 @@ module TidingDecorator I18n.t(locale_format(tiding_type)) % [container.try(:title) || extra] end end + + def public_course_start_content + I18n.t(locale_format) % [belong_container&.name, belong_container&.start_date&.strftime("%Y-%m-%d")] + end end diff --git a/config/locales/tidings/zh-CN.yml b/config/locales/tidings/zh-CN.yml index a4d213161..347b0139a 100644 --- a/config/locales/tidings/zh-CN.yml +++ b/config/locales/tidings/zh-CN.yml @@ -225,3 +225,4 @@ System: 1_end: "你提交的发布视频申请:%s,审核已通过" 2_end: "你提交的发布视频申请:%s,审核未通过
原因:%{reason}" + PublicCourseStart_end: "你报名参与的开放课程:%s,将于%s正式开课" From 255276124871158db08e09aa3b1b9b0ce35c18aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 15 Aug 2019 16:34:15 +0800 Subject: [PATCH 010/100] b --- public/react/config/webpack.config.prod.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/config/webpack.config.prod.js b/public/react/config/webpack.config.prod.js index 7b9795e80..a5f300872 100644 --- a/public/react/config/webpack.config.prod.js +++ b/public/react/config/webpack.config.prod.js @@ -301,7 +301,7 @@ module.exports = { }, warnings: false, compress: { - drop_debugger: true, + drop_debugger: false, drop_console: true } } From 83579170523762f0f8536c59d48447ecef62ff05 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 15 Aug 2019 16:54:28 +0800 Subject: [PATCH 011/100] =?UTF-8?q?=E5=85=B3=E5=8D=A1=E8=AF=84=E6=B5=8B?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=9A=84=E5=AD=A6=E9=99=A2=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=A4=AA=E9=95=BF=E5=90=8E=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20190815085136_modify_path_for_challenges.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 db/migrate/20190815085136_modify_path_for_challenges.rb diff --git a/db/migrate/20190815085136_modify_path_for_challenges.rb b/db/migrate/20190815085136_modify_path_for_challenges.rb new file mode 100644 index 000000000..a17fdbd04 --- /dev/null +++ b/db/migrate/20190815085136_modify_path_for_challenges.rb @@ -0,0 +1,5 @@ +class ModifyPathForChallenges < ActiveRecord::Migration[5.2] + def change + change_column :challenges, :path, :text + end +end From 422a40a59f6d734de87f199464e6d476dc608967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 15 Aug 2019 17:23:22 +0800 Subject: [PATCH 012/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/coursesDetail/CoursesLeftNav.js | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js index cb911c4dc..1ed63ffd9 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js @@ -496,6 +496,15 @@ class Coursesleftnav extends Component{ saveNavmoda=()=>{ let {Navmodaltypename,setnavid,NavmodalValue}=this.state; let id =setnavid; + + if(Navmodaltypename===5&&NavmodalValue==="未分班"){ + this.setState({ + NavmodalValuetype:true, + NavmodalValues:"名称不能和未分班一样" + }) + return + } + if(NavmodalValue===""){ this.setState({ NavmodalValuetype:true, @@ -639,6 +648,7 @@ class Coursesleftnav extends Component{ } onDragEnd=(result)=>{ + debugger // console.log(result) // let {course_modules}=this.props; // let newcourse_modules=course_modules; @@ -681,10 +691,10 @@ class Coursesleftnav extends Component{ this.droppablepost(url,result.destination.index+1) }else if(result.source.droppableId==="course_group"){ - - let url ="/course_groups/"+result.draggableId+"/move_category.json" - this.droppablepost(url,result.destination.index+1) - + if(result.draggableId!=1){ + let url ="/course_groups/"+result.draggableId+"/move_category.json" + this.droppablepost(url,result.destination.index+1) + } } } @@ -928,9 +938,9 @@ class Coursesleftnav extends Component{ {iem.category_name} - {iem.category_count===0?"":iem.category_count} + {iem.category_count===0?"":iem.category_count} {item.type===twosandiantypes&&twosandiantype===index? - iem.category_name==="未分班"?"": + iem.category_id===0?"": iem.category_type==="graduation_topics"||iem.category_type==="graduation_tasks"? {iem.category_count===0?"":iem.category_count} : From 8a9cd2b28887edf95772c6781b4258c140b23fa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 15 Aug 2019 17:27:50 +0800 Subject: [PATCH 013/100] b --- public/react/config/webpack.config.prod.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/config/webpack.config.prod.js b/public/react/config/webpack.config.prod.js index a5f300872..7b9795e80 100644 --- a/public/react/config/webpack.config.prod.js +++ b/public/react/config/webpack.config.prod.js @@ -301,7 +301,7 @@ module.exports = { }, warnings: false, compress: { - drop_debugger: false, + drop_debugger: true, drop_console: true } } From 2463d3343a54c644d09d9f0a41632cb87fdd5176 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Thu, 15 Aug 2019 17:29:12 +0800 Subject: [PATCH 014/100] add first_category_url to es search api --- app/models/searchable/course.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/searchable/course.rb b/app/models/searchable/course.rb index 0b2b78436..5060d9ddd 100644 --- a/app/models/searchable/course.rb +++ b/app/models/searchable/course.rb @@ -25,7 +25,8 @@ module Searchable::Course author_school_name: teacher&.school_name, visits_count: visits, members_count: members_count, - is_public: is_public == 1 + is_public: is_public == 1, + first_category_url: ApplicationController.helpers.module_url(none_hidden_course_modules.first, self) } end From 3f9c722c98faeaa9b62e5d38b47375f977e9d3f0 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 15 Aug 2019 17:34:33 +0800 Subject: [PATCH 015/100] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- lib/tasks/public_course.rake | 99 +++++++++++++++++++++++ lib/tasks/publick_course.rake | 25 ------ 3 files changed, 100 insertions(+), 26 deletions(-) create mode 100644 lib/tasks/public_course.rake delete mode 100644 lib/tasks/publick_course.rake diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index db6ae7b57..49fe9ca50 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -239,7 +239,7 @@ class ApplicationController < ActionController::Base uid_logger("user_setup: " + (User.current.logged? ? "#{User.current.try(:login)} (id=#{User.current.try(:id)})" : "anonymous")) if !User.current.logged? && Rails.env.development? - User.current = User.find 57703 + User.current = User.find 12 end diff --git a/lib/tasks/public_course.rake b/lib/tasks/public_course.rake new file mode 100644 index 000000000..9c5065982 --- /dev/null +++ b/lib/tasks/public_course.rake @@ -0,0 +1,99 @@ +#coding=utf-8 +# 执行示例 bundle exec rake public_course:student args=149,2903 +# args 第一个参数是subject_id,第二个参数是课程course_id +# 第一期时间:2018-12-16 至2019-03-31 +# 第二期时间:2019-04-07 至2019-07-28 +# +# 这次学习很有收获,感谢老师提供这么好的资源和细心的服务🎉🎉🎉 +# + +desc "同步精品课数据" +namespace :public_course do + subject_id = ENV['args'].split(",")[0] # 对应课程的id + course_id = ENV['args'].split(",")[1] # 对应课堂的id + status = ENV['args'].split(",")[2] # 表示相应的期数 + type = ENV['args'].split(",")[3] # 表示课程模块 + + if status.to_i == 1 + start_time = '2018-12-16' + end_time = '2019-04-01' + elsif status.to_i == 2 + start_time = '2019-04-07' + end_time = '2019-07-28' + else + # 这种情况是取所有的 + start_time = '2015-01-01' + end_time = '2022-07-28' + end + + task :student => :environment do + puts "subject_id is #{subject_id}" + puts "course_id is #{course_id}" + + user_ids = Myshixun.find_by_sql("select distinct(user_id) from myshixuns where shixun_id in (select shixun_id from stage_shixuns + where stage_id in (select id from stages where subject_id=#{subject_id}))").map(&:user_id) + puts user_ids + if user_ids.present? + user_ids.each do |user_id| + puts user_id + begin + CourseMember.create!(course_id: course_id, user_id: user_id, role: 4) + rescue Exception => e + Rails.logger() + end + end + end + end + + # + task :message => :environment do + discusses = Discuss.find_by_sql("select content, user_id, created_on, updated_on from discusses where dis_id in (select shixun_id from stage_shixuns where + stage_id in (select id from stages where subject_id=#{subject_id})) and created_at > #{start_time} and + created_at<#{end_time}") + discusses.find_each do |discuss| + puts discuss.user_id + puts discuss.content + # 回复帖子 + # 讨论区发布帖子 + # Message.create!(board: @message.board, root_id: @message.root_id || @message.id, + # author: current_user, parent: @message, + # message_detail_attributes: { + # content: params[:content] + # }) + end + end + + + # 更新某个课程的某类时间 + # 执行示例 bundle exec rake public_course:student tiems=149,2903 + task :time => :environment do + course_id = ENV['args'].split(",")[0] # 对应课堂的id + satus = ENV['args'].split(",")[1] + + course = Course.find(course_id) + + hour = (6..24).to_a.sample(1).first + min = rand(60) + sec = rand(60) + + start_time = Date.parse(start_time) + end_time = Date.parse(end_time) + date = (start_time..end_time).to_a.sample(1).first + + time = "#{date} #{min_swith(hour)}:#{min_swith(min)}:#{min_swith(sec)}" + + puts time + case type + when 1 + # 讨论区 + + end + + end + + def min_swith(time) + puts time + return time < 9 ? "0#{time}" : time + end +end + diff --git a/lib/tasks/publick_course.rake b/lib/tasks/publick_course.rake deleted file mode 100644 index 532e32369..000000000 --- a/lib/tasks/publick_course.rake +++ /dev/null @@ -1,25 +0,0 @@ -#coding=utf-8 -# 执行示例 bundle exec rake public_course:student args=149,2903 -# args 第一个参数是subject_id,第二个参数是课程course_id - -desc "同步精品课数据" -namespace :public_course do - task :student => :environment do - - - subject_id = ENV['args'].split(",").first - course_id = ENV['args'].split(",").last - puts "subject_id is #{subject_id}" - puts "course_id is #{course_id}" - - user_ids = Myshixun.find_by_sql("select distinct(user_id) from myshixuns where shixun_id in (select shixun_id from stage_shixuns - where stage_id in (select id from stages where subject_id=#{subject_id}))").map(&:user_id) - puts user_ids - if user_ids.present? - user_ids.each do |user_id| - puts user_id - CourseMember.create!(course_id: course_id, user_id: user_id, role: 4) - end - end - end -end \ No newline at end of file From 13cf4b04d3b19bf9b2e81fc14ef22306e2ed3bf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 15 Aug 2019 17:37:11 +0800 Subject: [PATCH 016/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/coursesDetail/CoursesLeftNav.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js index 1ed63ffd9..b6d6c1997 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js @@ -497,7 +497,7 @@ class Coursesleftnav extends Component{ let {Navmodaltypename,setnavid,NavmodalValue}=this.state; let id =setnavid; - if(Navmodaltypename===5&&NavmodalValue==="未分班"){ + if(Navmodaltypename===5&&NavmodalValue==="未分班"||Navmodaltypename===2&&NavmodalValue==="未分班"){ this.setState({ NavmodalValuetype:true, NavmodalValues:"名称不能和未分班一样" @@ -830,8 +830,16 @@ class Coursesleftnav extends Component{ onInput={this.setNavmodalValue} /> - - {this.state.NavmodalValuetype===true? + + {this.state.NavmodalValuetype===true? {this.state.NavmodalValues} :""}
@@ -938,9 +946,9 @@ class Coursesleftnav extends Component{ {iem.category_name} - {iem.category_count===0?"":iem.category_count} + {iem.category_count===0?"":iem.category_count} {item.type===twosandiantypes&&twosandiantype===index? - iem.category_id===0?"": + iem.category_name==="未分班"?"": iem.category_type==="graduation_topics"||iem.category_type==="graduation_tasks"? {iem.category_count===0?"":iem.category_count} : From 5a3dc6eae56c6563a60a7a523616c9f5796f4fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Thu, 15 Aug 2019 17:43:36 +0800 Subject: [PATCH 017/100] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=90=9C=E7=B4=A2=20?= =?UTF-8?q?=E8=AF=BE=E5=A0=82=E6=A0=B9=E6=8D=AE=E5=AD=97=E6=AE=B5=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/search/SearchPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/search/SearchPage.js b/public/react/src/search/SearchPage.js index 33a1a7852..e5cc07b2b 100644 --- a/public/react/src/search/SearchPage.js +++ b/public/react/src/search/SearchPage.js @@ -183,7 +183,7 @@ class SearchPage extends Component{ return ( From b8259d8871fde37bc3d1dd10946805c8d0527e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 15 Aug 2019 17:46:06 +0800 Subject: [PATCH 018/100] b --- .../react/src/modules/courses/coursesDetail/CoursesLeftNav.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js index b6d6c1997..282024b6d 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js @@ -946,9 +946,9 @@ class Coursesleftnav extends Component{ {iem.category_name} - {iem.category_count===0?"":iem.category_count} + {iem.category_count===0?"":iem.category_count} {item.type===twosandiantypes&&twosandiantype===index? - iem.category_name==="未分班"?"": + iem.category_id===0?"": iem.category_type==="graduation_topics"||iem.category_type==="graduation_tasks"? {iem.category_count===0?"":iem.category_count} : From d3a504bd0488ed3687471da4cf959ae04952b014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 15 Aug 2019 18:01:10 +0800 Subject: [PATCH 019/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/graduation/tasks/GraduationTasksSubmitedit.js | 1 + public/react/src/modules/paths/PathDetail/addCollaborators.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js index f93d13eac..fcbe6b9aa 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js @@ -760,6 +760,7 @@ class GraduationTasksSubmitedit extends Component{ height: '30px' }}> { return parseInt(task_status[key])===item.user_id?true:false diff --git a/public/react/src/modules/paths/PathDetail/addCollaborators.js b/public/react/src/modules/paths/PathDetail/addCollaborators.js index 6100ab2f6..0b99fd467 100644 --- a/public/react/src/modules/paths/PathDetail/addCollaborators.js +++ b/public/react/src/modules/paths/PathDetail/addCollaborators.js @@ -187,8 +187,8 @@ class addCollaborators extends Component{ { partnerList && partnerList.map((item,key)=>{ return( -
  • - +
  • + {item.user_name} {item.nickname} {item.identity} From e6b26ee6cbec2fd196ad913224df0ce4d96ec030 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 15 Aug 2019 18:03:16 +0800 Subject: [PATCH 020/100] =?UTF-8?q?=E4=BB=93=E5=BA=93=E5=9C=A8=E5=86=B7?= =?UTF-8?q?=E5=8C=BA=E5=90=8E=E8=87=AA=E5=8A=A8=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 63 ++++++++++++++--------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 828198def..c7a598a43 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -498,44 +498,41 @@ class GamesController < ApplicationController rescue Exception => e # 思路: 异常首先应该考虑去恢复 # retry为1表示已经轮训完成后还没有解决问题,这个时候需要检测异常 - if params[:retry].to_i == 1 - begin - # 如果模板没有问题,则通过中间层检测实训仓库是否异常 - # 监测版本库HEAD是否存在,不存在则取最新的HEAD - gitUrl = repo_url @myshixun.repo_path - gitUrl = Base64.urlsafe_encode64(gitUrl) - shixun_tomcat = edu_setting('cloud_bridge') - rep_params = {:tpiID => "#{@myshixun.id}", :tpiGitURL => "#{gitUrl}"} - # 监测版本库HEAD是否存在,不存在则取最新的HEAD - uri = "#{shixun_tomcat}/bridge/game/check" - res = uri_post uri, rep_params - uid_logger("repo_content to bridge: res is #{res}") - # res值:0 表示正常;-1表示有错误;-2表示代码版本库没了 - # - if status == 0 && res - # 版本库报错,修复不了 - if res['code'] == -1 || res['code'] == -2 - begin - # GitService.delete_repository(repo_path: @myshixun.repo_path) if res['code'] == -1 - project_fork(@myshixun, @shixun.repo_path, current_user.login) - rescue Exception => e - uid_logger_error("#{e.message}") - tip_exception("#{e.message}") - end + begin + # 如果模板没有问题,则通过中间层检测实训仓库是否异常 + # 监测版本库HEAD是否存在,不存在则取最新的HEAD + gitUrl = repo_url @myshixun.repo_path + gitUrl = Base64.urlsafe_encode64(gitUrl) + shixun_tomcat = edu_setting('cloud_bridge') + rep_params = {:tpiID => "#{@myshixun.id}", :tpiGitURL => "#{gitUrl}"} + # 监测版本库HEAD是否存在,不存在则取最新的HEAD + uri = "#{shixun_tomcat}/bridge/game/check" + res = uri_post uri, rep_params + uid_logger("repo_content to bridge: res is #{res}") + # res值:0 表示正常;-1表示有错误;-2表示代码版本库没了 + # + if status == 0 && res + # 版本库报错,修复不了 + if res['code'] == -1 || res['code'] == -2 + begin + # GitService.delete_repository(repo_path: @myshixun.repo_path) if res['code'] == -1 + project_fork(@myshixun, @shixun.repo_path, current_user.login) + rescue Exception => e + uid_logger_error("#{e.message}") + tip_exception("#{e.message}") end end - rescue Exception => e - uid_logger_error(e.message) + end + rescue Exception => e + uid_logger_error(e.message) - if @myshixun.shixun.try(:status) < 2 - tip_exception("代码获取异常,请检查实训模板的评测设置是否正确") - else - # 报错继续retry - tip_exception(-3, "#{e.message}") - end + if @myshixun.shixun.try(:status) < 2 + tip_exception("代码获取异常,请检查实训模板的评测设置是否正确") + else + # 报错继续retry + tip_exception(-3, "#{e.message}") end end - # 有异常,版本库获取不到代码,前端轮训15S后,调用retry == 1 tip_exception(0, e.message) end end From e4300243c0377737cb5e887aa21eb699f416f03b Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 16 Aug 2019 06:44:05 +0800 Subject: [PATCH 021/100] =?UTF-8?q?=E5=85=AC=E5=BC=80=E8=AF=BE=E8=AE=A8?= =?UTF-8?q?=E8=AE=BA=E5=8C=BA=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/public_message.rake | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 lib/tasks/public_message.rake diff --git a/lib/tasks/public_message.rake b/lib/tasks/public_message.rake new file mode 100644 index 000000000..a675d98fe --- /dev/null +++ b/lib/tasks/public_message.rake @@ -0,0 +1,41 @@ +# bundle exec rake sync:public_message args=149,2903 +namespace :sync do + task :public_message => :environment do + subject_id = ENV['args'].split(",")[0] # 对应课程的id + board_id = ENV['args'].split(",")[1] + message_id = ENV['args'].split(",")[2] + status = ENV['args'].split(",")[3] # 表示相应的期数 + + if status.to_i == 1 + start_time = '2018-12-16' + end_time = '2019-04-01' + elsif status.to_i == 2 + start_time = '2019-04-07' + end_time = '2019-07-28' + else + # 这种情况是取所有的 + start_time = '2015-01-01' + end_time = '2022-07-28' + end + + shixun_ids = Shixun.find_by_sql("select shixun_id from stage_shixuns where stage_id in (select id from stages where + subject_id=#{subject_id}) ").map(&:shixun_id) + + + discusses = Discuss.where(dis_id: shixun_ids).where("created_at >? and created_at Date: Fri, 16 Aug 2019 06:52:55 +0800 Subject: [PATCH 022/100] message detail --- lib/tasks/public_message.rake | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/tasks/public_message.rake b/lib/tasks/public_message.rake index a675d98fe..837a72a0b 100644 --- a/lib/tasks/public_message.rake +++ b/lib/tasks/public_message.rake @@ -2,9 +2,8 @@ namespace :sync do task :public_message => :environment do subject_id = ENV['args'].split(",")[0] # 对应课程的id - board_id = ENV['args'].split(",")[1] - message_id = ENV['args'].split(",")[2] - status = ENV['args'].split(",")[3] # 表示相应的期数 + message_id = ENV['args'].split(",")[1] + status = ENV['args'].split(",")[2] # 表示相应的期数 if status.to_i == 1 start_time = '2018-12-16' @@ -23,17 +22,11 @@ namespace :sync do discusses = Discuss.where(dis_id: shixun_ids).where("created_at >? and created_at Date: Fri, 16 Aug 2019 07:45:28 +0800 Subject: [PATCH 023/100] message --- lib/tasks/public_message.rake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/tasks/public_message.rake b/lib/tasks/public_message.rake index 837a72a0b..a804f9c2d 100644 --- a/lib/tasks/public_message.rake +++ b/lib/tasks/public_message.rake @@ -2,8 +2,9 @@ namespace :sync do task :public_message => :environment do subject_id = ENV['args'].split(",")[0] # 对应课程的id - message_id = ENV['args'].split(",")[1] - status = ENV['args'].split(",")[2] # 表示相应的期数 + board_id = ENV['args'].split(",")[1] + message_id = ENV['args'].split(",")[2] + status = ENV['args'].split(",")[3] # 表示相应的期数 if status.to_i == 1 start_time = '2018-12-16' @@ -26,7 +27,8 @@ namespace :sync do discusses.find_each do |discuss| puts discuss.user_id puts discuss.content - MessageDetail.create!(message_id: message_id, content: discuss.try(:content)) + new_message = Message.create!(board: board_id, author: discuss.user_id) + MessageDetail.create!(message_id: new_message.id, content: discuss.try(:content)) end end From c9e8ea9e7f45e4a45f227eede5074c659e6cd9f3 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 10:12:33 +0800 Subject: [PATCH 024/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/excellent_course_exercise.rake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/tasks/excellent_course_exercise.rake b/lib/tasks/excellent_course_exercise.rake index 3546e48c3..c68cf6348 100644 --- a/lib/tasks/excellent_course_exercise.rake +++ b/lib/tasks/excellent_course_exercise.rake @@ -5,7 +5,6 @@ namespace :excellent_course_exercise do task :student_answer => :environment do course = Course.find_by(id: 2933) - exercises = course.exercises participant_count = 1042 pass_count = 823 @@ -14,6 +13,13 @@ namespace :excellent_course_exercise do members_2 = course.students.order("id asc").limit(1042) members_1 = course.students.order("id asc").limit(322) + exercise_1884 = course.exercises.find_by(id: 1884) + members_1.each_with_index do |member, index| + if index < 821 + else + + end + end end end \ No newline at end of file From 0bef9700a1fa56efe4c206e755caaf4bea6c99ad Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 11:07:22 +0800 Subject: [PATCH 025/100] =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/public_course.rake | 66 ++++++++++++++++++++++++++++------- lib/tasks/publick_course.rake | 1 - 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/lib/tasks/public_course.rake b/lib/tasks/public_course.rake index 9c5065982..7ed492968 100644 --- a/lib/tasks/public_course.rake +++ b/lib/tasks/public_course.rake @@ -65,14 +65,56 @@ namespace :public_course do # 更新某个课程的某类时间 - # 执行示例 bundle exec rake public_course:student tiems=149,2903 + # 执行示例 bundle exec rake public_course:student args=2903,1 task :time => :environment do - course_id = ENV['args'].split(",")[0] # 对应课堂的id - satus = ENV['args'].split(",")[1] + # course_id = ENV['args'].split(",")[0] # 对应课堂的id + # type = ENV['args'].split(",")[1] course = Course.find(course_id) - hour = (6..24).to_a.sample(1).first + case type.to_i + when 1 + # 讨论区 + + when 2 + # 作业 + course.homework_commons.each do |homework| + created_at = random_time(start_time, end_time) + publish_time = random_larger_time created_at, start_time, end_time + end_time = random_larger_time publish_time, start_time, end_time + updated_at = end_time + + homework.update_columns(publish_time: publish_time, end_time: end_time, created_at: created_at, updated_at: updated_at) + homework.homework_detail_manual.update_columns(comment_status: 6, created_at: created_at, updated_at: updated_at) + end + when 3 + # 试卷 + course.exercises.each do |exercise| + created_at = random_time start_time, end_time + publish_time = random_larger_time created_at, start_time, end_time + end_time = random_larger_time publish_time, start_time, end_time + updated_at = end_time + + exercise.update_columns(publish_time: publish_time, end_time: end_time, created_at: created_at, updated_at: updated_at, exercise_status: 3) + end + when 4 + # 资源 + course.attachments.each do |atta| + created_on = random_time start_time, end_time + + atta.update_columns(is_publish: 1, created_on: created_on) + end + end + + end + + def min_swith(time) + puts time + return time < 9 ? "0#{time}" : time + end + + def random_time(start_time, end_time) + hour = (6..23).to_a.sample(1).first min = rand(60) sec = rand(60) @@ -83,17 +125,15 @@ namespace :public_course do time = "#{date} #{min_swith(hour)}:#{min_swith(min)}:#{min_swith(sec)}" puts time - case type - when 1 - # 讨论区 - - end - + time end - def min_swith(time) - puts time - return time < 9 ? "0#{time}" : time + def random_larger_time(time, start_time, end_time) + large_time = random_time(start_time, end_time) + while large_time <= time + large_time = random_time(start_time, end_time) + end + large_time end end diff --git a/lib/tasks/publick_course.rake b/lib/tasks/publick_course.rake index 2c12a859b..7e6f53a91 100644 --- a/lib/tasks/publick_course.rake +++ b/lib/tasks/publick_course.rake @@ -20,7 +20,6 @@ namespace :public_course do puts user_id unless CourseMember.exists?(course_id: course_id, user_id: user_id) CourseMember.create!(course_id: course_id, user_id: user_id, role: 4) - CourseAddStudentCreateWorksJob.perform_later(course_id, [user_id]) end end end From 6451e82e532b8e2c2581d04c50d9db41f483e114 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 11:18:17 +0800 Subject: [PATCH 026/100] =?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/files_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index bcfed25dd..e0ad6c5e5 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -221,8 +221,10 @@ class FilesController < ApplicationController @new_attachment_history = @old_attachment.become_history @new_attachment_history.save! + old_course_second_category_id = @old_attachment.course_second_category_id @old_attachment.copy_attributes_from_new_attachment(@new_attachment) @old_attachment.is_public = is_public == true ? 1 : 0 if is_public + @old_attachment.course_second_category_id = old_course_second_category_id @old_attachment.save! @new_attachment.delete end From 33cc18117f38981ce9913e7aa110abbd9dbd88a1 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 11:18:53 +0800 Subject: [PATCH 027/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/public_course.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/public_course.rake b/lib/tasks/public_course.rake index 7ed492968..d2777e613 100644 --- a/lib/tasks/public_course.rake +++ b/lib/tasks/public_course.rake @@ -102,7 +102,7 @@ namespace :public_course do course.attachments.each do |atta| created_on = random_time start_time, end_time - atta.update_columns(is_publish: 1, created_on: created_on) + atta.update_columns(is_publish: 1, created_on: created_on, publish_time: created_on) end end From b377047dfd9fddc5056db752de55ea4f59c42308 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 11:29:46 +0800 Subject: [PATCH 028/100] =?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/files_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index e0ad6c5e5..2bdd88566 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -210,6 +210,7 @@ class FilesController < ApplicationController is_unified_setting = params[:is_unified_setting] publish_time = params[:publish_time] + publish_time = format_time(Time.parse(publish_time)) unless publish_time.blank? is_public = params[:is_public] course_group_publish_times = params[:course_group_publish_times] || [] From f63ea194e15be4259a2e98f51adfff9e951cf924 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 16 Aug 2019 07:46:56 +0800 Subject: [PATCH 029/100] rake .. --- lib/tasks/publick_course.rake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tasks/publick_course.rake b/lib/tasks/publick_course.rake index 7e6f53a91..1e663067b 100644 --- a/lib/tasks/publick_course.rake +++ b/lib/tasks/publick_course.rake @@ -6,11 +6,13 @@ desc "同步精品课数据" namespace :public_course do task :student => :environment do - + if ENV['args'] subject_id = ENV['args'].split(",").first course_id = ENV['args'].split(",").last puts "subject_id is #{subject_id}" puts "course_id is #{course_id}" + end + user_ids = Myshixun.find_by_sql("select distinct(user_id) from myshixuns where shixun_id in (select shixun_id from stage_shixuns where stage_id in (select id from stages where subject_id=#{subject_id}))").map(&:user_id) From 51fb3db2e3404b274f89e14bd95addeb79febcd9 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 16 Aug 2019 07:48:34 +0800 Subject: [PATCH 030/100] sync public --- lib/tasks/public_course.rake | 11 +++++++---- lib/tasks/publick_course.rake | 29 ----------------------------- 2 files changed, 7 insertions(+), 33 deletions(-) delete mode 100644 lib/tasks/publick_course.rake diff --git a/lib/tasks/public_course.rake b/lib/tasks/public_course.rake index d2777e613..13ef7b2e7 100644 --- a/lib/tasks/public_course.rake +++ b/lib/tasks/public_course.rake @@ -9,10 +9,13 @@ desc "同步精品课数据" namespace :public_course do - subject_id = ENV['args'].split(",")[0] # 对应课程的id - course_id = ENV['args'].split(",")[1] # 对应课堂的id - status = ENV['args'].split(",")[2] # 表示相应的期数 - type = ENV['args'].split(",")[3] # 表示课程模块 + if ENV['args'] + subject_id = ENV['args'].split(",")[0] # 对应课程的id + course_id = ENV['args'].split(",")[1] # 对应课堂的id + status = ENV['args'].split(",")[2] # 表示相应的期数 + type = ENV['args'].split(",")[3] # 表示课程模块 + end + if status.to_i == 1 start_time = '2018-12-16' diff --git a/lib/tasks/publick_course.rake b/lib/tasks/publick_course.rake deleted file mode 100644 index 1e663067b..000000000 --- a/lib/tasks/publick_course.rake +++ /dev/null @@ -1,29 +0,0 @@ -#coding=utf-8 -# 执行示例 bundle exec rake public_course:student args=149,2903 -# args 第一个参数是subject_id,第二个参数是课程course_id - -desc "同步精品课数据" -namespace :public_course do - task :student => :environment do - - if ENV['args'] - subject_id = ENV['args'].split(",").first - course_id = ENV['args'].split(",").last - puts "subject_id is #{subject_id}" - puts "course_id is #{course_id}" - end - - - user_ids = Myshixun.find_by_sql("select distinct(user_id) from myshixuns where shixun_id in (select shixun_id from stage_shixuns - where stage_id in (select id from stages where subject_id=#{subject_id}))").map(&:user_id) - puts user_ids - if user_ids.present? - user_ids.each do |user_id| - puts user_id - unless CourseMember.exists?(course_id: course_id, user_id: user_id) - CourseMember.create!(course_id: course_id, user_id: user_id, role: 4) - end - end - end - end -end \ No newline at end of file From 4f9d645ec57ced7cc6abdd31fe055e27779d0690 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 16 Aug 2019 07:54:13 +0800 Subject: [PATCH 031/100] sync message --- lib/tasks/public_message.rake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/tasks/public_message.rake b/lib/tasks/public_message.rake index a804f9c2d..046f79909 100644 --- a/lib/tasks/public_message.rake +++ b/lib/tasks/public_message.rake @@ -26,8 +26,9 @@ namespace :sync do if discusses.present? discusses.find_each do |discuss| puts discuss.user_id - puts discuss.content - new_message = Message.create!(board: board_id, author: discuss.user_id) + puts board_id + puts message_id + new_message = Message.create!(board: board_id.to_i, author: discuss.user_id) MessageDetail.create!(message_id: new_message.id, content: discuss.try(:content)) end end From 475dea03581c0eab60894ef951ac80d6766b331d Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 16 Aug 2019 07:55:50 +0800 Subject: [PATCH 032/100] .. --- lib/tasks/public_message.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/public_message.rake b/lib/tasks/public_message.rake index 046f79909..d06c4a272 100644 --- a/lib/tasks/public_message.rake +++ b/lib/tasks/public_message.rake @@ -28,7 +28,7 @@ namespace :sync do puts discuss.user_id puts board_id puts message_id - new_message = Message.create!(board: board_id.to_i, author: discuss.user_id) + new_message = Message.create!(board_id: board_id.to_i, author: discuss.user_id) MessageDetail.create!(message_id: new_message.id, content: discuss.try(:content)) end end From 40baf91b1c1b2a6bfc058327c1b9e305d0552433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Fri, 16 Aug 2019 09:17:01 +0800 Subject: [PATCH 033/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/search/SearchPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/search/SearchPage.js b/public/react/src/search/SearchPage.js index e5cc07b2b..5c23d331e 100644 --- a/public/react/src/search/SearchPage.js +++ b/public/react/src/search/SearchPage.js @@ -190,7 +190,7 @@ class SearchPage extends Component{
    -
    +
    {/*标题*/} From 977a770b41a315546bc71b590cf30ba6cb62f55a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 09:45:02 +0800 Subject: [PATCH 034/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/excellent_course_exercise.rake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/tasks/excellent_course_exercise.rake diff --git a/lib/tasks/excellent_course_exercise.rake b/lib/tasks/excellent_course_exercise.rake new file mode 100644 index 000000000..3546e48c3 --- /dev/null +++ b/lib/tasks/excellent_course_exercise.rake @@ -0,0 +1,19 @@ +#coding=utf-8 +# 执行示例 bundle exec rake excellent_course_exercise:student_answer args=149,2903 +desc "同步精品课的学生试卷数据" +namespace :excellent_course_exercise do + task :student_answer => :environment do + + course = Course.find_by(id: 2933) + exercises = course.exercises + + participant_count = 1042 + pass_count = 823 + + members_1 = course.students.order("id asc").limit(987) + members_2 = course.students.order("id asc").limit(1042) + members_1 = course.students.order("id asc").limit(322) + + + end +end \ No newline at end of file From 0c408581ae6126049a32cf6c2c6468e71f043a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 16 Aug 2019 10:36:56 +0800 Subject: [PATCH 035/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/coursesDetail/CoursesLeftNav.js | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js index 282024b6d..b28472f66 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js @@ -680,22 +680,26 @@ class Coursesleftnav extends Component{ // course_modules:newcourse_modules // }) - if(result.source.droppableId==="shixun_homework"||result.source.droppableId==="graduation"||result.source.droppableId==="attachment"){ + if(result.source.droppableId==="shixun_homework"||result.source.droppableId==="graduation"||result.source.droppableId==="attachment"){ - let url ="/course_second_categories/"+result.draggableId+"/move_category.json" - this.droppablepost(url,result.destination.index+1) - - }else if(result.source.droppableId==="board"){ - - let url ="/boards/"+result.draggableId+"/move_category.json" - this.droppablepost(url,result.destination.index+1) + let url ="/course_second_categories/"+result.draggableId+"/move_category.json"; + if(result.destination.index!=null){ + this.droppablepost(url,result.destination.index+1) + } + }else if(result.source.droppableId==="board"){ - }else if(result.source.droppableId==="course_group"){ + let url ="/boards/"+result.draggableId+"/move_category.json"; + if(result.destination.index!=null) { + this.droppablepost(url, result.destination.index + 1) + } + }else if(result.source.droppableId==="course_group"){ if(result.draggableId!=1){ - let url ="/course_groups/"+result.draggableId+"/move_category.json" - this.droppablepost(url,result.destination.index+1) + let url ="/course_groups/"+result.draggableId+"/move_category.json"; + if(result.destination.index!=null) { + this.droppablepost(url, result.destination.index + 1) + } } - } + } } From d1f7143bd45148b4eadf0c9ddd52105637a0557e Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 12:23:06 +0800 Subject: [PATCH 036/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/public_message.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/public_message.rake b/lib/tasks/public_message.rake index d06c4a272..ca54fbd7b 100644 --- a/lib/tasks/public_message.rake +++ b/lib/tasks/public_message.rake @@ -28,7 +28,7 @@ namespace :sync do puts discuss.user_id puts board_id puts message_id - new_message = Message.create!(board_id: board_id.to_i, author: discuss.user_id) + new_message = Message.create!(board_id: board_id.to_i, author_id: discuss.user_id, parent_id: message_id, root_id: message_id) MessageDetail.create!(message_id: new_message.id, content: discuss.try(:content)) end end From f571a8bb83b1fb4f5df479116363146044fba086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 16 Aug 2019 12:30:22 +0800 Subject: [PATCH 037/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Resource/index.js | 1 + .../react/src/modules/courses/coursesPublic/SelectSetting.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/Resource/index.js b/public/react/src/modules/courses/Resource/index.js index d93c30d75..29c4a4ff5 100644 --- a/public/react/src/modules/courses/Resource/index.js +++ b/public/react/src/modules/courses/Resource/index.js @@ -757,6 +757,7 @@ class Fileslists extends Component{ setupdate={(id)=>this.seactall(id)} Cancel={this.Cancelvisible} has_course_groups={this.state.has_course_groups} + attachmentId={this.state.coursesecondcategoryid} />:""} Date: Fri, 16 Aug 2019 12:56:34 +0800 Subject: [PATCH 038/100] =?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/shixuns_controller.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 74942446e..8a59477c3 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -563,15 +563,15 @@ class ShixunsController < ApplicationController # end # 如果该实训是金课中的实训,则将当前用户加入到当期开课的课堂 - if StageShixun.exists?(shixun_id: @shixun.id, subject_id: Subject.where(excellent: 1)) - subject = Subject.where(excellent: 1, id: StageShixun.where(shixun_id: @shixun.id).pluck(:subject_id)).take - course = subject.courses.where("start_date is not null and start_date <= '#{Date.today}' and end_date is not null and end_date >= '#{Date.today}'").take - if course.present? && !CourseMember.exists?(course_id: course.id, user_id: current_user.id) - # 为了不影响后续操作,用create而不是create! - CourseMember.create(course_id: course.id, user_id: current_user.id, role: 4) - CourseAddStudentCreateWorksJob.perform_later(course.id, [current_user.id]) - end - end + # if StageShixun.exists?(shixun_id: @shixun.id, subject_id: Subject.where(excellent: 1)) + # subject = Subject.where(excellent: 1, id: StageShixun.where(shixun_id: @shixun.id).pluck(:subject_id)).take + # course = subject.courses.where("start_date is not null and start_date <= '#{Date.today}' and end_date is not null and end_date >= '#{Date.today}'").take + # if course.present? && !CourseMember.exists?(course_id: course.id, user_id: current_user.id) + # # 为了不影响后续操作,用create而不是create! + # CourseMember.create(course_id: course.id, user_id: current_user.id, role: 4) + # CourseAddStudentCreateWorksJob.perform_later(course.id, [current_user.id]) + # end + # end ActiveRecord::Base.transaction do begin From ac66f683f28221178d55251d2bbe2246cff57fed Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 12:57:32 +0800 Subject: [PATCH 039/100] =?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/shixuns_controller.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 8a59477c3..c9b56bb98 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -555,12 +555,12 @@ class ShixunsController < ApplicationController # 判断实训是否全为选择题 is_choice_type = (min_challenges.size == min_challenges.select{|challenge| challenge.last == 1}.count) - # if !is_choice_type - # commit = GitService.commits(repo_path: @repo_path).try(:first) - # uid_logger("First comit########{commit}") - # tip_exception("开启实战前请先在版本库中提交代码") if commit.blank? - # commit_id = commit["id"] - # end + if !is_choice_type + commit = GitService.commits(repo_path: @repo_path).try(:first) + uid_logger("First comit########{commit}") + tip_exception("开启实战前请先在版本库中提交代码") if commit.blank? + commit_id = commit["id"] + end # 如果该实训是金课中的实训,则将当前用户加入到当期开课的课堂 # if StageShixun.exists?(shixun_id: @shixun.id, subject_id: Subject.where(excellent: 1)) From 031b93f7cfb0db09cf14eb270b34a80c327d039b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 16 Aug 2019 13:48:41 +0800 Subject: [PATCH 040/100] =?UTF-8?q?=E5=A4=8D=E5=88=B6=E8=AF=BE=E5=A0=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/duplicate_course_service.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/services/duplicate_course_service.rb b/app/services/duplicate_course_service.rb index 9d61984db..8d6ce4f72 100644 --- a/app/services/duplicate_course_service.rb +++ b/app/services/duplicate_course_service.rb @@ -38,7 +38,12 @@ class DuplicateCourseService < ApplicationService def copy_course_modules! origin_course.course_modules.each do |course_module| attrs = course_module.as_json(only: %i[module_type position hidden module_name]) - CourseModule.create!(attrs.merge(course_id: course.id)) + new_course_module = CourseModule.create!(attrs.merge(course_id: course.id)) + # 复制子目录 + course_module.course_second_categories.each do |second_category| + category_attr = second_category.as_json(only: %i[category_type name position]) + CourseSecondCategory.create!(category_attr.merge(course_id: course.id, course_module_id: new_course_module.id)) + end end end From 8299c443ab5130f14aef33e8079386f949895b13 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 16 Aug 2019 14:21:15 +0800 Subject: [PATCH 041/100] =?UTF-8?q?=E5=A4=8D=E5=88=B6=E8=AF=BE=E5=A0=82?= =?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/services/duplicate_course_service.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/services/duplicate_course_service.rb b/app/services/duplicate_course_service.rb index 8d6ce4f72..acff0a726 100644 --- a/app/services/duplicate_course_service.rb +++ b/app/services/duplicate_course_service.rb @@ -36,13 +36,16 @@ class DuplicateCourseService < ApplicationService end def copy_course_modules! + @second_category_list = {} origin_course.course_modules.each do |course_module| attrs = course_module.as_json(only: %i[module_type position hidden module_name]) new_course_module = CourseModule.create!(attrs.merge(course_id: course.id)) # 复制子目录 course_module.course_second_categories.each do |second_category| category_attr = second_category.as_json(only: %i[category_type name position]) - CourseSecondCategory.create!(category_attr.merge(course_id: course.id, course_module_id: new_course_module.id)) + new_second_category = + CourseSecondCategory.create!(category_attr.merge(course_id: course.id, course_module_id: new_course_module.id)) + @second_category_list[second_category.id] = new_second_category.id end end end @@ -55,7 +58,10 @@ class DuplicateCourseService < ApplicationService origin_course.homework_commons.where(homework_type: %i[normal group practice]).find_each do |origin_homework| homework_attrs = origin_homework.as_json(only: %i[name description homework_type homework_bank_id reference_answer]) - homework = HomeworkCommon.create!(homework_attrs.merge(user_id: user.id, course_id: course.id)) + course_second_category_id = @second_category_list[origin_homework.course_second_category_id] + + homework = HomeworkCommon.create!(homework_attrs.merge(user_id: user.id, course_id: course.id, + course_second_category_id:course_second_category_id)) origin_homework.attachments.find_each do |origin_attachment| attachment = origin_attachment.copy @@ -76,6 +82,7 @@ class DuplicateCourseService < ApplicationService HomeworksService.new.create_shixun_homework_cha_setting(homework, origin_homework.shixuns.first) end + origin_homework.increment!(:quotes) origin_homework.homework_bank.increment!(:quotes) if origin_homework.homework_bank end @@ -143,9 +150,9 @@ class DuplicateCourseService < ApplicationService attachment.copy_from = origin_attachment.copy_from || origin_attachment.id attachment.is_publish = 0 attachment.attachtype ||= 4 + attachment.course_second_category_id = @second_category_list[origin_attachment.course_second_category_id] attachment.save! - origin_course.update_quotes(attachment) end end From cc29cb619419ff4325004c6a0bab5bd43d233fe4 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 16 Aug 2019 14:27:00 +0800 Subject: [PATCH 042/100] =?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/services/duplicate_course_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/duplicate_course_service.rb b/app/services/duplicate_course_service.rb index acff0a726..2456c81ff 100644 --- a/app/services/duplicate_course_service.rb +++ b/app/services/duplicate_course_service.rb @@ -11,7 +11,7 @@ class DuplicateCourseService < ApplicationService @course = copy_course! copy_course_modules! - + logger.info("###########second_category_list#{@second_category_list}") join_course! copy_homework_commons! From b81ddf1d0d31d3a1e921b3bd8a54fa14d6b40bdb Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 16 Aug 2019 14:28:01 +0800 Subject: [PATCH 043/100] =?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/services/duplicate_course_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/duplicate_course_service.rb b/app/services/duplicate_course_service.rb index 2456c81ff..27ae2f784 100644 --- a/app/services/duplicate_course_service.rb +++ b/app/services/duplicate_course_service.rb @@ -11,7 +11,7 @@ class DuplicateCourseService < ApplicationService @course = copy_course! copy_course_modules! - logger.info("###########second_category_list#{@second_category_list}") + Rails.logger.info("###########second_category_list#{@second_category_list}") join_course! copy_homework_commons! From 4103d471aa197a83acb5f68ddc12d6b496d6ca8b Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 14:39:20 +0800 Subject: [PATCH 044/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/excellent_course_exercise.rake | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/tasks/excellent_course_exercise.rake b/lib/tasks/excellent_course_exercise.rake index c68cf6348..9f1484027 100644 --- a/lib/tasks/excellent_course_exercise.rake +++ b/lib/tasks/excellent_course_exercise.rake @@ -16,7 +16,16 @@ namespace :excellent_course_exercise do exercise_1884 = course.exercises.find_by(id: 1884) members_1.each_with_index do |member, index| if index < 821 - + exercise_1884.exercise_questions.where.not(question_type: 5).each do |question| + answer_option = { + :user_id => current_user.id, + :exercise_question_id => @exercise_question.id, + :exercise_choice_id => choice_id, + :answer_text => "" + } + ex_a = ExerciseAnswer.new(answer_option) + ex_a.save! + end else end From c0a4766dab4c7519661875ca532aacc15ac48ce3 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 14:41:34 +0800 Subject: [PATCH 045/100] tz --- app/controllers/subjects_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 6a381b258..55f8722a2 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -86,6 +86,16 @@ class SubjectsController < ApplicationController @shixuns = @subject.shixuns.published.pluck(:id) @courses = @subject.courses if @subject.excellent + @members = @subject.subject_members.includes(:user) + shixuns = @subject.shixuns.published.pluck(:id) + challenge_ids = Challenge.where(shixun_id: shixuns).pluck(:id) + # 实训路径中的所有实训标签 + @tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq + # 用户获取的实训标签 + # @user_tags = @subject.shixuns.map(&:user_tags_name).flatten.uniq + @user_tags = user_shixun_tags challenge_ids, @user.id + @my_subject_progress = @subject.my_subject_progress + # 访问数变更 @subject.increment!(:visits) end From 6716cd9938736c3e33e13065a07bdb43f8bcc1d3 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 14:42:34 +0800 Subject: [PATCH 046/100] tz --- app/views/subjects/show.json.jbuilder | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/views/subjects/show.json.jbuilder b/app/views/subjects/show.json.jbuilder index bf179b86d..93fa105a6 100644 --- a/app/views/subjects/show.json.jbuilder +++ b/app/views/subjects/show.json.jbuilder @@ -22,4 +22,26 @@ if @subject.excellent json.course_identity @user.course_identity(course) json.course_status subject_course_status course end +end + + +json.members @members do |member| + json.partial! 'subject_member', locals: { user: member.user } + json.role member.role +end + +# 技能标签 +json.tags @tags do |tag| + unless tag.blank? + json.tag_name tag + json.status @user_tags.include?(tag) + end +end + +# 我的进展 +json.progress do + json.my_score @subject.my_subject_score + json.all_score @subject.all_score + json.learned @subject.my_subject_progress + json.time @subject.my_consume_time end \ No newline at end of file From 32bb3c60442e692f6e778e07098e01d8271e1fd7 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 16 Aug 2019 15:05:09 +0800 Subject: [PATCH 047/100] video feature add teacher check --- app/controllers/users/base_controller.rb | 6 ++++++ app/controllers/users/video_auths_controller.rb | 2 +- app/controllers/users/videos_controller.rb | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/users/base_controller.rb b/app/controllers/users/base_controller.rb index 706b77802..7dd5ae024 100644 --- a/app/controllers/users/base_controller.rb +++ b/app/controllers/users/base_controller.rb @@ -26,6 +26,12 @@ class Users::BaseController < ApplicationController render_forbidden end + def require_auth_teacher! + return if user.admin_or_business? || observed_user.certification_teacher? + + render_forbidden + end + def page_value params[:page].to_i <= 0 ? 1 : params[:page].to_i end diff --git a/app/controllers/users/video_auths_controller.rb b/app/controllers/users/video_auths_controller.rb index d7950f873..0eec4dffb 100644 --- a/app/controllers/users/video_auths_controller.rb +++ b/app/controllers/users/video_auths_controller.rb @@ -1,5 +1,5 @@ class Users::VideoAuthsController < Users::BaseController - before_action :private_user_resources! + before_action :private_user_resources!, :require_auth_teacher! def create result = Videos::CreateAuthService.call(observed_user, create_params) diff --git a/app/controllers/users/videos_controller.rb b/app/controllers/users/videos_controller.rb index e4dffec23..1df726c0c 100644 --- a/app/controllers/users/videos_controller.rb +++ b/app/controllers/users/videos_controller.rb @@ -1,5 +1,5 @@ class Users::VideosController < Users::BaseController - before_action :private_user_resources! + before_action :private_user_resources!, :require_auth_teacher! helper_method :current_video From 43d8f62f0fcec73b1872d90bafc6133fce3b6602 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 16 Aug 2019 15:28:24 +0800 Subject: [PATCH 048/100] fix --- app/controllers/users/base_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users/base_controller.rb b/app/controllers/users/base_controller.rb index 7dd5ae024..eb6b98048 100644 --- a/app/controllers/users/base_controller.rb +++ b/app/controllers/users/base_controller.rb @@ -27,7 +27,7 @@ class Users::BaseController < ApplicationController end def require_auth_teacher! - return if user.admin_or_business? || observed_user.certification_teacher? + return if current_user.admin_or_business? || observed_user.certification_teacher? render_forbidden end From 965f9b65f86f800465a12c1062cd5a6383c0cad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 16 Aug 2019 15:50:33 +0800 Subject: [PATCH 049/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/config/webpack.config.dev.js | 2 +- .../modules/courses/Resource/Fileslistitem.js | 25 ++++++++++++++----- .../courses/coursesPublic/Showoldfiles.js | 19 ++++++++++++-- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/public/react/config/webpack.config.dev.js b/public/react/config/webpack.config.dev.js index 6e78fd410..510bcaa4f 100644 --- a/public/react/config/webpack.config.dev.js +++ b/public/react/config/webpack.config.dev.js @@ -29,7 +29,7 @@ const env = getClientEnvironment(publicUrl); module.exports = { // You may want 'eval' instead if you prefer to see the compiled output in DevTools. // See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s - devtool: "cheap-module-eval-source-map", + // devtool: "cheap-module-eval-source-map", // 开启调试 // These are the "entry points" to our application. // This means they will be the "root" imports that are included in JS bundle. diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index f0aec7f64..5832770f1 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -36,7 +36,16 @@ class Fileslistitem extends Component{ course_id:coursesId }, }).then((result)=>{ - if(result.data.attachment_histories.length===0){ + + if(result.data.attachment_histories.length===0){ + if(result.data.is_pdf===true){ + axios.get(result.data.url).then((result)=>{ + var binaryData = []; + binaryData.push(result.data); + this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); + window.open(this.url); + }) + }else{ let link = document.createElement('a'); document.body.appendChild(link); link.href = result.data.url; @@ -46,12 +55,15 @@ class Fileslistitem extends Component{ evt.initEvent("click", false, false); link.dispatchEvent(evt); document.body.removeChild(link); + } }else{ - this.setState({ - Showoldfiles:true, - allfiles:result.data - }) - } + this.setState({ + Showoldfiles:true, + allfiles:result.data + }) + } + + }).catch((error)=>{ console.log(error) }) @@ -144,6 +156,7 @@ class Fileslistitem extends Component{ loadtype={this.state.Loadtype} />:""} { + axios.get(url).then((result)=>{ + var binaryData = []; + binaryData.push(result.data); + this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); + window.open(this.url); + }) + } render(){ let {visible,allfiles}=this.props; @@ -175,7 +183,10 @@ class Showoldfiles extends Component{
  • - {allfiles.title} + {allfiles.is_pdf===false? + {allfiles.title}: + this.showfiless(allfiles.url)} >{allfiles.title} + } 当前版本
  • @@ -191,7 +202,11 @@ class Showoldfiles extends Component{
  • - {item.title} + + {allfiles.is_pdf===false? + {item.title}: + this.showfiless(item.url)} >{item.title} + }
  • From 7b99a1a5c5f85a8adf74c9430f05cd2bfedd8307 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 16 Aug 2019 15:55:22 +0800 Subject: [PATCH 050/100] =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=99=84=E4=BB=B6=E7=9A=84pdf=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 7 +------ app/models/attachment.rb | 11 +++++++++++ .../_attachment_history.json.jbuilder | 1 + app/views/attachments/_attachment_small.json.jbuilder | 3 ++- app/views/files/histories.json.jbuilder | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index bcfed25dd..2cfa61cc9 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -260,12 +260,7 @@ class FilesController < ApplicationController return normal_status(-2, "该课程下没有id为 #{params[:id]}的资源") if @file.nil? return normal_status(403, "您没有权限进行该操作") if @user != @file.author && !@user.teacher_of_course?(@course) && !@file.public? - @is_pdf = false - file_content_type = @file.content_type - file_ext_type = File.extname(@file.filename).strip.downcase[1..-1] - if (file_content_type.present? && file_content_type.downcase.include?("pdf")) || (file_ext_type.present? && file_ext_type.include?("pdf")) - @is_pdf = true - end + @attachment_histories = @file.attachment_histories end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index bdd749108..3a512278a 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -115,4 +115,15 @@ class Attachment < ApplicationRecord end end + #判断是否为pdf文件 + def is_pdf? + is_pdf = false + file_content_type = content_type + file_ext_type = File.extname(filename).strip.downcase[1..-1] + if (file_content_type.present? && file_content_type.downcase.include?("pdf")) || (file_ext_type.present? && file_ext_type.include?("pdf")) + is_pdf = true + end + is_pdf + end + end diff --git a/app/views/attachment_histories/_attachment_history.json.jbuilder b/app/views/attachment_histories/_attachment_history.json.jbuilder index 37b8b95c1..65ca1e887 100644 --- a/app/views/attachment_histories/_attachment_history.json.jbuilder +++ b/app/views/attachment_histories/_attachment_history.json.jbuilder @@ -7,3 +7,4 @@ json.quotes attachment.quotes_count json.downloads_count attachment.downloads_count json.created_on attachment.created_on json.url attachment_path(attachment, type: 'history') +json.is_pdf attachment.is_pdf? diff --git a/app/views/attachments/_attachment_small.json.jbuilder b/app/views/attachments/_attachment_small.json.jbuilder index d9a976bde..97cbee120 100644 --- a/app/views/attachments/_attachment_small.json.jbuilder +++ b/app/views/attachments/_attachment_small.json.jbuilder @@ -2,4 +2,5 @@ json.id attachment.id json.title attachment.title json.filesize number_to_human_size(attachment.filesize) json.url download_url(attachment) -json.created_on attachment.created_on \ No newline at end of file +json.created_on attachment.created_on +json.is_pdf attachment.is_pdf? \ No newline at end of file diff --git a/app/views/files/histories.json.jbuilder b/app/views/files/histories.json.jbuilder index 9dfec4fd4..7039752e7 100644 --- a/app/views/files/histories.json.jbuilder +++ b/app/views/files/histories.json.jbuilder @@ -1,3 +1,3 @@ -json.is_pdf @is_pdf + json.partial! 'attachments/attachment_small', attachment: @file json.partial! "attachment_histories/list", attachment_histories: @attachment_histories From 1677cea34dbf1a5b24a20dddbecc5d885f3da78b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 16 Aug 2019 16:01:22 +0800 Subject: [PATCH 051/100] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E8=80=81=E5=B8=88?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E8=87=AA=E5=8A=A8=E5=8A=A0=E5=85=A5=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=E8=AF=BE=E5=A0=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/users/update_account_service.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/services/users/update_account_service.rb b/app/services/users/update_account_service.rb index c8ba6da61..3f0aa8cc8 100644 --- a/app/services/users/update_account_service.rb +++ b/app/services/users/update_account_service.rb @@ -51,8 +51,10 @@ class Users::UpdateAccountService < ApplicationService if first_full_reward RewardGradeService.call(user, container_id: user.id, container_type: 'Account', score: 500) - - sms_notify_admin(user.lastname) if user.user_extension.teacher? + if user.user_extension.teacher? + join_course(user.id,1309, 2) + sms_notify_admin(user.lastname) + end end user @@ -73,4 +75,11 @@ class Users::UpdateAccountService < ApplicationService rescue => ex Util.logger_error(ex) end + + def join_course(user_id, course_id, identity) + course = Course.find_by(id: course_id) + return unless course + attr = {course_id: course_id, role: identity, user_id: user_id} + CourseMember.create!(attr) + end end \ No newline at end of file From 653fb5191d595711dbc9fc8b8deedf532f43bf00 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 16 Aug 2019 16:09:32 +0800 Subject: [PATCH 052/100] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=A4=E6=96=ADpdf?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment_history.rb | 10 ++++++++++ .../_attachment_history.json.jbuilder | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/models/attachment_history.rb b/app/models/attachment_history.rb index 220f92535..c19146b95 100644 --- a/app/models/attachment_history.rb +++ b/app/models/attachment_history.rb @@ -20,4 +20,14 @@ class AttachmentHistory < ApplicationRecord is_public == 1 end + def is_history_pdf? + is_pdf = false + file_content_type = content_type + file_ext_type = File.extname(filename).strip.downcase[1..-1] + if (file_content_type.present? && file_content_type.downcase.include?("pdf")) || (file_ext_type.present? && file_ext_type.include?("pdf")) + is_pdf = true + end + is_pdf + end + end diff --git a/app/views/attachment_histories/_attachment_history.json.jbuilder b/app/views/attachment_histories/_attachment_history.json.jbuilder index 65ca1e887..8930e1b2d 100644 --- a/app/views/attachment_histories/_attachment_history.json.jbuilder +++ b/app/views/attachment_histories/_attachment_history.json.jbuilder @@ -7,4 +7,4 @@ json.quotes attachment.quotes_count json.downloads_count attachment.downloads_count json.created_on attachment.created_on json.url attachment_path(attachment, type: 'history') -json.is_pdf attachment.is_pdf? +json.is_pdf attachment.is_history_pdf? From de93d52d8cdc9a818e48fb9db5c1e377dc388683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 16 Aug 2019 16:35:38 +0800 Subject: [PATCH 053/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Resource/Fileslistitem.js | 2 +- .../react/src/modules/courses/coursesPublic/Showoldfiles.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 5832770f1..c26f390cf 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -48,7 +48,7 @@ class Fileslistitem extends Component{ }else{ let link = document.createElement('a'); document.body.appendChild(link); - link.href = result.data.url; + link.href = "/api"+result.data.url; link.download = result.data.title; //兼容火狐浏览器 let evt = document.createEvent("MouseEvents"); diff --git a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js index 8f1e7a29f..4bf98fb4f 100644 --- a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js +++ b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js @@ -184,7 +184,7 @@ class Showoldfiles extends Component{
  • {allfiles.is_pdf===false? - {allfiles.title}: + {allfiles.title}: this.showfiless(allfiles.url)} >{allfiles.title} } 当前版本 @@ -203,8 +203,8 @@ class Showoldfiles extends Component{
  • - {allfiles.is_pdf===false? - {item.title}: + {item.is_pdf===false? + {item.title}: this.showfiless(item.url)} >{item.title} }
  • From 31cae1194bbc03b16a4c2e802049725ac84f7720 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 16 Aug 2019 16:36:51 +0800 Subject: [PATCH 054/100] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E7=9A=84api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 2 +- .../attachment_histories/_attachment_history.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 099d45406..e6f2e1720 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -258,7 +258,7 @@ module ApplicationHelper end def download_url attachment - attachment_path(attachment) + attachment_path(attachment).gsub("/api","") end # 耗时:天、小时、分、秒 diff --git a/app/views/attachment_histories/_attachment_history.json.jbuilder b/app/views/attachment_histories/_attachment_history.json.jbuilder index 8930e1b2d..afb359e08 100644 --- a/app/views/attachment_histories/_attachment_history.json.jbuilder +++ b/app/views/attachment_histories/_attachment_history.json.jbuilder @@ -6,5 +6,5 @@ json.publish_time attachment.publish_time json.quotes attachment.quotes_count json.downloads_count attachment.downloads_count json.created_on attachment.created_on -json.url attachment_path(attachment, type: 'history') +json.url attachment_path(attachment, type: 'history').gsub("/api","") json.is_pdf attachment.is_history_pdf? From 83d63dcfaf947306a999d32726e7b6bdbfd79180 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 16:52:02 +0800 Subject: [PATCH 055/100] =?UTF-8?q?=E9=87=91=E8=AF=BE=E8=AF=95=E5=8D=B7?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/excellent_course_exercise.rake | 198 ++++++++++++++++++++--- 1 file changed, 175 insertions(+), 23 deletions(-) diff --git a/lib/tasks/excellent_course_exercise.rake b/lib/tasks/excellent_course_exercise.rake index 9f1484027..a607c24a0 100644 --- a/lib/tasks/excellent_course_exercise.rake +++ b/lib/tasks/excellent_course_exercise.rake @@ -1,34 +1,186 @@ #coding=utf-8 -# 执行示例 bundle exec rake excellent_course_exercise:student_answer args=149,2903 +# 执行示例 bundle exec rake excellent_course_exercise:student_answer args=2933,1042,823 +# args 第一个是course_id, 第二个是参与人数, 第三个是通过人数 desc "同步精品课的学生试卷数据" namespace :excellent_course_exercise do + if ENV['args'] + course_id = ENV['args'].split(",")[0] # 对应课堂的id + participant_count = ENV['args'].split(",")[1].to_i # 表示参与人数 + pass_count = ENV['args'].split(",")[2].to_i # 表示通过人数 + end + task :student_answer => :environment do - course = Course.find_by(id: 2933) - - participant_count = 1042 - pass_count = 823 - - members_1 = course.students.order("id asc").limit(987) - members_2 = course.students.order("id asc").limit(1042) - members_1 = course.students.order("id asc").limit(322) - - exercise_1884 = course.exercises.find_by(id: 1884) - members_1.each_with_index do |member, index| - if index < 821 - exercise_1884.exercise_questions.where.not(question_type: 5).each do |question| - answer_option = { - :user_id => current_user.id, - :exercise_question_id => @exercise_question.id, - :exercise_choice_id => choice_id, - :answer_text => "" - } - ex_a = ExerciseAnswer.new(answer_option) - ex_a.save! - end + course = Course.find_by(id: course_id) + + course.exercises.each_with_index do |exercise, index| + # 第一个试卷的参与人数和通过人数都是传的数据,后续的随机 + if index == 0 + members = course.students.order("id asc").limit(participant_count) + update_exercise_user(exercise, members, pass_count) + else + new_participant_count = rand((participant_count - 423)..participant_count) + new_pass_count = rand((new_participant_count - 113)..new_participant_count) + + members = course.students.order("id asc").limit(new_participant_count) + update_exercise_user(exercise, members, new_pass_count) + end + end + end + + def update_exercise_user exercise, members, pass_count + exercise_question_ids = exercise.exercise_questions.where(question_type: 0).pluck(:id) + + # index < pass_count 之前的学生都是通关的,之后的未通过 + members.each_with_index do |member, index| + exercise_user = exercise.exercise_users.where(user_id: member.user_id).take + if exercise_question_ids.length == 20 + rand_num = index < pass_count - 1 ? 20 : rand(1..16) + elsif exercise_question_ids.length == 17 + rand_num = index < pass_count - 1 ? rand(13..17) : rand(1..11) else + rand_num = exercise_question_ids.length + end + if exercise_user && exercise_user.commit_status == 0 + exercise_question_ids = exercise_question_ids.sample(rand_num) + questions = exercise.exercise_questions.where(id: exercise_question_ids) + create_exercise_answer questions, member.user_id + + total_score = calculate_student_score(exercise, member.user) + commit_option = { + :status => 1, + :commit_status => 1, + :start_at => exercise.publish_time, + :end_at => exercise.end_time, + :objective_score => total_score, + :score => total_score, + :subjective_score => 0 + } + exercise_user.update_columns(commit_option) + end + end + end + + def create_exercise_answer questions, user_id + questions.each do |question| + choice_position = question.exercise_standard_answers.take&.exercise_choice_id + choice = question.exercise_choices.where(choice_position: choice_position).take + + answer_option = { + :user_id => user_id, + :exercise_question_id => question.id, + :exercise_choice_id => choice&.id, + :answer_text => "" + } + ex_a = ExerciseAnswer.new(answer_option) + ex_a.save! + end + end + + #计算试卷的总分和试卷的答题状态 + def calculate_student_score(exercise,user) + score1 = 0.0 #选择题/判断题 + score2 = 0.0 #填空题 + score5 = 0.0 #实训题 + total_score = 0.0 + ques_stand = [] #问题是否正确 + exercise_questions = exercise.exercise_questions.includes(:exercise_answers,:exercise_shixun_answers,:exercise_standard_answers,:exercise_shixun_challenges) + exercise_questions&.each do |q| + begin + if q.question_type != 5 + answers_content = q.exercise_answers.where(user_id: user.id) #学生的答案 + else + answers_content = q.exercise_shixun_answers.where(user_id: user.id) #学生的答案 + end + if q.question_type <= 2 #为选择题或判断题时 + if answers_content.present? #学生有回答时 + answer_choice_array = [] + answers_content.each do |a| + answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置 + end + user_answer_content = answer_choice_array.sort + standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 + if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 + if standard_answer.size > 0 + q_score_1 = q.question_score + # q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。 + else + q_score_1 = 0.0 + end + answers_content.update_all(:score => q_score_1) + score1 = score1 + q.question_score + else + answers_content.update_all(:score => -1.0) + score1 += 0.0 + end + else + score1 += 0.0 + end + elsif q.question_type == 5 #实训题时,主观题这里不评分 + q.exercise_shixun_challenges&.each do |exercise_cha| + game = Game.user_games(user.id,exercise_cha.challenge_id)&.first #当前用户的关卡 + if game.present? + exercise_cha_score = 0.0 + answer_status = 0 + # if game.status == 2 && game.final_score >= 0 + if game.final_score > 0 + exercise_cha_score = game.real_score(exercise_cha.question_score) + # exercise_cha_score = exercise_cha.question_score #每一关卡的得分 + answer_status = 1 + end + ex_shixun_answer_content = answers_content&.where(exercise_shixun_challenge_id: exercise_cha.id) + code = nil + if exercise_cha.challenge&.path.present? + cha_path = challenge_path(exercise_cha.challenge&.path) + game_challenge = game.game_codes.search_challenge_path(cha_path)&.first + if game_challenge.present? + game_code = game_challenge + code = game_code.try(:new_code) + else + code = git_fle_content(game.myshixun.repo_path,cha_path) + end + end + if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里 + ### Todo 实训题的_shixun_details里的代码是不是直接从这里取出就可以了?涉及到code的多个版本库的修改 + sx_option = { + :exercise_question_id => q.id, + :exercise_shixun_challenge_id => exercise_cha.id, + :user_id => user.id, + :score => exercise_cha_score.round(1), + :answer_text => code, + :status => answer_status + } + ExerciseShixunAnswer.create(sx_option) + else + ex_shixun_answer_content.first.update_attributes(score:exercise_cha_score.round(1),answer_text:code) + end + score5 += exercise_cha_score + else + score5 += 0.0 + end + end + end + user_scores = answers_content.blank? ? 0.0 : answers_content.score_reviewed.pluck(:score).sum + if user_scores > 0.0 + stand_answer = 1 + else + stand_answer = 0 + end + ques_option = { + "q_id":q.id, #该问题的id + "q_type":q.question_type, + "q_position":q.question_number, #该问题的位置 + "stand_status":stand_answer, #该问题是否正确,1为正确,0为错误 + "user_score":user_scores.round(1) #每个问题的总得分 + } + ques_stand.push(ques_option) + rescue Exception => e + Rails.logger.info("calcuclate_score_have_error____________________________#{e}") + next end end + total_score = score1 + score2 + score5 + total_score end end \ No newline at end of file From 81047b02a39881af311c52dd835a6848919c6dd5 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 16 Aug 2019 16:54:28 +0800 Subject: [PATCH 056/100] video feature: upload video api error message extense --- app/libs/aliyun_vod/service/video_upload.rb | 9 +++++++++ app/services/videos/create_auth_service.rb | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/libs/aliyun_vod/service/video_upload.rb b/app/libs/aliyun_vod/service/video_upload.rb index 97ecd970b..a5ade72f9 100644 --- a/app/libs/aliyun_vod/service/video_upload.rb +++ b/app/libs/aliyun_vod/service/video_upload.rb @@ -16,6 +16,15 @@ module AliyunVod::Service::VideoUpload result = request(:post, params) + if result['Code'].present? + message = + case result['Code'] + when 'InvalidFileName.Extension' then '不支持的文件格式' + when 'IllegalCharacters' then '文件名称包含非法字符' + end + raise AliyunVod::Error, message if message.present? + end + raise AliyunVod::Error, '获取上传凭证失败' if result['UploadAddress'].blank? result diff --git a/app/services/videos/create_auth_service.rb b/app/services/videos/create_auth_service.rb index 8d83ca4e2..3c7ecf2f6 100644 --- a/app/services/videos/create_auth_service.rb +++ b/app/services/videos/create_auth_service.rb @@ -35,7 +35,7 @@ class Videos::CreateAuthService < ApplicationService def upload_video_result AliyunVod::Service.create_upload_video(title, filename, params) - rescue AliyunVod::Error => _ - raise Error, '获取视频上传凭证失败' + rescue AliyunVod::Error => ex + raise Error, ex.message || '获取视频上传凭证失败' end end \ No newline at end of file From dd143f45430619040aca9a3acfca9f8985237cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 16 Aug 2019 17:09:14 +0800 Subject: [PATCH 057/100] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0pdf=20=E5=B1=95=E7=A4=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/Resource/Fileslistitem.js | 17 +++++++++++------ .../courses/coursesPublic/Showoldfiles.js | 6 +++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index c26f390cf..563724040 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -39,12 +39,17 @@ class Fileslistitem extends Component{ if(result.data.attachment_histories.length===0){ if(result.data.is_pdf===true){ - axios.get(result.data.url).then((result)=>{ - var binaryData = []; - binaryData.push(result.data); - this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); - window.open(this.url); - }) + //预览pdf + axios({ + method:'get', + url:result.data.url, + responseType: 'arraybuffer', + }).then((result)=>{ + var binaryData = []; + binaryData.push(result.data); + this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); + window.open(this.url); + }) }else{ let link = document.createElement('a'); document.body.appendChild(link); diff --git a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js index 4bf98fb4f..483768271 100644 --- a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js +++ b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js @@ -43,7 +43,11 @@ class Showoldfiles extends Component{ } showfiless=(url)=>{ - axios.get(url).then((result)=>{ + axios({ + method:'get', + url:url, + responseType: 'arraybuffer', + }).then((result)=>{ var binaryData = []; binaryData.push(result.data); this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); From b5c560c1d12b1b7aeb6728aaaa9a474dc909cda2 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 16 Aug 2019 17:23:41 +0800 Subject: [PATCH 058/100] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E4=B8=87=E8=83=BD?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/accounts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index aa9ddebf0..2524c53d8 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -33,7 +33,7 @@ class AccountsController < ApplicationController uid_logger("start register: verifi_code is #{verifi_code}, code is #{code}, time is #{Time.now.to_i - verifi_code.try(:created_at).to_i}") # check_code = (verifi_code.try(:code) == code.strip && (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60) # todo 上线前请删除万能验证码"513231" - if code != "513231" + unless code == "513231" && request.host == "47.96.87.25" return normal_status(-2, "验证码不正确") if verifi_code.try(:code) != code.strip return normal_status(-2, "验证码已失效") if !verifi_code&.effective? end From a082283212e5b240a39fc19f68b8f2dfc9eb4223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 16 Aug 2019 17:44:14 +0800 Subject: [PATCH 059/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/paths/PathDetail/DetailCards.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/react/src/modules/paths/PathDetail/DetailCards.js b/public/react/src/modules/paths/PathDetail/DetailCards.js index e34666294..780ed4071 100644 --- a/public/react/src/modules/paths/PathDetail/DetailCards.js +++ b/public/react/src/modules/paths/PathDetail/DetailCards.js @@ -226,10 +226,11 @@ class DetailCards extends Component{ startshixunCombattype:true, }) } else { - window.location.href = "/tasks/" + response.data.game_identifier; + // window.location.href = "/tasks/" + response.data.game_identifier; // window.location.href = path // let path="/tasks/"+response.data.game_identifier; // this.props.history.push(path); + window.open("/tasks/" + response.data.game_identifier); } }).catch((error) => { From 0ed5b9fd68b4e07e756f1481928cf4f158cceb65 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 16 Aug 2019 17:44:14 +0800 Subject: [PATCH 060/100] =?UTF-8?q?=E5=BC=80=E5=A7=8B=E7=AD=94=E9=A2=98?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 781ede214..c9162448b 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1566,15 +1566,22 @@ class ExercisesController < ApplicationController def check_user_id_start_answer #判断用户在开始答题时,是否有用户id传入,如果为老师,则id必需,否则为当前用户的id user_login = params[:login] - # exercise_current_user_id = params[:user_id] if user_login.blank? && @user_course_identity < Course::STUDENT #id不存在,且当前为老师/管理员等 normal_status(-1,"请输入学生登陆名!") else - @ex_answerer = User.find_by(login: user_login) #回答者 + if @user_course_identity < Course::STUDENT || @exercise.score_open + @ex_answerer = user_login.blank? ? current_user : User.find_by(login: user_login) + else + @ex_answerer = current_user + end + if @ex_answerer.blank? normal_status(404,"答题用户不存在") + elsif @user_course_identity > Course::STUDENT && !@exercise.is_public + normal_status(403,"非公开试卷") else - @exercise_current_user_id = @ex_answerer.id || current_user.id + # @exercise_current_user_id = @ex_answerer.id || current_user.id + @exercise_current_user_id = @ex_answerer.id end end end From 2dba28b3e7b7d550d81f808e7dfb0a00187f4993 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 17:53:07 +0800 Subject: [PATCH 061/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/excellent_course_exercise.rake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/tasks/excellent_course_exercise.rake b/lib/tasks/excellent_course_exercise.rake index a607c24a0..07c33d9e9 100644 --- a/lib/tasks/excellent_course_exercise.rake +++ b/lib/tasks/excellent_course_exercise.rake @@ -38,6 +38,8 @@ namespace :excellent_course_exercise do rand_num = index < pass_count - 1 ? 20 : rand(1..16) elsif exercise_question_ids.length == 17 rand_num = index < pass_count - 1 ? rand(13..17) : rand(1..11) + elsif exercise_question_ids.length == 39 + rand_num = index < pass_count - 1 ? rand(30..39) : rand(1..18) else rand_num = exercise_question_ids.length end From 88afa881adc36f1376a515fc541478dcb4dc33a5 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 18:03:40 +0800 Subject: [PATCH 062/100] =?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/views/courses/settings.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/courses/settings.json.jbuilder b/app/views/courses/settings.json.jbuilder index be4470a66..97083d5f9 100644 --- a/app/views/courses/settings.json.jbuilder +++ b/app/views/courses/settings.json.jbuilder @@ -5,6 +5,7 @@ json.course_id @course.id json.school @course.school&.name json.class_period @course.class_period json.credit @course.credit +json.start_date @course.start_date json.end_date @course.end_date json.is_public @course.is_public json.course_module_types @course.course_modules.where(hidden: 0).pluck(:module_type) From fd65a24d5df48c2822fa1cb732ccd36dc5af47b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 16 Aug 2019 18:12:06 +0800 Subject: [PATCH 063/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/coursesDetail/CoursesLeftNav.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js index b28472f66..20f46f079 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js @@ -722,15 +722,19 @@ class Coursesleftnav extends Component{ let {url}=this.state; if (key === this.props.indexs) { this.props.unlocationNavfun(undefined) + this.props.history.replace(urls); } else { this.props.unlocationNavfun(key) + this.props.history.replace(urls); } if(urls!=url){ this.props.history.replace(urls); } - if(this.props.indexs===undefined){ - this.props.history.replace(urls); - } + // if(this.props.indexs===undefined){ + // + // }else{ + // + // } } maincontent=(item,key)=>{ From 852e2931b3f23ca76ee689ea56755e662f9ef2bf Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 18:27:22 +0800 Subject: [PATCH 064/100] =?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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 106ba3dd4..aaf24eadb 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1129,7 +1129,7 @@ class CoursesController < ApplicationController def validate_course_name tip_exception("课堂名称不能为空!") if params[:course][:name].blank? - if params[:subject_id].blank? || (@course && @course.subject.blank?) + if params[:subject_id].blank? && @course.blank? || (@course && @course.subject.blank?) tip_exception("课程名称不能为空!") if params[:course_list_name].blank? tip_exception("课堂名称应以课程名称开头命名") unless params[:course][:name].index(params[:course_list_name]) && params[:course][:name].index(params[:course_list_name]) == 0 From 961fa1ade5c7175da8bfb9b951fe6de6f314d381 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 18:28:42 +0800 Subject: [PATCH 065/100] =?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/models/homework_common.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 112fc523b..f198a7143 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -36,7 +36,7 @@ class HomeworkCommon < ApplicationRecord validates :name, length: { maximum: 60 } validates :description, length: { maximum: 15000 } - validates :reference_answer, length: { maximum: 5000 } + validates :reference_answer, length: { maximum: 15000 } # after_update :update_activity before_destroy :update_homework_bank_quotes From 905f9c040e3f3035b8c368235a3b229919bd2664 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 19:04:05 +0800 Subject: [PATCH 066/100] =?UTF-8?q?=E8=B5=84=E6=BA=90=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/attachment_histories/_attachment_history.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/attachment_histories/_attachment_history.json.jbuilder b/app/views/attachment_histories/_attachment_history.json.jbuilder index afb359e08..285aced42 100644 --- a/app/views/attachment_histories/_attachment_history.json.jbuilder +++ b/app/views/attachment_histories/_attachment_history.json.jbuilder @@ -8,3 +8,4 @@ json.downloads_count attachment.downloads_count json.created_on attachment.created_on json.url attachment_path(attachment, type: 'history').gsub("/api","") json.is_pdf attachment.is_history_pdf? +json.attachment_id attachment.attachment_id From efb1be8abe54174a317c10b38c0ee90e3bc7d605 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 19:08:01 +0800 Subject: [PATCH 067/100] =?UTF-8?q?=E8=B5=84=E6=BA=90=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../attachment_histories/_attachment_history.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/attachment_histories/_attachment_history.json.jbuilder b/app/views/attachment_histories/_attachment_history.json.jbuilder index 285aced42..790bc9f2d 100644 --- a/app/views/attachment_histories/_attachment_history.json.jbuilder +++ b/app/views/attachment_histories/_attachment_history.json.jbuilder @@ -6,6 +6,6 @@ json.publish_time attachment.publish_time json.quotes attachment.quotes_count json.downloads_count attachment.downloads_count json.created_on attachment.created_on -json.url attachment_path(attachment, type: 'history').gsub("/api","") +json.url download_url(attachment.attachment) json.is_pdf attachment.is_history_pdf? json.attachment_id attachment.attachment_id From b41d127635a981f2b2d9148584f0f60dfeba408a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 19:13:18 +0800 Subject: [PATCH 068/100] =?UTF-8?q?=E8=B5=84=E6=BA=90=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../attachment_histories/_attachment_history.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/attachment_histories/_attachment_history.json.jbuilder b/app/views/attachment_histories/_attachment_history.json.jbuilder index 790bc9f2d..285aced42 100644 --- a/app/views/attachment_histories/_attachment_history.json.jbuilder +++ b/app/views/attachment_histories/_attachment_history.json.jbuilder @@ -6,6 +6,6 @@ json.publish_time attachment.publish_time json.quotes attachment.quotes_count json.downloads_count attachment.downloads_count json.created_on attachment.created_on -json.url download_url(attachment.attachment) +json.url attachment_path(attachment, type: 'history').gsub("/api","") json.is_pdf attachment.is_history_pdf? json.attachment_id attachment.attachment_id From 93eac23c58ffb58ea35c1b39d2af8ba617b8ca95 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 16 Aug 2019 19:17:48 +0800 Subject: [PATCH 069/100] =?UTF-8?q?=E8=B5=84=E6=BA=90=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 44 ++++++++++++----------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index a6c74818c..a85937315 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -162,28 +162,30 @@ class AttachmentsController < ApplicationController def attachment_candown unless current_user.admin? || current_user.business? candown = true - if @file.container && current_user.logged? - # 课堂资源、作业、毕设相关资源的权限判断 - if @file.container.is_a?(Course) - course = @file.container - candown = current_user.member_of_course?(course) || @file.is_public == 1 - elsif @file.container.is_a?(HomeworkCommon) || @file.container.is_a?(GraduationTask) || @file.container.is_a?(GraduationTopic) - course = @file.container&.course - candown = current_user.member_of_course?(course) - elsif @file.container.is_a?(StudentWork) - course = @file.container&.homework_common&.course - candown = current_user.member_of_course?(course) - elsif @file.container.is_a?(StudentWorksScore) - course = @file.container&.student_work&.homework_common&.course - candown = current_user.member_of_course?(course) - elsif @file.container.is_a?(GraduationWork) - course = @file.container&.graduation_task&.course - candown = current_user.member_of_course?(course) - elsif @file.container.is_a?(GraduationWorkScore) - course = @file.container&.graduation_work&.graduation_task&.course - candown = current_user.member_of_course?(course) + unless params[:type] == 'history' + if @file.container && current_user.logged? + # 课堂资源、作业、毕设相关资源的权限判断 + if @file.container.is_a?(Course) + course = @file.container + candown = current_user.member_of_course?(course) || @file.is_public == 1 + elsif @file.container.is_a?(HomeworkCommon) || @file.container.is_a?(GraduationTask) || @file.container.is_a?(GraduationTopic) + course = @file.container&.course + candown = current_user.member_of_course?(course) + elsif @file.container.is_a?(StudentWork) + course = @file.container&.homework_common&.course + candown = current_user.member_of_course?(course) + elsif @file.container.is_a?(StudentWorksScore) + course = @file.container&.student_work&.homework_common&.course + candown = current_user.member_of_course?(course) + elsif @file.container.is_a?(GraduationWork) + course = @file.container&.graduation_task&.course + candown = current_user.member_of_course?(course) + elsif @file.container.is_a?(GraduationWorkScore) + course = @file.container&.graduation_work&.graduation_task&.course + candown = current_user.member_of_course?(course) + end + tip_exception(403, "您没有权限进入") if course.present? && !candown end - tip_exception(403, "您没有权限进入") if course.present? && !candown end end end From f9b8af0d617775ab1ad6c5f61e3d480357af9ef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 17 Aug 2019 09:33:29 +0800 Subject: [PATCH 070/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Resource/Fileslistitem.js | 4 ++-- .../react/src/modules/courses/coursesPublic/Showoldfiles.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 563724040..b65297884 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -42,7 +42,7 @@ class Fileslistitem extends Component{ //预览pdf axios({ method:'get', - url:result.data.url, + url:"http:"+window.location.host+result.data.url, responseType: 'arraybuffer', }).then((result)=>{ var binaryData = []; @@ -53,7 +53,7 @@ class Fileslistitem extends Component{ }else{ let link = document.createElement('a'); document.body.appendChild(link); - link.href = "/api"+result.data.url; + link.href = result.data.url; link.download = result.data.title; //兼容火狐浏览器 let evt = document.createEvent("MouseEvents"); diff --git a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js index 483768271..2c682ec19 100644 --- a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js +++ b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js @@ -45,7 +45,7 @@ class Showoldfiles extends Component{ showfiless=(url)=>{ axios({ method:'get', - url:url, + url:"http:"+window.location.host+url, responseType: 'arraybuffer', }).then((result)=>{ var binaryData = []; @@ -188,7 +188,7 @@ class Showoldfiles extends Component{
  • {allfiles.is_pdf===false? - {allfiles.title}: + {allfiles.title}: this.showfiless(allfiles.url)} >{allfiles.title} } 当前版本 @@ -208,7 +208,7 @@ class Showoldfiles extends Component{
  • {item.is_pdf===false? - {item.title}: + {item.title}: this.showfiless(item.url)} >{item.title} }
  • From 0746014dbaafc72920d41310030f0bad11eac6d2 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 17 Aug 2019 09:34:06 +0800 Subject: [PATCH 071/100] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=92=8C=E5=85=B6=E4=BB=96=E9=99=84=E4=BB=B6=E7=9A=84=E9=A2=84?= =?UTF-8?q?=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 2 +- app/views/files/histories.json.jbuilder | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e6f2e1720..099d45406 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -258,7 +258,7 @@ module ApplicationHelper end def download_url attachment - attachment_path(attachment).gsub("/api","") + attachment_path(attachment) end # 耗时:天、小时、分、秒 diff --git a/app/views/files/histories.json.jbuilder b/app/views/files/histories.json.jbuilder index 7039752e7..ed322bb17 100644 --- a/app/views/files/histories.json.jbuilder +++ b/app/views/files/histories.json.jbuilder @@ -1,3 +1,9 @@ -json.partial! 'attachments/attachment_small', attachment: @file +# json.partial! 'attachments/attachment_small', attachment: @file +json.id @file.id +json.title @file.title +json.filesize number_to_human_size(@file.filesize) +json.url download_url(@file).gsub("/api","") +json.created_on @file.created_on +json.is_pdf @file.is_pdf? json.partial! "attachment_histories/list", attachment_histories: @attachment_histories From 05b09597defc1f612470bacd7b380f8ecd668677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 17 Aug 2019 09:39:16 +0800 Subject: [PATCH 072/100] 1 --- public/react/src/modules/courses/Resource/Fileslistitem.js | 4 ++-- .../react/src/modules/courses/coursesPublic/Showoldfiles.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index b65297884..563724040 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -42,7 +42,7 @@ class Fileslistitem extends Component{ //预览pdf axios({ method:'get', - url:"http:"+window.location.host+result.data.url, + url:result.data.url, responseType: 'arraybuffer', }).then((result)=>{ var binaryData = []; @@ -53,7 +53,7 @@ class Fileslistitem extends Component{ }else{ let link = document.createElement('a'); document.body.appendChild(link); - link.href = result.data.url; + link.href = "/api"+result.data.url; link.download = result.data.title; //兼容火狐浏览器 let evt = document.createEvent("MouseEvents"); diff --git a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js index 2c682ec19..483768271 100644 --- a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js +++ b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js @@ -45,7 +45,7 @@ class Showoldfiles extends Component{ showfiless=(url)=>{ axios({ method:'get', - url:"http:"+window.location.host+url, + url:url, responseType: 'arraybuffer', }).then((result)=>{ var binaryData = []; @@ -188,7 +188,7 @@ class Showoldfiles extends Component{
  • {allfiles.is_pdf===false? - {allfiles.title}: + {allfiles.title}: this.showfiless(allfiles.url)} >{allfiles.title} } 当前版本 @@ -208,7 +208,7 @@ class Showoldfiles extends Component{
  • {item.is_pdf===false? - {item.title}: + {item.title}: this.showfiless(item.url)} >{item.title} }
  • From 5c76f32eece9e4f5778afa57462c9123bdee63e0 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 17 Aug 2019 09:53:50 +0800 Subject: [PATCH 073/100] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=94=B9=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/duplicate_course_service.rb | 2 +- app/views/files/index.json.jbuilder | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/services/duplicate_course_service.rb b/app/services/duplicate_course_service.rb index 27ae2f784..acff0a726 100644 --- a/app/services/duplicate_course_service.rb +++ b/app/services/duplicate_course_service.rb @@ -11,7 +11,7 @@ class DuplicateCourseService < ApplicationService @course = copy_course! copy_course_modules! - Rails.logger.info("###########second_category_list#{@second_category_list}") + join_course! copy_homework_commons! diff --git a/app/views/files/index.json.jbuilder b/app/views/files/index.json.jbuilder index 81fa406dd..7fe3bf5b7 100644 --- a/app/views/files/index.json.jbuilder +++ b/app/views/files/index.json.jbuilder @@ -8,6 +8,7 @@ json.data do json.course_is_public @course.is_public? json.files do json.array! @attachments do |attachment| + json.is_history_file attachment.attachment_histories.count > 0 #是否有历史文件 json.partial! "attachments/attachment", attachment: attachment json.author do json.partial! "users/user_simple", user: attachment.author From f7bdccda099bbc1c9b61eef88bf9a980f38bf0a0 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 17 Aug 2019 10:41:20 +0800 Subject: [PATCH 074/100] =?UTF-8?q?time=5Flimit=20+=205=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/page/Index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/page/Index.js b/public/react/src/modules/page/Index.js index 1513405b0..3a273e0d6 100644 --- a/public/react/src/modules/page/Index.js +++ b/public/react/src/modules/page/Index.js @@ -242,7 +242,7 @@ class Index extends Component { updateChallengePath={context.updateChallengePath} - time_limit={context.time_limit} + time_limit={context.time_limit + 5} resetTestSetsExpandedArray={context.resetTestSetsExpandedArray} onRunCodeTestFinish={context.onRunCodeTestFinish} From 945001cb37ec74edf52980e4a34ae96dcfb82b69 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 17 Aug 2019 10:42:47 +0800 Subject: [PATCH 075/100] =?UTF-8?q?attachment.json.jbuilder=E7=9A=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/attachments/_attachment.json.jbuilder | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/attachments/_attachment.json.jbuilder b/app/views/attachments/_attachment.json.jbuilder index 01a7f4163..b87154157 100644 --- a/app/views/attachments/_attachment.json.jbuilder +++ b/app/views/attachments/_attachment.json.jbuilder @@ -1,7 +1,8 @@ json.id attachment.id json.title attachment.title json.is_public attachment.publiced? -json.is_lock attachment.locked?(@is_member) +# json.is_lock attachment.locked?(@is_member) +json.is_lock !attachment.publiced? json.is_publish attachment.published? json.publish_time attachment.publish_time json.unified_setting attachment.unified_setting @@ -10,4 +11,6 @@ json.quotes attachment.quotes_count json.description attachment.description json.downloads_count attachment.downloads_count json.created_on attachment.created_on -json.url download_url(attachment) unless attachment.locked?(@is_member) +json.url download_url(attachment) + +# json.url download_url(attachment) unless attachment.locked?(@is_member) From c37492dc751e02e6a58d4800c6a5cf6d505eb00b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 17 Aug 2019 11:21:52 +0800 Subject: [PATCH 076/100] =?UTF-8?q?=E5=B0=81=E8=A3=85showpdf=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/Resource/Fileslistitem.js | 21 ++++++++++--------- .../courses/coursesPublic/Showoldfiles.js | 21 ++++++++++--------- public/react/src/modules/tpm/TPMIndexHOC.js | 15 ++++++++++++- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 563724040..58305f589 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -39,17 +39,18 @@ class Fileslistitem extends Component{ if(result.data.attachment_histories.length===0){ if(result.data.is_pdf===true){ + this.props.ShowOnlinePdf(result.data.url) //预览pdf - axios({ - method:'get', - url:result.data.url, - responseType: 'arraybuffer', - }).then((result)=>{ - var binaryData = []; - binaryData.push(result.data); - this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); - window.open(this.url); - }) + // axios({ + // method:'get', + // url:result.data.url, + // responseType: 'arraybuffer', + // }).then((result)=>{ + // var binaryData = []; + // binaryData.push(result.data); + // this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); + // window.open(this.url); + // }) }else{ let link = document.createElement('a'); document.body.appendChild(link); diff --git a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js index 483768271..1b2b89565 100644 --- a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js +++ b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js @@ -43,16 +43,17 @@ class Showoldfiles extends Component{ } showfiless=(url)=>{ - axios({ - method:'get', - url:url, - responseType: 'arraybuffer', - }).then((result)=>{ - var binaryData = []; - binaryData.push(result.data); - this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); - window.open(this.url); - }) + // axios({ + // method:'get', + // url:url, + // responseType: 'arraybuffer', + // }).then((result)=>{ + // var binaryData = []; + // binaryData.push(result.data); + // this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); + // window.open(this.url); + // }) + this.props.ShowOnlinePdf(url) } render(){ let {visible,allfiles}=this.props; diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js index f87f128a1..690e8bc80 100644 --- a/public/react/src/modules/tpm/TPMIndexHOC.js +++ b/public/react/src/modules/tpm/TPMIndexHOC.js @@ -321,6 +321,19 @@ export function TPMIndexHOC(WrappedComponent) { checkIfProfileCompleted = () => { return this.state.current_user && this.state.current_user.profile_completed } + + ShowOnlinePdf = (url) => { + return axios({ + method:'get', + url:url, + responseType: 'arraybuffer', + }).then((result)=>{ + var binaryData = []; + binaryData.push(result.data); + this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); + window.open(this.url); + }) + } render() { let{Headertop,Footerdown, isRender, AccountProfiletype}=this.state; const common = { @@ -334,11 +347,11 @@ export function TPMIndexHOC(WrappedComponent) { isNotMember: this.isNotMember, isUserid:this.state.coursedata&&this.state.coursedata.userid, fetchUser: this.fetchUser, - showLoginDialog: this.showLoginDialog, checkIfLogin: this.checkIfLogin, showProfileCompleteDialog: this.showProfileCompleteDialog, checkIfProfileCompleted: this.checkIfProfileCompleted, + ShowOnlinePdf:(url)=>this.ShowOnlinePdf(url) } return (
    From 9a0c4fa20b0c4082e5d995a5a783da4ae71c2319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 17 Aug 2019 11:25:43 +0800 Subject: [PATCH 077/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Resource/Fileslistitem.js | 2 +- .../react/src/modules/courses/coursesPublic/Showoldfiles.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 58305f589..706622570 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -54,7 +54,7 @@ class Fileslistitem extends Component{ }else{ let link = document.createElement('a'); document.body.appendChild(link); - link.href = "/api"+result.data.url; + link.href =result.data.url; link.download = result.data.title; //兼容火狐浏览器 let evt = document.createEvent("MouseEvents"); diff --git a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js index 1b2b89565..6b56702c3 100644 --- a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js +++ b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js @@ -189,7 +189,7 @@ class Showoldfiles extends Component{
  • {allfiles.is_pdf===false? - {allfiles.title}: + {allfiles.title}: this.showfiless(allfiles.url)} >{allfiles.title} } 当前版本 @@ -209,7 +209,7 @@ class Showoldfiles extends Component{
  • {item.is_pdf===false? - {item.title}: + {item.title}: this.showfiless(item.url)} >{item.title} }
  • From b262d98873d4b4d10dca80fef0c3554e6214f716 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 17 Aug 2019 11:25:47 +0800 Subject: [PATCH 078/100] =?UTF-8?q?=E9=99=84=E4=BB=B6=E4=B8=BApdf=E7=9A=84?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A4=E6=96=AD=EF=BC=8C=E5=B9=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_attachment_history.json.jbuilder | 3 ++- app/views/attachments/_attachment.json.jbuilder | 3 ++- app/views/attachments/_attachment_simple.json.jbuilder | 4 +++- app/views/attachments/_attachment_small.json.jbuilder | 4 ++-- app/views/files/histories.json.jbuilder | 8 +------- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/views/attachment_histories/_attachment_history.json.jbuilder b/app/views/attachment_histories/_attachment_history.json.jbuilder index 285aced42..6a02b569b 100644 --- a/app/views/attachment_histories/_attachment_history.json.jbuilder +++ b/app/views/attachment_histories/_attachment_history.json.jbuilder @@ -6,6 +6,7 @@ json.publish_time attachment.publish_time json.quotes attachment.quotes_count json.downloads_count attachment.downloads_count json.created_on attachment.created_on -json.url attachment_path(attachment, type: 'history').gsub("/api","") +# json.url attachment_path(attachment, type: 'history').gsub("/api","") json.is_pdf attachment.is_history_pdf? +json.url attachment.is_history_pdf? ? attachment_path(attachment, type: 'history').gsub("/api","") : attachment_path(attachment, type: 'history') json.attachment_id attachment.attachment_id diff --git a/app/views/attachments/_attachment.json.jbuilder b/app/views/attachments/_attachment.json.jbuilder index b87154157..76b9f2df0 100644 --- a/app/views/attachments/_attachment.json.jbuilder +++ b/app/views/attachments/_attachment.json.jbuilder @@ -11,6 +11,7 @@ json.quotes attachment.quotes_count json.description attachment.description json.downloads_count attachment.downloads_count json.created_on attachment.created_on -json.url download_url(attachment) +json.is_pdf attachment.is_pdf? +json.url attachment.is_pdf? ? download_url(attachment).gsub("/api","") : download_url(attachment) # json.url download_url(attachment) unless attachment.locked?(@is_member) diff --git a/app/views/attachments/_attachment_simple.json.jbuilder b/app/views/attachments/_attachment_simple.json.jbuilder index ad98fadb5..4bf6bd3e9 100644 --- a/app/views/attachments/_attachment_simple.json.jbuilder +++ b/app/views/attachments/_attachment_simple.json.jbuilder @@ -2,5 +2,7 @@ json.id attachment.id json.title attachment.title json.filesize number_to_human_size attachment.filesize json.description attachment.description -json.url download_url(attachment) +json.is_pdf attachment.is_pdf? +json.url attachment.is_pdf? ? download_url(attachment).gsub("/api","") : download_url(attachment) +# json.url download_url(attachment) json.set! :delete, delete.nil? ? true : delete if defined? delete \ No newline at end of file diff --git a/app/views/attachments/_attachment_small.json.jbuilder b/app/views/attachments/_attachment_small.json.jbuilder index 97cbee120..5a1faae3a 100644 --- a/app/views/attachments/_attachment_small.json.jbuilder +++ b/app/views/attachments/_attachment_small.json.jbuilder @@ -1,6 +1,6 @@ json.id attachment.id json.title attachment.title json.filesize number_to_human_size(attachment.filesize) -json.url download_url(attachment) +json.is_pdf attachment.is_pdf? +json.url attachment.is_pdf? ? download_url(attachment).gsub("/api","") : download_url(attachment) json.created_on attachment.created_on -json.is_pdf attachment.is_pdf? \ No newline at end of file diff --git a/app/views/files/histories.json.jbuilder b/app/views/files/histories.json.jbuilder index ed322bb17..7039752e7 100644 --- a/app/views/files/histories.json.jbuilder +++ b/app/views/files/histories.json.jbuilder @@ -1,9 +1,3 @@ -# json.partial! 'attachments/attachment_small', attachment: @file -json.id @file.id -json.title @file.title -json.filesize number_to_human_size(@file.filesize) -json.url download_url(@file).gsub("/api","") -json.created_on @file.created_on -json.is_pdf @file.is_pdf? +json.partial! 'attachments/attachment_small', attachment: @file json.partial! "attachment_histories/list", attachment_histories: @attachment_histories From b9de46e875b1cba52d559aacc3af18a5d0053818 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 17 Aug 2019 12:34:12 +0800 Subject: [PATCH 079/100] =?UTF-8?q?=E9=99=84=E4=BB=B6=E7=9A=84pdf=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E6=B7=BB=E5=8A=A0inline=E8=AF=B7=E6=B1=82=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 4 +++- app/helpers/application_helper.rb | 4 ++-- .../attachment_histories/_attachment_history.json.jbuilder | 2 +- app/views/attachments/_attachment.json.jbuilder | 2 +- app/views/attachments/_attachment_simple.json.jbuilder | 2 +- app/views/attachments/_attachment_small.json.jbuilder | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index a85937315..6202bf86d 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -15,7 +15,9 @@ class AttachmentsController < ApplicationController update_downloads(@file) redirect_to @file.cloud_url and return end - send_file(absolute_path(local_path(@file)), filename: @file.filename, type: @file.content_type.presence || 'application/octet-stream') + + pdf_attachment = params[:disposition] || "attachment" + send_file(absolute_path(local_path(@file)), filename: @file.filename,disposition: pdf_attachment, type: @file.content_type.presence || 'application/octet-stream') update_downloads(@file) end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 099d45406..a5f291c7b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -257,8 +257,8 @@ module ApplicationHelper end end - def download_url attachment - attachment_path(attachment) + def download_url attachment,options={} + attachment_path(attachment,options) end # 耗时:天、小时、分、秒 diff --git a/app/views/attachment_histories/_attachment_history.json.jbuilder b/app/views/attachment_histories/_attachment_history.json.jbuilder index 6a02b569b..a2369888f 100644 --- a/app/views/attachment_histories/_attachment_history.json.jbuilder +++ b/app/views/attachment_histories/_attachment_history.json.jbuilder @@ -8,5 +8,5 @@ json.downloads_count attachment.downloads_count json.created_on attachment.created_on # json.url attachment_path(attachment, type: 'history').gsub("/api","") json.is_pdf attachment.is_history_pdf? -json.url attachment.is_history_pdf? ? attachment_path(attachment, type: 'history').gsub("/api","") : attachment_path(attachment, type: 'history') +json.url attachment.is_history_pdf? ? attachment_path(attachment, type: 'history',disposition:"inline") : attachment_path(attachment, type: 'history') json.attachment_id attachment.attachment_id diff --git a/app/views/attachments/_attachment.json.jbuilder b/app/views/attachments/_attachment.json.jbuilder index 76b9f2df0..25d7aecd0 100644 --- a/app/views/attachments/_attachment.json.jbuilder +++ b/app/views/attachments/_attachment.json.jbuilder @@ -12,6 +12,6 @@ json.description attachment.description json.downloads_count attachment.downloads_count json.created_on attachment.created_on json.is_pdf attachment.is_pdf? -json.url attachment.is_pdf? ? download_url(attachment).gsub("/api","") : download_url(attachment) +json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment) # json.url download_url(attachment) unless attachment.locked?(@is_member) diff --git a/app/views/attachments/_attachment_simple.json.jbuilder b/app/views/attachments/_attachment_simple.json.jbuilder index 4bf6bd3e9..6737838d1 100644 --- a/app/views/attachments/_attachment_simple.json.jbuilder +++ b/app/views/attachments/_attachment_simple.json.jbuilder @@ -3,6 +3,6 @@ json.title attachment.title json.filesize number_to_human_size attachment.filesize json.description attachment.description json.is_pdf attachment.is_pdf? -json.url attachment.is_pdf? ? download_url(attachment).gsub("/api","") : download_url(attachment) +json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment) # json.url download_url(attachment) json.set! :delete, delete.nil? ? true : delete if defined? delete \ No newline at end of file diff --git a/app/views/attachments/_attachment_small.json.jbuilder b/app/views/attachments/_attachment_small.json.jbuilder index 5a1faae3a..853c14b40 100644 --- a/app/views/attachments/_attachment_small.json.jbuilder +++ b/app/views/attachments/_attachment_small.json.jbuilder @@ -2,5 +2,5 @@ json.id attachment.id json.title attachment.title json.filesize number_to_human_size(attachment.filesize) json.is_pdf attachment.is_pdf? -json.url attachment.is_pdf? ? download_url(attachment).gsub("/api","") : download_url(attachment) +json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment) json.created_on attachment.created_on From 8af97d5655de723f1a2992e8bf7e75ebec49c17b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 17 Aug 2019 13:43:10 +0800 Subject: [PATCH 080/100] =?UTF-8?q?pdf=E7=9A=84=E9=A2=84=E8=A7=88=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0disposition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 6202bf86d..dde7828c5 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -17,8 +17,11 @@ class AttachmentsController < ApplicationController end pdf_attachment = params[:disposition] || "attachment" - send_file(absolute_path(local_path(@file)), filename: @file.filename,disposition: pdf_attachment, type: @file.content_type.presence || 'application/octet-stream') - + if pdf_attachment == "inline" + render pdf: absolute_path(local_path(@file)), filename: @file.filename, disposition: 'inline', type: @file.content_type.presence || 'application/octet-stream' + else + send_file(absolute_path(local_path(@file)), filename: @file.filename,stream:false, type: @file.content_type.presence || 'application/octet-stream') + end update_downloads(@file) end From 5493ca53304d4cf1963c35cee5bdf6103d7596a0 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 17 Aug 2019 13:48:00 +0800 Subject: [PATCH 081/100] =?UTF-8?q?=E6=8E=A8=E8=8D=90=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 3 ++- app/views/attachments/_attachment.json.jbuilder | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 099d45406..142ca6d75 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -52,7 +52,8 @@ module ApplicationHelper shixun_id = shixun_id.blank? ? -1 : shixun_id.join(",") Shixun.select([:id, :name, :user_id, :challenges_count, :myshixuns_count, :trainee, :identifier]).where("id - in(#{shixun_id}) or homepage_show =1").unhidden.order("myshixuns_count desc, homepage_show asc").limit(3) + in(#{shixun_id})").unhidden.order("homepage_show asc, myshixuns_count desc").limit(3) + end # 相关推荐 diff --git a/app/views/attachments/_attachment.json.jbuilder b/app/views/attachments/_attachment.json.jbuilder index 01a7f4163..52f16c549 100644 --- a/app/views/attachments/_attachment.json.jbuilder +++ b/app/views/attachments/_attachment.json.jbuilder @@ -10,4 +10,4 @@ json.quotes attachment.quotes_count json.description attachment.description json.downloads_count attachment.downloads_count json.created_on attachment.created_on -json.url download_url(attachment) unless attachment.locked?(@is_member) +json.url download_url(attachment) From 8f453c4ebdc785e376e4a7f90a10cbcbaba5b329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 17 Aug 2019 13:48:01 +0800 Subject: [PATCH 082/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/Resource/Fileslistitem.js | 35 +++++-------------- .../courses/coursesPublic/Showoldfiles.js | 29 ++++++--------- public/react/src/modules/tpm/TPMIndexHOC.js | 14 +++++++- 3 files changed, 31 insertions(+), 47 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 706622570..5f7c0fa83 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -38,30 +38,13 @@ class Fileslistitem extends Component{ }).then((result)=>{ if(result.data.attachment_histories.length===0){ - if(result.data.is_pdf===true){ - this.props.ShowOnlinePdf(result.data.url) - //预览pdf - // axios({ - // method:'get', - // url:result.data.url, - // responseType: 'arraybuffer', - // }).then((result)=>{ - // var binaryData = []; - // binaryData.push(result.data); - // this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); - // window.open(this.url); - // }) - }else{ - let link = document.createElement('a'); - document.body.appendChild(link); - link.href =result.data.url; - link.download = result.data.title; - //兼容火狐浏览器 - let evt = document.createEvent("MouseEvents"); - evt.initEvent("click", false, false); - link.dispatchEvent(evt); - document.body.removeChild(link); - } + // if(result.data.is_pdf===true){ + // this.props.ShowOnlinePdf(result.data.url) + // //预览pdf + // }else{ + // + // } + this.props.DownloadFileA(result.data.title,result.data.url) }else{ this.setState({ Showoldfiles:true, @@ -146,9 +129,7 @@ class Fileslistitem extends Component{ const { checkBox, discussMessage, } = this.props; - - - + return(
    diff --git a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js index 6b56702c3..693e3448b 100644 --- a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js +++ b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js @@ -43,16 +43,6 @@ class Showoldfiles extends Component{ } showfiless=(url)=>{ - // axios({ - // method:'get', - // url:url, - // responseType: 'arraybuffer', - // }).then((result)=>{ - // var binaryData = []; - // binaryData.push(result.data); - // this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); - // window.open(this.url); - // }) this.props.ShowOnlinePdf(url) } render(){ @@ -188,10 +178,11 @@ class Showoldfiles extends Component{
  • - {allfiles.is_pdf===false? - {allfiles.title}: - this.showfiless(allfiles.url)} >{allfiles.title} - } + {allfiles.title} + {/*{allfiles.is_pdf===false?*/} + {/*{allfiles.title}:*/} + {/*this.showfiless(allfiles.url)} >{allfiles.title}*/} + {/*}*/} 当前版本
  • @@ -207,11 +198,11 @@ class Showoldfiles extends Component{
  • - - {item.is_pdf===false? - {item.title}: - this.showfiless(item.url)} >{item.title} - } + {item.title} + {/*{item.is_pdf===false?*/} + {/*{item.title}:*/} + {/*this.showfiless(item.url)} >{item.title}*/} + {/*}*/}
  • diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js index 690e8bc80..682e8f866 100644 --- a/public/react/src/modules/tpm/TPMIndexHOC.js +++ b/public/react/src/modules/tpm/TPMIndexHOC.js @@ -334,6 +334,17 @@ export function TPMIndexHOC(WrappedComponent) { window.open(this.url); }) } + DownloadFileA=(title,url)=>{ + let link = document.createElement('a'); + document.body.appendChild(link); + link.href =url; + link.download = title; + //兼容火狐浏览器 + let evt = document.createEvent("MouseEvents"); + evt.initEvent("click", false, false); + link.dispatchEvent(evt); + document.body.removeChild(link); + } render() { let{Headertop,Footerdown, isRender, AccountProfiletype}=this.state; const common = { @@ -351,7 +362,8 @@ export function TPMIndexHOC(WrappedComponent) { checkIfLogin: this.checkIfLogin, showProfileCompleteDialog: this.showProfileCompleteDialog, checkIfProfileCompleted: this.checkIfProfileCompleted, - ShowOnlinePdf:(url)=>this.ShowOnlinePdf(url) + ShowOnlinePdf:(url)=>this.ShowOnlinePdf(url), + DownloadFileA:(title,url)=>this.DownloadFileA(title,url), } return (
    From b094010ad11c5424eebee3395c238a129d947685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 17 Aug 2019 13:51:10 +0800 Subject: [PATCH 083/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Resource/Fileslistitem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 5f7c0fa83..d3405ebf5 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -129,7 +129,7 @@ class Fileslistitem extends Component{ const { checkBox, discussMessage, } = this.props; - + return(
    From e8dcb166756861f64edd9f5a487d60eb1b804bcd Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 17 Aug 2019 13:56:14 +0800 Subject: [PATCH 084/100] =?UTF-8?q?pdf=20=E9=A2=84=E8=A7=88=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index dde7828c5..7617270a8 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -18,7 +18,8 @@ class AttachmentsController < ApplicationController pdf_attachment = params[:disposition] || "attachment" if pdf_attachment == "inline" - render pdf: absolute_path(local_path(@file)), filename: @file.filename, disposition: 'inline', type: @file.content_type.presence || 'application/octet-stream' + send_data absolute_path(local_path(@file)),filename: @file.filename, disposition: 'inline',type: 'application/pdf' + # render pdf: absolute_path(local_path(@file)), filename: @file.filename, disposition: 'inline', type: @file.content_type.presence || 'application/octet-stream' else send_file(absolute_path(local_path(@file)), filename: @file.filename,stream:false, type: @file.content_type.presence || 'application/octet-stream') end From 476689314bcec5f32665fcd412de3bba975d3ed1 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 17 Aug 2019 14:00:18 +0800 Subject: [PATCH 085/100] xxx --- app/controllers/attachments_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 7617270a8..d3317e99e 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -18,8 +18,7 @@ class AttachmentsController < ApplicationController pdf_attachment = params[:disposition] || "attachment" if pdf_attachment == "inline" - send_data absolute_path(local_path(@file)),filename: @file.filename, disposition: 'inline',type: 'application/pdf' - # render pdf: absolute_path(local_path(@file)), filename: @file.filename, disposition: 'inline', type: @file.content_type.presence || 'application/octet-stream' + send_file absolute_path(local_path(@file)),filename: @file.filename, disposition: 'inline',type: 'application/pdf' else send_file(absolute_path(local_path(@file)), filename: @file.filename,stream:false, type: @file.content_type.presence || 'application/octet-stream') end From 3c1d30a133a7e56090612b7473e1e613ed720622 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 17 Aug 2019 14:03:18 +0800 Subject: [PATCH 086/100] video feature: add account check to api --- app/controllers/users/video_auths_controller.rb | 2 +- app/controllers/users/videos_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/users/video_auths_controller.rb b/app/controllers/users/video_auths_controller.rb index 0eec4dffb..a7d41bce5 100644 --- a/app/controllers/users/video_auths_controller.rb +++ b/app/controllers/users/video_auths_controller.rb @@ -1,5 +1,5 @@ class Users::VideoAuthsController < Users::BaseController - before_action :private_user_resources!, :require_auth_teacher! + before_action :private_user_resources!, :check_account, :require_auth_teacher! def create result = Videos::CreateAuthService.call(observed_user, create_params) diff --git a/app/controllers/users/videos_controller.rb b/app/controllers/users/videos_controller.rb index 1df726c0c..0ad3f87d6 100644 --- a/app/controllers/users/videos_controller.rb +++ b/app/controllers/users/videos_controller.rb @@ -1,5 +1,5 @@ class Users::VideosController < Users::BaseController - before_action :private_user_resources!, :require_auth_teacher! + before_action :private_user_resources!, :check_account, :require_auth_teacher! helper_method :current_video From e7a96f8ad10c931e23d9c1d6e7d692aa2d67e795 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 17 Aug 2019 14:12:55 +0800 Subject: [PATCH 087/100] sort --- public/react/src/common/TextUtil.js | 7 ++++++- public/react/src/common/educoder.js | 2 +- public/react/src/modules/courses/members/teacherList.js | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/public/react/src/common/TextUtil.js b/public/react/src/common/TextUtil.js index 4482f8607..4c83131f1 100644 --- a/public/react/src/common/TextUtil.js +++ b/public/react/src/common/TextUtil.js @@ -70,4 +70,9 @@ export function appendFileSizeToUploadFileAll(fileList) { return item }) } -export const uploadNameSizeSeperator = '  ' \ No newline at end of file +export const uploadNameSizeSeperator = '  ' + +export const sortDirections = ["ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", + "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", + "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", + "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", ] \ No newline at end of file diff --git a/public/react/src/common/educoder.js b/public/react/src/common/educoder.js index ca1596c54..88f8e1210 100644 --- a/public/react/src/common/educoder.js +++ b/public/react/src/common/educoder.js @@ -17,7 +17,7 @@ export { updatePageParams as updatePageParams } from './RouterUti export { bytesToSize as bytesToSize } from './UnitUtil'; export { markdownToHTML, uploadNameSizeSeperator, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll, isImageExtension, - downloadFile } from './TextUtil' + downloadFile, sortDirections } from './TextUtil' export { handleDateString, getNextHalfHourOfMoment,formatDuring } from './DateUtil' diff --git a/public/react/src/modules/courses/members/teacherList.js b/public/react/src/modules/courses/members/teacherList.js index c509cb057..06dbe74a8 100644 --- a/public/react/src/modules/courses/members/teacherList.js +++ b/public/react/src/modules/courses/members/teacherList.js @@ -8,7 +8,7 @@ import Titlesearchsection from '../common/titleSearch/TitleSearchSection' import ColorCountText from '../common/titleSearch/ColorCountText' import update from 'immutability-helper' -import { WordsBtn, ConditionToolTip, on, off ,trigger} from 'educoder' +import { WordsBtn, ConditionToolTip, on, off ,trigger, sortDirections } from 'educoder' import axios from 'axios' @@ -63,6 +63,7 @@ function buildColumns(that) { width: 120, key: 'name', sorter: showSorter, + sortDirections: sortDirections, sortOrder: sortedInfo.columnKey === 'name' && sortedInfo.order, render: (name, record) => { return Date: Sat, 17 Aug 2019 14:27:08 +0800 Subject: [PATCH 088/100] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/subjects/show.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/subjects/show.json.jbuilder b/app/views/subjects/show.json.jbuilder index 93fa105a6..ec76b5a2d 100644 --- a/app/views/subjects/show.json.jbuilder +++ b/app/views/subjects/show.json.jbuilder @@ -11,6 +11,7 @@ json.allow_statistics @is_manager json.allow_send @user.logged? json.allow_visit @subject.status > 1 || @is_manager json.allow_add_member @is_manager +json.is_creator @is_creator if @subject.excellent json.courses @courses do |course| From e17d636ba509c7ce06771ad0fbe057e90de2bf21 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 17 Aug 2019 14:29:17 +0800 Subject: [PATCH 089/100] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 2cd515261..449a86e8b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -268,7 +268,7 @@ class User < ApplicationRecord # 实训路径管理员 def creator_of_subject?(subject) - subject.user_id == id + subject.user_id == id || admin? end # 实训路径:合作者、admin From 0192c0c11f7df7248d5f8261bd7928ad97d5c046 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 17 Aug 2019 14:34:01 +0800 Subject: [PATCH 090/100] =?UTF-8?q?=E9=99=84=E4=BB=B6=E4=B8=8B=E8=BD=BD?= =?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/helpers/application_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e6f2e1720..099d45406 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -258,7 +258,7 @@ module ApplicationHelper end def download_url attachment - attachment_path(attachment).gsub("/api","") + attachment_path(attachment) end # 耗时:天、小时、分、秒 From 3f2cdc3ecef7cfa6d724951749fdeab8e3726aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 17 Aug 2019 14:39:27 +0800 Subject: [PATCH 091/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/Resource/Fileslistitem.js | 69 ++++++++++--------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index d3405ebf5..feae05740 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -27,35 +27,40 @@ class Fileslistitem extends Component{ this.props.Settingtypes(discussMessage.id) } - showfiles=(value)=>{ - let {discussMessage,coursesId}=this.props - let file_id=discussMessage.id - let url="/files/"+file_id+"/histories.json" - axios.get(url,{ - params:{ - course_id:coursesId - }, - }).then((result)=>{ - - if(result.data.attachment_histories.length===0){ - // if(result.data.is_pdf===true){ - // this.props.ShowOnlinePdf(result.data.url) - // //预览pdf - // }else{ - // - // } - this.props.DownloadFileA(result.data.title,result.data.url) - }else{ - this.setState({ - Showoldfiles:true, - allfiles:result.data - }) - } - - - }).catch((error)=>{ - console.log(error) - }) + showfiles=(list)=>{ + if(list.is_history_file===false){ + this.props.DownloadFileA(list.title,list.url) + }else{ + let {discussMessage,coursesId}=this.props + let file_id=discussMessage.id + let url="/files/"+file_id+"/histories.json" + axios.get(url,{ + params:{ + course_id:coursesId + }, + }).then((result)=>{ + + if(result.data.attachment_histories.length===0){ + // if(result.data.is_pdf===true){ + // this.props.ShowOnlinePdf(result.data.url) + // //预览pdf + // }else{ + // + // } + this.props.DownloadFileA(result.data.title,result.data.url) + }else{ + this.setState({ + Showoldfiles:true, + allfiles:result.data + }) + } + + + }).catch((error)=>{ + console.log(error) + }) + } + } closaoldfilesprops=()=>{ @@ -191,13 +196,13 @@ class Fileslistitem extends Component{ { this.props.isAdmin ? this.showfiles(discussMessage.title)} + onClick={()=>this.showfiles(discussMessage)} title={discussMessage.title} className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title} : "" } { this.props.isStudent? this.showfiles(discussMessage.title)} + onClick={()=>this.showfiles(discussMessage)} title={discussMessage.title} className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title} :"" } @@ -207,7 +212,7 @@ class Fileslistitem extends Component{ discussMessage.is_lock === true ? {discussMessage.title} :this.showfiles(discussMessage.title)} + onClick={()=>this.showfiles(discussMessage)} title={discussMessage.title} className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title}:"" } From f04ad3ed85de60358d57a062128cab31afec6fc6 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 17 Aug 2019 14:42:50 +0800 Subject: [PATCH 092/100] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/games/picture_display.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/games/picture_display.json.jbuilder b/app/views/games/picture_display.json.jbuilder index 770f0d71b..4c806d142 100644 --- a/app/views/games/picture_display.json.jbuilder +++ b/app/views/games/picture_display.json.jbuilder @@ -21,7 +21,7 @@ if @type == "image" elsif @type == "html" json.iframe_src File.read("#{@user_path}/#{@user_picture[0]}")&.html_safe elsif @type == "txt" - json.contents @contents.html_safe + json.contents @contents elsif @type =="qrcode" json.qrcode_str @qrcode_str elsif @type == "mp3" || @type == "mp4" From 989de0432f5059b9604d72a2b665863dd3a43c4b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 17 Aug 2019 14:49:18 +0800 Subject: [PATCH 093/100] =?UTF-8?q?txt=E8=AF=84=E6=B5=8B=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/games/picture_display.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/games/picture_display.json.jbuilder b/app/views/games/picture_display.json.jbuilder index 4c806d142..eb2309f9b 100644 --- a/app/views/games/picture_display.json.jbuilder +++ b/app/views/games/picture_display.json.jbuilder @@ -21,7 +21,7 @@ if @type == "image" elsif @type == "html" json.iframe_src File.read("#{@user_path}/#{@user_picture[0]}")&.html_safe elsif @type == "txt" - json.contents @contents + json.contents @contents.to_s elsif @type =="qrcode" json.qrcode_str @qrcode_str elsif @type == "mp3" || @type == "mp4" From fff396a35fac61eda63fa8f79476d5d704d47dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 17 Aug 2019 14:56:21 +0800 Subject: [PATCH 094/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Resource/Fileslistitem.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index feae05740..925bcc817 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -29,7 +29,8 @@ class Fileslistitem extends Component{ showfiles=(list)=>{ if(list.is_history_file===false){ - this.props.DownloadFileA(list.title,list.url) + // this.props.DownloadFileA(list.title,list.url) + window.location.href=list.url; }else{ let {discussMessage,coursesId}=this.props let file_id=discussMessage.id @@ -47,7 +48,8 @@ class Fileslistitem extends Component{ // }else{ // // } - this.props.DownloadFileA(result.data.title,result.data.url) + // this.props.DownloadFileA(result.data.title,result.data.url) + window.location.href=list.url; }else{ this.setState({ Showoldfiles:true, From 2f4e348049003779f99989d1bb33074ea95aa87a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 17 Aug 2019 15:01:20 +0800 Subject: [PATCH 095/100] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/excellent_course_exercise.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tasks/excellent_course_exercise.rake b/lib/tasks/excellent_course_exercise.rake index 07c33d9e9..964951003 100644 --- a/lib/tasks/excellent_course_exercise.rake +++ b/lib/tasks/excellent_course_exercise.rake @@ -45,8 +45,8 @@ namespace :excellent_course_exercise do end if exercise_user && exercise_user.commit_status == 0 - exercise_question_ids = exercise_question_ids.sample(rand_num) - questions = exercise.exercise_questions.where(id: exercise_question_ids) + question_ids = exercise_question_ids.sample(rand_num) + questions = exercise.exercise_questions.where(id: question_ids) create_exercise_answer questions, member.user_id total_score = calculate_student_score(exercise, member.user) From cddd7826864037268b5187da75917795f760aba1 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 17 Aug 2019 15:05:44 +0800 Subject: [PATCH 096/100] video feature: modify --- app/controllers/users/videos_controller.rb | 1 + app/views/users/get_user_info.json.jbuilder | 1 + 2 files changed, 2 insertions(+) diff --git a/app/controllers/users/videos_controller.rb b/app/controllers/users/videos_controller.rb index 0ad3f87d6..f04d4435d 100644 --- a/app/controllers/users/videos_controller.rb +++ b/app/controllers/users/videos_controller.rb @@ -1,5 +1,6 @@ class Users::VideosController < Users::BaseController before_action :private_user_resources!, :check_account, :require_auth_teacher! + skip_before_action :require_auth_teacher!, only: [:index] helper_method :current_video diff --git a/app/views/users/get_user_info.json.jbuilder b/app/views/users/get_user_info.json.jbuilder index 24f7b21b0..6189358ba 100644 --- a/app/views/users/get_user_info.json.jbuilder +++ b/app/views/users/get_user_info.json.jbuilder @@ -10,6 +10,7 @@ json.tidding_count 0 json.user_phone_binded @user.phone.present? json.phone @user.phone json.profile_completed @user.profile_completed? +json.professional_certification @user.professional_certification if @course json.course_identity @course_identity json.course_name @course.name From c417eeaf2aea5a44ca5fcdb2449ffa5277fd7afc Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 17 Aug 2019 15:06:22 +0800 Subject: [PATCH 097/100] =?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/views/student_works/edit.json.jbuilder | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/student_works/edit.json.jbuilder b/app/views/student_works/edit.json.jbuilder index 88e5354e4..1f79049d0 100644 --- a/app/views/student_works/edit.json.jbuilder +++ b/app/views/student_works/edit.json.jbuilder @@ -1,7 +1,6 @@ json.partial! "homework_commons/homework_public_navigation", locals: {homework: @homework, course: @course, user: @current_user} json.work_id @work.id json.description @work.description -json. json.attachments @work.attachments do |atta| json.partial! "attachments/attachment_simple", locals: {attachment: atta, delete: @work.delete_atta(atta)} From 4252648a4aadadb3c6e0c98a6cec541f0e358e98 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 17 Aug 2019 15:10:49 +0800 Subject: [PATCH 098/100] modify --- app/controllers/users/videos_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/users/videos_controller.rb b/app/controllers/users/videos_controller.rb index f04d4435d..8b445a7fb 100644 --- a/app/controllers/users/videos_controller.rb +++ b/app/controllers/users/videos_controller.rb @@ -1,6 +1,6 @@ class Users::VideosController < Users::BaseController - before_action :private_user_resources!, :check_account, :require_auth_teacher! - skip_before_action :require_auth_teacher!, only: [:index] + before_action :private_user_resources!, :check_account + before_action :require_auth_teacher!, except: [:index, :review] helper_method :current_video From e002d9f1eb63cb9d5594c4a60786cd927c28a251 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 17 Aug 2019 15:27:51 +0800 Subject: [PATCH 099/100] null --- public/react/src/modules/courses/busyWork/CommonWorkPost.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/busyWork/CommonWorkPost.js b/public/react/src/modules/courses/busyWork/CommonWorkPost.js index c248c554c..5ac53a065 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkPost.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkPost.js @@ -69,7 +69,7 @@ class CommonWorkPost extends Component{ status: 'done' } }) - const _memebers = response.data.members.slice(0); + const _memebers = response.data.members ? response.data.members.slice(0) : []; this._edit_init_memebers = _memebers delete response.data.members; this.setState({ From 0d8de9537aa9d7a81847a03aef7ba144e8cba0ca Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 17 Aug 2019 15:35:31 +0800 Subject: [PATCH 100/100] modify per_page max 100 --- app/controllers/users/base_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users/base_controller.rb b/app/controllers/users/base_controller.rb index eb6b98048..01ddee8fc 100644 --- a/app/controllers/users/base_controller.rb +++ b/app/controllers/users/base_controller.rb @@ -37,7 +37,7 @@ class Users::BaseController < ApplicationController end def per_page_value - params[:per_page].to_i > 0 && params[:per_page].to_i < 50 ? params[:per_page].to_i : 20 + params[:per_page].to_i > 0 && params[:per_page].to_i <= 100 ? params[:per_page].to_i : 20 end alias_method :limit_value, :per_page_value