init project

This commit is contained in:
Jasder
2020-03-09 00:40:16 +08:00
commit 2937b2a94d
6549 changed files with 7215173 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
json.extract! course, :id, :created_at, :updated_at
json.url course_url(course, format: :json)

View File

@@ -0,0 +1,7 @@
json.course_members @course_members.each do |member|
user = member.user
json.user_login user&.login
json.user_name user&.real_name
# json.course_group member.course_group_name
json.total_score member.score
end

View File

@@ -0,0 +1,13 @@
json.school_name @school_name
json.graduation_groups do
json.array! @graduation_groups do |graduation_group|
json.id graduation_group.id
json.name graduation_group.name
end
end
json.course_groups do
json.array! @course_groups do |course_group|
json.id course_group.id
json.name course_group.name
end
end

View File

@@ -0,0 +1,7 @@
json.course_groups do
json.array! @course_groups_array do |course_group|
json.id course_group.id
json.name course_group.name
end
end
json.course_groups_count @course_groups_array.size

View File

@@ -0,0 +1,15 @@
json.teacher_list_size @teacher_list_size
json.apply_size @applications_size
json.is_admin @is_admin
json.application_list do
json.array! @applications do |application|
json.application_id application.id
json.user_id application.course_message_id
json.name application.application_user.real_name
json.name_link user_path(application.application_user)
json.login application.application_user.login
json.image_url url_to_avatar(application.application_user)
json.school_name application.application_user.school_name
json.role application.content.to_i == 3 || application.content.to_i == 7 ? "助教" : application.content.to_i == 2 || application.content.to_i == 9 ? "教师" : ""
end
end

View File

@@ -0,0 +1,10 @@
json.has_course_groups @has_course_groups
json.course_modules do
json.array! @course_modules do |course_module|
json.id course_module.id
json.module_name course_module.module_name
json.course_second_categories do
json.array! course_module.course_second_categories, :id, :name
end
end
end

View File

@@ -0,0 +1,2 @@
json.course_id @course.id
json.course_name @course.name

View File

@@ -0,0 +1,10 @@
json.partial! 'commons/success'
json.data do
json.course_id @course.id
json.user_course_identity @current_user.course_identity(@course)
json.boards do
json.array! @boards, :id, :name
end
json.email_notify @course.email_notify
end

View File

@@ -0,0 +1,7 @@
json.course_groups do
json.array! @all_course_groups do |course_group|
json.id course_group.id
json.name course_group.name
json.checked @existed_course_group_ids.include? course_group.id
end
end

View File

@@ -0,0 +1,12 @@
json.course_groups @course_groups.each do |group|
json.(group, :id, :course_members_count, :name, :invite_code_halt)
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
json.edit_auth edit_auth(group, @teachers) if @user_course_identity < Course::STUDENT
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

View File

@@ -0,0 +1,3 @@
json.count @count
json.videos @videos, partial: 'users/videos/video', as: :video
json.course_id @course.id

View File

@@ -0,0 +1,2 @@
json.course_id @course.id
json.first_category_url module_url(@course.none_hidden_course_modules.first, @course)

View File

@@ -0,0 +1,29 @@
wb = xlsx_package.workbook
wb.use_shared_strings = true
wb.styles do |s|
no_wrap_sz = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: false,:horizontal => :center,:vertical => :center }
sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
row_cell = s.add_style :bg_color=> "FAEBDC",:border => { :style => :thin, :color =>"000000" },alignment: {wrap_text: true,:horizontal => :center,:vertical => :center }
blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 25,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center}
#课堂信息摘要
wb.add_worksheet(name:course_info[0]) do |sheet|
sheet.sheet_view.show_grid_lines = false
course_main_info = course_info[1]
course_group_info = course_info[2]
group_info_d = course_group_info[0]
group_info_detail = course_group_info[1]
course_main_info.each do |c|
sheet.add_row c, :style => sz_all #用户id
end
sheet["A1:A7"].each { |c| c.style = row_cell }
sheet.add_row [],:style => sz_all
if group_info_detail.count > 0
sheet.add_row group_info_d, :style => blue_cell
group_info_detail.each do |group|
sheet.add_row group, :style => sz_all #用户id
end
sheet.column_info.second.width = 40
end
end #add_worksheet
end

View File

@@ -0,0 +1,25 @@
wb = xlsx_package.workbook
wb.use_shared_strings = true
wb.styles do |s|
no_wrap_sz = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: false,:horizontal => :center,:vertical => :center }
sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
row_cell = s.add_style :bg_color=> "FAEBDC",:border => { :style => :thin, :color =>"000000" },alignment: {wrap_text: true,:horizontal => :center,:vertical => :center }
blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 25,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center}
#课堂活跃度统计
wb.add_worksheet(name:activity_level[0]) do |sheet|
sheet.sheet_view.show_grid_lines = false
sheet_title = activity_level[1]
sheet_content = activity_level[2]
sheet.add_row sheet_title, :height => 25,:style => blue_cell
if sheet_content.count > 0
sheet_content.each_with_index do |c,index|
c_1 = (index+1)
c_2 = [c_1] + c.values
sheet.add_row c_2, :height => 25, :style => sz_all #用户id
end
sheet.column_widths *([20]*sheet.column_info.count)
sheet.column_info.first.width = 8
end
end #add_worksheet
end

View File

@@ -0,0 +1,145 @@
wb = xlsx_package.workbook
wb.use_shared_strings = true
wb.styles do |s|
no_wrap_sz = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: false,:horizontal => :center,:vertical => :center }
sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
row_cell = s.add_style :bg_color=> "FAEBDC",:border => { :style => :thin, :color =>"000000" },alignment: {wrap_text: true,:horizontal => :center,:vertical => :center }
blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 25,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center}
#学生总成绩
wb.add_worksheet(name:course_scores[0]) do |sheet|
sheet.sheet_view.show_grid_lines = false
sheet_title = course_scores[1] #头部标题
sheet_title_counts = course_scores[2] #总成绩的作业数(包含每一项的总得分)如实训作业的作业数+总成绩
sheet_content = course_scores[3]
sheet_length = sheet_title.count
sheet.add_row [""]*sheet_length, :style => blue_cell
sheet.add_row [""]*sheet_length, :style => blue_cell
sheet.merge_cells("A1:A2")
sheet.merge_cells("B1:B2")
sheet.merge_cells("C1:C2")
sheet.merge_cells("D1:D2")
sheet.merge_cells("E1:E2")
sheet.merge_cells("F1:F2")
sheet.merge_cells("G1:G2")
sheet.merge_cells("H1:H2")
# sheet.merge_cells (Axlsx::cell_r(sheet_length-1,0) + ':' + Axlsx::cell_r(sheet_length-1,1)) #最后一行的合并
sheet_first = sheet.rows.first #第一行
sheet_second = sheet.rows.second #第二行
work_head_title = %w(实训作业 普通作业 分组作业 毕设任务 试卷)
(0..(sheet_length-1)).each do |i|
if i <= 7
sheet_first.cells[i].value = sheet_title[i]
else
sheet_second.cells[i].value = sheet_title[i]
end
end
st_col = 8
sheet_title_counts.each_with_index do |c,index|
end_col = (st_col + c - 1)
sheet.merge_cells sheet_first.cells[(st_col..end_col)]
sheet_first.cells[st_col].value = work_head_title[index.to_i]
st_col = end_col + 1
end
if sheet_content.count > 0
sheet_content.each_with_index do |c,index|
c_1 = (index+1)
c_2 = [c_1] + c
sheet.add_row c_2, :height => 25,:style => sz_all #用户id
end
end
sheet.column_widths *([15]*sheet.column_info.count)
sheet.column_info.first.width = 8
sheet.rows[1].height = 40
end #add_worksheet
#实训作业
if shixun_works.count > 0
shixun_works.each do |shixun|
wb.add_worksheet(name:shixun[0]) do |sheet|
head_title = shixun[1]
content_shixun = shixun[2]
sheet.sheet_view.show_grid_lines = false
sheet.add_row head_title, :style => blue_cell
if content_shixun.count > 0
content_shixun.each do |user|
sheet.add_row user, :height => 25,:style => sz_all
end #each_widh_index
end
sheet.column_widths *([20]*sheet.column_info.count)
sheet.column_info.first.width = 12
end #add_worksheet
end
end
#普通作业
if common_works.count > 0
common_works.each do |work|
wb.add_worksheet(name:work[0]) do |sheet|
head_title = work[1]
content_ = work[2]
sheet.sheet_view.show_grid_lines = false
sheet.add_row head_title, :style => blue_cell
if content_.count > 0
content_.each do |user|
sheet.add_row user, :height => 25,:style => no_wrap_sz
end #each_widh_index
end
sheet.column_widths *([20]*sheet.column_info.count)
sheet.column_info.first.width = 12
end #add_worksheet
end
end
#分组作业
if group_works.count > 0
group_works.each do |work|
wb.add_worksheet(name:work[0]) do |sheet|
head_title = work[1]
content_ = work[2]
sheet.sheet_view.show_grid_lines = false
sheet.add_row head_title, :style => blue_cell
if content_.count > 0
content_.each do |user|
sheet.add_row user, :height => 25,:style => sz_all
end #each_widh_index
end
sheet.column_widths *([20]*sheet.column_info.count)
sheet.column_info.first.width = 12
end #add_worksheet
end
end
#毕设任务
if task_works.count > 0
task_works.each do |task|
wb.add_worksheet(name:task[0]) do |sheet|
sheet.sheet_view.show_grid_lines = false
content_ = task[2]
sheet.add_row task[1], :style => blue_cell
content_.each do |user|
sheet.add_row user, :height => 25,:style => sz_all
end #each_widh_index
sheet.column_widths *([20]*sheet.column_info.count)
sheet.column_info.first.width = 12
end #add_worksheet
end
end
#试卷
if exercise_works.count > 0
exercise_works.each do |ex|
wb.add_worksheet(name: ex[0]) do |sheet|
sheet.sheet_view.show_grid_lines = false
content_ = ex[2]
sheet.add_row ex[1], :style => blue_cell
content_.each do |user|
sheet.add_row user, :height => 25,:style => sz_all #用户id
end #each_widh_index
sheet.column_widths *([20]*sheet.column_info.count)
sheet.column_info.first.width = 12
end #add_worksheet
end
end
end

View File

@@ -0,0 +1,9 @@
json.students do
json.array! @students do |student|
json.user_id student.user_id
json.name student.user.real_name
json.student_id student.user.student_id
json.school_name student.user.school_name
end
end
json.students_count @students_count

View File

@@ -0,0 +1,14 @@
json.courses do
json.array! @courses do |course|
if course.course_groups.present?
course.course_groups.each do |course_group|
json.name course.name + "-" + course_group.name
json.course_id course.id
json.course_group_id course_group.id
end
else
json.name course.name
json.course_id course.id
end
end
end

View File

@@ -0,0 +1,7 @@
json.graduation_group_list do
json.array! @graduation_group_list do |graduation_group|
json.id graduation_group.id
json.name graduation_group.name
end
end
json.graduation_groups_count @graduation_group_list.size

View File

@@ -0,0 +1,17 @@
json.courses @courses do |course|
json.id course.id
json.name course.name
json.avatar_url url_to_avatar(course.teacher)
json.creator course.teacher.real_name
json.school course.school&.name
json.technical_title "" # course.teacher.identity
json.course_members_count course.course_members_count
json.tasks_count get_tasks_count course
json.visits course.visits
json.is_public course.is_public
json.is_accessible course.is_public == 1 || @user.course_identity(course) < Course::NORMAL
json.is_end course.is_end
json.first_category_url module_url(course.none_hidden_course_modules.first, course)
json.excellent course.excellent
end
json.courses_count @courses_count

View File

@@ -0,0 +1,5 @@
json.informs @informs do |inform|
json.id inform.id
json.name inform.name
json.description inform.description
end

View File

@@ -0,0 +1,45 @@
json.is_teacher @is_teacher
json.course_modules @course_modules.each do |mod|
json.id mod.id
json.name mod.module_name
json.type mod.module_type
json.position mod.position
json.task_count course_task_count(@course, mod.module_type)
json.main_id mod.module_type == "board" ? @course.course_board.try(:id) : @course.id
json.category_url module_url(mod, @course)
if @second_category_type.include?(mod.module_type)
case mod.module_type
when "course_group"
# json.none_group_count @course.none_group_count
# json.second_category left_group_info @course
when "board"
course_board = @course.course_board
if course_board.present?
json.second_category course_board.children.each do |board|
json.category_id board.id
json.category_name board.name
json.position board.position
json.category_count board.messages_count
json.category_type "messages"
json.second_category_url "/courses/#{@course.id}/boards/#{board.id}"
end
end
else
json.second_category mod.course_second_categories.each do |category|
json.category_id category.id
json.category_name category.name
json.position category.position
json.category_count category_task_count(@course, category, @user)
json.category_type category.category_type_str
json.second_category_url category_url(category, @course)
end
end
end
end
json.hidden_modules @hidden_modules.each do |mod|
json.id mod.id
json.name mod.module_name
json.type mod.module_type
json.position mod.position
end

View File

@@ -0,0 +1,6 @@
json.partial! "commons/success"
json.data @courses do |course|
json.(course, :id, :name, :updated_at, :end_date)
json.created_at course.created_at.strftime("%Y-%m-%d")
end

View File

@@ -0,0 +1,12 @@
json.stages @stages do |stage|
json.partial! 'stages/stage', locals: {stage: stage, user: @user, subject: @subject, myshixuns: @myshixuns}
end
# json.description @subject&.description
json.start_learning @start_learning
json.subject_id @subject.id
json.learned @start_learning ? @course.my_subject_progress(@myshixuns) : 0
json.last_shixun @start_learning ? last_subject_shixun(@course, @myshixuns) : ""

View File

@@ -0,0 +1,5 @@
json.course_lists @course_lists do |course_list|
json.id course_list.id
json.name course_list.name
end
json.search_count @search_count

View File

@@ -0,0 +1,14 @@
json.candidates do
json.array! @users do |user|
json.id user.id
json.name user.real_name
json.nickname user.nickname
json.login user.login
json.school_name user.user_extension.school.try(:name)
json.school_id user.user_extension.school.try(:id)
json.added @course.course_member?(user.id, [1, 2, 3])
json.image_url url_to_avatar(user)
json.phone user.hidden_phone
end
end
json.candidates_count @users_size

View File

@@ -0,0 +1,11 @@
json.users do
json.array! @users do |user|
json.id user.id
json.login user.login
json.name user.real_name
json.student_id user&.student_id
json.school_name user&.school_name
json.added @course.course_member?(user.id, 4)
end
end
json.users_count @users_count

View File

@@ -0,0 +1,20 @@
json.course_list_id @course.course_list&.id
json.course_list_name @course.course_list&.name
json.name @course.name
json.course_id @course.id
json.school @course.school&.name
json.class_period @course.class_period
json.credit @course.credit
json.start_date @course.start_date
json.end_date @course.end_date
json.is_public @course.is_public
json.course_module_types @course.course_modules.where(hidden: 0).pluck(:module_type)
json.course_modules @course_modules do |module_type|
json.module_type module_type.module_type
json.hidden module_type.hidden
json.module_name module_type.module_name
end
json.authentication @course.authentication
json.professional_certification @course.professional_certification
json.subject_id @course.subject_id
json.excellent @course.excellent

View File

@@ -0,0 +1 @@
json.partial! "courses/course", course: @course

View File

@@ -0,0 +1,6 @@
json.top_scores @top_scores.each do |cm_score|
user = cm_score.user
json.user_name user.real_name
json.user_login user.login
json.avatar_url url_to_avatar(user)
end

View File

@@ -0,0 +1,21 @@
json.students do
json.array! @students do |student|
json.user_id student.user_id
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_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 @course.excellent ? "" : student.user.hidden_phone
json.user_mail @course.excellent ? "" : student.user.hidden_mail
end
end
json.students_count @students_count
if @course_group.present?
json.course_group_name @course_group.name
json.invite_code @course_group.invite_code
end

View File

@@ -0,0 +1,7 @@
json.tasks @tasks.each do |task|
json.user_name task.user.real_name
json.task_id task.id
json.task_name task.name
json.category task.course_second_category&.name
json.position task.position
end

View File

@@ -0,0 +1,26 @@
json.teacher_list do
json.array! @teacher_list do |teacher|
json.course_member_id teacher.id
json.name teacher.user.real_name
json.name_link user_path(teacher.user)
json.login teacher.user.login
json.user_id teacher.user.id
json.role teacher.role == "CREATOR" ? "管理员" : teacher.role == "PROFESSOR" ? "教师" : "助教"
json.course_groups do
if @course.course_groups_count > 0
json.array! @course.course_groups.select{|group| teacher.teacher_course_groups.pluck(:course_group_id).include?(group.id)} do |course_group|
json.name course_group.name
json.id course_group.id
end
end
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
json.apply_size @applications_size
json.is_admin @is_admin

View File

@@ -0,0 +1,28 @@
json.name @course.name
json.teacher_name @course.teacher.real_name
json.teacher_login @course.teacher.login
json.teacher_img url_to_avatar(@course.teacher)
json.teacher_school @course.school.try(:name)
json.teacher_count @course.course_member_count([1, 2, 3])
json.student_count @course.course_member_count(4)
json.course_group_count @course.course_groups_count
json.credit @course.credit
json.course_end @course.is_end
json.deadline course_end_date @course.end_date
json.educoder_teacher @user.is_teacher?
#json.is_student @is_student
json.is_admin @user_course_identity < Course::PROFESSOR
json.is_public @course.is_public == 1
json.code_halt @course.invite_code_halt == 1
json.invite_code @course.invite_code_halt == 0 ? @course.generate_invite_code : ""
json.switch_to_student @switch_student
json.switch_to_teacher switch_teacher_role(@is_student, @course, @user)
json.switch_to_assistant switch_assistant_role(@is_student, @course, @user)
#json.join_course !@user.member_of_course?(@course)
#json.copy_course !@user.member_of_course?(@course) && @user.is_teacher?
json.course_identity @user_course_identity
json.excellent @course.excellent
if @course.is_end == 0
json.days_remaining (@course.end_date.to_date - Time.now.to_date).to_i
end
json.teacher_applies_count CourseMessage.unhandled_join_course_requests_by_course(@course).size if @user_course_identity < Course::ASSISTANT_PROFESSOR

View File

@@ -0,0 +1,14 @@
json.course_members @course_members.each do |member|
user = member.user
json.user_login user.login
json.user_name user.real_name
json.course_group member.course_group_name
json.common_score member.common_score
json.group_score member.group_score
json.practice_score member.practice_score
json.exercise_score member.exercise_score
json.graduation_score member.graduation_score
json.total_score member.score
json.rank @rank if @user_course_identity == Course::STUDENT
end
json.all_count @all_count