Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

courseware
anke1460 5 years ago
commit 0cb8fe37ac

@ -164,6 +164,8 @@ class ChallengesController < ApplicationController
@challenges = @shixun.challenges.joins(join_sql).select(base_columns).uniq
@shixun_modify = (@challenges.select{|c| c.status.present? }.size == @challenges.size)
#@challenges = @shixun.challenges.fields_for_list
@editable = @shixun.status == 0 # before_action有判断权限如果没发布则肯定是管理人员
@user = current_user

@ -99,7 +99,7 @@ class CoursesController < ApplicationController
limit = params[:limit] || 16
@courses = @courses.page(page).per(limit)
@courses = @courses.preload(:school, :none_hidden_course_modules, teacher: :user_extension)
@courses = @courses.preload(:school, :teacher_users, :none_hidden_course_modules, teacher: :user_extension)
end
def course_videos
@ -1306,6 +1306,7 @@ class CoursesController < ApplicationController
@user = current_user
@switch_student = Course::BUSINESS < @user_course_identity && @user_course_identity < Course::STUDENT
@is_student = @user_course_identity == Course::STUDENT
@teacher_users = @course.teacher_users.where.not(id: @course.tea_id).map(&:real_name)[0..2]
@course.increment!(:visits)
end

@ -5,7 +5,7 @@ class Users::CoursesController < Users::BaseController
courses = courses.where(id: current_laboratory.all_courses)
@count = courses.count
@courses = paginate(courses.includes(teacher: { user_extension: :school }), special: observed_user.is_teacher?)
@courses = paginate(courses.includes(:teacher_users, teacher: { user_extension: :school }), special: observed_user.is_teacher?)
end
private

@ -69,13 +69,17 @@ class Challenge < ApplicationRecord
end
# 开启挑战
def open_game shixun
def open_game shixun, shixun_modify
# 这里的identifier,status是关联了games取了games的identifier,status
identifier = self.identifier
if identifier.present?
shixun.task_pass || self.status != 3 ? "/tasks/#{identifier}" : ""
if shixun_modify
"/shixuns/#{shixun.identifier}/shixun_exec.json"
else
(shixun.task_pass || self.status != 3) ? "/tasks/#{identifier}" : ""
end
else
self.position == 1 ? "/shixuns/#{shixun.identifier}/shixun_exec.json" : ""
(shixun.task_pass || position == 1) ? "/shixuns/#{shixun.identifier}/shixun_exec.json" : ""
end
end

@ -22,7 +22,7 @@ if @challenges.present?
#json.playing_count @play_games_map.fetch(challenge.id, 0)
json.playing_count (challenge.games.count - user_passed_count)
json.name_url shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier)
json.open_game challenge.open_game(@shixun)
json.open_game challenge.open_game(@shixun, @shixun_modify)
#json.open_game challenge.open_game(@shixun, @user.id)
if @editable
json.edit_url edit_shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier)

@ -13,5 +13,7 @@ json.courses @courses do |course|
json.is_end course.is_end
json.first_category_url module_url(course.none_hidden_course_modules.first, course)
json.excellent course.excellent
json.teacher_users course.teacher_users.select{|u| u.id != course.tea_id }.map(&:real_name)[0..2] # 取前3名老师
end
json.courses_count @courses_count

@ -22,6 +22,8 @@ json.switch_to_assistant switch_assistant_role(@is_student, @course, @user)
#json.copy_course !@user.member_of_course?(@course) && @user.is_teacher?
json.course_identity @user_course_identity
json.excellent @course.excellent
# 协作老师
json.teacher_users @teacher_users
if @course.is_end == 0
json.days_remaining (@course.end_date.to_date - Time.now.to_date).to_i
end

@ -7,6 +7,8 @@ json.homework_commons_count get_tasks_count course
json.attachments_count course.attachments.count
json.visits course.visits
json.school course.school&.name
json.teacher_users course.teacher_users.select{|u| u.id != course.tea_id }.map(&:real_name)[0..2] # 取前3名老师
json.first_category_url module_url(course.course_modules.where(hidden: 0).order(position: :desc).first, course)

Loading…
Cancel
Save