From 674ca582da6d5942c3379f732572e373ab9aefa9 Mon Sep 17 00:00:00 2001 From: anke1460 Date: Wed, 26 Feb 2020 14:40:42 +0800 Subject: [PATCH 1/9] =?UTF-8?q?sso=E7=BB=91=E5=AE=9A=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E6=97=B6=E5=8E=BB=E6=8E=89=E6=98=B5=E7=A7=B0=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/oauth/create_or_find_cas_user_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/oauth/create_or_find_cas_user_service.rb b/app/services/oauth/create_or_find_cas_user_service.rb index 0b6715471..761f9da58 100644 --- a/app/services/oauth/create_or_find_cas_user_service.rb +++ b/app/services/oauth/create_or_find_cas_user_service.rb @@ -14,7 +14,7 @@ class Oauth::CreateORFindCasUserService < ApplicationService return [open_user.user, false] if open_user.persisted? - @user = User.new(login: User.generate_login('C'), type: 'User', status: User::STATUS_ACTIVE, nickname: @params['comsys_name'], lastname: @params['comsys_name']) + @user = User.new(login: User.generate_login('C'), type: 'User', status: User::STATUS_ACTIVE, lastname: @params['comsys_name']) ActiveRecord::Base.transaction do @user.save! From 8f994b9f5e30141eddb348a4b28ad83e10dc171c 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, 26 Feb 2020 18:39:58 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E7=BF=BB=E8=BD=AC=E8=AF=BE=E5=A0=82-?= =?UTF-8?q?=E3=80=8B=E6=95=99=E5=AD=A6=E8=AF=BE=E5=A0=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/common/util/ShareUtil.js | 16 ++++++------- .../Competition_teams/Competitionteams.js | 2 +- .../Competition_teams/Competitionteams.js | 2 +- .../courses/coursesHome/CoursesHome.js | 4 ++-- .../src/modules/courses/new/CoursesNew.js | 2 +- .../src/modules/courses/new/Goldsubject.js | 2 +- public/react/src/modules/tpm/NewHeader.js | 10 ++++---- public/react/src/modules/tpm/TPMIndexHOC.js | 2 +- .../src/modules/user/usersInfo/InfosBanner.js | 24 +++++++++---------- public/react/src/search/SearchPage.js | 2 +- 10 files changed, 33 insertions(+), 33 deletions(-) diff --git a/public/react/src/common/util/ShareUtil.js b/public/react/src/common/util/ShareUtil.js index bd34e2edb..a85c37c4a 100644 --- a/public/react/src/common/util/ShareUtil.js +++ b/public/react/src/common/util/ShareUtil.js @@ -60,17 +60,17 @@ function requestForSignatrue (callback) { /** 实践课程 平台提供涵盖基础入门、案例实践和创新应用的完整实训项目体系,通过由浅入深的实训路径,帮助学生快速提升实战能力。 实训项目 覆盖不同专业的IT实验和实训,每周更新,无需配置本机实验环境,随时随地开启企业级真实实训。 - 翻转课堂 自动评测实训任务,支持技能统计,提供教学活动分析报告,减轻教师和助教的辅导压力,免去作业发布和批改的困扰,实时了解学生学习情况,全面提升教师施教效率和水平。 + 教学课堂 自动评测实训任务,支持技能统计,提供教学活动分析报告,减轻教师和助教的辅导压力,免去作业发布和批改的困扰,实时了解学生学习情况,全面提升教师施教效率和水平。 单个课程和实训 获取课程/实训的简介 该课程或者实训展示的缩略图 */ -export function configShareForIndex (path) { +export function configShareForIndex (path) { requestForSignatrue(() => { var shareData = { title: 'EduCoder - 首页', desc: 'Educoder是一个面向计算机类的互联网IT教育和实战平台,提供企业级工程实训,以实现工程化专业教学的自动化和智能化。高校和企业人员可以在此开展计算机实践性教学活动,将传统的知识传授和时兴的工程实战一体化。', link: host + (path || ''), - imgUrl: window.__testImageUrl + imgUrl: window.__testImageUrl || host + '/react/build/images/share_logo_icon.jpg' }; share(shareData) @@ -83,7 +83,7 @@ export function configShareForPaths () { title: 'EduCoder - 实践课程', desc: '平台提供涵盖基础入门、案例实践和创新应用的完整实训项目体系,通过由浅入深的实训路径,帮助学生快速提升实战能力。', link: `${host}/paths`, - imgUrl: window.__testImageUrl + imgUrl: window.__testImageUrl || host + '/react/build/images/share_logo_icon.jpg' }; share(shareData) @@ -97,7 +97,7 @@ export function configShareForShixuns () { title: 'EduCoder - 实训项目', desc: '覆盖不同专业的IT实验和实训,每周更新,无需配置本机实验环境,随时随地开启企业级真实实训。', link: `${host}/shixuns`, - imgUrl: window.__testImageUrl + imgUrl: window.__testImageUrl || host + '/react/build/images/share_logo_icon.jpg' }; share(shareData) @@ -108,10 +108,10 @@ export function configShareForCourses () { console.log('configShareForCourses', host) var shareData = { - title: 'EduCoder - 翻转课堂', + title: 'EduCoder - 教学课堂', desc: '自动评测实训任务,支持技能统计,提供教学活动分析报告,减轻教师和助教的辅导压力,免去作业发布和批改的困扰,实时了解学生学习情况,全面提升教师施教效率和水平。', link: `${host}/courses`, - imgUrl: window.__testImageUrl + imgUrl: window.__testImageUrl || host + '/react/build/images/share_logo_icon.jpg' }; share(shareData) @@ -127,7 +127,7 @@ export function configShareForCustom (title, desc, imgUrl, path) { title: title, desc: desc, link: path ? `${host}/${path}` : _url, - imgUrl: imgUrl || window.__testImageUrl + imgUrl: imgUrl || window.__testImageUrl || host + '/react/build/images/share_logo_icon.jpg' }; share(shareData) diff --git a/public/react/src/modules/competitions/Competition_teams/Competitionteams.js b/public/react/src/modules/competitions/Competition_teams/Competitionteams.js index be6c2e68d..ef9cf58ce 100644 --- a/public/react/src/modules/competitions/Competition_teams/Competitionteams.js +++ b/public/react/src/modules/competitions/Competition_teams/Competitionteams.js @@ -250,7 +250,7 @@ class Competitionteams extends Component{ - 翻转课堂 + 教学课堂
diff --git a/public/react/src/modules/courses/competitions/Competition_teams/Competitionteams.js b/public/react/src/modules/courses/competitions/Competition_teams/Competitionteams.js index be6c2e68d..ef9cf58ce 100644 --- a/public/react/src/modules/courses/competitions/Competition_teams/Competitionteams.js +++ b/public/react/src/modules/courses/competitions/Competition_teams/Competitionteams.js @@ -250,7 +250,7 @@ class Competitionteams extends Component{
- 翻转课堂 + 教学课堂
diff --git a/public/react/src/modules/courses/coursesHome/CoursesHome.js b/public/react/src/modules/courses/coursesHome/CoursesHome.js index f6b6d7303..21f7b33bc 100644 --- a/public/react/src/modules/courses/coursesHome/CoursesHome.js +++ b/public/react/src/modules/courses/coursesHome/CoursesHome.js @@ -55,7 +55,7 @@ class CoursesHome extends Component{ } componentDidMount(){ - document.title="翻转课堂"; + document.title="教学课堂"; const upsystem=`/users/system_update.json`; axios.get(upsystem).then((response)=>{ let updata=response.data; @@ -159,7 +159,7 @@ class CoursesHome extends Component{ onClick={ () => this.changeStatus("created_at")}>最新 this.changeStatus("visits")}>最热 - {this.props.user&&this.props.user.user_identity==="学生"?"":this.getUser("/courses/new")}>+新建翻转课堂} + {this.props.user&&this.props.user.user_identity==="学生"?"":this.getUser("/courses/new")}>+新建教学课堂} {/*
*/} {/*/!* - {this.props.match.params.coursesId === undefined ?"翻转课堂":dataname} + {this.props.match.params.coursesId === undefined ?"教学课堂":dataname} > {this.props.match.params.coursesId === undefined ?"新建课堂":"编辑课堂"} diff --git a/public/react/src/modules/courses/new/Goldsubject.js b/public/react/src/modules/courses/new/Goldsubject.js index 006f3f44f..23e098f80 100644 --- a/public/react/src/modules/courses/new/Goldsubject.js +++ b/public/react/src/modules/courses/new/Goldsubject.js @@ -721,7 +721,7 @@ class Goldsubject extends Component { {/**/}

{Whethertocreateanewclassroom===true?"翻转课堂":name} + >{Whethertocreateanewclassroom===true?"教学课堂":name} > {Whethertocreateanewclassroom===true?"新建课堂":"编辑课堂"}

diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js index b341e2d52..17bd92001 100644 --- a/public/react/src/modules/tpm/NewHeader.js +++ b/public/react/src/modules/tpm/NewHeader.js @@ -1097,7 +1097,7 @@ submittojoinclass=(value)=>{ {/*
  • 课堂
  • */}
  • {/*课堂*/} - 翻转课堂 + 教学课堂
  • 实训项目 @@ -1183,7 +1183,7 @@ submittojoinclass=(value)=>{ onBlur={(e)=>this.hideshowSearchOpen(e)} onMouseLeave={()=>this.setevaluatinghides()}> this.onKeywordSearchKeyDowns()} onSearch={(value) => this.onKeywordSearchKeyDown(value)} // onPressEnter={this.onKeywordSearchKeyDown} @@ -1230,7 +1230,7 @@ submittojoinclass=(value)=>{
  • +
    {is_current ? "我":"TA"}的金币 {data && data.grade} -
    + { - is_current ? + is_current ? { - data && data.attendance_signed ? + data && data.attendance_signed ? 已签到 : 签到 } - + : - 私信 @@ -120,7 +120,7 @@ class InfosBanner extends Component{ {coursestypes===true?"":
  • this.setState({moduleName: 'courses'})} - to={`/users/${username}/courses`}>翻转课堂 + to={`/users/${username}/courses`}>教学课堂
  • } {shixuntype===true?"":
  • 实训项目
  • } {pathstype===true?"":
  • - this.setState({moduleName: 'paths'})} to={`/users/${username}/paths`}>实践课程
  • } diff --git a/public/react/src/search/SearchPage.js b/public/react/src/search/SearchPage.js index e25829554..fc50bcbfa 100644 --- a/public/react/src/search/SearchPage.js +++ b/public/react/src/search/SearchPage.js @@ -158,7 +158,7 @@ class SearchPage extends Component{
    实践课程 - 翻转课堂 + 教学课堂 实训项目 交流问答 From 48a9dafe99affb1e751ab0bb06a9204ca617f67a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 26 Feb 2020 19:32:01 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E6=9D=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/weapps/courses_controller.rb | 1 + app/views/weapps/courses/course_activities.json.jbuilder | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/weapps/courses_controller.rb b/app/controllers/weapps/courses_controller.rb index ccd5d1bcf..a0ee59971 100644 --- a/app/controllers/weapps/courses_controller.rb +++ b/app/controllers/weapps/courses_controller.rb @@ -20,6 +20,7 @@ class Weapps::CoursesController < Weapps::BaseController activities = @course.course_activities.where("course_act_type in ('Course', 'CourseMessage') or (course_act_type = 'HomeworkCommon' and course_act_id in #{homework_ids})").order("id desc") + @activities_count = activities.size @activities = paginate activities.includes(:course_act, user: :user_extension) end diff --git a/app/views/weapps/courses/course_activities.json.jbuilder b/app/views/weapps/courses/course_activities.json.jbuilder index 498189cf8..edef01e1d 100644 --- a/app/views/weapps/courses/course_activities.json.jbuilder +++ b/app/views/weapps/courses/course_activities.json.jbuilder @@ -9,4 +9,5 @@ json.activities @activities do |activity| json.created_at activity.created_at.strftime('%m-%d %H:%M:') json.container_name activity.container_name json.container_type activity.course_act_type == "HomeworkCommon" ? activity.course_act&.homework_type : "" -end \ No newline at end of file +end +json.activities_count @activities_count \ No newline at end of file From e57b047eecdd6f3cfbc4945be13a0cb29891b34e Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 26 Feb 2020 19:33:09 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E5=8A=A8=E6=80=81?= =?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/views/weapps/courses/course_activities.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/weapps/courses/course_activities.json.jbuilder b/app/views/weapps/courses/course_activities.json.jbuilder index edef01e1d..2b1059ce1 100644 --- a/app/views/weapps/courses/course_activities.json.jbuilder +++ b/app/views/weapps/courses/course_activities.json.jbuilder @@ -6,7 +6,7 @@ json.activities @activities do |activity| json.login user.login json.img url_to_avatar(user) end - json.created_at activity.created_at.strftime('%m-%d %H:%M:') + json.created_at activity.created_at.strftime('%m-%d %H:%M') json.container_name activity.container_name json.container_type activity.course_act_type == "HomeworkCommon" ? activity.course_act&.homework_type : "" end From 8047b17ee17855bc30b3d073af6ba078e8cc74e9 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 26 Feb 2020 20:28:16 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=AF=BE=E5=A0=82?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 4 +--- app/jobs/delete_course_notify_job.rb | 13 +++++++++++++ spec/jobs/delete_course_notify_job_spec.rb | 5 +++++ 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 app/jobs/delete_course_notify_job.rb create mode 100644 spec/jobs/delete_course_notify_job_spec.rb diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index d0a2e5e4b..fd2d25dd5 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -395,9 +395,7 @@ class CoursesController < ApplicationController def destroy if @course.is_delete == 0 @course.delete! - Tiding.where(belong_container: @course).update_all(is_delete: 1) - Tiding.create!(user_id: current_user.id, trigger_user_id: current_user.id, container_id: @course.id, - container_type: 'DeleteCourse', tiding_type: 'System', belong_container: @course, extra: @course.name) + DeleteCourseNotifyJob.perform_later(@course.id, current_user.id) normal_status(0, "成功") else normal_status(-1, "课堂已删除,无需重复操作") diff --git a/app/jobs/delete_course_notify_job.rb b/app/jobs/delete_course_notify_job.rb new file mode 100644 index 000000000..4e3c21311 --- /dev/null +++ b/app/jobs/delete_course_notify_job.rb @@ -0,0 +1,13 @@ +# 删除课堂时将相应的课堂消息置为删除状态,并给老师发送删除消息 +class DeleteCourseNotifyJob < ApplicationJob + queue_as :default + + def perform(course_id, user_id) + course = Course.find_by(id: course_id) + return if course.blank? + + Tiding.where(belong_container: course).update_all(is_delete: 1) + Tiding.create!(user_id: user_id, trigger_user_id: user_id, container_id: course.id, + container_type: 'DeleteCourse', tiding_type: 'System', belong_container: course, extra: course.name) + end +end diff --git a/spec/jobs/delete_course_notify_job_spec.rb b/spec/jobs/delete_course_notify_job_spec.rb new file mode 100644 index 000000000..9fdf97f32 --- /dev/null +++ b/spec/jobs/delete_course_notify_job_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe DeleteCourseNotifyJob, type: :job do + pending "add some examples to (or delete) #{__FILE__}" +end From b1eac79e832a1101028d5f09631fc840aa5d7897 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, 27 Feb 2020 09:59:58 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/tpm/TPMsettings/Shixuninformation.js | 6 +++--- public/react/src/modules/tpm/newshixuns/Newshixuns.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js b/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js index 6697ee47c..f98baaa09 100644 --- a/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js +++ b/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js @@ -953,9 +953,9 @@ class Shixuninformation extends Component {
    {this.state.mainvalues === undefined && this.state.subvalues === undefined || this.state.mainvalues === "" && this.state.subvalues === "" ? "" :
    - {`${this.state.mainvalues === undefined || this.state.mainvalues === "" ? "" : this.state.mainvalues}`} - {`${this.state.subvalues === undefined || this.state.subvalues === "" ? "" : this.state.mainvalues === undefined || this.state.mainvalues === "" ? this.state.subvalues : this.state.subvalues}`} - {`${this.state.mainvalues === undefined || this.state.mainvalues === "" ? "" : this.state.mainvalues}${this.state.subvalues === undefined || this.state.subvalues === "" ? "" : + {`${this.state.mainvalues === undefined || this.state.mainvalues === "" ? "" : this.state.mainvalues}`} + {`${this.state.subvalues === undefined || this.state.subvalues === "" ? "" : this.state.mainvalues === undefined || this.state.mainvalues === "" ? this.state.subvalues : this.state.subvalues}`} + {`${this.state.mainvalues === undefined || this.state.mainvalues === "" ? "" : ""}${this.state.subvalues === undefined || this.state.subvalues === "" ? "" : this.state.mainvalues === undefined || this.state.mainvalues === "" ? this.state.subvalues : this.state.subvalues}`}
    }
    diff --git a/public/react/src/modules/tpm/newshixuns/Newshixuns.js b/public/react/src/modules/tpm/newshixuns/Newshixuns.js index 361ed3248..d017fe2aa 100644 --- a/public/react/src/modules/tpm/newshixuns/Newshixuns.js +++ b/public/react/src/modules/tpm/newshixuns/Newshixuns.js @@ -620,9 +620,9 @@ class Newshixuns extends Component {
    {this.state.mainvalues === undefined && this.state.subvalues === undefined || this.state.mainvalues === "" && this.state.subvalues === "" ? "" :
    - {`${this.state.mainvalues === undefined || this.state.mainvalues === "" ? "" : this.state.mainvalues}`} + {`${this.state.mainvalues === undefined || this.state.mainvalues === "" ? "" : this.state.mainvalues}`} {`${this.state.subvalues === undefined || this.state.subvalues === "" ? "" : this.state.mainvalues === undefined || this.state.mainvalues === "" ? this.state.subvalues : this.state.subvalues}`} - {`${this.state.mainvalues === undefined || this.state.mainvalues === "" ? "" : this.state.mainvalues}${this.state.subvalues === undefined || this.state.subvalues === "" ? "" : + {`${this.state.mainvalues === undefined || this.state.mainvalues === "" ? "" : ""}${this.state.subvalues === undefined || this.state.subvalues === "" ? "" : this.state.mainvalues === undefined || this.state.mainvalues === "" ? this.state.subvalues : this.state.subvalues}`}
    } From ff983875e7cdaf19923171be2e87e5de297a29d7 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 27 Feb 2020 10:43:48 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_commons_controller.rb | 2 +- app/models/course.rb | 2 +- app/models/course_message.rb | 2 +- lib/tasks/homework_publishtime.rake | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 082c8118d..c5ad7a94c 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -984,7 +984,7 @@ class HomeworkCommonsController < ApplicationController homework.homework_detail_manual.update_attributes!(comment_status: 1) if homework.course_act.blank? - homework.course_act << CourseActivity.new(user_id: homework.user_id, course_id: homework.course_id) + CourseActivity.create!(user_id: homework.user_id, course_id: homework.course_id, course_act: homework) end # 发消息 HomeworkCommonPushNotifyJob.perform_later(homework.id, tiding_group_ids) diff --git a/app/models/course.rb b/app/models/course.rb index 08e2e36f5..4b997fcb8 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -302,7 +302,7 @@ class Course < ApplicationRecord #课程动态公共表记录 def act_as_course_activity - self.course_act << CourseActivity.new(user_id: tea_id, course_id: id) + CourseActivity.create(user_id: tea_id, course_id: id, course_act: self) end # 当前老师分班下的所有学生 diff --git a/app/models/course_message.rb b/app/models/course_message.rb index b09613ec4..1bbb7e454 100644 --- a/app/models/course_message.rb +++ b/app/models/course_message.rb @@ -30,7 +30,7 @@ class CourseMessage < ApplicationRecord #课程动态公共表记录 def act_as_course_activity - self.course_act << CourseActivity.new(user_id: course_message_id, course_id: course_id) + CourseActivity.create(user_id: course_message_id, course_id: course_id, course_act: self) end def send_deal_tiding deal_status diff --git a/lib/tasks/homework_publishtime.rake b/lib/tasks/homework_publishtime.rake index 180afcdc2..b0aae5e58 100644 --- a/lib/tasks/homework_publishtime.rake +++ b/lib/tasks/homework_publishtime.rake @@ -45,7 +45,7 @@ namespace :homework_publishtime do end end - homework.course_act << CourseActivity.new(user_id: homework.user_id, course_id: homework.course_id) if !homework.course_act.present? + CourseActivity.create(user_id: homework.user_id, course_id: homework.course_id, course_act: homework) if !homework.course_act.present? end # 分组设置发布时间的作业 From c4c2927f87d2e255fc1d6880d7265c009673cf44 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 27 Feb 2020 11:41:58 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E5=88=B0=E7=9B=AE=E5=BD=95=E7=9A=84=E6=8E=A5?= =?UTF-8?q?=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/controllers/homework_commons_controller.rb | 2 +- app/models/course_second_category.rb | 9 +++++++++ .../homework_commons/_second_category.json.jbuilder | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index c5ad7a94c..3ed71746d 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -1117,7 +1117,7 @@ class HomeworkCommonsController < ApplicationController def choose_category @main_catrgory = @course.course_modules.where(module_type: "shixun_homework") - @homework_category = @main_catrgory.take.course_second_categories + @homework_category = @main_catrgory.take.course_second_categories.includes(:homework_commons) end # 实训作业移动到目录 diff --git a/app/models/course_second_category.rb b/app/models/course_second_category.rb index 963367e0b..84b47e27f 100644 --- a/app/models/course_second_category.rb +++ b/app/models/course_second_category.rb @@ -12,4 +12,13 @@ class CourseSecondCategory < ApplicationRecord category_type == "graduation" && name == "毕设任务" ? "graduation_tasks" : category_type ) end + + def homework_publish_count + homework_commons.select{|homework| homework.publish_time.present? && homework.publish_time <= Time.now}.size + end + + def homework_unpublish_count + homework_commons.select{|homework| homework.publish_time.nil? || homework.publish_time > Time.now}.size + end + end diff --git a/app/views/homework_commons/_second_category.json.jbuilder b/app/views/homework_commons/_second_category.json.jbuilder index b584abecc..c6dfa76a0 100644 --- a/app/views/homework_commons/_second_category.json.jbuilder +++ b/app/views/homework_commons/_second_category.json.jbuilder @@ -5,4 +5,7 @@ end json.homework_category homework_category do |category| json.category_id category.id json.category_name category.name + json.publish_count category.homework_publish_count + json.unpublish_count category.homework_unpublish_count + json.all_count category.homework_commons.size end \ No newline at end of file From b4d53a6ee7d6f4106b2341cd2573bc69f2c6c7fc Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 27 Feb 2020 15:00:59 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=9B=AE=E5=BD=95?= =?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/helpers/courses_helper.rb | 8 ++++++++ app/views/homework_commons/_second_category.json.jbuilder | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index f0d58adbb..0e79f11de 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -42,6 +42,14 @@ module CoursesHelper end end + def practice_homework_count course + homeworks = course.homework_commons.practices + publish_count = homeworks.select{|homework| homework.publish_time.present? && homework.publish_time <= Time.now}.size + unpublish_count = homeworks.select{|homework| homework.publish_time.nil? || homework.publish_time > Time.now}.size + all_count = homeworks.size + {publish_count: publish_count, unpublish_count: unpublish_count, all_count: all_count} + end + # 课堂模块的url def module_url mod, course return nil if mod.blank? or course.blank? diff --git a/app/views/homework_commons/_second_category.json.jbuilder b/app/views/homework_commons/_second_category.json.jbuilder index c6dfa76a0..04890e70c 100644 --- a/app/views/homework_commons/_second_category.json.jbuilder +++ b/app/views/homework_commons/_second_category.json.jbuilder @@ -1,6 +1,10 @@ json.main_category main_catrgory do |category| json.main_category_id 0 json.main_category_name category.module_name + homework_count = practice_homework_count category.course + json.publish_count homework_count[:publish_count] + json.unpublish_count homework_count[:unpublish_count] + json.all_count homework_count[:all_count] end json.homework_category homework_category do |category| json.category_id category.id