dev_forum
cxt 5 years ago
commit 3a028a6679

@ -1173,6 +1173,7 @@ class ExercisesController < ApplicationController
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
@current_user_id = current_user.id @current_user_id = current_user.id
@exercise = @exercise
exercise_ids = [@exercise.id] exercise_ids = [@exercise.id]
@exercise_status = @exercise.get_exercise_status(current_user.id) @exercise_status = @exercise.get_exercise_status(current_user.id)
@course_all_members = @course.students @course_all_members = @course.students
@ -1238,7 +1239,7 @@ class ExercisesController < ApplicationController
@teacher_unreview_count = 0 @teacher_unreview_count = 0
#筛选/分类,排序 #筛选/分类,排序
order = params[:order] order = params[:order]
if @exercise_users_list.present? && @exercise_users_list.count > 0 if @exercise_users_list.present? && @exercise_users_list.size > 0
teacher_reviews = @exercise_users_list.exercise_review teacher_reviews = @exercise_users_list.exercise_review
teacher_unreviews = @exercise_users_list.exercise_unreview teacher_unreviews = @exercise_users_list.exercise_unreview
@teacher_review_count = teacher_reviews.count #已评阅 @teacher_review_count = teacher_reviews.count #已评阅
@ -1254,14 +1255,6 @@ class ExercisesController < ApplicationController
end end
end end
if order == "student_id"
@exercise_users_list = @exercise_users_list.joins(user: [:user_extension]).order("user_extensions.student_id DESC")
elsif order == "score"
@exercise_users_list = @exercise_users_list.order("#{order} DESC")
else
@exercise_users_list = @exercise_users_list.order("end_at DESC, start_at DESC")
end
#答题状态的选择 #答题状态的选择
if params[:commit_status].present? if params[:commit_status].present?
choose_type = params[:commit_status] choose_type = params[:commit_status]
@ -1282,9 +1275,17 @@ class ExercisesController < ApplicationController
@exercise_users_list = @exercise_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%") @exercise_users_list = @exercise_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
end end
if order == "student_id"
@exercise_users_list = @exercise_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC")
elsif order == "score"
@exercise_users_list = @exercise_users_list.joins(user: :user_extension).order("#{order} DESC")
else
@exercise_users_list = @exercise_users_list.order("end_at DESC, start_at DESC")
end
@export_ex_users = @exercise_users_list @export_ex_users = @exercise_users_list
@exercise_users_size = @exercise_users_list.count @exercise_users_size = @exercise_users_list.size
# 分页 # 分页
@page = params[:page] || 1 @page = params[:page] || 1
@ -1296,10 +1297,14 @@ class ExercisesController < ApplicationController
if @user_course_identity > Course::ASSISTANT_PROFESSOR if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作") tip_exception(403,"无权限操作")
else else
get_export_users(@exercise,@course,@export_ex_users) if @exercise_users_size == 0
exercise_export_name = normal_status(-1,"暂无用户提交")
"#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" else
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns} get_export_users(@exercise,@course,@export_ex_users)
exercise_export_name =
"#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
end
end end
} }
end end

@ -186,7 +186,7 @@ class HomeworkCommonsController < ApplicationController
end end
@work_count = @student_works.size @work_count = @student_works.size
@work_excel = @student_works @work_excel = @student_works.includes(:student_works_scores, user: :user_extension, myshixun: :games)
@students = @course.students @students = @course.students
# 分页参数 # 分页参数
@ -207,6 +207,7 @@ class HomeworkCommonsController < ApplicationController
tip_exception(403, "无权限操作") tip_exception(403, "无权限操作")
else else
if @work_excel.present? if @work_excel.present?
@homework = @homework.includes(:shixuns,:homework_detail_manual)
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')

@ -18,7 +18,7 @@ class PollsController < ApplicationController
before_action :check_user_id_start_answer,only: [:start_answer] before_action :check_user_id_start_answer,only: [:start_answer]
before_action :check_poll_question_complete,only: [:commit_poll] #问卷提交前来判断问题是否完成 before_action :check_poll_question_complete,only: [:commit_poll] #问卷提交前来判断问题是否完成
before_action :check_poll_commit_result,only: [:commit_result] before_action :check_poll_commit_result,only: [:commit_result]
before_action :get_all_polls_commit, only: [:commit_result] #该问卷全部的用户 # before_action :get_all_polls_commit, only: [:commit_result] #该问卷全部的用户
before_action :get_left_banner_id, only:[:common_header,:start_answer,:new,:edit,:index] before_action :get_left_banner_id, only:[:common_header,:start_answer,:new,:edit,:index]
include PollsHelper include PollsHelper
@ -920,19 +920,32 @@ class PollsController < ApplicationController
def commit_result def commit_result
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
# @poll_questions = @poll.poll_questions.order("question_number ASC")
# 全部页面,需返回
# @poll_questions_count = @poll_questions.size
# 分页 # 分页
# @poll = @poll.includes(:poll_users,user: :user_extension)
@poll_users = @poll.poll_users
@poll_commit_ids = @poll_users.commit_by_status(1).pluck(:user_id) #问卷提交用户的id
@page = params[:page] || 1 @page = params[:page] || 1
@limit = params[:limit] || 10 @limit = params[:limit] || 10
@poll_export_questions = @poll_questions.order("question_number ASC") @poll_export_questions = @poll_questions.order("question_number ASC")
@poll_questions = @poll_questions.page(@page).per(@limit) @poll_questions = @poll_questions.page(@page).per(@limit)
respond_to do |format| respond_to do |format|
format.json format.json
format.xlsx{ format.xlsx{
if @user_course_identity > Course::ASSISTANT_PROFESSOR if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作") tip_exception(403,"无权限操作")
elsif @poll_export_questions.size == 0 || (@poll_users.where("commit_status = ?",1).size == 0)
normal_status(-1,"暂时没有提交的用户")
else else
polls_export_name = current_user.real_name + "_" + @course.name + "_" + @poll.polls_name + "_" + Time.now.strftime('%Y%m%d_%H%M%S') polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {poll_questions:@poll_export_questions} render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {
poll_questions:@poll_export_questions,
poll:@poll,
poll_users: @poll_users,
poll_commit_ids:@poll_commit_ids}
end end
} }
end end
@ -953,15 +966,12 @@ class PollsController < ApplicationController
@poll_publish_count = get_user_permission_course(poll_ids,2).count @poll_publish_count = get_user_permission_course(poll_ids,2).count
@poll_unpublish_count = get_user_permission_course(poll_ids,1).count @poll_unpublish_count = get_user_permission_course(poll_ids,1).count
@course_all_members = @course.students @course_all_members = @course.students
logger.info("#######F___________poll_user_ids________________####{@poll.poll_users.pluck(:id)}")
@poll_group_counts = @course.course_groups_count @poll_group_counts = @course.course_groups_count
if @user_course_identity < Course::STUDENT #当前为老师,而且老师只能查看自己班级的/课堂的问卷 if @user_course_identity < Course::STUDENT #当前为老师,而且老师只能查看自己班级的/课堂的问卷
@poll_current_user_status = 0 @poll_current_user_status = 0
@poll_users_list = @poll.all_poll_users(current_user.id) #该老师分班的全部学生 @poll_users_list = @poll.all_poll_users(current_user.id) #该老师分班的全部学生
get_poll_answers(@poll_users_list) get_poll_answers(@poll_users_list)
logger.info("#######F__________@poll_users_list________________####{@poll_users_list.pluck(:id)}")
if @poll_list_status == 1 if @poll_list_status == 1
@poll_course_groups =[] @poll_course_groups =[]
else else
@ -1007,14 +1017,8 @@ class PollsController < ApplicationController
search_content = params[:search] search_content = params[:search]
if @poll_users_list.present? && @poll_users_list.count > 0 if @poll_users_list.present? && @poll_users_list.count > 0
if order == "student_id"
@poll_users_list = @poll_users_list.joins(user: [:user_extension]).order("user_extensions.student_id DESC")
else
@poll_users_list = @poll_users_list.order("end_at DESC")
end
#答题状态的选择 #答题状态的选择
#
if choose_type.present? if choose_type.present?
@poll_users_list = @poll_users_list.commit_by_status(choose_type) @poll_users_list = @poll_users_list.commit_by_status(choose_type)
end end
@ -1031,11 +1035,18 @@ class PollsController < ApplicationController
@poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%") @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%")
end end
if order == "student_id"
@poll_users_list = @poll_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC")
else
@poll_users_list = @poll_users_list.joins(user: :user_extension).order("end_at DESC")
end
@poll_users_size = @poll_users_list.count @poll_users_size = @poll_users_list.count
# 分页 # 分页
@page = params[:page] || 1 page = params[:page] || 1
@limit = params[:limit] || 20 limit = params[:limit] || 20
@poll_users_list = @poll_users_list.page(@page).per(@limit) @poll_users_list = @poll_users_list.page(page).per(limit)
else else
@poll_users_list = [] @poll_users_list = []
@poll_users_size = 0 @poll_users_size = 0
@ -1145,10 +1156,10 @@ class PollsController < ApplicationController
def get_questions_count def get_questions_count
@poll_questions = @poll.poll_questions&.includes(:poll_answers,:poll_votes).order("question_number ASC") @poll_questions = @poll.poll_questions&.includes(:poll_answers,:poll_votes).order("question_number ASC")
@poll_questions_count = @poll_questions.count # 全部的题目数 @poll_questions_count = @poll_questions.size # 全部的题目数
@poll_question_singles = @poll_questions.ques_count(1).all.count # 单选题 @poll_question_singles = @poll_questions.ques_count(1).all.size # 单选题
@poll_question_doubles = @poll_questions.ques_count(2).all.count # 多选题 @poll_question_doubles = @poll_questions.ques_count(2).all.size # 多选题
@poll_question_mains = @poll_questions.ques_count(3).all.count #主观题 @poll_question_mains = @poll_questions.ques_count(3).all.size #主观题
end end
def check_poll_question_complete #commit_poll 的权限 def check_poll_question_complete #commit_poll 的权限

@ -387,8 +387,6 @@ class ShixunsController < ApplicationController
ShixunMirrorRepository.create(:shixun_id => @shixun.id, :mirror_repository_id => mirror) ShixunMirrorRepository.create(:shixun_id => @shixun.id, :mirror_repository_id => mirror)
end end
end end
logger.info("#######shixun_params: ##{shixun_params}")
logger.info("#######shixun_info_params: ##{shixun_info_params}")
@shixun.update_attributes(shixun_params) @shixun.update_attributes(shixun_params)
@shixun.shixun_info.update_attributes(shixun_info_params) @shixun.shixun_info.update_attributes(shixun_info_params)
@shixun.shixun_schools.delete_all @shixun.shixun_schools.delete_all
@ -407,9 +405,7 @@ class ShixunsController < ApplicationController
# 超级管理员和运营人员才能保存 中间层服务器pod信息的配置 # 超级管理员和运营人员才能保存 中间层服务器pod信息的配置
if current_user.admin? || current_user.business? if current_user.admin? || current_user.business?
@shixun.shixun_service_configs.destroy_all @shixun.shixun_service_configs.destroy_all
params[:shixun_service_configs].each do |config| @shixun.shixun_service_configs.create!(service_config_params[:shixun_service_configs])
@shixun.shixun_service_configs.create!(config)
end
end end
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) uid_logger_error(e.message)
@ -738,12 +734,18 @@ private
:task_pass, :multi_webssh, :opening_time, :mirror_script_id, :code_hidden, :task_pass, :multi_webssh, :opening_time, :mirror_script_id, :code_hidden,
:hide_code, :forbid_copy) :hide_code, :forbid_copy)
end end
def shixun_info_params def shixun_info_params
raise("实训描述不能为空") if params[:shixun_info][:description].blank? raise("实训描述不能为空") if params[:shixun_info][:description].blank?
raise("评测脚本不能为空") if params[:shixun_info][:evaluate_script].blank? raise("评测脚本不能为空") if params[:shixun_info][:evaluate_script].blank?
params.require(:shixun_info).permit(:description, :evaluate_script) params.require(:shixun_info).permit(:description, :evaluate_script)
end end
def service_config_params
params.permit(shixun_service_configs: [:cpu_limit, :lower_cpu_limit, :memory_limit, :request_limit, :mirror_repository_id])
end
def find_shixun def find_shixun
@shixun = Shixun.find_by_identifier(params[:identifier]) @shixun = Shixun.find_by_identifier(params[:identifier])
if @shixun.blank? if @shixun.blank?

@ -62,7 +62,7 @@ class ZipsController < ApplicationController
if default_ex_users_size == 0 if default_ex_users_size == 0
normal_status(-1,"导出失败,暂时没有已提交的学生") normal_status(-1,"导出失败,暂时没有已提交的学生")
elsif default_ex_users_size > 100 elsif default_ex_users_size > 100
normal_status(-1,"导出数量超过100,请分班导出或联系网站管理员导出") normal_status(-2,"100")
end end
end end
rescue Exception => e rescue Exception => e

@ -1,5 +1,5 @@
class ChallengeTag < ApplicationRecord class ChallengeTag < ApplicationRecord
belongs_to :challenge, counter_cache: true belongs_to :challenge, counter_cache: true
belongs_to :challenge_choose belongs_to :challenge_choose, optional: true
end end

@ -52,12 +52,12 @@ class Poll < ApplicationRecord
# 统一设置,为当前老师有权限的分班学生,分班设置,也为当前老师有权限的分班的学生 # 统一设置,为当前老师有权限的分班学生,分班设置,也为当前老师有权限的分班的学生
def all_poll_users(user_id) def all_poll_users(user_id)
poll_users = self.poll_users poll_all_users = poll_users
group_ids = poll_published_ids(user_id) group_ids = poll_published_ids(user_id)
if group_ids.present? if group_ids.present?
poll_users = poll_users.where(user_id: course.students.where(course_group_id: group_ids).pluck(:user_id)) poll_all_users = poll_all_users.where(user_id: course.students.where(course_group_id: group_ids).pluck(:user_id).uniq)
end end
poll_users poll_all_users
end end
#当前用户已发布的班级id和试卷分组已发布的班级id的交集 #当前用户已发布的班级id和试卷分组已发布的班级id的交集

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

@ -1,3 +1,5 @@
class SubRepertoire < ApplicationRecord class SubRepertoire < ApplicationRecord
has_many :tag_repertoires belongs_to :repertoire
has_many :tag_repertoires, ->{order(updated_at: :desc)} ,:dependent => :destroy
end end

@ -9,7 +9,7 @@ wb.styles do |s|
sheet.sheet_view.show_grid_lines = false sheet.sheet_view.show_grid_lines = false
poll_users_info = %w(序号) poll_users_info = %w(序号)
poll_ques_titles = poll_questions.pluck(:question_title).map {|k| strip_export_title(k) if k.present?} poll_ques_titles = poll_questions.pluck(:question_title).map {|k| strip_export_title(k) if k.present?}
poll_un_anony = @poll.un_anonymous poll_un_anony = poll.un_anonymous
if poll_un_anony #是否匿名默认为false if poll_un_anony #是否匿名默认为false
user_info = %w(登陆名 真实姓名 邮箱 学号) user_info = %w(登陆名 真实姓名 邮箱 学号)
else else
@ -18,13 +18,13 @@ wb.styles do |s|
poll_users_info = poll_users_info + user_info + poll_ques_titles poll_users_info = poll_users_info + user_info + poll_ques_titles
poll_questions.each do |q| poll_questions.each do |q|
if q.question_type != 3 #问题不为主观题 if q.question_type != 3 #问题不为主观题
question_vote_user = q.poll_votes.find_current_vote("user_id",@poll_commit_ids).count #该问题的有效填写量 question_vote_user = q.poll_votes.find_current_vote("user_id",poll_commit_ids).count #该问题的有效填写量
sheet_row = ["第#{q.question_number}题"] #选择题答案选项的数组 sheet_row = ["第#{q.question_number}题"] #选择题答案选项的数组
sheet_answer_row = ["小计"] #选择题回答的答案人数,数组 sheet_answer_row = ["小计"] #选择题回答的答案人数,数组
sheet_answer_percent = ["比例"] sheet_answer_percent = ["比例"]
sheet_answer_useful = ["有效填写人次",question_vote_user] sheet_answer_useful = ["有效填写人次",question_vote_user]
q.poll_answers.each do |a| #问卷的答案选项 q.poll_answers.each do |a| #问卷的答案选项
answer_users_count = a.poll_votes.find_current_vote("user_id",@poll_commit_ids).count answer_users_count = a.poll_votes.find_current_vote("user_id",poll_commit_ids).count
answer_percent = number_to_percentage((answer_users_count.to_f / question_vote_user.to_f)*100,precision:1) answer_percent = number_to_percentage((answer_users_count.to_f / question_vote_user.to_f)*100,precision:1)
sheet_row.push(a.answer_text) sheet_row.push(a.answer_text)
sheet_answer_row.push(answer_users_count) sheet_answer_row.push(answer_users_count)
@ -49,7 +49,7 @@ wb.styles do |s|
end #each_with_index end #each_with_index
sheet.add_row poll_users_info, :height =>15, :style => blue_cell sheet.add_row poll_users_info, :height =>15, :style => blue_cell
@poll.poll_users.each_with_index do |u,index| poll_users.each_with_index do |u,index|
u_user = u.user u_user = u.user
user_answer_array = [] user_answer_array = []
poll_questions.each do |q| poll_questions.each do |q|

Loading…
Cancel
Save