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 01/71] =?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 02/71] =?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 03/71] =?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 04/71] =?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 05/71] =?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 06/71] 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 07/71] 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 08/71] 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 09/71] 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 10/71] =?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 11/71] =?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 12/71] =?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 13/71] =?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 14/71] =?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 15/71] =?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 16/71] =?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 17/71] 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 18/71] =?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 19/71] =?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 20/71] =?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 21/71] =?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 22/71] =?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 23/71] =?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 24/71] =?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 25/71] =?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 26/71] =?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 27/71] =?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 28/71] =?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 29/71] =?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 30/71] =?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 31/71] =?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 32/71] =?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 33/71] 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 34/71] =?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 35/71] =?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 36/71] =?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 37/71] =?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 38/71] =?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 39/71] =?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 40/71] =?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 41/71] =?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 42/71] =?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 43/71] =?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 44/71] =?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 45/71] =?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 46/71] 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 47/71] 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 48/71] 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 49/71] =?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 50/71] =?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 51/71] =?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 52/71] =?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 53/71] =?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 54/71] =?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 55/71] =?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 56/71] =?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 57/71] 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 58/71] =?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 59/71] 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 60/71] 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 61/71] 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 From 29ab7e95c2c0e4c1e61b8368da8e0f77d2aea68a Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Sat, 17 Aug 2019 15:41:10 +0800 Subject: [PATCH 62/71] =?UTF-8?q?=E5=A4=B4=E9=83=A8=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/tpm/NewHeader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js index a6a849183..dff749515 100644 --- a/public/react/src/modules/tpm/NewHeader.js +++ b/public/react/src/modules/tpm/NewHeader.js @@ -727,7 +727,7 @@ submittojoinclass=(value)=>{ src={require('./roundedRectangle.png')} />
  • -
  • 教学案例
  • +
  • 教学案例
  • 众包创新
  • From 95c8f28a74b14fd203f8975adb75a16ed73f0603 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 17 Aug 2019 15:51:50 +0800 Subject: [PATCH 63/71] video feature: modify refresh auth api --- app/controllers/users/video_auths_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/users/video_auths_controller.rb b/app/controllers/users/video_auths_controller.rb index a7d41bce5..2231dcfdf 100644 --- a/app/controllers/users/video_auths_controller.rb +++ b/app/controllers/users/video_auths_controller.rb @@ -10,7 +10,9 @@ class Users::VideoAuthsController < Users::BaseController def update video = observed_user.videos.find_by(uuid: params[:video_id]) - return render_error('该视频凭证不存在') if video.blank? + if video.blank? + video = observed_user.videos.create!(uuid: params[:video_id], title: params[:title], cover_url: params[:cover_url]) + end result = AliyunVod::Service.refresh_upload_video(video.uuid) render_ok(data: result) From 2d59bf67662c885de3c7516781848bee6ace339e Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 17 Aug 2019 15:57:18 +0800 Subject: [PATCH 64/71] modify --- app/controllers/users/video_auths_controller.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/controllers/users/video_auths_controller.rb b/app/controllers/users/video_auths_controller.rb index 2231dcfdf..a7d41bce5 100644 --- a/app/controllers/users/video_auths_controller.rb +++ b/app/controllers/users/video_auths_controller.rb @@ -10,9 +10,7 @@ class Users::VideoAuthsController < Users::BaseController def update video = observed_user.videos.find_by(uuid: params[:video_id]) - if video.blank? - video = observed_user.videos.create!(uuid: params[:video_id], title: params[:title], cover_url: params[:cover_url]) - end + return render_error('该视频凭证不存在') if video.blank? result = AliyunVod::Service.refresh_upload_video(video.uuid) render_ok(data: result) From 5d46519867b49f6cb6333ebebf70d50a85d07c1f 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 16:06:59 +0800 Subject: [PATCH 65/71] =?UTF-8?q?=E5=B0=81=E8=A3=85open=20pdf=20=E6=96=B0?= =?UTF-8?q?=E5=BC=80=E9=A1=B5=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/tpm/TPMIndexHOC.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js index 682e8f866..795e01a31 100644 --- a/public/react/src/modules/tpm/TPMIndexHOC.js +++ b/public/react/src/modules/tpm/TPMIndexHOC.js @@ -345,6 +345,10 @@ export function TPMIndexHOC(WrappedComponent) { link.dispatchEvent(evt); document.body.removeChild(link); } + + DownloadOpenPdf=(type,url)=>{ + type===true?window.open(url):window.location.href=url; + } render() { let{Headertop,Footerdown, isRender, AccountProfiletype}=this.state; const common = { @@ -364,6 +368,7 @@ export function TPMIndexHOC(WrappedComponent) { checkIfProfileCompleted: this.checkIfProfileCompleted, ShowOnlinePdf:(url)=>this.ShowOnlinePdf(url), DownloadFileA:(title,url)=>this.DownloadFileA(title,url), + DownloadOpenPdf:(type,url)=>this.DownloadOpenPdf(type,url) } return (
    From 3af57e97ce8335d66eae53fed8806d88f66ccae2 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 17 Aug 2019 16:19:36 +0800 Subject: [PATCH 66/71] video feature: modify --- app/libs/aliyun_vod/service/base.rb | 10 +++++++++- app/libs/aliyun_vod/service/video_upload.rb | 9 --------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/libs/aliyun_vod/service/base.rb b/app/libs/aliyun_vod/service/base.rb index 85f74fc6f..e100eadcc 100644 --- a/app/libs/aliyun_vod/service/base.rb +++ b/app/libs/aliyun_vod/service/base.rb @@ -10,7 +10,15 @@ module AliyunVod::Service::Base Rails.logger.info("[AliyunVod] response => status: #{response.status}, result: #{result}") - raise AliyunVod::Error, result['Code'] if response.status != 200 + if response.status != 200 + message = + case result['Code'] + when 'InvalidFileName.Extension' then '不支持的文件格式' + when 'IllegalCharacters' then '文件名称包含非法字符' + else raise AliyunVod::Error, result['Message'] + end + raise AliyunVod::Error, message if message.present? + end result rescue => ex diff --git a/app/libs/aliyun_vod/service/video_upload.rb b/app/libs/aliyun_vod/service/video_upload.rb index a5ade72f9..97ecd970b 100644 --- a/app/libs/aliyun_vod/service/video_upload.rb +++ b/app/libs/aliyun_vod/service/video_upload.rb @@ -16,15 +16,6 @@ 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 From 64a51a1759fcf94292c486be5e5198c31debac50 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 19 Aug 2019 10:30:56 +0800 Subject: [PATCH 67/71] =?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/attachments_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index d3317e99e..3d6e20ee9 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -172,7 +172,10 @@ class AttachmentsController < ApplicationController # 课堂资源、作业、毕设相关资源的权限判断 if @file.container.is_a?(Course) course = @file.container + Rails.logger.info("@@@@@@@@@@@@######################## course_id#{course.id}") candown = current_user.member_of_course?(course) || @file.is_public == 1 + Rails.logger.info("@@@@@@@@@@@@######################## public #{@file.is_public}") + Rails.logger.info("@@@@@@@@@@@@#########################{candown}") 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) From e9b682383b9b44805301edd4ea3ec417f8ba8455 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 19 Aug 2019 10:47:31 +0800 Subject: [PATCH 68/71] =?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/attachments_controller.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 3d6e20ee9..df74cf737 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -172,10 +172,7 @@ class AttachmentsController < ApplicationController # 课堂资源、作业、毕设相关资源的权限判断 if @file.container.is_a?(Course) course = @file.container - Rails.logger.info("@@@@@@@@@@@@######################## course_id#{course.id}") - candown = current_user.member_of_course?(course) || @file.is_public == 1 - Rails.logger.info("@@@@@@@@@@@@######################## public #{@file.is_public}") - Rails.logger.info("@@@@@@@@@@@@#########################{candown}") + candown = current_user.member_of_course?(course) || (course.is_public? && @file.publiced?) 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) From 2f187e1a84884a57edec55d56a698125d06e43e2 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 19 Aug 2019 11:28:02 +0800 Subject: [PATCH 69/71] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=95=8A=E7=9A=84=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_questions_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index 3718e18d5..52915a8ba 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -339,10 +339,11 @@ class ExerciseQuestionsController < ApplicationController @exercise_question.exercise_shixun_challenges.each_with_index do |challenge, index| challenge.question_score = params[:question_scores][index].to_f.round(1) challenge.save - question_score += challenge.question_score + question_score += params[:question_scores][index].to_f.round(1) end @exercise_question.question_score = question_score @exercise_question.shixun_name = shixun_name + @exercise_question.save end #当试卷已发布时(试卷的总状态),当标准答案修改时,如有已提交的学生,需重新计算分数. From d203a381099e54e749ff5a3eeb00db5a2eb833c9 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 19 Aug 2019 11:33:46 +0800 Subject: [PATCH 70/71] =?UTF-8?q?=E8=B0=83=E6=95=B4=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 | 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 964951003..d337fbd73 100644 --- a/lib/tasks/excellent_course_exercise.rake +++ b/lib/tasks/excellent_course_exercise.rake @@ -35,9 +35,9 @@ namespace :excellent_course_exercise do 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) + rand_num = index < pass_count - 1 ? rand(15..20) : rand(1..10) elsif exercise_question_ids.length == 17 - rand_num = index < pass_count - 1 ? rand(13..17) : rand(1..11) + rand_num = index < pass_count - 1 ? rand(12..17) : rand(1..9) elsif exercise_question_ids.length == 39 rand_num = index < pass_count - 1 ? rand(30..39) : rand(1..18) else From 9110cc6a9ac3e0a71ae2514d9c2bb5a206f95b6d Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Mon, 19 Aug 2019 11:33:47 +0800 Subject: [PATCH 71/71] list --- public/react/src/common/components/attachment/AttachmentList.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 public/react/src/common/components/attachment/AttachmentList.js diff --git a/public/react/src/common/components/attachment/AttachmentList.js b/public/react/src/common/components/attachment/AttachmentList.js new file mode 100644 index 000000000..e69de29bb