Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

dev_hs
杨树明 6 years ago
commit 5e420c5e51

@ -38,7 +38,7 @@ class AccountsController < ApplicationController
return normal_status(-2, "验证码已失效") if !verifi_code&.effective?
end
code = generate_identifier User, 8
code = generate_identifier User, 8, pre
login = pre + code
@user = User.new(admin: false, login: login, mail: email, phone: phone, type: "User")
@user.password = params[:password]

@ -396,10 +396,10 @@ class ApplicationController < ActionController::Base
end
# 随机生成字符
def generate_identifier(container, num)
def generate_identifier(container, num, pre='')
code = DCODES.sample(num).join
if container == User
while container.exists?(login: code) do
while container.exists?(login: pre+code) do
code = DCODES.sample(num).join
end
else

@ -348,7 +348,7 @@ class ExerciseQuestionsController < ApplicationController
#当试卷已发布时(试卷的总状态),当标准答案修改时,如有已提交的学生,需重新计算分数.
if @exercise.exercise_status == Exercise::PUBLISHED
if @exercise.exercise_status >= Exercise::PUBLISHED
ex_users_committed = @exercise.exercise_users.exercise_user_committed
if ex_users_committed.size > 0
ex_users_committed.each do |ex_user|

@ -403,6 +403,12 @@ module ExercisesHelper
end
user_answer_content = answer_choice_array.sort
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
#TODO: 旧版多选题的标准答案是放在一个里面的新版又做成了一个题有多个标准答案exercise_choice_id存放的是标准答案的位置..
if q.question_type == 1 && standard_answer.size == 1
standard_answer = standard_answer.first.to_s.split("").map(&:to_i)
end
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
if standard_answer.size > 0
q_score_1 = q.question_score

@ -19,7 +19,7 @@ class Subject < ApplicationRecord
has_many :stages, -> { order("stages.position ASC") }, dependent: :destroy
# 开放课堂
has_many :courses, -> { order("courses.id ASC") }
has_many :courses, -> { where("is_delete = 0").order("courses.id ASC") }
validates :name, length: { maximum: 60 }
validates :description, length: { maximum: 5000 }

@ -0,0 +1,29 @@
class ChangeExercise1930Position < ActiveRecord::Migration[5.2]
def change
exs = Exercise.all.includes(:exercise_questions)
exs.each do |ex|
ex_questions = ex&.exercise_questions&.select(:id,:question_number,:exercise_id)&.order("question_number ASC") #试卷的位置迁移
if ex_questions.exists?
ex_questions.each_with_index do |q,index|
puts index
q_num = index + 1
if q.question_number.to_i != q_num
q.update_attributes(question_number: q_num)
end
end
end
ex_q_bank = ex&.exercise_bank&.exercise_bank_questions&.select(:id,:question_number,:exercise_bank_id,:shixun_id)&.order("question_number ASC") #试卷的习题库位置迁移
if ex_q_bank.exists?
ex_q_bank.each_with_index do |q,index|
puts index
q_num_1 = index + 1
if q.question_number.to_i != q_num_1
q.update_attributes(question_number: q_num_1)
end
end
end
end
end
end

@ -103,6 +103,13 @@ namespace :excellent_course_exercise do
end
user_answer_content = answer_choice_array.sort
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
#TODO: 旧版多选题的标准答案是放在一个里面的新版又做成了一个题有多个标准答案exercise_choice_id存放的是标准答案的位置..
if q.question_type == 1 && standard_answer.size == 1
standard_answer = standard_answer.first.to_s.split("").map(&:to_i)
end
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
if standard_answer.size > 0
q_score_1 = q.question_score

@ -276,7 +276,7 @@ class shixunAnswer extends Component{
}
{
item.operation ?
<a className={isAdmin ? "color-blue mt5 fr":"color-blue"} target="_blank" href='javascript:void(0)' onClick={()=>this.scrollToAnchor(`${questionType.question_id}${index+1}`)}>查看</a>
<a className={isAdmin ? "color-blue mt5 fr":"color-blue"} href='javascript:void(0)' onClick={()=>this.scrollToAnchor(`${questionType.question_id}${index+1}`)}>查看</a>
:
<span className={isAdmin ? "color-grey-9 mt5 fr":"color-grey-9"} >--</span>
}

Loading…
Cancel
Save