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{ 导出 :""} diff --git a/public/react/src/modules/courses/exercise/question/multiple.js b/public/react/src/modules/courses/exercise/question/multiple.js index 7e96f8550..bbbfa0c94 100644 --- a/public/react/src/modules/courses/exercise/question/multiple.js +++ b/public/react/src/modules/courses/exercise/question/multiple.js @@ -15,6 +15,7 @@ class Multiple extends Component{ saveId=(value)=>{ let question_id=this.props.questionType.question_id; let url=`/exercise_questions/${question_id}/exercise_answers.json`; + let {index}=this.props; axios.post((url),{ exercise_choice_id:value }).then((result)=>{ @@ -25,6 +26,7 @@ class Multiple extends Component{ }else{ k=0; } + this.props.changeOption && this.props.changeOption(index,value); this.props.changeQuestionStatus && this.props.changeQuestionStatus(parseInt(this.props.questionType.q_position)-1,k); } }).catch((error)=>{ @@ -42,14 +44,14 @@ class Multiple extends Component{ console.log(questionType); return(
- + { questionType.question_choices && questionType.question_choices.map((item,key)=>{ let prefix = `${tagArray[key]}.` return(

- {prefix} + {prefix} {/* */} {/* */} { let choiceId=e.target.value; let question_id=this.props.questionType.question_id; + let {index}=this.props; let url=`/exercise_questions/${question_id}/exercise_answers.json`; axios.post((url),{ exercise_choice_id:choiceId }).then((result)=>{ if(result){ + this.props.changeOption && this.props.changeOption(index,[choiceId]); this.props.changeQuestionStatus && this.props.changeQuestionStatus(parseInt(this.props.questionType.q_position)-1,1); } }).catch((error)=>{ @@ -38,12 +40,12 @@ class single extends Component{ let isJudge = questionType.question_type == 2 return(

- + { questionType.question_choices && questionType.question_choices.map((item,key)=>{ let prefix = isJudge ? undefined : `${tagArray[key]}.` return( -

+

{prefix} {/* */} {/* */} diff --git a/public/react/src/modules/courses/shixunHomework/Listofworksstudentone.js b/public/react/src/modules/courses/shixunHomework/Listofworksstudentone.js index 6b756ad8f..8ba9b8ac2 100644 --- a/public/react/src/modules/courses/shixunHomework/Listofworksstudentone.js +++ b/public/react/src/modules/courses/shixunHomework/Listofworksstudentone.js @@ -367,9 +367,9 @@ class Listofworksstudentone extends Component { render: (text, record) => ( { - record.submitstate === "未提交" ?-- + record.submitstate === "未提交" ?-- : - this.Viewstudenttraininginformation(record)}>{record.operating} } @@ -691,9 +691,9 @@ class Listofworksstudentone extends Component { align: 'center', className:'font-14', render: (text, record) => ( - record.submitstate === "未提交" ? -- : + record.submitstate === "未提交" ? -- : - this.Viewstudenttraininginformationt(record)}>{record.operating} ) @@ -985,9 +985,9 @@ class Listofworksstudentone extends Component { align: 'center', className:'font-14', render: (text, record) => ( - record.submitstate === "未提交" ? -- : + record.submitstate === "未提交" ? -- : - this.Viewstudenttraininginformationt(record)}>{record.operating} )