diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 2cfa61cc9..bcfed25dd 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -260,7 +260,12 @@ 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/views/files/histories.json.jbuilder b/app/views/files/histories.json.jbuilder index f30cf6b1b..9dfec4fd4 100644 --- a/app/views/files/histories.json.jbuilder +++ b/app/views/files/histories.json.jbuilder @@ -1,2 +1,3 @@ +json.is_pdf @is_pdf json.partial! 'attachments/attachment_small', attachment: @file json.partial! "attachment_histories/list", attachment_histories: @attachment_histories diff --git a/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js b/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js index c2c9b7bcf..91ca19e7d 100644 --- a/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js +++ b/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js @@ -336,6 +336,16 @@ class ExerciseReviewAndAnswer extends Component{ } + // 选择题,切换答案 + changeOption = (index,ids) =>{ + //console.log(index+" "+ids); + this.setState( + (prevState) => ({ + exercise_questions : update(prevState.exercise_questions, {[index]: { user_answer: {$set: ids} }}), + }) + ) + } + //简答题 显示和隐藏答案 changeA_flag=(index,status)=>{ this.setState( @@ -726,6 +736,7 @@ class ExerciseReviewAndAnswer extends Component{ exercise={exercise} questionType={item} user_exercise_status={user_exercise_status} + changeOption={(index,ids)=>this.changeOption(index,ids)} changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)} index={key} > @@ -739,6 +750,7 @@ class ExerciseReviewAndAnswer extends Component{ exercise={exercise} questionType={item} user_exercise_status={user_exercise_status} + changeOption={(index,ids)=>this.changeOption(index,ids)} changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)} index={key} diff --git a/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js b/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js index bcc0d85a3..65e48962a 100644 --- a/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js +++ b/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js @@ -163,6 +163,10 @@ class Testpapersettinghomepage extends Component{ } } + //打开pdf + confpdf = (url) =>{ + window.open(url); + } /// 确认是否下载 confirmysl(url,child){ let params ={} @@ -372,7 +376,7 @@ class Testpapersettinghomepage extends Component{ 导出
-
+