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

dev_forum
jingquan huang 5 years ago
commit f3db5a8ef3

@ -47,19 +47,19 @@ class CoursesController < ApplicationController
@order = params[:order].present? ? params[:order] : "all"
order_str = @order != "course_members_count" && @order != "created_at" ? "updated_at" : @order
if @order == "all"
# if @order == "all"
# @course = Course.where(is_delete: 0, is_hidden: 0).select("select c.name, c.id, s.name, u.login, ifnull(concat(u.lastname,u.firstname),
# u.login), s.name from courses c, users u, user_extensions ue, schools s where c.is_delete=0 and
# c.tea_id=u.id and u.id=ue.user_id and ue.school_id=s.id")
@courses = Course.where(is_delete: 0, is_hidden: 0)
.order("courses.id = 1309 desc, courses.created_at desc")
# @courses = Course.where(is_delete: 0, is_hidden: 0)
# .order("courses.id = 1309 desc, courses.created_at desc")
# @courses = Course.where(is_delete: 0, is_hidden: 0).select("courses.id, courses.tea_id, courses.name, courses.exercises_count, courses.polls_count,
# courses.is_public, courses.is_end, courses.visits, courses.course_members_count,courses.homework_commons_count,(SELECT MAX(created_at)
# FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a")
# .order("courses.id = 1309 desc, a desc")
elsif @order == "mine"
if @order == "mine"
@courses = Course.joins(:course_members)
.where("is_delete = 0 AND is_hidden = 0 AND course_members.user_id = ?", @user.id)
.order("courses.id = 1309 DESC, courses.#{order_str} DESC")
@ -86,7 +86,7 @@ class CoursesController < ApplicationController
(course_members.role in(1,2,3) and CONCAT(users.lastname, users.firstname) like :keyword) or courses.name like :keyword
or schools.name like :keyword
}
@courses = @courses.joins(:school, course_members: [user: :user_extension])
@courses = @courses.joins(:school, course_members: :user)
.where("#{sql}", keyword: "%#{params[:search]}%").distinct
end
@courses_count = @courses.size

@ -1390,7 +1390,7 @@ class ExercisesController < ApplicationController
if @paging_type == "percent"
@question_result_hash = ques_result_all.sort_by{|s| s[:percent]}
else
@question_result_hash = ques_result_all.sort_by{|s| s["#{@paging_type}"]}
@question_result_hash = ques_result_all.sort_by{|s| s[:"#{@paging_type}"]}
end
@exercise_questions_count = @exercise_questions.size

@ -28,6 +28,6 @@ class Users::AvatarsController < Users::BaseAccountController
end
def avatar_url
ApplicationController.helpers.url_to_avatar(observed_user)
ApplicationController.helpers.url_to_avatar(observed_user).to_s + "?#{Time.now.to_i}"
end
end

@ -216,10 +216,19 @@ module ExercisesHelper
ex.exercise_shixun_challenges.each do |c|
cha_score = c&.question_score
cha_shixun_answer = effictive_users.search_shixun_keys("exercise_shixun_challenge_id",c.id)
effictive_users_count = cha_shixun_answer.count #实训题的每个关卡的有效填写量
full_scores = cha_shixun_answer.search_shixun_keys("score",cha_score).count #满分人数
no_full_scores = cha_shixun_answer.shixun_no_full_scores(cha_score).count #部分分数人数c
all_zero_scores = cha_shixun_answer.search_shixun_keys("score",0.0).count #满分人数
effictive_users_count = cha_shixun_answer.size #实训题的每个关卡的有效填写量
full_scores = cha_shixun_answer.search_shixun_keys("score",cha_score).size #满分人数
no_full_scores = cha_shixun_answer.shixun_no_full_scores(cha_score).size #部分分数人数c
all_zero_scores = cha_shixun_answer.search_shixun_keys("score",0.0).size #零分人数
shixun_scores = user_ids.count * cha_score
shixun_answered_scores = cha_shixun_answer.score_reviewed.pluck(:score).sum #该问题的全部得分
if shixun_answered_scores == 0.0
game_percent = "0.0"
else
game_percent = (shixun_answered_scores / shixun_scores.to_f).round(3) * 100 #正确率
end
shixun_score_array = [full_scores,no_full_scores,all_zero_scores]
shixun_chas = []
shixun_score_array.each_with_index do |s,index|
@ -242,7 +251,8 @@ module ExercisesHelper
:cha_id => c.challenge_id,
:cha_name => c.challenge.subject,
:cha_position => c.position,
:cha_details => shixun_chas
:cha_details => shixun_chas,
:cha_percent => game_percent
}
question_answer_infos.push(shixun_new_chas)
end

@ -48,6 +48,7 @@ json.commit_results do
json.challenge_id cha[:cha_id]
json.challenge_name cha[:cha_name]
json.challenge_position cha[:cha_position]
json.challenge_percent cha[:cha_percent]
json.challenge_details do
json.array! cha[:cha_details] do |ch|
json.choice_position ch[:choice_position]

@ -36,7 +36,7 @@ json.exercises_counts do
json.exercises_all_counts @exercises_select_count #选择后的全部试卷数
json.exercises_unpublish_counts @exercises_unpublish_counts #未发布试卷数
json.exercises_published_counts @exercises_published_counts #已发布试卷数
json.exercises_ended_counts @exercises_ended_counts #已截止试卷数
# json.exercises_ended_counts @exercises_ended_counts #已截止试卷数
json.left_banner_id @left_banner_id
json.left_banner_name @left_banner_name
end

@ -3,5 +3,5 @@ json.login user.login
json.name user.full_name
json.grade user.grade
# json.email user.mail # 邮箱原则上不暴露的,如果实在需要的话只能对某些具体的接口公开
json.image_url url_to_avatar(user)
json.image_url image_url(url_to_avatar(user))
json.school user.school_name
Loading…
Cancel
Save