登录api修改

活跃值,平均成绩 是否可以加载 需要计算 最大值
This commit is contained in:
lizanle 2015-07-09 14:32:10 +08:00
parent 1b1cce615d
commit 8d7faaced6
3 changed files with 42 additions and 16 deletions

View File

@ -26,7 +26,8 @@ module Mobile
present :data, {token: key.access_token, user: api_user}, using: Entities::Auth
present :status, 0
else
raise "无效的用户名或密码"
present :message, "无效的用户名或密码"
present :status,1
end
end

View File

@ -322,7 +322,9 @@ module Mobile
get ':course_id/students_score_list' do
cs = CoursesService.new
news = cs.students_score_list params,current_user
present :data,news,with:Mobile::Entities::User
present :data,news[:user_list],with:Mobile::Entities::User
present :maxSize,news[:max_size]
present :status,0
end
desc '课程某次作业提交列表 并显示成绩'

View File

@ -333,13 +333,13 @@ class CoursesService
def homework_list params,current_user
course = Course.find(params[:id])
if course.is_public != 0 || current_user.member_of_course?(course)
bids = course.homework_commons.page(1).per(20).order('created_at DESC')
bids = course.homework_commons.page(params[:page] || 1).per(20).order('created_at DESC')
bids = bids.like(params[:name]) if params[:name].present?
homeworks = []
bids.each do |bid|
homeworks << show_homework_info(course,bid,current_user,is_course_teacher(current_user,course))
end
homeworks
homeworks = []
bids.each do |bid|
homeworks << show_homework_info(course,bid,current_user,is_course_teacher(current_user,course))
end
homeworks
else
raise '403'
end
@ -552,17 +552,28 @@ class CoursesService
else
end
end
studentlist = []
bid.student_works.order("created_at desc").page(1).per(6).each do |work|
studentlist << work.user
end
# studentlist = []
# bid.student_works.order("created_at desc").page(1).per(6).each do |work|
# studentlist << work.user
# end
unless is_course_teacher
homework_for_anonymous_comments = get_student_batch_homework_list bid,current_user
end
#end
open_anonymous_evaluation = bid.homework_detail_manual.comment_status
{:course_name => course.name,:course_id => course.id,:id => bid.id, :author => bid.user,:author_real_name => author_real_name, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => 0,
:description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:homework_for_anonymous_comments => homework_for_anonymous_comments,:created_on => bid.created_at,:deadline => bid.end_time,:studentlist => studentlist}
{:course_name => course.name,:course_id => course.id,:id => bid.id,
:author => bid.user,:author_real_name => author_real_name,
:homework_times => many_times, :homework_name => name,
:homework_count => homework_count,:student_questions_count => 0,
:description => description, :homework_state => state,
:open_anonymous_evaluation => open_anonymous_evaluation,
:homework_for_anonymous_comments => homework_for_anonymous_comments,
:created_on => bid.created_at,:deadline => bid.end_time,
:homework_notsubmit_num => bid.course.members.count - bid.student_works.count,
:homework_submit_num => bid.student_works.count,
:homework_status_student => get_homework_status( bid),:homework_status_teacher => homework_status_desc( bid),
:student_evaluation_part => get_evaluation_part( bid ,3),
:ta_evaluation_part => get_evaluation_part( bid ,2),:homework_anony_type => bid.homework_type == 1 && !bid.homework_detail_manual.nil?}
end
@ -720,20 +731,32 @@ class CoursesService
# 获取课程历次作业的学生总成绩
def students_score_list params,current_user
page = (params[:page] || 1) - 1
user_list = []
max_size = 0
if params[:type] == 1
homework_count = Course.find(params[:course_id]).homework_commons.count
sql = "select users.*,sum(IFNULL(0,student_works.final_score))/#{homework_count} score from student_works left outer join users on student_works.user_id = users.id" <<
" where homework_common_id in ( select id from homework_commons where homework_commons.course_id = #{params[:course_id]}) GROUP BY student_works.user_id ORDER BY score limit #{page*10},10"
User.find_by_sql(sql)
sql_count = " select count(distinct(student_works.user_id) ) " <<
" from student_works left outer join users on student_works.user_id = users.id " <<
" where homework_common_id in " <<
" ( select id from homework_commons where homework_commons.course_id = #{params[:course_id]}) "
max_size = ActiveRecord::Base.connection().select_value(sql_count)
user_list = User.find_by_sql(sql)
else
sql1 = " select users.*,count(author_id)*2 active_count from messages " <<
" LEFT JOIN users on messages.author_id = users.id " <<
" where messages.board_id in (select id from boards where boards.course_id = #{params[:course_id]} ) " <<
" GROUP BY messages.author_id ORDER BY count(author_id) desc " <<
" limit #{page*10},10"
User.find_by_sql(sql1)
sql1_count = " select count(DISTINCT(messages.author_id))" <<
" from messages LEFT JOIN users on messages.author_id = users.id " <<
" where messages.board_id in (select id from boards where boards.course_id = #{params[:course_id]} )"
max_size = ActiveRecord::Base.connection().select_value(sql1_count)
user_list = User.find_by_sql(sql1)
end
{:user_list=>user_list,:max_size=>max_size}
end
# 获取某次作业的所有作业列表