Merge branch 'dev_aliyun' into dev_hs

dev_winse
SylorHuang 6 years ago
commit 60a17fa69b

@ -210,6 +210,7 @@ class FilesController < ApplicationController
is_unified_setting = params[:is_unified_setting]
publish_time = params[:publish_time]
publish_time = format_time(Time.parse(publish_time)) unless publish_time.blank?
is_public = params[:is_public]
course_group_publish_times = params[:course_group_publish_times] || []
@ -221,8 +222,10 @@ class FilesController < ApplicationController
@new_attachment_history = @old_attachment.become_history
@new_attachment_history.save!
old_course_second_category_id = @old_attachment.course_second_category_id
@old_attachment.copy_attributes_from_new_attachment(@new_attachment)
@old_attachment.is_public = is_public == true ? 1 : 0 if is_public
@old_attachment.course_second_category_id = old_course_second_category_id
@old_attachment.save!
@new_attachment.delete
end

@ -498,44 +498,41 @@ class GamesController < ApplicationController
rescue Exception => e
# 思路: 异常首先应该考虑去恢复
# retry为1表示已经轮训完成后还没有解决问题这个时候需要检测异常
if params[:retry].to_i == 1
begin
# 如果模板没有问题,则通过中间层检测实训仓库是否异常
# 监测版本库HEAD是否存在不存在则取最新的HEAD
gitUrl = repo_url @myshixun.repo_path
gitUrl = Base64.urlsafe_encode64(gitUrl)
shixun_tomcat = edu_setting('cloud_bridge')
rep_params = {:tpiID => "#{@myshixun.id}", :tpiGitURL => "#{gitUrl}"}
# 监测版本库HEAD是否存在不存在则取最新的HEAD
uri = "#{shixun_tomcat}/bridge/game/check"
res = uri_post uri, rep_params
uid_logger("repo_content to bridge: res is #{res}")
# res值0 表示正常;-1表示有错误-2表示代码版本库没了
#
if status == 0 && res
# 版本库报错,修复不了
if res['code'] == -1 || res['code'] == -2
begin
# GitService.delete_repository(repo_path: @myshixun.repo_path) if res['code'] == -1
project_fork(@myshixun, @shixun.repo_path, current_user.login)
rescue Exception => e
uid_logger_error("#{e.message}")
tip_exception("#{e.message}")
end
begin
# 如果模板没有问题,则通过中间层检测实训仓库是否异常
# 监测版本库HEAD是否存在不存在则取最新的HEAD
gitUrl = repo_url @myshixun.repo_path
gitUrl = Base64.urlsafe_encode64(gitUrl)
shixun_tomcat = edu_setting('cloud_bridge')
rep_params = {:tpiID => "#{@myshixun.id}", :tpiGitURL => "#{gitUrl}"}
# 监测版本库HEAD是否存在不存在则取最新的HEAD
uri = "#{shixun_tomcat}/bridge/game/check"
res = uri_post uri, rep_params
uid_logger("repo_content to bridge: res is #{res}")
# res值0 表示正常;-1表示有错误-2表示代码版本库没了
#
if status == 0 && res
# 版本库报错,修复不了
if res['code'] == -1 || res['code'] == -2
begin
# GitService.delete_repository(repo_path: @myshixun.repo_path) if res['code'] == -1
project_fork(@myshixun, @shixun.repo_path, current_user.login)
rescue Exception => e
uid_logger_error("#{e.message}")
tip_exception("#{e.message}")
end
end
rescue Exception => e
uid_logger_error(e.message)
end
rescue Exception => e
uid_logger_error(e.message)
if @myshixun.shixun.try(:status) < 2
tip_exception("代码获取异常,请检查实训模板的评测设置是否正确")
else
# 报错继续retry
tip_exception(-3, "#{e.message}")
end
if @myshixun.shixun.try(:status) < 2
tip_exception("代码获取异常,请检查实训模板的评测设置是否正确")
else
# 报错继续retry
tip_exception(-3, "#{e.message}")
end
end
# 有异常版本库获取不到代码前端轮训15S后调用retry == 1
tip_exception(0, e.message)
end
end

@ -171,6 +171,14 @@ class HomeworkCommonsController < ApplicationController
@student_works = @student_works.where(user_id: group_user_ids)
end
if @homework.homework_type == "group" && !params[:member_work].blank?
if params[:member_work].to_i == 1
@student_works = @student_works.where("user_id = commit_user_id")
elsif params[:member_work].to_i == 0
@student_works = @student_works.where("user_id != commit_user_id")
end
end
# 输入姓名和学号搜索
# TODO user_extension 如果修改 请调整
unless params[:search].blank?

@ -562,6 +562,17 @@ class ShixunsController < ApplicationController
commit_id = commit["id"]
end
# 如果该实训是金课中的实训,则将当前用户加入到当期开课的课堂
# if StageShixun.exists?(shixun_id: @shixun.id, subject_id: Subject.where(excellent: 1))
# subject = Subject.where(excellent: 1, id: StageShixun.where(shixun_id: @shixun.id).pluck(:subject_id)).take
# course = subject.courses.where("start_date is not null and start_date <= '#{Date.today}' and end_date is not null and end_date >= '#{Date.today}'").take
# if course.present? && !CourseMember.exists?(course_id: course.id, user_id: current_user.id)
# # 为了不影响后续操作用create而不是create!
# CourseMember.create(course_id: course.id, user_id: current_user.id, role: 4)
# CourseAddStudentCreateWorksJob.perform_later(course.id, [current_user.id])
# end
# end
ActiveRecord::Base.transaction do
begin
cloud_bridge = edu_setting('cloud_bridge')

@ -61,16 +61,21 @@ class StudentWorksController < ApplicationController
end
def delete_work
begin
work = @homework.student_works.find_by!(user_id: params[:user_id])
work.update_attributes(description: nil, project_id: 0,
late_penalty: 0, work_status: 0,
commit_time: nil, update_time: nil, group_id: 0,
commit_user_id: nil, final_score: nil, work_score: nil, teacher_score: nil, teaching_asistant_score: nil)
normal_status("删除成功")
rescue Exception => e
uid_logger(e.message)
tip_exception(e.message)
ActiveRecord::Base.transaction do
begin
work = @homework.student_works.find_by!(user_id: params[:user_id])
tip_exception("只有组长才能删除组员") if work.commit_user_id != current_user.id
work.update_attributes(description: nil, project_id: 0,
late_penalty: 0, work_status: 0,
commit_time: nil, update_time: nil, group_id: 0,
commit_user_id: nil, final_score: nil, work_score: nil, teacher_score: nil, teaching_asistant_score: nil)
work.attachments.destroy_all
work.tidings.destroy_all
normal_status("删除成功")
rescue Exception => e
uid_logger(e.message)
tip_exception(e.message)
end
end
end
@ -137,8 +142,9 @@ class StudentWorksController < ApplicationController
@current_user = current_user
if @homework.homework_type == "group"
# todo user_extension
@commit_user_id = @work.commit_user_id
@work_members = @course.students.where(user_id: @homework.student_works.where(group_id: @work.group_id).pluck(:user_id)).
order("course_members.id=#{@work.user_id} desc").includes(:course_group, user: :user_extension)
order("course_members.user_id=#{@work.commit_user_id} desc").includes(:course_group, user: :user_extension)
end
end
@ -150,7 +156,7 @@ class StudentWorksController < ApplicationController
begin
@work.description = params[:description]
@work.update_time = Time.now
@work.commit_user_id = current_user.id
# @work.commit_user_id = current_user.id
if @work.save!
Attachment.associate_container(params[:attachment_ids], @work.id, @work.class)
@ -165,7 +171,8 @@ class StudentWorksController < ApplicationController
# 原成员更新描述、更新时间以及附件
@homework.student_works.where(group_id: @work.group_id, user_id: (work_user_ids & params_user_ids)).each do |work|
work.update_attributes(update_time: Time.now, description: @work.description, commit_user_id: current_user.id)
# work.update_attributes(update_time: Time.now, description: @work.description, commit_user_id: current_user.id)
work.update_attributes(update_time: Time.now, description: @work.description)
work.attachments.destroy_all
@work.attachments.each do |attachment|
att = attachment.copy
@ -193,7 +200,7 @@ class StudentWorksController < ApplicationController
stu_work.update_attributes(user_id: user_id, description: @work.description, homework_common_id: @homework.id,
project_id: @work.project_id, late_penalty: @work.late_penalty,
work_status: @work.work_status, commit_time: Time.now, update_time: Time.now,
group_id: @work.group_id, commit_user_id: current_user.id)
group_id: @work.group_id, commit_user_id: @work.commit_user_id)
@work.attachments.each do |attachment|
att = attachment.copy
att.author_id = attachment.author_id

@ -83,21 +83,37 @@ class SubjectsController < ApplicationController
@is_creator = current_user.creator_of_subject?(@subject)
@is_manager = @user.manager_of_subject?(@subject)
# 合作团队
@members = @subject.subject_members.includes(:user)
@shixuns = @subject.shixuns.published.pluck(:id)
challenge_ids = Challenge.where(shixun_id: @shixuns).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
@challenge_count = challenge_ids.size
# 访问数变更
@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

@ -26,6 +26,12 @@ class Users::BaseController < ApplicationController
render_forbidden
end
def require_auth_teacher!
return if current_user.admin_or_business? || observed_user.certification_teacher?
render_forbidden
end
def page_value
params[:page].to_i <= 0 ? 1 : params[:page].to_i
end

@ -1,5 +1,5 @@
class Users::VideoAuthsController < Users::BaseController
before_action :private_user_resources!
before_action :private_user_resources!, :require_auth_teacher!
def create
result = Videos::CreateAuthService.call(observed_user, create_params)

@ -1,5 +1,5 @@
class Users::VideosController < Users::BaseController
before_action :private_user_resources!
before_action :private_user_resources!, :require_auth_teacher!
helper_method :current_video

@ -380,4 +380,8 @@ module TidingDecorator
I18n.t(locale_format(tiding_type)) % [container.try(:title) || extra]
end
end
def public_course_start_content
I18n.t(locale_format) % [belong_container&.name, belong_container&.start_date&.strftime("%Y-%m-%d")]
end
end

@ -163,7 +163,7 @@ module ExportHelper
end
w_15 = w.work_score.nil? ? "--" : w.work_score.round(1)
w_16 = w.update_time ? format_time(w.update_time) : "--" "更新时间"
w_17 = (game_spend_time w.cost_time)
w_17 = w.cost_time ? (game_spend_time w.cost_time) : "--"
teacher_comments = w.student_works_scores
if teacher_comments.present?
w_18 = ""

@ -16,4 +16,19 @@ module SubjectsHelper
ChallengeTag.joins("join games on challenge_tags.challenge_id = games.challenge_id").
where(challenge_id: challenge_ids, games: {status: 2, user_id: user_id}).pluck("challenge_tags.name").uniq
end
# 金课的课堂状态 0未开课1进行中2已结束
def subject_course_status course
if course.is_end
{status: 2, time: ""}
elsif course.start_date && course.start_date > Date.today
{status: 0, time: ""}
elsif course.start_date && course.start_date <= Date.today && course.end_date >= Date.today
sum_week = ((course.end_date - course.start_date).to_i / 7.0).ceil
curr_week = ((Date.today - course.start_date).to_i / 7.0).ceil
{status: 1, time: "进行至第#{curr_week}周,共#{sum_week}"}
else
{status: -1, time: ""}
end
end
end

@ -25,7 +25,8 @@ module Searchable::Course
author_school_name: teacher&.school_name,
visits_count: visits,
members_count: members_count,
is_public: is_public == 1
is_public: is_public == 1,
first_category_url: ApplicationController.helpers.module_url(none_hidden_course_modules.first, self)
}
end

@ -11,7 +11,7 @@ class DuplicateCourseService < ApplicationService
@course = copy_course!
copy_course_modules!
Rails.logger.info("###########second_category_list#{@second_category_list}")
join_course!
copy_homework_commons!
@ -36,9 +36,17 @@ class DuplicateCourseService < ApplicationService
end
def copy_course_modules!
@second_category_list = {}
origin_course.course_modules.each do |course_module|
attrs = course_module.as_json(only: %i[module_type position hidden module_name])
CourseModule.create!(attrs.merge(course_id: course.id))
new_course_module = CourseModule.create!(attrs.merge(course_id: course.id))
# 复制子目录
course_module.course_second_categories.each do |second_category|
category_attr = second_category.as_json(only: %i[category_type name position])
new_second_category =
CourseSecondCategory.create!(category_attr.merge(course_id: course.id, course_module_id: new_course_module.id))
@second_category_list[second_category.id] = new_second_category.id
end
end
end
@ -50,7 +58,10 @@ class DuplicateCourseService < ApplicationService
origin_course.homework_commons.where(homework_type: %i[normal group practice]).find_each do |origin_homework|
homework_attrs = origin_homework.as_json(only: %i[name description homework_type homework_bank_id reference_answer])
homework = HomeworkCommon.create!(homework_attrs.merge(user_id: user.id, course_id: course.id))
course_second_category_id = @second_category_list[origin_homework.course_second_category_id]
homework = HomeworkCommon.create!(homework_attrs.merge(user_id: user.id, course_id: course.id,
course_second_category_id:course_second_category_id))
origin_homework.attachments.find_each do |origin_attachment|
attachment = origin_attachment.copy
@ -71,6 +82,7 @@ class DuplicateCourseService < ApplicationService
HomeworksService.new.create_shixun_homework_cha_setting(homework, origin_homework.shixuns.first)
end
origin_homework.increment!(:quotes)
origin_homework.homework_bank.increment!(:quotes) if origin_homework.homework_bank
end
@ -138,9 +150,9 @@ class DuplicateCourseService < ApplicationService
attachment.copy_from = origin_attachment.copy_from || origin_attachment.id
attachment.is_publish = 0
attachment.attachtype ||= 4
attachment.course_second_category_id = @second_category_list[origin_attachment.course_second_category_id]
attachment.save!
origin_course.update_quotes(attachment)
end
end

@ -69,6 +69,7 @@ elsif @user_course_identity == Course::STUDENT
json.project_info project_info @work, @current_user, @user_course_identity
end
json.work_group @work.work_group_name
json.is_leader @work.user_id == @work.commit_user_id
end
end
@ -140,6 +141,7 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal"
if @homework.homework_detail_group.base_on_project
json.project_info project_info work, @current_user, @user_course_identity
end
json.is_leader work.user_id == work.commit_user_id
json.work_group work.work_group_name
end

@ -1,12 +1,14 @@
json.partial! "homework_commons/homework_public_navigation", locals: {homework: @homework, course: @course, user: @current_user}
json.work_id @work.id
json.description @work.description
json.
json.attachments @work.attachments do |atta|
json.partial! "attachments/attachment_simple", locals: {attachment: atta, delete: @work.delete_atta(atta)}
end
if @homework.homework_type == "group"
json.is_leader_work @work.user_id == @commit_user_id
json.min_num @homework.homework_detail_group.try(:min_num)
json.max_num @homework.homework_detail_group.try(:max_num)
@ -15,5 +17,6 @@ if @homework.homework_type == "group"
json.user_name member.user.real_name
json.group_name member.course_group_name
json.student_id member.user.student_id
json.is_leader member.user_id == @commit_user_id
end
end

@ -3,6 +3,7 @@ json.(@work, :description, :commit_time, :update_time)
json.is_evaluation @is_evaluation
json.author_name @is_evaluation ? "匿名" : @work.user.real_name
json.is_leader_work @work.user_id == @work.commit_user_id if @homework.homework_type == "group"
json.is_author @is_author
json.update_user_name @is_evaluation ? "匿名" : @work.commit_user.try(:real_name)
@ -17,8 +18,10 @@ unless @is_evaluation
json.project_info project_info @work, @current_user, @user_course_identity
end
json.work_members @work_members.each do |member|
json.user_name member.user.real_name
json.user_login member.user.login
json.work_members @work_members.each do |work|
json.user_name work.user.real_name
json.user_login work.user.login
json.work_id work.id
json.is_leader work.user_id == work.commit_user_id
end
end

@ -0,0 +1,21 @@
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

@ -1,4 +1,4 @@
json.(@subject, :id, :name, :description, :learning_notes, :stages_count, :stage_shixuns_count, :shixuns_count)
json.(@subject, :id, :name, :description, :learning_notes, :stages_count, :stage_shixuns_count, :shixuns_count, :excellent)
json.challenge_choose_count @subject.subject_challenge_choose_count
json.challenges_count @subject.subject_challenge_count
@ -12,6 +12,19 @@ json.allow_send @user.logged?
json.allow_visit @subject.status > 1 || @is_manager
json.allow_add_member @is_manager
if @subject.excellent
json.courses @courses do |course|
json.course_id course.id
json.first_category_url module_url(course.none_hidden_course_modules.first, course)
json.start_date course.start_date
json.end_date course.end_date
json.student_count course.students.count
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

@ -225,3 +225,4 @@
System:
1_end: "你提交的发布视频申请:%s审核已通过"
2_end: "你提交的发布视频申请:%s审核未通过<br/><span>原因:%{reason}</span>"
PublicCourseStart_end: "你报名参与的开放课程:%s将于%s正式开课"

@ -273,6 +273,7 @@ Rails.application.routes.draw do
delete :delete_member
post :up_member_position
post :down_member_position
get :right_banner
end
collection do

@ -0,0 +1,5 @@
class ModifyPathForChallenges < ActiveRecord::Migration[5.2]
def change
change_column :challenges, :path, :text
end
end

Binary file not shown.

@ -0,0 +1,34 @@
#coding=utf-8
# 执行示例 bundle exec rake excellent_course_exercise:student_answer args=149,2903
desc "同步精品课的学生试卷数据"
namespace :excellent_course_exercise do
task :student_answer => :environment do
course = Course.find_by(id: 2933)
participant_count = 1042
pass_count = 823
members_1 = course.students.order("id asc").limit(987)
members_2 = course.students.order("id asc").limit(1042)
members_1 = course.students.order("id asc").limit(322)
exercise_1884 = course.exercises.find_by(id: 1884)
members_1.each_with_index do |member, index|
if index < 821
exercise_1884.exercise_questions.where.not(question_type: 5).each do |question|
answer_option = {
:user_id => current_user.id,
:exercise_question_id => @exercise_question.id,
:exercise_choice_id => choice_id,
:answer_text => ""
}
ex_a = ExerciseAnswer.new(answer_option)
ex_a.save!
end
else
end
end
end
end

@ -0,0 +1,142 @@
#coding=utf-8
# 执行示例 bundle exec rake public_course:student args=149,2903
# args 第一个参数是subject_id第二个参数是课程course_id
# 第一期时间2018-12-16 至2019-03-31
# 第二期时间2019-04-07 至2019-07-28
#
# 这次学习很有收获,感谢老师提供这么好的资源和细心的服务🎉🎉🎉
#
desc "同步精品课数据"
namespace :public_course do
if ENV['args']
subject_id = ENV['args'].split(",")[0] # 对应课程的id
course_id = ENV['args'].split(",")[1] # 对应课堂的id
status = ENV['args'].split(",")[2] # 表示相应的期数
type = ENV['args'].split(",")[3] # 表示课程模块
end
if status.to_i == 1
start_time = '2018-12-16'
end_time = '2019-04-01'
elsif status.to_i == 2
start_time = '2019-04-07'
end_time = '2019-07-28'
else
# 这种情况是取所有的
start_time = '2015-01-01'
end_time = '2022-07-28'
end
task :student => :environment do
puts "subject_id is #{subject_id}"
puts "course_id is #{course_id}"
user_ids = Myshixun.find_by_sql("select distinct(user_id) from myshixuns where shixun_id in (select shixun_id from stage_shixuns
where stage_id in (select id from stages where subject_id=#{subject_id}))").map(&:user_id)
puts user_ids
if user_ids.present?
user_ids.each do |user_id|
puts user_id
begin
CourseMember.create!(course_id: course_id, user_id: user_id, role: 4)
rescue Exception => e
Rails.logger()
end
end
end
end
#
task :message => :environment do
discusses = Discuss.find_by_sql("select content, user_id, created_on, updated_on from discusses where dis_id in (select shixun_id from stage_shixuns where
stage_id in (select id from stages where subject_id=#{subject_id})) and created_at > #{start_time} and
created_at<#{end_time}")
discusses.find_each do |discuss|
puts discuss.user_id
puts discuss.content
# 回复帖子
# 讨论区发布帖子
# Message.create!(board: @message.board, root_id: @message.root_id || @message.id,
# author: current_user, parent: @message,
# message_detail_attributes: {
# content: params[:content]
# })
end
end
# 更新某个课程的某类时间
# 执行示例 bundle exec rake public_course:student args=2903,1
task :time => :environment do
# course_id = ENV['args'].split(",")[0] # 对应课堂的id
# type = ENV['args'].split(",")[1]
course = Course.find(course_id)
case type.to_i
when 1
# 讨论区
when 2
# 作业
course.homework_commons.each do |homework|
created_at = random_time(start_time, end_time)
publish_time = random_larger_time created_at, start_time, end_time
end_time = random_larger_time publish_time, start_time, end_time
updated_at = end_time
homework.update_columns(publish_time: publish_time, end_time: end_time, created_at: created_at, updated_at: updated_at)
homework.homework_detail_manual.update_columns(comment_status: 6, created_at: created_at, updated_at: updated_at)
end
when 3
# 试卷
course.exercises.each do |exercise|
created_at = random_time start_time, end_time
publish_time = random_larger_time created_at, start_time, end_time
end_time = random_larger_time publish_time, start_time, end_time
updated_at = end_time
exercise.update_columns(publish_time: publish_time, end_time: end_time, created_at: created_at, updated_at: updated_at, exercise_status: 3)
end
when 4
# 资源
course.attachments.each do |atta|
created_on = random_time start_time, end_time
atta.update_columns(is_publish: 1, created_on: created_on, publish_time: created_on)
end
end
end
def min_swith(time)
puts time
return time < 9 ? "0#{time}" : time
end
def random_time(start_time, end_time)
hour = (6..23).to_a.sample(1).first
min = rand(60)
sec = rand(60)
start_time = Date.parse(start_time)
end_time = Date.parse(end_time)
date = (start_time..end_time).to_a.sample(1).first
time = "#{date} #{min_swith(hour)}:#{min_swith(min)}:#{min_swith(sec)}"
puts time
time
end
def random_larger_time(time, start_time, end_time)
large_time = random_time(start_time, end_time)
while large_time <= time
large_time = random_time(start_time, end_time)
end
large_time
end
end

@ -0,0 +1,19 @@
desc "开放课程开课前通知报名用户"
namespace :public_course_notice do
task :tiding => :environment do
Course.where(excellent: 1).where("start_date is not null and start_date = '#{Date.today}'").each do |course|
attrs = %i[user_id trigger_user_id status container_id container_type belong_container_id
belong_container_type tiding_type created_at updated_at]
same_attrs = {
trigger_user_id: 0, container_id: course.id, container_type: 'PublicCourseStart',
belong_container_id: course.id, belong_container_type: 'Course', tiding_type: 'System', status: 0
}
Tiding.bulk_insert(*attrs) do |worker|
course.students.each do |student|
worker.add same_attrs.merge(user_id: student.user_id)
end
end
end
end
end

@ -0,0 +1,37 @@
# bundle exec rake sync:public_message args=149,2903
namespace :sync do
task :public_message => :environment do
subject_id = ENV['args'].split(",")[0] # 对应课程的id
board_id = ENV['args'].split(",")[1]
message_id = ENV['args'].split(",")[2]
status = ENV['args'].split(",")[3] # 表示相应的期数
if status.to_i == 1
start_time = '2018-12-16'
end_time = '2019-04-01'
elsif status.to_i == 2
start_time = '2019-04-07'
end_time = '2019-07-28'
else
# 这种情况是取所有的
start_time = '2015-01-01'
end_time = '2022-07-28'
end
shixun_ids = Shixun.find_by_sql("select shixun_id from stage_shixuns where stage_id in (select id from stages where
subject_id=#{subject_id}) ").map(&:shixun_id)
discusses = Discuss.where(dis_id: shixun_ids).where("created_at >? and created_at <?", start_time, end_time)
if discusses.present?
discusses.find_each do |discuss|
puts discuss.user_id
puts board_id
puts message_id
new_message = Message.create!(board_id: board_id.to_i, author_id: discuss.user_id, parent_id: message_id, root_id: message_id)
MessageDetail.create!(message_id: new_message.id, content: discuss.try(:content))
end
end
end
end

@ -1,25 +0,0 @@
#coding=utf-8
# 执行示例 bundle exec rake public_course:student args=149,2903
# args 第一个参数是subject_id第二个参数是课程course_id
desc "同步精品课数据"
namespace :public_course do
task :student => :environment do
subject_id = ENV['args'].split(",").first
course_id = ENV['args'].split(",").last
puts "subject_id is #{subject_id}"
puts "course_id is #{course_id}"
user_ids = Myshixun.find_by_sql("select distinct(user_id) from myshixuns where shixun_id in (select shixun_id from stage_shixuns
where stage_id in (select id from stages where subject_id=#{subject_id}))").map(&:user_id)
puts user_ids
if user_ids.present?
user_ids.each do |user_id|
puts user_id
CourseMember.create!(course_id: course_id, user_id: user_id, role: 4)
end
end
end
end

@ -10,6 +10,7 @@ broadcastChannelOnmessage('refreshPage', () => {
})
function locationurl(list){
debugger
if (window.location.port === "3007") {
} else {
@ -158,7 +159,8 @@ export function initAxiosInterceptors(props) {
// console.log("401401401")
// }
if (response.data.status === 403||response.data.status === "403") {
locationurl('/403');
locationurl('/403');
}
if (response.data.status === 404) {

@ -757,6 +757,7 @@ class Fileslists extends Component{
setupdate={(id)=>this.seactall(id)}
Cancel={this.Cancelvisible}
has_course_groups={this.state.has_course_groups}
attachmentId={this.state.coursesecondcategoryid}
/>:""}
<Titlesearchsection

@ -496,6 +496,15 @@ class Coursesleftnav extends Component{
saveNavmoda=()=>{
let {Navmodaltypename,setnavid,NavmodalValue}=this.state;
let id =setnavid;
if(Navmodaltypename===5&&NavmodalValue==="未分班"||Navmodaltypename===2&&NavmodalValue==="未分班"){
this.setState({
NavmodalValuetype:true,
NavmodalValues:"名称不能和未分班一样"
})
return
}
if(NavmodalValue===""){
this.setState({
NavmodalValuetype:true,
@ -639,6 +648,7 @@ class Coursesleftnav extends Component{
}
onDragEnd=(result)=>{
debugger
// console.log(result)
// let {course_modules}=this.props;
// let newcourse_modules=course_modules;
@ -670,22 +680,26 @@ class Coursesleftnav extends Component{
// course_modules:newcourse_modules
// })
if(result.source.droppableId==="shixun_homework"||result.source.droppableId==="graduation"||result.source.droppableId==="attachment"){
let url ="/course_second_categories/"+result.draggableId+"/move_category.json"
this.droppablepost(url,result.destination.index+1)
}else if(result.source.droppableId==="board"){
let url ="/boards/"+result.draggableId+"/move_category.json"
this.droppablepost(url,result.destination.index+1)
}else if(result.source.droppableId==="course_group"){
let url ="/course_groups/"+result.draggableId+"/move_category.json"
this.droppablepost(url,result.destination.index)
}
if(result.source.droppableId==="shixun_homework"||result.source.droppableId==="graduation"||result.source.droppableId==="attachment"){
let url ="/course_second_categories/"+result.draggableId+"/move_category.json";
if(result.destination.index!=null){
this.droppablepost(url,result.destination.index+1)
}
}else if(result.source.droppableId==="board"){
let url ="/boards/"+result.draggableId+"/move_category.json";
if(result.destination.index!=null) {
this.droppablepost(url, result.destination.index + 1)
}
}else if(result.source.droppableId==="course_group"){
if(result.draggableId!=1){
let url ="/course_groups/"+result.draggableId+"/move_category.json";
if(result.destination.index!=null) {
this.droppablepost(url, result.destination.index + 1)
}
}
}
}
@ -820,8 +834,16 @@ class Coursesleftnav extends Component{
onInput={this.setNavmodalValue}
/>
</div>
{this.state.NavmodalValuetype===true?<span className={"color-red"}>
<style>
{
`
.ml70{
margin-left: 70px;
}
`
}
</style>
{this.state.NavmodalValuetype===true?<span className={"ml70 color-red"}>
{this.state.NavmodalValues}
</span>:""}
<div className={this.state.NavmodalValuetype===true?"clearfix mt20 edu-txt-center":"clearfix mt50 edu-txt-center"}>
@ -837,7 +859,7 @@ class Coursesleftnav extends Component{
.droppableul{
max-height: 500px;
overflow-y:auto;
overflow:hidden auto;
overflow-x:hidden;
}
.mr13{
@ -928,8 +950,9 @@ class Coursesleftnav extends Component{
<a className="fl pl46 pd0 Draggablelichild">
<span className={this.props.location.pathname===iem.second_category_url?"color-blue fl ml38 maxwidth155 task-hide Draggablelichild":"fl ml38 maxwidth155 task-hide Draggablelichild"}>{iem.category_name}</span>
<span className={twosandiantype===undefined?this.props.location.pathname===iem.second_category_url?"fr mr20 color-blue Draggablelichild font-14":"fr mr20 color999 Draggablelichild font-14":item.type===twosandiantypes&&twosandiantype===index?"none":this.props.location.pathname===iem.second_category_url?"fr mr20 color-blue Draggablelichild font-14":"fr mr20 color999 Draggablelichild font-14"} >{iem.category_count===0?"":iem.category_count}</span>
<span className={twosandiantype===undefined?this.props.location.pathname===iem.second_category_url?"fr mr20 color-blue Draggablelichild font-14":"fr mr20 color999 Draggablelichild font-14":item.type===twosandiantypes&&twosandiantype===index&&iem.category_id!=0?"none":this.props.location.pathname===iem.second_category_url?"fr mr20 color-blue Draggablelichild font-14":"fr mr20 color999 Draggablelichild font-14"} >{iem.category_count===0?"":iem.category_count}</span>
{item.type===twosandiantypes&&twosandiantype===index?
iem.category_id===0?"":
iem.category_type==="graduation_topics"||iem.category_type==="graduation_tasks"?
<span className={"fr mr20 color999 Draggablelichild font-14"} >{iem.category_count===0?"":iem.category_count}</span>
:<Popover placement="right" content={this.content(item,iem,index)} trigger="hover" key={index}>

@ -220,12 +220,13 @@ class Selectsetting extends Component{
let coursesId=this.props.match.params.coursesId;
let attachmentId=this.props.match.params.attachmentId;
let attachmentId=this.props.attachmentId;
let url="/files/"+this.props.discussMessageid+".json";
//
axios.put(url,{
course_id:coursesId,
new_attachment_id:newfileList.length===0?undefined:newfileList,
course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId,
is_public:is_public,
is_unified_setting:unified_setting,
publish_time:unified_setting===true?datatime===undefined?moment(new Date()).format('YYYY-MM-DD HH'):datatime:undefined,

@ -163,6 +163,10 @@ class Testpapersettinghomepage extends Component{
}
}
//打开pdf
confpdf = (url) =>{
window.open(url);
}
/// 确认是否下载
confirmysl(url,child){
let params ={}
@ -372,7 +376,7 @@ class Testpapersettinghomepage extends Component{
导出<i className="iconfont icon-xiajiantou font-12 ml2"></i>
<ul className="drop_down_menu" style={{"right":"-34px","left":"unset","height":"auto"}}>
<li><a onClick={()=>this.confirmysl(`/exercises/${this.props.match.params.Id}/exercise_lists.xlsx`,this.child)}>学生成绩</a></li>
<li><a onClick={()=>this.confirmysl(`/exercises/${this.props.match.params.Id}/export_exercise`,this.child)} >空白试卷</a></li>
<li><a onClick={()=>this.confpdf(`/api/exercises/${this.props.match.params.Id}/export_exercise`)} >空白试卷</a></li>
{/*<li><a onClick={()=>this.confirmysl(`/zip/export_exercises?exercise_id=${this.props.match.params.Id}${this.state.groupyslsval===null||this.state.groupyslsval===undefined?null:this.state.groupyslsval}`)}>学生答题试卷</a></li>*/}
</ul>
</li></Spin>:""}

@ -760,6 +760,7 @@ class GraduationTasksSubmitedit extends Component{
height: '30px'
}}>
<Checkbox value={item.user_id}
key={item.user_id}
checked={
task_status.map((item,key)=>{
return parseInt(task_status[key])===item.user_id?true:false

@ -472,6 +472,9 @@ class GraduationTasksSubmitnew extends Component{
// }
// }
}).catch((error) => {
this.setState({
spinnings:false
});
console.log(error)
})

@ -179,8 +179,13 @@ class GraduationTasks extends Component{
})
.then((result)=>{
if(result.data.status==0){
this.setState({
checkBoxValues:[],
checkAllValue:false
})
this.fetchAll(search,page,order,15)
this.props.showNotification(`${result.data.message}`);
this.fetchAll(search,page,order,15)
}
}).catch((error)=>{
console.log(error);
@ -554,9 +559,10 @@ class GraduationTasks extends Component{
}
// 题库选用成功后刷新页面
useBankSuccess=(checkBoxValues,object_ids)=>{
// debugger
//debugger
let {search,page,order,all_count} = this.state;
this.fetchAll(search,page,order,all_count)
}
getcourse_groupslist=(id)=>{
this.setState({
@ -651,7 +657,7 @@ class GraduationTasks extends Component{
</Link>
</WordsBtn> : ""}
{this.props.isAdmin() ?<UseBank {...this.props} {...this.state} object_type={"gtask"} useBankSuccess={(checkBoxValues,object_ids)=>this.useBankSuccess=(checkBoxValues,object_ids)}></UseBank>:""}
{this.props.isAdmin() ?<UseBank {...this.props} {...this.state} object_type={"gtask"} useBankSuccess={(checkBoxValues,object_ids)=>this.useBankSuccess(checkBoxValues,object_ids)}></UseBank>:""}
</React.Fragment>
}

@ -355,6 +355,13 @@ onBoardsNew=()=>{
DownloadMessageval:undefined
})
}
// 题库选用成功后刷新页面
useBankSuccess=(checkBoxValues,object_ids)=>{
//debugger
let {searchValue,page,status} =this.state
this.fetchAll(searchValue,page,status);
}
render(){
let {
searchValue,

@ -367,9 +367,9 @@ class Listofworksstudentone extends Component {
render: (text, record) => (
<span>
{
record.submitstate === "未提交" ?<span style={{ color: '#9A9A9A',cursor:"default"}}>--</span>
record.submitstate === "未提交" ?<span style={{ color: '#9A9A9A'}}>--</span>
:
<span style={{textAlign: "center",cursor:"default"}}
<span style={{textAlign: "center"}}
className="color-blue"
onClick={() => this.Viewstudenttraininginformation(record)}>{record.operating}</span>
}
@ -691,9 +691,9 @@ class Listofworksstudentone extends Component {
align: 'center',
className:'font-14',
render: (text, record) => (
record.submitstate === "未提交" ? <span style={{ color: '#9A9A9A',cursor:"default"}}>--</span> :
record.submitstate === "未提交" ? <span style={{ color: '#9A9A9A'}}>--</span> :
<span>
<a style={{textAlign: "center",cursor:"default"}} className="color-blue"
<a style={{textAlign: "center"}} className="color-blue"
onClick={() => this.Viewstudenttraininginformationt(record)}>{record.operating}</a>
</span>
)
@ -985,9 +985,9 @@ class Listofworksstudentone extends Component {
align: 'center',
className:'font-14',
render: (text, record) => (
record.submitstate === "未提交" ? <span style={{ color: '#9A9A9A',cursor:"default"}}>--</span> :
record.submitstate === "未提交" ? <span style={{ color: '#9A9A9A'}}>--</span> :
<span>
<a style={{textAlign: "center",cursor:"default"}} className="color-blue"
<a style={{textAlign: "center"}} className="color-blue"
onClick={() => this.Viewstudenttraininginformationt(record)}>{record.operating}</a>
</span>
)

@ -500,8 +500,8 @@ class PathDetailIndex extends Component{
</div>
{
detailInfoList===undefined?"":detailInfoList.allow_add_member===true? <div>
<div className="fr ml15 flex1"><a onClick={()=>this.moveup(item)}><Tooltip title="上移"><i className="color-green font-18 iconfont icon-xiangshangyi"></i></Tooltip></a></div>
<div className="fr ml15 flex1 "><a onClick={()=>this.movedown(item)}><Tooltip title="下移"><i className="color-green font-18 iconfont icon-xiangxiayi"></i></Tooltip></a></div>
{key!=0?<div className="fr ml15 flex1"><a onClick={()=>this.moveup(item)}><Tooltip title="上移"><i className="color-green font-18 iconfont icon-xiangshangyi"></i></Tooltip></a></div>:""}
{key+1!=detailInfoList.members.length?<div className="fr ml15 flex1 "><a onClick={()=>this.movedown(item)}><Tooltip title="下移"><i className="color-green font-18 iconfont icon-xiangxiayi"></i></Tooltip></a></div>:""}
</div>
:""
}

@ -187,8 +187,8 @@ class addCollaborators extends Component{
{
partnerList && partnerList.map((item,key)=>{
return(
<li className="clearfix">
<Checkbox value={item.user_id} key={key} className="fl"></Checkbox>
<li className="clearfix" key={key}>
<Checkbox value={item.user_id} key={item.user_id} className="fl"></Checkbox>
<a target="_blank" className="task-hide color-grey3 fl span1 edu-txt-w80">{item.user_name}</a>
<span className="task-hide fl color-grey edu-txt-w80 span2">{item.nickname}</span>
<span className="task-hide fl color-grey edu-txt-w80 span2">{item.identity}</span>

@ -826,6 +826,9 @@ submittojoinclass=(value)=>{
{/* p 老师 l 学生 */}
<li><Link to={`/users/${this.props.current_user===undefined?"":this.props.current_user.login}/shixuns`}>我的实训</Link></li>
<li><Link to={`/users/${this.props.current_user===undefined?"":this.props.current_user.login}/paths`}>我的实践课程</Link></li>
<li style={{display: this.props.Headertop === undefined ? 'none' : this.props.Headertop.customer_management_url===null || this.props.Headertop.customer_management_url===""? 'none' : 'block'}}>
<a href={this.props.Headertop === undefined ? '' : this.props.Headertop.customer_management_url}>客户管理</a>
</li>
<li><Link to={`/users/${this.props.current_user===undefined?"":this.props.current_user.login}/projects`}>我的项目</Link></li>
<li><Link to={`/users/${this.props.current_user===undefined?"":this.props.current_user.login}/package`}>我的众包</Link></li>
<li><a href={`/account/profile`}>账号管理</a></li>

@ -362,6 +362,7 @@ export function TPMIndexHOC(WrappedComponent) {
overflow: hidden;
}
.newHeaders{
// position: fixed;
max-width: unset;
background: #24292D !important;
width: 100%;

@ -183,14 +183,14 @@ class SearchPage extends Component{
return (
<a key={key}
href={
item.type==="shixun"?`/shixuns/${item.identifier}/challenges`:item.type==="course"?`/courses/${item.id}/students`:item.type==="subject"?`/paths/${item.id}`:item.type==="memo"?`/forums/${item.id}`:""
item.type==="shixun"?`/shixuns/${item.identifier}/challenges`:item.type==="course"?`${item.first_category_url}`:item.type==="subject"?`/paths/${item.id}`:item.type==="memo"?`/forums/${item.id}`:""
}
target="_blank"
>
<div className="project-package-item">
<div className={"font-16 color-dark fl "} >
<div className={"font-16 color-dark fl "} style={{width:"100%"}} >
{/*标题*/}
<span className={"markdown-body fonttext"}
dangerouslySetInnerHTML={{__html:item.title}}/>

Loading…
Cancel
Save