dev_jupyter
daiao 5 years ago
commit 24a8002ad8

@ -23,11 +23,11 @@ class ApplicationController < ActionController::Base
# 所有请求必须合法签名
def check_sign
if !Rails.env.development? && EduSetting.get("host_name") != "https://test-newweb.educoder.net"
if !Rails.env.development?
Rails.logger.info("66666 #{params}")
suffix = request.url.split(".").last.split("?").first
suffix_arr = ["xls", "xlsx", "pdf"] # excel文件先注释
unless suffix_arr.include?(suffix)
# suffix = request.url.split(".").last.split("?").first
# suffix_arr = ["xls", "xlsx", "pdf", "zip"] # excel文件先注释
# unless suffix_arr.include?(suffix)
if params[:client_key].present?
randomcode = params[:randomcode]
# tip_exception(501, "请求不合理") unless (Time.now.to_i - randomcode.to_i).between?(0,5)
@ -38,7 +38,7 @@ class ApplicationController < ActionController::Base
else
tip_exception(501, "请求不合理")
end
end
# end
end
end

@ -606,10 +606,10 @@ class GraduationTasksController < ApplicationController
end
def graduation_task_params
tip_exception("task_type参数不能为空") if params[:task_type].blank?
tip_exception("name参数不能为空") if params[:name].blank?
tip_exception("name参数不能超过60个字符") if params[:name].length > 60 #6.11 -hs
tip_exception("description参数不能为空") if params[:description].blank?
tip_exception("类型参数不能为空") if params[:task_type].blank?
tip_exception("名称不能为空") if params[:name].blank?
tip_exception("名称不能超过60个字符") if params[:name].length > 60 #6.11 -hs
tip_exception("描述不能为空") if params[:description].blank?
params.require(:graduation_task).permit(:task_type, :name, :description)
end

@ -62,9 +62,9 @@ class HacksController < ApplicationController
ItemBank.create!(new_item_params)
end
render_ok({identifier: hack.identifier})
rescue Exception => e
rescue => e
logger.error("########create_hack_error: #{e.message}")
render_error("创建失败")
render_error("创建失败: #{e.message}")
end
end
@ -96,7 +96,7 @@ class HacksController < ApplicationController
render_ok
rescue Exception => e
logger.error("####update_hack_error: #{e.message}")
render_error("更新失败")
render_error("更新失败: #{e.message}")
end
end

@ -306,7 +306,7 @@ class HomeworkCommonsController < ApplicationController
def alter_name
tip_exception("作业名称不能为空") if params[:name].blank?
@homework.update_attributes(name: params[:name].strip)
@homework.update_attributes!(name: params[:name].strip)
normal_status("更新成功")
end
@ -348,7 +348,7 @@ class HomeworkCommonsController < ApplicationController
end
def update_explanation
@homework.update_attributes(explanation: params[:explanation])
@homework.update_attributes!(explanation: params[:explanation])
normal_status(0, "更新成功")
end
@ -416,7 +416,7 @@ class HomeworkCommonsController < ApplicationController
ActiveRecord::Base.transaction do
begin
@homework.update_attributes(homework_params)
@homework.update_attributes!(homework_params)
if @homework.homework_type == "group"
homework_detail_group = @homework.homework_detail_group
@ -521,7 +521,7 @@ class HomeworkCommonsController < ApplicationController
score = challenge[:challenge_score]
if setting && setting.score != score
score_change = true
setting.update_attributes(score: score)
setting.update_attributes!(score: score)
elsif setting.blank?
score_change = true
HomeworkChallengeSetting.create!(homework_common_id: @homework.id, challenge_id: challenge[:challenge_id],
@ -1159,11 +1159,11 @@ class HomeworkCommonsController < ApplicationController
if homework_bank.present?
# 如果作业加入过题库则更新参数
if homework_bank.homework_type == 1
homework_bank.update_attributes(name: homework.name, description: homework.description,
homework_bank.update_attributes!(name: homework.name, description: homework.description,
reference_answer: homework.reference_answer, course_list_id: @course.course_list_id)
elsif homework_bank.homework_type == 3
homework_detail_group = homework.homework_detail_group
homework_bank.update_attributes(name: homework.name, description: homework.description,
homework_bank.update_attributes!(name: homework.name, description: homework.description,
reference_answer: homework.reference_answer, course_list_id: @course.course_list_id,
min_num: homework_detail_group.min_num, max_num: homework_detail_group.max_num,
base_on_project: homework_detail_group.base_on_project)
@ -1449,7 +1449,7 @@ class HomeworkCommonsController < ApplicationController
# 如果用户已有查重记录则更新相似度 否则新建一条记录
user_review = homework.homework_review_results.find_by(:user_id => user)
if user_review.present?
user_review.update_attributes(:code_rate => user_rate)
user_review.update_attributes!(:code_rate => user_rate)
else
homework.homework_review_results.create(:user_id => user, :code_rate => user_rate)
end

@ -144,7 +144,7 @@ class MemosController < ApplicationController
def reply
tip_exception("parent_id不能为空") if params[:parent_id].blank?
tip_exception("content不能为空") if params[:content].blank?
tip_exception("content不能超过1000字符") if params[:content].length > 1000
tip_exception("内容不能超过1000字符") if params[:content].length > 1000
ActiveRecord::Base.transaction do
begin

@ -3,7 +3,7 @@ class MyshixunsController < ApplicationController
before_action :find_myshixun, :except => [:training_task_status, :code_runinng_message]
before_action :find_repo_name, :except => [:training_task_status, :code_runinng_message]
skip_before_action :verify_authenticity_token, :only => [:html_content]
skip_before_action :check_sign, only: [:training_task_status, :code_runinng_message]
skip_before_action :check_sign, only: [:training_task_status, :code_runinng_message, :html_content]
## TPI关卡列表
def challenges

@ -57,6 +57,8 @@ class PollVotesController < ApplicationController
:vote_text => question_answer_text
}
PollVote.create(answer_option)
# 重新取一次poll_votes
user_votes = @poll_question.poll_votes.find_current_vote("user_id",current_user.id)
end
# if current_vote_text.present? #已有其他输入文字的选项
# current_vote_text.update_attribute("vote_text", question_answer_text)

@ -6,7 +6,7 @@ class ExaminationBanks::SaveExamForm
validates :discipline_id, presence: true
validates :sub_discipline_id, presence: true
validates :difficulty, presence: true, inclusion: {in: 1..3}, numericality: { only_integer: true }
validates :name, presence: true, length: { maximum: 60 }
validates :name, presence: true, length: { maximum: 60, too_long: "不能超过60个字符" }
validate :validate_duration
def validate_duration

@ -4,7 +4,7 @@ module Validate
attr_accessor :nickname, :lastname
validates :nickname, presence: true, length: { maximum: 10 }
validates :nickname, presence: true, length: { maximum: 10, too_long: "不能超过10个字符" }
validates :lastname, presence: true
end
end

@ -25,7 +25,7 @@ class Attachment < ApplicationRecord
scope :search_by_container, -> (ids) {where(container_id: ids)}
scope :unified_setting, -> {where("unified_setting = ? ", 1)}
validates_length_of :description, maximum: 100
validates_length_of :description, maximum: 100, message: "不能超过100个字符"
DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)

@ -28,7 +28,7 @@ class Challenge < ApplicationRecord
scope :fields_for_list, -> { select([:id, :subject, :st, :score, :position, :shixun_id]) }
validates :task_pass, length: { maximum: 10000 }
validates :task_pass, length: { maximum: 10000, too_long: "不能超过10000个字符" }
after_commit :create_diff_record

@ -3,7 +3,7 @@ class ChallengeAnswer < ApplicationRecord
belongs_to :challenge
has_many :game_answers, :dependent => :destroy
validates :contents, length: { maximum: 5000 }
validates :contents, length: { maximum: 5000 , too_long: "不能超过5000个字符"}
def view_answer_time(user_id)
game_answers.where(user_id: user_id).last&.view_time

@ -4,6 +4,6 @@ class ChallengeChoose < ApplicationRecord
has_many :challenge_tags, :dependent => :destroy
has_many :challenge_questions, dependent: :destroy
validates :subject, length: { maximum: 1000 }
validates :subject, length: { maximum: 1000, too_long: "不能超过1000个字符" }
end

@ -1,6 +1,6 @@
class ChallengeQuestion < ApplicationRecord
belongs_to :challenge_choose
validates :option_name, length: { maximum: 500 }
validates :option_name, length: { maximum: 500, too_long: "不能超过500个字符" }
end

@ -4,6 +4,8 @@ class ChallengeWorkScore < ApplicationRecord
belongs_to :challenge
has_many :tidings, as: :container, dependent: :destroy
validates :comment, length: { maximum: 500, too_long: "不能超过500个字符" }
def create_tiding trigger_user_id
tidings << Tiding.new(user_id: student_work.user_id, trigger_user_id: trigger_user_id, container_id: id,
container_type: "ChallengeWorkScore", parent_container_id: student_work_id,

@ -2,5 +2,5 @@ class ChartRule < ApplicationRecord
belongs_to :competition
belongs_to :competition_stage, optional: true
validates :content, length: { maximum: 1000 }
validates :content, length: { maximum: 1000, too_long: "不能超过1000个字符" }
end

@ -33,7 +33,7 @@ class Competition < ApplicationRecord
has_many :competition_prizes, dependent: :destroy
has_many :competition_prize_users, dependent: :destroy
validates :introduction, length: { maximum: 500 }
validates :introduction, length: { maximum: 500, too_long: "不能超过500个字符" }
before_save :set_laboratory
after_create :create_competition_modules

@ -5,6 +5,6 @@ class CompetitionModuleMdContent < ApplicationRecord
# validates :name, presence: true
validates :content, presence: true
validates :content, length: { maximum: 10000 }
validates :content, length: { maximum: 10000 , too_long: "不能超过10000个字符"}
end

@ -108,7 +108,7 @@ class Course < ApplicationRecord
NORMAL = 6 # 普通用户
Anonymous = 7 # 普未登录
validates :name, presence: true, length: { maximum: 60 }
validates :name, presence: true, length: { maximum: 60, too_long: "不能超过60个字符" }
before_save :set_laboratory
after_create :create_board_sync, :act_as_course_activity, :send_tiding

@ -9,7 +9,7 @@ class CourseGroup < ApplicationRecord
has_many :homework_group_settings, :dependent => :destroy
scope :by_group_ids, lambda { |ids| where(id: ids)}
validates :name, length: { maximum: 60 }
validates :name, length: { maximum: 60, too_long: "不能超过60个字符" }
validates_uniqueness_of :name, scope: :course_id, message: "不能创建相同名称的分班"
after_create :generate_invite_code

@ -5,7 +5,7 @@ class CourseModule < ApplicationRecord
# 二级目录
has_many :course_second_categories
validates :module_name, length: { maximum: 20 }
validates :module_name, length: { maximum: 20, too_long: "不能超过20个字符" }
scope :not_hidden, -> { where(hidden: 0) }
scope :graduation_module, -> { where(module_type: "graduation") }

@ -5,7 +5,7 @@ class CourseSecondCategory < ApplicationRecord
belongs_to :course_module
has_many :homework_commons
validates :name, length: { maximum: 60 }
validates :name, length: { maximum: 60, too_long: "不能超过60个字符" }
def category_type_str
category_type == "graduation" && name == "毕设选题" ? "graduation_topics" : (

@ -4,6 +4,6 @@ class CourseStage < ApplicationRecord
has_many :course_stage_shixuns, -> { order("course_stage_shixuns.position ASC") }, dependent: :destroy
has_many :shixuns, :through => :course_stage_shixuns
validates :name, length: { maximum: 60 }
validates :description, length: { maximum: 300 }
validates :name, length: { maximum: 60 , too_long: "不能超过60个字符"}
validates :description, length: { maximum: 1000, too_long: "不能超过1000个字符" }
end

@ -13,7 +13,7 @@ class Discuss < ApplicationRecord
belongs_to :challenge, optional: true
validate :validate_sensitive_string
validates :content, length: { maximum: 1000 }
validates :content, length: { maximum: 1000, too_long: "不能超过1000个字符" }
after_create :send_tiding

@ -19,8 +19,8 @@ class Exercise < ApplicationRecord
scope :exercise_search, lambda { |keywords|
where("exercise_name LIKE ?", "%#{keywords}%") unless keywords.blank?}
validates :exercise_name, length: { maximum: 60, too_long: "60 characters is the maximum allowed" }
validates :exercise_description, length: { maximum: 100 }
validates :exercise_name, length: { maximum: 60, too_long: "不能超过60个字符" }
validates :exercise_description, length: { maximum: 100, too_long: "不能超过100个字符" }
after_create :create_exercise_list

@ -11,6 +11,6 @@ class ExerciseAnswer < ApplicationRecord
scope :exercise_answer_is_right, -> {where("score > ?",0.0)} #判断答案是否正确根据分数总和大于0
scope :score_reviewed, lambda {where("score >= ?",0.0)} #是否评分,用于判断主观题的
validates :answer_text, length: { maximum: 5000 }
validates :answer_text, length: { maximum: 5000, too_long: "不能超过5000个字符" }
end

@ -7,5 +7,5 @@ class ExerciseAnswerComment < ApplicationRecord
scope :search_answer_comments, lambda {|name,ids| where("#{name}":ids)}
validates :comment, length: { maximum: 100 }
validates :comment, length: { maximum: 100, too_long: "不能超过100个字符" }
end

@ -18,7 +18,7 @@ class ExerciseBank < ApplicationRecord
scope :exercise_bank_search, lambda { |keywords|
where("name LIKE ?", "%#{keywords}%") unless keywords.blank?}
validates :name, length: { maximum: 60, too_long: "60 characters is the maximum allowed" }
validates :description, length: { maximum: 100, too_long: "100 characters is the maximum allowed" }
validates :name, length: { maximum: 60, too_long: "不能超过60个字符" }
validates :description, length: { maximum: 100, too_long: "不能超过100个字符" }
end

@ -5,6 +5,6 @@ class ExerciseBankChoice < ApplicationRecord
scope :find_choice_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题
scope :left_choice_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题
validates :choice_text, length: { maximum: 500 }
validates :choice_text, length: { maximum: 500, too_long: "不能超过500个字符" }
end

@ -11,7 +11,7 @@ class ExerciseBankQuestion < ApplicationRecord
scope :left_question_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题
scope :find_objective_questions, -> {where("question_type != ?",4)} #查找全部客观题
validates :question_title, length: { maximum: 1000 }
validates :question_title, length: { maximum: 1000, too_long: "不能超过1000个字符" }
def question_type_name
case self.question_type

@ -4,6 +4,6 @@ class ExerciseBankStandardAnswer < ApplicationRecord
#attr_accessible :answer_text
scope :standard_by_ids, lambda { |s| where(exercise_bank_choice_id: s) }
validates :answer_text, length: { maximum: 5000 }
validates :answer_text, length: { maximum: 5000, too_long: "不能超过5000个字符" }
end

@ -7,6 +7,6 @@ class ExerciseChoice < ApplicationRecord
scope :find_choice_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题
scope :left_choice_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题
validates :choice_text, length: { maximum: 500 }
validates :choice_text, length: { maximum: 500, too_long: "不能超过500个字符" }
end

@ -16,7 +16,7 @@ class ExerciseQuestion < ApplicationRecord
scope :left_question_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题
scope :find_objective_questions, -> {where("question_type != ?",4)} #查找全部客观题
validates :question_title, length: { maximum: 1000 }
validates :question_title, length: { maximum: 1000, too_long: "不能超过1000个字符" }
def question_type_name

@ -6,5 +6,5 @@ class ExerciseStandardAnswer < ApplicationRecord
scope :find_standard_answer_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题
scope :standard_by_ids, lambda { |s| where(exercise_choice_id: s) }
validates :answer_text, length: { maximum: 5000 }
validates :answer_text, length: { maximum: 5000, too_long: "不能超过5000个字符" }
end

@ -29,8 +29,8 @@ class GraduationTask < ApplicationRecord
belongs_to :gtask_bank, optional: true
validates :name, length: { maximum: 60 }
validates :description, length: { maximum: 5000 }
validates :name, length: { maximum: 60, too_long: "不能超过60个字符" }
validates :description, length: { maximum: 5000, too_long: "不能超过5000个字符" }
# 未提交
scope :unfinished, -> {where(status: 0)}

@ -19,10 +19,8 @@ class GraduationTopic < ApplicationRecord
#after_create :act_as_course_activity
# 课题名称和描述字段长度限制
validates :name, length: { maximum: 60,
too_long: "60 characters is the maximum allowed" }
validates :description, length: { maximum: 5000,
too_long: "5000 characters is the maximum allowed" }
validates :name, length: { maximum: 60, too_long: "不能超过60个字符" }
validates :description, length: { maximum: 5000, too_long: "不能超过5000个字符" }
def status_name
case self.status

@ -19,7 +19,7 @@ class GraduationWork < ApplicationRecord
# has_many :formal_graduation_task_group_assignations, -> { formal }, class_name: "GraduationTaskGroupAssignation"
# has_many :temporary_graduation_task_group_assignations, -> { temporary }, class_name: "GraduationTaskGroupAssignation"
validates :description, length: { maximum: 5000 }
validates :description, length: { maximum: 5000, too_long: "不能超过5000个字符" }
scope :has_committed, lambda { where("work_status != 0") }

@ -5,5 +5,5 @@ class GraduationWorkScore < ApplicationRecord
belongs_to :graduation_task
has_many :attachments, as: :container, dependent: :destroy
validates :comment, length: { maximum: 1000 }
validates :comment, length: { maximum: 1000, too_long: "不能超过1000个字符" }
end

@ -9,6 +9,6 @@ class GtaskBank < ApplicationRecord
scope :myself, ->(user_id) { where(user_id: user_id)}
scope :is_public, -> { where(:is_public => true) }
validates :name, length: { maximum: 60 }
validates :description, length: { maximum: 5000 }
validates :name, length: { maximum: 60, too_long: "不能超过60个字符" }
validates :description, length: { maximum: 5000, too_long: "不能超过5000个字符" }
end

@ -10,8 +10,6 @@ class GtopicBank < ApplicationRecord
# 课题名称和描述字段长度限制
validates :name, length: { maximum: 60,
too_long: "60 characters is the maximum allowed" }
validates :description, length: { maximum: 5000,
too_long: "5000 characters is the maximum allowed" }
validates :name, length: { maximum: 60, too_long: "不能超过60个字符" }
validates :description, length: { maximum: 5000, too_long: "不能超过5000个字符" }
end

@ -2,8 +2,8 @@ class Hack < ApplicationRecord
# status: 0 未发布; 1已发布
# diffcult: 难度 1简单2中等 3困难
# 编程题
validates_length_of :name, maximum: 60
validates_length_of :description, maximum: 5000
validates_length_of :name, maximum: 60, message: "不能超过60个字符"
validates_length_of :description, maximum: 5000, message: "不能超过5000个字符"
validates :description, presence: { message: "描述不能为空" }
validates :name, presence: { message: "名称不能为空" }
# 测试集

@ -1,6 +1,6 @@
class HackSet < ApplicationRecord
validates_length_of :input, maximum: 500
validates_length_of :output, maximum: 500
validates_length_of :input, maximum: 1000, message: "不能超过5000个字符"
validates_length_of :output, maximum: 1000, message: "不能超过5000个字符"
validates :input, presence: { message: "测试集输入不能为空" }
validates :output, presence: { message: "测试集输出不能为空" }
validates_uniqueness_of :input, scope: [:hack_id, :input], message: "多个测试集的输入不能相同"

@ -12,6 +12,6 @@ class HackUserLastestCode < ApplicationRecord
scope :mine_hack, ->(author_id){ where(user_id: author_id) }
scope :passed, -> {where(status: 1)}
validates_length_of :notes, maximum: 5000, message: "笔记不能超过5000个字"
validates_length_of :notes, maximum: 5000, message: "不能超过5000个字"
end

@ -10,7 +10,7 @@ class HomeworkBank < ApplicationRecord
scope :is_public, -> { where(is_public: true)}
scope :myself, ->(user_id) { where(user_id: user_id)}
validates :name, length: { maximum: 60 }
validates :description, length: { maximum: 15000 }
validates :reference_answer, length: { maximum: 15000 }
validates :name, length: { maximum: 60, too_long: "不能超过60个字符" }
validates :description, length: { maximum: 15000, too_long: "不能超过15000个字符" }
validates :reference_answer, length: { maximum: 15000, too_long: "不能超过15000个字符" }
end

@ -35,10 +35,10 @@ class HomeworkCommon < ApplicationRecord
# 学生的查重情况
has_many :homework_review_results, :dependent => :destroy
validates :name, length: { maximum: 60 }
validates :description, length: { maximum: 15000 }
validates :explanation, length: { maximum: 5000 }
validates :reference_answer, length: { maximum: 15000 }
validates :name, length: { maximum: 60, too_long: "不能超过60个字符" }
validates :description, length: { maximum: 15000, too_long: "不能超过15000个字符" }
validates :explanation, length: { maximum: 5000, too_long: "不能超过5000个字符" }
validates :reference_answer, length: { maximum: 15000, too_long: "不能超过15000个字符" }
# after_update :update_activity
before_destroy :update_homework_bank_quotes

@ -1,8 +1,8 @@
class Inform < ApplicationRecord
belongs_to :container, polymorphic: true, optional: true
validates :name, length: { maximum: 60 }
validates :description, length: { maximum: 5000 }
validates :name, length: { maximum: 60, too_long: "不能超过60个字符" }
validates :description, length: { maximum: 5000, too_long: "不能超过5000个字符" }
has_many :attachments, as: :container, dependent: :destroy

@ -26,7 +26,7 @@ class JournalsForMessage < ApplicationRecord
# "is_comprehensive_evaluation", # 1 教师评论、2 匿评、3 留言
# "hidden", 隐藏、
validates :notes, length: { maximum: 1000 }
validates :notes, length: { maximum: 1000, too_long: "不能超过1000个字符" }
after_create :send_tiding

@ -13,7 +13,7 @@ class Library < ApplicationRecord
has_one :praise_tread_cache, foreign_key: :object_id
has_many :praise_treads, as: :praise_tread_object, dependent: :destroy
validates :content, length: { maximum: 5000 }
validates :content, length: { maximum: 5000, too_long: "不能超过5000个字符" }
validates :uuid, presence: true, uniqueness: true

@ -27,7 +27,7 @@ class Memo < ApplicationRecord
scope :hot, -> { order("all_replies_count desc, updated_at desc") }
scope :posts, -> { where(root_id: nil, forum_id: [3, 5]) }
validates :content, length: { maximum: 10000 }
validates :content, length: { maximum: 10000, too_long: "不能超过10000个字符" }
after_create :send_tiding

@ -33,7 +33,7 @@ class Message < ApplicationRecord
#转发表
# has_many :forwards, as: :from, dependent: :destroy
validates :subject, length: { maximum: 255 }
validates :subject, length: { maximum: 255, too_long: "不能超过255个字符" }
def update_content(content)
message_detail.update_attributes(content: content)

@ -1,5 +1,5 @@
class MessageDetail < ApplicationRecord
belongs_to :message, :touch => true
validates :content, length: { maximum: 5000 }
validates :content, length: { maximum: 5000, too_long: "内容不能超过5000个字符" }
end

@ -24,8 +24,8 @@ class Poll < ApplicationRecord
scope :poll_search, lambda { |keywords|
where("polls_name LIKE ?", "%#{keywords}%") unless keywords.blank?}
validates :polls_name, length: { maximum: 60, too_long: "60 characters is the maximum allowed" }
validates :polls_description, length: { maximum: 100 }
validates :polls_name, length: { maximum: 60, too_long: "不能超过60个字符" }
validates :polls_description, length: { maximum: 100, too_long: "不能超过100个字符" }
after_create :create_polls_list

@ -8,6 +8,6 @@ class PollAnswer < ApplicationRecord
scope :find_answer_by_custom, lambda {|k,v| where("#{k}":v)} #根据传入的参数查找问题
scope :left_answer_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题
validates :answer_text, length: { maximum: 500 }
validates :answer_text, length: { maximum: 500, too_long: "不能超过500个字符" }
end

@ -9,7 +9,7 @@ class PollQuestion < ApplicationRecord
scope :ques_necessary, -> {where("is_necessary = ?",1)}
scope :insert_question, lambda {|k| where("question_number > ?",k)}
validates :question_title, length: { maximum: 1000 }
validates :question_title, length: { maximum: 1000, too_long: "不能超过1000个字符" }
def question_type_name
case self.question_type

@ -9,6 +9,6 @@ class PollVote < ApplicationRecord
scope :find_current_vote,lambda {|k,v| where("#{k}": v)}
scope :find_vote_text,-> {where("vote_text IS NOT NULL")}
validates :vote_text, length: { maximum: 5000 }
validates :vote_text, length: { maximum: 5000, too_long: "不能超过5000个字符" }
end

@ -0,0 +1,34 @@
class ProgramBank < ApplicationRecord
def oj_language
result = case language
when '1'
then 'C'
when '2'
then 'C++'
when '3'
then 'Python'
when '4'
then 'Java'
end
result
end
def strip_description
strip_html description
end
def oj_sub_discipline_id
result = case language
when '1'
then 3
when '2'
then 4
when '3'
then 5
when '4'
then 2
end
result
end
end

@ -0,0 +1,2 @@
class ProgramBankTest < ApplicationRecord
end

@ -1,10 +1,10 @@
class ShixunInfo < ApplicationRecord
belongs_to :shixun
validates_uniqueness_of :shixun_id
validates_length_of :fork_reason, maximum: 60
validates_length_of :fork_reason, maximum: 60, message: "不能超过60个字符"
after_commit :create_diff_record
validates :description, length: { maximum: 5000 }
validates :description, length: { maximum: 5000, too_long: "不能超过5000个字符" }
private

@ -2,6 +2,6 @@ class ShixunWorkComment < ApplicationRecord
belongs_to :student_work
belongs_to :user
belongs_to :challenge, optional: true
validates :comment, length: { maximum: 500 }
validates :hidden_comment, length: { maximum: 500 }
validates :comment, length: { maximum: 500, too_long: "不能超过500个字符" }
validates :hidden_comment, length: { maximum: 500, too_long: "不能超过500个字符" }
end

@ -6,6 +6,6 @@ class Stage < ApplicationRecord
has_many :stage_shixuns, -> { order("stage_shixuns.position ASC") }, dependent: :destroy
has_many :shixuns, :through => :stage_shixuns
validates :name, length: { maximum: 60 }
validates :description, length: { maximum: 1000 }
validates :name, length: { maximum: 60 , too_long: "不能超过60个字符" }
validates :description, length: { maximum: 1000, too_long: "不能超过1000个字符" }
end

@ -19,7 +19,7 @@ class StudentWork < ApplicationRecord
before_save :set_work_score
validates :description, length: { maximum: 5000 }
validates :description, length: { maximum: 5000, too_long: "不能超过5000个字符" }
scope :has_committed, lambda { where("work_status != 0") }
# 未提交

@ -7,7 +7,7 @@ class StudentWorksScore < ApplicationRecord
has_many :tidings, as: :container, dependent: :destroy
has_many :attachments, as: :container, dependent: :destroy
validates :comment, length: { maximum: 1000 }
validates :comment, length: { maximum: 1000, too_long: "不能超过1000个字符" }
scope :shixun_comment, lambda { where(is_ultimate: 0) }

@ -31,9 +31,9 @@ class Subject < ApplicationRecord
has_many :subject_shixun_infos, dependent: :destroy
has_many :subject_user_infos, dependent: :destroy
validates :name, length: { maximum: 60 }
validates :description, length: { maximum: 8000 }
validates :learning_notes, length: { maximum: 2000 }
validates :name, length: { maximum: 60, too_long: "不能超过60个字符" }
validates :description, length: { maximum: 8000, too_long: "不能超过8000个字符" }
validates :learning_notes, length: { maximum: 2000, too_long: "不能超过2000个字符" }
scope :visible, lambda{where(status: 2)}
scope :published, lambda{where(status: 1)}

@ -1,7 +1,7 @@
class TestSet < ApplicationRecord
# match_rule: 匹配规则: full 完全匹配, last 末尾匹配
#
validates :input, length: { maximum: 5000 }
validates :input, length: { maximum: 5000 }
validates :input, length: { maximum: 5000, too_long: "不能超过5000个字符" }
validates :output, length: { maximum: 5000, too_long: "不能超过5000个字符" }
end

@ -1,5 +1,5 @@
class TrustieHack < ApplicationRecord
validates_length_of :description, maximum: 500
validates_length_of :description, maximum: 500, message: "不能超过500个字符"
has_many :hack_users, :dependent => :destroy
belongs_to :trustie_hackathon, counter_cache: true

@ -2,23 +2,25 @@ class Subjects::ShixunUsedInfoService < ApplicationService
attr_reader :subject, :stages
def initialize(subject)
@subject = subject
@stages = subject.stages.includes(shixuns: [myshixuns: :games, homework_commons_shixuns: [homework_common: :course]])
@stages = subject.stages
end
def call
shixun_infos = []
stages.each do |stage|
position = stage.position
stage.shixuns.each_with_index do |shixun, index|
shixuns = stage.shixuns.includes(myshixuns: :games, homework_commons: :course)
shixuns.each_with_index do |shixun, index|
stage = "#{position}-#{index+1}"
name = shixun.name
myshixuns = shixun.myshixuns
challenge_count = shixun.challenges_count
course_count = shixun.homework_commons.map{|hc| hc.course_id}.uniq.size
school_count = shixun.homework_commons.map{|hc| hc.course&.school_id}.uniq.size
used_count = shixun.myshixuns_count
passed_count = shixun.myshixuns.select{|m| m.status == 1}.size
evaluate_count = shixun.myshixuns.map{|m| m.output_times }.sum
passed_ave_time = passed_count > 0 ? shixun.myshixuns.map{|m| m.total_cost_time}.sum : 0
passed_count = myshixuns.select{|m| m.status == 1}.size
evaluate_count = myshixuns.map{|m| m.output_times }.sum
passed_ave_time = passed_count > 0 ? myshixuns.map{|m| m.total_cost_time}.sum : 0
shixun_infos << {stage: stage, name: name, challenge_count: challenge_count, course_count: course_count,
school_count: school_count, used_count: used_count, passed_count: passed_count,
evaluate_count: evaluate_count, passed_ave_time: passed_ave_time, shixun_id: shixun.id}

@ -13,4 +13,157 @@ zh-CN:
'pending': '待审批'
'processed': '已审批'
'refused': '已拒绝'
'agreed': '已同意'
'agreed': '已同意'
activerecord:
attributes:
user:
login: '登录名'
lastname: '姓名'
nickname: '昵称'
discuss:
content: '内容'
journals_for_message:
notes: '内容'
subject:
name: '课程名称'
description: '课程简介'
learning_notes: '学习须知'
stage:
name: '章节名称'
description: '章节描述'
shixun_info:
description: '简介'
fork_reason: 'fork原因'
challenge:
task_pass: '过关任务'
test_set:
input: '输入'
output: '输出'
challenge_question:
option_name: '选项'
challenge_choose:
subject: '题干'
challenge_answer:
contents: '答案内容'
memo:
content: '帖子内容'
course:
name: '课堂名称'
course_group:
name: '分班名称'
course_module:
module_name: '目录名称'
course_second_category:
name: '目录名称'
inform:
name: '标题'
description: '内容'
course_stage:
name: '章节名称'
description: '章节描述'
attachment:
description: '资源描述'
message:
subject: '标题'
message_detail:
content: '内容'
homework_common:
name: '标题'
description: '内容'
explanation: '内容'
reference_answer: '参考答案'
student_work:
description: '内容'
student_work_score:
comment: '评语'
challenge_work_score:
comment: '评语'
shixun_work_comment:
comment: '评语'
hidden_comment: '隐藏评语'
graduation_topic:
name: '选题名称'
description: '选题简介'
graduation_task:
name: '任务标题'
description: '内容'
graduation_work:
description: '作品内容'
graduation_work_score:
comment: '评语'
poll:
polls_name: '问卷标题'
polls_description: '问卷须知'
poll_question:
question_title: '题干'
poll_answer:
answer_text: '选项'
poll_vote:
vote_text: '内容'
exercise:
exercise_name: '试卷标题'
exercise_description: '试卷须知'
exercise_question:
question_title: '题干'
exercise_choice:
choice_text: '选项'
exercise_answer:
answer_text: '答案'
exercise_standard_answer:
answer_text: '参考答案'
exercise_answer_comment:
comment: '评语'
homework_bank:
name: '标题'
description: '内容'
reference_answer: '参考答案'
gtask_bank:
name: '任务标题'
description: '内容'
gtopic_bank:
name: '选题名称'
description: '选题简介'
exercise_bank:
name: '试卷标题'
description: '试卷须知'
exercise_bank_question:
question_title: '题干'
exerise_bank_choice:
choice_text: '选项'
exercise_bank_standard_answer:
answer_text: '参考答案'
library:
title: '标题'
content: '内容'
author_name: '作者姓名'
author_school_name: '作者单位名称'
competition:
introduction: '简介'
competition_module_md_content:
content: '内容'
chart_rule:
content: '内容'
project_package:
title: '标题'
examination_bank:
name: '试卷名称'
item_bank:
name: '题干'
item_analysis:
analysis: '解析'
item_choice:
choice_text: '选项'
hack:
name: '任务名称'
description: '描述'
hack_set:
input: '测试集输入'
output: '测试集输出'
hack_user_lastest_code:
notes: '笔记'
trustie_hack:
description: '描述'

@ -1,7 +1,7 @@
class CreateSubjectRecords < ActiveRecord::Migration[5.2]
def change
create_table :subject_records do |t|
t.references :subject, unique: true
t.references :subject
t.integer :study_count, default: 0
t.integer :course_study_count, default: 0
t.integer :initiative_study, default: 0

@ -0,0 +1,6 @@
class AddIndexForSubjectRecords < ActiveRecord::Migration[5.2]
def change
remove_index :subject_records, :subject_id
add_index :subject_records, :subject_id, unique: true
end
end

@ -5,26 +5,35 @@ namespace :subjects do
puts("---------------------data_statistic_begin")
Rails.logger.info("---------------------data_statistic_begin")
subjects = Subject.where(status: 2)
str = ""
buffer_size = 0
column_value = "subject_id, study_count, course_study_count, initiative_study, passed_count, course_used_count, " +
"school_used_count, created_at, updated_at"
subjects.find_each do |subject|
puts("---------------------data_statistic: #{subject.id}")
Rails.logger.info("---------------------data_statistic: #{subject.id}")
sr = SubjectRecord.find_or_create_by!(subject_id: subject.id)
data = Subjects::DataStatisticService.new(subject)
study_count = data.study_count
# 总人数没有变化的话,不同课堂之类的变化了
course_study_count = (study_count == sr.study_count ? sr.course_study_count : data.course_study_count)
passed_count = (study_count == sr.study_count ? sr.passed_count : data.passed_count)
course_used_count = (study_count == sr.study_count ? sr.course_used_count : data.course_used_count)
school_used_count = (study_count == sr.study_count ? sr.school_used_count : data.school_used_count)
update_params = {
study_count: study_count,
course_study_count: course_study_count,
initiative_study: (study_count - course_study_count),
passed_count: passed_count,
course_used_count: course_used_count,
school_used_count: school_used_count
}
sr.update_attributes!(update_params)
next if study_count == 0
course_study_count = data.course_study_count
initiative_study = study_count - course_study_count
str += ", " unless str.empty?
str += ("(#{subject.id}, #{study_count}, #{course_study_count}, #{initiative_study}, " +
"#{data.passed_count}, #{data.course_used_count}, #{data.school_used_count}, " +
"'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')")
buffer_size += 1
if buffer_size == 1000
sql = "REPLACE INTO subject_records(#{column_value}) VALUES #{str}"
puts sql
ActiveRecord::Base.connection.execute sql
str = ""
buffer_size = 0
end
end
if buffer_size > 0
sql = "REPLACE INTO subject_records(#{column_value}) VALUES #{str}"
puts sql
ActiveRecord::Base.connection.execute sql
end
puts("---------------------data_statistic_end")
Rails.logger.info("---------------------data_statistic_end")
@ -34,22 +43,35 @@ namespace :subjects do
puts("---------------------course_info_statistic_begin")
Rails.logger.info("---------------------course_info_statistic_begin")
subjects = Subject.where(status: 2)
str = ""
buffer_size = 0
column_value = "subject_id, school_id, school_name, course_count, student_count, choice_shixun_num, " +
"choice_shixun_frequency, created_at, updated_at"
subjects.find_each do |subject|
puts("---------------------course_info_statistic: #{subject.id}")
Rails.logger.info("---------------------course_info_statistic: #{subject.id}")
data = Subjects::CourseUsedInfoService.call(subject)
data.each do |key|
scr = SubjectCourseRecord.find_or_create_by!(school_id: key[:school_id], subject_id: subject.id)
update_params = {
school_name: key[:school_name],
course_count: key[:course_count],
student_count: key[:student_count],
choice_shixun_num: key[:choice_shixun_num],
choice_shixun_frequency: key[:choice_shixun_frequency]
}
scr.update_attributes(update_params)
next if key[:school_id].nil?
str += ", " unless str.empty?
str += ("(#{subject.id}, #{key[:school_id]}, '#{key[:school_name]}', #{key[:course_count]}, " +
"#{key[:student_count]}, #{key[:choice_shixun_num]}, #{key[:choice_shixun_frequency]}, " +
"'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')")
buffer_size += 1
if buffer_size == 1000
sql = "REPLACE INTO subject_course_records(#{column_value}) VALUES #{str}"
puts sql
ActiveRecord::Base.connection.execute sql
str = ""
buffer_size = 0
end
end
end
if buffer_size > 0
sql = "REPLACE INTO subject_course_records(#{column_value}) VALUES #{str}"
puts sql
ActiveRecord::Base.connection.execute sql
end
puts("---------------------course_info_statistic_end")
Rails.logger.info("---------------------course_info_statistic_end")
end
@ -58,26 +80,36 @@ namespace :subjects do
puts("---------------------shixun_info_statistic_begin")
Rails.logger.info("---------------------shixun_info_statistic_begin")
subjects = Subject.where(status: 2)
str = ""
buffer_size = 0
column_value = "subject_id, shixun_id, stage, shixun_name, challenge_count, course_count, " +
"school_count, used_count, passed_count, evaluate_count, passed_ave_time, created_at, updated_at"
subjects.find_each(batch_size: 100) do |subject|
puts("---------------------shixun_info_statistic: #{subject.id}")
Rails.logger.info("---------------------shixun_info_statistic: #{subject.id}")
data = Subjects::ShixunUsedInfoService.call(subject)
data.each do |key|
ssi = SubjectShixunInfo.find_or_create_by!(shixun_id: key[:shixun_id], subject_id: subject.id)
update_params = {
stage: key[:stage],
shixun_name: key[:name],
challenge_count: key[:challenge_count],
course_count: key[:course_count],
school_count: key[:school_count],
used_count: key[:used_count],
passed_count: key[:passed_count],
evaluate_count: key[:evaluate_count],
passed_ave_time: key[:passed_ave_time]
}
ssi.update_attributes(update_params)
next if key[:shixun_id].nil?
str += ", " unless str.empty?
str += ("(#{subject.id}, #{key[:shixun_id]}, '#{key[:stage]}', '#{key[:name]}', #{key[:challenge_count]}, " +
"#{key[:course_count]}, #{key[:school_count]}, #{key[:used_count]}, #{key[:passed_count]}, " +
"#{key[:evaluate_count]}, #{key[:passed_ave_time]}, " +
"'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')")
buffer_size += 1
if buffer_size == 1000
sql = "REPLACE INTO subject_shixun_infos(#{column_value}) VALUES #{str}"
puts sql
ActiveRecord::Base.connection.execute sql
str = ""
buffer_size = 0
end
end
end
if buffer_size > 0
sql = "REPLACE INTO subject_shixun_infos(#{column_value}) VALUES #{str}"
puts sql
ActiveRecord::Base.connection.execute sql
end
puts("---------------------shixun_info_statistic_end")
Rails.logger.info("---------------------shixun_info_statistic_end")
end
@ -86,22 +118,34 @@ namespace :subjects do
puts("---------------------user_info_statistic_begin")
Rails.logger.info("---------------------user_info_statistic_begin")
subjects = Subject.where(status: 2)
subjects.find_each(batch_size: 100) do |subject|
str = ""
buffer_size = 0
column_value = "user_id, subject_id, username, passed_myshixun_count, passed_games_count, " +
"code_line_count, evaluate_count, cost_time, created_at, updated_at"
subjects.find_each(batch_size: 50) do |subject|
puts("---------------------user_info_statistic: #{subject.id}")
data = Subjects::UserUsedInfoService.call(subject)
data.each do |key|
sui = SubjectUserInfo.find_or_create_by!(user_id: key[:user_id], subject_id: subject.id)
update_params = {
username: key[:name],
passed_myshixun_count: key[:passed_myshixun_count],
passed_games_count: key[:passed_games_count],
code_line_count: key[:code_line_count],
evaluate_count: key[:evaluate_count],
cost_time: key[:cost_time]
}
sui.update_attributes(update_params)
next if key[:user_id].nil?
str += ", " unless str.empty?
str += ("(#{key[:user_id]}, #{subject.id}, '#{key[:name]}', '#{key[:passed_myshixun_count]}', " +
"#{key[:passed_games_count]}, #{key[:code_line_count]}, #{key[:evaluate_count]}, #{key[:cost_time]}, " +
"'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')")
buffer_size += 1
if buffer_size == 1000
sql = "REPLACE INTO subject_user_infos(#{column_value}) VALUES #{str}"
puts sql
ActiveRecord::Base.connection.execute sql
str = ""
buffer_size = 0
end
end
end
if buffer_size > 0
sql = "REPLACE INTO subject_user_infos(#{column_value}) VALUES #{str}"
puts sql
ActiveRecord::Base.connection.execute sql
end
puts("---------------------user_info_statistic_end")
Rails.logger.info("---------------------user_info_statistic_end")
end

@ -0,0 +1,70 @@
desc "同步trustie的编程作业"
namespace :sync_program do
DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)
task data: :environment do
ProgramBank.where(homework_type: 2).each do |program|
unless Hack.where(name: program.name).exists?
strip_des = strip_html(program.description, 5000)
description = strip_des.present? ? strip_des : program.name
hack_params = {name: program.name[0..59], description: description, difficult: 1, open_or_not: 1, score: 200, status:0, time_limit: 3, sub_discipline_id: program.oj_sub_discipline_id}
puts "language::::#{program.language}"
puts "program_bank::::#{program.id}"
hack = Hack.new(hack_params)
hack.user_id = 1
hack.identifier = generate_identifier Hack, 8
ActiveRecord::Base.transaction do
hack.save!
# 创建测试集与代码
position = 1
ProgramBankTest.where(homework_bank_id: program.id).each do |test_set|
if !test_set.input.blank? && !test_set.output.blank? && !hack.hack_sets.where(input: test_set.input).exists? && test_set.input.length <= 1000 && test_set.output.length <= 1000
hack.hack_sets.create!(input: test_set.input, output: test_set.output, position: position)
position += 1
end
end
# 新建知识点
hack_code_params = {code: program.standard_code.blank? ? nil : Base64.encode64(program.standard_code), language: program.oj_language}
hack_codes = hack.hack_codes.new(hack_code_params)
hack_codes.modify_time = Time.now
hack_codes.save!
new_item_params = {name: program.name, sub_discipline_id: program.oj_sub_discipline_id, container: hack, item_type: 'PROGRAM', public: 0, difficulty: 1, user_id: 1}
ItemBank.create!(new_item_params)
end
puts hack.id
end
end
end
# 随机生成字符
def generate_identifier(container, num)
code = DCODES.sample(num).join
if container == User
while container.exists?(login: code) do
code = DCODES.sample(num).join
end
else
while container.exists?(identifier: code) do
code = DCODES.sample(num).join
end
end
code
end
def strip_html(text, len=0, endss="...")
ss = ""
if !text.nil? && text.length>0
ss=text.gsub(/<\/?.*?>/, '').strip
ss = ss.gsub(/&nbsp;*/, '')
ss = ss.gsub(/\r\n/,'') #新增
ss = ss.gsub(/\n/,'') #新增
if len > 0 && ss.length > len
ss = ss[0, len-4] + endss
elsif len > 0 && ss.length <= len
ss = ss
#ss = truncate(ss, :length => len)
end
end
ss
end
end

@ -42,7 +42,7 @@ if (isDev) {
// 老师
//debugType="teacher";
// 学生
//debugType="student";
debugType="student";
function railsgettimes(proxy) {

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-12-18 08:49:30
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-10 15:05:27
* @LastEditTime : 2020-01-11 13:43:31
*/
import './index.scss';
import 'quill/dist/quill.core.css'; // 核心样式
@ -18,7 +18,7 @@ import deepEqual from './deepEqual.js'
import { fetchUploadImage } from '../../services/ojService.js';
import { getImageUrl } from 'educoder'
import ImageBlot from './ImageBlot';
import FillBlot from './FillBlot';
// import FillBlot from './FillBlot';
const Size = Quill.import('attributors/style/size');
const Font = Quill.import('formats/font');
// const Color = Quill.import('attributes/style/color');
@ -31,9 +31,9 @@ Quill.register(ImageBlot);
Quill.register(Size);
Quill.register(Font, true);
// Quill.register({'modules/toolbar': Toolbar});
Quill.register({
'formats/fill': FillBlot
});
// Quill.register({
// 'formats/fill': FillBlot
// });
// Quill.register(Color);
@ -87,12 +87,6 @@ function QuillForEditor ({
console.log('调用了tab=====>>>>');
}
},
enter: {
key: 'Enter',
handler: function () {
console.log('enter====>>>>>>');
}
},
backspace: {
key: 'Backspace',
/**
@ -103,7 +97,7 @@ function QuillForEditor ({
* @param {*} context 上下文
*/
handler: function (range, context) {
console.log('调用了删除按钮', range, context);
// console.log('调用了删除按钮', range, context);
/**
* 1. 根据range中的index及length值获取删除的起始位置
* length === 0 -> start = index - 1;
@ -112,13 +106,13 @@ function QuillForEditor ({
* ctx = this.quill.getText(start, length === 0 ? 1 : length);
* 3. 判断当前删除的下划线是第几个
*/
const {index, length} = range;
const _start = length === 0 ? index - 1 : index;
const _length = length || 1;
let delCtx = this.quill.getText(_start, _length);
// const {index, length} = range;
// const _start = length === 0 ? index - 1 : index;
// const _length = length || 1;
// let delCtx = this.quill.getText(_start, _length);
// aa
console.log(delCtx.match(/▁/g));
console.log('删除的文本信息=====>>>>', delCtx);
// console.log(delCtx.match(/▁/g));
// console.log('删除的文本信息=====>>>>', delCtx);
// const r = window.confirm('确定要删除吗?')
// if (r) {
// // 调用传入的删除事件
@ -153,12 +147,6 @@ function QuillForEditor ({
editorRef.current.appendChild(quillNode);
const _quill = new Quill(editorRef.current, quillOption);
// _quill.keyboard.addBinding({
// key: 'tab'
// }, function (range, context) {
// console.log('点击了键盘的删除按钮: ', range, context);
// });
setQuill(_quill);
// 处理图片上传功能
_quill.getModule('toolbar').addHandler('image', (e) => {

@ -75,9 +75,12 @@ class MemoDetailMDEditor extends Component {
}
onCommit = () => {
if(this.props.checkIfLogin()===false){
this.props.showLoginDialog()
return
}
if(this.props.checkIfProfileCompleted()===false){
this.props.showhideAccountPhoneemailDialog()
this.props.showaccountprofileDialog()
return
}
const content = this.commentMDEditor.getValue();

@ -396,7 +396,7 @@ export function TPMIndexHOC(WrappedComponent) {
});
}
fetchUser = () => {
let url = `/users/get_user_info.json`
let courseId;
@ -590,6 +590,17 @@ export function TPMIndexHOC(WrappedComponent) {
checkIfProfileCompleted = () => {
return this.state.current_user && this.state.current_user.profile_completed
}
showaccountprofileDialog = () => {
this.dialogObj = {
content: '您需要去完成您的个人资料,才能使用此功能',
okText: '立即完成',
okHref: '/account/profile'
}
this.setState({
AccountProfiletype: true,
})
}
showProfessionalCertificationDialog = () => {
this.dialogObj = {
content: '您需要去完成您的职业认证,才能使用此功能',
@ -713,6 +724,7 @@ export function TPMIndexHOC(WrappedComponent) {
showProfileCompleteDialog: this.showProfileCompleteDialog,
showhideAccountPhoneemailDialog:this.showhideAccountPhoneemailDialog,
checkIfProfileCompleted: this.checkIfProfileCompleted,
showaccountprofileDialog:this.showaccountprofileDialog,
checkIfProfessionalCertification: this.checkIfProfessionalCertification,
showProfessionalCertificationDialog: this.showProfessionalCertificationDialog,

@ -77,20 +77,20 @@ class Challengesjupyter extends Component {
}else{
if(boxoffsetHeigh>=300){
if(this.props&&this.props.is_jupyter===true&&this.props&&this.props.user.user_identity==="学生"){
this.setState({
opentitletype:false,
isopentitletype:"greater",
boxoffsetHeigh:boxoffsetHeigh
})
}else{
this.setState({
opentitletype:true,
isopentitletype:"greater",
boxoffsetHeigh:boxoffsetHeigh
})
}
// if(this.state.enlarge===false){
// this.setState({
// opentitletype:false,
// isopentitletype:"greater",
// boxoffsetHeigh:boxoffsetHeigh
// })
// }else{
//
// }
this.setState({
opentitletype:true,
isopentitletype:"greater",
boxoffsetHeigh:boxoffsetHeigh
})
}else{
this.setState({
isopentitletype:"Less",
@ -284,7 +284,7 @@ class Challengesjupyter extends Component {
.then((result) => {
if (result.data.status === 0) {
// this.props.showNotification(`应用成功`);
console.log("应用成功了");
// console.log("应用成功了");
this.props.showNotification('保存成功!');
setTimeout(() => {
this.setState({
@ -645,8 +645,8 @@ class Challengesjupyter extends Component {
`
}
</style>
{this.props&&this.props.is_jupyter===true&&this.props&&this.props.user.user_identity==="学生"?"":this.state.isopentitletype==="Less"?"":this.state.opentitletype===true?<Divider dashed={true} onClick={()=>this.opentitle()} className={"pointer Breadcrumbfont color-grey-9 "}>
{/*this.state.enlarge===false?"":*/}
{this.state.isopentitletype==="Less"?"":this.state.opentitletype===true?<Divider dashed={true} onClick={()=>this.opentitle()} className={"pointer Breadcrumbfont color-grey-9 "}>
<a className={"font-14 color-grey-9"}>阅读全文 <i className={"iconfont icon-jiantou9 font-14"}></i></a>
</Divider>:<Divider dashed={true} onClick={()=>this.opentitle()} className={"pointer Breadcrumbfont color-grey-9 "}>
<a className={"font-14 color-grey-9"}>收起全文 <i className={"iconfont icon-changyongtubiao-xianxingdaochu-zhuanqu- font-14"}></i></a>
@ -725,10 +725,11 @@ class Challengesjupyter extends Component {
</div>
</div>
:""
: ""
:
(
admin===true||business===true||mysidentity===true?
<div style={{
height: '63px',
}} className={enlarge?"shixunjianjiecballenges edu-back-white intermediatecenter fangdaone":"shixunjianjiecballenges edu-back-white mt20"}>

@ -75,17 +75,18 @@ class ShixunCardList extends Component {
type="new";
}
if(typekeyid===key){
if(upcircle===true){
this.setState({
upcircle:false,
})
this.props.Shixunsupcircles("desc")
// this.props.Shixunsupcircles("desc")
}else if(upcircle===false){
this.setState({
upcircle:true,
})
this.props.Shixunsupcircles("asc")
// this.props.Shixunsupcircles("desc")
}
}else{
this.setState({
@ -93,8 +94,8 @@ class ShixunCardList extends Component {
})
}
//allevent
this.props.ShixunsState(false,type);
this.props.ShixunsState(false,type,"desc");
}

@ -296,21 +296,23 @@ class ShixunsIndex extends Component {
console.log(error)
});
}
ShixunsState=(val,type)=>{
ShixunsState=(val,type,sorts)=>{
// sort,
let {tag_level, tag_id, page, limit, keyword, status, diff,sort} = this.state;
let newsort=sort;
let newsort=sorts?sorts:sort;
this.setState({
order_by:type,
typepvisible:true,
pages:1,
// sort:sort
sort:sorts?sorts:sort
})
let params
// let vals=false
if(newsort===undefined){
newsort="desc"
}else{
newsort=sorts?sorts:sort
}
params= {
order_by:type,

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe ProgramBank, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe ProgramBankTest, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save