dev_local
cxt 6 years ago
parent fc8ecd706b
commit a44ad345d2

@ -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

@ -298,13 +298,15 @@
<% if game.present? && game.status == 2 && !is_answer_correct && game.answer_open %>
<span class="color-red mr5">(答案抄袭)</span>
<% end %>
<% score = exercise_shixun_answer.present? ? exercise_shixun_answer.try(:score) : 0 %>
<span class="<%= score != 0 ? 'color-light-green' : 'color-red' %> mr3" id="shixun_answer_score_<%= exercise_shixun_answer.try(:id) %>">
<% if is_answer_correct || score == 0 %>
<i class="mr5 fa <%= is_answer_correct ? 'fa-check' : 'fa-close' %> font-14"></i>
<% end %>
<%= score %>
</span>分
<% if @show_score %>
<% score = exercise_shixun_answer.present? ? exercise_shixun_answer.try(:score) : 0 %>
<span class="<%= score != 0 ? 'color-light-green' : 'color-red' %> mr3" id="shixun_answer_score_<%= exercise_shixun_answer.try(:id) %>">
<% if is_answer_correct || score == 0 %>
<i class="mr5 fa <%= is_answer_correct ? 'fa-check' : 'fa-close' %> font-14"></i>
<% end %>
<%= score %>
</span>分
<% end %>
</p>
</li>
<div class="test-code">

Loading…
Cancel
Save