From 02655789e171b67bbeddb83cef59665e68293d8a Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Thu, 31 Oct 2019 11:05:32 +0800
Subject: [PATCH 01/15] =?UTF-8?q?=E7=BB=9F=E8=AE=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/files_controller.rb | 80 +++++++++++++++++++++-----
app/models/attachment.rb | 1 +
app/models/attachment_group_setting.rb | 2 +
app/models/course.rb | 4 ++
4 files changed, 73 insertions(+), 14 deletions(-)
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index 117475894..bb81269da 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -24,26 +24,53 @@ class FilesController < ApplicationController
get_category(@course, @course_second_category_id)
@total_count = @attachments.size
- @publish_count = @attachments.published.size
- @unpublish_count = @total_count - @publish_count
- @attachments = @attachments.by_keywords(params[:search])
- @attachments =
- case @user.course_identity(@course)
- when 5
- @attachments.published
- when 6, 7
- @attachments.publiced.published
+ if @user.course_identity(@course) == 5
+ member = @course.course_members.find_by(user_id: current_user.id, is_active: 1)
+ if member.try(:course_group_id).to_i == 0
+ @attachments = @attachments.published.unified_setting
else
- @attachments
+ not_atta_ids = @course.attachment_group_settings.none_published.where("course_group_id = #{member.try(:course_group_id)}").pluck(:attachment_id)
+
+ @attachments = @attachments.where.not(id: not_atta_ids).published
end
+ elsif @user.course_identity(@course) > 5
+ @attachments = @attachments.publiced.published
+ end
+
+ @publish_count = @attachments.published.size
+ @unpublish_count = @total_count - @publish_count
+ @attachments = @attachments.by_keywords(params[:search])
@attachments = @attachments.page(@page).per(@page_size)
end
def bulk_publish
return normal_status(403, "您没有权限进行操作") if current_user.course_identity(@course) >= 5
- @course.attachments.by_ids(@attachment_ids).unpublish.update_all(is_publish: 1, publish_time: Time.now)
+ tip_exception("请至少选择一个分班") if params[:group_ids].blank? && @course.course_groups.size != 0
+
+ attachments = @course.attachments.by_ids(@attachment_ids)
+
+ ActiveRecord::Base.transaction do
+ # 有分班设置时
+ if @course.course_group_module? && @course.course_groups_count != 0 && params[:group_ids]
+ group_ids = params[:group_ids]&.reject(&:blank?)
+ charge_group_ids = @course.charge_group_ids(current_user)
+ publish_groups = charge_group_ids & group_ids if group_ids
+
+ attachments.each do |atta|
+ if atta.published? && !atta.unified_setting || !atta.published?
+ create_atta_group_settings atta
+ atta.update_all(unified_setting: 0) if atta.unified_setting
+ none_publish_settings = atta.attachment_group_settings.where(course_group_id: publish_groups).none_published
+ none_publish_settings.update_all(publish_time: Time.now)
+ end
+ end
+ end
+
+ # 未发布的资源更新状态
+ attachments.where(is_publish: 0).update_all(is_publish: 1, publish_time: Time.now)
+ end
render_ok
end
@@ -153,6 +180,10 @@ class FilesController < ApplicationController
attachment.is_publish = @atta_is_publish
attachment.delay_publish = @atta_delay_publish
attachment.publish_time = @atta_publish_time
+ attachment.unified_setting = @unified_setting
+ unless @unified_setting
+
+ end
# attachment.set_publish_time(publish_time) if is_unified_setting
# attachment.set_course_group_publish_time(@course, course_group_publish_times) if @course.course_groups.size > 0 && !is_unified_setting && publish_time.blank?
attachment.save!
@@ -319,9 +350,30 @@ class FilesController < ApplicationController
def publish_params
tip_exception("缺少发布参数") if params[:delay_publish].blank?
- tip_exception("缺少延期发布的时间参数") if params[:delay_publish].to_i == 1 && params[:publish_time].blank?
- @atta_is_publish = params[:delay_publish].to_i == 1 && params[:publish_time].to_time > Time.now ? 0 : 1
+ @unified_setting = 1
+ if params[:delay_publish].to_i == 1 && @course.course_group_module? && @course.course_groups_count != 0
+ tip_exception("分班发布设置不能为空") if params[:group_settings].blank?
+ min_publish_time = params[:group_settings].pluck(:publish_time).reject(&:blank?).min
+ max_publish_time = params[:group_settings].pluck(:publish_time).reject(&:blank?).max
+ tip_exception("分班发布设置不能为空") if min_publish_time.blank?
+
+ # 分班设置中的时间一样且包含所有分班 则按统一设置处理,否则是非统一设置
+ @unified_setting = 0 unless min_publish_time == max_publish_time && params[:group_settings].pluck(:group_id).flatten.sort == @course.course_groups.pluck(:id).sort
+ elsif params[:delay_publish].to_i == 1
+ tip_exception("缺少延期发布的时间参数") if params[:publish_time].blank?
+ min_publish_time = params[:publish_time]
+ end
+ @atta_is_publish = params[:delay_publish].to_i == 1 && min_publish_time.to_time > Time.now ? 0 : 1
@atta_delay_publish = params[:delay_publish].to_i
- @atta_publish_time = params[:delay_publish].to_i == 1 && params[:publish_time] ? params[:publish_time] : Time.now
+ @atta_publish_time = params[:delay_publish].to_i == 1 ? min_publish_time : Time.now
+ end
+
+ def create_atta_group_settings atta
+ if atta.attachment_group_settings.size != @course.course_groups.size
+ @course.course_groups.where.not(id: atta.attachment_group_settings.pluck(:course_group_id)).each do |group|
+ atta.attachment_group_settings << AttachmentGroupSetting.new(course_group_id: group.id, course_id: @course.id,
+ publish_time: atta.publish_time)
+ end
+ end
end
end
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index 8b7034ab9..37884e40b 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -23,6 +23,7 @@ class Attachment < ApplicationRecord
scope :mine, -> (author_id) { where(author_id: author_id) }
scope :simple_columns, -> { select(:id, :filename, :filesize, :created_on, :cloud_url, :author_id, :content_type) }
scope :search_by_container, -> (ids) {where(container_id: ids)}
+ scope :unified_setting, -> {where("unified_setting = ? ", 1)}
validates_length_of :description, maximum: 100
diff --git a/app/models/attachment_group_setting.rb b/app/models/attachment_group_setting.rb
index 67240d88f..3fefe5ceb 100644
--- a/app/models/attachment_group_setting.rb
+++ b/app/models/attachment_group_setting.rb
@@ -3,4 +3,6 @@ class AttachmentGroupSetting < ActiveRecord::Base
belongs_to :course_group
belongs_to :course
+ scope :none_published, -> {where("attachment_group_settings.publish_time IS NULL OR attachment_group_settings.publish_time > ?", Time.now)}
+
end
diff --git a/app/models/course.rb b/app/models/course.rb
index 16700428b..3e20eee12 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -111,6 +111,10 @@ class Course < ApplicationRecord
course_members.where(user_id: user_id, role: role).exists?
end
+ def course_group_module?
+ course_modules.exists?(module_type: "course_group", hidden: 0)
+ end
+
# 作业对应的子目录/父目录名称
def category_info type
course_module = course_modules.find_by(module_type: type)
From f2e29cd33de00a0bfa763b4f2450ed6ec4f6e921 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Thu, 31 Oct 2019 16:28:40 +0800
Subject: [PATCH 02/15] =?UTF-8?q?=E8=B5=84=E6=BA=90=E8=AE=BE=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/files_controller.rb | 22 +++++++++++++++++--
.../homework_commons_controller.rb | 3 ++-
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index bb81269da..683d35da2 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -181,8 +181,8 @@ class FilesController < ApplicationController
attachment.delay_publish = @atta_delay_publish
attachment.publish_time = @atta_publish_time
attachment.unified_setting = @unified_setting
- unless @unified_setting
-
+ if @unified_setting == 0
+ attachment_group_setting attachment, params[:group_settings]
end
# attachment.set_publish_time(publish_time) if is_unified_setting
# attachment.set_course_group_publish_time(@course, course_group_publish_times) if @course.course_groups.size > 0 && !is_unified_setting && publish_time.blank?
@@ -226,6 +226,10 @@ class FilesController < ApplicationController
attach_copied_obj.is_publish = @atta_is_publish
attach_copied_obj.delay_publish = @atta_delay_publish
attach_copied_obj.publish_time = @atta_publish_time
+ attach_copied_obj.unified_setting = @unified_setting
+ if @unified_setting == 0
+ attachment_group_setting attach_copied_obj, params[:group_settings]
+ end
attach_copied_obj.course_second_category_id = course_second_category_id
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from
if attach_copied_obj.attachtype == nil
@@ -265,6 +269,10 @@ class FilesController < ApplicationController
@old_attachment.is_publish = @atta_is_publish
@old_attachment.delay_publish = @atta_delay_publish
@old_attachment.publish_time = @atta_publish_time
+ @old_attachment.unified_setting = @unified_setting
+ if @unified_setting == 0
+ attachment_group_setting @old_attachment, params[:group_settings]
+ end
if params[:description] && !params[:description].strip.blank? && params[:description] != @old_attachment.description
@old_attachment.description = params[:description]
@@ -376,4 +384,14 @@ class FilesController < ApplicationController
end
end
end
+
+ def attachment_group_setting attachment, group_setting
+ create_atta_group_settings attachment
+ group_setting.each do |setting|
+ tip_exception("分班id不能为空") if setting[:group_id].length == 0
+ tip_exception("发布时间不能为空") if setting[:publish_time].blank?
+ AttachmentGroupSetting.where(attachment_id: attachment.id, course_group_id: setting[:group_id]).
+ update_all(publish_time: setting[:publish_time])
+ end
+ end
end
diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb
index 5d27de7b8..b7a76951e 100644
--- a/app/controllers/homework_commons_controller.rb
+++ b/app/controllers/homework_commons_controller.rb
@@ -13,7 +13,8 @@ class HomeworkCommonsController < ApplicationController
:reference_answer, :publish_groups, :end_groups, :alter_name, :update_explanation,
:update_score, :update_student_score]
before_action :user_course_identity
- before_action :homework_publish, only: [:show, :works_list, :code_review_results, :show_comment, :settings, :reference_answer, :update_student_score]
+ before_action :homework_publish, only: [:show, :works_list, :code_review_results, :show_comment, :settings, :reference_answer,
+ :update_student_score]
before_action :teacher_allowed, only: [:new, :edit, :create, :update, :shixuns, :subjects, :create_shixun_homework,
:publish_homework, :end_homework, :set_public, :choose_category, :move_to_category,
:choose_category, :create_subject_homework, :multi_destroy, :group_list, :homework_code_repeat,
From 11acb716713fea33601baf2783bdd66f73cef172 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Mon, 11 Nov 2019 14:46:31 +0800
Subject: [PATCH 03/15] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E8=B5=84=E6=BA=90?=
=?UTF-8?q?=E7=9A=84=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/files_controller.rb | 2 ++
app/views/files/show.json.jbuilder | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index 683d35da2..0299fdf7d 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -272,6 +272,8 @@ class FilesController < ApplicationController
@old_attachment.unified_setting = @unified_setting
if @unified_setting == 0
attachment_group_setting @old_attachment, params[:group_settings]
+ else
+ @old_attachment.attachment_group_settings.destroy_all
end
if params[:description] && !params[:description].strip.blank? && params[:description] != @old_attachment.description
diff --git a/app/views/files/show.json.jbuilder b/app/views/files/show.json.jbuilder
index 71359ccfd..941e66619 100644
--- a/app/views/files/show.json.jbuilder
+++ b/app/views/files/show.json.jbuilder
@@ -1,3 +1,3 @@
json.partial! 'attachments/attachment', attachment: @file
-# json.partial! "files/course_groups", attachment_group_settings: @file.attachment_group_settings
+json.partial! "files/course_groups", attachment_group_settings: @file.attachment_group_settings
json.partial! "attachment_histories/list", attachment_histories: @attachment_histories
\ No newline at end of file
From fdd98e7549e0303a5742e901bd219ab6c0cda762 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Mon, 11 Nov 2019 15:53:07 +0800
Subject: [PATCH 04/15] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=B5=84=E6=BA=90?=
=?UTF-8?q?=E5=8F=91=E5=B8=83?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/modules/courses/Resource/index.js | 48 +++++++++++++------
1 file changed, 33 insertions(+), 15 deletions(-)
diff --git a/public/react/src/modules/courses/Resource/index.js b/public/react/src/modules/courses/Resource/index.js
index c63348c83..be4195d1f 100644
--- a/public/react/src/modules/courses/Resource/index.js
+++ b/public/react/src/modules/courses/Resource/index.js
@@ -610,21 +610,33 @@ class Fileslists extends Component{
}
let starttime= this.props.getNowFormatDates(1);
let endtime=this.props.getNowFormatDates(2);
- this.setState({
- modalname:"立即发布",
- visible:true,
- typs:"start",
- Topval:"学生将能立即收到资源",
- // Botvalleft:"暂不发布",
- // Botval:`本操作只对"未发布"的分班有效`,
- // starttime:"发布时间:"+moment(moment(new Date())).format("YYYY-MM-DD HH:mm"),
- // starttimes:starttime,
- // endtime:"截止时间:"+endtime,
- Cancelname:"暂不发布",
- Savesname:"立即发布",
- Cancel:this.homeworkhide,
- Saves:this.homeworkstartend,
- })
+ let coursesId=this.props.match.params.coursesId;
+ let url="/courses/"+coursesId+"/all_course_groups.json";
+ axios.get(url).then((response) => {
+ if(response.status===200){
+ this.setState({
+ modalname:"立即发布",
+ modaltype:response.data.course_groups===null||response.data.course_groups.length===0?2:1,
+ visible:true,
+ typs:"start",
+ Topval:"学生将能立即收到资源",
+ // Botvalleft:"暂不发布",
+ // Botval:`本操作只对"未发布"的分班有效`,
+ // starttime:"发布时间:"+moment(moment(new Date())).format("YYYY-MM-DD HH:mm"),
+ // starttimes:starttime,
+ // endtime:"截止时间:"+endtime,
+ Cancelname:"暂不发布",
+ Savesname:"立即发布",
+ Cancel:this.homeworkhide,
+ Saves:this.homeworkstartend,
+ course_groups:response.data.course_groups,
+ })
+ }
+ }).catch((error) => {
+ console.log(error)
+ });
+
+
}
// 立即发布
homeworkstartend=(ds,endtime)=>{
@@ -674,6 +686,12 @@ class Fileslists extends Component{
starttimes:undefined,
})
}
+
+ getcourse_groupslist=(id)=>{
+ this.setState({
+ course_groupslist:id
+ })
+ }
render(){
let { searchValue,
checkBoxValues,
From c7e9f402f5982346b6077800fa2235f4ae294f47 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Mon, 11 Nov 2019 16:37:10 +0800
Subject: [PATCH 05/15] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=B5=84=E6=BA=90?=
=?UTF-8?q?=E6=89=B9=E9=87=8F=E5=8F=91=E5=B8=83?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/react/src/modules/courses/Resource/index.js | 3 ++-
.../react/src/modules/courses/coursesPublic/HomeworkModal.js | 3 +--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/public/react/src/modules/courses/Resource/index.js b/public/react/src/modules/courses/Resource/index.js
index be4195d1f..b74ca7a37 100644
--- a/public/react/src/modules/courses/Resource/index.js
+++ b/public/react/src/modules/courses/Resource/index.js
@@ -618,7 +618,7 @@ class Fileslists extends Component{
modalname:"立即发布",
modaltype:response.data.course_groups===null||response.data.course_groups.length===0?2:1,
visible:true,
- typs:"start",
+ typs:"end",
Topval:"学生将能立即收到资源",
// Botvalleft:"暂不发布",
// Botval:`本操作只对"未发布"的分班有效`,
@@ -645,6 +645,7 @@ class Fileslists extends Component{
let url ="/files/bulk_publish.json";
axios.put(url, {
course_id:coursesId,
+ group_ids:ds,
ids :checkBoxValues,
}).then((result)=>{
if(result.status===200){
diff --git a/public/react/src/modules/courses/coursesPublic/HomeworkModal.js b/public/react/src/modules/courses/coursesPublic/HomeworkModal.js
index 69eb937ff..11b180eb5 100644
--- a/public/react/src/modules/courses/coursesPublic/HomeworkModal.js
+++ b/public/react/src/modules/courses/coursesPublic/HomeworkModal.js
@@ -91,7 +91,7 @@ class HomeworkModal extends Component{
//勾选实训
shixunhomeworkedit=(list)=>{
-
+debugger
this.setState({
group_ids:list
})
@@ -108,7 +108,6 @@ class HomeworkModal extends Component{
}
propsSaves=(ds,endtime)=>{
-
if(ds.length ===0&&endtime === ""){
this.props.Saves()
}else{
From f30f7701347068af55fb4ca9024441e8c1c661ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Mon, 11 Nov 2019 18:06:02 +0800
Subject: [PATCH 06/15] =?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/courses/coursesPublic/sendResource.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/public/react/src/modules/courses/coursesPublic/sendResource.js b/public/react/src/modules/courses/coursesPublic/sendResource.js
index a0a62048b..9b13808d5 100644
--- a/public/react/src/modules/courses/coursesPublic/sendResource.js
+++ b/public/react/src/modules/courses/coursesPublic/sendResource.js
@@ -265,6 +265,7 @@ class Sendresource extends Component{
};
+ console.log(this.props.course_groups)
return(
{/*提示*/}
From 113842ebed0dbe1930bb47801bbd9991da44c94a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Mon, 11 Nov 2019 19:09:24 +0800
Subject: [PATCH 07/15] =?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/Resource/index.js | 62 +++++++++++--------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/public/react/src/modules/courses/Resource/index.js b/public/react/src/modules/courses/Resource/index.js
index b74ca7a37..139ca10bf 100644
--- a/public/react/src/modules/courses/Resource/index.js
+++ b/public/react/src/modules/courses/Resource/index.js
@@ -43,7 +43,23 @@ class Fileslists extends Component{
course_second_categories:[]
}
}
+
+
+ getcourse_groupslist=()=>{
+ let coursesId=this.props.match.params.coursesId;
+ let url="/courses/"+coursesId+"/all_course_groups.json";
+ axios.get(url).then((response) => {
+ if(response.status===200){
+ this.setState({
+ course_groups:response.data.course_groups
+ })
+ }
+ }).catch((error) => {
+ console.log(error)
+ });
+ }
componentDidMount=()=>{
+ this.getcourse_groupslist()
this.setState({
isSpin:true,
checkBoxValues:[],
@@ -81,6 +97,7 @@ class Fileslists extends Component{
}
componentDidUpdate = (prevProps) => {
if(prevProps.match.params.main_id != this.props.match.params.main_id){
+ this.getcourse_groupslist()
this.setState({
isSpin:true,
checkBoxValues:[],
@@ -95,6 +112,7 @@ class Fileslists extends Component{
}
}
if(prevProps.match.params.Id != this.props.match.params.Id){
+ this.getcourse_groupslist()
this.setState({
isSpin:true,
checkBoxValues:[],
@@ -610,32 +628,24 @@ class Fileslists extends Component{
}
let starttime= this.props.getNowFormatDates(1);
let endtime=this.props.getNowFormatDates(2);
- let coursesId=this.props.match.params.coursesId;
- let url="/courses/"+coursesId+"/all_course_groups.json";
- axios.get(url).then((response) => {
- if(response.status===200){
- this.setState({
- modalname:"立即发布",
- modaltype:response.data.course_groups===null||response.data.course_groups.length===0?2:1,
- visible:true,
- typs:"end",
- Topval:"学生将能立即收到资源",
- // Botvalleft:"暂不发布",
- // Botval:`本操作只对"未发布"的分班有效`,
- // starttime:"发布时间:"+moment(moment(new Date())).format("YYYY-MM-DD HH:mm"),
- // starttimes:starttime,
- // endtime:"截止时间:"+endtime,
- Cancelname:"暂不发布",
- Savesname:"立即发布",
- Cancel:this.homeworkhide,
- Saves:this.homeworkstartend,
- course_groups:response.data.course_groups,
- })
- }
- }).catch((error) => {
- console.log(error)
- });
+ this.setState({
+ modalname:"立即发布",
+ modaltype:this.state.course_groups===null||this.state.course_groups.length===0?2:1,
+ visible:true,
+ typs:"end",
+ Topval:"学生将能立即收到资源",
+ // Botvalleft:"暂不发布",
+ // Botval:`本操作只对"未发布"的分班有效`,
+ // starttime:"发布时间:"+moment(moment(new Date())).format("YYYY-MM-DD HH:mm"),
+ // starttimes:starttime,
+ // endtime:"截止时间:"+endtime,
+ Cancelname:"暂不发布",
+ Savesname:"立即发布",
+ Cancel:this.homeworkhide,
+ Saves:this.homeworkstartend,
+ course_groups:this.state.course_groups,
+ })
}
// 立即发布
@@ -724,7 +734,7 @@ class Fileslists extends Component{
let category_id= this.props.match.params.category_id;
-
+ console.log(this.state.course_groups)
return(
From 1d21e56564c6cd8702b27d4e138070e3df61164b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Mon, 11 Nov 2019 19:44:41 +0800
Subject: [PATCH 08/15] =?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/courses/Resource/index.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/public/react/src/modules/courses/Resource/index.js b/public/react/src/modules/courses/Resource/index.js
index 139ca10bf..102962dc3 100644
--- a/public/react/src/modules/courses/Resource/index.js
+++ b/public/react/src/modules/courses/Resource/index.js
@@ -45,7 +45,7 @@ class Fileslists extends Component{
}
- getcourse_groupslist=()=>{
+ getcourse_groupslists=()=>{
let coursesId=this.props.match.params.coursesId;
let url="/courses/"+coursesId+"/all_course_groups.json";
axios.get(url).then((response) => {
@@ -59,7 +59,7 @@ class Fileslists extends Component{
});
}
componentDidMount=()=>{
- this.getcourse_groupslist()
+ this.getcourse_groupslists()
this.setState({
isSpin:true,
checkBoxValues:[],
@@ -97,7 +97,7 @@ class Fileslists extends Component{
}
componentDidUpdate = (prevProps) => {
if(prevProps.match.params.main_id != this.props.match.params.main_id){
- this.getcourse_groupslist()
+ this.getcourse_groupslists()
this.setState({
isSpin:true,
checkBoxValues:[],
@@ -112,7 +112,7 @@ class Fileslists extends Component{
}
}
if(prevProps.match.params.Id != this.props.match.params.Id){
- this.getcourse_groupslist()
+ this.getcourse_groupslists()
this.setState({
isSpin:true,
checkBoxValues:[],
From 7173fa94b248b9c71f1bf87d2cc2709c7fe3507d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Tue, 12 Nov 2019 20:59:39 +0800
Subject: [PATCH 09/15] =?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/coursesPublic/HomeworkModal.js | 1 -
.../src/modules/courses/coursesPublic/sendResource.js | 7 +++++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/public/react/src/modules/courses/coursesPublic/HomeworkModal.js b/public/react/src/modules/courses/coursesPublic/HomeworkModal.js
index 11b180eb5..849159301 100644
--- a/public/react/src/modules/courses/coursesPublic/HomeworkModal.js
+++ b/public/react/src/modules/courses/coursesPublic/HomeworkModal.js
@@ -91,7 +91,6 @@ class HomeworkModal extends Component{
//勾选实训
shixunhomeworkedit=(list)=>{
-debugger
this.setState({
group_ids:list
})
diff --git a/public/react/src/modules/courses/coursesPublic/sendResource.js b/public/react/src/modules/courses/coursesPublic/sendResource.js
index 9b13808d5..b266767ff 100644
--- a/public/react/src/modules/courses/coursesPublic/sendResource.js
+++ b/public/react/src/modules/courses/coursesPublic/sendResource.js
@@ -402,8 +402,8 @@ class Sendresource extends Component{
延期发布
+ {this.props.course_groups.length===0?
+ />:""}
(按照设置的时间定时发布)
+
+
+
From 2bd0bb5850b77c6dd2c1b9f61af902a014697fa7 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, 13 Nov 2019 11:57:19 +0800
Subject: [PATCH 10/15] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=B5=84=E6=BA=90?=
=?UTF-8?q?=E4=B8=8A=E4=BC=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/react/config/webpack.config.dev.js | 2 +-
.../src/modules/courses/Resource/index.js | 2 +-
.../courses/coursesPublic/SelectResource.js | 160 ++++++++++++++++--
.../courses/coursesPublic/sendResource.js | 135 +++++++++++++--
4 files changed, 274 insertions(+), 25 deletions(-)
diff --git a/public/react/config/webpack.config.dev.js b/public/react/config/webpack.config.dev.js
index f335f1705..4acbb35a7 100644
--- a/public/react/config/webpack.config.dev.js
+++ b/public/react/config/webpack.config.dev.js
@@ -32,7 +32,7 @@ module.exports = {
// See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s
// devtool: "cheap-module-eval-source-map",
// 开启调试
- devtool: "source-map", // 开启调试
+ //devtool: "source-map", // 开启调试
// These are the "entry points" to our application.
// This means they will be the "root" imports that are included in JS bundle.
// The first two entry points enable "hot" CSS and auto-refreshes for JS.
diff --git a/public/react/src/modules/courses/Resource/index.js b/public/react/src/modules/courses/Resource/index.js
index 102962dc3..a1a43602b 100644
--- a/public/react/src/modules/courses/Resource/index.js
+++ b/public/react/src/modules/courses/Resource/index.js
@@ -734,7 +734,7 @@ class Fileslists extends Component{
let category_id= this.props.match.params.category_id;
- console.log(this.state.course_groups)
+ // console.log(this.state.course_groups)
return(
diff --git a/public/react/src/modules/courses/coursesPublic/SelectResource.js b/public/react/src/modules/courses/coursesPublic/SelectResource.js
index 13c201cd0..16e52182f 100644
--- a/public/react/src/modules/courses/coursesPublic/SelectResource.js
+++ b/public/react/src/modules/courses/coursesPublic/SelectResource.js
@@ -42,7 +42,13 @@ class Selectresource extends Component{
getallfiles:false,
searchtype:'getallfiles',
Radiovalue:0,
- datatime:undefined
+ datatime:undefined,
+ course_group_publish_times:[
+ {
+ group_id : undefined,
+ publish_time :undefined,
+ course_group_name:undefined
+ }],
}
}
componentDidMount() {
@@ -212,7 +218,7 @@ class Selectresource extends Component{
savecouseShixunModal=()=>{
- let {patheditarry,datatime,Radiovalue}=this.state;
+ let {patheditarry,datatime,Radiovalue,course_group_publish_times}=this.state;
let {coursesId,attachmentId}=this.props;
let url="/files/import.json";
@@ -227,7 +233,7 @@ class Selectresource extends Component{
})
}
- if(this.state.Radiovalue===1){
+ if(this.state.Radiovalue===1&&this.props.course_groups.length===0){
if(datatime===undefined||datatime===null||datatime=== ""){
this.setState({
Radiovaluetype:true
@@ -245,7 +251,8 @@ class Selectresource extends Component{
attachment_ids:patheditarry,
course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId,
delay_publish:Radiovalue,
- publish_time:Radiovalue===1?datatime:undefined
+ publish_time:this.props.course_groups.length===0?Radiovalue===1?datatime===undefined? undefined:datatime:undefined:undefined,
+ group_settings:this.props.course_groups.length===0?undefined:course_group_publish_times
}
).then((response) => {
if(response.data.status===0){
@@ -271,15 +278,59 @@ class Selectresource extends Component{
});
}
- onChangeTimepublish= (date, dateString) => {
+ onChangeTimepublish= (date, dateString,key,type) => {
+ if(type===1){
+ this.setState({
+ datatime:handleDateString(dateString),
+ })
+ }else if(type===2){
+ let {course_group_publish_times}=this.state;
+ let newgroup_publish=course_group_publish_times;
+ for(var i=0; i{
+ let newlist=this.state.course_group_publish_times;
+ newlist.push( {
+ group_id : undefined,
+ publish_time :undefined,
+ course_group_name:undefined
+ })
this.setState({
- datatime:handleDateString(dateString),
+ course_group_publish_times:newlist
})
-
}
+ deletegrouppublish=(key)=>{
+ let newlist=this.state.course_group_publish_times;
+ newlist.splice(key,1);
+ this.setState({
+ course_group_publish_times:newlist
+ })
+ }
+ selectassigngroups=(e,index,key)=>{
+ let {course_group_publish_times}=this.state;
+ let newgroup_publish=course_group_publish_times;
+ for(var i=0; i;
const radioStyle = {
@@ -287,6 +338,8 @@ class Selectresource extends Component{
height: '30px',
lineHeight: '30px',
};
+
+ console.log(course_group_publish_times)
return(
{/*提示*/}
@@ -325,12 +378,12 @@ class Selectresource extends Component{
}
#shixun_tab_div{
padding: 0 30px;
- padding-top:30px;
+ padding-top:15px;
}
.search-news{
width: 237px!important;
height: 30px;
- margin-bottom: 30px;
+ margin-bottom: 15px;
}
`}
@@ -373,7 +426,7 @@ class Selectresource extends Component{
height: 37px;
}
.scrollbox{
- height:250px !important;
+ height:145px !important;
}
.selectfilsbox{
height: 50px;
@@ -424,7 +477,7 @@ class Selectresource extends Component{
延期发布
- 0?"":
+ />}
(按照设置的时间定时发布)
+
+
+ {this.props.course_groups.length>0?this.props.isStudent()===true?"":
+ {this.state.Radiovalue===1?:""}
+ {
+ course_group_publish_times.map((item,key)=>{
+ return(
+
+
+
+ this.onChangeTimepublish(e,index,key,2)}
+ // onChange={ this.onChangeTimepublish }
+ disabledTime={disabledDateTime}
+ disabledDate={disabledDate}
+ />
+ {key!=0?this.deletegrouppublish(key)}>:""}
+ {key+1===this.props.course_groups.length?"":}
+
+ )
+ })
+
+ }
+
:""}
{this.state.patheditarrytype===true?请选择资源
:""}
diff --git a/public/react/src/modules/courses/coursesPublic/sendResource.js b/public/react/src/modules/courses/coursesPublic/sendResource.js
index b266767ff..83c774ae3 100644
--- a/public/react/src/modules/courses/coursesPublic/sendResource.js
+++ b/public/react/src/modules/courses/coursesPublic/sendResource.js
@@ -14,12 +14,12 @@ function range(start, end) {
}
return result;
}
+
function disabledDateTime() {
return {
- // disabledHours: () => range(0, 24).splice(4, 20),
disabledMinutes: () => range(1, 30).concat(range(31, 60)),
- // disabledSeconds: () => [0, 60],
- };
+ // disabledSeconds: () => range(0,60)
+ }
}
function disabledDate(current) {
@@ -45,8 +45,9 @@ class Sendresource extends Component{
// moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
course_group_publish_times:[
{
- course_group_id : undefined,
- publish_time :""
+ group_id : undefined,
+ publish_time :undefined,
+ course_group_name:undefined
}],
course_groups:undefined,
course_groups_count:undefined,
@@ -127,7 +128,7 @@ class Sendresource extends Component{
}
Saves=()=>{
- let {fileList,description,is_public,datatime,Radiovalue} =this.state;
+ let {fileList,description,is_public,datatime,Radiovalue,course_group_publish_times} =this.state;
let newfileList=[];
for(var list of fileList){
@@ -141,7 +142,7 @@ class Sendresource extends Component{
return
}
- if(this.state.Radiovalue===1){
+ if(this.state.Radiovalue===1&&this.props.course_groups.length===0){
if(datatime===undefined||datatime===null||datatime=== ""){
this.setState({
Radiovaluetype:true
@@ -156,6 +157,7 @@ class Sendresource extends Component{
+
if(description===undefined){
}else if(description.length>100){
@@ -176,9 +178,10 @@ class Sendresource extends Component{
course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId,
attachment_ids:newfileList,
is_public:is_public,
- publish_time:Radiovalue===1?datatime===undefined? undefined:datatime:undefined,
+ publish_time:this.props.course_groups.length===0?Radiovalue===1?datatime===undefined? undefined:datatime:undefined:"",
description:description,
delay_publish:Radiovalue,
+ group_settings:this.props.course_groups.length===0?"":course_group_publish_times
}).then((result)=>{
if(result.data.status===0){
@@ -237,10 +240,44 @@ class Sendresource extends Component{
Radiovalue: e.target.value,
});
}
+
+ addgrouppublish=()=>{
+ let newlist=this.state.course_group_publish_times;
+ newlist.push( {
+ group_id : undefined,
+ publish_time :undefined,
+ course_group_name:undefined
+ })
+ this.setState({
+ course_group_publish_times:newlist
+ })
+ }
+ deletegrouppublish=(key)=>{
+ let newlist=this.state.course_group_publish_times;
+ newlist.splice(key,1);
+ this.setState({
+ course_group_publish_times:newlist
+ })
+ }
+ selectassigngroups=(e,index,key)=>{
+ let {course_group_publish_times}=this.state;
+ let newgroup_publish=course_group_publish_times;
+ for(var i=0; i
{/*提示*/}
@@ -421,10 +458,88 @@ class Sendresource extends Component{
(按照设置的时间定时发布)
+
+
+ {this.props.course_groups.length>0?this.props.isStudent()===true?"":
+ {this.state.Radiovalue===1?:""}
+ {
+ course_group_publish_times.map((item,key)=>{
+ return(
+
+
+
+ this.onChangeTimepublish(e,index,key,2)}
+ // onChange={ this.onChangeTimepublish }
+ disabledTime={disabledDateTime}
+ disabledDate={disabledDate}
+ />
+ {key!=0?this.deletegrouppublish(key)}>:""}
+ {key+1===this.props.course_groups.length?"":}
+
+ )
+ })
-
+ }
+
:""}
From 4a228139dc896ebd64ab5e916cf6e938d6350f6f 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, 15 Nov 2019 09:13:14 +0800
Subject: [PATCH 11/15] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../courses/coursesPublic/SelectResource.js | 15 +++++++--------
.../modules/courses/coursesPublic/sendResource.js | 8 +++-----
2 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/public/react/src/modules/courses/coursesPublic/SelectResource.js b/public/react/src/modules/courses/coursesPublic/SelectResource.js
index 16e52182f..31c6d2f52 100644
--- a/public/react/src/modules/courses/coursesPublic/SelectResource.js
+++ b/public/react/src/modules/courses/coursesPublic/SelectResource.js
@@ -45,9 +45,8 @@ class Selectresource extends Component{
datatime:undefined,
course_group_publish_times:[
{
- group_id : undefined,
+ group_id : [],
publish_time :undefined,
- course_group_name:undefined
}],
}
}
@@ -302,7 +301,6 @@ class Selectresource extends Component{
newlist.push( {
group_id : undefined,
publish_time :undefined,
- course_group_name:undefined
})
this.setState({
course_group_publish_times:newlist
@@ -316,12 +314,12 @@ class Selectresource extends Component{
})
}
selectassigngroups=(e,index,key)=>{
+ debugger
let {course_group_publish_times}=this.state;
let newgroup_publish=course_group_publish_times;
for(var i=0; i