试卷的助教权限

PCqiandao
cxt 5 years ago
parent 78921f7006
commit 084f77fcca

@ -379,6 +379,7 @@ class ExercisesController < ApplicationController
#试卷的提交设置 #试卷的提交设置
def commit_setting def commit_setting
tip_exception("助教无权限修改本试卷") if @user_course_identity == Course::ASSISTANT_PROFESSOR && !@exercise.assistant_auth
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
error_count = 0 # 判断循环里是否有已发布/已截止的,且时间更改了的分班。 error_count = 0 # 判断循环里是否有已发布/已截止的,且时间更改了的分班。
# course_group_ids = @course.teacher_course_group_ids(current_user.id) #当前老师的班级id数组 # 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 choice_random = params[:choice_random] ? true : false
score_open = params[:score_open] ? true : false #分数是否公开 score_open = params[:score_open] ? true : false #分数是否公开
answer_open = params[:answer_open] ? true : false #答案是否公开 answer_open = params[:answer_open] ? true : false #答案是否公开
assistant_auth = params[:assistant_auth] ? true : false # 助教权限
# 统一设置或者分班为0则更新试卷并删除试卷分组 # 统一设置或者分班为0则更新试卷并删除试卷分组
if unified_setting || (course_group_ids.size == 0) if unified_setting || (course_group_ids.size == 0)
@ -426,7 +428,8 @@ class ExercisesController < ApplicationController
:answer_open => answer_open, :answer_open => answer_open,
:exercise_status => exercise_status_n, :exercise_status => exercise_status_n,
:publish_time => params_publish_time, :publish_time => params_publish_time,
:end_time => params_end_time :end_time => params_end_time,
:assistant_auth => assistant_auth
} }
@exercise.update!(exercise_params) @exercise.update!(exercise_params)
@exercise.exercise_group_settings.destroy_all @exercise.exercise_group_settings.destroy_all

@ -1,5 +1,5 @@
json.course_is_end @course.is_end # true表示已结束false表示未结束 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.time (@user_left_time.to_i / 60)
json.exercise_status @ex_status json.exercise_status @ex_status

@ -2,7 +2,7 @@
if @exercises_count > 0 if @exercises_count > 0
json.exercises do json.exercises do
json.array! @exercises do |exercise| 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 if @is_teacher_or == 2
second_left = get_exercise_left_time(exercise,@current_user_) second_left = get_exercise_left_time(exercise,@current_user_)
json.time second_left.present? ? (second_left / 60) : nil json.time second_left.present? ? (second_left / 60) : nil

@ -0,0 +1,5 @@
class AddAuthToExercise < ActiveRecord::Migration[5.2]
def change
add_column :exercises, :assistant_auth, :boolean, default: 1
end
end
Loading…
Cancel
Save