Merge branch 'dev_aliyun' into dev_cxt

dev_ec
cxt 5 years ago
commit fcbe14c56f

@ -269,8 +269,9 @@ class CoursesController < ApplicationController
def online_learning
@subject = @course.subject
@stages = @course.course_stages
@stages = @course.course_stages.includes(:shixuns)
@user = current_user
@myshixuns = @user.myshixuns.where(shixun_id: @course.course_stage_shixuns.pluck(:shixun_id))
@start_learning = @user_course_identity == Course::STUDENT && @course.learning?(current_user.id)
end

@ -25,7 +25,6 @@ class ExercisesController < ApplicationController
include ExercisesHelper
def index
ActiveRecord::Base.transaction do
begin
# 按发布时间或创建时间排序
@exercises_all = @course.exercises
@ -105,7 +104,6 @@ class ExercisesController < ApplicationController
raise ActiveRecord::Rollback
end
end
end
def new
ActiveRecord::Base.transaction do

@ -6,7 +6,8 @@ class StagesController < ApplicationController
def index
@user = current_user
@stages = @subject.stages
@stages = @subject.stages.includes(:shixuns)
@myshixuns = @user.myshixuns.where(shixun_id: @subject.stage_shixuns.pluck(:shixun_id))
end
def create

@ -1,8 +1,8 @@
module StagesHelper
# 章节实训的通关情况
def stage_myshixun_status shixun, user
myshixun = Myshixun.where(user_id: user.id, shixun_id: shixun.id).take
def stage_myshixun_status myshixun
# myshixun = Myshixun.where(user_id: user.id, shixun_id: shixun.id).take
myshixun.try(:status) == 1 ? 1 : 0
end

@ -1,5 +1,5 @@
json.stages @stages do |stage|
json.partial! 'stages/stage', locals: {stage: stage, user:@user, subject:@subject}
json.partial! 'stages/stage', locals: {stage: stage, user: @user, subject: @subject, myshixuns: @myshixuns}
end
# json.description @subject&.description

@ -0,0 +1,2 @@
json.course_targets @course_targets, partial: 'ecs/course_targets/shared/ec_course_target_with_achievement_methods', as: :ec_course_target

@ -15,7 +15,7 @@ json.shixuns_list do
json.shixun_name shixun.name
json.shixun_hidden shixun.hidden
json.identifier shixun.identifier
json.complete_status stage_myshixun_status(shixun, user)
json.complete_status stage_myshixun_status(myshixuns.select{|ms| ms.shixun_id == shixun.id}.first)
json.shixun_status stage_shixun_status(subject.status, shixun.status, shixun.hidden)
end
end

@ -1,3 +1,3 @@
json.stages @stages do |stage|
json.partial! 'stage', locals: {stage: stage, user:@user, subject:@subject}
json.partial! 'stage', locals: {stage: stage, user: @user, subject: @subject, myshixuns: @myshixuns}
end
Loading…
Cancel
Save