From ca5602ae08a4ad9171becb53f2e528e21beb4163 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 10:36:53 +0800 Subject: [PATCH 01/30] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/challenges/index.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/challenges/index.json.jbuilder b/app/views/challenges/index.json.jbuilder index eae72dad2..217fe1e28 100644 --- a/app/views/challenges/index.json.jbuilder +++ b/app/views/challenges/index.json.jbuilder @@ -20,7 +20,7 @@ if @challenges.present? user_passed_count = challenge.user_passed_count json.passed_count user_passed_count #json.playing_count @play_games_map.fetch(challenge.id, 0) - json.playing_count (challenge.games.count - user_passed_count) + json.playing_count (challenge.playing_count) json.name_url shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier) json.open_game challenge.open_game(@shixun) #json.open_game challenge.open_game(@shixun, @user.id) From 9657b7065fb196763496bf3095f471ce1859d4b0 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 10:48:02 +0800 Subject: [PATCH 02/30] =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=80=9A=E5=85=B3?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/challenge.rb | 2 +- app/views/challenges/index.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 31a683760..42d7f3499 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -143,7 +143,7 @@ class Challenge < ApplicationRecord # 关卡用户通关数 def user_passed_count #games.map{|g| g.status == 2}.count - self.games.where(status: 1).count + self.games.where(status: 2).count end # 关卡用户正在挑战的人数 diff --git a/app/views/challenges/index.json.jbuilder b/app/views/challenges/index.json.jbuilder index 217fe1e28..eae72dad2 100644 --- a/app/views/challenges/index.json.jbuilder +++ b/app/views/challenges/index.json.jbuilder @@ -20,7 +20,7 @@ if @challenges.present? user_passed_count = challenge.user_passed_count json.passed_count user_passed_count #json.playing_count @play_games_map.fetch(challenge.id, 0) - json.playing_count (challenge.playing_count) + json.playing_count (challenge.games.count - user_passed_count) json.name_url shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier) json.open_game challenge.open_game(@shixun) #json.open_game challenge.open_game(@shixun, @user.id) From 6d2500e253aad593fffc1bdfbe1d3c2885b6899f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 15:09:58 +0800 Subject: [PATCH 03/30] 1 --- app/controllers/challenges_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 47c8fc68c..e73243b94 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -162,7 +162,7 @@ class ChallengesController < ApplicationController #@pass_games_map = @shixun.challenges.joins(:games).where(games: {status:2}).group(:challenge_id).reorder(nil).count #@play_games_map = @shixun.challenges.joins(:games).where(games: {status:[0,1]}).group(:challenge_id).reorder(nil).count - @challenges = @shixun.challenges.joins(join_sql).select(base_columns) + @challenges = @shixun.challenges.joins(join_sql).select(base_columns).uniq #@challenges = @shixun.challenges.fields_for_list @editable = @shixun.status == 0 # before_action:有判断权限,如果没发布,则肯定是管理人员 From 0094e94b03627e8f5e87c6fa5b9b19256ec2e744 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 15:37:06 +0800 Subject: [PATCH 04/30] 1 --- app/controllers/challenges_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index e73243b94..47c8fc68c 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -162,7 +162,7 @@ class ChallengesController < ApplicationController #@pass_games_map = @shixun.challenges.joins(:games).where(games: {status:2}).group(:challenge_id).reorder(nil).count #@play_games_map = @shixun.challenges.joins(:games).where(games: {status:[0,1]}).group(:challenge_id).reorder(nil).count - @challenges = @shixun.challenges.joins(join_sql).select(base_columns).uniq + @challenges = @shixun.challenges.joins(join_sql).select(base_columns) #@challenges = @shixun.challenges.fields_for_list @editable = @shixun.status == 0 # before_action:有判断权限,如果没发布,则肯定是管理人员 From 3535d4ce12516bdbee437f847a19e22fe609e661 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 15:40:07 +0800 Subject: [PATCH 05/30] 1 --- app/controllers/challenges_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 47c8fc68c..e73243b94 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -162,7 +162,7 @@ class ChallengesController < ApplicationController #@pass_games_map = @shixun.challenges.joins(:games).where(games: {status:2}).group(:challenge_id).reorder(nil).count #@play_games_map = @shixun.challenges.joins(:games).where(games: {status:[0,1]}).group(:challenge_id).reorder(nil).count - @challenges = @shixun.challenges.joins(join_sql).select(base_columns) + @challenges = @shixun.challenges.joins(join_sql).select(base_columns).uniq #@challenges = @shixun.challenges.fields_for_list @editable = @shixun.status == 0 # before_action:有判断权限,如果没发布,则肯定是管理人员 From 7884cd71c520bec1c6dd2395ab2ac7cefd84894d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 15:41:33 +0800 Subject: [PATCH 06/30] 1 --- app/models/game.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/game.rb b/app/models/game.rb index 144dbced2..d0d59c0e3 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -7,6 +7,7 @@ class Game < ApplicationRecord default_scope { order("games.created_at desc") } + #TODO: games表要增加challenge_id与user_id的唯一索引 has_many :outputs, -> { order('query_index DESC') } has_many :challenge_samples, :dependent => :destroy has_many :game_codes, :dependent => :destroy From cd80381510acdac828828756e696010edca99d40 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 17:45:22 +0800 Subject: [PATCH 07/30] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 29a9a9730..324d2214e 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -23,22 +23,16 @@ class MyshixunsController < ApplicationController end begin ActiveRecord::Base.transaction do - begin @shixun = Shixun.select(:id, :identifier, :challenges_count).find(@myshixun.shixun_id) @myshixun.destroy! - StudentWork.where(:myshixun_id => @myshixun.id).update_all(myshixun_id: 0, work_status: 0, work_score: nil, - final_score: nil, efficiency: 0, eff_score: 0, calculation_time: nil, cost_time: 0, compelete_status: 0) - rescue Exception => e - logger.error("######reset_my_game_failed:#{e.message}") - raise("ActiveRecord::RecordInvalid") - end + + StudentWork.where(:myshixun_id => @myshixun.id) + .update_all(myshixun_id: 0, work_status: 0, work_score: nil, + final_score: nil, efficiency: 0, eff_score: 0, calculation_time: nil, cost_time: 0, compelete_status: 0) end # 删除版本库 GitService.delete_repository(repo_path: @repo_path) unless @shixun.is_choice_type? rescue Exception => e - if e.message != "ActiveRecord::RecordInvalid" - logger.error("######delete_repository_error-:#{e.message}") - end raise "delete_repository_error:#{e.message}" end end From 03a72aedc87bdd83b93ab05f256337ba7a0e67a8 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 17:51:20 +0800 Subject: [PATCH 08/30] =?UTF-8?q?=E9=87=8D=E7=BD=AE=E5=AE=9E=E8=AE=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 324d2214e..e816ab667 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -22,8 +22,8 @@ class MyshixunsController < ApplicationController tip_exception("403", "") end begin + @shixun = Shixun.select(:id, :identifier, :challenges_count).find(@myshixun.shixun_id) ActiveRecord::Base.transaction do - @shixun = Shixun.select(:id, :identifier, :challenges_count).find(@myshixun.shixun_id) @myshixun.destroy! StudentWork.where(:myshixun_id => @myshixun.id) From b4234965e50d9bbcb2e4c23af2270898938ffec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Wed, 11 Mar 2020 22:19:07 +0800 Subject: [PATCH 09/30] =?UTF-8?q?=E6=99=AE=E9=80=9A=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E3=80=81=E5=88=86=E7=BB=84=E4=BD=9C=E4=B8=9A=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Index.js | 28 ++- .../src/modules/courses/ListPageIndex.js | 12 ++ .../courses/busyWork/CommonWorkDetailIndex.js | 48 ++++- .../src/modules/courses/busyWork/Index.js | 58 +++++++ .../modules/courses/busyWork/IndexGroup.js | 55 +++++- .../src/modules/courses/busyWork/NewWork.js | 26 ++- .../src/modules/courses/busyWork/UseBank.js | 5 +- .../src/modules/courses/busyWork/common.js | 19 +- .../modules/courses/busyWork/commonWork.js | 164 ++++++++++++------ .../courses/coursesDetail/CoursesLeftNav.js | 44 ++++- .../user/usersInfo/banks/NewGtaskForm.js | 2 +- 11 files changed, 393 insertions(+), 68 deletions(-) diff --git a/public/react/src/modules/courses/Index.js b/public/react/src/modules/courses/Index.js index eef17f420..e11a0c59f 100644 --- a/public/react/src/modules/courses/Index.js +++ b/public/react/src/modules/courses/Index.js @@ -684,12 +684,24 @@ class CoursesIndex extends Component{ (props) => () } > + {/* 子目录普通作业 */} + () + } + > {/* 分组作业 */} () } > + {/* 分组作业 */} + () + } + > {/* 普通作业 */} () } > + {/* 子普通作业 */} + () + } + > {/* 分组作业 */} - {/* 问卷答题 */} + {/* 分组作业 */} + () + } + > + + + {/* 问卷答题 */} () diff --git a/public/react/src/modules/courses/ListPageIndex.js b/public/react/src/modules/courses/ListPageIndex.js index d95ed6739..a780f4dc6 100644 --- a/public/react/src/modules/courses/ListPageIndex.js +++ b/public/react/src/modules/courses/ListPageIndex.js @@ -230,6 +230,12 @@ class ListPageIndex extends Component{ (props) => () } > + {/* 普通作业 */} + () + } + > {/* 作品列表 */} () } > + {/* 作品列表 */} + () + } + > + () + } + > + {/* 作品列表 */} + {/* 作品列表 */} + () + } + > + {/* 作业问答 */} () } > + () + } + > + () } > + () + } + > () } > - + () + } + > {/* 作品列表 */} () } > - + () + } + > {/* 作业问答 */} () } > + () + } + > () } > + () + } + > diff --git a/public/react/src/modules/courses/busyWork/Index.js b/public/react/src/modules/courses/busyWork/Index.js index b204a7b47..308950ab6 100644 --- a/public/react/src/modules/courses/busyWork/Index.js +++ b/public/react/src/modules/courses/busyWork/Index.js @@ -68,6 +68,12 @@ class CoursesWorkIndex extends Component{ (props) => () } > + () + } + > + {/* 作品列表 */} () } > + {/* 作品列表 */} + () + } + > + {/* 作业问答 */} () } > + () + } + > + () } > + () + } + > + {/* 评阅 */} () } > + () + } + > + {/* 提交作品 */} () } > + () + } + > + () } > + () + } + > {/* 新建 */} @@ -114,12 +156,23 @@ class CoursesWorkIndex extends Component{ (props) => () } > + () + } + > + () } > + () + } + > {/* 作业列表 */} @@ -128,6 +181,11 @@ class CoursesWorkIndex extends Component{ (props) => () } > + () + } + > {/* --------------------------------------------------------------------- */} diff --git a/public/react/src/modules/courses/busyWork/IndexGroup.js b/public/react/src/modules/courses/busyWork/IndexGroup.js index 932030253..7479366d3 100644 --- a/public/react/src/modules/courses/busyWork/IndexGroup.js +++ b/public/react/src/modules/courses/busyWork/IndexGroup.js @@ -71,6 +71,11 @@ class CoursesWorkIndex extends Component{ (props) => () } > + () + } + > {/* 作品列表 */} () } > + () + } + > {/* 作业问答 */} () } > + () + } + > {/* 参考答案 */} () } > + () + } + > {/* 评阅 */} () } > - + () + } + > () } > + + () + } + > + () } > - + () + } + > {/* 新建 */} {/* http://localhost:3007/classrooms/1309/group_homeworks/9299/edit/1 */} () } > + () + } + > () } > + () + } + > {/* 作业列表 */} () } > + {/* 作业列表 */} + () + } + > diff --git a/public/react/src/modules/courses/busyWork/NewWork.js b/public/react/src/modules/courses/busyWork/NewWork.js index 81ca690b6..1bd79d93e 100644 --- a/public/react/src/modules/courses/busyWork/NewWork.js +++ b/public/react/src/modules/courses/busyWork/NewWork.js @@ -34,8 +34,17 @@ class NewWork extends Component{ } } fetchCourseData = (courseId) => { + let newcategory=undefined; + if(this.props.match.path==="/classrooms/:coursesId/common_homework/:workId/:pageType"){ + newcategory=this.props.match.params.workId + } const isGroup = this.props.isGroup() - const url = `/courses/${courseId}/homework_commons/new.json?type=${isGroup ? 3 : 1}` + let url="" + if(newcategory){ + url = `/courses/${courseId}/homework_commons/new.json?type=${isGroup ? 3 : 1}&category=${newcategory}`; + }else{ + url = `/courses/${courseId}/homework_commons/new.json?type=${isGroup ? 3 : 1}` + } axios.get(url, { }) .then((response) => { @@ -54,7 +63,17 @@ class NewWork extends Component{ }); } fetchWork = (workId) => { - const url = `/homework_commons/${workId}/edit.json` + let newcategory=undefined; + if(this.props.match.path==="/classrooms/:coursesId/common_homework/:workId/:pageType"){ + newcategory=this.props.match.params.workId + } + let url="" + if(newcategory){ + url = `/homework_commons/${workId}/edit.json?category=${newcategory}`; + }else{ + url = `/homework_commons/${workId}/edit.json` + } + axios.get(url, { }) .then((response) => { @@ -96,6 +115,9 @@ class NewWork extends Component{ doNew = (params) => { const coursesId = this.props.match.params.coursesId const newUrl = `/courses/${coursesId}/homework_commons.json` + if(this.props.match.path==="/classrooms/:coursesId/common_homework/:workId/:pageType"){ + params.category=this.props.match.params.workId + } axios.post(newUrl, params) .then((response) => { diff --git a/public/react/src/modules/courses/busyWork/UseBank.js b/public/react/src/modules/courses/busyWork/UseBank.js index 6c98695ba..b31412470 100644 --- a/public/react/src/modules/courses/busyWork/UseBank.js +++ b/public/react/src/modules/courses/busyWork/UseBank.js @@ -132,7 +132,7 @@ class UseBank extends Component{ onSave = () => { debugger const { checkBoxValues } = this.state; - const { object_type } = this.props + const { object_type,category_id } = this.props if(checkBoxValues.length==0){ this.setState({ isChecked:"请先选择"+engNameMap[object_type] @@ -149,7 +149,8 @@ class UseBank extends Component{ , { "object_type": object_type, "bank_id": checkBoxValues, - "course_id": courseId + "course_id": courseId, + "category":category_id } ) .then((response) => { diff --git a/public/react/src/modules/courses/busyWork/common.js b/public/react/src/modules/courses/busyWork/common.js index ebcce2c12..b413f2c53 100644 --- a/public/react/src/modules/courses/busyWork/common.js +++ b/public/react/src/modules/courses/busyWork/common.js @@ -39,8 +39,23 @@ export function RouteHOC(options = {}) { let chName = isGroup ? '分组作业' : '普通作业' return chName; } - const secondName = isGroup ? 'group_homeworks' : 'common_homeworks' - return secondName; + + if(window.location.pathname.indexOf('group_homeworks') != -1){ + const secondName ='group_homeworks'; + return secondName; + } + + if(window.location.pathname.indexOf('common_homeworks') != -1){ + const secondName ='common_homeworks'; + return secondName; + } + + if(window.location.pathname.indexOf('common_homework') != -1){ + const secondName ='common_homework'; + return secondName; + } + + } getModuleType = () => { const isGroup = this.isGroup() diff --git a/public/react/src/modules/courses/busyWork/commonWork.js b/public/react/src/modules/courses/busyWork/commonWork.js index 8ba6303fc..d4b097cec 100644 --- a/public/react/src/modules/courses/busyWork/commonWork.js +++ b/public/react/src/modules/courses/busyWork/commonWork.js @@ -6,7 +6,7 @@ import '../css/busyWork.css' import CommonWorkItem from './CommonWorkItem' import PublishRightnow from './PublishRightnow' import ConnectProject from './ConnectProject' -import { WordsBtn, on, off } from 'educoder' +import { WordsBtn, on, off ,trigger} from 'educoder' import Modals from '../../modals/Modals' import NoneData from "../coursesPublic/NoneData" import Titlesearchsection from '../common/titleSearch/TitleSearchSection'; @@ -34,7 +34,8 @@ class commonWork extends Component{ totalCount:0, checkAll:false, checkBoxValues:[], - isSpin:false + isSpin:false, + category_id:undefined } } //输入搜索条件 @@ -45,8 +46,8 @@ class commonWork extends Component{ } //搜索查询 searchStudent=()=>{ - let {page,search,order}=this.state; - this.getList(1,search,order); + let {category_id,search,order}=this.state; + this.getList(1,search,order,category_id); } openConnectionProject = (work) => { this.refs['connectProject'].openConnectionProject(work) @@ -54,7 +55,7 @@ class commonWork extends Component{ // 新建 createCommonWork=(type)=>{ - this.props.toNewPage(this.props.match.params) + this.props.toNewPage(this.props.match.params) } cancelDelClasses=()=>{ @@ -69,23 +70,60 @@ class commonWork extends Component{ } componentDidUpdate(prevProps, prevState) { - if (prevProps.match.path != this.props.match.path) { - this.clearSelection() - this.setState({ selectedKeys: 'all', order: '' }, () => { - this._getList() - }) + console.log(this.props) + if (prevProps.coursesidtype != this.props.coursesidtype) { + if (this.props.match.path === "/classrooms/:coursesId/common_homeworks/:category_id" || this.props.match.path === "/classrooms/:coursesId/common_homework/:category_id") { + + if (this.props.coursesidtype === "node" && this.props.match.path === "/classrooms/:coursesId/common_homeworks/:category_id") { + this.clearSelection() + this.setState({selectedKeys: 'all', order: ''}, () => { + this._getList() + }) + } + if (this.props.coursesidtype === "child" && this.props.match.path === "/classrooms/:coursesId/common_homework/:category_id") { + this.clearSelection() + this.setState({selectedKeys: 'all', order: ''}, () => { + this._getList(this.props.match.params.category_id) + }) + } + } } + // + // if(this.props.match.path==="/classrooms/:coursesId/common_homeworks/:category_id"||this.props.match.path==="/classrooms/:coursesId/common_homework/:category_id"){ + // + // + // if(this.props.coursesidtype==="node"&&this.props.match.path==="/classrooms/:coursesId/common_homeworks/:category_id"){ + // this.clearSelection() + // this.setState({ selectedKeys: 'all', order: '' }, () => { + // this._getList() + // }) + // } + // if(this.props.coursesidtype==="child"&&this.props.match.path==="/classrooms/:coursesId/common_homework/:category_id"){ + // this.clearSelection() + // this.setState({ selectedKeys: 'all', order: '' }, () => { + // this._getList(this.props.match.params.category_id) + // }) + // } + // + // } + } - - _getList = () => { + + _getList = (id) => { this.setState({ - isSpin:true + isSpin:true, + category_id:id }) let {page,search,order}=this.state; - this.getList(page,search,order); + this.getList(page,search,order,id); } componentDidMount(){ - this._getList() + if(this.props.coursesidtype==="node"){ + this._getList() + }else{ + this._getList(this.props.match.params.category_id) + } + on('updateNavSuccess', this.updateNavSuccess) } @@ -93,9 +131,13 @@ class commonWork extends Component{ off('updateNavSuccess', this.updateNavSuccess) } updateNavSuccess = () => { - this._getList() + if(this.props.coursesidtype==="node"){ + this._getList() + }else{ + this._getList(this.props.match.params.category_id) + } } - + useBankSuccess = (checkBoxValues, newWorkIdArray) => { this.setState({ page:1, @@ -103,12 +145,14 @@ class commonWork extends Component{ }, () => { this.refs['publishModalRef'].open() }) - - let {search, order}=this.state; - this.getList(1, search, order); + + let {search, order,category_id}=this.state; + this.getList(1, search, order,category_id); } - getList=(page,search,order)=>{ + getList=(page,search,order,category_id)=>{ + console.log(category_id) + this.setState({ isSpin:true }) @@ -121,6 +165,9 @@ class commonWork extends Component{ if(search!=""){ url+="&search="+search; } + if(category_id){ + url+="&category="+category_id; + } axios.get(encodeURI(url)).then((result)=>{ if(result.status==200){ this.setState({ @@ -148,8 +195,8 @@ class commonWork extends Component{ checkBoxValues:[], checkAll:false }) - let {search}=this.state; - this.getList(1,search,e.key==="all"?"":e.key); + let {search,category_id}=this.state; + this.getList(1,search,e.key==="all"?"":e.key,category_id); } onPageChange=(pageNumber)=>{ @@ -157,8 +204,8 @@ class commonWork extends Component{ page:pageNumber, checkBoxValues:[] }) - let {search,order}=this.state; - this.getList(pageNumber,search,order); + let {search,order,category_id}=this.state; + this.getList(pageNumber,search,order,category_id); } // 全选和反选 @@ -191,7 +238,7 @@ class commonWork extends Component{ } onWorkDelete = () => { - const { checkBoxValues } = this.state; + const { checkBoxValues,category_id} = this.state; const len = checkBoxValues.length; if (len == 0) { this.props.showNotification('请先选择要删除的作业') @@ -209,13 +256,14 @@ class commonWork extends Component{ axios.post(url, { homework_ids: checkBoxValues, all_check: 0, + // category:category_id // group_ids }).then((response) => { - if (response.data.status == 0) { + if (response.data.status == 0) { this.props.showNotification('删除成功') this.clearSelection() let {search,order}=this.state; - this.getList(1,search,order); + this.getList(1,search,order,category_id); this.props.updataleftNavfun() } @@ -224,12 +272,12 @@ class commonWork extends Component{ }) } }) - + } clearSelection = () => { this.setState({ checkBoxValues: [], checkAll: false }) } - // + // onSetPublic = () => { const { checkBoxValues } = this.state; const len = checkBoxValues.length; @@ -249,10 +297,10 @@ class commonWork extends Component{ homework_ids: checkBoxValues, all_check: 0 }).then((response) => { - if (response.data.status == 0) { + if (response.data.status == 0) { this.props.showNotification('设为公开操作成功') let {search,order, page}=this.state; - this.getList(page,search,order); + this.getList(page,search,order,category_id); } }).catch((error) => { @@ -262,8 +310,8 @@ class commonWork extends Component{ }) } doWhenSuccess = () => { - let {search,order, page}=this.state; - this.getList(page,search,order); + let {search,order, page,category_id}=this.state; + this.getList(page,search,order,category_id); this.setState({ checkBoxValues:[] }) @@ -279,7 +327,7 @@ class commonWork extends Component{ this.onChangeSelect(checkBoxValues) } addToBank = () => { - const { checkBoxValues } = this.state; + const { checkBoxValues,category_id } = this.state; const len = checkBoxValues.length; if (len == 0) { this.props.showNotification('请先选择要加入题库的作业') @@ -291,10 +339,10 @@ class commonWork extends Component{ homework_ids: checkBoxValues, all_check: 0 }).then((response) => { - if (response.data.status == 0) { + if (response.data.status == 0) { this.props.showNotification('加入成功') let {search,order}=this.state; - this.getList(1,search,order); + this.getList(1,search,order,category_id); } }).catch((error) => { @@ -302,27 +350,36 @@ class commonWork extends Component{ }) } connectSuccess = () => { - let {page,search,order}=this.state; - this.getList(page,search,order); + let {page,search,order,category_id}=this.state; + this.getList(page,search,order,category_id); } cancelConnectionProject = (work) => { let workId=this.props.match.params.workId; let courseId=this.props.match.params.coursesId; - + let {page,search,order,category_id}=this.state; const url = `/homework_commons/${work.homework_id}/student_works/cancel_relate_project.json` axios.get(url).then((response)=> { if (response.data.status == 0) { - let {page,search,order}=this.state; - this.getList(page,search,order); + + this.getList(page,search,order,category_id); this.props.showNotification('取消关联成功') } }).catch((error)=>{ console.log(error) }) } + addDir = (id) => { + + if(!id){ + trigger('addcommon_homeworks', parseInt(this.props.match.params.category_id)) + }else{ + let data={id:parseInt(id),name:name} + trigger('editcommon_homeworks', data) + } + + } - render(){ let { search, @@ -339,6 +396,8 @@ class commonWork extends Component{ published_count, unpublished_count, main_category_name, + category_name, + category_id }=this.state; const { coursedata } = this.props; if (!coursedata) { @@ -354,12 +413,12 @@ class commonWork extends Component{ // // return( - +
{/*

{moduleChineseName} - +

@@ -374,7 +433,7 @@ class commonWork extends Component{
- } + { isAdmin &&
  • + this.addDir(category_id)}>{!category_id?"新建目录":"目录重命名"} +
  • } } secondRowBotton={ @@ -425,7 +487,7 @@ class commonWork extends Component{ searchPlaceholder={"请输入名称进行搜索"} showSearchInput={true} > - this.refs['publishModalRef'].homeworkstart()}>{ "立即发布" }
  • -
  • - + { !!course_public &&
  • 设为公开
  • } {this.props.user&&this.props.user.main_site===true?
  • 15 && -
    +
    } diff --git a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js index 1c627b78d..eaefd50e9 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js @@ -142,6 +142,8 @@ class Coursesleftnav extends Component{ off('editshixunmainname',this.editshixunmainname) off('videoAdd',this.addVideo) off('editVideo',this.editVideo) + off('addcommon_homeworks',this.addcommon_homeworks) + off('editcommon_homeworks',this.editcommon_homeworks) } addshixunchild=(e, data)=>{ this.Navmodalnames(e,1,"shixun_homework",data); @@ -149,6 +151,12 @@ class Coursesleftnav extends Component{ editshixunchild=(e, data)=>{ this.Navmodalnames(e,4,"editSecondname",data.id,data.name); } + addcommon_homeworks=(e, data)=>{ + this.Navmodalnames(e,1,"common_homework",data); + } + editcommon_homeworks=(e, data)=>{ + this.Navmodalnames(e,4,"editSecondname",data.id,data.name); + } editshixunmainname=(e, data)=>{ this.Navmodalnames(e,3,"editname",data.id,data.name); } @@ -196,7 +204,8 @@ class Coursesleftnav extends Component{ on('editshixunmainname',this.editshixunmainname); on('videoAdd',this.addVideo); on('editVideo',this.editVideo) - + on('addcommon_homeworks',this.addcommon_homeworks) + on('editcommon_homeworks',this.editcommon_homeworks) let courstype=this.props.match.url; @@ -537,7 +546,7 @@ class Coursesleftnav extends Component{ } saveNavmodapost=(url,value,positiontype,coursesId,type)=>{ - + console.log(positiontype) axios.post(url, {name:value}).then((result)=>{ if(result!=undefined){ @@ -548,6 +557,23 @@ class Coursesleftnav extends Component{ description:result.data.message }); + if(positiontype==="common_homeworks"||positiontype==="common_homework"||positiontype==="group_homeworks"||positiontype==="group_homework"){ + if(type===true){ + this.updasaveNavmoda() + trigger('updateNavSuccess') + }else{ + this.updasaveNavmoda() + if(positiontype==="common_homeworks"){ + this.props.history.push(`/classrooms/${coursesId}/common_homework/${result.data.category_id}`); + } + if(positiontype==="group_homeworks"){ + this.props.history.push(`/classrooms/${coursesId}/group_homework/${result.data.category_id}`); + } + + } + return + } + if(positiontype==="shixun_homeworks"||positiontype==="shixun_homework"){ if(type===true){ this.updasaveNavmoda() @@ -557,6 +583,7 @@ class Coursesleftnav extends Component{ this.props.history.push(`/classrooms/${coursesId}/shixun_homework/${result.data.category_id}`); } + return } if(positiontype==="files"||positiontype==="file"){ @@ -569,22 +596,25 @@ class Coursesleftnav extends Component{ this.updasaveNavmoda() this.props.history.push(`/classrooms/${coursesId}/file/${result.data.category_id}`); } - + return } if(positiontype==="boards"){ this.updasaveNavmoda() trigger('updateNavSuccess') this.props.history.push(`/classrooms/${coursesId}/boards/${result.data.category_id}`); + return } if(positiontype!="course_groups"&&positiontype!="shixun_homeworks"&&positiontype!="shixun_homework"){ this.updasaveNavmoda() + return } if(positiontype==="course_groups"){ this.props.updataleftNavfun(); this.props.history.push(`/classrooms/${coursesId}/course_groups/${result.data.group_id}`); + return } } @@ -864,6 +894,10 @@ class Coursesleftnav extends Component{ {/*公告栏*/} {/*作业*/} {item.type==="shixun_homework"?
    this.Navmodalnames(e,1,"shixun_homework",item.id)}>新建目录
    :""} + {/* 普通作业 */} + {item.type==="common_homework"?
    this.Navmodalnames(e,1,"common_homeworks",item.id)}>新建目录
    :""} + {/*/!* 分组作业 *!/*/} + {item.type==="group_homework"?
    this.Navmodalnames(e,1,"group_homeworks",item.id)}>新建目录
    :""} {/*资源*/} {item.type==="attachment"?
    this.Navmodalnames(e,1,"attachment",item.id)}>新建目录
    :""} {/* 视频 */} @@ -894,8 +928,8 @@ class Coursesleftnav extends Component{ let {twosandiantypes,twosandiantypenum}=this.state; return (item.type==="graduation"?"":
    {/*作业/资源*/} - {item.type==="shixun_homework"||item.type==="attachment"||item.type==="graduation"?
    this.Navmodalnames(e,4,"editSecondname",iem.category_id,iem.category_name)}>重命名
    :""} - {item.type==="shixun_homework"||item.type==="attachment"?
    this.deleteSecondary(e,1,iem.category_id)}>删除
    :""} + {item.type==="shixun_homework"||item.type==="attachment"||item.type==="graduation"||item.type==="common_homework"||item.type==="group_homework"?
    this.Navmodalnames(e,4,"editSecondname",iem.category_id,iem.category_name)}>重命名
    :""} + {item.type==="shixun_homework"||item.type==="attachment"||item.type==="common_homework"||item.type==="group_homework"?
    this.deleteSecondary(e,1,iem.category_id)}>删除
    :""} {/*分班*/} {item.type==="course_group"?
    this.Navmodalnames(e,5,"editSecondname",iem.category_id,iem.category_name)}>重命名
    :""} {item.type==="course_group"?
    this.deleteSecondary(e,2,iem.category_id)}>删除
    :""} diff --git a/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js b/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js index 70994e42d..a8fcdeeae 100644 --- a/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js +++ b/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js @@ -110,7 +110,7 @@ class NewGtaskForms extends Component{ } handleSubmit = () => { - + console.log(this.props) let {contentFileList,min_num,max_num,base_on_project}=this.state; let {data}=this.props; let task_type=data.task_type From 7a8e9226438998af3af5305fc7d94f448ffaa851 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 22:44:15 +0800 Subject: [PATCH 10/30] =?UTF-8?q?=E8=BD=AC=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/video_transcode.rake | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/tasks/video_transcode.rake b/lib/tasks/video_transcode.rake index 995f9a82f..ecb5afdc6 100644 --- a/lib/tasks/video_transcode.rake +++ b/lib/tasks/video_transcode.rake @@ -2,13 +2,18 @@ namespace :video_transcode do desc "视频转码成h264" task :submit => :environment do - Video.find_each do |v| - if v.uuid && !v.transcoded && !v.file_url.include?('.mp4') && !AliyunVod::Service.get_meta_code_info(v.uuid)[:codecnamne].start_with?("h264", "h265") - p "--- Start submit video trans code #{v.uuid}" + i = 1 + Video.where.not(uuid: nil, file_url: nil).where(transcoded: false).find_each do |v| + code_info = AliyunVod::Service.get_meta_code_info(v.uuid) + if !v.file_url.include?('.mp4') && !code_info[:codecnamne]&.include?("h264") + puts "v.file_url: #{v.file_url}, code_info[:codecnamne]: #{code_info[:codecnamne]}" + i += 1 AliyunVod::Service.submit_transcode_job(v.uuid, 'a0277c5c0c7458458e171b0cee6ebf5e') else v.update(transcoded: true) end end + puts "###########转码个数:#{i}" + end end \ No newline at end of file From a5f26d33ca427356134e74543373c3535284b29c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 23:12:28 +0800 Subject: [PATCH 11/30] =?UTF-8?q?=E8=BD=AC=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/video_transcode.rake | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/tasks/video_transcode.rake b/lib/tasks/video_transcode.rake index ecb5afdc6..c0b8a9a62 100644 --- a/lib/tasks/video_transcode.rake +++ b/lib/tasks/video_transcode.rake @@ -2,18 +2,17 @@ namespace :video_transcode do desc "视频转码成h264" task :submit => :environment do - i = 1 + i = [] Video.where.not(uuid: nil, file_url: nil).where(transcoded: false).find_each do |v| code_info = AliyunVod::Service.get_meta_code_info(v.uuid) - if !v.file_url.include?('.mp4') && !code_info[:codecnamne]&.include?("h264") - puts "v.file_url: #{v.file_url}, code_info[:codecnamne]: #{code_info[:codecnamne]}" - i += 1 - AliyunVod::Service.submit_transcode_job(v.uuid, 'a0277c5c0c7458458e171b0cee6ebf5e') - else + if v.file_url.include?('.mp4') && code_info[:codecnamne]&.include?("h264") v.update(transcoded: true) + else + i << "#{v.id}, #{v.file_url}, #{code_info[:codecnamne]}" + AliyunVod::Service.submit_transcode_job(v.uuid, 'a0277c5c0c7458458e171b0cee6ebf5e') end end - puts "###########转码个数:#{i}" - + puts "###########转码个数:#{i.size}" + puts "###########id,file_url, codecnamne:#{i}" end end \ No newline at end of file From 2dfb081f4f5e9ba469e62844f2a019d5f102d91e Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 12 Mar 2020 00:13:20 +0800 Subject: [PATCH 12/30] =?UTF-8?q?=E8=BD=AC=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/video_transcode.rake | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tasks/video_transcode.rake b/lib/tasks/video_transcode.rake index c0b8a9a62..98221e007 100644 --- a/lib/tasks/video_transcode.rake +++ b/lib/tasks/video_transcode.rake @@ -8,6 +8,7 @@ namespace :video_transcode do if v.file_url.include?('.mp4') && code_info[:codecnamne]&.include?("h264") v.update(transcoded: true) else + puts("uuid: #{v.uuid}") i << "#{v.id}, #{v.file_url}, #{code_info[:codecnamne]}" AliyunVod::Service.submit_transcode_job(v.uuid, 'a0277c5c0c7458458e171b0cee6ebf5e') end From 8bdeb3ea4570c7de81d60574fe6d1488e3036186 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 12 Mar 2020 00:21:38 +0800 Subject: [PATCH 13/30] =?UTF-8?q?=E5=8F=91=E5=B8=83=E7=9A=84=E8=A7=86?= =?UTF-8?q?=E9=A2=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/video_transcode.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/video_transcode.rake b/lib/tasks/video_transcode.rake index 98221e007..4fb7c17bd 100644 --- a/lib/tasks/video_transcode.rake +++ b/lib/tasks/video_transcode.rake @@ -3,7 +3,7 @@ namespace :video_transcode do desc "视频转码成h264" task :submit => :environment do i = [] - Video.where.not(uuid: nil, file_url: nil).where(transcoded: false).find_each do |v| + Video.where.not(uuid: nil, file_url: nil).where(transcoded: false, status: "published").find_each do |v| code_info = AliyunVod::Service.get_meta_code_info(v.uuid) if v.file_url.include?('.mp4') && code_info[:codecnamne]&.include?("h264") v.update(transcoded: true) From 0f22210bf5f3da0a9300bd28fd86ee2f17285048 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 12 Mar 2020 12:00:48 +0800 Subject: [PATCH 14/30] =?UTF-8?q?=E9=AB=98=E6=A0=A1=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/schools.rake | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/tasks/schools.rake diff --git a/lib/tasks/schools.rake b/lib/tasks/schools.rake new file mode 100644 index 000000000..f5a66a786 --- /dev/null +++ b/lib/tasks/schools.rake @@ -0,0 +1,21 @@ +#coding=utf-8 + +desc "合并高校的数据,第一个参数是: 正确高校的id, 第二个参数是: 错误高校需要合并到正确高校的id" +# 命令: bundle exec rake schools:merge_school_data f_school=1 s_school=2,3 +namespace :schools do + task merge_school_data: :environment do + f_school = ENV['f_school'].to_i + school = School.find_by(id: f_school) + return if school.blank? + + s_school = ENV['s_school'].split(",") + merge_schools = School.where(id: s_school) + + # 改变用户的学校id 和 单位 + UserExtension.where(school_id: merge_schools) + .update_all(school_id: f_school, department_id: nil) + + # 改变课堂的学校id + Course.where(school_id: merge_schools).update_all(school_id: f_school) + end +end \ No newline at end of file From d2a282e37befae934cd25424c9e1b0dad371d1fb Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 12 Mar 2020 12:10:46 +0800 Subject: [PATCH 15/30] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=95=B0=E7=9B=AE?= =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/schools.rake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/tasks/schools.rake b/lib/tasks/schools.rake index f5a66a786..3b62c5e20 100644 --- a/lib/tasks/schools.rake +++ b/lib/tasks/schools.rake @@ -17,5 +17,12 @@ namespace :schools do # 改变课堂的学校id Course.where(school_id: merge_schools).update_all(school_id: f_school) + + # 实训报告表迁移数据 + s_report = SchoolReport.find_by(school_id: f_school) + SchoolReport.where(school_id: merge_schools).each do |sr| + s_report.update_column(:shixun_evaluate_count, shixun_evaluate_count+sr.shixun_evaluate_count) + sr.update(shixun_evaluate_count: 0) + end end end \ No newline at end of file From 52fe87875b6a3044bbb1422090cc270d2d309cf3 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 12 Mar 2020 12:11:49 +0800 Subject: [PATCH 16/30] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/schools.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/schools.rake b/lib/tasks/schools.rake index 3b62c5e20..0d2cf0899 100644 --- a/lib/tasks/schools.rake +++ b/lib/tasks/schools.rake @@ -21,7 +21,7 @@ namespace :schools do # 实训报告表迁移数据 s_report = SchoolReport.find_by(school_id: f_school) SchoolReport.where(school_id: merge_schools).each do |sr| - s_report.update_column(:shixun_evaluate_count, shixun_evaluate_count+sr.shixun_evaluate_count) + s_report.update_column(:shixun_evaluate_count, s_report.shixun_evaluate_count+sr.shixun_evaluate_count) sr.update(shixun_evaluate_count: 0) end end From 65d8ccee54233e8cbe521864af2dc96740054768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 12 Mar 2020 13:25:59 +0800 Subject: [PATCH 17/30] =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/courses/busyWork/NewWork.js | 6 +- .../src/modules/courses/busyWork/common.js | 8 +- .../modules/courses/busyWork/commonWork.js | 147 +++++++++++++----- 3 files changed, 120 insertions(+), 41 deletions(-) diff --git a/public/react/src/modules/courses/busyWork/NewWork.js b/public/react/src/modules/courses/busyWork/NewWork.js index 1bd79d93e..4bee890d8 100644 --- a/public/react/src/modules/courses/busyWork/NewWork.js +++ b/public/react/src/modules/courses/busyWork/NewWork.js @@ -35,7 +35,7 @@ class NewWork extends Component{ } fetchCourseData = (courseId) => { let newcategory=undefined; - if(this.props.match.path==="/classrooms/:coursesId/common_homework/:workId/:pageType"){ + if(this.props.match.path==="/classrooms/:coursesId/common_homework/:workId/:pageType"||this.props.match.path==="/classrooms/:coursesId/group_homework/:workId/:pageType"){ newcategory=this.props.match.params.workId } const isGroup = this.props.isGroup() @@ -64,7 +64,7 @@ class NewWork extends Component{ } fetchWork = (workId) => { let newcategory=undefined; - if(this.props.match.path==="/classrooms/:coursesId/common_homework/:workId/:pageType"){ + if(this.props.match.path==="/classrooms/:coursesId/common_homework/:workId/:pageType"||this.props.match.path==="/classrooms/:coursesId/group_homework/:workId/:pageType"){ newcategory=this.props.match.params.workId } let url="" @@ -115,7 +115,7 @@ class NewWork extends Component{ doNew = (params) => { const coursesId = this.props.match.params.coursesId const newUrl = `/courses/${coursesId}/homework_commons.json` - if(this.props.match.path==="/classrooms/:coursesId/common_homework/:workId/:pageType"){ + if(this.props.match.path==="/classrooms/:coursesId/common_homework/:workId/:pageType"||this.props.match.path==="/classrooms/:coursesId/group_homework/:workId/:pageType"){ params.category=this.props.match.params.workId } diff --git a/public/react/src/modules/courses/busyWork/common.js b/public/react/src/modules/courses/busyWork/common.js index b413f2c53..f738af2b4 100644 --- a/public/react/src/modules/courses/busyWork/common.js +++ b/public/react/src/modules/courses/busyWork/common.js @@ -31,7 +31,7 @@ export function RouteHOC(options = {}) { // common_homework group_homework // 是否是分组作业 isGroup = () => { - return window.location.pathname.indexOf('group_homeworks') != -1 + return window.location.pathname.indexOf('group_homeworks') != -1||window.location.pathname.indexOf('group_homework') != -1 } getModuleName = (isChinese) => { const isGroup = this.isGroup() @@ -45,6 +45,12 @@ export function RouteHOC(options = {}) { return secondName; } + + if(window.location.pathname.indexOf('group_homework') != -1){ + const secondName ='group_homework'; + return secondName; + } + if(window.location.pathname.indexOf('common_homeworks') != -1){ const secondName ='common_homeworks'; return secondName; diff --git a/public/react/src/modules/courses/busyWork/commonWork.js b/public/react/src/modules/courses/busyWork/commonWork.js index d4b097cec..6a7e3c878 100644 --- a/public/react/src/modules/courses/busyWork/commonWork.js +++ b/public/react/src/modules/courses/busyWork/commonWork.js @@ -35,7 +35,8 @@ class commonWork extends Component{ checkAll:false, checkBoxValues:[], isSpin:false, - category_id:undefined + category_id:undefined, + course_module:[] } } //输入搜索条件 @@ -70,42 +71,34 @@ class commonWork extends Component{ } componentDidUpdate(prevProps, prevState) { - console.log(this.props) - if (prevProps.coursesidtype != this.props.coursesidtype) { - if (this.props.match.path === "/classrooms/:coursesId/common_homeworks/:category_id" || this.props.match.path === "/classrooms/:coursesId/common_homework/:category_id") { - if (this.props.coursesidtype === "node" && this.props.match.path === "/classrooms/:coursesId/common_homeworks/:category_id") { + if (prevProps.coursesidtype != this.props.coursesidtype||prevProps.match.params.category_id!=this.props.match.params.category_id) { + if (this.props.match.path === "/classrooms/:coursesId/common_homeworks/:category_id" || this.props.match.path === "/classrooms/:coursesId/common_homework/:category_id"|| + this.props.match.path === "/classrooms/:coursesId/group_homeworks/:category_id" || this.props.match.path === "/classrooms/:coursesId/group_homework/:category_id" + ) { + + if (this.props.coursesidtype === "node" && this.props.match.path === "/classrooms/:coursesId/common_homeworks/:category_id"|| + this.props.coursesidtype === "node" && this.props.match.path === "/classrooms/:coursesId/group_homeworks/:category_id" + ) { + this.clearSelection() this.setState({selectedKeys: 'all', order: ''}, () => { this._getList() }) } - if (this.props.coursesidtype === "child" && this.props.match.path === "/classrooms/:coursesId/common_homework/:category_id") { + + if (this.props.coursesidtype === "child" && this.props.match.path === "/classrooms/:coursesId/common_homework/:category_id"|| + this.props.coursesidtype === "child" && this.props.match.path === "/classrooms/:coursesId/group_homework/:category_id" + ) { + this.clearSelection() this.setState({selectedKeys: 'all', order: ''}, () => { this._getList(this.props.match.params.category_id) }) } } + } - // - // if(this.props.match.path==="/classrooms/:coursesId/common_homeworks/:category_id"||this.props.match.path==="/classrooms/:coursesId/common_homework/:category_id"){ - // - // - // if(this.props.coursesidtype==="node"&&this.props.match.path==="/classrooms/:coursesId/common_homeworks/:category_id"){ - // this.clearSelection() - // this.setState({ selectedKeys: 'all', order: '' }, () => { - // this._getList() - // }) - // } - // if(this.props.coursesidtype==="child"&&this.props.match.path==="/classrooms/:coursesId/common_homework/:category_id"){ - // this.clearSelection() - // this.setState({ selectedKeys: 'all', order: '' }, () => { - // this._getList(this.props.match.params.category_id) - // }) - // } - // - // } } @@ -118,22 +111,24 @@ class commonWork extends Component{ this.getList(page,search,order,id); } componentDidMount(){ - if(this.props.coursesidtype==="node"){ + + if(this.props.match.path === "/classrooms/:coursesId/common_homeworks/:category_id"||this.props.match.path === "/classrooms/:coursesId/group_homeworks/:category_id"){ this._getList() - }else{ + } + if(this.props.match.path === "/classrooms/:coursesId/common_homework/:category_id"||this.props.match.path === "/classrooms/:coursesId/group_homework/:category_id") { this._getList(this.props.match.params.category_id) } - on('updateNavSuccess', this.updateNavSuccess) } componentWillUnmount() { off('updateNavSuccess', this.updateNavSuccess) } updateNavSuccess = () => { - if(this.props.coursesidtype==="node"){ + if(this.props.match.path === "/classrooms/:coursesId/common_homeworks/:category_id"||this.props.match.path === "/classrooms/:coursesId/group_homeworks/:category_id"){ this._getList() - }else{ + } + if(this.props.match.path === "/classrooms/:coursesId/common_homework/:category_id"||this.props.match.path === "/classrooms/:coursesId/group_homework/:category_id") { this._getList(this.props.match.params.category_id) } } @@ -151,7 +146,6 @@ class commonWork extends Component{ } getList=(page,search,order,category_id)=>{ - console.log(category_id) this.setState({ isSpin:true @@ -177,6 +171,32 @@ class commonWork extends Component{ page:page, ...result.data }) + this.getdatas(result.data.main_category_id) + } + }).catch((error)=>{ + this.setState({ + isSpin:false + }) + }) + } + getdatas=(main_category_id)=>{ + let newcourse_module=[] + + let urls=`/course_modules/${main_category_id}.json` + axios.get(encodeURI(urls)).then((result)=>{ + if(result.status==200){ + + newcourse_module.push({name:result.data.course_module.module_name,id:result.data.course_module.id}) + if(result.data.course_module.course_second_categories.length>0){ + + result.data.course_module.course_second_categories.map((item,key)=>{ + newcourse_module.push(item) + }) + } + + this.setState({ + course_module:newcourse_module + }) } }).catch((error)=>{ this.setState({ @@ -279,7 +299,7 @@ class commonWork extends Component{ } // onSetPublic = () => { - const { checkBoxValues } = this.state; + const { checkBoxValues,category_id } = this.state; const len = checkBoxValues.length; if (len == 0) { this.props.showNotification('请先选择要公开的作业') @@ -374,11 +394,41 @@ class commonWork extends Component{ if(!id){ trigger('addcommon_homeworks', parseInt(this.props.match.params.category_id)) }else{ - let data={id:parseInt(id),name:name} + let data={id:parseInt(id),name:this.state.category_name} trigger('editcommon_homeworks', data) } } + moveTo = (item) => { + const len = this.state.checkBoxValues.length + if (len == 0) { + this.props.showNotification('请先在列表中选择要移动的作业') + return; + } + const checkBoxValues = this.state.checkBoxValues; + const coursesId= this.props.match.params.coursesId; + const category_id=this.state.category_id; + const url = `/courses/${coursesId}/homework_commons/move_to_category.json` + axios.post(url, { + homework_ids: checkBoxValues, + new_category_id: item.id, + category_id:!category_id?undefined:category_id + }) + .then((response) => { + if (response.data.status == 0) { + console.log('--- 成功') + this.props.showNotification('作业移动成功') + this.props.updataleftNavfun() + this.setState({ + checkBoxValues:[] + }) + this.updateNavSuccess() + } + }) + .catch(function (error) { + console.log(error); + }); + } render(){ let { @@ -391,7 +441,7 @@ class commonWork extends Component{ totalCount, checkAll, checkBoxValues, - + course_module, task_count, published_count, unpublished_count, @@ -409,9 +459,8 @@ class commonWork extends Component{ const isGroup = this.props.isGroup() const isAdmin = this.props.isAdmin() + const bid = this.props.match.params.category_id - // - // return(
    @@ -458,7 +507,7 @@ class commonWork extends Component{ { isAdmin &&
  • } - { isAdmin &&
  • + { isAdmin &&
  • this.addDir(category_id)}>{!category_id?"新建目录":"目录重命名"}
  • } @@ -512,9 +561,33 @@ class commonWork extends Component{ { !!course_public &&
  • 设为公开
  • } - {this.props.user&&this.props.user.main_site===true?
  • 加入题库
  • :""} +
  • + 移动到... +
      + { course_module && course_module.length > 10 &&

      + {this.setState({dirSearchValue: e.target.value})}}/> +

      } + { + course_module && course_module.filter((item)=> { + return item.id != bid && (!this.state.dirSearchValue || item.name.indexOf(this.state.dirSearchValue) != -1) + }).map( (item, index) => { + return
    • this.moveTo(item)} title={item.name}>{item.name}
    • + }) + } + { isAdmin && +

      + this.addDir(category_id)} + >新建目录... +

      + } + {/*

      添加分班...

      */} +
    +
  • {/* 设为公开 */} Date: Thu, 12 Mar 2020 14:32:38 +0800 Subject: [PATCH 18/30] 1 --- lib/tasks/schools.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/schools.rake b/lib/tasks/schools.rake index 0d2cf0899..a788d57d1 100644 --- a/lib/tasks/schools.rake +++ b/lib/tasks/schools.rake @@ -21,7 +21,7 @@ namespace :schools do # 实训报告表迁移数据 s_report = SchoolReport.find_by(school_id: f_school) SchoolReport.where(school_id: merge_schools).each do |sr| - s_report.update_column(:shixun_evaluate_count, s_report.shixun_evaluate_count+sr.shixun_evaluate_count) + s_report.update_column(:shixun_evaluate_count, (s_report.shixun_evaluate_count+sr.shixun_evaluate_count)) sr.update(shixun_evaluate_count: 0) end end From 92804ee277408fbd5ef0635e60d64adc527a3a1c Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Mar 2020 14:48:33 +0800 Subject: [PATCH 19/30] =?UTF-8?q?web=E7=AB=AF=E7=9A=84=E6=AD=A3=E5=9C=A8?= =?UTF-8?q?=E7=AD=BE=E5=88=B0=E5=92=8C=E5=8E=86=E5=8F=B2=E7=AD=BE=E5=88=B0?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attendances_controller.rb | 39 +++++++++++++++++++++++ app/views/attendances/index.json.jbuilder | 18 +++++++++++ config/routes.rb | 4 +++ 3 files changed, 61 insertions(+) create mode 100644 app/controllers/attendances_controller.rb create mode 100644 app/views/attendances/index.json.jbuilder diff --git a/app/controllers/attendances_controller.rb b/app/controllers/attendances_controller.rb new file mode 100644 index 000000000..17eeab1d6 --- /dev/null +++ b/app/controllers/attendances_controller.rb @@ -0,0 +1,39 @@ +class AttendancesController < ApplicationController + before_action :require_login + before_action :find_course, only: [:index, :student_attendances, :history_attendances] + before_action :find_attendance, except: [:index, :student_attendances, :history_attendances] + before_action :user_course_identity + + def index + current_date = Date.current + current_end_time = Time.current.strftime("%H:%M:%S") + + if params[:history] + @attendances = @course.course_attendances.where("attendance_date < '#{current_date}' or + (attendance_date = '#{current_date}' and end_time < '#{current_end_time}')") + else + @attendances = @course.course_attendances.where("attendance_date > '#{current_date}' or + (attendance_date = '#{current_date}' and end_time > '#{current_end_time}')") + end + @attendances_count = @attendances.size + + @attendances = @attendances.order("attendance_date desc, start_time desc") + @attendances = paginate @attendances.includes(:user, :course_member_attendances) + end + + def history_attendances + current_date = Date.current + current_end_time = Time.current.strftime("%H:%M:%S") + + @history_attendances = @course.course_attendances.where("attendance_date < '#{current_date}' or + (attendance_date = '#{current_date}' and end_time < '#{current_end_time}')").order("id desc") + @all_history_count = @history_attendances.size + @history_attendances = paginate @history_attendances.includes(:course_member_attendances) + end + + private + def find_attendance + @attendance = CourseAttendance.find params[:id] + @course = @attendance.course + end +end \ No newline at end of file diff --git a/app/views/attendances/index.json.jbuilder b/app/views/attendances/index.json.jbuilder new file mode 100644 index 000000000..76febf51e --- /dev/null +++ b/app/views/attendances/index.json.jbuilder @@ -0,0 +1,18 @@ +json.attendances @attendances do |attendance| + json.(attendance, :id, :name, :normal_count, :all_count, :mode) + json.author do + user = attendance.user + json.user_name user.real_name + json.user_login user.login + end + json.attendance_date attendance.attendance_date.strftime("%Y-%m-%d") + json.start_time attendance.start_time.strftime("%H:%M") + json.end_time attendance.end_time.strftime("%H:%M") + json.edit_auth @user_course_identity < Course::PROFESSOR || attendance.user_id == User.current.id + + if @user_course_identity < Course::PROFESSOR == Course::STUDENT + json.attendance_status student_attendance_status(attendance, User.current) + end +end + +json.attendances_count @attendances_count \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index bcab93203..0f1bc5ba4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -550,6 +550,10 @@ Rails.application.routes.draw do end end + resources :attendances, shallow: true do + + end + resources :polls, only:[:index,:new,:create] do collection do post :publish # 立即发布 From 3d2c7097d9732b6a51c81a9cfc6574565e6aaeed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 12 Mar 2020 15:24:35 +0800 Subject: [PATCH 20/30] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E3=80=81=E8=AF=BE=E7=A8=8B=E9=A1=B6=E9=83=A8=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/modals/Modals.js | 5 +- .../src/modules/paths/PathDetail/DetailTop.js | 56 +++++++++++-------- public/react/src/modules/tpm/TPMBanner.js | 55 ++++++++++++++---- public/react/src/modules/tpm/TPMIndex.js | 1 + 4 files changed, 82 insertions(+), 35 deletions(-) diff --git a/public/react/src/modules/modals/Modals.js b/public/react/src/modules/modals/Modals.js index 1aaec6402..60485b26a 100644 --- a/public/react/src/modules/modals/Modals.js +++ b/public/react/src/modules/modals/Modals.js @@ -34,6 +34,9 @@ render() { } .color848282{ color:#848282; + } + .task-btn{ + color: #fff !important; } ` } @@ -50,7 +53,7 @@ render() {
    : } diff --git a/public/react/src/modules/paths/PathDetail/DetailTop.js b/public/react/src/modules/paths/PathDetail/DetailTop.js index d542c225e..1509b2b43 100644 --- a/public/react/src/modules/paths/PathDetail/DetailTop.js +++ b/public/react/src/modules/paths/PathDetail/DetailTop.js @@ -32,7 +32,10 @@ class DetailTop extends Component{ getappointmenttype:false, openpathss:false, cancel_publics:false, - cancel_has_publics:false + cancel_has_publics:false, + applyissuePaths:false, + cancelText:undefined, + okText:undefined } } componentDidMount(){ @@ -110,21 +113,27 @@ class DetailTop extends Component{ applyissuePath=()=>{ + this.setState({ + loadtype:true, + Modalstype: true, + Modalstopval:` 课程需经过平台审核方可公开使用,公开的课程将对平台所`, + modalsMidval:"有人公开可见,若仅本人教学使用则无需申请公开,直接发", + Modalsbottomval:"送到课堂即可。", + applyissuePaths:true + }) + + } + + showapplyissuePath=()=>{ let pathid=this.props.match.params.pathId; let url ="/paths/"+pathid+"/publish.json"; axios.post(url).then((result)=>{ if(result.status===200){ if(result.data.status===0){ - this.setState({ - loadtype:true, - Modalstype: true, - Modalstopval: ` 课程需经过平台审核方可公开使用,公开的课程将对平台所`, - modalsMidval:"有人公开可见。若仅本人教学使用则无需申请公开, 直接发", - Modalsbottomval:"送到课堂即可.", - cardsModalsavetype: true, - }) + this.props.showNotification(result.data.message) this.props.getlistdatas(); + this.cardsModalcancel() }else if(result.data.status===1){ // window.location.reload(); } @@ -132,9 +141,7 @@ class DetailTop extends Component{ }).catch((error)=>{ console.log(error); }) - - - } + } postcancelissuePath=()=>{ let pathId=this.props.match.params.pathId; let url ="/paths/"+pathId+"/cancel_publish.json"; @@ -180,12 +187,15 @@ class DetailTop extends Component{ modalsMidval:'', modalstyles:'', cardsModalsavetype:false, - applyissuePath:false, + applyissuePaths:false, openpathss:false, cancel_publics:false, cancel_has_publics:false, Modalstopval:``, + cancelText:undefined, + okText:undefined }) + } cardsModalsave=()=>{ @@ -369,13 +379,13 @@ class DetailTop extends Component{ openpaths=()=>{ this.setState({ - loadtype:true, Modalstype: true, openpathss:true, - Modalstopval: "公开申请已提交,请等待管理员的审核", - modalsMidval:"• 我们将在1-2个工作日内完成审核", - Loadtype:true, - modalstyles:"848282" + Modalstopval: "公开课程需经过平台标准化审核,审核周期为1-2天,公开", + modalsMidval:"的课程将对平台所有人可见。若仅本人教学使用则无需", + Modalsbottomval:"申请公开,直接发送到课堂即可", + cancelText:"取消申请", + okText:"确定申请" }) } @@ -433,7 +443,7 @@ class DetailTop extends Component{ render(){ let{detailInfoList}=this.props; - let{Modalstype,Modalstopval,cardsModalcancel,putappointmenttype,Modalsbottomval,cardsModalsavetype,loadtype,getappointmenttype,openpathss,cancel_publics,cancel_has_publics}=this.state; + let{Modalstype,Modalstopval,cardsModalcancel,putappointmenttype,Modalsbottomval,cardsModalsavetype,loadtype,getappointmenttype,openpathss,cancel_publics,cancel_has_publics,applyissuePaths}=this.state; const radioStyle = { display: 'block', height: '30px', @@ -470,8 +480,10 @@ class DetailTop extends Component{ modalsTopval={Modalstopval} modalsBottomval={Modalsbottomval} modalCancel={cardsModalcancel} - modalSave={loadtype===true&&openpathss===false?()=>this.cardsModalcancel():cardsModalsavetype===true?()=>this.postcancelissuePath():openpathss===true?()=>this.postopenpaths():cancel_publics===true?()=>this.postcancel_public():cancel_has_publics===true?()=>this.postcancel_has_public():putappointmenttype===true?()=>this.getappointment():()=>this.cardsModalsave()} + modalSave={applyissuePaths===true?()=>this.showapplyissuePath():loadtype===true&&openpathss===false?()=>this.cardsModalcancel():cardsModalsavetype===true?()=>this.postcancelissuePath():openpathss===true?()=>this.postopenpaths():cancel_publics===true?()=>this.postcancel_public():cancel_has_publics===true?()=>this.postcancel_has_public():putappointmenttype===true?()=>this.getappointment():()=>this.cardsModalsave()} loadtype={loadtype} + cancelText={this.state.cancelText} + okText={this.state.okText} modalsMidval={this.state.modalsMidval} modalstyles={this.state.modalstyles} > @@ -605,8 +617,8 @@ class DetailTop extends Component{ { detailInfoList.publish_status===0&&detailInfoList.allow_add_member===true? 发布:"" + style={{'width':'95px'}} + onClick={this.applyissuePath}>申请发布:"" } diff --git a/public/react/src/modules/tpm/TPMBanner.js b/public/react/src/modules/tpm/TPMBanner.js index 9ba752827..7527357c0 100644 --- a/public/react/src/modules/tpm/TPMBanner.js +++ b/public/react/src/modules/tpm/TPMBanner.js @@ -60,7 +60,8 @@ class TPMBanner extends Component { openshowpublictype:false, Radiovalue:1, TextAreaintshow:false, - + cancelText:undefined, + okText:undefined, } } @@ -434,6 +435,9 @@ class TPMBanner extends Component { modalsMidval:undefined, ModalsBottomval:"", modalstyles:"", + cancelText:undefined, + okText:undefined, + Loadtype:false, }) } ModalSave = () => { @@ -441,7 +445,10 @@ class TPMBanner extends Component { let url = "/shixuns/" + id + "/cancel_publish.json"; axios.get(url).then((response) => { this.props.showSnackbar(response.data.message); - window.location.reload() + // window.location.reload() + this.ModalCancel() + this.props.getcomponentdidmount() + }).catch((error) => { console.log(error) }); @@ -461,16 +468,21 @@ class TPMBanner extends Component { ModalSaveopenpublic= () => { this.setState({ Modalstype: true, - Modalstopval: "公开申请已提交,请等待管理员的审核", - modalsMidval:"• 我们将在1-2个工作日内完成审核", - ModalCancel: this.eopenpublicupdatadata, + Modalstopval:"公开实训需经过平台标准化审核,审核周期为1-2天,", + modalsMidval:"公开的实训将对平台所有人可见。若仅本人教学使用", + ModalsBottomval:"则无需申请公开, 直接发送到课堂即可。", + cancelText:"取消申请", + okText:"确定申请", + ModalCancel: this.ModalCancel, ModalSave: this.eopenpublicupdatadata, - Loadtype:true, - modalstyles:"848282" + // Loadtype:true, + // modalstyles:"848282" }) } eopenpublicupdatadata=()=>{ - window.location.reload() + // window.location.reload() + this.ModalCancel() + this.props.getcomponentdidmount() } openpublic=()=>{ let id = this.props.match.params.shixunId; @@ -490,7 +502,9 @@ class TPMBanner extends Component { let url = `/shixuns/${id}/cancel_apply_public.json`; axios.get(url).then((response) => { if(response.data.status===0){ - window.location.reload() + // window.location.reload() + this.ModalCancel() + this.props.getcomponentdidmount() } }).catch((error) => { console.log(error) @@ -522,7 +536,10 @@ class TPMBanner extends Component { evaluation_set_position = response.data.evaluation_set_position } if(response.data.status===0){ - window.location.reload() + // window.location.reload() + this.applyreleaseopen() + // this.ModalCancel() + this.props.getcomponentdidmount() }else{ this.setState({ Issuevisible: true, @@ -536,13 +553,23 @@ class TPMBanner extends Component { console.log(error) }); }; + applyreleaseopen = () => { + this.setState({ + Modalstype: true, + Loadtype:true, + Modalstopval: "实训发布后即可发送课堂使用", + ModalSave: this.ModalCancel, + }) + } hiddenIssuevisible = (val) => { this.setState({ Issuevisible: false }) if (val === 0 || val === 1) { - window.location.reload() + // window.location.reload() + this.ModalCancel() + this.props.getcomponentdidmount() } } @@ -803,7 +830,9 @@ class TPMBanner extends Component { hidestartshixunsreplacevalue, Forkvisibletype, AccountProfiletype, - isIE + isIE, + cancelText, + okText, } = this.state; let {shixunsDetails, shixunId, star_info, star_infos} = this.props; let challengeBtnTipText = ''; @@ -900,6 +929,8 @@ class TPMBanner extends Component { modalsMidval={this.state.modalsMidval} loadtype={this.state.Loadtype} modalstyles={this.state.modalstyles} + cancelText={this.state.cancelText} + okText={this.state.okText} /> : ""}
    diff --git a/public/react/src/modules/tpm/TPMIndex.js b/public/react/src/modules/tpm/TPMIndex.js index 7c7a706c5..2a650e3d0 100644 --- a/public/react/src/modules/tpm/TPMIndex.js +++ b/public/react/src/modules/tpm/TPMIndex.js @@ -412,6 +412,7 @@ class TPMIndex extends Component { {...this.props} {...this.state} is_jupyter={this.state. is_jupyter} + getcomponentdidmount={()=>this.getcomponentdidmount()} > } From b3089a4d6b78c575032e5843f04ef3eba659447b Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Mar 2020 15:47:19 +0800 Subject: [PATCH 21/30] =?UTF-8?q?=E7=AD=BE=E5=88=B0=E7=9A=84=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attendances_controller.rb | 14 ++++++++++++++ app/views/attendances/index.json.jbuilder | 10 ++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/controllers/attendances_controller.rb b/app/controllers/attendances_controller.rb index 17eeab1d6..e920eaa8a 100644 --- a/app/controllers/attendances_controller.rb +++ b/app/controllers/attendances_controller.rb @@ -11,6 +11,16 @@ class AttendancesController < ApplicationController if params[:history] @attendances = @course.course_attendances.where("attendance_date < '#{current_date}' or (attendance_date = '#{current_date}' and end_time < '#{current_end_time}')") + if @user_course_identity == Course::STUDENT + member = @course.students.find_by(user_id: current_user.id) + group_ids = [member&.course_group_id.to_i, 0] + @attendances = @attendances.joins(:course_attendance_groups).where(course_attendance_groups: {course_group_id: group_ids}) + + attendance_ids = @attendances.pluck(:id) + @normal_count = @course.course_member_attendances.where(course_member_id: member&.id, course_attendance_id: attendance_ids, attendance_status: "NORMAL").size + @leave_count = @course.course_member_attendances.where(course_member_id: member&.id, course_attendance_id: attendance_ids, attendance_status: "LEAVE").size + @absence_count = @course.course_member_attendances.where(course_member_id: member&.id, course_attendance_id: attendance_ids, attendance_status: "ABSENCE").size + end else @attendances = @course.course_attendances.where("attendance_date > '#{current_date}' or (attendance_date = '#{current_date}' and end_time > '#{current_end_time}')") @@ -21,6 +31,10 @@ class AttendancesController < ApplicationController @attendances = paginate @attendances.includes(:user, :course_member_attendances) end + def statistics + + end + def history_attendances current_date = Date.current current_end_time = Time.current.strftime("%H:%M:%S") diff --git a/app/views/attendances/index.json.jbuilder b/app/views/attendances/index.json.jbuilder index 76febf51e..8a4dd2bb1 100644 --- a/app/views/attendances/index.json.jbuilder +++ b/app/views/attendances/index.json.jbuilder @@ -10,9 +10,15 @@ json.attendances @attendances do |attendance| json.end_time attendance.end_time.strftime("%H:%M") json.edit_auth @user_course_identity < Course::PROFESSOR || attendance.user_id == User.current.id - if @user_course_identity < Course::PROFESSOR == Course::STUDENT + if @user_course_identity == Course::STUDENT json.attendance_status student_attendance_status(attendance, User.current) end end -json.attendances_count @attendances_count \ No newline at end of file +json.attendances_count @attendances_count + +if @user_course_identity == Course::STUDENT + json.normal_count @normal_count + json.leave_count @leave_count + json.absence_count @absence_count +end \ No newline at end of file From 3ed72cb593ca27aff6fca15d4fae45627ce22b4f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 12 Mar 2020 15:54:29 +0800 Subject: [PATCH 22/30] =?UTF-8?q?=E5=85=B3=E5=8D=A1=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/challenge.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 42d7f3499..38aa2812a 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -75,7 +75,7 @@ class Challenge < ApplicationRecord if identifier.present? shixun.task_pass || self.status != 3 ? "/tasks/#{identifier}" : "" else - self.position == 1 ? "/api/shixuns/#{shixun.identifier}/shixun_exec" : "" + self.position == 1 ? "/shixuns/#{shixun.identifier}/shixun_exec.json" : "" end end From 1c79a27646b236d5676c2e74290201f0a28a5265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 12 Mar 2020 16:14:43 +0800 Subject: [PATCH 23/30] =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/common/components/comment/util.js | 6 +- .../CompetitionContentsMd.js | 2 +- .../courses/busyWork/PublishRightnow.js | 12 ++-- .../src/modules/courses/busyWork/UseBank.js | 2 +- .../CompetitionContentsMd.js | 2 +- .../courses/gradinforms/Bullsubdirectory.js | 2 +- .../EditableCourseSupportSetting.js | 58 +++++++++---------- .../subroute/ecStudentList/EcStudentList.js | 8 +-- public/react/src/modules/forums/MemoDetail.js | 2 +- public/react/src/modules/login/LoginDialog.js | 2 +- public/react/src/modules/modals/SendTopics.js | 4 +- .../PackageIndexNEIBanner.js | 2 +- .../question/component/Newknledpots.js | 2 +- .../comthetestpaper/Comthetestpaperst.js | 2 +- .../component/Paperlibraryseeid_item.js | 2 +- .../modules/tpm/Audit_situationComponent.js | 2 +- .../src/modules/tpm/newshixuns/Newshixuns.js | 2 +- .../src/modules/user/FindPasswordComponent.js | 2 +- .../modules/user/LoginRegisterComponent.js | 2 +- 19 files changed, 58 insertions(+), 58 deletions(-) diff --git a/public/react/src/common/components/comment/util.js b/public/react/src/common/components/comment/util.js index 2b4f36a85..8694161a3 100644 --- a/public/react/src/common/components/comment/util.js +++ b/public/react/src/common/components/comment/util.js @@ -1,7 +1,7 @@ /* * @Description: quill delta -> html * @Author: tangjiang - * @Github: + * @Github: * @Date: 2019-12-24 08:51:25 * @LastEditors : tangjiang * @LastEditTime : 2019-12-26 09:30:11 @@ -55,7 +55,7 @@ export const formatDelta = (deltas) => { */ export const operate = (text, key, value) => { let operatedText = null; - debugger; + switch (key) { case 'bold': operatedText = `${text}`; @@ -72,7 +72,7 @@ export const operate = (text, key, value) => { case 'link': operatedText = `${text}`; break; - default: + default: operatedText = text; } diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js index 9ea972177..0cae1e2a6 100644 --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js @@ -34,7 +34,7 @@ class CompetitionContentsMd extends Component{ }else{ chart_rules.rule_contents.map((items,keys)=>{ - debugger + if(parseInt(this.props.tabkey)===items.competition_stage_id){ console.log(items) this.contentMdRef.current.setValue(items.content); diff --git a/public/react/src/modules/courses/busyWork/PublishRightnow.js b/public/react/src/modules/courses/busyWork/PublishRightnow.js index 1b9c8b0f1..9863a95d6 100644 --- a/public/react/src/modules/courses/busyWork/PublishRightnow.js +++ b/public/react/src/modules/courses/busyWork/PublishRightnow.js @@ -41,10 +41,10 @@ class PublishRightnow extends Component{ this.props.showNotification(`请先选择要立即${showdatatypes? "发布" : "截止"}的作业`) return; } - + this.fetchCourseGroups(); - - + + } showDialog = (course_groups) => { const isPublish = this.props.isPublish; @@ -96,7 +96,7 @@ class PublishRightnow extends Component{ } homeworkstartend=(arg_group_ids,endtime)=>{ - debugger + if (this.usingCheckBeforePost && this.props.checkBeforePost) { const goOn = this.props.checkBeforePost(); if (!goOn) { @@ -104,7 +104,7 @@ class PublishRightnow extends Component{ return; } } - debugger + const isPublish = this.props.isPublish; let group_ids = arg_group_ids if (this.usingCheckBeforePost) { @@ -112,7 +112,7 @@ class PublishRightnow extends Component{ return item.id }) } - debugger + if(this.state.course_groups.length>0){ if (this.state.course_groups.length && (!group_ids || group_ids&&group_ids.length == 0)) { this.props.showNotification('请至少选择一个分班'); diff --git a/public/react/src/modules/courses/busyWork/UseBank.js b/public/react/src/modules/courses/busyWork/UseBank.js index b31412470..bfa9b3520 100644 --- a/public/react/src/modules/courses/busyWork/UseBank.js +++ b/public/react/src/modules/courses/busyWork/UseBank.js @@ -130,7 +130,7 @@ class UseBank extends Component{ }) } onSave = () => { - debugger + const { checkBoxValues } = this.state; const { object_type,category_id } = this.props if(checkBoxValues.length==0){ diff --git a/public/react/src/modules/courses/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js b/public/react/src/modules/courses/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js index 9ea972177..0cae1e2a6 100644 --- a/public/react/src/modules/courses/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js +++ b/public/react/src/modules/courses/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js @@ -34,7 +34,7 @@ class CompetitionContentsMd extends Component{ }else{ chart_rules.rule_contents.map((items,keys)=>{ - debugger + if(parseInt(this.props.tabkey)===items.competition_stage_id){ console.log(items) this.contentMdRef.current.setValue(items.content); diff --git a/public/react/src/modules/courses/gradinforms/Bullsubdirectory.js b/public/react/src/modules/courses/gradinforms/Bullsubdirectory.js index 78f56a0f7..f166f3aaa 100644 --- a/public/react/src/modules/courses/gradinforms/Bullsubdirectory.js +++ b/public/react/src/modules/courses/gradinforms/Bullsubdirectory.js @@ -156,7 +156,7 @@ class Bullsubdirectory extends Component{ handleSubmit=(e) => { e.preventDefault(); this.props.form.validateFields((err, values) => { - debugger + if (!err) { console.log(values.description); if(values.eduintits === undefined|| values.eduintits === "" || values.eduintits ===null){ diff --git a/public/react/src/modules/ecs/subroute/ecCourseSupportSetting/EditableCourseSupportSetting.js b/public/react/src/modules/ecs/subroute/ecCourseSupportSetting/EditableCourseSupportSetting.js index 70b39241c..3b5d88a3d 100644 --- a/public/react/src/modules/ecs/subroute/ecCourseSupportSetting/EditableCourseSupportSetting.js +++ b/public/react/src/modules/ecs/subroute/ecCourseSupportSetting/EditableCourseSupportSetting.js @@ -20,7 +20,7 @@ let id = 0; /** target_id - position + position target_weight target_contents @@ -29,7 +29,7 @@ let id = 0; subitem_contents */ -const data = +const data = [{"position":0,"target_weight":0.02,"target_contents":"12","standard_grade":2,"subitem_id":"65"},{"position":3,"target_id":"0","target_weight":0.1,"target_contents":"理解数据管理技术和数据库技术的发展,区分不同数据模型的作用和特点,描述数据库系统的类型、结构、数据独立性。","standard_grade":60,"subitem_id":"66"},{"position":4,"target_weight":1,"target_contents":"22","standard_grade":33,"subitem_id":"66"},{"position":11,"target_id":"1","target_weight":0.1,"target_contents":"理解数据管理技术和数据库技术的发展,区分不同数据模型的作用和特点,描述数据库系统的类型、结构、数据独立性。","standard_grade":61,"subitem_id":"65"}] ; let _data = [ @@ -70,10 +70,10 @@ class EditableCourseSupportSetting extends Component { let fValues = this.props.form.getFieldsValue(); if ( // fValues.standard_grade[k] && fValues.standard_grade[k] != 75 - // || fValues.subitem_id[k] - // || - fValues.target_contents[k] - // || fValues.target_weight[k] + // || fValues.subitem_id[k] + // || + fValues.target_contents[k] + // || fValues.target_weight[k] ) { this.props.showModal('提示', '确定要删除吗?', () => { this.remove(k) @@ -129,7 +129,7 @@ class EditableCourseSupportSetting extends Component { const subitem_id = form.getFieldValue('subitem_id'); keys.splice(index_arg, 0, newKey); - // position2Target_idMap + // position2Target_idMap // {1:2, 2:3, 3:4, 4:6 } --> {1:2, 2:3, 3:7, 4:4, 5:6 } // 更新key/position 映射到target_id的map // 两次revers,用这个结构,达到给position加1的效果 @@ -142,13 +142,13 @@ class EditableCourseSupportSetting extends Component { reverseMap[target_id] = parseInt(reverseMap[target_id]) + 1; keys[i] = keys[i] + 1; } - for (let i = 0 ; i < keys.length - 1; i++) { + for (let i = 0 ; i < keys.length - 1; i++) { if (keys[i] == keys[i + 1]) { - debugger; + } } this.position2Target_idMap = this._reverseMap(reverseMap); - + target_weight.splice(newKey, 0, undefined); target_contents.splice(newKey, 0, undefined); @@ -179,7 +179,7 @@ class EditableCourseSupportSetting extends Component { const keys = form.getFieldValue('keys'); let nextKeys ; let newKey = k + 1; - + const newKeyIndex = keys.indexOf(newKey) if (newKeyIndex != -1) { // 新key存在,将新key位置及以后的row后移,直到找到一个之后的空位置 @@ -213,7 +213,7 @@ class EditableCourseSupportSetting extends Component { data.push({}) } for (var valKey in values) { - + let dataIndex = 0 values[valKey].forEach( (item,index) => { let _val = values[valKey][index]; @@ -228,7 +228,7 @@ class EditableCourseSupportSetting extends Component { } console.log('Received values of form: ', values, data); - + let totalWeight = 0; values.target_weight.forEach(item => { if (item) { @@ -264,8 +264,8 @@ class EditableCourseSupportSetting extends Component { } } } - - + + }); } @@ -292,7 +292,7 @@ class EditableCourseSupportSetting extends Component { subitem_id[item.position] = item.subitem_id ? (item.subitem_id).toString() : item.subitem_id; this.position2Target_idMap[item.position] = item.target_id - }) + }) form.setFieldsValue({ keys }); @@ -308,9 +308,9 @@ class EditableCourseSupportSetting extends Component { // this.forceUpdate() }, 3000) - + } - + render() { const { getFieldDecorator, getFieldValue } = this.props.form; @@ -397,7 +397,7 @@ class EditableCourseSupportSetting extends Component { message: "请先选择毕业要求指标点", }], })( - )} - { !addOrDeleting && { this.onRemove(k) }} className="color-grey-c mr15" data-tip-down="删除"> } - { !addOrDeleting && { this.add(k, index + 1) }} - className="color-green show-FillTable" + className="color-green show-FillTable" data-tip-down="添加"> } - - + + )); return ( - +

    @@ -443,15 +443,15 @@ class EditableCourseSupportSetting extends Component { 对应毕业要求指标点 { !addOrDeleting && - { this.add(-1, 0) }} data-tip-down="添加"> } -

    +

    {formItems}
    {/* - diff --git a/public/react/src/modules/ecs/subroute/ecStudentList/EcStudentList.js b/public/react/src/modules/ecs/subroute/ecStudentList/EcStudentList.js index e8876b7a5..9af0acb31 100644 --- a/public/react/src/modules/ecs/subroute/ecStudentList/EcStudentList.js +++ b/public/react/src/modules/ecs/subroute/ecStudentList/EcStudentList.js @@ -123,7 +123,7 @@ class EcStudentList extends Component { console.log(error); }); } - + windowsgoblack=()=>{ window.history.go(-1) @@ -267,17 +267,17 @@ class EcStudentList extends Component { Modallist: '确定删除这些学生吗?', Modallisttype:true, Modallisttypess:1 - }) + }) }else{ this.setState({ Modallist: '请选择学生!', Modallisttype:true - }) + }) } }; //删除学生 deletelistbthenters=()=>{ - debugger + let {Myschoolstudents,studentall} =this.state; let major_id=this.props.match.params.majorId; let year_id=this.props.match.params.yearId; diff --git a/public/react/src/modules/forums/MemoDetail.js b/public/react/src/modules/forums/MemoDetail.js index 792b24aa9..b5ba988e5 100644 --- a/public/react/src/modules/forums/MemoDetail.js +++ b/public/react/src/modules/forums/MemoDetail.js @@ -668,7 +668,7 @@ class MemoDetail extends Component { // --------------------------------------------------------------------------------------------帖子獎勵 END showCommentInput = () => { - debugger + if (window.__useKindEditor === true) { this.refs.editor.showEditor(); } else { diff --git a/public/react/src/modules/login/LoginDialog.js b/public/react/src/modules/login/LoginDialog.js index dda9fed7f..cc0a15514 100644 --- a/public/react/src/modules/login/LoginDialog.js +++ b/public/react/src/modules/login/LoginDialog.js @@ -469,7 +469,7 @@ class LoginDialog extends Component { autologin:isGoingValue } ).then((response) => { - debugger; + if(response===undefined){ return } diff --git a/public/react/src/modules/modals/SendTopics.js b/public/react/src/modules/modals/SendTopics.js index 96320f201..7a072a843 100644 --- a/public/react/src/modules/modals/SendTopics.js +++ b/public/react/src/modules/modals/SendTopics.js @@ -95,7 +95,7 @@ class SendTopics extends Component{ }catch (e) { } -debugger + if(this.props.mysendall===true){ //详情页面跳过来的 try { @@ -119,7 +119,7 @@ debugger } }else{ //外部多个列表页跳过来的 - debugger + try { var rurls=""; if(this.props.category==="normal"){ diff --git a/public/react/src/modules/projectPackages/PackageIndexNewandEdit/PackageIndexNEIBanner.js b/public/react/src/modules/projectPackages/PackageIndexNewandEdit/PackageIndexNEIBanner.js index ffb28d3df..283445ea1 100644 --- a/public/react/src/modules/projectPackages/PackageIndexNewandEdit/PackageIndexNEIBanner.js +++ b/public/react/src/modules/projectPackages/PackageIndexNewandEdit/PackageIndexNEIBanner.js @@ -16,7 +16,7 @@ class PackageIndexNEIBanner extends Component { } onChange=(current)=>{ - debugger + console.log('onChange:', current); this.setState({ current }); }; diff --git a/public/react/src/modules/question/component/Newknledpots.js b/public/react/src/modules/question/component/Newknledpots.js index 7e0a79228..ad2710593 100644 --- a/public/react/src/modules/question/component/Newknledpots.js +++ b/public/react/src/modules/question/component/Newknledpots.js @@ -63,7 +63,7 @@ class PaperDeletModel extends Component { } NewknTypedeltyoedels=()=>{ - debugger + if(this.state.newkntypeinput.length===0){ this.setState({ errorestit:'请输入知识点', diff --git a/public/react/src/modules/question/comthetestpaper/Comthetestpaperst.js b/public/react/src/modules/question/comthetestpaper/Comthetestpaperst.js index a426e7ea7..447416225 100644 --- a/public/react/src/modules/question/comthetestpaper/Comthetestpaperst.js +++ b/public/react/src/modules/question/comthetestpaper/Comthetestpaperst.js @@ -475,7 +475,7 @@ class Comthetestpaperst extends Component { //////console.log('Clicked! But prevent default.'); } deletesobject = (item, index) => { - debugger + var tmp = this.state.Knowpoints; for (var i = 0; i < tmp.length; i++) { if (i ===index) { diff --git a/public/react/src/modules/testpaper/component/Paperlibraryseeid_item.js b/public/react/src/modules/testpaper/component/Paperlibraryseeid_item.js index 58959d745..05dbaec82 100644 --- a/public/react/src/modules/testpaper/component/Paperlibraryseeid_item.js +++ b/public/react/src/modules/testpaper/component/Paperlibraryseeid_item.js @@ -123,7 +123,7 @@ class Paperreview_item extends Component { } axios.post(url, data) .then((result) => { - debugger + if (result.data.status == 0) { // this.props.showNotification(`拖动成功`); this.props.getdata(); diff --git a/public/react/src/modules/tpm/Audit_situationComponent.js b/public/react/src/modules/tpm/Audit_situationComponent.js index 3739cd6db..1057bc484 100644 --- a/public/react/src/modules/tpm/Audit_situationComponent.js +++ b/public/react/src/modules/tpm/Audit_situationComponent.js @@ -106,7 +106,7 @@ class Audit_situationComponent extends Component { } showModal = (id,status) => { - debugger + this.setState({ visible: true, editid:id, diff --git a/public/react/src/modules/tpm/newshixuns/Newshixuns.js b/public/react/src/modules/tpm/newshixuns/Newshixuns.js index 46f45a8a7..71b325986 100644 --- a/public/react/src/modules/tpm/newshixuns/Newshixuns.js +++ b/public/react/src/modules/tpm/newshixuns/Newshixuns.js @@ -97,7 +97,7 @@ class Newshixuns extends Component { }) const mdContnet = this.contentMdRef.current.getValue().trim(); this.props.form.validateFieldsAndScroll((err, values) => { - debugger + if (!err) { console.log('Received values of form: ', values); diff --git a/public/react/src/modules/user/FindPasswordComponent.js b/public/react/src/modules/user/FindPasswordComponent.js index baf099909..85f0285a8 100644 --- a/public/react/src/modules/user/FindPasswordComponent.js +++ b/public/react/src/modules/user/FindPasswordComponent.js @@ -94,7 +94,7 @@ class LoginRegisterComponent extends Component { } //倒计时 getverificationcode = () => { - debugger + if(this.state.login === undefined || this.state.login.length===0){ this.openNotification("请输入手机号或邮箱"); return; diff --git a/public/react/src/modules/user/LoginRegisterComponent.js b/public/react/src/modules/user/LoginRegisterComponent.js index a356e3788..786fd1356 100644 --- a/public/react/src/modules/user/LoginRegisterComponent.js +++ b/public/react/src/modules/user/LoginRegisterComponent.js @@ -352,7 +352,7 @@ class LoginRegisterComponent extends Component { login: this.state.login, password: this.state.password, }).then((response) => { - debugger + if (response === undefined) { return } From a3e6962c710152d2ae5db32c599f71467cf83415 Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Thu, 12 Mar 2020 16:30:02 +0800 Subject: [PATCH 24/30] =?UTF-8?q?=E5=85=B3=E5=8D=A1-=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E6=8C=91=E6=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tpm/shixunchild/Challenges/Challenges.js | 132 ++++++++++++------ .../shixunchild/shixunchildCss/Challenges.css | 24 ++++ 2 files changed, 117 insertions(+), 39 deletions(-) diff --git a/public/react/src/modules/tpm/shixunchild/Challenges/Challenges.js b/public/react/src/modules/tpm/shixunchild/Challenges/Challenges.js index 0e701c00c..32263676f 100644 --- a/public/react/src/modules/tpm/shixunchild/Challenges/Challenges.js +++ b/public/react/src/modules/tpm/shixunchild/Challenges/Challenges.js @@ -33,7 +33,7 @@ class Challenges extends Component { isSpin:false, boxoffsetHeigh:0, opentitletype:true, - isopentitletype:"Less", + isopentitletype:"Less" } } @@ -357,6 +357,50 @@ class Challenges extends Component { }) } + // 开启挑战 + beginChallenge=(url)=>{ + if (this.props.checkIfLogin() === false) { + this.props.showLoginDialog() + return; + } + if (this.props.checkIfProfileCompleted() === false) { + this.setState({ + AccountProfiletype: true + }) + return; + } + this.setState({ + startbtns:true + }) + if(url.indexOf(".json")>-1){ + axios.get(url).then((response) => { + if (response.data.status === -2) { + this.setState({ + startbtns:false, + shixunsreplace:true, + hidestartshixunsreplacevalue:response.data.message+".json" + }) + } else if (response.data.status === -1) { + this.setState({ + startbtns: false + }) + }else if(response.data.status===-3){ + this.setState({ + shixunsmessage:response.data.message, + startshixunCombattype:true, + startbtns:false + }) + } else { + window.location.href = "/tasks/" + response.data.game_identifier; + } + }).catch((error) => { + + }); + }else{ + window.location.href=url; + } + } + render() { let { ChallengesDataList, startbtns, sumidtype ,startshixunCombattype,shixunsreplace,shixunsmessage,hidestartshixunsreplacevalue,operationstrue,AccountProfiletype} = this.state; let { loadingContent } = this.props; @@ -700,49 +744,60 @@ class Challenges extends Component {
    +
    +
    +
    + {/*onClick={() => this.EditTraining(this.props.identity, item.challenge_id, "/editquestion")}*/} + {this.props.identity<5? + item.st === 1 ? +
    {item.name}
    + : +
    {item.name}
    :
    this.startshixunCombat(this.props.identity, item.challenge_id, "/editcheckpoint")} + className="font-16 color05101a fonthiddens">{item.name}
    + } + {/* onClick={() => this.EditTraining(this.props.identity, item.challenge_id, "/editcheckpoint")}*/} + + + +
    +
    + + 正在挑战: {item.playing_count}人 + 完成挑战: {item.passed_count}人 + 可获经验: {item.score}点 -
    - {/*onClick={() => this.EditTraining(this.props.identity, item.challenge_id, "/editquestion")}*/} - {this.props.identity<5? - item.st === 1 ? -
    {item.name}
    - : -
    {item.name}
    :
    this.startshixunCombat(this.props.identity, item.challenge_id, "/editcheckpoint")} - className="font-16 color05101a fonthiddens">{item.name}
    +
    +
    + { + item.open_game ? + this.beginChallenge(item.open_game)} className="challengeBtn blue">开启挑战 + : + 开启挑战 } - {/* onClick={() => this.EditTraining(this.props.identity, item.challenge_id, "/editcheckpoint")}*/} - - - - - -
    -
    - - 正在挑战: {item.playing_count}人 - 完成挑战: {item.passed_count}人 - 可获经验: {item.score}点 - -
    +
    ) })}
    + + + - Date: Thu, 12 Mar 2020 16:33:37 +0800 Subject: [PATCH 25/30] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=AD=90=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/course_second_categories_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/controllers/course_second_categories_controller.rb b/app/controllers/course_second_categories_controller.rb index 62cbf83d9..c59ffbdbe 100644 --- a/app/controllers/course_second_categories_controller.rb +++ b/app/controllers/course_second_categories_controller.rb @@ -43,6 +43,12 @@ class CourseSecondCategoriesController < ApplicationController elsif @course_module.module_type == "video" @course.course_videos.where(course_second_category_id: @category.id).update_all(course_second_category_id: 0) @right_url = "/classrooms/#{@course.id}/course_videos" + elsif @course_module.module_type == "common_homework" + @category.homework_commons.update_all(course_second_category_id: 0) + @right_url = "/classrooms/#{@course.id}/common_homeworks/#{@course_module.id}" + elsif @course_module.module_type == "group_homework" + @category.homework_commons.update_all(course_second_category_id: 0) + @right_url = "/classrooms/#{@course.id}/group_homeworks/#{@course_module.id}" end @category.destroy From e8c14246d35a70ddf634ebe12a1719b48223416b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 12 Mar 2020 16:42:52 +0800 Subject: [PATCH 26/30] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/courses/busyWork/CommonWorkItem.js | 10 ++++++++-- .../react/src/modules/courses/busyWork/commonWork.js | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/public/react/src/modules/courses/busyWork/CommonWorkItem.js b/public/react/src/modules/courses/busyWork/CommonWorkItem.js index b2f598486..4e8146118 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkItem.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkItem.js @@ -163,7 +163,7 @@ class CommonWorkItem extends Component{ }
    this.props.onItemClick(Object.assign({}, item, {id: item.homework_id})) }> -

    +

    {canNotLink? @@ -199,7 +199,13 @@ class CommonWorkItem extends Component{ } */}

    -

    + { + item && item.upper_category_name && + // 22 }> +

    所属目录:{item.upper_category_name}
    + // + } +

    { item.author && {item.author} } {item.commit_count===undefined?"":{item.commit_count} 已交} {item.uncommit_count===undefined?"":{item.uncommit_count} 未交} diff --git a/public/react/src/modules/courses/busyWork/commonWork.js b/public/react/src/modules/courses/busyWork/commonWork.js index 6a7e3c878..c5db27252 100644 --- a/public/react/src/modules/courses/busyWork/commonWork.js +++ b/public/react/src/modules/courses/busyWork/commonWork.js @@ -399,6 +399,10 @@ class commonWork extends Component{ } } + + newaddDir = () => { + trigger('addcommon_homeworks', parseInt(this.state.main_category_id)) + } moveTo = (item) => { const len = this.state.checkBoxValues.length if (len == 0) { @@ -581,7 +585,7 @@ class commonWork extends Component{ { isAdmin &&

    this.addDir(category_id)} + onClick={()=>this.newaddDir()} >新建目录...

    } From 51014fa2583b2cbebed264729924c971d38680a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 12 Mar 2020 16:45:59 +0800 Subject: [PATCH 27/30] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/paths/PathDetail/DetailTop.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/react/src/modules/paths/PathDetail/DetailTop.js b/public/react/src/modules/paths/PathDetail/DetailTop.js index 1509b2b43..bf43c0759 100644 --- a/public/react/src/modules/paths/PathDetail/DetailTop.js +++ b/public/react/src/modules/paths/PathDetail/DetailTop.js @@ -116,9 +116,9 @@ class DetailTop extends Component{ this.setState({ loadtype:true, Modalstype: true, - Modalstopval:` 课程需经过平台审核方可公开使用,公开的课程将对平台所`, - modalsMidval:"有人公开可见,若仅本人教学使用则无需申请公开,直接发", - Modalsbottomval:"送到课堂即可。", + Modalstopval:`课程发布后即可发送课堂使用`, + // modalsMidval:"有人公开可见,若仅本人教学使用则无需申请公开,直接发", + // Modalsbottomval:"送到课堂即可。", applyissuePaths:true }) From 759ad9bdb8321e2b7669ef85ee20b8d7139311b7 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Mar 2020 18:12:51 +0800 Subject: [PATCH 28/30] =?UTF-8?q?=E7=AC=91=E5=88=B0=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attendances_controller.rb | 26 +++++---- app/services/attendance_statistics_service.rb | 54 +++++++++++++++++++ .../attendances/statistics.json.jbuilder | 10 ++++ config/routes.rb | 2 +- 4 files changed, 81 insertions(+), 11 deletions(-) create mode 100644 app/services/attendance_statistics_service.rb create mode 100644 app/views/attendances/statistics.json.jbuilder diff --git a/app/controllers/attendances_controller.rb b/app/controllers/attendances_controller.rb index e920eaa8a..dc30df7e3 100644 --- a/app/controllers/attendances_controller.rb +++ b/app/controllers/attendances_controller.rb @@ -1,7 +1,7 @@ class AttendancesController < ApplicationController + before_action :require_login - before_action :find_course, only: [:index, :student_attendances, :history_attendances] - before_action :find_attendance, except: [:index, :student_attendances, :history_attendances] + before_action :find_course, only: [:index, :statistics] before_action :user_course_identity def index @@ -32,17 +32,23 @@ class AttendancesController < ApplicationController end def statistics - - end - - def history_attendances current_date = Date.current current_end_time = Time.current.strftime("%H:%M:%S") + history_attendances = @course.course_attendances.where("attendance_date < '#{current_date}' or + (attendance_date = '#{current_date}' and end_time < '#{current_end_time}')") + all_member_attendances = CourseMemberAttendance.where(course_attendance_id: history_attendances) + if params[:group_id].present? + history_attendances = history_attendances.joins(:course_attendance_groups).where(course_attendance_groups: {course_group_id: [params[:group_id], 0]}) + all_member_attendances = all_member_attendances.joins(:course_member).where(course_members: {course_group_id: params[:group_id]}) + end - @history_attendances = @course.course_attendances.where("attendance_date < '#{current_date}' or - (attendance_date = '#{current_date}' and end_time < '#{current_end_time}')").order("id desc") - @all_history_count = @history_attendances.size - @history_attendances = paginate @history_attendances.includes(:course_member_attendances) + history_attendances = history_attendances.order("attendance_date desc, start_time desc") + data = AttendanceStatisticsService.call history_attendances, all_member_attendances + @all_history_count = data[:all_history_count] + @history_attendances = data[:history_attendances] + @avg_normal_rate = data[:avg_normal_rate] + @avg_absence_rate = data[:avg_absence_rate] + @avg_leave_rate = data[:avg_leave_rate] end private diff --git a/app/services/attendance_statistics_service.rb b/app/services/attendance_statistics_service.rb new file mode 100644 index 000000000..e31049b22 --- /dev/null +++ b/app/services/attendance_statistics_service.rb @@ -0,0 +1,54 @@ +class AttendanceStatisticsService < ApplicationService + + attr_reader :attendances, :member_attendances + + def initialize(attendances, member_attendances) + @attendances = attendances + @member_attendances = member_attendances + end + + def call + all_normal_rate = [] + all_absence_rate = [] + all_leave_rate = [] + + history_attendances = [] + + attendances.each do |attendance| + normal_count = history_member_count(member_attendances, "NORMAL", attendance.id) + absence_count = history_member_count(member_attendances, "ABSENCE", attendance.id) + leave_count = history_member_count(member_attendances, "LEAVE", attendance.id) + all_count = member_attendances.select{|member_attendance| member_attendance.course_attendance_id == attendance.id}.size + + normal_rate = cal_rate(normal_count, all_count) + all_normal_rate << normal_rate + absence_rate = cal_rate(absence_count, all_count) + all_absence_rate << absence_rate + leave_rate = cal_rate(leave_count, all_count) + all_leave_rate << leave_rate + + history_attendances << {name: attendance.name, attendance_date: attendance.attendance_date.strftime("%Y-%m-%d"), + start_time: attendance.start_time.strftime("%H:%M"), end_time: attendance.end_time.strftime("%H:%M"), + normal_rate: normal_rate, absence_rate: absence_rate, leave_rate: leave_rate} + end + + all_history_count = history_attendances.size + history_attendances = history_attendances[0..9].reverse + avg_normal_rate = cal_rate(all_normal_rate.sum, all_history_count) + avg_absence_rate = cal_rate(all_absence_rate.sum, all_history_count) + avg_leave_rate = cal_rate(all_leave_rate.sum, all_history_count) + + {all_history_count: all_history_count, history_attendances: history_attendances, avg_normal_rate: avg_normal_rate, + avg_absence_rate: avg_absence_rate, avg_leave_rate: avg_leave_rate} + end + + private + + def history_member_count member_attendances, status, attendance_id + member_attendances.select{|member_attendance| member_attendance.attendance_status == status && member_attendance.course_attendance_id == attendance_id}.size + end + + def cal_rate base, sum + sum == 0 ? 0 : (base.to_f / sum) + end +end \ No newline at end of file diff --git a/app/views/attendances/statistics.json.jbuilder b/app/views/attendances/statistics.json.jbuilder new file mode 100644 index 000000000..d07f234d6 --- /dev/null +++ b/app/views/attendances/statistics.json.jbuilder @@ -0,0 +1,10 @@ + +json.history_attendances @history_attendances.each_with_index.to_a do |attendance, index| + json.(attendance, :name, :attendance_date, :start_time, :end_time, :normal_rate, :absence_rate, :leave_rate) + json.index "签到#{index + 1}" +end + +json.all_history_count @all_history_count +json.avg_normal_rate @avg_normal_rate +json.avg_absence_rate @avg_absence_rate +json.avg_leave_rate @avg_leave_rate \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 0f1bc5ba4..6c3efcfe8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -551,7 +551,7 @@ Rails.application.routes.draw do end resources :attendances, shallow: true do - + get :statistics, on: :collection end resources :polls, only:[:index,:new,:create] do From d588229832fb9c6bbbb0b8ff6e5e61ee3c597961 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Mar 2020 18:18:35 +0800 Subject: [PATCH 29/30] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=AD=BE?= =?UTF-8?q?=E5=88=B0=E5=8F=AA=E6=98=BE=E7=A4=BA=E6=9C=80=E8=BF=91=E5=8D=81?= =?UTF-8?q?=E6=AC=A1=E7=AD=BE=E5=88=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weapps/attendances_controller.rb | 10 ++++++-- .../weapps/attendances/index.json.jbuilder | 23 ++++--------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/app/controllers/weapps/attendances_controller.rb b/app/controllers/weapps/attendances_controller.rb index 2ec4180a1..da22aa300 100644 --- a/app/controllers/weapps/attendances_controller.rb +++ b/app/controllers/weapps/attendances_controller.rb @@ -37,8 +37,14 @@ class Weapps::AttendancesController < ApplicationController @all_member_attendances = @all_member_attendances.joins(:course_member).where(course_members: {course_group_id: params[:group_id]}) end - @history_attendances = all_attendances.order("id asc") - @all_history_count = @history_attendances.size + all_attendances = all_attendances.order("attendance_date desc, start_time desc") + + data = AttendanceStatisticsService.call all_attendances, @all_member_attendances + @all_history_count = data[:all_history_count] + @history_attendances = data[:history_attendances] + @avg_normal_rate = data[:avg_normal_rate] + @avg_absence_rate = data[:avg_absence_rate] + @avg_leave_rate = data[:avg_leave_rate] end def student_attendances diff --git a/app/views/weapps/attendances/index.json.jbuilder b/app/views/weapps/attendances/index.json.jbuilder index da8be3c8d..4326880ef 100644 --- a/app/views/weapps/attendances/index.json.jbuilder +++ b/app/views/weapps/attendances/index.json.jbuilder @@ -5,25 +5,12 @@ json.current_attendance @current_attendance do |attendance| json.end_time attendance.end_time.strftime("%H:%M") end -all_normal_rate = [] -all_absence_rate = [] -all_leave_rate = [] json.history_attendances @history_attendances.each_with_index.to_a do |attendance, index| - normal_count = history_member_count(@all_member_attendances, "NORMAL", attendance.id) - absence_count = history_member_count(@all_member_attendances, "ABSENCE", attendance.id) - leave_count = history_member_count(@all_member_attendances, "LEAVE", attendance.id) - all_count = @all_member_attendances.select{|member_attendance| member_attendance.course_attendance_id == attendance.id}.size - - json.index index + 1 - json.normal_rate cal_rate(normal_count, all_count) - all_normal_rate << cal_rate(normal_count, all_count) - json.absence_rate cal_rate(absence_count, all_count) - all_absence_rate << cal_rate(absence_count, all_count) - json.leave_rate cal_rate(leave_count, all_count) - all_leave_rate << cal_rate(leave_count, all_count) + json.(attendance, :name, :attendance_date, :start_time, :end_time, :normal_rate, :absence_rate, :leave_rate) + json.index "签到#{index + 1}" end json.all_history_count @all_history_count -json.avg_normal_rate @all_history_count == 0 ? 0 : all_normal_rate.sum / @all_history_count -json.avg_absence_rate @all_history_count == 0 ? 0 : all_absence_rate.sum / @all_history_count -json.avg_leave_rate @all_history_count == 0 ? 0 : all_leave_rate.sum / @all_history_count +json.avg_normal_rate @avg_normal_rate +json.avg_absence_rate @avg_absence_rate +json.avg_leave_rate @avg_leave_rate From 930d622760084cbab2f9f772a59dfa89b4f7b21a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Mar 2020 18:22:05 +0800 Subject: [PATCH 30/30] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/weapps/attendances/index.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/weapps/attendances/index.json.jbuilder b/app/views/weapps/attendances/index.json.jbuilder index 4326880ef..0770bb6f6 100644 --- a/app/views/weapps/attendances/index.json.jbuilder +++ b/app/views/weapps/attendances/index.json.jbuilder @@ -7,7 +7,7 @@ end json.history_attendances @history_attendances.each_with_index.to_a do |attendance, index| json.(attendance, :name, :attendance_date, :start_time, :end_time, :normal_rate, :absence_rate, :leave_rate) - json.index "签到#{index + 1}" + json.index index + 1 end json.all_history_count @all_history_count