dev_oauth
杨树明 6 years ago
commit c751fecf72

@ -555,11 +555,22 @@ class ShixunsController < ApplicationController
# 判断实训是否全为选择题
is_choice_type = (min_challenges.size == min_challenges.select{|challenge| challenge.last == 1}.count)
if !is_choice_type
commit = GitService.commits(repo_path: @repo_path).try(:first)
uid_logger("First comit########{commit}")
tip_exception("开启实战前请先在版本库中提交代码") if commit.blank?
commit_id = commit["id"]
# if !is_choice_type
# commit = GitService.commits(repo_path: @repo_path).try(:first)
# uid_logger("First comit########{commit}")
# tip_exception("开启实战前请先在版本库中提交代码") if commit.blank?
# 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

@ -83,19 +83,25 @@ 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
# 访问数变更
@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
@challenge_count = challenge_ids.size
# 访问数变更
@subject.increment!(:visits)
end
def new

@ -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

@ -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,23 +12,14 @@ json.allow_send @user.logged?
json.allow_visit @subject.status > 1 || @is_manager
json.allow_add_member @is_manager
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)
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.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

@ -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

Binary file not shown.

@ -0,0 +1,19 @@
#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)
exercises = course.exercises
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)
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,28 @@
#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
unless CourseMember.exists?(course_id: course_id, user_id: user_id)
CourseMember.create!(course_id: course_id, user_id: user_id, role: 4)
CourseAddStudentCreateWorksJob.perform_later(course_id, [user_id])
end
end
end
end
end

@ -682,16 +682,23 @@ class Coursesleftnav extends Component{
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)
}
}
}
}
@ -989,8 +996,8 @@ class Coursesleftnav extends Component{
>
<a className={ item.second_category===undefined?"fl ml20 pd0":item.second_category.length===0?"fl ml20 pd0":this.state.sandiantypes===key?"fl ml20 pd0 ebebeb":"fl ml20 pd0"}>
{
item.type==="announcement"?<i className={this.props.location.pathname===item.category_url?"color-blue iconfont icon-daima mr10 fl":"iconfont icon-daima mr10 fl"}></i>:
item.type==="online_learning"?<i className={this.props.location.pathname===item.category_url?"color-blue iconfont icon-daima mr10 fl":"iconfont icon-daima mr10 fl"}></i>:
item.type==="announcement"?<i className={this.props.location.pathname===item.category_url?"color-blue iconfont icon-xiaoxi1 mr10 fl":"iconfont icon-xiaoxi1 mr10 fl"}></i>:
item.type==="online_learning"?<i className={this.props.location.pathname===item.category_url?"color-blue iconfont icon-xuexizhongxin mr10 fl":"iconfont icon-xuexizhongxin mr10 fl"}></i>:
item.type==="shixun_homework"?<i className={this.props.location.pathname===item.category_url?"color-blue iconfont icon-daima mr10 fl":"iconfont icon-daima mr10 fl"}></i>:
item.type==="common_homework"?<i className={this.props.location.pathname===item.category_url?"color-blue iconfont icon-putongzuoye mr10 fl":"iconfont icon-putongzuoye mr10 fl"}></i>:
item.type==="group_homework"?<i className={this.props.location.pathname===item.category_url?"color-blue iconfont icon-fenzuzuoye mr10 fl":"iconfont icon-fenzuzuoye mr10 fl"}></i>:

Loading…
Cancel
Save