diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d889de36d..dbdcaea40 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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" diff --git a/app/views/users/courses/shared/_course.json.jbuilder b/app/views/users/courses/shared/_course.json.jbuilder index e917033da..8da80f372 100644 --- a/app/views/users/courses/shared/_course.json.jbuilder +++ b/app/views/users/courses/shared/_course.json.jbuilder @@ -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) diff --git a/public/react/config/webpack.config.dev.js b/public/react/config/webpack.config.dev.js index b4f1aec9f..aabcd8fb7 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: "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. diff --git a/public/react/src/modules/courses/busyWork/NewWorkForm.js b/public/react/src/modules/courses/busyWork/NewWorkForm.js index bc74576d3..c52350c78 100644 --- a/public/react/src/modules/courses/busyWork/NewWorkForm.js +++ b/public/react/src/modules/courses/busyWork/NewWorkForm.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{ }], })( + initValue={this.state.description} noSetValueOnInit={!!this.isEdit} + className="courseMessageMD" > )} } @@ -507,7 +520,8 @@ class NewWorkForm extends Component{ }], })( + initValue={this.state.reference_answer || ''} noSetValueOnInit={!!this.isEdit} + className="courseMessageMD" refreshTimeout={1500} > )} diff --git a/public/react/src/modules/courses/common/CBreadcrumb.js b/public/react/src/modules/courses/common/CBreadcrumb.js index 6e3343edf..bf98a3a36 100644 --- a/public/react/src/modules/courses/common/CBreadcrumb.js +++ b/public/react/src/modules/courses/common/CBreadcrumb.js @@ -16,7 +16,7 @@ class CBreadcrumb extends Component{ return '' } if (item.to) { - return + return {item.name} {separator ? {separator} : @@ -24,7 +24,7 @@ class CBreadcrumb extends Component{ } } else { - return {item.name} + return {item.name} } })}

diff --git a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js index 366f239d0..90fb3939b 100644 --- a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js +++ b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js @@ -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', diff --git a/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js b/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js index 91cb34954..5d54f514b 100644 --- a/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js +++ b/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js @@ -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) {