From a64d6ef50214f8e29a3130edeba1dd84e7a504cd Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 11 Oct 2019 15:23:25 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E9=A2=98=E5=BA=93=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/question_banks_controller.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/question_banks_controller.rb b/app/controllers/question_banks_controller.rb index 60b9a807c..7781b5792 100644 --- a/app/controllers/question_banks_controller.rb +++ b/app/controllers/question_banks_controller.rb @@ -90,23 +90,25 @@ class QuestionBanksController < ApplicationController def send_to_course banks = @object_type.classify.constantize.where(id: params[:object_id]) course = current_user.manage_courses.find_by!(id: params[:course_id]) + task_ids = [] banks.each do |bank| case @object_type when 'HomeworkBank' # 作业 - quote_homework_bank bank, course + task = quote_homework_bank bank, course when 'ExerciseBank' if bank.container_type == 'Exercise' # 试卷 - quote_exercise_bank bank, course + task = quote_exercise_bank bank, course else # 问卷 - quote_poll_bank bank, course + task = quote_poll_bank bank, course end when 'GtaskBank' - quote_gtask_bank bank, course + task = quote_gtask_bank bank, course when 'GtopicBank' - quote_gtopic_bank bank, course + task = quote_gtopic_bank bank, course end + task_ids << task.id if task end - normal_status("发送成功") + render :json => {task_ids: task_ids, status: 0, message: "发送成功"} end def destroy From cce35c89ff26dbaad9a0e055d3bc7d70987bec84 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 11 Oct 2019 15:31:39 +0800 Subject: [PATCH 02/12] tiaoz --- app/controllers/courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index a3b20c598..bab8a4189 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -552,7 +552,7 @@ class CoursesController < ApplicationController def change_member_role tip_exception("请至少选择一个角色") if params[:roles].blank? tip_exception("不能具有老师、助教两种角色") if params[:roles].include?("PROFESSOR") && params[:roles].include?("ASSISTANT_PROFESSOR") - tip_exception("管理员不能切换为助教或老师") if @user_course_identity == Course::CREATOR && + tip_exception("管理员不能切换为助教或老师") if current_user.id == @course.tea_id && (params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR")) course_members = @course.course_members.where(user_id: params[:user_id]) From 450e9675348a085b852311cf25cce9b7b3bf4532 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 11 Oct 2019 15:32:09 +0800 Subject: [PATCH 03/12] tiaoz --- app/controllers/courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index bab8a4189..0c643d15c 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -552,7 +552,7 @@ class CoursesController < ApplicationController def change_member_role tip_exception("请至少选择一个角色") if params[:roles].blank? tip_exception("不能具有老师、助教两种角色") if params[:roles].include?("PROFESSOR") && params[:roles].include?("ASSISTANT_PROFESSOR") - tip_exception("管理员不能切换为助教或老师") if current_user.id == @course.tea_id && + tip_exception("管理员不能切换为助教或老师") if params[:user_id].to_i == @course.tea_id && (params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR")) course_members = @course.course_members.where(user_id: params[:user_id]) From 2651dd7f2258c7f67590db9daec91ca68622dc58 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 11 Oct 2019 15:33:48 +0800 Subject: [PATCH 04/12] trigger('updatabanner') --- public/react/src/modules/courses/members/ChangeRolePop.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/react/src/modules/courses/members/ChangeRolePop.js b/public/react/src/modules/courses/members/ChangeRolePop.js index 44dfc28fc..896360a40 100644 --- a/public/react/src/modules/courses/members/ChangeRolePop.js +++ b/public/react/src/modules/courses/members/ChangeRolePop.js @@ -41,7 +41,9 @@ function ChangeRolePop({ member_roles = [], record, courseId, onChangeRoleSucces user_id: record.user_id }) if (response.data.status == 0) { + showNotification('保存成功') onChangeRoleSuccess() + trigger('updatabanner') } console.log(response) } From 8b65317d974fe1985218e752a5c86376d7a00ac8 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 11 Oct 2019 15:35:04 +0800 Subject: [PATCH 05/12] debug --- public/react/src/AppConfig.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index c00c5fb62..e1d5da561 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -84,9 +84,9 @@ export function initAxiosInterceptors(props) { } config.url = `${proxy}${url}`; if (config.url.indexOf('?') == -1) { - config.url = `${config.url}?debug=${'student'}`; + config.url = `${config.url}?debug=${debugType}`; } else { - config.url = `${config.url}&debug=${'student'}`; + config.url = `${config.url}&debug=${debugType}`; } } else { // 加api前缀 From b2f406aa2f75577b57cf717116235b9260609034 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 11 Oct 2019 16:14:19 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/courses/members/ChangeRolePop.js | 9 +++++++-- public/react/src/modules/courses/members/studentsList.js | 2 ++ public/react/src/modules/courses/members/teacherList.js | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/courses/members/ChangeRolePop.js b/public/react/src/modules/courses/members/ChangeRolePop.js index 896360a40..7f55910bf 100644 --- a/public/react/src/modules/courses/members/ChangeRolePop.js +++ b/public/react/src/modules/courses/members/ChangeRolePop.js @@ -6,7 +6,7 @@ import axios from 'axios' /** 角色数组, CREATOR: 创建者, PROFESSOR: 教师, ASSISTANT_PROFESSOR: 助教, STUDENT: 学生 */ -function ChangeRolePop({ member_roles = [], record, courseId, onChangeRoleSuccess, showNotification }) { +function ChangeRolePop({ member_roles = [], record, courseId, onChangeRoleSuccess, showNotification, getUserId, fetchUser }) { const [checkBoxRoles, setCheckBoxRoles] = useState(member_roles) useEffect(() => { setCheckBoxRoles(member_roles) @@ -43,7 +43,12 @@ function ChangeRolePop({ member_roles = [], record, courseId, onChangeRoleSucces if (response.data.status == 0) { showNotification('保存成功') onChangeRoleSuccess() - trigger('updatabanner') + + if (fetchUser && record.user_id == getUserId) { + fetchUser() + trigger('updatabanner') + } + } console.log(response) } diff --git a/public/react/src/modules/courses/members/studentsList.js b/public/react/src/modules/courses/members/studentsList.js index e3859345a..626a76baf 100644 --- a/public/react/src/modules/courses/members/studentsList.js +++ b/public/react/src/modules/courses/members/studentsList.js @@ -155,6 +155,8 @@ const buildColumns = (that,isParent) => { member_roles={record.member_roles} onChangeRoleSuccess={that.onChangeRoleSuccess} showNotification={that.props.showNotification} + getUserId={that.props.isUserid} + fetchUser={that.props.fetchUser} > ) diff --git a/public/react/src/modules/courses/members/teacherList.js b/public/react/src/modules/courses/members/teacherList.js index 72b667300..74271ea5a 100644 --- a/public/react/src/modules/courses/members/teacherList.js +++ b/public/react/src/modules/courses/members/teacherList.js @@ -165,6 +165,9 @@ function buildColumns(that) { member_roles={record.member_roles} onChangeRoleSuccess={that.onChangeRoleSuccess} showNotification={that.props.showNotification} + getUserId={that.props.isUserid} + fetchUser={that.props.fetchUser} + > {/* Date: Fri, 11 Oct 2019 16:16:21 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E7=AB=8B=E5=8D=B3=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=97=B6=E9=97=B4=E6=94=B9=E6=88=901?= =?UTF-8?q?=E5=91=A8=E4=B9=8B=E5=90=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/AppConfig.js | 4 ++-- .../react/src/modules/courses/coursesPublic/HomeworkModal.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index c00c5fb62..e1d5da561 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -84,9 +84,9 @@ export function initAxiosInterceptors(props) { } config.url = `${proxy}${url}`; if (config.url.indexOf('?') == -1) { - config.url = `${config.url}?debug=${'student'}`; + config.url = `${config.url}?debug=${debugType}`; } else { - config.url = `${config.url}&debug=${'student'}`; + config.url = `${config.url}&debug=${debugType}`; } } else { // 加api前缀 diff --git a/public/react/src/modules/courses/coursesPublic/HomeworkModal.js b/public/react/src/modules/courses/coursesPublic/HomeworkModal.js index 89e747004..a001e6d86 100644 --- a/public/react/src/modules/courses/coursesPublic/HomeworkModal.js +++ b/public/react/src/modules/courses/coursesPublic/HomeworkModal.js @@ -48,7 +48,7 @@ class HomeworkModal extends Component{ if(this.props.starttimes!=undefined&&this.props.starttimes!=""){ this.setState({ - endtime:moment(moment(handleDateString(this.props.starttimes)).add(1, 'months')).format("YYYY-MM-DD HH:mm") + endtime:moment(moment(handleDateString(this.props.starttimes)).add(1, 'week')).format("YYYY-MM-DD HH:mm") }) } } @@ -70,7 +70,7 @@ class HomeworkModal extends Component{ if(this.props.starttimes!=undefined&&this.props.starttimes!=""){ this.setState({ - endtime:moment(moment(handleDateString(this.props.starttimes)).add(1, 'months')).format("YYYY-MM-DD HH:mm") + endtime:moment(moment(handleDateString(this.props.starttimes)).add(1, 'week')).format("YYYY-MM-DD HH:mm") }) } } From eb673fcc4b0e606da0b8fc26a43612f9de477d5d Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 11 Oct 2019 16:25:36 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=88=86=E7=8F=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/courses/members/studentsList.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/public/react/src/modules/courses/members/studentsList.js b/public/react/src/modules/courses/members/studentsList.js index 626a76baf..5c56afbe0 100644 --- a/public/react/src/modules/courses/members/studentsList.js +++ b/public/react/src/modules/courses/members/studentsList.js @@ -547,6 +547,19 @@ class studentsList extends Component{ addDir = () => { trigger('groupAdd', this.props.coursesids) } + addToDir = async () => { + const courseId = this.props.match.params.coursesId + const url = `/courses/${courseId}/join_course_group.json` + const course_group_id = this.props.match.params.course_group_id + + const response = await axios.post(url, { + course_group_id + }) + if (response && response.data.status == 0) { + this.props.showNotification('加入成功') + this.fetchAll() + } + } renameDir = () => { const course_group_id = this.props.match.params.course_group_id trigger('groupRename', { id: parseInt(course_group_id), name: this.state.course_group_name}) @@ -593,6 +606,7 @@ class studentsList extends Component{ render(){ const isAdmin = this.props.isAdmin() + const isStudent = this.props.isStudent() const isSuperAdmin = this.props.isSuperAdmin() const isCourseEnd = this.props.isCourseEnd() let { @@ -704,6 +718,8 @@ class studentsList extends Component{ { // pageType !== TYPE_STUDENTS && !isCourseEnd && isAdmin && isParent && this.addDir()}>添加分班 } + { + isStudent && !isParent && course_group_id != 0 && this.addToDir()}>加入分班 } { isAdmin && !isParent && course_group_id != 0 && this.deleteDir()}>删除分班 } { From 038ff29699542cabdf4b6b9a2bc45119d32e4e86 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 11 Oct 2019 16:27:05 +0800 Subject: [PATCH 09/12] =?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/controllers/exercises_controller.rb | 2 +- app/controllers/homework_commons_controller.rb | 2 +- app/controllers/polls_controller.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index f9d9531f1..e25bec7f2 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -694,6 +694,7 @@ class ExercisesController < ApplicationController #首页批量或单独 立即发布,应是跳出弹窗,设置开始时间和截止时间。 def publish + group_ids = params[:group_ids]&.reject(&:blank?) if params[:detail].blank? tip_exception("缺少截止时间参数") if params[:end_time].blank? tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now) @@ -701,7 +702,6 @@ class ExercisesController < ApplicationController @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day) else group_end_times = params[:group_end_times].reject(&:blank?).map{|time| time.to_time} - group_ids = params[:group_ids].reject(&:blank?) tip_exception("缺少截止时间参数") if group_end_times.blank? tip_exception("截止时间和分班参数的个数不一致") if group_end_times.length != group_ids.length group_end_times.each do |time| diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 9941e1d42..5d75604ee 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -1044,6 +1044,7 @@ class HomeworkCommonsController < ApplicationController def publish_homework tip_exception("请至少选择一个分班") if params[:group_ids].blank? && @course.course_groups.size != 0 + group_ids = params[:group_ids]&.reject(&:blank?) if params[:detail].blank? tip_exception("缺少截止时间参数") if params[:end_time].blank? tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now) @@ -1051,7 +1052,6 @@ class HomeworkCommonsController < ApplicationController @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day) else group_end_times = params[:group_end_times].reject(&:blank?).map{|time| time.to_time} - group_ids = params[:group_ids].reject(&:blank?) tip_exception("缺少截止时间参数") if group_end_times.blank? tip_exception("截止时间和分班参数的个数不一致") if group_end_times.length != group_ids.length group_end_times.each do |time| diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 2259907e4..da5917e1b 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -254,6 +254,7 @@ class PollsController < ApplicationController #首页批量或单独 立即发布,应是跳出弹窗,设置开始时间和截止时间。 def publish + group_ids = params[:group_ids]&.reject(&:blank?) if params[:detail].blank? tip_exception("缺少截止时间参数") if params[:end_time].blank? tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now) @@ -261,7 +262,6 @@ class PollsController < ApplicationController @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day) else group_end_times = params[:group_end_times].reject(&:blank?).map{|time| time.to_time} - group_ids = params[:group_ids].reject(&:blank?) tip_exception("缺少截止时间参数") if group_end_times.blank? tip_exception("截止时间和分班参数的个数不一致") if group_end_times.length != group_ids.length group_end_times.each do |time| From 663083a63e1be5c1eea50d05a2df33ca5b8bd242 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 11 Oct 2019 16:33:00 +0800 Subject: [PATCH 10/12] isAdminOrCreator --- public/react/src/modules/courses/members/teacherList.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/members/teacherList.js b/public/react/src/modules/courses/members/teacherList.js index 74271ea5a..fe46e9bf4 100644 --- a/public/react/src/modules/courses/members/teacherList.js +++ b/public/react/src/modules/courses/members/teacherList.js @@ -649,6 +649,7 @@ class studentsList extends Component{ combineArray = this.state.application_list } const isAdminOrTeacher = this.props.isAdminOrTeacher() + const isAdminOrCreator = this.props.isAdminOrCreator() const isSuperAdmin = this.props.isSuperAdmin() const hasGraduationModule = this.hasGraduationModule() const coursesId = this.props.match.params.coursesId @@ -685,7 +686,7 @@ class studentsList extends Component{ {/* { isAdmin && this.addTeacher()}>添加教师 } { isAdmin && this.addStudent()}>添加学生 } */} - { isAdmin && this.showChangeAdminModal()}>更换管理员} + { isAdminOrCreator && this.showChangeAdminModal()}>更换管理员} } From 699d33ed9096ab67ed4bb89248f7a597ba70fffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 11 Oct 2019 16:42:25 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/courses/busyWork/CommonWorkSetting.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/busyWork/CommonWorkSetting.js b/public/react/src/modules/courses/busyWork/CommonWorkSetting.js index 5d9a7dc16..ad25f553f 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkSetting.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkSetting.js @@ -167,7 +167,12 @@ class CommonWorkSetting extends Component{ } on('commonwork_fetch_all', this.fetchAllListener) - } + + + if(this.props.isAdmin()===true){ + this.setState({startEditFlag: true}) + } + } componentWillUnmount() { off('commonwork_fetch_all', this.fetchAllListener) } From 6d84c0333a3dc653da54a8e108f790adce1bd629 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 11 Oct 2019 16:48:17 +0800 Subject: [PATCH 12/12] updatabanner --- public/react/src/modules/courses/members/ChangeRolePop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/members/ChangeRolePop.js b/public/react/src/modules/courses/members/ChangeRolePop.js index 7f55910bf..0f9e6f5f1 100644 --- a/public/react/src/modules/courses/members/ChangeRolePop.js +++ b/public/react/src/modules/courses/members/ChangeRolePop.js @@ -44,9 +44,9 @@ function ChangeRolePop({ member_roles = [], record, courseId, onChangeRoleSucces showNotification('保存成功') onChangeRoleSuccess() + trigger('updatabanner') if (fetchUser && record.user_id == getUserId) { fetchUser() - trigger('updatabanner') } }