Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_hjm
cxt 6 years ago
commit 286793d71b

@ -132,6 +132,10 @@ class User < ApplicationRecord
# 项目
has_many :applied_projects, dependent: :destroy
# 教学案例
has_many :libraries, dependent: :destroy
# Groups and active users
scope :active, lambda { where(status: STATUS_ACTIVE) }

@ -56,7 +56,7 @@ class Libraries::SaveService < ApplicationService
destroy_ids = old_attachment_id - attachment_ids
library.attachments.where(id: destroy_ids).delete_all
Attachment.where(id: attachment_ids, author_id: user.id).update_all(container_type: library)
Attachment.where(id: attachment_ids, author_id: user.id).update_all(container_type: library.class.to_s, container_id: library.id)
end
def library_params

@ -1,6 +1,6 @@
class SyncIndexToUsers < ActiveRecord::Migration[5.2]
def change
# add_index :users, :login, unique: true
add_index :users, :login, unique: true
add_index :users, :mail, unique: true
add_index :users, :phone, unique: true
end

@ -1,17 +1,72 @@
class ModifyKeContentsForMarkdown < ActiveRecord::Migration[5.2]
# include ActionView::Helpers::SanitizeHelper
include ActionView::Helpers::SanitizeHelper
def change
# def ke_transform_to_md content
# sanitize(content, tags: %w(img a span), attributes: %w(src href target style))
# .gsub(/^(\n)/, "").gsub(/(\n)+/, "<br />").gsub(/$(\n)/, "")
# .gsub(/(\n)+/, "<br />").gsub("\t", "&nbsp;&nbsp;&nbsp;&nbsp;")
# end
#
# MessageDetail.find_each do |m|
# content = ke_transform_to_md m.content
# puts("content:#{content}")
# m.update_column(:content, content)
# end
def ke_transform_to_md content
sanitize(content, tags: %w(img a span), attributes: %w(src href target style))
.gsub(/^(\n)/, "").gsub(/(\n)+/, "<br />").gsub(/$(\n)/, "")
.gsub(/(\n)+/, "<br />").gsub("\t", "&nbsp;&nbsp;&nbsp;&nbsp;")
end
# 课程讨论区
MessageDetail.find_each do |m|
content = ke_transform_to_md m.content
puts("content:#{content}")
m.update_column(:content, content)
end
# 试卷的描述
Exercise.find_each do |e|
exercise_description = ke_transform_to_md e.exercise_description
puts("#exercise_description: #{exercise_description}")
e.update_column(:exercise_description, exercise_description)
end
# 试卷的标题
ExerciseQuestion.find_each do |eq|
question_title = ke_transform_to_md eq.question_title
puts("question_title:#{question_title}")
eq.update_column(:question_title, question_title)
end
# 试卷的答案
ExerciseStandardAnswer.find_each do |esa|
answer_text = ke_transform_to_md esa.answer_text
puts("answer_text: #{answer_text}")
esa.update_column(:answer_text, answer_text)
end
# 试卷题库
ExerciseBankQuestion.find_each do |ebq|
question_title = ke_transform_to_md ebq.question_title
puts("#question_title: #{question_title}")
end
# 问卷的标题
PollQuestion.find_each do |pq|
question_title = ke_transform_to_md pq.question_title
puts("question_title:#{question_title}")
pq.update_column(:question_title, question_title)
end
StudentWork
HomeworkCommon
JournalsForMessage
GraduationTask
GraduationTopic
GraduationWork
GtaskBank
GtopicBank
HomeworkBank
QuestionBank
ExerciseBankStandardAnswer
Memo
end

@ -0,0 +1,7 @@
class AddExecTimeToEvaluateRecords < ActiveRecord::Migration[5.2]
def change
remove_columns :evaluate_records, :exec_time if User.first.attributes.include?("exec_time")
add_column :evaluate_records, :exec_time, :integer
end
end

@ -23,6 +23,7 @@ import CommentItemMDEditor from './CommentItemMDEditor';
import './Comment.css'
import Modals from '../modals/Modals'
import { InputNumber } from 'antd'
/*
-------------------------- 样式相关
@ -470,7 +471,8 @@ class Comments extends Component {
onGoldRewardDialogOkBtnClick() {
console.log('onGoldRewardDialogOkBtnClick')
const { goldRewardInput } = this.state;
if (!goldRewardInput || goldRewardInput === '0' || goldRewardInput.indexOf('-') !== -1) {
// || goldRewardInput.indexOf('-') !== -1
if (!goldRewardInput || goldRewardInput === '0' ) {
this.setState({ goldRewardInputError: true})
return;
} else {
@ -478,8 +480,13 @@ class Comments extends Component {
this.props.rewardCode(this.comment, this.childComment, goldRewardInput)
}
}
onGoldRewardInputChange(event) {
this.setState({ goldRewardInput: event.target.value, goldRewardInputError: false });
onGoldRewardInputChange(value) {
// e.target.value
const number = parseInt(value || 0, 10);
if (Number.isNaN(number)) {
return;
}
this.setState({ goldRewardInput: number, goldRewardInputError: false });
}
render() {
const { deleteComment, onPaginationChange, comment_count_without_reply, currentPage, comments, usingAntdModal } = this.props;
@ -538,11 +545,14 @@ class Comments extends Component {
<DialogTitle id="alert-dialog-title">{"奖励设置"}</DialogTitle>
<DialogContent>
<FormControl { ...goldRewardInputErrorObj } aria-describedby="name-error-text">
<InputNumber placeholder="请输入奖励的金币数量" id="goldReward" type="number" value={this.state.goldRewardInput}
onChange={(e) => this.onGoldRewardInputChange(e)} width={228} style={{ width: '228px'}} />
{/* <FormControl { ...goldRewardInputErrorObj } aria-describedby="name-error-text">
<InputLabel htmlFor="goldReward">请输入奖励的金币数量</InputLabel>
<Input id="goldReward" type="number" value={this.state.goldRewardInput} onChange={(e) => this.onGoldRewardInputChange(e)} />
{ goldRewardInputError ? <FormHelperText id="name-error-text">奖励金币不能为空或负数</FormHelperText> : ''}
</FormControl>
</FormControl> */}
{/*<DialogContentText id="alert-dialog-description" style={{textAlign: 'center'}}> </DialogContentText>*/}
</DialogContent>

@ -48,9 +48,13 @@ class RewardDialog extends Component {
this.props.rewardCode(goldRewardInput)
}
}
onGoldRewardInputChange(event) {
onGoldRewardInputChange(value) {
// || event.target.value
this.setState({ goldRewardInput: event , goldRewardInputError: false });
const number = parseInt(value || 0, 10);
if (Number.isNaN(number)) {
return;
}
this.setState({ goldRewardInput: number , goldRewardInputError: false });
}
render() {

@ -68,7 +68,7 @@ class MemoShixun extends Component {
let currentPage = parseInt( arg_currentPage ? arg_currentPage : (parsed.page || 1) )
const paramsObject = {
page: currentPage - 1
page: currentPage // - 1 从1开始
}
let searchValue = arg_searchValue != undefined ? arg_searchValue : this.props.searchValue

@ -195,7 +195,7 @@ class DetailTop extends Component{
detailInfoList &&
<ul className="fl color-grey-eb pathInfo">
{ detailInfoList.stages_count!=0 ? <li><span>章节</span><span className="ml5">{detailInfoList.stages_count}</span></li> : ""}
{ detailInfoList.stage_shixuns_count!=0 ? <li><span>实训</span><span className="ml5">{ detailInfoList.stage_shixuns_count}</span></li> : ""}
{ detailInfoList.shixuns_count!=0 ? <li><span>实训</span><span className="ml5">{ detailInfoList.shixuns_count}</span></li> : ""}
{ detailInfoList.challenge_choose_count!=0 ? <li><span>选择题任务</span><span>{detailInfoList.challenge_choose_count}</span></li> : ""}
{ detailInfoList.challenges_count!=0 ? <li><span>实践任务</span><span>{detailInfoList.challenges_count}</span></li> : ""}
{ detailInfoList.subject_score!=0 ? <li><span>经验值</span><span>{detailInfoList.subject_score}</span></li> : ""}

@ -286,10 +286,10 @@ class SearchPage extends Component{
</span>
</span>}
{!!item.stage_shixuns_count && <span className="ml20 ziticor">
{!!item.shixuns_count && <span className="ml20 ziticor">
{/* <i className="iconfont icon-shixunguanqia ziticor"></i> */}
<span>实训数:
<span className="ml10 ziticor">{item.stage_shixuns_count}</span>
<span className="ml10 ziticor">{item.shixuns_count}</span>
</span>
</span>}
{type == 'subject' && !!item.visits_count && <span className="ml20 ziticor">

Loading…
Cancel
Save