From 9cf1de1880989b765c9f896b2867eca4a0e4f91d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 8 May 2019 13:00:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...508045744_migrate_exercise_answer_score.rb | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 db/migrate/20190508045744_migrate_exercise_answer_score.rb diff --git a/db/migrate/20190508045744_migrate_exercise_answer_score.rb b/db/migrate/20190508045744_migrate_exercise_answer_score.rb new file mode 100644 index 00000000..3b639d92 --- /dev/null +++ b/db/migrate/20190508045744_migrate_exercise_answer_score.rb @@ -0,0 +1,20 @@ +class MigrateExerciseAnswerScore < ActiveRecord::Migration + def up + exercise = Exercise.where(:id => 1527).first + if exercise.present? + exercise.exercise_users.each do |exercise_user| + score = 0 + exercise.exercise_questions.each do |question| + ExerciseShixunAnswer.where(exercise_question_id: question.id, user_id: exercise_user.user_id).each do |answer| + score += answer.score + end + end + + exercise_user.update_attributes(objective_score: score, score: score) + end + end + end + + def down + end +end From 31635eb93fe8bd677cfb1f95f80dac7e3ad8a238 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 11 May 2019 14:37:22 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E9=A2=98=E7=9A=84?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_exercise_student.html.erb | 2 +- app/views/exercise/_exercise_student_result.html.erb | 2 +- app/views/exercise/_show_MC.html.erb | 2 +- app/views/exercise/_show_MCQ.html.erb | 2 +- app/views/exercise/_show_multi.html.erb | 2 +- app/views/exercise/_show_single.html.erb | 2 +- app/views/exercise/student_exercise_list.html.erb | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index d361c200..add9d655 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -164,7 +164,7 @@ <% if exercise_question.question_type == 5 %>

<%= exercise_question.shixun.name %>

<% end %> -
<%= sanitize exercise_question.question_title %>
+
<%= exercise_question.question_title.html_safe %>
<% case exercise_question.question_type %> <% when 1 %>
diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb index b5336cdb..0dd656be 100644 --- a/app/views/exercise/_exercise_student_result.html.erb +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -142,7 +142,7 @@ <% if exercise_question.question_type == 5 %>

<%= exercise_question.shixun.name %>

<% end %> -
<%= sanitize exercise_question.question_title %>
+
<%= exercise_question.question_title.html_safe %>
<% case exercise_question.question_type %> <% when 1 %>
diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index 993369af..8461374a 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -15,7 +15,7 @@

<% end %>
-
<%= sanitize exercise_question.question_title%>
+
<%= exercise_question.question_title.html_safe%>
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
  • diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb index a778abb3..e1767b3b 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -15,7 +15,7 @@

    <% end %>
  • -
    <%= sanitize exercise_question.question_title %>
    +
    <%= exercise_question.question_title.html_safe %>
    <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
  • diff --git a/app/views/exercise/_show_multi.html.erb b/app/views/exercise/_show_multi.html.erb index 2512123f..71623bf8 100644 --- a/app/views/exercise/_show_multi.html.erb +++ b/app/views/exercise/_show_multi.html.erb @@ -15,7 +15,7 @@

    <% end %>
  • -
    <%= sanitize exercise_question.question_title %>
    +
    <%= exercise_question.question_title.html_safe %>

    参考答案:

    diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb index 675ed49f..0c601f63 100644 --- a/app/views/exercise/_show_single.html.erb +++ b/app/views/exercise/_show_single.html.erb @@ -15,7 +15,7 @@

    <% end %>
    -
    <%= sanitize exercise_question.question_title %>
    +
    <%= exercise_question.question_title.html_safe %>
    <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %> 候选答案<%= convert_to_chi_num(index+1) %>: diff --git a/app/views/exercise/student_exercise_list.html.erb b/app/views/exercise/student_exercise_list.html.erb index d47db23a..3632b4d7 100644 --- a/app/views/exercise/student_exercise_list.html.erb +++ b/app/views/exercise/student_exercise_list.html.erb @@ -259,7 +259,7 @@

    <%= exercise_question.shixun.name %>

    <% end %>
    - <%= sanitize exercise_question.question_title %> + <%= exercise_question.question_title.html_safe %>
    <% case exercise_question.question_type %> <% when 1 %>