diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 317383d5a..dd015ba9e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -285,7 +285,7 @@ class ApplicationController < ActionController::Base def user_setup # # reacct静态资源加载不需要走这一步 - return if params[:controller] == "main" + #return if params[:controller] == "main" # Find the current user #Rails.logger.info("current_laboratory is #{current_laboratory} domain is #{request.subdomain}") User.current = find_current_user diff --git a/app/controllers/concerns/git_helper.rb b/app/controllers/concerns/git_helper.rb index 0d8604aac..efc073c86 100644 --- a/app/controllers/concerns/git_helper.rb +++ b/app/controllers/concerns/git_helper.rb @@ -41,7 +41,8 @@ module GitHelper # 更新文件代码 # content: 文件内容;message:提交描述 def update_file_content(content, repo_path, path, mail, username, message) - GitService.update_file(repo_path: repo_path, file_path: path, message: message, + content = Base64.encode64(content) + GitService.update_file_base64(repo_path: repo_path, file_path: path, message: message, content: content, author_name: username, author_email: mail) end diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index e8554300c..75a6012b0 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -1,5 +1,7 @@ class MainController < ApplicationController skip_before_action :check_sign + skip_before_action :user_setup + skip_before_action :setup_laboratory def first_stamp render :json => { status: 0, message: Time.now.to_i } diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 442881df2..7009726d8 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -931,7 +931,7 @@ class ShixunsController < ApplicationController page = params[:page] || 1 limit = params[:limit] || 20 @user_count = @users.count - @users = @users.page(page).per(limit) + @users = @users.page(page).per(20) end @@ -995,7 +995,7 @@ class ShixunsController < ApplicationController @courses = @courses.where(id: current_laboratory.all_courses) @course_count = @courses.count - @courses = @courses.page(page).per(limit) + @courses = @courses.page(page).per(10) end # 将实训发送到课程 diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index ca76ee953..22adf3005 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -850,7 +850,7 @@ module ExportHelper def make_zip_name(work, file_name="") Rails.logger.info("######################file_name: #{file_name}") # name = file_name === "" ? "" : (file_name[0, file_name.rindex('.')]+"_") - "#{work&.user&.student_id}_#{work&.user&.real_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" + "#{work&.homework_common.course&.user_group_name(work.user_id)}_#{work&.user&.student_id}_#{work&.user&.real_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" end def zipping(zip_name_refer, files_paths, output_path, is_attachment=false, not_exist_file=[]) diff --git a/app/services/git_service.rb b/app/services/git_service.rb index 7867d063e..eedac2595 100644 --- a/app/services/git_service.rb +++ b/app/services/git_service.rb @@ -2,16 +2,30 @@ # # 文档在 https://www.showdoc.cc/127895880302646?page_id=1077512172693249 # +require 'faraday' + class GitService class << self - ['add_repository', 'fork_repository', 'delete_repository', 'file_tree', 'update_file', 'file_content', 'commits', 'add_tree', 'delete_file'].each do |method| + ['add_repository', 'fork_repository', 'delete_repository', 'file_tree', 'update_file', 'file_content', 'commits', + 'add_tree', 'delete_file', 'update_file_base64'].each do |method| define_method method do |params| post(method, params) end end + def make_new_multipar_file(full_file_path) + Faraday::FilePart.new(full_file_path, 'application/octet-stream') + end + + #上传二进制文件 + #参数构造形式 + # {a: 'a', file: make_new_multipar_file('1.txt') } + def update_file_binary(params) + post_form('update_file', params) + end + private def root_url @@ -24,6 +38,19 @@ class GitService Rails.logger end + def post_form(action,params) + conn = Faraday.new(root_url) do |f| + f.request :multipart + f.request :url_encoded + f.adapter :net_http + end + + resp = conn.post("/api/#{action}", params) + + body = resp.body + parse_return(body) + end + def post(action, params) uri = URI.parse("#{root_url}/api/#{action}") https = Net::HTTP.new(uri.host, uri.port) @@ -32,6 +59,11 @@ class GitService req.body = params.to_json res = https.request(req) body = res.body + + parse_return(body) + end + + def parse_return(body) logger.info("--uri_exec: .....res is #{body}") content = JSON.parse(body) diff --git a/db/migrate/20200106092135_modify_viewed_count_for_subjects.rb b/db/migrate/20200106092135_modify_viewed_count_for_subjects.rb new file mode 100644 index 000000000..ecef2df69 --- /dev/null +++ b/db/migrate/20200106092135_modify_viewed_count_for_subjects.rb @@ -0,0 +1,10 @@ +class ModifyViewedCountForSubjects < ActiveRecord::Migration[5.2] + def change + + subjects = Subject.where(status: 2).includes(:shixuns) + subjects.find_each do |subject| + subject.update_attribute(:visits, subject.visits + subject.shixuns.pluck(:myshixuns_count).sum) + end + + end +end diff --git a/lib/tasks/zip_pack.rake b/lib/tasks/zip_pack.rake index 6e3140f47..393f7ab3c 100644 --- a/lib/tasks/zip_pack.rake +++ b/lib/tasks/zip_pack.rake @@ -1,7 +1,7 @@ # 执行示例 bundle exec rake zip_pack:shixun_pack args=123,2323 namespace :zip_pack do desc "手工打包作品" - OUTPUT_FOLDER = "/tmp" + OUTPUT_FOLDER = "#{Rails.root}/files/archiveZip" task :shixun_pack => :environment do @@ -27,7 +27,7 @@ namespace :zip_pack do pdfs << pdf begin zip.add(export.filename, pdf.path) - puts "out: #{export.filename}" + puts "out: #{export.filename}_#{pdf.path}" rescue => ex Rails.logger.error(ex.message) @@ -46,6 +46,21 @@ namespace :zip_pack do end end + task :homework_attach_pack => :environment do + include ExportHelper + if ENV['args'] + homework_id = ENV['args'] + homework = HomeworkCommon.find homework_id + zip_works = homework.student_works.where("work_status > 0") + if zip_works.size > 0 + zipfile = zip_homework_common homework, zip_works + else + zipfile = {:message => "no file"} + end + puts "out: #{zipfile}" + end + end + def filename_for_content_disposition(name) request.env['HTTP_USER_AGENT'] =~ %r{MSIE|Trident|Edge} ? ERB::Util.url_encode(name) : name end diff --git a/public/react/src/common/quillForEditor/README.md b/public/react/src/common/quillForEditor/README.md index bbec5eb50..0369164c7 100644 --- a/public/react/src/common/quillForEditor/README.md +++ b/public/react/src/common/quillForEditor/README.md @@ -4,7 +4,7 @@ * @Github: * @Date: 2020-01-06 16:20:03 * @LastEditors : tangjiang - * @LastEditTime : 2020-01-06 16:46:44 + * @LastEditTime : 2020-01-06 17:13:19 --> ## QuillForEditor 使用 [https://quilljs.com/] @@ -17,14 +17,14 @@ | 字段 | 描述 | | ----- | ----- | | placeholder | 提示信息 | - | readOnly | 只读(只读取模式时,没有 工具栏且内容不可编辑,通过用于展示quill内容) | + | readOnly | 只读(只读取模式时,没有 工具栏且内容不可编辑,通常用于展示quill内容) | | autoFocus | 自动获得焦点 | | options | 配置参数, 指定工具栏内容 | | value | 文本编辑器内容 | | imgAttrs | 指定上传图片的尺寸 | | style | 指定quill容器样式 | | wrapStyle | 指定包裹quill容器的样式| - | onContentChange | 当编辑器内容变化时调用此回调函数 | + | onContentChange | 当编辑器内容变化时调用此回调函数(注: 此时返回的内容为对象,提交到后台时需要格式成 JSON 字符串: JSON.stringify(xx)) | | showUploadImage | 点击放大上传成功后的图片, 返回上传成功后的图片 url, (评论时点击图片这么大)| @@ -63,7 +63,32 @@ ```` import QuillForEditor from 'xxx'; - + // 指定需要显示的工具栏信息, 不指定加载全部 + const options = [ + + ]; + + /** + * @description 获取编辑器返回的内容 + * @params [Object] value 编辑器内容 + */ + const handleCtxChange = (value) => { + // 编辑器内容非空判断 + const _text = quill.getText(); + const reg = /^[\s\S]*.*[^\s][\s\S]*$/; + if (!reg.test(_text)) { + // 处理编辑器内容为空 + } else { + // 提交到后台的内容需要处理一下; + value = JSON.stringify(value) + } + } + + + ```` diff --git a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js index 3727b88a2..65fa4e9da 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js @@ -734,21 +734,20 @@ background:rgba(204,204,204,0.2) !important; } `} - { excellent===true&&this.props.isAdminOrStudent()===false?"": - - - trigger.parentNode} visible={coursedata.teacher_applies_count===undefined?false:coursedata.teacher_applies_count>0?true:false} + + + trigger.parentNode} visible={excellent === true && this.props.isAdminOrStudent() === false ?false:coursedata.teacher_applies_count===undefined?false:coursedata.teacher_applies_count>0?true:false} placement="topLeft" title={
 																			 {coursedata.teacher_applies_count===undefined?"":coursedata.teacher_applies_count>0?
 																				 您有{coursedata.teacher_applies_count}条新的加入申请
-																					 this.setHistoryFun("/courses/"+this.props.match.params.coursesId+"/teachers?tab=2")}>
+																					 this.setHistoryFun("/courses/"+this.props.match.params.coursesId+"/teachers?tab=2")}>
 																			 
 																			 待审批
 																		 :""}
}> - this.setHistoryFun("/courses/"+this.props.match.params.coursesId+"/teachers")}> + this.setHistoryFun("/courses/"+this.props.match.params.coursesId+"/teachers")}> 教师 {coursedata.teacher_count} @@ -756,8 +755,8 @@ background:rgba(204,204,204,0.2) !important;
this.setHistoryFun("/courses/"+this.props.match.params.coursesId+"/students"):"":()=>this.setHistoryFun("/courses/"+this.props.match.params.coursesId+"/students")} + className={excellent === true && this.props.isAdminOrStudent() === false ?"":excellent===true&&coursedata.course_end === true?this.props.isAdminOrTeacher()===true?"pointer":"":"pointer"} + onClick={excellent === true && this.props.isAdminOrStudent() === false ?"":excellent===true&&coursedata.course_end === true?this.props.isAdminOrTeacher()===true?()=>this.setHistoryFun("/courses/"+this.props.match.params.coursesId+"/students"):"":()=>this.setHistoryFun("/courses/"+this.props.match.params.coursesId+"/students")} > 学生 {coursedata.student_count} @@ -766,7 +765,7 @@ background:rgba(204,204,204,0.2) !important; 学分 {coursedata.credit} }
-
} + {/*
  • */} {/**/} diff --git a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js index 2ce9c0e53..5fd2abdee 100644 --- a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js +++ b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js @@ -157,9 +157,9 @@ class Trainingjobsetting extends Component { this.props.triggerRef(this); - if (this.props.isAdmin() === false) { - this.cancelEdit() - } + // if (this.props.isAdmin() === false) { + // this.cancelEdit() + // } } // componentWillReceiveProps(nextProps) { @@ -383,6 +383,10 @@ class Trainingjobsetting extends Component { } let max = latedeductiontwos + len; let maxs = max.toFixed(1); + + // console.log(1) + // console.log(maxs) + this.setState({ CalculateMax: maxs, }) @@ -1212,7 +1216,8 @@ class Trainingjobsetting extends Component { } //总比分 Totalscorecalculation = (value) => { - debugger + // console.log(2) + // console.log(value) this.setState({ CalculateMax: value, }) @@ -2168,6 +2173,9 @@ class Trainingjobsetting extends Component { }) this.refs.targetElementTrainingjobsetting.scrollIntoView(); this.getTrainingjobsetting(false); + + // console.log(3) + // console.log(this.state.total_scoretwo) this.setState({ CalculateMax:this.state.total_scoretwo, }) @@ -2311,7 +2319,7 @@ class Trainingjobsetting extends Component { // console.log(this.props.isAdmin()) // console.log(this.state.code_review===false) // console.log("引入的分值"); - // console.log(this.state.work_efficiencys); + // console.log(this.state.CalculateMax); return ( diff --git a/public/react/src/modules/forums/MemoDetailKEEditor.js b/public/react/src/modules/forums/MemoDetailKEEditor.js index 9061d557c..64806c19e 100644 --- a/public/react/src/modules/forums/MemoDetailKEEditor.js +++ b/public/react/src/modules/forums/MemoDetailKEEditor.js @@ -25,16 +25,16 @@ class MemoDetailKEEditor extends Component { showEditor() { - $("html, body").animate({ scrollTop: $('#commentInput').offset().top - 100 }, 1000, () => { - if (this.keEditor) { - const FF = !(window.mozInnerScreenX == null); - if (FF) { - this.keEditor.focus() - } else { - this.keEditor.edit.win.document.body.focus() - } - } - }); + // $("html, body").animate({ scrollTop: $('#commentInput').offset().top - 100 }, 1000, () => { + // if (this.keEditor) { + // const FF = !(window.mozInnerScreenX == null); + // if (FF) { + // this.keEditor.focus() + // } else { + // this.keEditor.edit.win.document.body.focus() + // } + // } + // }); } render() { diff --git a/public/react/src/modules/forums/MemoDetailMDEditor.js b/public/react/src/modules/forums/MemoDetailMDEditor.js index 57a48fe91..fb89f5bca 100644 --- a/public/react/src/modules/forums/MemoDetailMDEditor.js +++ b/public/react/src/modules/forums/MemoDetailMDEditor.js @@ -108,13 +108,13 @@ class MemoDetailMDEditor extends Component { } showEditor() { - $("html, body").animate({ scrollTop: $('.commentInput:visible').offset().top - 100 }, 1000, () => { - if (this.commentMDEditor) { - this.commentMDEditor.cm.focus() - } else { - this.onMockInputClick() - } - }); + // $("html, body").animate({ scrollTop: $('.commentInput:visible').offset().top - 100 }, 1000, () => { + // if (this.commentMDEditor) { + // this.commentMDEditor.cm.focus() + // } else { + // this.onMockInputClick() + // } + // }); } close = () => { this.setState({isInited: false}) diff --git a/public/react/src/modules/forums/MemoDetailMDEditortwo.js b/public/react/src/modules/forums/MemoDetailMDEditortwo.js index eafc1451f..257294452 100644 --- a/public/react/src/modules/forums/MemoDetailMDEditortwo.js +++ b/public/react/src/modules/forums/MemoDetailMDEditortwo.js @@ -96,13 +96,13 @@ class MemoDetailMDEditortwo extends Component { } showEditor() { - $("html, body").animate({ scrollTop: $('#commentInput').offset().top - 100 }, 1000, () => { - if (this.commentMDEditor) { - this.commentMDEditor.cm.focus() - } else { - $('#commentInput input')[0].click() - } - }); + // $("html, body").animate({ scrollTop: $('#commentInput').offset().top - 100 }, 1000, () => { + // if (this.commentMDEditor) { + // this.commentMDEditor.cm.focus() + // } else { + // $('#commentInput input')[0].click() + // } + // }); } onMockInputClick = () => { this.setState({isInited: true}) diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js index 0e4ea3073..6e27f9591 100644 --- a/public/react/src/modules/tpm/NewHeader.js +++ b/public/react/src/modules/tpm/NewHeader.js @@ -1039,17 +1039,17 @@ submittojoinclass=(value)=>{ ` } -
  • - -
    -
    - 题库 -
    -
    -
    -
  • + {/*
  • */} + {/* */} + {/*
    */} + {/*
    */} + {/* 题库*/} + {/*
    */} + {/*
    */} + {/*
    */} + {/*
  • */}
  • - {/*{endjupytertime===false?"":}*/} + {endjupytertime===false?"":}

    diff --git a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js index d53a88327..3f2aa68a9 100644 --- a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js +++ b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js @@ -107,7 +107,7 @@ class Challengesjupyter extends Component { } - gettimeinfo_with_tpm=(datas)=>{ + gettimeinfo_with_tpm=(datas,type)=>{ let timeinfo_with_tpm=`/jupyters/timeinfo_with_tpm.json` axios.get(timeinfo_with_tpm, {params: datas}).then((response) => { if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { @@ -128,6 +128,9 @@ class Challengesjupyter extends Component { endtimes:endsms===0?Date.now()+1000:Date.now() +endsms }) },500); + if(type===true){ + this.props.showNotification('延长成功!'); + } } }else{ @@ -461,19 +464,21 @@ class Challengesjupyter extends Component { onendhandleClickResetTpi=(id)=>{ - + let datas={ + identifier:id, + } const url = `/jupyters/active_with_tpm.json`; axios.get(url,{params:{ identifier:id }}).then((response) => { if(response.data.status===0){ - this.props.showNotification('延长成功!'); - setTimeout(()=>{ - this.setState({ - jupytertime:Date.now() + 900 * 1000, - endtimes:Date.now() + 300 * 1000 - }) - },500); + this.gettimeinfo_with_tpm(datas,true) + // setTimeout(()=>{ + // this.setState({ + // jupytertime:Date.now() + 900 * 1000, + // endtimes:Date.now() + 300 * 1000 + // }) + // },500); } }); } @@ -550,7 +555,7 @@ class Challengesjupyter extends Component { {/*this.state.jupytertime*/} - {/*{endtimes===false?"":}*/} + {endtimes===false?"":}

    diff --git a/public/react/src/redux/actions/jupyter.js b/public/react/src/redux/actions/jupyter.js index 1a3654c3f..c4a723b3c 100644 --- a/public/react/src/redux/actions/jupyter.js +++ b/public/react/src/redux/actions/jupyter.js @@ -160,7 +160,8 @@ export const active_with_tpi = (identifier, msg) => { if (status === 0) { message.success(msg); // dispatch(addjypertime(Date.now() + 900 * 1000,false)) - setTimeout(()=>{dispatch(addjypertime(Date.now() + 900 * 1000, Date.now() + 300 * 1000))},800); + // setTimeout(()=>{dispatch(addjypertime(Date.now() + 900 * 1000, Date.now() + 300 * 1000))},800); + timeinfo_with_tpi(identifier,dispatch) } } })