diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 15f5c67d9..e5d9fc495 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -379,6 +379,7 @@ class ExercisesController < ApplicationController #试卷的提交设置 def commit_setting + tip_exception("助教无权限修改本试卷") if @user_course_identity == Course::ASSISTANT_PROFESSOR && !@exercise.assistant_auth ActiveRecord::Base.transaction do error_count = 0 # 判断循环里是否有已发布/已截止的,且时间更改了的分班。 # course_group_ids = @course.teacher_course_group_ids(current_user.id) #当前老师的班级id数组 @@ -398,6 +399,7 @@ class ExercisesController < ApplicationController choice_random = params[:choice_random] ? true : false score_open = params[:score_open] ? true : false #分数是否公开 answer_open = params[:answer_open] ? true : false #答案是否公开 + assistant_auth = params[:assistant_auth] ? true : false # 助教权限 # 统一设置或者分班为0,则更新试卷,并删除试卷分组 if unified_setting || (course_group_ids.size == 0) @@ -426,7 +428,8 @@ class ExercisesController < ApplicationController :answer_open => answer_open, :exercise_status => exercise_status_n, :publish_time => params_publish_time, - :end_time => params_end_time + :end_time => params_end_time, + :assistant_auth => assistant_auth } @exercise.update!(exercise_params) @exercise.exercise_group_settings.destroy_all diff --git a/app/views/exercises/common_header.json.jbuilder b/app/views/exercises/common_header.json.jbuilder index d43d7c3f8..7843c260e 100644 --- a/app/views/exercises/common_header.json.jbuilder +++ b/app/views/exercises/common_header.json.jbuilder @@ -1,5 +1,5 @@ json.course_is_end @course.is_end # true表示已结束,false表示未结束 -json.extract! @exercise, :id,:exercise_name,:exercise_description,:show_statistic +json.extract! @exercise, :id,:exercise_name,:exercise_description,:show_statistic,:assistant_auth json.time (@user_left_time.to_i / 60) json.exercise_status @ex_status diff --git a/app/views/exercises/index.json.jbuilder b/app/views/exercises/index.json.jbuilder index c8f6cd380..e1c8bd3a4 100644 --- a/app/views/exercises/index.json.jbuilder +++ b/app/views/exercises/index.json.jbuilder @@ -2,7 +2,7 @@ if @exercises_count > 0 json.exercises do json.array! @exercises do |exercise| - json.extract! exercise, :id, :exercise_name,:is_public,:created_at + json.extract! exercise, :id, :exercise_name,:is_public,:created_at,:assistant_auth if @is_teacher_or == 2 second_left = get_exercise_left_time(exercise,@current_user_) json.time second_left.present? ? (second_left / 60) : nil diff --git a/db/migrate/20200311082736_add_auth_to_exercise.rb b/db/migrate/20200311082736_add_auth_to_exercise.rb new file mode 100644 index 000000000..fceb96e0c --- /dev/null +++ b/db/migrate/20200311082736_add_auth_to_exercise.rb @@ -0,0 +1,5 @@ +class AddAuthToExercise < ActiveRecord::Migration[5.2] + def change + add_column :exercises, :assistant_auth, :boolean, default: 1 + end +end diff --git a/public/react/src/modules/question/Questionitem_banks.js b/public/react/src/modules/question/Questionitem_banks.js index 345ca9753..503e6f5de 100644 --- a/public/react/src/modules/question/Questionitem_banks.js +++ b/public/react/src/modules/question/Questionitem_banks.js @@ -529,6 +529,7 @@ class Questionitem_banks extends Component { } handleShowUploadImage=(url)=>{ + debugger this.setState({ url:url }) @@ -550,7 +551,7 @@ class Questionitem_banks extends Component { > {url? - this.handleClose()}> + this.handleClose()}> : "" } diff --git a/public/react/src/modules/question/component/ChoquesEditor.js b/public/react/src/modules/question/component/ChoquesEditor.js index 3277f03c9..82cd7b1b4 100644 --- a/public/react/src/modules/question/component/ChoquesEditor.js +++ b/public/react/src/modules/question/component/ChoquesEditor.js @@ -176,7 +176,16 @@ class ChoquesEditor extends Component{ onCancel = () => { this.props.onEditorCancel() } + handleShowUploadImages=(url)=>{ + this.setState({ + url:url, + }) + try { + this.props.handleShowUploadImage(url) + }catch (e) { + } + } handleShowUploadImage = (url,i) => { this.setState({ @@ -466,6 +475,8 @@ class ChoquesEditor extends Component{ options={options} value={question_title} onContentChange={this.onContentChange} + showUploadImage={(url)=>this.handleShowUploadImages(url)} + /> @@ -577,6 +588,7 @@ class ChoquesEditor extends Component{ options={options} value={question_titles} onContentChange={this.onContentChanges} + showUploadImage={(url)=>this.handleShowUploadImages(url)} /> diff --git a/public/react/src/modules/question/component/JudquestionEditor.js b/public/react/src/modules/question/component/JudquestionEditor.js index ab7e930b1..baea3391f 100644 --- a/public/react/src/modules/question/component/JudquestionEditor.js +++ b/public/react/src/modules/question/component/JudquestionEditor.js @@ -58,6 +58,7 @@ class JudquestionEditor extends Component{ zqda:null, item_banksedit:[], mychoicess:[], + url:'' } } addOption = () => { @@ -334,6 +335,16 @@ class JudquestionEditor extends Component{ } } } + handleShowUploadImages=(url)=>{ + this.setState({ + url:url, + }) + try { + this.props.handleShowUploadImage(url) + }catch (e) { + + } + } onContentChanges=(value,quill)=>{ const _text = quill.getText(); const reg = /^[\s\S]*.*[^\s][\s\S]*$/; @@ -437,6 +448,8 @@ class JudquestionEditor extends Component{ options={options} value={question_title} onContentChange={this.onContentChange} + showUploadImage={(url)=>this.handleShowUploadImages(url)} + /> @@ -487,6 +500,8 @@ class JudquestionEditor extends Component{ options={options} value={question_titles} onContentChange={this.onContentChanges} + showUploadImage={(url)=>this.handleShowUploadImages(url)} + /> diff --git a/public/react/src/modules/question/component/SingleEditor.js b/public/react/src/modules/question/component/SingleEditor.js index b34bfa9bb..06b057c82 100644 --- a/public/react/src/modules/question/component/SingleEditor.js +++ b/public/react/src/modules/question/component/SingleEditor.js @@ -251,6 +251,16 @@ class SingleEditor extends Component{ // standard_answers[index] = !standard_answers[index]; this.setState({ standard_answers }) } + handleShowUploadImages=(url)=>{ + this.setState({ + url:url, + }) + try { + this.props.handleShowUploadImage(url) + }catch (e) { + + } + } handleShowUploadImage = (url,i) => { @@ -494,6 +504,7 @@ class SingleEditor extends Component{ options={options} value={question_title} onContentChange={this.onContentChange} + showUploadImage={(url)=>this.handleShowUploadImages(url)} />
@@ -603,6 +614,7 @@ class SingleEditor extends Component{ options={options} value={question_titles} onContentChange={this.onContentChanges} + showUploadImage={(url)=>this.handleShowUploadImages(url)} />