diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 1c8928d98..f75dd7147 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -67,15 +67,11 @@ class ShixunsController < ApplicationController ## 排序参数 bsort = params[:sort] || 'desc' - case params[:order_by] || 'publish_time' - when 'new' - @shixuns = @shixuns.order("shixuns.status = 2 desc, shixuns.created_at #{bsort}") + case params[:order_by] || 'new' when 'hot' - @shixuns = @shixuns.order("shixuns.status = 2 desc, shixuns.myshixuns_count #{bsort}") - when 'mine' - @shixuns = @shixuns.order("shixuns.created_at #{bsort}") + @shixuns = @shixuns.order("shixuns.public = 2 desc, shixuns.myshixuns_count #{bsort}") else - @shixuns = @shixuns.order("shixuns.status = 2 desc, shixuns.publish_time #{bsort}") + @shixuns = @shixuns.order("shixuns.public = 2 desc, shixuns.publish_time #{bsort}") end # 用id计数会快10+MS左右,对于搜索的内容随着数据的增加,性能会提升一些。 @@ -265,7 +261,12 @@ class ShixunsController < ApplicationController project_fork(@new_shixun, @repo_path, current_user.login) ShixunMember.create!(:user_id => User.current.id, :shixun_id => @new_shixun.try(:id), :role => 1) - + # 如果是jupyter,先创建一个目录,为了挂载(因为后续数据集,开启Pod后环境在没销毁前,你上传数据集是挂载不上目录的,因此要先创建目录,方便中间层挂载) + if @new_shixun.is_jupyter? + folder = EduSetting.get('shixun_folder') + path = "#{folder}/#{@new_shixun.identifier}" + FileUtils.mkdir_p(path, :mode => 0777) unless File.directory?(path) + end # 同步复制关卡 if @shixun.challenges.present? @shixun.challenges.each do |challenge| diff --git a/app/services/jupyter_service.rb b/app/services/jupyter_service.rb index 143b2eda7..0f5af6cb8 100644 --- a/app/services/jupyter_service.rb +++ b/app/services/jupyter_service.rb @@ -20,15 +20,8 @@ module JupyterService logger.info "test_juypter: #{res}" @shixun_jupyter_port = res['port'] - jupyter_service = edu_setting('jupyter_service') - - url = - if false - "https://#{jupyter_service}:#{res['port']}/notebooks/data/workspace/myshixun_#{tpiID}/01.ipynb" - else - "https://#{res['port']}.#{jupyter_service}/notebooks/data/workspace/myshixun_#{tpiID}/01.ipynb" - end - return url + + "#{jupyter_service(res['port'])}/notebooks/data/workspace/myshixun_#{tpiID}/01.ipynb" end end @@ -55,7 +48,7 @@ module JupyterService tpiID = myshixun.id mount = myshixun.shixun.data_sets.present? - params = {tpiID: tpiID, identifier: shixun.identifier, needMount: mount, + params = {tpiID: tpiID, identifier: shixun.identifier, myshixunIdentifier: myshixun.identifier, needMount: mount, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"} res = uri_post uri, params @@ -69,14 +62,7 @@ module JupyterService repo_save_path = myshixun.repo_save_path - jupyter_service = edu_setting('jupyter_service') - - if false - "https://#{jupyter_service}:#{res['port']}/notebooks/data/workspace/myshixun_#{tpiID}/#{repo_save_path}/01.ipynb" - else - "https://#{res['port']}.#{jupyter_service}/notebooks/data/workspace/myshixun_#{tpiID}/#{repo_save_path}/01.ipynb" - end - + "#{jupyter_service(res['port'])}/notebooks/data/workspace/myshixun_#{tpiID}/#{repo_save_path}/01.ipynb" end end @@ -99,14 +85,8 @@ module JupyterService tpiID = "tpm#{shixun.id}" - jupyter_service = edu_setting('jupyter_service') - src_url = - if false - "https://#{jupyter_service}:#{jupyter_port}/nbconvert/notebook/data/workspace/myshixun_#{tpiID}/01.ipynb?download=true" - else - "https://#{jupyter_port}.#{jupyter_service}/nbconvert/notebook/data/workspace/myshixun_#{tpiID}/01.ipynb?download=true" - end - #https://47526.jupyter.educoder.net/nbconvert/notebook/data/workspace/myshixun_570461/f2ef5p798r20191210163135/01.ipynb?download=true + src_url = "#{jupyter_service(jupyter_port)}/nbconvert/notebook/data/workspace/myshixun_#{tpiID}/01.ipynb?download=true" + response = Faraday.get(src_url) if response.status.to_i != 200 @@ -133,15 +113,7 @@ module JupyterService tpiID = myshixun.id repo_save_path = myshixun.repo_save_path - jupyter_service = edu_setting('jupyter_service') - - src_url = - if false - "https://#{jupyter_service}:#{jupyter_port}/nbconvert/notebook/data/workspace/myshixun_#{tpiID}/#{repo_save_path}/01.ipynb?download=true" - else - "https://#{jupyter_port}.#{jupyter_service}/nbconvert/notebook/data/workspace/myshixun_#{tpiID}/#{repo_save_path}/01.ipynb?download=true" - end - + src_url = "#{jupyter_service(jupyter_port)}/nbconvert/notebook/data/workspace/myshixun_#{tpiID}/#{repo_save_path}/01.ipynb?download=true" response = Faraday.get(src_url) if response.status.to_i != 200 @@ -215,5 +187,9 @@ module JupyterService end end + def jupyter_service jupyter_port + edu_setting('jupyter_service').gsub("PORT", jupyter_port) + end + end diff --git a/app/services/shixuns/create_shixun_service.rb b/app/services/shixuns/create_shixun_service.rb index 08b515163..c85455901 100644 --- a/app/services/shixuns/create_shixun_service.rb +++ b/app/services/shixuns/create_shixun_service.rb @@ -44,9 +44,9 @@ class CreateShixunService < ApplicationService end # 如果是jupyter,先创建一个目录,为了挂载(因为后续数据集,开启Pod后环境在没销毁前,你上传数据集是挂载不上目录的,因此要先创建目录,方便中间层挂载) if shixun.is_jupyter? - folder = edu_setting('shixun_folder') + folder = EduSetting.get('shixun_folder') path = "#{folder}/#{identifier}" - FileUtils.mkdir_p(path, :mode => 0777) unless File.directory?(dir) + FileUtils.mkdir_p(path, :mode => 0777) unless File.directory?(path) end return shixun end diff --git a/public/react/src/modules/courses/poll/PollNew.js b/public/react/src/modules/courses/poll/PollNew.js index 248434295..7384c7f6e 100644 --- a/public/react/src/modules/courses/poll/PollNew.js +++ b/public/react/src/modules/courses/poll/PollNew.js @@ -893,6 +893,7 @@ class PollNew extends Component { //保存并继续 //保存并继续,即提交本题的新建并继续创建一个相同的题(该新题处于编辑模式,题目和选项不要清空) Deleteadddomtwo = (indexo, object,bool) => { + debugger var thiss = this; @@ -1449,7 +1450,6 @@ class PollNew extends Component { //object 单个数组数据 Deleteadddomthree = (indexo, object,bool) => { this.setState({ - Newdisplay:false, newoption: false, }) // console.log("deleteadddom 349") @@ -1477,6 +1477,7 @@ class PollNew extends Component { } if (newarr[indexo].question.question_title === "") { this.props.showNotification('题目不能为空!'); + return } if (max > 0) { @@ -1866,6 +1867,7 @@ class PollNew extends Component { }; question = {"question": questiontwo}; //插入多选题 + if (uuk !== -1) { // console.log("修改") this.edittotheserver(object, 2, arrc, null, object.question.max_choices, object.question.min_choices,object.question.answers.length); @@ -2014,7 +2016,11 @@ class PollNew extends Component { if (result !== undefined) { if (result.data.status === 0) { this.props.showNotification(`已完成`); + thiss.thisinitializationdatanew(); + this.setState({ + Newdisplay:false, + }) // console.log("确认创建问题") // console.log(result) // try { diff --git a/public/react/src/modules/courses/statistics/Statistics.js b/public/react/src/modules/courses/statistics/Statistics.js index 00a47a81d..21041a59c 100644 --- a/public/react/src/modules/courses/statistics/Statistics.js +++ b/public/react/src/modules/courses/statistics/Statistics.js @@ -99,7 +99,6 @@ class Statistics extends Component{ } getwork_scoredata=(page,group_ids,sort,key)=>{ - this.setState({ page:page, sort:sort, @@ -189,8 +188,45 @@ class Statistics extends Component{ } + //计算成绩 + setComputeTimet = (homeworkid) => { + let url = `/courses/${homeworkid}/calculate_all_shixun_scores.json`; + try { + this.props.yslslowCheckresults(); + } catch (e) { + + } + axios.get(url).then((response) => { + if (response) { + if (response.data.status === 0) { + let{page,group_ids,sort}=this.state; + setTimeout(() => { + try { + this.props.showNotification(`${response.data.message}`); + } catch (e) { + + } + try { + this.props.yslslowCheckresultsNo(); + } catch (e) { + + } + this.getwork_scoredata(page,group_ids,sort); + }, 2500); + } + } + }).catch((error) => { + try { + this.props.yslslowCheckresultsNo(); + } catch (e) { + + } + console.log(error) + }); + }; + render(){ - let {nd1,nd2,nd3,data,bomdata,course_members}=this.state; + let {nd1,nd2,nd3,data,bomdata,course_members,activeKey}=this.state; const columns = [ { @@ -360,12 +396,26 @@ class Statistics extends Component{ const operations = - {course_grouptype===false||this.state.course_groups.length===0?"":this.getwork_scoredata(1,group_idss,'desc')} - />} + {course_grouptype===false||this.state.course_groups.length===0?"": + this.state.activeKey==="1"? + this.getwork_scoredata(1,group_idss,'desc') + } + /> + :"" + } + { + this.state.activeKey==="1"? + this.setComputeTimet(this.props.match.params.coursesId)}>获取最新成绩 + :"" + } + { + this.state.activeKey==="1"? this.derivefun(this.state.activeKey==="1"?`/courses/${this.props.match.params.coursesId}/export_member_scores_excel.xlsx`:`/courses/${this.props.match.params.coursesId}/export_member_act_score.xlsx`)}>导出 + :"" + } ; return( diff --git a/public/react/src/modules/message/js/MessagChat.js b/public/react/src/modules/message/js/MessagChat.js index e320ff3a3..c88307b19 100644 --- a/public/react/src/modules/message/js/MessagChat.js +++ b/public/react/src/modules/message/js/MessagChat.js @@ -554,6 +554,17 @@ class MessagChat extends Component{ {myuserl!==undefined?myuserl.name:""}与你的私信

{/*聊天页面*/} +
{ @@ -637,6 +648,18 @@ class MessagChat extends Component{ {/*右边头部*/}

私信列表

+
{/*列表数据*/} { diff --git a/public/react/src/modules/tpm/TPMBanner.js b/public/react/src/modules/tpm/TPMBanner.js index c7cc7fba9..1811e876d 100644 --- a/public/react/src/modules/tpm/TPMBanner.js +++ b/public/react/src/modules/tpm/TPMBanner.js @@ -366,7 +366,7 @@ class TPMBanner extends Component { Modalstype: true, Modalstopval: "是否确认撤销发布?", modalsMidval:"撤销发布后,学员将无法进行练习,若您新增关", - ModalsBottomval:"卡,学员需要重新体验课程", + ModalsBottomval:"卡,学员需要重新体验实训", ModalCancel: this.ModalCancel, ModalSave: this.ModalSave, modalstyles:"848282" @@ -843,7 +843,7 @@ class TPMBanner extends Component {
  • 学习人数 - {shixunsDetails.stu_num} + {shixunsDetails.stu_num}
  • {/*
  • */} {/*经验值*/} @@ -851,7 +851,7 @@ class TPMBanner extends Component { {/*
  • */}
  • 难度级别 - {shixunsDetails.diffcult} + {shixunsDetails.diffcult}
@@ -1223,7 +1223,7 @@ class TPMBanner extends Component { } - {this.props.identity < 5 && shixunsDetails.shixun_status != -1 && shixunsDetails.shixun_status != 0? + {this.props.identity < 8 && shixunsDetails.shixun_status != -1 && shixunsDetails.shixun_status != 0?
diff --git a/public/react/src/modules/tpm/TPMDataset.js b/public/react/src/modules/tpm/TPMDataset.js index 619dea9e1..85ce2006e 100644 --- a/public/react/src/modules/tpm/TPMDataset.js +++ b/public/react/src/modules/tpm/TPMDataset.js @@ -156,8 +156,10 @@ class TPMDataset extends Component { selectedRowKeysdata:[], selectedRowKeys: [], checked:false, + page:1, }); + } } @@ -181,7 +183,7 @@ class TPMDataset extends Component { getdatastwo = (page,limit) => { let id=this.props.match.params.shixunId; - let collaborators=`/shixuns/${id}/jupyter_data_sets.json`; + let collaborators=`/shixuns/${id}/get_data_sets.json`; axios.get(collaborators,{params:{ page:page, limit:limit, @@ -209,6 +211,7 @@ class TPMDataset extends Component { selectedRowKeysdata:[], selectedRowKeys: [], checked:false, + page:page, }); } @@ -233,7 +236,7 @@ class TPMDataset extends Component { getdatasthree = (page,limit) => { let id=this.props.match.params.shixunId; - let collaborators=`/shixuns/${id}/jupyter_data_sets.json`; + let collaborators=`/shixuns/${id}/get_data_sets.json`; axios.get(collaborators,{params:{ page:page, limit:limit, @@ -298,10 +301,19 @@ class TPMDataset extends Component { this.setState({ fileList: appendFileSizeToUploadFileAll(fileList), }); + if(info.file.status === 'done'){ //done 成功就会调用这个方法 - this.getdatas(); + if(info.file.response){ + if(info.file.response.status===-1||info.file.response.status==="-1"){ + + }else{ + this.getdatas(); + + } + } } + if(info.file.response){ if(info.file.response.status===-1||info.file.response.status==="-1"){ // console.log("准备显示弹框了"); @@ -318,6 +330,8 @@ class TPMDataset extends Component { tittest:info.file.response.message, itemtypebool:itemtype>-1?true:itemtype<=-1?false:false, }) + }else{ + } } diff --git a/public/react/src/modules/tpm/TPMsettings/Configuration.js b/public/react/src/modules/tpm/TPMsettings/Configuration.js index 070f5b156..848f853d6 100644 --- a/public/react/src/modules/tpm/TPMsettings/Configuration.js +++ b/public/react/src/modules/tpm/TPMsettings/Configuration.js @@ -72,11 +72,18 @@ export default class Shixuninformation extends Component { componentDidMount() { if (this.props.data) { if (this.props.data.shixun) { + let time =this.props.data && this.props.data.shixun.opening_time; + let timetype=false; + if(!time){ + timetype=false; + }else{ + timetype=true; + } this.setState({ can_copy: this.props.data && this.props.data.shixun.can_copy === undefined ? false : this.props.data && this.props.data.shixun.can_copy, use_scope: this.props.data && this.props.data.shixun.use_scope, opening_time: this.props.data && this.props.data.shixun.opening_time, - opentime: !this.props.data && this.props.data.shixun.opening_time ? false : true, + opentime: timetype, oldscope_partment: this.props.data && this.props.data.shixun.scope_partment, }) } @@ -100,11 +107,18 @@ export default class Shixuninformation extends Component { if (prevProps.data != this.props.data) { if (this.props.data) { if (this.props.data.shixun) { + let time =this.props.data && this.props.data.shixun.opening_time; + let timetype=false; + if(!time){ + timetype=false; + }else{ + timetype=true; + } this.setState({ can_copy: this.props.data && this.props.data.shixun.can_copy === undefined ? false : this.props.data && this.props.data.shixun.can_copy, use_scope: this.props.data && this.props.data.shixun.use_scope, opening_time: this.props.data && this.props.data.shixun.opening_time, - opentime: !this.props.data && this.props.data.shixun.opening_time ? false : true, + opentime: timetype, oldscope_partment: this.props.data && this.props.data.shixun.scope_partment, }) } @@ -257,9 +271,15 @@ export default class Shixuninformation extends Component { } setopentime = (e) => { + if(e.target.checked===false){ + this.setState({ + opening_time:null + }) + } this.setState({ opentime: e.target.checked }) + } render() { diff --git a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js index 651818da7..e27cf126c 100644 --- a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js +++ b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js @@ -57,14 +57,14 @@ export default class TPMsettings extends Component { }); if(key==="3"&&this.props.shixunsDetails&&this.props.shixunsDetails.is_jupyter === true){ - this.props.history.replace(`/shixuns/${this.props.match.params.shixunId}/challenges`); + window.location.href =`/shixuns/${this.props.match.params.shixunId}/challenges`; }else{ if(key){ this.setState({ activeKeys:key }) }else{ - this.props.history.replace(`/shixuns/${this.props.match.params.shixunId}/challenges`); + window.location.href =`/shixuns/${this.props.match.params.shixunId}/challenges`; } } diff --git a/public/react/src/modules/tpm/jupyter/leftPane/index.js b/public/react/src/modules/tpm/jupyter/leftPane/index.js index ea3c7a6c7..d87be9064 100644 --- a/public/react/src/modules/tpm/jupyter/leftPane/index.js +++ b/public/react/src/modules/tpm/jupyter/leftPane/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-12-12 10:34:03 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-13 21:19:30 + * @LastEditTime: 2019-12-13 22:46:51 */ import './index.scss'; import React, { useState, useEffect } from 'react'; @@ -71,7 +71,7 @@ function LeftPane (props) { {/* 数据集 */} { renderCtx } -
0 ? 'flex' : 'none'}}> +
- {this.props.user&&this.props.user.admin===true||this.props.user&&this.props.user.business===true? + {getFieldDecorator('is_jupyter')( - + 普通实训 - Jupyter实训 + {this.props.user&&this.props.user.admin===true||this.props.user&&this.props.user.business===true?Jupyter实训:""} , )} - :""} + @@ -254,7 +263,7 @@ class Challengesjupyter extends Component { "" : ( - is_teacher===true? + is_teacher===true||admin===true||business===true||mysidentity===true?

任务详情

@@ -297,7 +306,7 @@ class Challengesjupyter extends Component { } { - is_teacher===true? + is_teacher===true||admin===true||business===true||mysidentity===true?
{ diff --git a/public/react/src/redux/actions/jupyter.js b/public/react/src/redux/actions/jupyter.js index f641bb20f..57c12e6d3 100644 --- a/public/react/src/redux/actions/jupyter.js +++ b/public/react/src/redux/actions/jupyter.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-12-12 09:01:30 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-13 21:02:48 + * @LastEditTime: 2019-12-13 23:03:27 */ import types from "./actionTypes"; import { message } from 'antd'; @@ -100,7 +100,12 @@ export const syncJupyterCode = (identifier, msg) => { if (res.data.status === 401) return; if (res.status === 200) { const {status} = res.data - if (status === 0) message.success(msg); + if (status === 0) { + message.success(msg); + setTimeout(() => { + window.location.reload(); + }, 300); + } } }) }