diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index be8173b2f..8a3999410 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -657,7 +657,8 @@ class GamesController < ApplicationController # 高性能取上一关、下一关 prev_game = @game.prev_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position) - next_game = @game.next_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position) if had_passed + next_game = @game.next_game(@shixun.id, @game.myshixun_id, game_challenge.position) if had_passed + next_game.update_column(:status, 0) if next_game.present? && next_game.status == 3 # 高性能取上一关、下一关 #prev_game = Game.prev_identifier(@shixun.id, @game.myshixun_id, game_challenge.position) @@ -670,7 +671,7 @@ class GamesController < ApplicationController choose_correct_num: choose_correct_num, test_sets: test_sets, prev_game: prev_game, - next_game: next_game} + next_game: next_game&.identifier} rescue Exception => e uid_logger("choose build failed #{e.message}") @result = [status: -1, contents: "#{e.message}"] diff --git a/app/forms/users/apply_authentication_form.rb b/app/forms/users/apply_authentication_form.rb index 986ba6223..2b984fcaa 100644 --- a/app/forms/users/apply_authentication_form.rb +++ b/app/forms/users/apply_authentication_form.rb @@ -4,5 +4,12 @@ class Users::ApplyAuthenticationForm attr_accessor :name, :id_number, :upload_image validates :name, presence: true - validates :id_number, presence: true + validate :validate_ID_number + + + def validate_ID_number + unless id_number =~ User::VALID_NUMBER_REGEX + raise("身份证格式不对") + end + end end \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb index 70cd54c92..5fdb1a713 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -20,6 +20,8 @@ class User < ApplicationRecord VALID_EMAIL_REGEX = /^[a-zA-Z0-9]+([.\-_\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/i VALID_PHONE_REGEX = /^1\d{10}$/ + # 身份证 + VALID_NUMBER_REGEX = /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/ LOGIN_LENGTH_LIMIT = 30 MAIL_LENGTH_LMIT = 60 @@ -162,7 +164,8 @@ class User < ApplicationRecord # validates_format_of :mail, with: VALID_EMAIL_REGEX, multiline: true # validates_format_of :phone, with: VALID_PHONE_REGEX, multiline: true validate :validate_password_length - + #validate :validate_ID_number + #validates_format_of :ID_number, with: VALID_NUMBER_REGEX, multiline: true, message: "身份证号格式不对" # validates :nickname, presence: true, length: { maximum: 10 } # validates :lastname, presence: true diff --git a/app/services/users/apply_authentication_service.rb b/app/services/users/apply_authentication_service.rb index 9e0901ef4..d6da2d1fb 100644 --- a/app/services/users/apply_authentication_service.rb +++ b/app/services/users/apply_authentication_service.rb @@ -25,10 +25,10 @@ class Users::ApplyAuthenticationService < ApplicationService user.apply_user_authentication.create!(auth_type: 1, status: 0) move_image_file! unless params[:upload_image].to_s == 'false' - - sms_notify_admin end + sms_notify_admin + user end diff --git a/app/services/users/apply_professional_auth_service.rb b/app/services/users/apply_professional_auth_service.rb index cc6f36fff..ea9f3e0d1 100644 --- a/app/services/users/apply_professional_auth_service.rb +++ b/app/services/users/apply_professional_auth_service.rb @@ -37,13 +37,9 @@ class Users::ApplyProfessionalAuthService < ApplicationService user.apply_user_authentication.create!(auth_type: 2, status: 0) move_image_file! unless params[:upload_image].to_s == 'false' - - sms_cache = Rails.cache.read("apply_pro_certification") - if sms_cache.nil? - sms_notify_admin - Rails.cache.write("apply_pro_certification", 1, expires_in: 5.minutes) - end end + + sms_notify_admin end private @@ -61,7 +57,11 @@ class Users::ApplyProfessionalAuthService < ApplicationService end def sms_notify_admin - Educoder::Sms.notify_admin(send_type: 'apply_pro_certification') + sms_cache = Rails.cache.read('apply_pro_certification') + if sms_cache.nil? + Educoder::Sms.notify_admin(send_type: 'apply_pro_certification') + Rails.cache.write('apply_pro_certification', 1, expires_in: 5.minutes) + end rescue => ex Util.logger_error(ex) end diff --git a/db/migrate/20190927091948_change_user_p02389416_exercise.rb b/db/migrate/20190927091948_change_user_p02389416_exercise.rb index bea1e28b7..c4026f75b 100644 --- a/db/migrate/20190927091948_change_user_p02389416_exercise.rb +++ b/db/migrate/20190927091948_change_user_p02389416_exercise.rb @@ -6,15 +6,26 @@ class ChangeUserP02389416Exercise < ActiveRecord::Migration[5.2] # 分数分别为:2分,2分,5分,2分,2分,2分,2分,2分 合计19分 question_ids = [37411,37414,37417,37418,37419,37423,37424,37429] choice_ids = [117788,117797,117806,117809,117811,117816,117818,117828] + question_scores = [2,2,5,2,2,2,2,2] question_ids.each_with_index do |q, index| - ExerciseAnswer.create(user_id: 45442, exercise_question_id: q, exercise_choice_id: choice_ids[index]) + ex_exercise_user = ExerciseAnswer.where(user_id: 45442, exercise_question_id: q, exercise_choice_id: choice_ids[index]) + if ex_exercise_user.exists? + ex_exercise_user.first.update_attribute(:score,question_scores[index]) + else + ExerciseAnswer.create(user_id: 45442, exercise_question_id: q, exercise_choice_id: choice_ids[index], score: question_scores[index]) + end end ex_user = ExerciseUser.where(user_id: 45442, exercise_id: 2561)&.first if ex_user.present? - obj_score = ex_user.objective_score.to_i + 19 - total_score = ex_user.score.to_i + 19 + if ex_user.score > 65 || ex_user.objective_score > 65 + ex_user.update_attributes(score: 65, objective_score: 65) + else + obj_score = ex_user.objective_score.to_i + 19 + total_score = ex_user.score.to_i + 19 + + ex_user.update_attributes(score: total_score, objective_score: obj_score) + end - ex_user.update_attributes(score: total_score, objective_score: obj_score) end puts "====> end_to_create user exercise_answer" diff --git a/public/react/config/webpack.config.dev.js b/public/react/config/webpack.config.dev.js index fe525154f..ef38a18f8 100644 --- a/public/react/config/webpack.config.dev.js +++ b/public/react/config/webpack.config.dev.js @@ -32,7 +32,7 @@ module.exports = { // See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s // devtool: "cheap-module-eval-source-map", // 开启调试 - devtool: "source-map", // 开启调试 + //devtool: "source-map", // 开启调试 // These are the "entry points" to our application. // This means they will be the "root" imports that are included in JS bundle. // The first two entry points enable "hot" CSS and auto-refreshes for JS. diff --git a/public/react/package.json b/public/react/package.json index 3e86dae98..6a0cf6d09 100644 --- a/public/react/package.json +++ b/public/react/package.json @@ -79,6 +79,7 @@ "react-url-query": "^1.4.0", "redux": "^4.0.0", "redux-thunk": "2.3.0", + "rsuite": "^4.0.1", "store": "^2.0.12", "style-loader": "0.19.0", "styled-components": "^4.1.3", diff --git a/public/react/src/modules/courses/coursesPublic/ModulationModal.js b/public/react/src/modules/courses/coursesPublic/ModulationModal.js index 974077793..1857f6814 100644 --- a/public/react/src/modules/courses/coursesPublic/ModulationModal.js +++ b/public/react/src/modules/courses/coursesPublic/ModulationModal.js @@ -94,7 +94,19 @@ class ModulationModal extends Component{