试卷的编程题调整

dev_chen
cxt 5 years ago
parent 25a11ffec1
commit 7d8012e92e

@ -91,6 +91,8 @@ class HacksController < ApplicationController
if @hack.item_bank.present?
update_item_params = item_params.merge({difficulty: params[:hack][:difficult]})
@hack.item_bank.update!(update_item_params)
elsif @hack.exercise_question.present?
@hack.exercise_question.update!(question_title: params[:name])
end
end
render_ok
@ -176,9 +178,10 @@ class HacksController < ApplicationController
end
end
# 只有自己,或者管理员才能更新
# 只有自己,或者管理员才能更新,或者试卷所属课堂老师
def require_auth_identity
unless @hack.user_id == current_user.id || admin_or_business?
unless @hack.user_id == current_user.id || admin_or_business? ||
(@hack.fork_id.present? && @hack.exercise_course.present? && current_user.course_identity(@hack.exercise_course) < Course::STUDENT)
tip_exception(403, "..")
end
end

@ -301,7 +301,32 @@ module ExercisesHelper
}
question_answer_infos.push(shixun_new_chas)
end
elsif ex.question_type == Exercise::PROGRAM #编程题
ex_score = ex&.question_score
full_scores = effictive_users.search_exercise_answer("score",ex_score).size #满分人数
zero_scores = effictive_users.search_exercise_answer("score",0.0).size #包含为0分的及未评阅的
main_scores_array = [full_scores,zero_scores]
main_scores_array.each_with_index do |s,index|
right_answer = (index == 0)
if effictive_users_count == 0 || s < 0
s = 0
score_percent = 0.0
else
score_percent = (s.to_i / effictive_users_count.to_f ).round(3)
end
answer_option = {
:choice_position => index+1,
:choice_text => index+1,
:choice_users_count => s,
:choice_percent => score_percent.round(2).to_s,
:right_answer => right_answer
}
question_answer_infos.push(answer_option)
end
end
ques_option = {
:ques_title => ques_title,
:ques_less_title => ques_less_title, #副标题,仅实训题才有

@ -39,6 +39,10 @@ class Hack < ApplicationRecord
end
end
def exercise_course
exercise_question.present? ? exercise_question&.exercise&.course : nil
end
def code
if hack_codes.count == 1
#tran_base64_decode64(hack_codes.first.code)

Loading…
Cancel
Save