Merge branch 'dev_aliyun' into dev_hjm_a

dev_hjm_a
hjm 5 years ago
commit 54a3589c0d

@ -12,10 +12,10 @@ class CoursesController < ApplicationController
end
before_action :require_login, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups,
:left_banner, :top_banner, :informs, :online_learning]
:left_banner, :top_banner, :informs, :online_learning, :course_groups]
before_action :check_account, only: [:new, :create, :apply_to_join_course, :join_excellent_course]
before_action :check_auth, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups,
:left_banner, :top_banner, :apply_to_join_course, :exit_course]
:left_banner, :top_banner, :apply_to_join_course, :exit_course, :course_groups]
before_action :set_course, only: [:show, :update, :destroy, :settings, :set_invite_code_halt,
:set_public_or_private, :search_teacher_candidate, :teachers, :apply_teachers,
:top_banner, :left_banner, :add_teacher_popup, :add_teacher,
@ -27,7 +27,8 @@ class CoursesController < ApplicationController
:attahcment_category_list,:export_member_scores_excel, :duplicate_course,
:switch_to_teacher, :switch_to_assistant, :switch_to_student, :exit_course,
:informs, :update_informs, :online_learning, :update_task_position, :tasks_list,
:join_excellent_course, :export_couser_info, :export_member_act_score, :new_informs, :delete_informs]
:join_excellent_course, :export_couser_info, :export_member_act_score, :new_informs,
:delete_informs, :change_member_role, :course_groups, :join_course_group]
before_action :user_course_identity, except: [:join_excellent_course, :index, :create, :new, :apply_to_join_course,
:search_course_list, :get_historical_course_students, :mine, :search_slim, :board_list]
before_action :teacher_allowed, only: [:update, :destroy, :settings, :search_teacher_candidate,
@ -39,7 +40,7 @@ class CoursesController < ApplicationController
:set_course_group, :create_group_by_importing_file,
:update_task_position, :tasks_list]
before_action :teacher_or_admin_allowed, only: [:graduation_group_list, :create_graduation_group, :join_graduation_group,
:change_course_teacher, :course_group_list,
:change_course_teacher, :course_group_list, :change_member_role,
:teacher_application_review, :apply_teachers, :delete_course_teacher]
before_action :validate_course_name, only: [:create, :update]
before_action :find_board, only: :board_list
@ -340,8 +341,8 @@ class CoursesController < ApplicationController
@has_graduation_design = @course.course_modules.graduation_module_not_hidden.any?
sort = params[:sort] || "desc"
@order = params[:order].to_i
sort = params[:sort] || "asc"
@order = params[:order] ? params[:order].to_i : 1
if @order.present?
case @order
when 1
@ -547,6 +548,61 @@ class CoursesController < ApplicationController
end
end
# 修改角色
def change_member_role
tip_exception("请至少选择一个角色") if params[:roles].blank?
tip_exception("不能具有老师、助教两种角色") if params[:roles].include?("PROFESSOR") && params[:roles].include?("ASSISTANT_PROFESSOR")
tip_exception("管理员不能切换为助教或老师") if params[:user_id].to_i == @course.tea_id &&
(params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR"))
course_members = @course.course_members.where(user_id: params[:user_id])
tip_exception("非课堂成员不能修改角色") if course_members.blank?
ActiveRecord::Base.transaction do
# 第一次修改为教师或助教身份时直接创建数据
if params[:roles].include?("CREATOR")
teacher_member = course_members.where(role: %i[CREATOR]).take
elsif (params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR")) && !course_members.exists?(role: %i[PROFESSOR ASSISTANT_PROFESSOR])
teacher_member = CourseMember.create!(course_id: @course.id, user_id: params[:user_id], role: params[:roles].include?("PROFESSOR") ? 2 : 3)
elsif course_members.exists?(role: %i[PROFESSOR ASSISTANT_PROFESSOR])
teacher_member = course_members.where(role: %i[PROFESSOR ASSISTANT_PROFESSOR]).take
if params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR")
# 如果之前有老师身份且老师身份要调整时只需要修改role字段
if !params[:roles].include?(teacher_member.role) && params[:roles].include?("PROFESSOR")
teacher_member.PROFESSOR!
elsif !params[:roles].include?(teacher_member.role) && params[:roles].include?("ASSISTANT_PROFESSOR")
teacher_member.ASSISTANT_PROFESSOR!
end
teacher_member.save!
else
# 不含教师的参数时删除记录
teacher_member.destroy!
# CourseDeleteStudentNotifyJob.perform_later(@course.id, [teacher_member.user_id], current_user.id)
end
end
# 学生身份的处理
student_member = course_members.where(role: %i[STUDENT]).take
if params[:roles].include?("STUDENT") && student_member.blank?
correspond_teacher_exist = CourseMember.exists?(user_id: params[:user_id], is_active: 1, course_id: @course.id, role: %i[CREATOR PROFESSOR ASSISTANT_PROFESSOR])
new_student = CourseMember.new(user_id: params[:user_id], course_id: @course.id, role: 4)
new_student.is_active = 0 if correspond_teacher_exist
new_student.save!
CourseAddStudentCreateWorksJob.perform_later(@course.id, [params[:user_id]])
# StudentJoinCourseNotifyJob.perform_later(current_user.id, course.id)
elsif !params[:roles].include?("STUDENT") && student_member.present?
# 删除学生身份时激活老师身份
teacher_member.update_attributes!(is_active: 1) if student_member.is_active && teacher_member.present?
student_member.destroy!
CourseDeleteStudentDeleteWorksJob.perform_later(@course.id, [params[:user_id]])
# CourseDeleteStudentNotifyJob.perform_later(@course.id, [params[:user_id]], current_user.id)
end
normal_status(0, "修改成功")
end
end
# 教师和助教角色转换的接口
def change_course_teacher
begin
@ -715,8 +771,8 @@ class CoursesController < ApplicationController
# 学生列表(包括各个子分班的学生列表)及搜索
def students
search = params[:search].present? ? params[:search].strip : nil
order = params[:order].present? ? params[:order].to_i : 0
sort = params[:sort].present? ? params[:sort] : "desc"
order = params[:order].present? ? params[:order].to_i : 1
sort = params[:sort].present? ? params[:sort] : "asc"
course_group_id = params[:course_group_id].present? ? params[:course_group_id].to_i : nil
@students = CourseMember.students(@course)
@ -766,6 +822,26 @@ class CoursesController < ApplicationController
end
end
# 分班列表
def course_groups
@course_groups = @course.course_groups
@course_groups = @course_groups.where("name like ?", "%#{params[:search]}%") unless params[:search].blank?
@all_group_count = @course_groups.size
@teachers = @course.teachers.includes(:user, :teacher_course_groups) if @user_course_identity < Course::NORMAL
@current_group_id = @course.students.where(user_id: current_user.id).take&.course_group_id if @user_course_identity == Course::STUDENT
end
# 学生自动加入分班
def join_course_group
tip_exception("学生才能加入分班") if @user_course_identity != Course::STUDENT
course_group = CourseGroup.find_by!(id: params[:course_group_id], course_id: @course.id)
member = CourseMember.find_by!(user_id: current_user.id, course_id: @course.id, role: 4)
if course_group && member
member.update_attributes!(course_group_id: course_group.id)
normal_status(0, "加入成功")
end
end
# 将学生批量移动到某个分班
def transfer_to_course_group
ActiveRecord::Base.transaction do

@ -683,12 +683,34 @@ class ExercisesController < ApplicationController
end
end
# 详情页的立即发布弹框
def publish_groups
@current_user = current_user
# 可立即发布的分班:当前用户管理的分班去除已发布的分班
group_ids = @course.charge_group_ids(@current_user) - @exercise.exercise_group_settings.exercise_group_published.pluck(:course_group_id)
@course_groups = @course.course_groups.where(id: group_ids)
@group_settings = @exercise.exercise_group_settings.where(course_group_id: group_ids)
end
#首页批量或单独 立即发布,应是跳出弹窗,设置开始时间和截止时间。
def publish
if params[:detail].blank?
tip_exception("缺少截止时间参数") if params[:end_time].blank?
tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now)
tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
@course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day)
else
group_end_times = params[:group_end_times].reject(&:blank?).map{|time| time.to_time}
group_ids = params[:group_ids].reject(&:blank?)
tip_exception("缺少截止时间参数") if group_end_times.blank?
tip_exception("截止时间和分班参数的个数不一致") if group_end_times.length != group_ids.length
group_end_times.each do |time|
tip_exception("分班截止时间不能早于当前时间") if time <= Time.now
tip_exception("分班截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
@course.end_date.present? && time > @course.end_date.end_of_day
end
end
ActiveRecord::Base.transaction do
begin
check_ids = Exercise.where(id: params[:check_ids])
@ -702,28 +724,30 @@ class ExercisesController < ApplicationController
.exercise_group_not_published.present? ? 1 : 0
end
if ex_status == 1 #如果试卷存在已发布的,或者是已截止的,那么则直接跳过
g_course = params[:group_ids] #表示是否传入分班参数,如果传入分班的参数,那么试卷的统一设置需修改
g_course = group_ids #表示是否传入分班参数,如果传入分班的参数,那么试卷的统一设置需修改
tiding_group_ids = g_course
if g_course
user_course_groups = @course.charge_group_ids(current_user)
if g_course.map(&:to_i).sort == user_course_groups.sort # 如果是设置为全部班级,则试卷不用分组,且试卷设定为统一设置,否则则分组设置
user_course_groups = @course.course_groups.pluck(:id)
if g_course.map(&:to_i).sort == user_course_groups.sort &&
((params[:detail] && group_end_times.min == group_end_times.max) || params[:detail].blank?) # 如果是设置为全部班级,则试卷不用分组,且试卷设定为统一设置,否则则分组设置
exercise.exercise_group_settings.destroy_all
ex_unified = true
e_time = ex_end_time
e_time = params[:detail] ? group_end_times.max : ex_end_time
tiding_group_ids = []
else
ex_unified = false
g_course.each do |i|
g_course.each_with_index do |i, index|
exercise_group_setting = exercise.exercise_group_settings.find_in_exercise_group("course_group_id",i).first #根据课堂分班的id寻找试卷所在的班级
group_end_time = params[:detail] ? group_end_times[index] : ex_end_time
if exercise_group_setting #如果该试卷分组存在,则更新,否则新建
exercise_group_setting.update_attributes(publish_time:Time.now,end_time:ex_end_time)
exercise_group_setting.update_attributes(publish_time: Time.now, end_time: group_end_time)
else
p_course_group = {
:exercise_id => exercise.id,
:course_group_id => i,
:course_id => exercise.course.id,
:publish_time => Time.now,
:end_time => ex_end_time,
:end_time => group_end_time,
}
new_exercise_group = exercise.exercise_group_settings.new p_course_group
new_exercise_group.save
@ -954,7 +978,8 @@ class ExercisesController < ApplicationController
:status => nil,
:commit_status => 0,
:objective_score => 0.0,
:subjective_score => -1.0
:subjective_score => -1.0,
:commit_method => 0
}
redo_exercise_users = @exercise_users.exercise_commit_users(user_ids)
redo_exercise_users.update_all(redo_option)
@ -1078,9 +1103,10 @@ class ExercisesController < ApplicationController
ActiveRecord::Base.transaction do
begin
can_commit_exercise = false
if (@user_course_identity > Course::ASSISTANT_PROFESSOR) && params[:commit_method].present? #为学生时
if @user_course_identity > Course::ASSISTANT_PROFESSOR #为学生时
if params[:commit_method].to_i == 2 #自动提交时
user_left_time = get_exercise_left_time(@exercise,current_user)
Rails.logger.info("######__________auto_commit_user_left_time_________################{user_left_time}")
if user_left_time.to_i <= 0
can_commit_exercise = true
end
@ -1105,10 +1131,10 @@ class ExercisesController < ApplicationController
CommitExercsieNotifyJobJob.perform_later(@exercise.id, current_user.id)
normal_status(0,"试卷提交成功!")
else
normal_status(-1,"提交失败,请重试!")
normal_status(-1,"提交失败,未到截止时间!")
end
else
normal_status(-1,"提交失败,请重试!")
normal_status(-1,"提交失败,当前用户不为课堂学生!")
end
rescue Exception => e
uid_logger_error(e.message)

@ -1036,6 +1036,7 @@ class HomeworkCommonsController < ApplicationController
# 可立即发布的分班:当前用户管理的分班去除已发布的分班
group_ids = @course.charge_group_ids(@current_user) - @homework.homework_group_settings.group_published.pluck(:course_group_id)
@course_groups = @course.course_groups.where(id: group_ids)
@group_settings = @homework.homework_group_settings.where(course_group_id: group_ids)
else
tip_exception("没有可发布的分班")
end
@ -1043,16 +1044,28 @@ class HomeworkCommonsController < ApplicationController
def publish_homework
tip_exception("请至少选择一个分班") if params[:group_ids].blank? && @course.course_groups.size != 0
if params[:detail].blank?
tip_exception("缺少截止时间参数") if params[:end_time].blank?
tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now)
tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
@course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day)
else
group_end_times = params[:group_end_times].reject(&:blank?).map{|time| time.to_time}
group_ids = params[:group_ids].reject(&:blank?)
tip_exception("缺少截止时间参数") if group_end_times.blank?
tip_exception("截止时间和分班参数的个数不一致") if group_end_times.length != group_ids.length
group_end_times.each do |time|
tip_exception("分班截止时间不能早于当前时间") if time <= Time.now
tip_exception("分班截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
@course.end_date.present? && time > @course.end_date.end_of_day
end
end
homeworks = @course.homework_commons.where(id: params[:homework_ids])
homeworks = homeworks.includes(:homework_group_settings, :homework_detail_manual)
charge_group_ids = @course.charge_group_ids(current_user)
publish_groups = charge_group_ids & params[:group_ids] if params[:group_ids]
publish_groups = charge_group_ids & group_ids if group_ids
# ActiveRecord::Base.transaction do
begin
@ -1062,18 +1075,26 @@ class HomeworkCommonsController < ApplicationController
if !params[:group_ids].blank?
# 全选即统一设置unified_setting为true
if @course.course_groups.where(id: publish_groups).size == @course.course_groups.size
if @course.course_groups.where(id: publish_groups).size == @course.course_groups.size &&
((params[:detail] && group_end_times.min == group_end_times.max) || params[:detail].blank?)
homework.homework_group_settings.destroy_all
homework.unified_setting = true
homework.end_time = params[:end_time]
homework.end_time = params[:detail] ? group_end_times.max : params[:end_time]
else
homework.unified_setting = false
# 创建作业分班设置homework_group_setting
create_homework_group_settings(homework)
# 选中的分班设置的发布时间改为当前时间,截止时间改为传的截止时间参数
if params[:detail]
group_ids.each_with_index do |group_id, index|
homework.homework_group_settings.find_by(course_group_id: group_id)&.update_attributes!(publish_time: Time.now,
end_time: group_end_times[index])
end
else
homework.homework_group_settings.where(course_group_id: publish_groups).update_all(publish_time: Time.now,
end_time: params[:end_time])
end
# 发消息
tiding_group_ids = publish_groups
end
@ -1086,7 +1107,7 @@ class HomeworkCommonsController < ApplicationController
# 截止时间的处理
if homework.end_time.nil?
homework.end_time = params[:end_time]
homework.end_time = params[:detail] ? group_end_times.max : params[:end_time]
elsif homework.max_group_end_time
homework.end_time = homework.max_group_end_time
end
@ -1101,12 +1122,22 @@ class HomeworkCommonsController < ApplicationController
create_homework_group_settings(homework)
none_publish_settings = homework.homework_group_settings.where(course_group_id: publish_groups).none_published
if params[:detail]
group_ids.each_with_index do |group_id, index|
none_publish_settings.find_by(course_group_id: group_id)&.update_attributes!(publish_time: Time.now,
end_time: group_end_times[index])
end
else
none_publish_settings.update_all(publish_time: Time.now, end_time: params[:end_time])
end
if homework.max_group_end_time
homework.end_time = homework.max_group_end_time
end
HomeworkCommonPushNotifyJob.perform_later(homework.id, none_publish_settings.pluck(:course_group_id))
end
if homework.end_time > Time.now && homework.homework_detail_manual.try(:comment_status) > 1
homework.homework_detail_manual.update_attribute("comment_status", 1)
end

@ -2,10 +2,10 @@ class PollsController < ApplicationController
# before_action :check_poll_status 问卷的发消息和定时任务没有做
before_action :require_login, :check_auth,except: [:index]
before_action :find_course, except: [:show,:poll_setting,:commit_setting,:edit,:update,:start_answer,:commit_poll,
:commit_result,:poll_lists,:cancel_publish,:cancel_publish_modal,:common_header]
:commit_result,:poll_lists,:cancel_publish,:cancel_publish_modal,:common_header,:publish_groups]
before_action :get_poll_and_course, only: [:show,:poll_setting,:commit_setting,:edit,:update,:start_answer,
:commit_poll,:commit_result,:poll_lists,:cancel_publish,
:cancel_publish_modal,:common_header]
:cancel_publish_modal,:common_header, :publish_groups]
before_action :user_course_identity
before_action :is_course_teacher, except: [:index,:start_answer,:poll_setting,:commit_poll,:commit_result,:poll_lists,:common_header] #判断是否为课堂老师
before_action :check_user_status
@ -242,12 +242,35 @@ class PollsController < ApplicationController
end
end
end
# 详情页的立即发布弹框
def publish_groups
@current_user = current_user
# 可立即发布的分班:当前用户管理的分班去除已发布的分班
group_ids = @course.charge_group_ids(@current_user) - @poll.poll_group_settings.poll_group_published.pluck(:course_group_id)
@course_groups = @course.course_groups.where(id: group_ids)
@group_settings = @poll.poll_group_settings.where(course_group_id: group_ids)
end
#首页批量或单独 立即发布,应是跳出弹窗,设置开始时间和截止时间。
def publish
if params[:detail].blank?
tip_exception("缺少截止时间参数") if params[:end_time].blank?
tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now)
tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
@course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day)
else
group_end_times = params[:group_end_times].reject(&:blank?).map{|time| time.to_time}
group_ids = params[:group_ids].reject(&:blank?)
tip_exception("缺少截止时间参数") if group_end_times.blank?
tip_exception("截止时间和分班参数的个数不一致") if group_end_times.length != group_ids.length
group_end_times.each do |time|
tip_exception("分班截止时间不能早于当前时间") if time <= Time.now
tip_exception("分班截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
@course.end_date.present? && time > @course.end_date.end_of_day
end
end
ActiveRecord::Base.transaction do
begin
check_ids = Poll.where(id: params[:check_ids])
@ -259,26 +282,28 @@ class PollsController < ApplicationController
pl_status = poll.poll_group_settings.find_in_poll_group("course_group_id",params[:group_ids]).poll_group_not_published.present? ? 1 : 0 #立即发布针对分组设置的全部未发布的班级才生效
end
if pl_status == 1 #如果问卷存在已发布的,或者是已截止的,那么则直接跳过
g_course = params[:group_ids] #表示是否传入分班参数,如果传入分班的参数那么poll的统一设置需修改
g_course = group_ids #表示是否传入分班参数,如果传入分班的参数那么poll的统一设置需修改
if g_course
user_course_groups = @course.charge_group_ids(current_user)
if g_course.map(&:to_i).sort == user_course_groups.sort # 如果是设置为全部班级,则问卷不用分组,且问卷设定为统一设置,否则则分组设置
user_course_groups = @course.course_groups.pluck(:id)
if g_course.map(&:to_i).sort == user_course_groups.sort &&
((params[:detail] && group_end_times.min == group_end_times.max) || params[:detail].blank?) # 如果是设置为全部班级,则问卷不用分组,且问卷设定为统一设置,否则则分组设置
poll.poll_group_settings.destroy_all
poll_unified = true
e_time = ex_end_time
e_time = params[:detail] ? group_end_times.max : ex_end_time
else
poll_unified = false
g_course.each do |i|
g_course.each_with_index do |i, index|
poll_group_setting = poll.poll_group_settings.find_in_poll_group("course_group_id",i).first #根据课堂分班的id寻找问卷所在的班级
group_end_time = params[:detail] ? group_end_times[index] : ex_end_time
if poll_group_setting #如果该问卷分组存在,则更新,否则新建
poll_group_setting.update_attributes(publish_time:Time.now,end_time:ex_end_time)
poll_group_setting.update_attributes(publish_time: Time.now, end_time: group_end_time)
else
p_course_group = {
:poll_id => poll.id,
:course_group_id => i,
:course_id => poll.course.id,
:publish_time => Time.now,
:end_time => ex_end_time,
:end_time => group_end_time,
}
new_poll_group = poll.poll_group_settings.new p_course_group
new_poll_group.save

@ -90,23 +90,25 @@ class QuestionBanksController < ApplicationController
def send_to_course
banks = @object_type.classify.constantize.where(id: params[:object_id])
course = current_user.manage_courses.find_by!(id: params[:course_id])
task_ids = []
banks.each do |bank|
case @object_type
when 'HomeworkBank' # 作业
quote_homework_bank bank, course
task = quote_homework_bank bank, course
when 'ExerciseBank'
if bank.container_type == 'Exercise' # 试卷
quote_exercise_bank bank, course
task = quote_exercise_bank bank, course
else # 问卷
quote_poll_bank bank, course
task = quote_poll_bank bank, course
end
when 'GtaskBank'
quote_gtask_bank bank, course
task = quote_gtask_bank bank, course
when 'GtopicBank'
quote_gtopic_bank bank, course
task = quote_gtopic_bank bank, course
end
task_ids << task.id if task
end
normal_status("发送成功")
render :json => {task_ids: task_ids, status: 0, message: "发送成功"}
end
def destroy

@ -1,5 +1,17 @@
module CoursesHelper
def member_manager group, teachers
str = ""
members = teachers.select{|teacher| teacher.teacher_course_groups.pluck(:course_group_id).include?(group.id) || teacher.teacher_course_groups.size == 0}
str = members.uniq.size == teachers.size ? "全部教师" : members.map{|member| member.user.real_name}.join("")
str
# teachers.each do |member|
# if member.teacher_course_groups.exists?(course_group_id: group.id) || member.teacher_course_groups.size == 0
# str << member.user.real_name
# end
# end
end
# 是否有切换为学生的入口
def switch_student_role is_teacher, course, user
is_teacher && course.course_members.where(user_id: user.id, role: %i(STUDENT)).exists?

@ -48,8 +48,8 @@ module Util
return if str.blank?
case type
when :phone then "#{str[0..2]}***#{str[-4..-1]}"
when :email then "#{str[0..2]}***#{str[str.rindex('@')..-1]}"
when :phone then "#{str[0..2]}***#{str[-3..-1]}"
when :email then "#{str[0]}***#{str[(str.rindex('@')-1)..-1]}"
else "#{str[0..2]}***#{str[-3..-1]}"
end
end

@ -242,6 +242,11 @@ class User < ApplicationRecord
user_extension&.department&.name || ''
end
# 课堂的所有身份
def course_role course
course.course_members.where(user_id: id).pluck(:role)
end
# 课堂的老师(创建者、老师、助教)
def teacher_of_course?(course)
course.course_members.exists?(user_id: id, role: [1,2,3], is_active: 1) || admin? || business?
@ -583,6 +588,16 @@ class User < ApplicationRecord
mail.present?
end
# 手机号123***123
def hidden_phone
Util.conceal(phone, :phone).to_s
end
# 邮箱w***l@qq.com
def hidden_mail
Util.conceal(mail, :email).to_s
end
# 学院的url标识
def college_identifier
Department.find_by_id(department_members.pluck(:department_id).first)&.identifier

@ -0,0 +1,11 @@
json.course_groups @course_groups.each do |group|
json.(group, :id, :course_members_count, :name)
json.invite_code group.invite_code if @user_course_identity < Course::STUDENT
json.member_manager member_manager(group, @teachers) if @user_course_identity < Course::NORMAL
end
if @user_course_identity == Course::STUDENT
json.current_group_id @current_group_id
end
json.none_group_member_count @course.none_group_count
json.group_count @all_group_count

@ -1,12 +1,17 @@
json.students do
json.array! @students do |student|
json.user_id student.user_id
json.login student.user.try(:login)
# json.login student.user.try(:login)
json.name student.user.try(:real_name)
json.name_link user_path(student.user)
json.student_id student.user.try(:student_id)
json.course_group_name student.course_group.try(:name)
json.course_member_id student.id
if @user_course_identity < Course::ASSISTANT_PROFESSOR && !params[:course_group_id].present?
json.member_roles student.user.course_role(@course)
end
json.user_phone student.user.hidden_phone
json.user_mail student.user.hidden_mail
end
end
json.students_count @students_count

@ -16,6 +16,9 @@ json.teacher_list do
end
json.graduation_group teacher.graduation_group.try(:name)
json.graduation_group_id teacher.graduation_group.try(:id)
if @user_course_identity < Course::ASSISTANT_PROFESSOR
json.member_roles teacher.user.course_role(@course)
end
end
end
json.teacher_list_size @teacher_list_size

@ -1,6 +1,6 @@
json.course_is_end @course.is_end # true表示已结束false表示未结束
json.extract! @exercise, :id,:exercise_name,:exercise_description,:show_statistic
json.time @user_left_time
json.time (@user_left_time.to_i / 60)
json.exercise_status @ex_status

@ -0,0 +1,6 @@
json.course_groups @course_groups do |group|
json.id group.id
json.name group.name
json.end_time @group_settings.select{|group_setting| group_setting.course_group_id == group.id}.first&.end_time
end
json.end_time @exercise.end_time

@ -1,4 +1,6 @@
json.course_groups @course_groups do |group|
json.id group.id
json.name group.name
json.end_time @group_settings.select{|group_setting| group_setting.course_group_id == group.id}.first&.end_time
end
json.end_time @homework.end_time

@ -0,0 +1,6 @@
json.course_groups @course_groups do |group|
json.id group.id
json.name group.name
json.end_time @group_settings.select{|group_setting| group_setting.course_group_id == group.id}.first&.end_time
end
json.end_time @poll.end_time

@ -1,5 +1,7 @@
json.extract! observed_user, :id, :nickname, :phone, :mail, :show_realname
json.extract! observed_user, :id, :nickname, :show_realname
json.phone observed_user.hidden_phone
json.mail observed_user.hidden_mail
json.avatar_url url_to_avatar(observed_user)
user = ActiveDecorator::Decorator.instance.decorate(observed_user)
json.name user.name

@ -331,6 +331,7 @@ Rails.application.routes.draw do
post 'join_graduation_group'
post 'set_course_group'
post 'change_course_admin'
post 'change_member_role'
post 'change_course_teacher'
post 'delete_course_teacher'
post 'teacher_application_review'
@ -369,6 +370,8 @@ Rails.application.routes.draw do
post 'join_excellent_course'
get 'tasks_list'
post 'update_task_position'
get 'course_groups'
post 'join_course_group'
end
collection do
@ -584,6 +587,7 @@ Rails.application.routes.draw do
post :cancel_publish #撤销发布
get :cancel_publish_modal #撤销发布的弹窗
get :common_header
get :publish_groups
end
resources :poll_questions,only:[:new,:create]
end
@ -615,6 +619,7 @@ Rails.application.routes.draw do
get :exercise_result
post :cancel_exercise
get :begin_commit #提交前的弹窗
get :publish_groups
end
resources :exercise_questions,only:[:new,:create,:index]
end

@ -41,7 +41,9 @@ function ChangeRolePop({ member_roles = [], record, courseId, onChangeRoleSucces
user_id: record.user_id
})
if (response.data.status == 0) {
showNotification('保存成功')
onChangeRoleSuccess()
trigger('updatabanner')
}
console.log(response)
}

@ -814,7 +814,7 @@ class studentsList extends Component{
</div>
<Spin size="large" spinning={this.state.isSpin}>
<div className="clearfix stu_table">
{!this.state.isSpin && <Checkbox.Group style={{ width: '100%' }} onChange={this.onCheckBoxChange} value={checkBoxValues}>
{students && students.length && <Checkbox.Group style={{ width: '100%' }} onChange={this.onCheckBoxChange} value={checkBoxValues}>
<Table columns={buildColumns(this,isParent)} dataSource={students} onChange={this.onTableChange} pagination={false}></Table>
</Checkbox.Group> }
</div>

@ -354,8 +354,8 @@ class ShixunhomeWorkItem extends Component{
<span className="mr50 df">
{/* <a href="/users/innov" className="panel-name-small hide fl mr15 mr30 color-grey3">{discussMessage.author.name}</a> */}
{ discussMessage.author && <span className="mr15 color-grey-3">{discussMessage.author}</span> }
{discussMessage.commit_count===undefined?"":<span className="mr15 color-grey9">{discussMessage.commit_count} 已开始做题</span>}
{discussMessage.uncommit_count===undefined?"":<span className="mr15 color-grey9">{discussMessage.uncommit_count} 未开始做题</span>}
{discussMessage.commit_count===undefined?"":<span className="mr15 color-grey9">已开始做题 {discussMessage.commit_count}</span>}
{discussMessage.uncommit_count===undefined?"":<span className="mr15 color-grey9">未开始做题 {discussMessage.uncommit_count}</span>}
{/*<span className="mr15 color-grey9">{discussMessage.replies_count} 3 未评</span>*/}
{

Loading…
Cancel
Save