Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_hjm
杨树林 6 years ago
commit 1cc224e709

@ -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

@ -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

@ -0,0 +1,8 @@
class ModifyClassPeriodForCourses < ActiveRecord::Migration[5.2]
def change
Course.find_each do |c|
c.update_column(:class_period, c.class_period.to_i)
end
change_column :courses, :class_period, :integer
end
end

@ -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}
></Single>
@ -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}

@ -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(
<div className="pl30 pr30 singleDisplay">
<Checkbox.Group disabled={ user_exercise_status == 1 ? true : false } onChange={this.saveId} defaultValue={questionType.user_answer}>
<Checkbox.Group disabled={ user_exercise_status == 1 ? true : false } onChange={this.saveId} value={questionType.user_answer}>
{
questionType.question_choices && questionType.question_choices.map((item,key)=>{
let prefix = `${tagArray[key]}.`
return(
<p className="clearfix mb15 df">
<Checkbox className="fl lineh-20 " value={item.choice_id}>{prefix}</Checkbox>
<Checkbox className="fl lineh-15 df mr8 mt2" value={item.choice_id}>{prefix}</Checkbox>
{/* <span class="fl lineh-20 mt1"></span> */}
{/* <span style={{display:"inline-block"}} className="markdown-body " dangerouslySetInnerHTML={{__html: markdownToHTML1(item.choice_text)}}></span> */}
<MarkdownToHtml content={item.choice_text} selector={'multiple_' + (this.props.index + 1) + (key + 1)}

@ -16,11 +16,13 @@ class single extends Component{
changeItem=(e)=>{
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(
<div className="pl30 pr30 singleDisplay">
<Radio.Group disabled={ user_exercise_status == 1 ? true : false } defaultValue={questionType.user_answer[0]} onChange={this.changeItem}>
<Radio.Group disabled={ user_exercise_status == 1 ? true : false } value={questionType.user_answer[0]} onChange={this.changeItem}>
{
questionType.question_choices && questionType.question_choices.map((item,key)=>{
let prefix = isJudge ? undefined : `${tagArray[key]}.`
return(
<p className={parseInt(questionType.question_type) == 0 ? "clearfix mb15 df" : "fl mr40"}>
<p className={parseInt(questionType.question_type) == 0 ? "clearfix mb15 df" : "fl mr40 df"}>
<Radio className="fl lineh-20" value={item.choice_id}>{prefix}</Radio>
{/* <span className="fl lineh-20 mr3 "></span> */}
{/* <span style={{display:"inline-block", 'margin-top': '-1px'}} className="markdown-body fl " dangerouslySetInnerHTML={{__html: markdownToHTML1(item.choice_text)}}></span> */}

Loading…
Cancel
Save