Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

dev_oauth
杨树明 5 years ago
commit c9e13c644c

@ -126,10 +126,11 @@ module ApplicationHelper
# 用户图像url如果不存在的话source为匿名用户即默认使用匿名用户图像
def url_to_avatar(source)
if File.exist?(disk_filename(source.class, source.id))
ctime = File.ctime(disk_filename(source.class, source.id)).to_i
if source.class.to_s == 'User'
File.join(relative_path, ["#{source.class}", "#{source.id}"])
File.join(relative_path, ["#{source.class}", "#{source.id}"]) + "?t=#{ctime}"
else
File.join("images/avatars", ["#{source.class}", "#{source.id}"])
File.join("images/avatars", ["#{source.class}", "#{source.id}"]) + "?t=#{ctime}"
end
elsif source.class.to_s == 'User'
str = source.user_extension.try(:gender).to_i == 0 ? "b" : "g"

@ -5,6 +5,7 @@ json.members_count course.course_members_count
# json.homework_commons_count course.homework_commons_count
json.homework_commons_count get_tasks_count course
json.attachments_count course.attachments.count
json.visits course.visits
json.first_category_url module_url(course.course_modules.where(hidden: 0).order(position: :desc).first, course)

@ -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: "eval-source-map", // 开启调试
// devtool: "eval-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.

@ -70,10 +70,23 @@ class NewWorkForm extends Component{
contentFileList,
answerFileList,
}, () => {
setTimeout(() => {
this.contentMdRef.current.setValue(data.description || '')
this.answerMdRef.current.setValue(data.reference_answer || '')
}, 2000)
// setTimeout(() => {
// this._scrollToTop()
// 阻止setValue的滚动
// $(window).scroll( function() {
// $("html").scrollTop(0)
// $(window).unbind("scroll");
// });
/**
setValue会调用到 codemirror的 o.scrollIntoView(i), 会导致滚动条跳动
*/
// $('.editormd').parent().css('position', 'fixed').css('left', '-1000px')
// this.contentMdRef.current.setValue(data.description || '')
// this.answerMdRef.current.setValue(data.reference_answer || '')
// setTimeout(() => {
// $('.editormd').parent().css('position', '').css('left', 'auto')
// }, 100);
// }, 500)
this.props.form.setFieldsValue({
title: data.name,
@ -85,12 +98,13 @@ class NewWorkForm extends Component{
} else { // new
}
this._scrollToTop()
// this._scrollToTop()
}
_scrollToTop = () => {
setTimeout(() => {
$("html").animate({ scrollTop: 0 })
}, 1500)
// setTimeout(() => {
$("html").scrollTop(0)
// $("html").animate({ scrollTop: 0 })
// }, 1000)
}
// 输入title
@ -303,15 +317,13 @@ class NewWorkForm extends Component{
let{
title_value, contentFileList, answerFileList, max_num, min_num, base_on_project,
init_max_num, init_min_num,
title_num, course_name, category, has_commit, has_project,
isEdit
title_num, course_name, category, has_commit, has_project
}=this.state
const { current_user } = this.props
const courseId = this.state.course_id || this.props.match.params.coursesId ;
if ((isEdit) && !this.state.workLoaded) {
this.isEdit = this.isEdit || this.props.match.url.indexOf('/edit') != -1
if ((this.isEdit) && !this.state.description) {
return ''
}
const uploadProps = {
@ -439,7 +451,8 @@ class NewWorkForm extends Component{
}],
})(
<TPMMDEditor ref={this.contentMdRef} placeholder="请在此输入作业内容和要求,最大限制5000个字符" mdID={'courseContentMD'} refreshTimeout={1500}
className="courseMessageMD" initValue={this.state.description}></TPMMDEditor>
initValue={this.state.description} noSetValueOnInit={!!this.isEdit}
className="courseMessageMD" ></TPMMDEditor>
)}
</Form.Item> }
<Upload {...uploadProps} className="upload_1 newWorkUpload">
@ -507,7 +520,8 @@ class NewWorkForm extends Component{
}],
})(
<TPMMDEditor ref={this.answerMdRef} placeholder="请在此输入作业的参考答案,最大限制5000个字符" mdID={'workAnswerMD'}
className="courseMessageMD" refreshTimeout={1500} initValue={this.state.reference_answer || ''}></TPMMDEditor>
initValue={this.state.reference_answer || ''} noSetValueOnInit={!!this.isEdit}
className="courseMessageMD" refreshTimeout={1500} ></TPMMDEditor>
)}
</Form.Item>
<Upload {...answerUploadProps} className="upload_1 newWorkUpload resetNewWorkUpload">

@ -16,7 +16,7 @@ class CBreadcrumb extends Component{
return ''
}
if (item.to) {
return <React.Fragment>
return <React.Fragment key={index}>
<WordsBtn style="grey" className="fl hovercolorblue" to={item.to}>{item.name}</WordsBtn>
{separator ?
<span className="color-grey-9 fl ml3 mr3">{separator}</span> :
@ -24,7 +24,7 @@ class CBreadcrumb extends Component{
}
</React.Fragment>
} else {
return <span>{item.name}</span>
return <span key={index}>{item.name}</span>
}
})}
</p>

@ -1738,7 +1738,6 @@ class Trainingjobsetting extends Component {
flagPageEditstwo:releasetime,
flagPageEditsthrees:deadline,
flagPageEditsfor:endtime,
unifiedsetting:this.state.unifiedsetting,
});
if(this.state.work_efficiencys===true){
@ -1784,7 +1783,121 @@ class Trainingjobsetting extends Component {
} catch (e) {
}
};
//一进来就是老师要用的编辑页面
editSettings=(datas)=>{
console.log("编辑页面");
console.log(datas);
try {
if (datas.data.is_end === true) {
this.setState({
modalsType: true,
modalsTopval: "课堂已结束不能再修改!",
loadtype: true,
modalSave: this.cancelBox
})
} else {
var releasetime =true;
var deadline = true;
var endtime =true;
var whethertopays =true;
//发布时间
if(moment(datas.data.publish_time,"YYYY-MM-DD HH:mm")<=moment()){
releasetime=false;
}
//截止时间
if(moment(datas.data.end_time,"YYYY-MM-DD HH:mm")<=moment()){
deadline=false;
}
//结束时间
if(moment(datas.data.late_time,"YYYY-MM-DD HH:mm")<=moment()){
endtime=false;
}
if(datas.data.allowreplenishment === false){
whethertopays=false;
}
try {
if(datas.data&& datas.data.homework_status[0]==="未发布"){
this.setState({
flagPageEditsbox:true,
flagPageEdit: true,
whethertopay:whethertopays,
flagPageEditstwo:releasetime,
flagPageEditsthrees:deadline,
flagPageEditsfor:endtime,
completionefficiencyscore:true,
work_efficiencys:true,
unifiedsetting:datas.data.unifiedsetting,
latedeductiontwo:20,
});
//均分比例
try {
if(datas.data.proportion==="均分比例"){
this.Equalproportion(20);
}else if(datas.data.proportion==="经验值比例"){
this.Empiricalvalueratio(20);
}
}catch (e) {
}
}else {
this.setState({
flagPageEditsbox:true,
flagPageEdit: true,
whethertopay:whethertopays,
flagPageEditstwo:releasetime,
flagPageEditsthrees:deadline,
flagPageEditsfor:endtime,
unifiedsetting:datas.data.unifiedsetting,
});
if(datas.data.work_efficiencys===true){
this.setState({
completionefficiencyscore:true,
})
}else{
this.setState({
completionefficiencyscore:false,
})
}
}
}catch (e) {
this.setState({
flagPageEditsbox:true,
flagPageEdit: true,
whethertopay:whethertopays,
flagPageEditstwo:releasetime,
flagPageEditsthrees:deadline,
flagPageEditsfor:endtime,
unifiedsetting:datas.data.unifiedsetting,
});
if(datas.data.work_efficiencys===true){
this.setState({
completionefficiencyscore:true,
})
}else{
this.setState({
completionefficiencyscore:false,
})
}
}
if(datas.data.proportion === "自定义分值"){
this.setState({
boolUnitetwoname:"自定义分值",
boolUnitetwo: false,
flagPageEdits:true,
})
}
}
} catch (e) {
}
}
//取消编辑
cancelEdit = () => {
@ -1919,8 +2032,8 @@ class Trainingjobsetting extends Component {
const dataformat = 'YYYY-MM-DD HH:mm';
let {flagPageEdit,testscripttiptype,publish_timebool,end_timebool,late_timesbool,work_efficiencys,flagPageEdits,flagPageEditstwo,flagPageEditsbox,whethertopay,handclass,flagPageEditsthrees, flagPageEditsfor,rules,rulest,unifiedsetting,group_settings, course_group,unit_e_tip, borreds,borredss,unit_p_tip, end_time, late_time, score_open, publish_time, starttimetype, modalsType, modalsTopval, loadtype, modalSave, endtimetype, latetimetype, allowlate, latepenaltytype, jobsettingsdata, endOpen, mystyle, mystyles} = this.state;
console.log(publish_timebool);
console.log(!flagPageEditstwo);
// console.log(publish_timebool);
// console.log(!flagPageEditstwo);
const radioStyle = {
display: 'block',
height: '30px',

@ -236,19 +236,24 @@ export default class TPMMDEditor extends Component {
setTimeout(() => {
if (that.props.needRecreate == true) {
__editorName.recreate()
__editorName.recreate() // 注意 必须在setValue之前触发不然会清空
} else {
__editorName.resize()
}
console.log('timeout', __editorName.id)
__editorName.cm && __editorName.cm.refresh()
}, that.props.refreshTimeout || 500)
if (that.props.initValue != undefined && that.props.initValue != '') {
__editorName.setValue(that.props.initValue)
}
if (that.state.initValue) {
__editorName.setValue(that.state.initValue)
if (this.props.noSetValueOnInit) {
that.onEditorChange()
} else {
if (that.props.initValue != undefined && that.props.initValue != '') {
__editorName.setValue(that.props.initValue)
}
if (that.state.initValue) {
__editorName.setValue(that.state.initValue)
}
}
__editorName.cm.on("change", (_cm, changeObj) => {
that.contentChanged = true;
if (that.state.showError) {
@ -277,6 +282,7 @@ export default class TPMMDEditor extends Component {
onEditorChange = () => {
if (!this.answers_editormd) return;
const val = this.answers_editormd.getValue();
//console.log('onEditorChange', this.props.id, val)
try {
this.props.onChange && this.props.onChange(val)
} catch(e) {

Loading…
Cancel
Save