|
|
|
@ -1343,9 +1343,9 @@ class ExerciseController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
@exercise = Exercise.find params[:id]
|
|
|
|
|
@course = @exercise.course
|
|
|
|
|
@is_teacher = params[:pdf] && User.current.nil? ? true : User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
|
|
|
|
|
@is_teacher = params[:pdf] ? true : User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
|
|
|
|
|
@user = User.find params[:user_id]
|
|
|
|
|
current_ex_user = ExerciseUser.where("user_id =? and exercise_id=?", User.current.id, @exercise.id).first if User.current
|
|
|
|
|
current_ex_user = ExerciseUser.where("user_id =? and exercise_id=?", User.current.id, @exercise.id).first if !@is_teacher
|
|
|
|
|
if @is_teacher || (User.current.member_of_course?(@exercise.course) && @exercise.end_time <= Time.now &&
|
|
|
|
|
current_ex_user && (@exercise.score_open || User.current == @user))
|
|
|
|
|
@exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", @user.id, @exercise.id).first
|
|
|
|
@ -1672,7 +1672,9 @@ class ExerciseController < ApplicationController
|
|
|
|
|
sheet1 = book.create_worksheet :name => "exercise"
|
|
|
|
|
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
|
|
|
|
|
sheet1.row(0).default_format = blue
|
|
|
|
|
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_course_group),l(:excel_mail),l(:excel_objective_score),l(:excel_subjective_score),l(:excel_f_score),l(:excel_answer_time)])
|
|
|
|
|
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_course_group),
|
|
|
|
|
l(:excel_mail),l(:excel_objective_score),l(:excel_subjective_score),l(:excel_f_score),
|
|
|
|
|
l(:excel_answer_time), "初级题得分", "中级题得分", "高级题得分", "顶级题得分"])
|
|
|
|
|
count_row = 1
|
|
|
|
|
members = @exercise.course.members
|
|
|
|
|
items.each do |exercise|
|
|
|
|
@ -1686,6 +1688,11 @@ class ExerciseController < ApplicationController
|
|
|
|
|
sheet1[count_row,7] = exercise.subjective_score == -1 ? "0.0" : format("%.1f",exercise.subjective_score)
|
|
|
|
|
sheet1[count_row,8] = exercise.score
|
|
|
|
|
sheet1[count_row,9] = exercise.commit_status == 0 ? l(:excel_no_answer) : format_time(exercise.start_at)
|
|
|
|
|
|
|
|
|
|
sheet1[count_row, 10] = level_score(exercise.user, 1).to_f
|
|
|
|
|
sheet1[count_row, 11] = level_score(exercise.user, 2).to_f
|
|
|
|
|
sheet1[count_row, 12] = level_score(exercise.user, 3).to_f
|
|
|
|
|
sheet1[count_row, 13] = level_score(exercise.user, 4).to_f
|
|
|
|
|
count_row += 1
|
|
|
|
|
end
|
|
|
|
|
book.write xls_report
|
|
|
|
@ -1733,6 +1740,11 @@ class ExerciseController < ApplicationController
|
|
|
|
|
complete_question
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def level_score user, level
|
|
|
|
|
user.exercise_shixun_answers.where(exercise_question_id: @exercise.exercise_questions.where(level: level).pluck(:id)).pluck(:score).sum
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 获取答题百分比
|
|
|
|
|
def get_percent exercise, exercise_user
|
|
|
|
|
complete_count = get_complete_question(exercise,exercise_user).count
|
|
|
|
|