diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb
index a1bc853b..775b1947 100644
--- a/app/controllers/managements_controller.rb
+++ b/app/controllers/managements_controller.rb
@@ -1267,7 +1267,8 @@ end
if school.present?
customer = Customer.new(school_id: s)
customer.save!
- PartnerCustomer.create(partner_id: partner_id,customer_id: customer.id )
+ PartnerCustomer.create!(partner_id: partner_id,customer_id: customer.id )
+ school.update_attributes(customer_id: customer.id)
end
end
render :json => {status: 1, message: "创建成功!"}
diff --git a/app/controllers/oauth_controller.rb b/app/controllers/oauth_controller.rb
index 714bd610..780cc4ba 100644
--- a/app/controllers/oauth_controller.rb
+++ b/app/controllers/oauth_controller.rb
@@ -196,12 +196,14 @@ class OauthController < ApplicationController
UserExtensions.create!(user_id: user.id, school_id: School.first.id, identity: 4, gender: 0)
openi = Openi.create!(user_id: user.id, openi_user_id: openi_user_id, avatar_url: avatar_url, login: login, name: name, email: email)
+ openi.user = user
+ openi.save!
end
end
self.logged_user = openi.user if openi.present? && openi.user.present?
original_url = params[:original_url]
- if current_user.logged?
+ if User.current.logged?
redirect_to original_url
else
redirect_to signin_path
diff --git a/app/helpers/subjects_helper.rb b/app/helpers/subjects_helper.rb
index 0a8d659f..6c5e240f 100644
--- a/app/helpers/subjects_helper.rb
+++ b/app/helpers/subjects_helper.rb
@@ -46,7 +46,7 @@ module SubjectsHelper
content = if (shixun.status == 2 && !shixun.hidden) || User.current.manager_of_shixun?(shixun)
content_before = "查看详情"
if User.current.try(:mail).blank?
- %Q{开始实战}
+ %Q{开始实战}
elsif shixun.challenges_count > 0
if is_modify.blank?
%Q{#{link_to '开始实战', shixun_exec_shixun_path(shixun, :is_subject => subject.id), :class => "btn_auto user_bluebg_btn fl none", :id => "shixun_operation", :target => "_blank"}}
diff --git a/app/services/zip_service.rb b/app/services/zip_service.rb
index b798e111..32846312 100644
--- a/app/services/zip_service.rb
+++ b/app/services/zip_service.rb
@@ -188,6 +188,7 @@ module ZipService
# file_name = "#{exercise.course_id}-#{exercise.exercise_name}-#{exercise_user.user.user_extensions.student_id}-#{exercise_user.user.show_real_name}" + ".pdf"
# file_name = "#{Time.now.strftime("%Y%m%d%H%M%S").to_s}-#{exercise.course_id}-#{exercise.id}-#{exercise_user.user.user_extensions.student_id}" + ".pdf"
file_name.gsub!(" ", "-")
+ file_name.gsub!("/", "_")
kit.to_file("#{OUTPUT_FOLDER}/#{file_name}")
out_file = "#{OUTPUT_FOLDER}/#{file_name}"
out_file
@@ -200,6 +201,7 @@ module ZipService
# file_name = "#{homework.course_id}-#{homework.name}-#{student_work.user.user_extensions.student_id}-#{student_work.user.show_real_name}" + ".pdf"
# file_name = "#{Time.now.strftime("%Y%m%d%H%M%S").to_s}-#{homework.course_id}-#{homework.id}-#{student_work.user.user_extensions.student_id}" + ".pdf"
file_name.gsub!(" ", "-")
+ file_name.gsub!("/", "_")
kit.to_file("#{OUTPUT_FOLDER}/#{file_name}")
out_file = "#{OUTPUT_FOLDER}/#{file_name}"
out_file
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 %>
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 %>
diff --git a/app/views/managements/_reject_authorization_model.html.erb b/app/views/managements/_reject_authorization_model.html.erb
index 4d35359f..6d7468f4 100644
--- a/app/views/managements/_reject_authorization_model.html.erb
+++ b/app/views/managements/_reject_authorization_model.html.erb
@@ -51,15 +51,15 @@
-
+
-
-
+
+
@@ -79,8 +79,23 @@
var modal = $(".modal.reject-auth-modal");
var form = modal.find("#reject-auth-form");
var applyIdInput = form.find("input[name='apply_id']");
+ var rejectDescriptionSpan = form.find(".reject-description-label span");
+ var needRejectDescription = false;
var error = modal.find(".error");
+ modal.on("click", "input[name='reasons[]']", function(){
+ var checkbox = $(this);
+ if (checkbox.data("type") != "other") { return; }
+
+ if (checkbox.prop("checked")) {
+ needRejectDescription = true;
+ rejectDescriptionSpan.show();
+ } else {
+ needRejectDescription = false;
+ rejectDescriptionSpan.hide();
+ }
+ });
+
modal.on('click', '.submit-btn', function(){
if (!formValid()) { return; }
form.submit();
@@ -88,8 +103,13 @@
var formValid = function () {
error.html("").hide();
- if (form.find("input[name='reasons[]']:checked").length == 0 || form.find("textarea[name='reject_description']").val() == '') {
- error.html("原因和说明不能为空,请完善后再确认提交").show();
+ if (form.find("input[name='reasons[]']:checked").length == 0) {
+ error.html("撤销原因不能为空,请完善后再确认提交").show();
+ return false;
+ }
+
+ if (needRejectDescription && form.find("textarea[name='reject_description']").val() == '') {
+ error.html("备注说明不能为空,请完善后再确认提交").show();
return false;
}
@@ -100,6 +120,8 @@
applyIdInput.val('');
form.find("textarea[name='reject_description']").val('');
form.find("input[name='reasons[]']").each(function(){this.checked=false;})
+ needRejectDescription = false;
+ rejectDescriptionSpan.hide();
modal.hide();
};
// 隐藏弹窗
diff --git a/app/views/managements/_trial_authorization_list.html.erb b/app/views/managements/_trial_authorization_list.html.erb
index 0e44ecfd..1a1a8791 100644
--- a/app/views/managements/_trial_authorization_list.html.erb
+++ b/app/views/managements/_trial_authorization_list.html.erb
@@ -15,7 +15,7 @@
<% if !user.try(:user_extensions).school_id.blank? && user.try(:user_extensions).try(:school) %>
- <%= user.try(:user_extensions).school.name %><%= user.try(:user_extensions).department ? ' - '+user.try(:user_extensions).department.name.to_s : '' %>
+ <%= user.try(:school_name) %><%= user.try(:user_extensions).department ? ' - '+user.try(:user_extensions).department.name.to_s : '' %>
<% end %>
<% if user.try(:user_extensions) && user.try(:user_extensions).identity %>
<%= user.identity %>
diff --git a/app/views/managements/_trial_authorization_passed_list.html.erb b/app/views/managements/_trial_authorization_passed_list.html.erb
index 6f31ffc6..bfaf91c2 100644
--- a/app/views/managements/_trial_authorization_passed_list.html.erb
+++ b/app/views/managements/_trial_authorization_passed_list.html.erb
@@ -38,7 +38,9 @@
<% if authorization.status == 2 %>
原因:<%= authorization.reason.blank? ? "空" : authorization.reason %>
-
备注说明:<%= authorization.reject_description.blank? ? "空" : authorization.reject_description %>
+ <% if authorization.reject_description.present? %>
+
备注说明:<%= authorization.reject_description %>
+ <% end %>
<% end %>
diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb
index e70c3555..5103d7f9 100644
--- a/app/views/my/account.html.erb
+++ b/app/views/my/account.html.erb
@@ -103,7 +103,7 @@
<% if @trail_authentication.status == 1 %>
sure_box_redirect_without_newtab("<%= user_path(@user) %>", "试用申请已被接受");
<% elsif @trail_authentication.status == 2 %>
- sure_box_redirect_without_newtab_btn("<%= my_account_path %>", "试用申请已被拒绝
原因:<%= @trail_authentication.reason %>", "重新申请");
+ sure_box_redirect_without_newtab_btn("<%= my_account_path %>", "试用申请已被拒绝
原因:<%= [@trail_authentication.reason, @trail_authentication.reject_description].join(';') %>", "重新申请");
<% end %>
<% end %>
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