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 :applied_projects, dependent: :destroy
# 教学案例
has_many :libraries, dependent: :destroy
# Groups and active users # Groups and active users
scope :active, lambda { where(status: STATUS_ACTIVE) } scope :active, lambda { where(status: STATUS_ACTIVE) }

@ -56,7 +56,7 @@ class Libraries::SaveService < ApplicationService
destroy_ids = old_attachment_id - attachment_ids destroy_ids = old_attachment_id - attachment_ids
library.attachments.where(id: destroy_ids).delete_all 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 end
def library_params def library_params

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

@ -1,17 +1,72 @@
class ModifyKeContentsForMarkdown < ActiveRecord::Migration[5.2] class ModifyKeContentsForMarkdown < ActiveRecord::Migration[5.2]
# include ActionView::Helpers::SanitizeHelper include ActionView::Helpers::SanitizeHelper
def change def change
# def ke_transform_to_md content def ke_transform_to_md content
# sanitize(content, tags: %w(img a span), attributes: %w(src href target style)) sanitize(content, tags: %w(img a span), attributes: %w(src href target style))
# .gsub(/^(\n)/, "").gsub(/(\n)+/, "<br />").gsub(/$(\n)/, "") .gsub(/^(\n)/, "").gsub(/(\n)+/, "<br />").gsub(/$(\n)/, "")
# .gsub(/(\n)+/, "<br />").gsub("\t", "&nbsp;&nbsp;&nbsp;&nbsp;") .gsub(/(\n)+/, "<br />").gsub("\t", "&nbsp;&nbsp;&nbsp;&nbsp;")
# end end
#
# MessageDetail.find_each do |m| # 课程讨论区
# content = ke_transform_to_md m.content MessageDetail.find_each do |m|
# puts("content:#{content}") content = ke_transform_to_md m.content
# m.update_column(:content, content) puts("content:#{content}")
# end 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 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 './Comment.css'
import Modals from '../modals/Modals' import Modals from '../modals/Modals'
import { InputNumber } from 'antd'
/* /*
-------------------------- 样式相关 -------------------------- 样式相关
@ -470,7 +471,8 @@ class Comments extends Component {
onGoldRewardDialogOkBtnClick() { onGoldRewardDialogOkBtnClick() {
console.log('onGoldRewardDialogOkBtnClick') console.log('onGoldRewardDialogOkBtnClick')
const { goldRewardInput } = this.state; const { goldRewardInput } = this.state;
if (!goldRewardInput || goldRewardInput === '0' || goldRewardInput.indexOf('-') !== -1) { // || goldRewardInput.indexOf('-') !== -1
if (!goldRewardInput || goldRewardInput === '0' ) {
this.setState({ goldRewardInputError: true}) this.setState({ goldRewardInputError: true})
return; return;
} else { } else {
@ -478,8 +480,13 @@ class Comments extends Component {
this.props.rewardCode(this.comment, this.childComment, goldRewardInput) this.props.rewardCode(this.comment, this.childComment, goldRewardInput)
} }
} }
onGoldRewardInputChange(event) { onGoldRewardInputChange(value) {
this.setState({ goldRewardInput: event.target.value, goldRewardInputError: false }); // e.target.value
const number = parseInt(value || 0, 10);
if (Number.isNaN(number)) {
return;
}
this.setState({ goldRewardInput: number, goldRewardInputError: false });
} }
render() { render() {
const { deleteComment, onPaginationChange, comment_count_without_reply, currentPage, comments, usingAntdModal } = this.props; 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> <DialogTitle id="alert-dialog-title">{"奖励设置"}</DialogTitle>
<DialogContent> <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> <InputLabel htmlFor="goldReward">请输入奖励的金币数量</InputLabel>
<Input id="goldReward" type="number" value={this.state.goldRewardInput} onChange={(e) => this.onGoldRewardInputChange(e)} /> <Input id="goldReward" type="number" value={this.state.goldRewardInput} onChange={(e) => this.onGoldRewardInputChange(e)} />
{ goldRewardInputError ? <FormHelperText id="name-error-text">奖励金币不能为空或负数</FormHelperText> : ''} { goldRewardInputError ? <FormHelperText id="name-error-text">奖励金币不能为空或负数</FormHelperText> : ''}
</FormControl> </FormControl> */}
{/*<DialogContentText id="alert-dialog-description" style={{textAlign: 'center'}}> </DialogContentText>*/} {/*<DialogContentText id="alert-dialog-description" style={{textAlign: 'center'}}> </DialogContentText>*/}
</DialogContent> </DialogContent>

@ -48,9 +48,13 @@ class RewardDialog extends Component {
this.props.rewardCode(goldRewardInput) this.props.rewardCode(goldRewardInput)
} }
} }
onGoldRewardInputChange(event) { onGoldRewardInputChange(value) {
// || event.target.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() { render() {

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

@ -195,7 +195,7 @@ class DetailTop extends Component{
detailInfoList && detailInfoList &&
<ul className="fl color-grey-eb pathInfo"> <ul className="fl color-grey-eb pathInfo">
{ detailInfoList.stages_count!=0 ? <li><span>章节</span><span className="ml5">{detailInfoList.stages_count}</span></li> : ""} { 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.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.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> : ""} { detailInfoList.subject_score!=0 ? <li><span>经验值</span><span>{detailInfoList.subject_score}</span></li> : ""}

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

Loading…
Cancel
Save