From 564b0bdd953b4593137c9cc868e73bd45ac09bd6 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Thu, 10 Oct 2019 10:27:58 +0800 Subject: [PATCH 01/15] ecs: modify add course manager api --- .../ecs/course_managers_controller.rb | 3 ++- .../ecs/create_course_manager_service.rb | 26 ++++++++++--------- .../ecs/course_managers/create.json.jbuilder | 1 - 3 files changed, 16 insertions(+), 14 deletions(-) delete mode 100644 app/views/ecs/course_managers/create.json.jbuilder diff --git a/app/controllers/ecs/course_managers_controller.rb b/app/controllers/ecs/course_managers_controller.rb index 714dac580..132a212d7 100644 --- a/app/controllers/ecs/course_managers_controller.rb +++ b/app/controllers/ecs/course_managers_controller.rb @@ -3,7 +3,8 @@ class Ecs::CourseManagersController < Ecs::CourseBaseController before_action :check_major_manager_permission!, only: [:create, :destroy] def create - @user = Ecs::CreateCourseManagerService.call(current_course, params[:user_id]) + Ecs::CreateCourseManagerService.call(current_course, params[:user_ids]) + render_ok rescue Ecs::CreateCourseManagerService::Error => ex render_error(ex.message) end diff --git a/app/services/ecs/create_course_manager_service.rb b/app/services/ecs/create_course_manager_service.rb index 58e803bcf..162a0da55 100644 --- a/app/services/ecs/create_course_manager_service.rb +++ b/app/services/ecs/create_course_manager_service.rb @@ -3,27 +3,29 @@ class Ecs::CreateCourseManagerService < ApplicationService COURSE_MANAGER_COUNT_LIMIT = 2 # 课程管理员数量限制 - attr_reader :ec_course, :user_id + attr_reader :ec_course, :user_ids - def initialize(ec_course, user_id) + def initialize(ec_course, user_ids) @ec_course = ec_course - @user_id = user_id + @user_ids = user_ids end def call - user = User.find_by(id: params[:user_id]) - raise Error, '该用户不存在' if user.blank? + users_count = User.where(id: user_ids).count + raise Error, '用户不存在' if users_count != user_ids.size - if ec_course.ec_course_users.exists?(user_id: user.id) - raise Error, '该用户已经是该课程的管理员了' + if ec_course.ec_course_users.exists?(user_id: user_ids) + raise Error, '用户已经是该课程的管理员' end - if ec_course.ec_course_users.count >= COURSE_MANAGER_COUNT_LIMIT - raise Error, '该课程管理员数量已达上限' + if ec_course.ec_course_users.count + user_ids.size >= COURSE_MANAGER_COUNT_LIMIT + raise Error, "课程管理员数量过多(最多#{COURSE_MANAGER_COUNT_LIMIT})" end - ec_course.ec_course_users.create!(user: user) - - user + ActiveRecord::Base.transaction do + user_ids.each do |user_id| + ec_course.ec_course_users.create!(user_id: user_id) + end + end end end \ No newline at end of file diff --git a/app/views/ecs/course_managers/create.json.jbuilder b/app/views/ecs/course_managers/create.json.jbuilder deleted file mode 100644 index ff7ff01e5..000000000 --- a/app/views/ecs/course_managers/create.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.partial! 'ecs/shared/user', user: @user From 707d3c08ed126a3a294db1aea4e0da48770c1ed0 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Thu, 10 Oct 2019 10:38:44 +0800 Subject: [PATCH 02/15] ecs: fix api --- app/services/ecs/create_course_manager_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/ecs/create_course_manager_service.rb b/app/services/ecs/create_course_manager_service.rb index 162a0da55..4d3633bfd 100644 --- a/app/services/ecs/create_course_manager_service.rb +++ b/app/services/ecs/create_course_manager_service.rb @@ -18,7 +18,7 @@ class Ecs::CreateCourseManagerService < ApplicationService raise Error, '用户已经是该课程的管理员' end - if ec_course.ec_course_users.count + user_ids.size >= COURSE_MANAGER_COUNT_LIMIT + if ec_course.ec_course_users.count + user_ids.size > COURSE_MANAGER_COUNT_LIMIT raise Error, "课程管理员数量过多(最多#{COURSE_MANAGER_COUNT_LIMIT})" end From acd913a588a5b60e1c6f70fca93ede519170b697 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Thu, 10 Oct 2019 10:59:16 +0800 Subject: [PATCH 03/15] add template show api --- app/controllers/templates_controller.rb | 5 +++++ app/views/templates/show.json.jbuilder | 3 +++ config/routes.rb | 1 + 3 files changed, 9 insertions(+) create mode 100644 app/controllers/templates_controller.rb create mode 100644 app/views/templates/show.json.jbuilder diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb new file mode 100644 index 000000000..efb114bdc --- /dev/null +++ b/app/controllers/templates_controller.rb @@ -0,0 +1,5 @@ +class TemplatesController < ApplicationController + def show + @template = EcTemplate.find_by_name!(params[:name]) + end +end \ No newline at end of file diff --git a/app/views/templates/show.json.jbuilder b/app/views/templates/show.json.jbuilder new file mode 100644 index 000000000..cff89037b --- /dev/null +++ b/app/views/templates/show.json.jbuilder @@ -0,0 +1,3 @@ +json.template do + json.partial! 'attachments/attachment_simple', attachment: @template.attachments.last +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 2c02c6a79..847afaa83 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -818,6 +818,7 @@ Rails.application.routes.draw do post :feedback end end + resource :template, only: [:show] end namespace :admins do From 92218bb829c12da5456247c6a99a95432c8f3ac0 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, 10 Oct 2019 14:31:50 +0800 Subject: [PATCH 04/15] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=BE=97=E5=88=86?= =?UTF-8?q?=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/busyWork/CommonWorkDetailIndex.js | 6 +-- .../busyWork/common/WorkDetailPageHeader.js | 6 +-- .../shixunHomework/Listofworksstudentone.js | 40 ++++++++++--------- .../shixunHomework/ShixunHomeworkPage.js | 4 +- .../shixunHomework/Trainingjobsetting.js | 7 +++- 5 files changed, 32 insertions(+), 31 deletions(-) diff --git a/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js b/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js index 8985aa07e..e49d4fb28 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js @@ -308,15 +308,11 @@ class CommonWorkDetailIndex extends Component{ onClick={() => this.setState({moduleName: '参考答案'})} className={`${childModuleName == '参考答案' ? 'active' : '' } `} to={`/courses/${courseId}/${moduleEngName}/${workId}/answer`}>参考答案} - - {this.props.isAdmin() ? this.setState({moduleName: '设置'})} className={`${childModuleName == '设置' ? 'active' : '' } `} style={{paddingLeft:'38px'}} - to={`/courses/${courseId}/${moduleEngName}/${workId}/setting`}>设置: - "" - } + to={`/courses/${courseId}/${moduleEngName}/${workId}/setting`}>{this.props.isAdmin()?"设置":"得分规则"} {/* { this.props.tabRightComponents } */} diff --git a/public/react/src/modules/courses/busyWork/common/WorkDetailPageHeader.js b/public/react/src/modules/courses/busyWork/common/WorkDetailPageHeader.js index 68a16d89e..89c9df772 100644 --- a/public/react/src/modules/courses/busyWork/common/WorkDetailPageHeader.js +++ b/public/react/src/modules/courses/busyWork/common/WorkDetailPageHeader.js @@ -144,13 +144,11 @@ class WorkDetailPageHeader extends Component{ {view_answer == true && 参考答案} - {this.props.isAdmin()? + 设置: - "" - } + to={`/courses/${courseId}/${moduleEngName}/${workId}/setting`}>{this.props.isAdmin()?"设置":"得分规则"} { this.props.tabRightComponents } diff --git a/public/react/src/modules/courses/shixunHomework/Listofworksstudentone.js b/public/react/src/modules/courses/shixunHomework/Listofworksstudentone.js index 2380df531..73070497b 100644 --- a/public/react/src/modules/courses/shixunHomework/Listofworksstudentone.js +++ b/public/react/src/modules/courses/shixunHomework/Listofworksstudentone.js @@ -1535,6 +1535,7 @@ class Listofworksstudentone extends Component { // console.log("获取作品列表"); // console.log("935"); // debugger + let searchtype=this.props.history.location.search; let urll = `/homework_commons/${homeworkid}/works_list.json`; var datasysl = { search: this.state.searchtext, @@ -1587,13 +1588,14 @@ class Listofworksstudentone extends Component { if(this.props.isAdmin() === true){ if(result.data.update_score===true){ if(bool===true){ - + if(searchtype==="?tab=0"){ try { this.props.yslslowCheckresults(); }catch (e) { } - this.setComputeTimet(); + this.setComputeTimet(); + } } } } @@ -3242,21 +3244,25 @@ class Listofworksstudentone extends Component { {/*作品状态GraduationTaskssettinglist*/}