diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb
index 2524c53d8..e62dcf6ed 100644
--- a/app/controllers/accounts_controller.rb
+++ b/app/controllers/accounts_controller.rb
@@ -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]
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index e7b4bdac6..54c07d1c1 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -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
diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb
index 52915a8ba..75ada699d 100644
--- a/app/controllers/exercise_questions_controller.rb
+++ b/app/controllers/exercise_questions_controller.rb
@@ -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|
diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb
index ace9e062e..baf594a42 100644
--- a/app/helpers/exercises_helper.rb
+++ b/app/helpers/exercises_helper.rb
@@ -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
diff --git a/app/models/subject.rb b/app/models/subject.rb
index 5116cce75..b8d6eef8b 100644
--- a/app/models/subject.rb
+++ b/app/models/subject.rb
@@ -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 }
diff --git a/db/migrate/20190820102040_change_exercise_1930_position.rb b/db/migrate/20190820102040_change_exercise_1930_position.rb
new file mode 100644
index 000000000..c46616e28
--- /dev/null
+++ b/db/migrate/20190820102040_change_exercise_1930_position.rb
@@ -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
diff --git a/lib/tasks/excellent_course_exercise.rake b/lib/tasks/excellent_course_exercise.rake
index d337fbd73..0d8875806 100644
--- a/lib/tasks/excellent_course_exercise.rake
+++ b/lib/tasks/excellent_course_exercise.rake
@@ -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
diff --git a/public/react/src/modules/courses/exercise/question/shixunAnswer.js b/public/react/src/modules/courses/exercise/question/shixunAnswer.js
index f1fb09227..d8644f8c4 100644
--- a/public/react/src/modules/courses/exercise/question/shixunAnswer.js
+++ b/public/react/src/modules/courses/exercise/question/shixunAnswer.js
@@ -276,7 +276,7 @@ class shixunAnswer extends Component{
}
{
item.operation ?
- this.scrollToAnchor(`${questionType.question_id}${index+1}`)}>查看
+ this.scrollToAnchor(`${questionType.question_id}${index+1}`)}>查看
:
--
}