Merge branches 'dev_Ysm' and 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_Ysm

# Conflicts:
#	app/controllers/subjects_controller.rb
#	public/react/src/App.js
#	public/react/src/modules/courses/coursesPublic/Addcourses.js
#	public/react/src/modules/modals/Certifiedprofessional.js
#	public/react/src/modules/modals/certfed.css
dev_hs
杨树明 5 years ago
commit c61f3c1e8b

@ -1,436 +1,447 @@
class SubjectsController < ApplicationController
before_action :require_login, :check_auth, except: [:index, :show, :right_banner]
# before_action :check_auth, except: [:index]
before_action :check_account, except: [:index, :show, :right_banner]
before_action :find_subject, except: [:index, :create, :new, :append_to_stage]
before_action :allowed, only: [:update, :edit, :destroy, :publish, :cancel_publish, :cancel_has_publish,
:search_members, :add_subject_members, :statistics, :shixun_report, :school_report,
:up_member_position, :down_member_position]
include ApplicationHelper
include SubjectsHelper
def index
@tech_system = Repertoire.where(nil).order("updated_at desc")
select = params[:select] # 路径导航类型
reorder = params[:order] || "publish_time"
search = params[:search]
## 分页参数
page = params[:page] || 1
limit = params[:limit] || 16
offset = (page.to_i-1) * limit
# 最热排序
if reorder == "myshixun_count"
if select
@subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status,
subjects.shixuns_count, subjects.excellent, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns
on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where
subjects.hidden = 0 AND subjects.status = 2 AND subjects.name like '%#{search}%'
AND subjects.repertoire_id = #{select} GROUP BY subjects.id ORDER BY myshixun_member_count DESC")
else
@subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status,
subjects.shixuns_count, subjects.excellent, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns
on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where
subjects.hidden = 0 AND subjects.status = 2 AND subjects.name like '%#{search}%'
GROUP BY subjects.id ORDER BY myshixun_member_count DESC")
end
else
# 我的路径
if reorder == "mine"
tip_exception(401, "..") unless current_user.logged?
mine_subject_id = StageShixun.find_by_sql("select DISTINCT(subject_id) from stage_shixuns where shixun_id in
(select distinct(shixun_id) from myshixuns where user_id=#{current_user.id})").map(&:subject_id)
manage_subject_id = SubjectMember.where(user_id: current_user.id).pluck(:subject_id)
total_subject_id = (mine_subject_id + manage_subject_id).uniq
@subjects = Subject.where(id: total_subject_id)
elsif reorder == "publish_time"
@subjects = Subject.unhidden
else
@subjects = Subject.visible.unhidden
end
# 类型
if select
@subjects = @subjects.where(repertoire_id: select)
end
if search.present?
@subjects = @subjects.where("name like ?", "%#{search}%")
end
# 排序
order_str = reorder == "publish_time" ? "status = 2 desc, publish_time asc" : "updated_at desc"
@subjects = @subjects.reorder(order_str)
end
@total_count = @subjects.size
if reorder != "myshixun_count"
@subjects = @subjects.page(page).per(limit).includes(:shixuns, :repertoire)
else
@subjects = @subjects[offset, limit]
subject_ids = @subjects.pluck(:id)
order_ids = subject_ids.size > 0 ? subject_ids.join(',') : -1
@subjects = Subject.where(id: subject_ids).order("field(id,#{order_ids})").includes(:shixuns, :repertoire)
end
end
def show
@user = current_user
@is_creator = current_user.creator_of_subject?(@subject)
@is_manager = @user.manager_of_subject?(@subject)
# 合作团队
@shixuns = @subject.shixuns.published.pluck(:id)
@courses = @subject.courses if @subject.excellent
# 访问数变更
@subject.increment!(:visits)
end
def right_banner
@user = current_user
# 合作团队
@members = @subject.subject_members.includes(:user)
shixuns = @subject.shixuns.published.pluck(:id)
challenge_ids = Challenge.where(shixun_id: shixuns).pluck(:id)
# 实训路径中的所有实训标签
@tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq
# 用户获取的实训标签
# @user_tags = @subject.shixuns.map(&:user_tags_name).flatten.uniq
@user_tags = user_shixun_tags challenge_ids, @user.id
@my_subject_progress = @subject.my_subject_progress
end
def new
normal_status("")
end
def create
ActiveRecord::Base.transaction do
begin
@subject = Subject.new(subject_params)
@subject.user_id = current_user.id
@subject.save!
@subject.subject_members.create!(role: 1, user_id: current_user.id)
rescue Exception => e
uid_logger_error(e.message)
tip_exception("实训路径创建失败")
raise ActiveRecord::Rollback
end
end
end
def edit
end
def update
begin
@subject.update_attributes(subject_params)
rescue Exception => e
uid_logger_error(e.message)
tip_exception("实训路径更新失败")
raise ActiveRecord::Rollback
end
end
def destroy
ActiveRecord::Base.transaction do
begin
ApplyAction.where(container_type: "ApplySubject", container_id: @subject.id).destroy_all
@subject.destroy
rescue Exception => e
uid_logger_error(e.message)
tip_exception("实训路径删除失败")
raise ActiveRecord::Rollback
end
end
end
def choose_subject_shixun
@search = params[:search].strip if params[:search]
@type = params[:type]
# 超级管理员用户显示所有未隐藏的实训、非管理员显示合作团队用户的实训(对本单位公开且未隐藏)
if current_user.admin?
@shixuns = Shixun.select([:id, :name, :status, :myshixuns_count, :identifier, :averge_star]).where(hidden: 0)
else
none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id).to_i}").pluck(:shixun_id)
@shixuns = Shixun.select([:id, :name, :status, :myshixuns_count, :identifier, :averge_star]).where.not(id: none_shixun_ids).where(hidden: 0)
end
# 实训课程的所有标签
tag_ids = @shixuns.joins(:shixun_tag_repertoires).pluck(:tag_repertoire_id).uniq
@tags = TagRepertoire.select([:id, :name]).where(id: tag_ids)
unless @search.blank?
@shixuns = @shixuns.where("name like ?", "%#{@search}%")
end
unless @type.nil? || @type == "" || @type == "all"
shixun_ids = ShixunTagRepertoire.where(tag_repertoire_id: @type).pluck(:shixun_id).uniq
@shixuns = @shixuns.where(id: shixun_ids)
end
@shixuns = @shixuns.reorder("created_at desc")
@shixuns_count = @shixuns.size
## 分页参数
page = params[:page] || 1
@shixuns = @shixuns.page(page).per(10)
@shixuns = @shixuns.includes(:myshixuns)
end
def append_to_stage
@shixuns = Shixun.where(id: params[:shixun_id]).order("id desc")
end
def choose_course
course_ids = Course.find_by_sql("SELECT c.id FROM courses c, course_members m
WHERE m.course_id = c.id AND m.role in (1,2,3)
AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0").map(&:id)
@courses = Course.where(id: course_ids)
@none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id).to_i}").pluck(:shixun_id)
end
def send_to_course
@course = Course.find_by!(id: params[:course_id])
stages = @subject.stages.where(id: @subject.stage_shixuns.where(shixun_id: params[:shixun_ids]).pluck(:stage_id))
course_module = @course.course_modules.where(module_type: "shixun_homework").first
ActiveRecord::Base.transaction do
begin
# 将实训课程下的所有已发布实训按顺序发送到课堂,同时创建与章节同名的实训作业目录
stages.each do |stage|
category = CourseSecondCategory.where(name: stage.name, course_id: @course.id, category_type: "shixun_homework").first ||
CourseSecondCategory.create!(name: stage.name, course_id: @course.id, category_type: "shixun_homework",
course_module_id: course_module.id, position: course_module.course_second_categories.count + 1)
stage.shixuns.where(id: params[:shixun_ids], status: 2).each do |shixun|
homework = HomeworksService.new.create_homework shixun, @course, category, current_user
end
end
rescue Exception => e
uid_logger(e.message)
tip_exception(e.message)
raise ActiveRecord::Rollback
end
end
end
def publish
apply = ApplyAction.where(container_type: "ApplySubject", container_id: @subject.id).order("created_at desc").first
if apply && apply.status == 0
@status = 0
else
@subject.update_attributes(status: 1)
ApplyAction.create(container_type: "ApplySubject", container_id: @subject.id, user_id: current_user.id, status: 0)
begin
status = Educoder::Sms.send(mobile: '18711011226', send_type:'publish_subject' , name: '管理员')
rescue => e
uid_logger_error("发送验证码出错: #{e}")
end
@status = 1
end
end
def cancel_publish
begin
apply = ApplyAction.where(container_type: "ApplySubject", container_id: @subject.id).order("created_at desc").first
if apply && apply.status == 0
apply.update_attributes(status: 3)
apply.tidings.destroy_all
end
@subject.update_attributes(status: 0)
rescue => e
uid_logger_error(e.message)
tip_exception("撤销申请失败")
raise ActiveRecord::Rollback
end
end
def cancel_has_publish
begin
@subject.update_attributes(:status => 0)
rescue => e
uid_logger_error(e.message)
tip_exception("撤销发布失败")
raise ActiveRecord::Rollback
end
end
def search_members
tip_exception("搜索内容不能为空") unless params[:search]
page = params[:page] || 1
member_ids = @subject.subject_members.map(&:user_id).join(',')
condition = "%#{params[:search].strip}%".gsub(" ","")
@users = User.where("id not in (?) and status = 1 and LOWER(concat(lastname, firstname, login, mail)) LIKE ?", member_ids, "#{condition}")
@users = @users.page(page).per(10)
@users = @users.includes(:user_extension)
end
def add_subject_members
# tip_exception(403, "没权限操作") if !current_user.admin?
tip_exception("user_ids 不能为空!") if params[:user_ids].blank?
memberships = params[:user_ids]
memberships.each do |member|
if SubjectMember.where(user_id: member, subject_id: @subject.id).count == 0
user = User.find_by!(id: member)
SubjectMember.create!(user_id: member, subject_id: @subject.id, role: 2, position: @subject.subject_members.size + 1) if user.present?
end
end
end
# 删除实训
# DELETE: /api/subejcts/:id/delete_member
def delete_member
tip_exception(403, "没权限操作") unless current_user.manager_of_subject?(@subject)
tip_exception('用户id不能为空') if params[:user_id].blank?
user = @subject.subject_members.where(:user_id => params[:user_id], :role => 2).first
tip_exception("管理员用户不允许删除,或用户不存在") if user.blank?
ActiveRecord::Base.transaction do
begin
@subject.subject_members.where("position > #{user.position}").update_all("position = position - 1")
user.destroy
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
raise ActiveRecord::Rollback
end
end
end
# 合作者上移
def up_member_position
tip_exception('用户id不能为空') if params[:user_id].blank?
ActiveRecord::Base.transaction do
begin
member = @subject.subject_members.where(user_id: params[:user_id]).first
# position为1时不能再往上移
tip_exception('不能再上移了') if member.position == 1
up_member = @subject.subject_members.where(position: member.position - 1).first
up_member.update_attribute(:position, member.position)
member.update_attribute(:position, member.position - 1)
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
raise ActiveRecord::Rollback
end
end
end
# 合作者下移
def down_member_position
tip_exception('用户id不能为空') if params[:user_id].blank?
ActiveRecord::Base.transaction do
begin
member = @subject.subject_members.where(user_id: params[:user_id]).first
# position已经是最大值时不能再往下移
tip_exception('不能再下移了') if member.position == @subject.subject_members.size
down_member = @subject.subject_members.where(:position => member.position + 1).first
down_member.update_attribute(:position, member.position)
member.update_attribute(:position, member.position + 1)
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
raise ActiveRecord::Rollback
end
end
end
def statistics
@learn_count = @subject.member_count
shixun_ids = @subject.stage_shixuns.pluck(:shixun_id)
# 受用课堂(已经发布的实训(在此路径中的实训)作业的个数)
homework_common_id = HomeworkCommonsShixun.where(shixun_id: shixun_ids).pluck(:homework_common_id).uniq
homework_common_id = homework_common_id.blank? ? -1 : homework_common_id.join(",")
courses = Course.find_by_sql("select c.id, c.school_id from courses c right join homework_commons hc on c.id = hc.course_id where c.is_delete = 0
and c.school_id is not null and hc.publish_time < '#{Time.now}' and hc.id in (#{(homework_common_id)})")
course_ids = courses.pluck(:id).uniq
@course_count = course_ids.length
# 受用院校
school_ids = courses.pluck(:school_id).uniq
@schools_count = school_ids.length
# 采用课堂情况
@schools = School.select([:id, :name]).where(id: school_ids)
@schools =
@schools.map do |s|
school_courses = Course.where(id: course_ids, school_id: s.id)
course_count = school_courses.count
student_count = StudentsForCourse.where(course_id: school_courses.pluck(:id)).count
homework_count = HomeworkCommon.find_by_sql("select count(*) cnt from homework_commons hc join courses c on hc.course_id = c.id
where c.school_id = #{s.id} and hc.id in(#{homework_common_id})").first.try(:cnt)
s.attributes.dup.merge({name: s.name, course_count: course_count, student_count: student_count,homework_count: homework_count})
end
@schools = @schools.sort{|x,y| y['homework_count'] <=> x['homework_count']}
@school_total_count = @schools.size
page = params[:page] || 1
@schools = @schools[(page.to_i-1)*10, 10]
# TODO: 这个可以异步加载,让页面刷新完成后再加载图形数据
# 章节使用情况
@stage_user_info = []
@sum = 0 #总数
@subject.stages.includes(:stage_shixuns).each do |stage|
shixun_ids = stage.stage_shixuns.pluck(:shixun_id)
if shixun_ids.present?
homework_common_id = HomeworkCommonsShixun.where(shixun_id: shixun_ids).pluck(:homework_common_id).uniq
if homework_common_id.present?
publish_homework = HomeworkDetailManual.where("homework_common_id in(?) and comment_status > 0", homework_common_id.join(",")).pluck(:homework_common_id)
use_count = publish_homework.present? ? HomeworkCommon.find_by_sql("select count(*) cnt from homework_commons hc join courses c on hc.course_id = c.id
where hc.id in(#{publish_homework.join(",")}) and c.school_id is not null").first.try(:cnt) : 0
@sum += use_count
else
@sum += 0
use_count = 0
end
@stage_user_info << use_count
else
@sum += 0
@stage_user_info << 0
end
end
end
def shixun_report
end
def school_report
@schools = School.find_by_sql("select count(ms.id) ue_count, s.id, s.name school_name from user_extensions ue,
myshixuns ms, schools s where ue.user_id = ms.user_id and ms.shixun_id in (select shixun_id from
stage_shixuns where subject_id = '#{@subject.id}') and s.id = ue.school_id group by ue.school_id
order by ue_count desc limit 10")
end
private
def subject_params
tip_exception("实训路径名称不能为空") if params[:name].blank?
tip_exception("实训路径简介不能为空") if params[:description].blank?
tip_exception("实训路径学习须知不能为空") if params[:learning_notes].blank?
params.require(:subject).permit(:name, :description, :learning_notes)
end
def find_subject
@subject = Subject.find_by!(id: params[:id])
unless @subject.status == 2 || current_user.manager_of_subject?(@subject)
tip_exception("403", "")
end
end
def allowed
unless current_user.manager_of_subject?(@subject)
tip_exception("403", "")
end
end
end
class SubjectsController < ApplicationController
before_action :require_login, :check_auth, except: [:index, :show, :right_banner]
# before_action :check_auth, except: [:index]
before_action :check_account, except: [:index, :show, :right_banner]
before_action :find_subject, except: [:index, :create, :new, :append_to_stage]
before_action :allowed, only: [:update, :edit, :destroy, :publish, :cancel_publish, :cancel_has_publish,
:search_members, :add_subject_members, :statistics, :shixun_report, :school_report,
:up_member_position, :down_member_position]
include ApplicationHelper
include SubjectsHelper
def index
@tech_system = Repertoire.where(nil).order("updated_at desc")
select = params[:select] # 路径导航类型
reorder = params[:order] || "publish_time"
search = params[:search]
## 分页参数
page = params[:page] || 1
limit = params[:limit] || 16
offset = (page.to_i-1) * limit
# 最热排序
if reorder == "myshixun_count"
if select
@subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status,
subjects.shixuns_count, subjects.excellent, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns
on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where
subjects.hidden = 0 AND subjects.status = 2 AND subjects.name like '%#{search}%'
AND subjects.repertoire_id = #{select} GROUP BY subjects.id ORDER BY myshixun_member_count DESC")
else
@subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status,
subjects.shixuns_count, subjects.excellent, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns
on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where
subjects.hidden = 0 AND subjects.status = 2 AND subjects.name like '%#{search}%'
GROUP BY subjects.id ORDER BY myshixun_member_count DESC")
end
else
# 我的路径
if reorder == "mine"
tip_exception(401, "..") unless current_user.logged?
mine_subject_id = StageShixun.find_by_sql("select DISTINCT(subject_id) from stage_shixuns where shixun_id in
(select distinct(shixun_id) from myshixuns where user_id=#{current_user.id})").map(&:subject_id)
manage_subject_id = SubjectMember.where(user_id: current_user.id).pluck(:subject_id)
total_subject_id = (mine_subject_id + manage_subject_id).uniq
@subjects = Subject.where(id: total_subject_id)
elsif reorder == "publish_time"
@subjects = Subject.unhidden
else
@subjects = Subject.visible.unhidden
end
# 类型
if select
@subjects = @subjects.where(repertoire_id: select)
end
if search.present?
@subjects = @subjects.where("name like ?", "%#{search}%")
end
# 排序
order_str = reorder == "publish_time" ? "status = 2 desc, publish_time asc" : "updated_at desc"
@subjects = @subjects.reorder(order_str)
end
@total_count = @subjects.size
if reorder != "myshixun_count"
@subjects = @subjects.page(page).per(limit).includes(:shixuns, :repertoire)
else
@subjects = @subjects[offset, limit]
subject_ids = @subjects.pluck(:id)
order_ids = subject_ids.size > 0 ? subject_ids.join(',') : -1
@subjects = Subject.where(id: subject_ids).order("field(id,#{order_ids})").includes(:shixuns, :repertoire)
end
end
def show
@user = current_user
@is_creator = current_user.creator_of_subject?(@subject)
@is_manager = @user.manager_of_subject?(@subject)
# 合作团队
@shixuns = @subject.shixuns.published.pluck(:id)
@courses = @subject.courses if @subject.excellent
@members = @subject.subject_members.includes(:user)
shixuns = @subject.shixuns.published.pluck(:id)
challenge_ids = Challenge.where(shixun_id: shixuns).pluck(:id)
# 实训路径中的所有实训标签
@tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq
# 用户获取的实训标签
# @user_tags = @subject.shixuns.map(&:user_tags_name).flatten.uniq
@user_tags = user_shixun_tags challenge_ids, @user.id
@my_subject_progress = @subject.my_subject_progress
# 访问数变更
@subject.increment!(:visits)
end
def right_banner
@user = current_user
# 合作团队
@members = @subject.subject_members.includes(:user)
shixuns = @subject.shixuns.published.pluck(:id)
challenge_ids = Challenge.where(shixun_id: shixuns).pluck(:id)
# 实训路径中的所有实训标签
@tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq
# 用户获取的实训标签
# @user_tags = @subject.shixuns.map(&:user_tags_name).flatten.uniq
@user_tags = user_shixun_tags challenge_ids, @user.id
@my_subject_progress = @subject.my_subject_progress
end
def new
normal_status("")
end
def create
ActiveRecord::Base.transaction do
begin
@subject = Subject.new(subject_params)
@subject.user_id = current_user.id
@subject.save!
@subject.subject_members.create!(role: 1, user_id: current_user.id)
rescue Exception => e
uid_logger_error(e.message)
tip_exception("实训路径创建失败")
raise ActiveRecord::Rollback
end
end
end
def edit
end
def update
begin
@subject.update_attributes(subject_params)
rescue Exception => e
uid_logger_error(e.message)
tip_exception("实训路径更新失败")
raise ActiveRecord::Rollback
end
end
def destroy
ActiveRecord::Base.transaction do
begin
ApplyAction.where(container_type: "ApplySubject", container_id: @subject.id).destroy_all
@subject.destroy
rescue Exception => e
uid_logger_error(e.message)
tip_exception("实训路径删除失败")
raise ActiveRecord::Rollback
end
end
end
def choose_subject_shixun
@search = params[:search].strip if params[:search]
@type = params[:type]
# 超级管理员用户显示所有未隐藏的实训、非管理员显示合作团队用户的实训(对本单位公开且未隐藏)
if current_user.admin?
@shixuns = Shixun.select([:id, :name, :status, :myshixuns_count, :identifier, :averge_star]).where(hidden: 0)
else
none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id).to_i}").pluck(:shixun_id)
@shixuns = Shixun.select([:id, :name, :status, :myshixuns_count, :identifier, :averge_star]).where.not(id: none_shixun_ids).where(hidden: 0)
end
# 实训课程的所有标签
tag_ids = @shixuns.joins(:shixun_tag_repertoires).pluck(:tag_repertoire_id).uniq
@tags = TagRepertoire.select([:id, :name]).where(id: tag_ids)
unless params[:search].blank?
@shixuns = @shixuns.joins(:user).where("shixuns.name like ? or concat(users.lastname, users.firstname) like ?",
"%#{@search}%", "%#{@search}%").distinct
end
unless @type.nil? || @type == "" || @type == "all"
shixun_ids = ShixunTagRepertoire.where(tag_repertoire_id: @type).pluck(:shixun_id).uniq
@shixuns = @shixuns.where(id: shixun_ids)
end
@shixuns = @shixuns.reorder("created_at desc")
@shixuns_count = @shixuns.size
## 分页参数
page = params[:page] || 1
@shixuns = @shixuns.page(page).per(10)
@shixuns = @shixuns.includes(:myshixuns)
end
def append_to_stage
@shixuns = Shixun.where(id: params[:shixun_id]).order("id desc")
end
def choose_course
course_ids = Course.find_by_sql("SELECT c.id FROM courses c, course_members m
WHERE m.course_id = c.id AND m.role in (1,2,3)
AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0").map(&:id)
@courses = Course.where(id: course_ids)
@none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id).to_i}").pluck(:shixun_id)
end
def send_to_course
@course = Course.find_by!(id: params[:course_id])
stages = @subject.stages.where(id: @subject.stage_shixuns.where(shixun_id: params[:shixun_ids]).pluck(:stage_id))
course_module = @course.course_modules.where(module_type: "shixun_homework").first
ActiveRecord::Base.transaction do
begin
# 将实训课程下的所有已发布实训按顺序发送到课堂,同时创建与章节同名的实训作业目录
stages.each do |stage|
category = CourseSecondCategory.where(name: stage.name, course_id: @course.id, category_type: "shixun_homework").first ||
CourseSecondCategory.create!(name: stage.name, course_id: @course.id, category_type: "shixun_homework",
course_module_id: course_module.id, position: course_module.course_second_categories.count + 1)
stage.shixuns.where(id: params[:shixun_ids], status: 2).each do |shixun|
homework = HomeworksService.new.create_homework shixun, @course, category, current_user
end
end
rescue Exception => e
uid_logger(e.message)
tip_exception(e.message)
raise ActiveRecord::Rollback
end
end
end
def publish
apply = ApplyAction.where(container_type: "ApplySubject", container_id: @subject.id).order("created_at desc").first
if apply && apply.status == 0
@status = 0
else
@subject.update_attributes(status: 1)
ApplyAction.create(container_type: "ApplySubject", container_id: @subject.id, user_id: current_user.id, status: 0)
begin
status = Educoder::Sms.send(mobile: '18711011226', send_type:'publish_subject' , name: '管理员')
rescue => e
uid_logger_error("发送验证码出错: #{e}")
end
@status = 1
end
end
def cancel_publish
begin
apply = ApplyAction.where(container_type: "ApplySubject", container_id: @subject.id).order("created_at desc").first
if apply && apply.status == 0
apply.update_attributes(status: 3)
apply.tidings.destroy_all
end
@subject.update_attributes(status: 0)
rescue => e
uid_logger_error(e.message)
tip_exception("撤销申请失败")
raise ActiveRecord::Rollback
end
end
def cancel_has_publish
begin
@subject.update_attributes(:status => 0)
rescue => e
uid_logger_error(e.message)
tip_exception("撤销发布失败")
raise ActiveRecord::Rollback
end
end
def search_members
tip_exception("搜索内容不能为空") unless params[:search]
page = params[:page] || 1
member_ids = @subject.subject_members.map(&:user_id).join(',')
condition = "%#{params[:search].strip}%".gsub(" ","")
@users = User.where("id not in (?) and status = 1 and LOWER(concat(lastname, firstname, login, mail)) LIKE ?", member_ids, "#{condition}")
@users = @users.page(page).per(10)
@users = @users.includes(:user_extension)
end
def add_subject_members
# tip_exception(403, "没权限操作") if !current_user.admin?
tip_exception("user_ids 不能为空!") if params[:user_ids].blank?
memberships = params[:user_ids]
memberships.each do |member|
if SubjectMember.where(user_id: member, subject_id: @subject.id).count == 0
user = User.find_by!(id: member)
SubjectMember.create!(user_id: member, subject_id: @subject.id, role: 2, position: @subject.subject_members.size + 1) if user.present?
end
end
end
# 删除实训
# DELETE: /api/subejcts/:id/delete_member
def delete_member
tip_exception(403, "没权限操作") unless current_user.manager_of_subject?(@subject)
tip_exception('用户id不能为空') if params[:user_id].blank?
user = @subject.subject_members.where(:user_id => params[:user_id], :role => 2).first
tip_exception("管理员用户不允许删除,或用户不存在") if user.blank?
ActiveRecord::Base.transaction do
begin
@subject.subject_members.where("position > #{user.position}").update_all("position = position - 1")
user.destroy
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
raise ActiveRecord::Rollback
end
end
end
# 合作者上移
def up_member_position
tip_exception('用户id不能为空') if params[:user_id].blank?
ActiveRecord::Base.transaction do
begin
member = @subject.subject_members.where(user_id: params[:user_id]).first
# position为1时不能再往上移
tip_exception('不能再上移了') if member.position == 1
up_member = @subject.subject_members.where(position: member.position - 1).first
up_member.update_attribute(:position, member.position)
member.update_attribute(:position, member.position - 1)
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
raise ActiveRecord::Rollback
end
end
end
# 合作者下移
def down_member_position
tip_exception('用户id不能为空') if params[:user_id].blank?
ActiveRecord::Base.transaction do
begin
member = @subject.subject_members.where(user_id: params[:user_id]).first
# position已经是最大值时不能再往下移
tip_exception('不能再下移了') if member.position == @subject.subject_members.size
down_member = @subject.subject_members.where(:position => member.position + 1).first
down_member.update_attribute(:position, member.position)
member.update_attribute(:position, member.position + 1)
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
raise ActiveRecord::Rollback
end
end
end
def statistics
@learn_count = @subject.member_count
shixun_ids = @subject.stage_shixuns.pluck(:shixun_id)
# 受用课堂(已经发布的实训(在此路径中的实训)作业的个数)
homework_common_id = HomeworkCommonsShixun.where(shixun_id: shixun_ids).pluck(:homework_common_id).uniq
homework_common_id = homework_common_id.blank? ? -1 : homework_common_id.join(",")
courses = Course.find_by_sql("select c.id, c.school_id from courses c right join homework_commons hc on c.id = hc.course_id where c.is_delete = 0
and c.school_id is not null and hc.publish_time < '#{Time.now}' and hc.id in (#{(homework_common_id)})")
course_ids = courses.pluck(:id).uniq
@course_count = course_ids.length
# 受用院校
school_ids = courses.pluck(:school_id).uniq
@schools_count = school_ids.length
# 采用课堂情况
@schools = School.select([:id, :name]).where(id: school_ids)
@schools =
@schools.map do |s|
school_courses = Course.where(id: course_ids, school_id: s.id)
course_count = school_courses.count
student_count = StudentsForCourse.where(course_id: school_courses.pluck(:id)).count
homework_count = HomeworkCommon.find_by_sql("select count(*) cnt from homework_commons hc join courses c on hc.course_id = c.id
where c.school_id = #{s.id} and hc.id in(#{homework_common_id})").first.try(:cnt)
s.attributes.dup.merge({name: s.name, course_count: course_count, student_count: student_count,homework_count: homework_count})
end
@schools = @schools.sort{|x,y| y['homework_count'] <=> x['homework_count']}
@school_total_count = @schools.size
page = params[:page] || 1
@schools = @schools[(page.to_i-1)*10, 10]
# TODO: 这个可以异步加载,让页面刷新完成后再加载图形数据
# 章节使用情况
@stage_user_info = []
@sum = 0 #总数
@subject.stages.includes(:stage_shixuns).each do |stage|
shixun_ids = stage.stage_shixuns.pluck(:shixun_id)
if shixun_ids.present?
homework_common_id = HomeworkCommonsShixun.where(shixun_id: shixun_ids).pluck(:homework_common_id).uniq
if homework_common_id.present?
publish_homework = HomeworkDetailManual.where("homework_common_id in(?) and comment_status > 0", homework_common_id.join(",")).pluck(:homework_common_id)
use_count = publish_homework.present? ? HomeworkCommon.find_by_sql("select count(*) cnt from homework_commons hc join courses c on hc.course_id = c.id
where hc.id in(#{publish_homework.join(",")}) and c.school_id is not null").first.try(:cnt) : 0
@sum += use_count
else
@sum += 0
use_count = 0
end
@stage_user_info << use_count
else
@sum += 0
@stage_user_info << 0
end
end
end
def shixun_report
end
def school_report
@schools = School.find_by_sql("select count(ms.id) ue_count, s.id, s.name school_name from user_extensions ue,
myshixuns ms, schools s where ue.user_id = ms.user_id and ms.shixun_id in (select shixun_id from
stage_shixuns where subject_id = '#{@subject.id}') and s.id = ue.school_id group by ue.school_id
order by ue_count desc limit 10")
end
private
def subject_params
tip_exception("实训路径名称不能为空") if params[:name].blank?
tip_exception("实训路径简介不能为空") if params[:description].blank?
tip_exception("实训路径学习须知不能为空") if params[:learning_notes].blank?
params.require(:subject).permit(:name, :description, :learning_notes)
end
def find_subject
@subject = Subject.find_by!(id: params[:id])
unless @subject.status == 2 || current_user.manager_of_subject?(@subject)
tip_exception("403", "")
end
end
def allowed
unless current_user.manager_of_subject?(@subject)
tip_exception("403", "")
end
end
end

@ -23,4 +23,26 @@ if @subject.excellent
json.course_identity @user.course_identity(course)
json.course_status subject_course_status course
end
end
json.members @members do |member|
json.partial! 'subject_member', locals: { user: member.user }
json.role member.role
end
# 技能标签
json.tags @tags do |tag|
unless tag.blank?
json.tag_name tag
json.status @user_tags.include?(tag)
end
end
# 我的进展
json.progress do
json.my_score @subject.my_subject_score
json.all_score @subject.all_score
json.learned @subject.my_subject_progress
json.time @subject.my_consume_time
end

@ -198,6 +198,8 @@ function generateNewIndexJsp() {
var result = data.replace('/js/js_min_all.js', `${cdnHost}/react/build/js/js_min_all.js?v=${newVersion}`)
// .replace('/js/js_min_all_2.js', `${cdnHost}/react/build/js/js_min_all_2.js?v=${newVersion}`)
// ${cdnHost} 加了cdn后这个文件里的字体文件加载会有跨域的报错 ../fonts/fontawesome-webfont.eot
// TODO tpi 评测结果关闭也使用了fontawesome
.replace('/css/css_min_all.css', `${cdnHost}/react/build/css/css_min_all.css?v=${newVersion}`)
.replace('/css/iconfont.css', `${cdnHost}/react/build/css/iconfont.css?v=${newVersion}`)
.replace(/\/js\/create_kindeditor.js/g, `${cdnHost}/react/build/js/create_kindeditor.js?v=${newVersion}`)

@ -306,7 +306,7 @@ class App extends Component {
<Trialapplicationreview {...this.props} {...this.state}></Trialapplicationreview>
<Addcourses {...this.props} {...this.state}/>
<AccountProfile {...this.props} {...this.state}/>
{/*<Certifiedprofessional {...this.props} {...this.state} />*/}
{/*<Certifiedprofessional {...this.props} {...this.state}/>*/}
<Router>
<Switch>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

@ -213,11 +213,9 @@ class Addcourses extends Component{
student:student
}
).then((response) => {
console.log(217);
console.log(response);
if(response === undefined){
this.setState({
Addcoursestype:false,
// Addcoursestype:false,
isSpin:false
});
return
@ -260,7 +258,7 @@ class Addcourses extends Component{
});
this.setState({
Addcoursestype:false
});
})
if(Addcoursestype===true){
this.props.hideAddcoursestype();
}
@ -275,15 +273,16 @@ class Addcourses extends Component{
// })
}
this.setState({
this.setState({
Addcoursestype:false,
isSpin:false
})
});
}).catch((error) => {
console.log(error);
console.log("报错了报错报错了");
console.log(error)
this.setState({
Addcoursestype:false,
isSpin:false
})
});
})
// if(value===0){

@ -7,7 +7,7 @@ import moment from 'moment';
import Modals from '../../modals/Modals';
const Option = Select.Option;
const dateFormat ="YYYY-MM-DD HH:mm"
function range(start, end) {
const result = [];
@ -131,7 +131,7 @@ class Selectsetting extends Component{
getalldata=()=>{
getalldata=()=>{
}
componentDidUpdate = (prevProps) => {
@ -139,9 +139,9 @@ class Selectsetting extends Component{
if ( prevProps.visible != this.props.visible ) {
console.log(prevProps)
console.log(this.props)
this.setState({
visible:this.props.visible
})
this.setState({
visible:this.props.visible
})
this.getalldata()
}
@ -205,23 +205,23 @@ class Selectsetting extends Component{
// }
// })
// if(unified_setting===false){
//
// course_groups.forEach((item,key)=>{
// if(item.course_group_id===undefined){
// this.setState({
// course_group_idtypes:true
// })
// return
// }
// })
//
// }
// if(unified_setting===false){
//
// course_groups.forEach((item,key)=>{
// if(item.course_group_id===undefined){
// this.setState({
// course_group_idtypes:true
// })
// return
// }
// })
//
// }
let coursesId=this.props.match.params.coursesId;
let attachmentId=this.props.attachmentId;
let url="/files/"+this.props.discussMessageid+".json";
let url="/files/"+this.props.discussMessageid+".json";
//
axios.put(url,{
course_id:coursesId,
@ -298,7 +298,7 @@ class Selectsetting extends Component{
onAttachmentRemove = (file) => {
// const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
axios.delete(url, {
})
.then((response) => {
@ -368,7 +368,7 @@ class Selectsetting extends Component{
newlist.push( {
course_group_id : undefined,
publish_time :""
// moment(new Date()).format('YYYY-MM-DD HH:mm')
// moment(new Date()).format('YYYY-MM-DD HH:mm')
})
this.setState({
course_groups:newlist
@ -381,7 +381,7 @@ class Selectsetting extends Component{
width: 600,
// https://github.com/ant-design/ant-design/issues/15505
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
// showUploadList: false,
// showUploadList: false,
action: `${getUrl()}/api/attachments.json`,
onChange: this.handleChange,
onRemove: this.onAttachmentRemove,
@ -463,7 +463,7 @@ class Selectsetting extends Component{
<div className="pl20 pr20"
style={{"Height":"204px"}}>
style={{"Height":"204px"}}>
<style>{`
.color-grey-9a{color: #9A9A9A !important;}
@ -487,7 +487,7 @@ class Selectsetting extends Component{
{datalist&&datalist.attachment_histories.length===0?"":<span className={"newcolor-orange fl"}>当前版本</span>}
</li>
<li className="fl edu-txt-left task-hide paddingl5 "
style={{width: '76px'}}> {datalist&&datalist.downloads_count} </li>
style={{width: '76px'}}> {datalist&&datalist.downloads_count} </li>
<li className="fl paddingl10 " style={{width: '100px'}}> {datalist&&datalist.quotes} </li>
<li className="fl paddingl10 datastyle">
{moment(datalist&&datalist.created_on).format('YYYY-MM-DD HH:mm')==="Invalid date"?"":moment(datalist&&datalist.created_on).format('YYYY-MM-DD HH:mm')}
@ -495,21 +495,21 @@ class Selectsetting extends Component{
</div>
{datalist&&datalist.attachment_histories.map((item,key)=>{
return(
<div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" key={key}>
<li className="fl" style={{width: '241px'}}>
<span className={"isabox"} title={item.title}> {item.title} </span>
{/*<span className={"newcolor-orange fl"}>当前版本</span>*/}
</li>
<li className="fl edu-txt-left task-hide paddingl5 "
style={{width: '76px'}}> {item.downloads_count} </li>
<li className="fl paddingl10 " style={{width: '100px'}}> {item.quotes} </li>
<li className="fl paddingl10 datastyle">
{moment(item.created_on).format('YYYY-MM-DD HH:mm')==="Invalid date"?"":moment(item.created_on).format('YYYY-MM-DD HH:mm')}
</li>
</div>
)
})}
return(
<div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" key={key}>
<li className="fl" style={{width: '241px'}}>
<span className={"isabox"} title={item.title}> {item.title} </span>
{/*<span className={"newcolor-orange fl"}>当前版本</span>*/}
</li>
<li className="fl edu-txt-left task-hide paddingl5 "
style={{width: '76px'}}> {item.downloads_count} </li>
<li className="fl paddingl10 " style={{width: '100px'}}> {item.quotes} </li>
<li className="fl paddingl10 datastyle">
{moment(item.created_on).format('YYYY-MM-DD HH:mm')==="Invalid date"?"":moment(item.created_on).format('YYYY-MM-DD HH:mm')}
</li>
</div>
)
})}
</div>
<style>{`
.popups{
@ -571,21 +571,21 @@ class Selectsetting extends Component{
<p className={"winth540"}>
{
this.state.fileListtype===true?
<div>
<Tooltip placement="bottom" title={
<pre>
this.state.fileListtype===true?
<div>
<Tooltip placement="bottom" title={
<pre>
每次只能上传一个资源<br/>删除下面资源可重新上传
</pre>
}>
<Button className="uploadBtns">
更新版本
</Button>
</Tooltip>
<span>(单个文件最大150M)</span>
</div>
:""
}>
<Button className="uploadBtns">
更新版本
</Button>
</Tooltip>
<span>(单个文件最大150M)</span>
</div>
:""
}
<Upload {...uploadProps} fileList={this.state.fileList} className="upload_1">
@ -600,121 +600,121 @@ class Selectsetting extends Component{
</p>
{/*<style>*/}
{/*{*/}
{/*`*/}
{/*.maxwidth400{*/}
{/*max-width: 400px;*/}
{/*overflow: hidden;*/}
{/*text-overflow: ellipsis;*/}
{/*white-space: nowrap;*/}
{/*}*/}
{/*`*/}
{/*}*/}
{/*{*/}
{/*`*/}
{/*.maxwidth400{*/}
{/*max-width: 400px;*/}
{/*overflow: hidden;*/}
{/*text-overflow: ellipsis;*/}
{/*white-space: nowrap;*/}
{/*}*/}
{/*`*/}
{/*}*/}
{/*</style>*/}
{/*{this.state.fileList.length===0?"":this.state.fileList.map((item,key)=>{*/}
{/*return(*/}
{/*<p className="color-grey mt10" key={key} >*/}
{/*<a className="color-grey fl">*/}
{/*<i className="font-14 color-green iconfont icon-fujian mr8" aria-hidden="true"></i>*/}
{/*</a>*/}
{/*<span className="mr12 color9B9B maxwidth400 fl" length="58">*/}
{/*{item.name}*/}
{/*</span>*/}
{/*<span className="color656565 mt2 color-grey-6 font-12 mr8">*/}
{/*{item.response===undefined?"":isNaN(bytesToSize(item.filesize))?"123":bytesToSize(item.filesize)}*/}
{/*</span>*/}
{/*<i className="font-14 iconfont icon-guanbi "*/}
{/*id={item.response===undefined?"":item.response.id}*/}
{/*aria-hidden="true" onClick={()=>this.onAttachmentRemove(item.response===undefined?"":item.response.id&&item.response.id)}></i>*/}
{/*</p>*/}
{/*)*/}
{/*return(*/}
{/*<p className="color-grey mt10" key={key} >*/}
{/*<a className="color-grey fl">*/}
{/*<i className="font-14 color-green iconfont icon-fujian mr8" aria-hidden="true"></i>*/}
{/*</a>*/}
{/*<span className="mr12 color9B9B maxwidth400 fl" length="58">*/}
{/*{item.name}*/}
{/*</span>*/}
{/*<span className="color656565 mt2 color-grey-6 font-12 mr8">*/}
{/*{item.response===undefined?"":isNaN(bytesToSize(item.filesize))?"123":bytesToSize(item.filesize)}*/}
{/*</span>*/}
{/*<i className="font-14 iconfont icon-guanbi "*/}
{/*id={item.response===undefined?"":item.response.id}*/}
{/*aria-hidden="true" onClick={()=>this.onAttachmentRemove(item.response===undefined?"":item.response.id&&item.response.id)}></i>*/}
{/*</p>*/}
{/*)*/}
{/*})}*/}
{this.state.newfileListtypes===true?<p className={"color-red"}>请先上传资源</p>:""}
{/*<p className={"winth540"}>*/}
{/*<style>{`*/}
{/*.ant-checkbox-wrapper{*/}
{/*margin-left:0px !important;*/}
{/*margin-top:10px;*/}
{/*}*/}
{/*`}</style>*/}
{/*<div className={this.state.fileListtype===true?"mt30":""}>*/}
{/*<Checkbox*/}
{/*checked={is_public}*/}
{/*onChange={this.onChangepublics}>*/}
{/*<span className={"font-14"}>勾选后所有用户可见,否则仅课堂成员可见</span>*/}
{/*</Checkbox>*/}
{/*</div>*/}
{/*/!*{this.props.has_course_groups&&this.props.has_course_groups===true?:""}*!/*/}
{/*/!*{this.state.course_groupss&&this.state.course_groupss.length>0?<Checkbox*!/*/}
{/*/!*checked={unified_setting}*!/*/}
{/*/!*onChange={this.onChangesettings}>*!/*/}
{/*/!*<span>统一设置</span><span className={"font-14 color-grey-9"}>(选中则所有分班使用相同的发布设置,否则各个单独设置)</span>*!/*/}
{/*/!*</Checkbox>:""}*!/*/}
{/*<style>*/}
{/*{`*/}
{/*.Selectleft20{*/}
{/*margin-left: 20px !important;*/}
{/*width: 176px;*/}
{/*height: 40px; */}
{/*}*/}
{/*.resourcebox{*/}
{/*max-height:150px;*/}
{/*overflow: auto;*/}
{/*}*/}
{/*`}*/}
{/*</style>*/}
{/*/!*this.props.has_course_groups&&this.props.has_course_groups===true?:""*!/*/}
{/*<div className={"resourcebox"}>*/}
{/*{unified_setting===false?*/}
{/*this.state.course_groups&&this.state.course_groups.map((item,key)=>{*/}
{/*return(*/}
{/*<div className={"mt10 "} key={key}>*/}
{/*<Select placeholder="请选择分班名称"*/}
{/*value={item.course_group_id}*/}
{/*style={{ width: 200 }}*/}
{/*onChange={(e,index)=>this.selectassigngroups(e,index,key)}*/}
{/*>*/}
{/*{ this.state.course_groupss&&this.state.course_groupss.map((item,key)=>{*/}
{/*return(*/}
{/*<Option value={item.id} key={key}>{item.name}</Option>*/}
{/*)*/}
{/*})}*/}
{/*</Select>*/}
{/*<DatePicker*/}
{/*showToday={false}*/}
{/*dropdownClassName="hideDisable"*/}
{/*showTime={{ format: 'HH:mm' }}*/}
{/*format="YYYY-MM-DD HH:mm"*/}
{/*locale={locale}*/}
{/*placeholder="请选择发布时间"*/}
{/*id={"startimes"}*/}
{/*className={"Selectleft20"}*/}
{/*width={"200px"}*/}
{/*value={item.publish_time===undefined||item.publish_time===""?"":item.publish_time===null?"":moment(item.publish_time, dateFormat)}*/}
{/*onChange={(e,index)=>this.onChangeTimepublishs(e,index,key)}*/}
{/*// onChange={ this.onChangeTimepublish }*/}
{/*disabledTime={disabledDateTime}*/}
{/*disabledDate={disabledDate}*/}
{/*/>*/}
{/*{key!=0?<i className="iconfont icon-shanchu color-grey-c font-14 font-n ml20" onClick={()=>this.deletegrouppublish(key)}></i>:""}*/}
{/*{key===course_groups.length-1?<i className="iconfont icon-tianjiafangda color-green ml15" onClick={this.addgrouppublish}></i>:""}*/}
{/*</div>*/}
{/*)*/}
{/*}):""}*/}
{/*</div>*/}
<p className={"winth540"}>
<style>{`
.ant-checkbox-wrapper{
margin-left:0px !important;
margin-top:10px;
}
`}</style>
{/*</p>*/}
<div className={this.state.fileListtype===true?"mt30":""}>
<Checkbox
checked={is_public}
onChange={this.onChangepublics}>
<span className={"font-14"}>勾选后所有用户可见否则仅课堂成员可见</span>
</Checkbox>
</div>
{/*{this.props.has_course_groups&&this.props.has_course_groups===true?:""}*/}
{/*{this.state.course_groupss&&this.state.course_groupss.length>0?<Checkbox*/}
{/*checked={unified_setting}*/}
{/*onChange={this.onChangesettings}>*/}
{/*<span>统一设置</span><span className={"font-14 color-grey-9"}>(选中则所有分班使用相同的发布设置,否则各个单独设置)</span>*/}
{/*</Checkbox>:""}*/}
<style>
{`
.Selectleft20{
margin-left: 20px !important;
width: 176px;
height: 40px;
}
.resourcebox{
max-height:150px;
overflow: auto;
}
`}
</style>
{/*this.props.has_course_groups&&this.props.has_course_groups===true?:""*/}
<div className={"resourcebox"}>
{unified_setting===false?
this.state.course_groups&&this.state.course_groups.map((item,key)=>{
return(
<div className={"mt10 "} key={key}>
<Select placeholder="请选择分班名称"
value={item.course_group_id}
style={{ width: 200 }}
onChange={(e,index)=>this.selectassigngroups(e,index,key)}
>
{ this.state.course_groupss&&this.state.course_groupss.map((item,key)=>{
return(
<Option value={item.id} key={key}>{item.name}</Option>
)
})}
</Select>
<DatePicker
showToday={false}
dropdownClassName="hideDisable"
showTime={{ format: 'HH:mm' }}
format="YYYY-MM-DD HH:mm"
locale={locale}
placeholder="请选择发布时间"
id={"startimes"}
className={"Selectleft20"}
width={"200px"}
value={item.publish_time===undefined||item.publish_time===""?"":item.publish_time===null?"":moment(item.publish_time, dateFormat)}
onChange={(e,index)=>this.onChangeTimepublishs(e,index,key)}
// onChange={ this.onChangeTimepublish }
disabledTime={disabledDateTime}
disabledDate={disabledDate}
/>
{key!=0?<i className="iconfont icon-shanchu color-grey-c font-14 font-n ml20" onClick={()=>this.deletegrouppublish(key)}></i>:""}
{key===course_groups.length-1?<i className="iconfont icon-tianjiafangda color-green ml15" onClick={this.addgrouppublish}></i>:""}
</div>
)
}):""}
</div>
</p>
<style>
{`
#startime .ant-calendar-picker-icon{
@ -723,22 +723,22 @@ class Selectsetting extends Component{
`}
</style>
{unified_setting===true?
<p className={this.state.fileListtype===true?"mt30":""}>
<p className={"mt10"}>
<span>
<DatePicker
showToday={false}
dropdownClassName="hideDisable"
showTime={{ format: 'HH:mm' }}
format="YYYY-MM-DD HH:mm"
locale={locale}
placeholder="请选择发布时间"
id={"startime"}
width={"210px"}
value={datatime===undefined||datatime===""?"":moment(datatime, dateFormat)}
onChange={this.onChangeTimepublish}
disabledTime={disabledDateTime}
showToday={false}
dropdownClassName="hideDisable"
showTime={{ format: 'HH:mm' }}
format="YYYY-MM-DD HH:mm"
locale={locale}
placeholder="请选择发布时间"
id={"startime"}
width={"210px"}
value={datatime===undefined||datatime===""?"":moment(datatime, dateFormat)}
onChange={this.onChangeTimepublish}
disabledTime={disabledDateTime}
disabledDate={disabledDate}
/>
/>
</span>
</p>:""}
{/*{this.state.course_group_idtypes===true?<p className={"color-red"}>请选择分班</p>:""}*/}

@ -8,18 +8,18 @@ import moment from 'moment';
const CheckboxGroup = Checkbox.Group;
const Option = Select.Option;
function range(start, end) {
const result = [];
for (let i = start; i < end; i++) {
result.push(i);
}
return result;
const result = [];
for (let i = start; i < end; i++) {
result.push(i);
}
return result;
}
function disabledDateTime() {
return {
// disabledHours: () => range(0, 24).splice(4, 20),
disabledMinutes: () => range(1, 30).concat(range(31, 60)),
// disabledSeconds: () => [0, 60],
};
return {
// disabledHours: () => range(0, 24).splice(4, 20),
disabledMinutes: () => range(1, 30).concat(range(31, 60)),
// disabledSeconds: () => [0, 60],
};
}
function disabledDate(current) {
@ -29,63 +29,63 @@ function disabledDate(current) {
const dateFormat="YYYY-MM-DD HH:mm";
class Sendresource extends Component{
constructor(props){
super(props);
this.state={
group_ids:[],
fileList:[],
Modalstype:false,
Modalstopval:"",
ModalCancel:"",
ModalSave:"",
constructor(props){
super(props);
this.state={
group_ids:[],
fileList:[],
Modalstype:false,
Modalstopval:"",
ModalCancel:"",
ModalSave:"",
fileListtype:false,
loadtype:false,
is_unified_setting:true,
is_public:false,
datatime:undefined,
// moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
course_group_publish_times:[
{
course_group_id : undefined,
publish_time :""
}],
course_groups:undefined,
course_groups_count:undefined
}
}
componentDidMount() {
let coursesId=this.props.match.params.coursesId;
if(this.props.isAdmin()){
let url = `/courses/${coursesId}/all_course_groups.json`
axios.get(url, {
})
.then((response) => {
this.setState({
course_groups: response.data.course_groups,
course_groups_count:response.data.course_groups_count
})
})
.catch(function (error) {
console.log(error);
});
}
}
//勾选实训
shixunhomeworkedit=(list)=>{
this.setState({
group_ids:list
})
}
// 附件相关 START
handleChange = (info) => {
loadtype:false,
is_unified_setting:true,
is_public:false,
datatime:undefined,
// moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
course_group_publish_times:[
{
course_group_id : undefined,
publish_time :""
}],
course_groups:undefined,
course_groups_count:undefined
}
}
componentDidMount() {
let coursesId=this.props.match.params.coursesId;
if(this.props.isAdmin()){
let url = `/courses/${coursesId}/all_course_groups.json`
axios.get(url, {
})
.then((response) => {
this.setState({
course_groups: response.data.course_groups,
course_groups_count:response.data.course_groups_count
})
})
.catch(function (error) {
console.log(error);
});
}
}
//勾选实训
shixunhomeworkedit=(list)=>{
this.setState({
group_ids:list
})
}
// 附件相关 START
handleChange = (info) => {
let fileList = info.fileList;
if(info.file.status!="removed"){
@ -98,280 +98,280 @@ class Sendresource extends Component{
fileList: appendFileSizeToUploadFileAll(fileList),
});
}
}
}
// onAttachmentRemove = (file) => {
//
// onAttachmentRemove = (file) => {
//
// this.setState({
// fileListtype:false,
// })
// // confirm({
// // title: '确定要删除这个附件吗?',
// // okText: '确定',
// // cancelText: '取消',
// // // content: 'Some descriptions',
// // onOk: () => {
// // this.deleteAttachment(file)
// // },
// // onCancel() {
// // console.log('Cancel');
// // },
// // });
// // return false;
// // confirm({
// // title: '确定要删除这个附件吗?',
// // okText: '确定',
// // cancelText: '取消',
// // // content: 'Some descriptions',
// // onOk: () => {
// // this.deleteAttachment(file)
// // },
// // onCancel() {
// // console.log('Cancel');
// // },
// // });
// // return false;
//
// // this.setState({
// // Modalstype:true,
// // Modalstopval:'确定要删除这个附件吗?',
// // ModalSave: ()=>this.deleteAttachment(file),
// // ModalCancel:this.cancelAttachment
// // })
// // return false;
// // this.setState({
// // Modalstype:true,
// // Modalstopval:'确定要删除这个附件吗?',
// // ModalSave: ()=>this.deleteAttachment(file),
// // ModalCancel:this.cancelAttachment
// // })
// // return false;
//
// this.deleteAttachment(file);
// }
// this.deleteAttachment(file);
// }
onAttachmentRemove = (file) => {
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
axios.delete(url, {
})
.then((response) => {
if (response.data) {
const { status } = response.data;
if (status == 0) {
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
axios.delete(url, {
})
.then((response) => {
if (response.data) {
const { status } = response.data;
if (status == 0) {
this.setState({
fileListtype:false,
fileList:[]
})
}
}
}
})
.catch(function (error) {
console.log(error);
});
}
})
.catch(function (error) {
console.log(error);
});
this.setState({
fileListtype:false,
})
}
ModalCancelModalCancel=()=>{
this.setState({
Modalstype:false,
Modalstopval:"",
ModalSave:this.ModalCancelModalCancel,
loadtype:false
})
this.props.Cancel()
}
Saves=()=>{
let id=this.props.categoryid;
let {fileList,description,is_public,is_unified_setting,datatime,course_group_publish_times} =this.state;
let newfileList=[];
for(var list of fileList){
newfileList.push(list.response.id)
}
if(newfileList.length===0){
this.setState({
fileListtype:false,
newfileListtype:true
})
}
ModalCancelModalCancel=()=>{
this.setState({
Modalstype:false,
Modalstopval:"",
ModalSave:this.ModalCancelModalCancel,
loadtype:false
})
this.props.Cancel()
}
Saves=()=>{
let id=this.props.categoryid;
let {fileList,description,is_public,is_unified_setting,datatime,course_group_publish_times} =this.state;
let newfileList=[];
for(var list of fileList){
newfileList.push(list.response.id)
}
if(newfileList.length===0){
this.setState({
newfileListtype:true
})
return
}
// if(is_unified_setting===false){
// course_group_publish_times.forEach((item,key)=>{
// if(item.course_group_id===undefined||item.publish_time===undefined){
// this.setState({
// course_group_publish_timestype:true
// })
// return
// }
// })
//
// }
if(description===undefined){
}else if(description.length>100){
this.setState({
descriptiontype:true
})
return
}
let coursesId=this.props.match.params.coursesId;
let attachmentId=this.props.attachmentId;
let url="/files/upload.json";
axios.post(url,{
course_id:coursesId,
course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId,
attachment_ids:newfileList,
is_public:is_public,
is_unified_setting:is_unified_setting,
publish_time:is_unified_setting===true?datatime===undefined? moment(new Date()).format('YYYY-MM-DD HH:mm'):datatime:undefined,
description:description,
course_group_publish_times:is_unified_setting===false?course_group_publish_times:undefined
}).then((result)=>{
if(result.data.status===0){
// this.setState({
// Modalstype:true,
// Modalstopval:result.data.message,
// ModalSave:this.ModalCancelModalCancel,
// loadtype:true
// })
this.ModalCancelModalCancel();
this.props.updataleftNavfun();
// this.props.showNotification(result.data.message);
this.props.showNotification("上传资源成功");
this.props.setupdate(this.props.attachmentId)
}
})
}
settextarea=(e)=>{
this.setState({
description:e.target.value
})
}
onChangesetting=(e)=>{
this.setState({
is_unified_setting:e.target.checked
})
}
onChangepublic=(e)=>{
this.setState({
is_public:e.target.checked
})
}
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<newgroup_publish.length; i++){
if(i===parseInt(key)){
newgroup_publish[i].publish_time=handleDateString(dateString);
}
}
this.setState({
course_group_publish_times:newgroup_publish,
})
}
}
selectassigngroups=(e,index,key)=>{
let {course_group_publish_times}=this.state;
let newgroup_publish=course_group_publish_times;
for(var i=0; i<newgroup_publish.length; i++){
if(i===parseInt(key)){
newgroup_publish[i].course_group_id=index.props.value;
}
}
this.setState({
course_group_publish_times:newgroup_publish,
})
}
deletegrouppublish=(key)=>{
let newlist=this.state.course_group_publish_times;
newlist.splice(key,1);
this.setState({
course_group_publish_times:newlist
})
}
addgrouppublish=()=>{
let newlist=this.state.course_group_publish_times;
newlist.push( {
course_group_id : undefined,
publish_time :undefined
})
this.setState({
course_group_publish_times:newlist
})
}
render(){
let {settextarea,newfileListtype,descriptiontype,
course_group_publish_timestype,
Modalstopval,
ModalCancel,
ModalSave,
loadtype,
is_unified_setting,
is_public,
datatime,
course_group_publish_times,
course_groups
}=this.state;
const uploadProps = {
width: 600,
// showUploadList:false,
action: `${getUrl()}/api/attachments.json`,
onChange: this.handleChange,
onRemove: this.onAttachmentRemove,
beforeUpload: (file) => {
// console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) {
message.error('文件大小必须小于150MB!');
}
return isLt150M;
},
};
return(
<div>
{/*提示*/}
<Modals
modalsType={this.state.Modalstype}
modalsTopval={this.state.Modalstopval}
modalCancel={this.state.ModalCancel}
modalSave={this.state.ModalSave}
loadtype= {this.state.loadtype}
/>
<Modal
keyboard={false}
className={"HomeworkModal"}
title={this.props.modalname}
visible={this.props.visible}
closable={false}
footer={null}
destroyOnClose={true}
>
<div className="task-popup-content">
<p className="task-popup-text-center font-16">
<span className={"color-blue underline"}> </span>
</p>
<style>{`
return
}
// if(is_unified_setting===false){
// course_group_publish_times.forEach((item,key)=>{
// if(item.course_group_id===undefined||item.publish_time===undefined){
// this.setState({
// course_group_publish_timestype:true
// })
// return
// }
// })
//
// }
if(description===undefined){
}else if(description.length>100){
this.setState({
descriptiontype:true
})
return
}
let coursesId=this.props.match.params.coursesId;
let attachmentId=this.props.attachmentId;
let url="/files/upload.json";
axios.post(url,{
course_id:coursesId,
course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId,
attachment_ids:newfileList,
is_public:is_public,
is_unified_setting:is_unified_setting,
publish_time:is_unified_setting===true?datatime===undefined? moment(new Date()).format('YYYY-MM-DD HH:mm'):datatime:undefined,
description:description,
course_group_publish_times:is_unified_setting===false?course_group_publish_times:undefined
}).then((result)=>{
if(result.data.status===0){
// this.setState({
// Modalstype:true,
// Modalstopval:result.data.message,
// ModalSave:this.ModalCancelModalCancel,
// loadtype:true
// })
this.ModalCancelModalCancel();
this.props.updataleftNavfun();
// this.props.showNotification(result.data.message);
this.props.showNotification("上传资源成功");
this.props.setupdate(this.props.attachmentId)
}
})
}
settextarea=(e)=>{
this.setState({
description:e.target.value
})
}
onChangesetting=(e)=>{
this.setState({
is_unified_setting:e.target.checked
})
}
onChangepublic=(e)=>{
this.setState({
is_public:e.target.checked
})
}
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<newgroup_publish.length; i++){
if(i===parseInt(key)){
newgroup_publish[i].publish_time=handleDateString(dateString);
}
}
this.setState({
course_group_publish_times:newgroup_publish,
})
}
}
selectassigngroups=(e,index,key)=>{
let {course_group_publish_times}=this.state;
let newgroup_publish=course_group_publish_times;
for(var i=0; i<newgroup_publish.length; i++){
if(i===parseInt(key)){
newgroup_publish[i].course_group_id=index.props.value;
}
}
this.setState({
course_group_publish_times:newgroup_publish,
})
}
deletegrouppublish=(key)=>{
let newlist=this.state.course_group_publish_times;
newlist.splice(key,1);
this.setState({
course_group_publish_times:newlist
})
}
addgrouppublish=()=>{
let newlist=this.state.course_group_publish_times;
newlist.push( {
course_group_id : undefined,
publish_time :undefined
})
this.setState({
course_group_publish_times:newlist
})
}
render(){
let {settextarea,newfileListtype,descriptiontype,
course_group_publish_timestype,
Modalstopval,
ModalCancel,
ModalSave,
loadtype,
is_unified_setting,
is_public,
datatime,
course_group_publish_times,
course_groups
}=this.state;
const uploadProps = {
width: 600,
// showUploadList:false,
action: `${getUrl()}/api/attachments.json`,
onChange: this.handleChange,
onRemove: this.onAttachmentRemove,
beforeUpload: (file) => {
// console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) {
message.error('文件大小必须小于150MB!');
}
return isLt150M;
},
};
return(
<div>
{/*提示*/}
<Modals
modalsType={this.state.Modalstype}
modalsTopval={this.state.Modalstopval}
modalCancel={this.state.ModalCancel}
modalSave={this.state.ModalSave}
loadtype= {this.state.loadtype}
/>
<Modal
keyboard={false}
className={"HomeworkModal"}
title={this.props.modalname}
visible={this.props.visible}
closable={false}
footer={null}
destroyOnClose={true}
>
<div className="task-popup-content">
<p className="task-popup-text-center font-16">
<span className={"color-blue underline"}> </span>
</p>
<style>{`
.uploadBtn.ant-btn {
border: none;
color: #4CACFF;
@ -404,7 +404,7 @@ class Sendresource extends Component{
margin-top:31px;
}
`}</style>}
<p className={"winth540"}>
<p className={"winth540"}>
{
@ -433,152 +433,152 @@ class Sendresource extends Component{
<span className={"ml10"}>(单个文件最大150M)</span>
</span>:""}
</Upload>
</p>
</p>
{/*<style>*/}
{/*{*/}
{/*`*/}
{/*.maxwidth400{*/}
{/*max-width: 400px;*/}
{/*overflow: hidden;*/}
{/*text-overflow: ellipsis;*/}
{/*white-space: nowrap;*/}
{/*}*/}
{/*`*/}
{/*}*/}
{/*{*/}
{/*`*/}
{/*.maxwidth400{*/}
{/*max-width: 400px;*/}
{/*overflow: hidden;*/}
{/*text-overflow: ellipsis;*/}
{/*white-space: nowrap;*/}
{/*}*/}
{/*`*/}
{/*}*/}
{/*</style>*/}
{/*{this.state.fileList.length===0?"":this.state.fileList.map((item,key)=>{*/}
{/*debugger*/}
{/*return(*/}
{/*<p className="color-grey mt10" key={key} >*/}
{/*<a className="color-grey fl">*/}
{/*<i className="font-14 color-green iconfont icon-fujian mr8" aria-hidden="true"></i>*/}
{/*</a>*/}
{/*<span className="mr12 color9B9B maxwidth400 fl" length="58">*/}
{/*{item.name}*/}
{/*</span>*/}
{/*<span className="color656565 mt2 color-grey-6 font-12 mr8">*/}
{/*{item.response===undefined?"":isNaN(bytesToSize(item.filesize))?"":bytesToSize(item.filesize)}*/}
{/*</span>*/}
{/*<i className="font-14 iconfont icon-guanbi "*/}
{/*id={item.response===undefined?"":item.response.id}*/}
{/*aria-hidden="true" onClick={()=>this.onAttachmentRemove(item.response===undefined?"":item.response.id&&item.response.id)}></i>*/}
{/*</p>*/}
{/*)*/}
{/*debugger*/}
{/*return(*/}
{/*<p className="color-grey mt10" key={key} >*/}
{/*<a className="color-grey fl">*/}
{/*<i className="font-14 color-green iconfont icon-fujian mr8" aria-hidden="true"></i>*/}
{/*</a>*/}
{/*<span className="mr12 color9B9B maxwidth400 fl" length="58">*/}
{/*{item.name}*/}
{/*</span>*/}
{/*<span className="color656565 mt2 color-grey-6 font-12 mr8">*/}
{/*{item.response===undefined?"":isNaN(bytesToSize(item.filesize))?"":bytesToSize(item.filesize)}*/}
{/*</span>*/}
{/*<i className="font-14 iconfont icon-guanbi "*/}
{/*id={item.response===undefined?"":item.response.id}*/}
{/*aria-hidden="true" onClick={()=>this.onAttachmentRemove(item.response===undefined?"":item.response.id&&item.response.id)}></i>*/}
{/*</p>*/}
{/*)*/}
{/*})}*/}
{newfileListtype===true&&this.state.fileListtype===false?<p className={"color-red"}>请先上传资源</p>:""}
{/*<p className={"winth540"}>*/}
{/*<style>{`*/}
{/*.ant-checkbox-wrapper{*/}
{/*margin-left:0px !important;*/}
{/*margin-top:10px;*/}
{/*}*/}
{/*`}</style>*/}
{/*<div className={this.state.fileListtype===true?"mt30":""}></div><Checkbox checked={is_public} onChange={this.onChangepublic}>*/}
{/*<span className={"font-14"}>勾选后所有用户可见,否则仅课堂成员可见</span>*/}
{/*</Checkbox>*/}
{/*/!*{this.state.course_groups_count&&this.state.course_groups_count>0?<Checkbox checked={is_unified_setting} onChange={this.onChangesetting}>*!/*/}
{/*/!*<span>统一设置</span><span className={"font-14 color-grey-9"}>(选中则所有分班使用相同的发布设置,否则各个单独设置)</span>*!/*/}
{/*/!*</Checkbox>:""}*!/*/}
{/*<style>{`*/}
{/*.Selectleft20{*/}
{/*margin-left: 20px !important;*/}
{/*width: 176px;*/}
{/*height: 40px; */}
{/*}*/}
{/*#startimes .ant-calendar-picker-icon{*/}
{/*margin-top:-11px;*/}
{/*}*/}
{/*.resourcebox{*/}
{/*max-height:150px;*/}
{/*overflow: auto;*/}
{/*}*/}
{/*`}</style>*/}
{/*<div className={"resourcebox"}>*/}
{/*{is_unified_setting===false?*/}
{/*course_group_publish_times.map((item,key)=>{*/}
{/*return(*/}
{/*<div className={"mt10"} key={key}>*/}
{/*<Select placeholder="请选择分班名称"*/}
{/*value={item.course_group_id}*/}
{/*style={{ width: 200 }}*/}
{/*onChange={(e,index)=>this.selectassigngroups(e,index,key)}*/}
{/*>*/}
{/*{course_groups&&course_groups.map((item,key)=>{*/}
{/*return(*/}
{/*<Option value={item.id} key={key}>{item.name}</Option>*/}
{/*)*/}
{/*})}*/}
{/*</Select>*/}
{/*<DatePicker*/}
{/*dropdownClassName="hideDisable"*/}
{/*showTime={{ format: 'HH:mm' }}*/}
{/*locale={locale}*/}
{/*showToday={false}*/}
{/*format={dateFormat}*/}
{/*placeholder="请选择发布时间"*/}
{/*id={"startimes"}*/}
{/*className={"Selectleft20 "}*/}
{/*width={"200px"}*/}
{/*value={item.publish_time===undefined||item.publish_time===""?undefined:moment(item.publish_time, dateFormat)}*/}
{/*onChange={(e,index)=>this.onChangeTimepublish(e,index,key,2)}*/}
{/*// onChange={ this.onChangeTimepublish }*/}
{/*disabledTime={disabledDateTime}*/}
{/*disabledDate={disabledDate}*/}
{/*/>*/}
{/*{key!=0?<i className="iconfont icon-shanchu color-grey-c font-14 font-n ml20" onClick={()=>this.deletegrouppublish(key)}></i>:""}*/}
{/*{key===course_group_publish_times.length-1&&key<this.state.course_groups_count-1?<i className="iconfont icon-tianjiafangda color-green ml15" onClick={this.addgrouppublish}></i>:""}*/}
{/*</div>*/}
{/*)*/}
{/*})*/}
{/*:""}*/}
{/*</div>*/}
{/*</p>*/}
{is_unified_setting===true?<p className={this.state.fileListtype===true?"mt30":"mt10"}>
{newfileListtype===true&&this.state.fileListtype===false?<p className={"color-red"}>请先上传资源</p>:""}
<p className={"winth540"}>
<style>{`
.ant-checkbox-wrapper{
margin-left:0px !important;
margin-top:10px;
}
`}</style>
<div className={this.state.fileListtype===true?"mt30":""}></div><Checkbox checked={is_public} onChange={this.onChangepublic}>
<span className={"font-14"}>勾选后所有用户可见否则仅课堂成员可见</span>
</Checkbox>
{/*{this.state.course_groups_count&&this.state.course_groups_count>0?<Checkbox checked={is_unified_setting} onChange={this.onChangesetting}>*/}
{/*<span>统一设置</span><span className={"font-14 color-grey-9"}>(选中则所有分班使用相同的发布设置,否则各个单独设置)</span>*/}
{/*</Checkbox>:""}*/}
<style>{`
.Selectleft20{
margin-left: 20px !important;
width: 176px;
height: 40px;
}
#startimes .ant-calendar-picker-icon{
margin-top:-11px;
}
.resourcebox{
max-height:150px;
overflow: auto;
}
`}</style>
<div className={"resourcebox"}>
{is_unified_setting===false?
course_group_publish_times.map((item,key)=>{
return(
<div className={"mt10"} key={key}>
<Select placeholder="请选择分班名称"
value={item.course_group_id}
style={{ width: 200 }}
onChange={(e,index)=>this.selectassigngroups(e,index,key)}
>
{course_groups&&course_groups.map((item,key)=>{
return(
<Option value={item.id} key={key}>{item.name}</Option>
)
})}
</Select>
<DatePicker
dropdownClassName="hideDisable"
showTime={{ format: 'HH:mm' }}
locale={locale}
showToday={false}
format={dateFormat}
placeholder="请选择发布时间"
id={"startimes"}
className={"Selectleft20 "}
width={"200px"}
value={item.publish_time===undefined||item.publish_time===""?undefined:moment(item.publish_time, dateFormat)}
onChange={(e,index)=>this.onChangeTimepublish(e,index,key,2)}
// onChange={ this.onChangeTimepublish }
disabledTime={disabledDateTime}
disabledDate={disabledDate}
/>
{key!=0?<i className="iconfont icon-shanchu color-grey-c font-14 font-n ml20" onClick={()=>this.deletegrouppublish(key)}></i>:""}
{key===course_group_publish_times.length-1&&key<this.state.course_groups_count-1?<i className="iconfont icon-tianjiafangda color-green ml15" onClick={this.addgrouppublish}></i>:""}
</div>
)
})
:""}
</div>
</p>
{is_unified_setting===true?<p className={"mt10"}>
<span>
<DatePicker
dropdownClassName="hideDisable"
showTime={{ format: 'HH:mm' }}
locale={locale}
format={dateFormat}
placeholder="请选择发布时间"
id={"startime"}
showToday={false}
width={"210px"}
value={datatime===undefined||datatime===""?undefined:moment(datatime, dateFormat)}
onChange={(e,index)=>this.onChangeTimepublish(e,index,undefined,1)}
disabledTime={disabledDateTime}
dropdownClassName="hideDisable"
showTime={{ format: 'HH:mm' }}
locale={locale}
format={dateFormat}
placeholder="请选择发布时间"
id={"startime"}
showToday={false}
width={"210px"}
value={datatime===undefined||datatime===""?undefined:moment(datatime, dateFormat)}
onChange={(e,index)=>this.onChangeTimepublish(e,index,undefined,1)}
disabledTime={disabledDateTime}
disabledDate={disabledDate}
/>
/>
</span>
</p>:""}
{/*{course_group_publish_timestype===true?<p className={"color-red mt10"}>请填写完整</p>:""}*/}
<textarea placeholder="请在此输入资源描述最大限制100个字符" className={"mt10"} value={this.state.description} onInput={this.settextarea} style={{
width: '100%',
height:'120px',
border:'1px solid rgba(234,234,234,1)',
padding: '10px'
}}></textarea>
{descriptiontype===true?<p className={"color-red"}>请输入资源描述最大限制100个字符</p>:""}
<div className="clearfix mt30 edu-txt-center mb10">
<a className="task-btn color-white mr70" onClick={this.props.Cancel}>{this.props.Cancelname}</a>
<a className="task-btn task-btn-orange" onClick={()=>this.Saves()}>{this.props.Savesname}</a>
</div>
</div>
</Modal>
</div>
)
}
</p>:""}
{/*{course_group_publish_timestype===true?<p className={"color-red mt10"}>请填写完整</p>:""}*/}
<textarea placeholder="请在此输入资源描述最大限制100个字符" className={"mt10"} value={this.state.description} onInput={this.settextarea} style={{
width: '100%',
height:'120px',
border:'1px solid rgba(234,234,234,1)',
padding: '10px'
}}></textarea>
{descriptiontype===true?<p className={"color-red"}>请输入资源描述最大限制100个字符</p>:""}
<div className="clearfix mt30 edu-txt-center mb10">
<a className="task-btn color-white mr70" onClick={this.props.Cancel}>{this.props.Cancelname}</a>
<a className="task-btn task-btn-orange" onClick={()=>this.Saves()}>{this.props.Savesname}</a>
</div>
</div>
</Modal>
</div>
)
}
}
export default Sendresource;

@ -2033,7 +2033,7 @@ class Studentshavecompletedthelist extends Component {
page:1,
})
}
this.Searchdatasys(this.state.order, this.state.commit_status, null, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit);
this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, null, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit);
}
// notlimiteds = () => {
// this.setState({
@ -2160,7 +2160,7 @@ class Studentshavecompletedthelist extends Component {
})
}
this.Searchdatasys(this.state.order, this.state.commit_status, checkedValues, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit);
this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, checkedValues, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit);
} else if (checkedValues.length === data.length) {
if (this.state.loadingstate === false) {
this.setState({
@ -2177,7 +2177,7 @@ class Studentshavecompletedthelist extends Component {
})
}
this.Searchdatasys(this.state.order, this.state.commit_status, checkedValues, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit);
this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, checkedValues, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit);
} else {
// console.log(checkedValues);
if (this.state.loadingstate === false) {
@ -2195,7 +2195,7 @@ class Studentshavecompletedthelist extends Component {
})
}
this.Searchdatasys(this.state.order, this.state.commit_status, checkedValues, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit);
this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, checkedValues, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit);
}
}
@ -2218,7 +2218,7 @@ class Studentshavecompletedthelist extends Component {
})
}
this.Searchdatasys(this.state.order, this.state.commit_status, this.state.review, undefined, this.state.searchtext, 1, this.state.limit)
this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, this.state.review, undefined, this.state.searchtext, 1, this.state.limit)
}
funtaskstatustwo = (checkedValues, data) => {
@ -2240,7 +2240,7 @@ class Studentshavecompletedthelist extends Component {
})
}
this.Searchdatasys(this.state.order, this.state.commit_status, this.state.review, checkedValues, this.state.searchtext, 1, this.state.limit)
this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, this.state.review, checkedValues, this.state.searchtext, 1, this.state.limit)
} else if (checkedValues.length === data.length) {
if (this.state.loadingstate === false) {
this.setState({
@ -2257,7 +2257,7 @@ class Studentshavecompletedthelist extends Component {
})
}
this.Searchdatasys(this.state.order, this.state.commit_status, this.state.review, checkedValues, this.state.searchtext, 1, this.state.limit)
this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, this.state.review, checkedValues, this.state.searchtext, 1, this.state.limit)
} else {
// console.log(checkedValues);
if (this.state.loadingstate === false) {
@ -2278,7 +2278,7 @@ class Studentshavecompletedthelist extends Component {
}
this.Searchdatasys(this.state.order, this.state.commit_status, this.state.review, checkedValues, this.state.searchtext, 1, this.state.limit)
this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, this.state.review, checkedValues, this.state.searchtext, 1, this.state.limit)
this.props.setcourse_groupysls(checkedValues)
}
@ -2299,7 +2299,7 @@ class Studentshavecompletedthelist extends Component {
})
}
this.Searchdatasys(this.state.order, this.state.commit_status, this.state.review, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit);
this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, this.state.review, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit);
}
};
//搜索学生按钮输入 老师
@ -2316,7 +2316,7 @@ class Studentshavecompletedthelist extends Component {
})
}
this.Searchdatasys(this.state.order, this.state.commit_status, this.state.review, this.state.checkedValuesineinfo, value, 1, this.state.limit);
this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, this.state.review, this.state.checkedValuesineinfo, value, 1, this.state.limit);
// this.Startsorting(this.state.order,this.state.checkedValuesine,this.state.checkedValuesineinfo,value);
// console.log(value)
@ -2353,6 +2353,8 @@ class Studentshavecompletedthelist extends Component {
//排序
funordersy = (e) => {
console.log(this.state.course_groupyslstwo);
debugger
if (e === "end_at") {
// 时间
// 时间排序是从小到大
@ -2367,7 +2369,7 @@ class Studentshavecompletedthelist extends Component {
})
}
this.Searchdatasys(e, this.state.commit_status, this.state.review, this.state.checkedValuesineinfo, this.state.searchtext, this.state.page,this.state.limit)
this.Searchdatasys(e, this.state.course_groupyslstwo, this.state.review, this.state.checkedValuesineinfo, this.state.searchtext, this.state.page,this.state.limit)
}
if (e === "score") {
@ -2385,7 +2387,7 @@ class Studentshavecompletedthelist extends Component {
}
this.Searchdatasys(e, this.state.commit_status, this.state.review, this.state.checkedValuesineinfo, this.state.searchtext, null, null)
this.Searchdatasys(e, this.state.course_groupyslstwo, this.state.review, this.state.checkedValuesineinfo, this.state.searchtext, null, null)
}
if (e === "student_id") {
@ -2402,7 +2404,7 @@ class Studentshavecompletedthelist extends Component {
})
}
this.Searchdatasys(e, this.state.commit_status, this.state.review, this.state.checkedValuesineinfo, this.state.searchtext, null, null)
this.Searchdatasys(e, this.state.course_groupyslstwo, this.state.review, this.state.checkedValuesineinfo, this.state.searchtext, null, null)
}
}
setExerciseReviewAndAnswer = () => {
@ -2423,7 +2425,7 @@ class Studentshavecompletedthelist extends Component {
" min-width": " 1200px",
}}>
{/*老师*/}
<div className="edu-back-white">
<div className="edu-back-white" >
<ul className="clearfix" style={{padding: '10px 30px 10px 30px'}}>
{/*你的评阅:*/}
@ -2588,6 +2590,7 @@ class Studentshavecompletedthelist extends Component {
{data === undefined ? "" : <Table
dataSource={data}
columns={columnsys}
className="mysjysltable1"
pagination={false}
loading={loadingstate}
// onChange={this.TablePaginationsy}
@ -2683,6 +2686,7 @@ class Studentshavecompletedthelist extends Component {
{datas === undefined ? "" : <Table
dataSource={datas}
columns={columnss}
className="mysjysltable2"
pagination={false}
loading={false}
/>}
@ -2716,6 +2720,7 @@ class Studentshavecompletedthelist extends Component {
dataSource={data}
columns={columnstwo}
// showHeader={false}
className="mysjysltable3"
pagination={false}
loading={false}
@ -2789,6 +2794,7 @@ class Studentshavecompletedthelist extends Component {
dataSource={datas}
columns={columns}
pagination={false}
className="mysjysltable4"
loading={loadingstate}
/>}</div>
</div>

@ -1,7 +1,9 @@
import React, { Component } from 'react';
import { Modal} from 'antd';
import axios from 'axios';
import certfed from './certfed.css';
import shimingrenzheng from '../../../src/images/cert/shimingrenzheng.png';
import zhiyerenzheng from '../../../src/images/cert/zhiyerenzheng.png';
import './certfed.css';
//认证职业
class Certifiedprofessional extends Component {
@ -22,23 +24,23 @@ class Certifiedprofessional extends Component {
axios.interceptors.response.use((response) => {
if (response != undefined)
if (response && response.data.status === -1) {
if(response.data.message==="该课堂要求成员完成实名认证"){
this.setState({
mydisplay:true,
occupation:1,
})
if(response.data.message==="该课堂要求成员完成实名认证"){
this.setState({
mydisplay:true,
occupation:1,
})
}else if(response.data.message==="该课堂要求成员完成职业认证"){
this.setState({
mydisplay:true,
occupation:2,
})
}else if(response.data.message==="该课堂要求成员完成实名和职业认证"){
this.setState({
mydisplay:true,
occupation:3,
})
}
}else if(response.data.message==="该课堂要求成员完成职业认证"){
this.setState({
mydisplay:true,
occupation:2,
})
}else if(response.data.message==="该课堂要求成员完成实名和职业认证"){
this.setState({
mydisplay:true,
occupation:3,
})
}
}
return response;
}, (error) => {
@ -53,7 +55,7 @@ class Certifiedprofessional extends Component {
};
setDownload=()=>{
window.location.href="/account/certification"
}
@ -61,7 +63,8 @@ class Certifiedprofessional extends Component {
render() {
// console.log("加入金品课堂2");
// console.log(this.props);
return(
let{occupation} =this.state;
return(
<Modal
keyboard={false}
closable={false}
@ -74,21 +77,48 @@ class Certifiedprofessional extends Component {
heigth="307px"
>
<div className="educouddiv">
<div className={"tabeltext-alignleft fontsizecoirlysl"}><p style={{fontSize: "16px",marginTop:"26px"}}>请在完成条件后重试</p></div>
<div className="yslcentercerlfed edu-txt-center mt30" >
<div className="mr30">
<div className={"tabeltext-alignleft fontsizecoirlysl"}><p style={{fontSize: "16px"}}>请在完成条件后重试</p></div>
{
occupation=== 3?
<div className="yslcentercerlfed edu-txt-center mt30" >
<span className="fontsizecoirlysltwo">未实名认证</span>
</div>
<div >
<div className="mr55 imgysldivone">
<img className="yslimgwidthte"
src={shimingrenzheng}
/>
<span className="fontsizecoirlysltwo mt15">未实名认证</span>
</div>
<div className="imgysldivone">
<img className="yslimgwidthte"
src={zhiyerenzheng}
/>
<span className="fontsizecoirlysltwo mt15">未职业认证</span>
</div>
</div>
:occupation=== 2?
<div className="yslcentercerlfed edu-txt-center mt30" >
<div className="imgysldivone">
<img className="yslimgwidthte"
src={zhiyerenzheng}
/>
<span className="fontsizecoirlysltwo mt15">未职业认证</span>
</div>
</div>
:
<div className="yslcentercerlfed edu-txt-center mt30" >
<div className=" imgysldivone">
<img className="yslimgwidthte"
src={shimingrenzheng}
/>
<span className="fontsizecoirlysltwo mt15">未实名认证</span>
</div>
</div>
}
<span className="fontsizecoirlysltwo">未职业认证</span>
</div>
</div>
<div className="clearfix edu-txt-center mt60">
<div className="clearfix edu-txt-center mt28">
<a className="task-btn mr30" onClick={()=>this.modalCancel()}>取消</a>
<a className="task-btn task-btn-orange" onClick={()=>this.setDownload()}>立即认证</a>
<a className="task-btn mr60 w90" onClick={()=>this.modalCancel()}>取消</a>
<a className="task-btn task-btn-orange w90" onClick={()=>this.setDownload()}>立即认证</a>
</div>
</div>
</Modal>

@ -18,4 +18,27 @@
.fontsizecoirlysltwo{
font-size: 14px;
color: #979797;
}
.imgysldivone{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.yslimgwidthte{
width: 40px;
height: 37px;
}
.mr55{
margin-right: 55px;
}
.mt28{
margin-top: 28px;
}
.w90{
width: 90px;
}
.mr60{
margin-right: 60px;
}

@ -449,7 +449,7 @@ class DetailCardsEditAndAdd extends Component{
<Spin spinning={hometypepvisible} size="large" style={{marginTop:'15%'}}>
<div className="newupload_conbox">
<div className="clearfix mb20 shixun_work_div newshixun_tab_div cdefault" style={{"marginRight":"4px"}} id="shixun_tab_div">
<li className="fl mr5 mt5"> <a onClick={()=>this.changeTag(0,`${search}`)} className={ type===0 ? "active edu-filter-cir-grey font-12":"edu-filter-cir-grey font-12"}>全部</a></li>
<li className="fl mr5 mt5"> <a onClick={()=>this.changeTag(0,`${search}`)} className={ parseInt(type)===0 ? "active edu-filter-cir-grey font-12":"edu-filter-cir-grey font-12"}>全部</a></li>
{
ChooseShixunList && ChooseShixunList.tags.map((item,key)=>{
return(

@ -81,6 +81,7 @@ class DetailCardsEditAndEdit extends Component{
//打开选择实训弹框初始化tag标签和列表
changeTag(id,search){
this.setState({
ChooseShixunListshixun_list:[],
page:1,
@ -481,7 +482,7 @@ class DetailCardsEditAndEdit extends Component{
<Spin spinning={hometypepvisible} size="large" style={{marginTop:'15%'}}>
<div className="newupload_conbox">
<div className="clearfix mb20 shixun_work_div newshixun_tab_div cdefault" style={{"marginRight":"4px"}} id="shixun_tab_div">
<li className="fl mr5 mt5"> <a onClick={()=>this.changeTag(0,`${search}`)} className={ type===0 ? "active edu-filter-cir-grey font-12":"edu-filter-cir-grey font-12"}>全部</a></li>
<li className="fl mr5 mt5"> <a onClick={()=>this.changeTag(0,`${search}`)} className={ parseInt(type)===0 ? "active edu-filter-cir-grey font-12":"edu-filter-cir-grey font-12"}>全部</a></li>
{
ChooseShixunList && ChooseShixunList.tags.map((item,key)=>{
return(

@ -35,14 +35,14 @@ if (!window['indexHOCLoaded']) {
// $('head').append($('<link rel="stylesheet" type="text/css" />')
// .attr('href', `${_url_origin}/stylesheets/educoder/antd.min.css?1525440977`));
$('head').append($('<link rel="stylesheet" type="text/css" />')
.attr('href', `${_url_origin}/stylesheets/css/edu-common.css?8`));
.attr('href', `${_url_origin}/stylesheets/css/edu-common.css?9`));
$('head').append($('<link rel="stylesheet" type="text/css" />')
.attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?8`));
.attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?9`));
// index.html有加载
$('head').append($('<link rel="stylesheet" type="text/css" />')
.attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?8`));
.attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?9`));
// $('head').append($('<link rel="stylesheet" type="text/css" />')

@ -43,6 +43,8 @@ function doCreateUploader (options) {
retryDuration: $('#retryDuration').val() || 2,
region: $('#region').val() || 'ap-southeast-1',
userId: $('#userId').val() || 1829848226361863, // 1303984639806000,
// 解决取消上传后无法继续上传同文件的问题
// https://workorder.console.aliyun.com/console.htm#/ticket/detail/?ticketId=FLASELR
enableUploadProgress: false,
// 添加文件成功
addFileSuccess: function (uploadInfo) {

@ -70,6 +70,7 @@ function VideoUploadList (props) {
&& file.name.indexOf('.webm') == -1
) {
showNotification(`不支持的视频格式`)
clearInput()
return;
}
if (file.size > 200 * 1024 * 1024) {

Loading…
Cancel
Save