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

dev_course
cxt 5 years ago
commit a189f57844

@ -151,6 +151,8 @@ class AccountsController < ApplicationController
send_type = verify_type(login_type, type) send_type = verify_type(login_type, type)
verification_code = code.sample(6).join verification_code = code.sample(6).join
logger.info("########get_verification_code: login_type #{login_type} send_type#{send_type}, ")
# 记录验证码 # 记录验证码
check_verification_code(verification_code, send_type, value) check_verification_code(verification_code, send_type, value)
sucess_status sucess_status

@ -32,38 +32,34 @@ class ExercisesController < ApplicationController
@exercises_all = @course.exercises @exercises_all = @course.exercises
member_show_exercises = @exercises_all.is_exercise_published #已发布的或已截止的试卷 member_show_exercises = @exercises_all.is_exercise_published #已发布的或已截止的试卷
@current_user_ = current_user @current_user_ = current_user
@exercises_count = @exercises_all.size # 全部页面,需返回
@exercises_unpublish_counts = @exercises_all.exercise_by_status(1).size #未发布的试卷数
@exercises_published_counts = @exercises_all.exercise_by_status([2,3]).size # 已发布的试卷数,包含已截止的
@exercises_ended_counts = @exercises_all.exercise_by_status(3).size #已截止的试卷数
# 课堂的学生人数 # 课堂的学生人数
@course_all_members = @course.students #当前课堂的全部学生 @course_all_members = @course.students #当前课堂的全部学生
@course_all_members_count = @course_all_members.size #当前课堂的学生数
@current_student = @course_all_members.course_find_by_ids("user_id",current_user.id) #当前用户是否为课堂的学生 @current_student = @course_all_members.course_find_by_ids("user_id",current_user.id) #当前用户是否为课堂的学生
# exercises的不同用户群体的显示 # exercises的不同用户群体的显示
if @user_course_identity < Course::STUDENT # @is_teacher_or 1为老师/管理员/助教 if @user_course_identity < Course::STUDENT # @is_teacher_or 1为老师/管理员/助教
@is_teacher_or = 1 @is_teacher_or = 1
# @teacher_groups_ids = @course.teacher_course_groups.get_user_groups(current_user.id).pluck(:course_group_id).reject(&:blank?) @exercises = @exercises_all #老师能看到全部的试卷,不管是已发布的/未发布的/已截止的/统一设置的/私有设置的(看到内容不同)
@exercises = @exercises_all #老师能看到全部的试卷,不管是已发布的/未发布的/已截止的/统一设置的/私有设置的(看到内容不同)
elsif @user_course_identity == Course::STUDENT # 2为课堂成员能看到统一设置的和自己班级的 elsif @user_course_identity == Course::STUDENT # 2为课堂成员能看到统一设置的和自己班级的
@is_teacher_or = 2 @is_teacher_or = 2
# get_exercise_left_time(@exercise,current_user) # get_exercise_left_time(@exercise,current_user)
member_group_id = @current_student.first.try(:course_group_id).to_i # 成员的分班id默认为0 member_group_id = @current_student.first.try(:course_group_id).to_i # 成员的分班id默认为0
if member_group_id == 0 #表示是课堂的未分班成员,只能查看统一设置的试卷(已发布的/已截止的) if member_group_id == 0 #表示是课堂的未分班成员,只能查看统一设置的试卷(已发布的/已截止的)
@exercises = member_show_exercises.present? ? member_show_exercises.unified_setting : [] @exercises = member_show_exercises.exists? ? member_show_exercises.unified_setting : []
else #已分班级的成员,可以查看统一设置和单独设置(试卷是发布在该班级)试卷 else #已分班级的成员,可以查看统一设置和单独设置(试卷是发布在该班级)试卷
# 已发布 当前用户班级分组的 试卷id # 已发布 当前用户班级分组的 试卷id
exercise_settings_ids = @course.exercise_group_settings.exercise_group_published exercise_settings_ids = @course.exercise_group_settings.exercise_group_published
.where(course_group_id: member_group_id).pluck(:exercise_id).uniq .where(course_group_id: member_group_id).pluck(:exercise_id).uniq
@exercises = member_show_exercises.present? ? @exercises = member_show_exercises.exists? ?
member_show_exercises.unified_setting.or(member_show_exercises.where(id: exercise_settings_ids)) member_show_exercises.unified_setting.or(member_show_exercises.where(id: exercise_settings_ids))
: [] : []
end end
else #用户未登陆或不是该课堂成员,仅显示统一设置的(已发布的/已截止的),如有公开,则不显示锁,不公开,则显示锁 else #用户未登陆或不是该课堂成员,仅显示统一设置的(已发布的/已截止的),如有公开,则不显示锁,不公开,则显示锁
@is_teacher_or = 0 @is_teacher_or = 0
@exercises = member_show_exercises.present? ? member_show_exercises.unified_setting : [] @exercises = member_show_exercises.exists? ? member_show_exercises.unified_setting : []
end end
if @exercises.size > 0 if @exercises.size > 0
if params[:type].present? if params[:type].present?
choose_type = params[:type].to_i choose_type = params[:type].to_i
@ -74,12 +70,12 @@ class ExercisesController < ApplicationController
exercise_settings_ids = exercise_groups_sets.pluck(:exercise_id) exercise_settings_ids = exercise_groups_sets.pluck(:exercise_id)
exercise_ended_ids = exercise_groups_sets.exercise_group_ended.pluck(:exercise_id).uniq exercise_ended_ids = exercise_groups_sets.exercise_group_ended.pluck(:exercise_id).uniq
if choose_type == 2 if choose_type == 2
@exercises = @exercises_all.present? ? @exercises = @exercises_all.exists? ?
@exercises_all.exercise_by_status(2).unified_setting @exercises_all.exercise_by_status(2).unified_setting
.or(@exercises_all.where(id: (exercise_settings_ids - exercise_ended_ids).uniq)) .or(@exercises_all.where(id: (exercise_settings_ids - exercise_ended_ids).uniq))
: [] : []
elsif choose_type == 3 elsif choose_type == 3
@exercises = @exercises_all.present? ? @exercises = @exercises_all.exists? ?
@exercises_all.exercise_by_status(3).unified_setting @exercises_all.exercise_by_status(3).unified_setting
.or(@exercises_all.where(id: exercise_ended_ids)) .or(@exercises_all.where(id: exercise_ended_ids))
: [] : []
@ -106,6 +102,11 @@ class ExercisesController < ApplicationController
@exercises = [] @exercises = []
end end
@course_all_members_count = @course_all_members.size #当前课堂的学生数
@exercises_count = @exercises_all.size # 全部页面,需返回
@exercises_unpublish_counts = @exercises_all.exercise_by_status(1).size #未发布的试卷数
@exercises_published_counts = @exercises_count - @exercises_unpublish_counts # 已发布的试卷数,包含已截止的
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) uid_logger_error(e.message)
tip_exception(e.message) tip_exception(e.message)

@ -538,6 +538,7 @@ class GamesController < ApplicationController
# 编程题评测 # 编程题评测
def game_build def game_build
sec_key = params[:sec_key]
game_challenge = Challenge.select([:id, :position, :picture_path]).find(@game.challenge_id) game_challenge = Challenge.select([:id, :position, :picture_path]).find(@game.challenge_id)
# 更新评测次数 # 更新评测次数
@ -585,7 +586,7 @@ class GamesController < ApplicationController
:instanceChallenge => "#{step}", :testCases => "#{testCases}", :resubmit => "#{resubmit}", :instanceChallenge => "#{step}", :testCases => "#{testCases}", :resubmit => "#{resubmit}",
:times => params[:first].to_i, :podType => @shixun.webssh, :content_modified => content_modified, :times => params[:first].to_i, :podType => @shixun.webssh, :content_modified => content_modified,
:containers => "#{Base64.urlsafe_encode64(shixun_container_limit(@shixun))}", :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(@shixun))}",
:persistenceName => @shixun.identifier, :tpmScript => "#{tpmScript}", :persistenceName => @shixun.identifier, :tpmScript => "#{tpmScript}", :sec_key => sec_key,
:timeLimit => "#{@shixun.exec_time}", :isPublished => (@shixun.status < 2 ? 0 : 1) } :timeLimit => "#{@shixun.exec_time}", :isPublished => (@shixun.status < 2 ? 0 : 1) }
# 评测有文件输出的需要特殊传字段 path表示文件存储的位置 # 评测有文件输出的需要特殊传字段 path表示文件存储的位置

@ -1,10 +1,15 @@
class GitsController < ApplicationController class GitsController < ApplicationController
#供git-workhorse反向调用认证 # 说明:
# 以下Git认证只针对新版gitGitlab的Git认证不走该控制器
# 思路:
# 1、用户通过Git客户端推送代码的时候这个时候Git客户端肯定会强制用户输入邮箱的
# 2、通过web端版本库界面更新代码如果用户邮箱不存在则用系统备用邮箱
# 供 git-workhorse反向调用认证
def auth def auth
# HTTP_AUTHORIZATION: "Basic 这里base64编码的的密码(user:passwd)" # HTTP_AUTHORIZATION: "Basic 这里base64编码的的密码(user:passwd)"
logger.info("11111112222223333 HTTP_AUTHORIZATION: #{request.env["HTTP_AUTHORIZATION"]}") logger.info("11111112222223333 HTTP_AUTHORIZATION: #{request.env["HTTP_AUTHORIZATION"]}")
#logger.info("#########-----request_env: #{request.env}") # logger.info("#########-----request_env: #{request.env}")
# {"service"=>"git-receive-pack", "controller"=>"gits", "action"=>"auth", # {"service"=>"git-receive-pack", "controller"=>"gits", "action"=>"auth",
# "url"=>"forge01/cermyt39.git/info/refs"} # "url"=>"forge01/cermyt39.git/info/refs"}
# #

@ -207,9 +207,10 @@ class HomeworkCommonsController < ApplicationController
format.xlsx{ format.xlsx{
student_work_to_xlsx(@work_excel,@homework) student_work_to_xlsx(@work_excel,@homework)
exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S') exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
response.set_header("Content-Disposition","attachment; filename=#{exercise_export_name.strip.first(30)}};filename*=utf-8''#{exercise_export_name.strip.first(30)}}") # response.set_header("Content-Disposition","attachment; filename=#{exercise_export_name.strip.first(30)}};filename*=utf-8''#{exercise_export_name.strip.first(30)}}")
file_name = Base64.urlsafe_encode64(exercise_export_name.strip.first(30))
# response.setHeader['Content-Disposition'] = "attachment; filename=\"#{exercise_export_name.strip.first(30)}\"" # response.setHeader['Content-Disposition'] = "attachment; filename=\"#{exercise_export_name.strip.first(30)}\""
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals: render xlsx: "#{file_name}",template: "homework_commons/works_list.xlsx.axlsx",locals:
{table_columns: @work_head_cells,task_users: @work_cells_column} {table_columns: @work_head_cells,task_users: @work_cells_column}
} }
end end

@ -85,9 +85,6 @@ class MyshixunsController < ApplicationController
# "createPod":"1.610","evaluateAllTime":2820,"evaluateStart":"2017-11-24 11:04:35","execute":"0.294"}' # "createPod":"1.610","evaluateAllTime":2820,"evaluateStart":"2017-11-24 11:04:35","execute":"0.294"}'
# params[:pics] = "a.png,b.png,c.png" # params[:pics] = "a.png,b.png,c.png"
def training_task_status def training_task_status
logger.info("123################{params[:jsonTestDetails]}")
logger.info("456################{params[:timeCost]}")
logger.info("666###############{params}")
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
@ -98,13 +95,14 @@ class MyshixunsController < ApplicationController
return_back_time = format("%.3f", ( t1.to_f - brige_end_time.to_f)).to_f return_back_time = format("%.3f", ( t1.to_f - brige_end_time.to_f)).to_f
status = jsonTestDetails['status'] status = jsonTestDetails['status']
game_id = jsonTestDetails['buildID'] game_id = jsonTestDetails['buildID']
sec_key = jsonTestDetails['sec_key']
logger.info("training_task_status start#1**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") logger.info("training_task_status start#1**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}")
resubmit = jsonTestDetails['resubmit'] resubmit = jsonTestDetails['resubmit']
outPut = tran_base64_decode64(jsonTestDetails['outPut']) outPut = tran_base64_decode64(jsonTestDetails['outPut'])
jenkins_testsets = jsonTestDetails['msg'] jenkins_testsets = jsonTestDetails['msg']
compile_success = jsonTestDetails['compileSuccess'] compile_success = jsonTestDetails['compileSuccess']
# message = Base64.decode64(params[:msg]) unless params[:msg].blank? # message = Base64.decode64(params[:msg]) unless params[:msg].blank?
logger.info(outPut)
game = Game.find(game_id) game = Game.find(game_id)
myshixun = game.myshixun myshixun = game.myshixun
challenge = game.challenge challenge = game.challenge
@ -125,7 +123,7 @@ class MyshixunsController < ApplicationController
logger.info "actual_output:################################################# #{actual_output}" logger.info "actual_output:################################################# #{actual_output}"
Output.create!(:code => status, :game_id => game_id, :out_put => outPut, :test_set_position => j_test_set['caseId'], Output.create!(:code => status, :game_id => game_id, :out_put => outPut, :test_set_position => j_test_set['caseId'],
:actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => max_query_index, :actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => max_query_index,
:compile_success => compile_success.to_i) :compile_success => compile_success.to_i, :sec_key => sec_key)
# 如果设置了按测试集给分,则需要统计测试集的分值 # 如果设置了按测试集给分,则需要统计测试集的分值
if challenge.test_set_score && j_test_set['passed'].to_i == 1 if challenge.test_set_score && j_test_set['passed'].to_i == 1
test_set_score += challenge.test_sets.where(:position => j_test_set['caseId']).pluck(:score).first test_set_score += challenge.test_sets.where(:position => j_test_set['caseId']).pluck(:score).first

@ -0,0 +1,25 @@
class Users::InterestsController < Users::BaseController
before_action :require_login
before_action :private_user_resources!
def create
identity = params[:identity].to_s.strip
extension = observed_user.user_extension || observed_user.build_user_extension
return render_error('请选择职业') unless %w(teacher student professional).include?(identity)
ActiveRecord::Base.transaction do
extension.update_column(:identity, identity)
# 兴趣
observed_user.user_interests.delete_all
UserInterest.bulk_insert(:user_id, :repertoire_id) do |worker|
(Repertoire.pluck(:id) & Array.wrap(params[:interest_ids]).map(&:to_i)).each do |repertoire_id|
worker.add(user_id: observed_user.id, repertoire_id: repertoire_id)
end
end
end
render_ok
end
end

@ -251,15 +251,14 @@ module ExercisesHelper
#获取试卷的已答/未答人数 #获取试卷的已答/未答人数
def get_exercise_answers(ex_users) def get_exercise_answers(ex_users)
@commit_ex_users = ex_users.commit_exercise_by_status(1) #当前老师的全部学生中已提交的 @exercise_answers = ex_users.commit_exercise_by_status(1).size #表示已经提交了的用户
course_all_members_count = ex_users.exists? ? ex_users.size : 0
@exercise_answers = @commit_ex_users.present? ? @commit_ex_users.size : 0 #表示已经提交了的用户
course_all_members_count = ex_users.present? ? ex_users.size : 0
@exercise_unanswers = (course_all_members_count - @exercise_answers) @exercise_unanswers = (course_all_members_count - @exercise_answers)
end end
def exercise_index_show(exercise,course,is_teacher_or,user) def exercise_index_show(exercise,course,is_teacher_or,user)
# exercise_all_users = exercise.exercise_users # exercise_all_users = exercise.exercise_users
# lock_icon 0出现锁1不出现锁
ex_show_text = [] ex_show_text = []
if course.is_end #课堂停止后,试卷显示为已结束 if course.is_end #课堂停止后,试卷显示为已结束
@ -280,6 +279,7 @@ module ExercisesHelper
else else
ex_show_text ex_show_text
end end
if is_teacher_or == 1 if is_teacher_or == 1
exercise_users_list = exercise.all_exercise_users(user.id) #当前老师所在班级的全部学生 exercise_users_list = exercise.all_exercise_users(user.id) #当前老师所在班级的全部学生
unreview_count = exercise_users_list.exercise_unreview.size unreview_count = exercise_users_list.exercise_unreview.size
@ -288,7 +288,7 @@ module ExercisesHelper
exercise_publish_time = ex_pb_time[:publish_time] exercise_publish_time = ex_pb_time[:publish_time]
exercise_end_time = ex_pb_time[:end_time] exercise_end_time = ex_pb_time[:end_time]
current_status = 3 current_status = 3
lock_icon = 1 #不显示锁图标 lock_icon = 0
if exercise_status == 1 if exercise_status == 1
ex_show_text.push("未发布") ex_show_text.push("未发布")
elsif exercise_status == 3 elsif exercise_status == 3
@ -302,7 +302,7 @@ module ExercisesHelper
exercise_publish_time = ex_pb_time[:publish_time] exercise_publish_time = ex_pb_time[:publish_time]
exercise_end_time = ex_pb_time[:end_time] exercise_end_time = ex_pb_time[:end_time]
current_status = exercise.check_user_answer_status(user) current_status = exercise.check_user_answer_status(user)
lock_icon = 1 #不显示锁图标 lock_icon = 0
if current_status == 4 if current_status == 4
ex_show_text.push("未提交") ex_show_text.push("未提交")
end end
@ -314,16 +314,20 @@ module ExercisesHelper
unreview_count = nil unreview_count = nil
if exercise.is_public if exercise.is_public
current_status = exercise.check_user_answer_status(user) current_status = exercise.check_user_answer_status(user)
lock_icon = 1 #非课堂成员,但是试卷为公开的,不加 lock_icon = 1 #不出现
if current_status == 4 if current_status == 4
ex_show_text.push("未提交") ex_show_text.push("未提交")
end end
else else
current_status = 4 current_status = 4
lock_icon = 0 #显示锁图标 lock_icon = 0
end end
end end
if (course.is_public == 1) && exercise.is_public
lock_icon = 1
end
if exercise_status > 1 if exercise_status > 1
show_unreview_count = unreview_count show_unreview_count = unreview_count
else else
@ -332,8 +336,6 @@ module ExercisesHelper
if exercise_status == 2 && exercise_end_time.present? if exercise_status == 2 && exercise_end_time.present?
ex_left_time = how_much_time(exercise_end_time) ex_left_time = how_much_time(exercise_end_time)
# elsif exercise_status == 3 && course.end_date.present?
# ex_left_time = how_much_time(course.end_date.to_time)
else #已截止后不显示时间 else #已截止后不显示时间
ex_left_time = nil ex_left_time = nil
end end
@ -721,8 +723,8 @@ module ExercisesHelper
if ex_time > 0 if ex_time > 0
exercise_user = exercise.exercise_users.find_by(user_id:user.id) exercise_user = exercise.exercise_users.find_by(user_id:user.id)
time_mill = ex_time * 60 #转为秒 time_mill = ex_time * 60 #转为秒
exercise_end_time = exercise.end_time.present? ? exercise.end_time.to_i : 0 exercise_end_time = exercise.end_time.exists? ? exercise.end_time.to_i : 0
exercise_user_start = exercise_user&.start_at.present? ? exercise_user.start_at.to_i : 0 exercise_user_start = exercise_user&.start_at.exists? ? exercise_user.start_at.to_i : 0
#用户未开始答题时即exercise_user_start为0 #用户未开始答题时即exercise_user_start为0
if exercise_user_start == 0 if exercise_user_start == 0
if (exercise_end_time - time_now_i) > time_mill if (exercise_end_time - time_now_i) > time_mill

@ -69,11 +69,7 @@ class Exercise < ApplicationRecord
def common_published_ids(user_id) def common_published_ids(user_id)
current_user_groups = course.teacher_course_ids(user_id) current_user_groups = course.teacher_course_ids(user_id)
if unified_setting if unified_setting
if course.none_group_count > 0 #有未分班的,则发布到未发布分班 un_group_ids = (course.none_group_count > 0) ? [0] : []
un_group_ids = [0]
else
un_group_ids = []
end
published_group_ids = (current_user_groups + un_group_ids).uniq #统一设置时为当前用户的分班id及未分班 published_group_ids = (current_user_groups + un_group_ids).uniq #统一设置时为当前用户的分班id及未分班
else else
ex_group_setting = exercise_group_settings.pluck("course_group_id").uniq ex_group_setting = exercise_group_settings.pluck("course_group_id").uniq
@ -89,11 +85,7 @@ class Exercise < ApplicationRecord
ex_group_settings = exercise_group_settings.pluck(:course_group_id) ex_group_settings = exercise_group_settings.pluck(:course_group_id)
member = course.course_members.course_find_by_ids("user_id",user_id) member = course.course_members.course_find_by_ids("user_id",user_id)
member_group_id = member.pluck(:course_group_id).uniq member_group_id = member.pluck(:course_group_id).uniq
if (member_group_id & ex_group_settings).size > 0 || user_identity < Course::STUDENT ((member_group_id & ex_group_settings).size > 0 || user_identity < Course::STUDENT) ? true : false
true
else
false
end
end end
#判断是否为分班,如果分班,试卷的截止时间为当前分班时间,否则为试卷的截止时间 #判断是否为分班,如果分班,试卷的截止时间为当前分班时间,否则为试卷的截止时间
@ -130,11 +122,11 @@ class Exercise < ApplicationRecord
else else
ex_group_setting = exercise_group_settings ex_group_setting = exercise_group_settings
user_group = course.students.course_find_by_ids("user_id",user_id) user_group = course.students.course_find_by_ids("user_id",user_id)
if user_group.present? if user_group.exists?
user_group_id = user_group.first.course_group_id user_group_id = user_group.first.course_group_id
user_ex_group_setting = ex_group_setting.find_in_exercise_group("course_group_id",user_group_id) user_ex_group_setting = ex_group_setting.find_in_exercise_group("course_group_id",user_group_id)
pb_time = user_ex_group_setting.present? ? user_ex_group_setting.first.publish_time : nil pb_time = user_ex_group_setting.exists? ? user_ex_group_setting.first.publish_time : nil
en_time = user_ex_group_setting.present? ? user_ex_group_setting.first.end_time : nil en_time = user_ex_group_setting.exists? ? user_ex_group_setting.first.end_time : nil
else else
pb_time = nil pb_time = nil
en_time = nil en_time = nil
@ -152,10 +144,10 @@ class Exercise < ApplicationRecord
ex_answer_user = exercise_users.find_by(user_id: user.id) ex_answer_user = exercise_users.find_by(user_id: user.id)
user_ex_status = get_exercise_status(user.id) user_ex_status = get_exercise_status(user.id)
user_status = 2 user_status = 2
if ex_answer_user.present? && (ex_answer_user.start_at.present? || ex_answer_user.end_at.present?) #学生有过答题的,或者立即截止,但学生未做试卷的 if ex_answer_user.exists? && (ex_answer_user.start_at.exists? || ex_answer_user.end_at.exists?) #学生有过答题的,或者立即截止,但学生未做试卷的
user_status = ex_answer_user.commit_status user_status = ex_answer_user.commit_status
end end
if ex_answer_user.present? && ex_answer_user.start_at.blank? && user_ex_status == 3 if ex_answer_user.exists? && ex_answer_user.start_at.blank? && user_ex_status == 3
user_status = 4 user_status = 4
end end

@ -2,4 +2,5 @@ class Repertoire < ApplicationRecord
has_many :sub_repertoires, ->{order(updated_at: :desc)}, :dependent => :destroy has_many :sub_repertoires, ->{order(updated_at: :desc)}, :dependent => :destroy
has_many :tag_repertoires, through: :sub_repertoires has_many :tag_repertoires, through: :sub_repertoires
has_many :user_interests, dependent: :delete_all
end end

@ -115,6 +115,10 @@ class User < ApplicationRecord
has_many :attendances has_many :attendances
# 兴趣
has_many :user_interests, dependent: :delete_all
has_many :interests, through: :user_interests, source: :repertoire
# Groups and active users # Groups and active users
scope :active, lambda { where(status: STATUS_ACTIVE) } scope :active, lambda { where(status: STATUS_ACTIVE) }

@ -0,0 +1,4 @@
class UserInterest < ApplicationRecord
belongs_to :user
belongs_to :repertoire
end

@ -1,22 +1,4 @@
json.exercises_counts do
json.exercises_total_counts @exercises_count #全部试卷数
json.exercises_all_counts @exercises_select_count #选择后的全部试卷数
json.exercises_unpublish_counts @exercises_unpublish_counts #未发布试卷数
json.exercises_published_counts @exercises_published_counts #已发布试卷数
json.exercises_ended_counts @exercises_ended_counts #已截止试卷数
json.left_banner_id @left_banner_id
json.left_banner_name @left_banner_name
end
json.course_types do
json.course_status @course.is_end ? 1 : 0 #课堂的当前是否结束如结束则为1否则为0
json.course_end_time @course.end_date #课堂的截止时间
json.course_is_public @course.is_public #判断课堂是否为公开,只有公开课才有设为公开的按钮
json.user_permission @is_teacher_or # 当前用户存在且为课堂教师/管理员/超级管理员时为1 课堂成员为2否则为0
end
if @exercises_count > 0 if @exercises_count > 0
json.exercises do json.exercises do
json.array! @exercises do |exercise| json.array! @exercises do |exercise|
@ -43,3 +25,22 @@ else
json.exercises [] json.exercises []
end end
json.course_types do
json.course_status @course.is_end ? 1 : 0 #课堂的当前是否结束如结束则为1否则为0
json.course_end_time @course.end_date #课堂的截止时间
json.course_is_public @course.is_public #判断课堂是否为公开,只有公开课才有设为公开的按钮
json.user_permission @is_teacher_or # 当前用户存在且为课堂教师/管理员/超级管理员时为1 课堂成员为2否则为0
end
json.exercises_counts do
json.exercises_total_counts @exercises_count #全部试卷数
json.exercises_all_counts @exercises_select_count #选择后的全部试卷数
json.exercises_unpublish_counts @exercises_unpublish_counts #未发布试卷数
json.exercises_published_counts @exercises_published_counts #已发布试卷数
json.exercises_ended_counts @exercises_ended_counts #已截止试卷数
json.left_banner_id @left_banner_id
json.left_banner_name @left_banner_name
end

@ -47,6 +47,7 @@ Rails.application.routes.draw do
resource :experience_records, only: [:show] resource :experience_records, only: [:show]
resource :grade_records, only: [:show] resource :grade_records, only: [:show]
resource :watch, only: [:create, :destroy] resource :watch, only: [:create, :destroy]
resource :interest, only: [:create]
end end

@ -0,0 +1,5 @@
class AddSecKeyToOutputs < ActiveRecord::Migration[5.2]
def change
add_column :outputs, :sec_key, :string
end
end

@ -0,0 +1,8 @@
class CreateUserInterests < ActiveRecord::Migration[5.2]
def change
create_table :user_interests do |t|
t.references :user
t.references :repertoire
end
end
end
Loading…
Cancel
Save