新版课程动态 课程作业展示

This commit is contained in:
lizanle 2015-06-26 09:18:12 +08:00
parent d73a2c1003
commit e5082ff489
3 changed files with 38 additions and 12 deletions

View File

@ -22,7 +22,7 @@ module Mobile
end
end
obj
elsif field == :jour_message_count
elsif field == :topic_count
obj = nil
c[:dynamics].each do |d|
if d[:type] == 2
@ -80,7 +80,7 @@ module Mobile
course_dynamic_expose :count
course_dynamic_expose :news_count
course_dynamic_expose :document_count
course_dynamic_expose :jour_message_count
course_dynamic_expose :topic_count
course_dynamic_expose :homework_count
course_dynamic_expose :homework_submit_students
course_dynamic_expose :homework_submit_num
@ -95,11 +95,11 @@ module Mobile
end
obj
end
expose :jour_message,using:Mobile::Entities::Jours do |f,opt|
expose :topic,using:Mobile::Entities::Message do |f,opt|
obj = nil
f[:dynamics].each do |d|
if d[:type] == 2
obj = d[:jour_message]
obj = d[:topic]
end
end
obj

View File

@ -68,6 +68,10 @@ module Mobile
homework_expose :homework_notsubmit_num
expose :submit_student_list ,using:Mobile::Entities::User do |f,opt|
f[:studentlist]
end
end
end
end

View File

@ -330,7 +330,7 @@ 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.order('end_time DESC')
bids = course.homework_commons.page(1).per(3).order('end_time DESC')
bids = bids.like(params[:name]) if params[:name].present?
homeworks = []
bids.each do |bid|
@ -540,14 +540,35 @@ class CoursesService
#student_questions_count = bid.journals_for_messages.where('m_parent_id IS NULL').count
description = bid.description
#if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2
state = bid.homework_detail_manual.comment_status
#state = bid.homework_detail_manual.comment_status
if !bid.nil?
if bid.homework_type == 1 && bid.homework_detail_manual
case bid.homework_detail_manual.comment_status
when 1
state = show_homework_deadline bid
when 2
state = "正在匿评中"
when 3
state = "匿评已结束"
end
elsif bid.homework_type == 0
state = "未启用匿评"
elsif bid.homework_type == 2
state = "编程作业"
else
end
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}
: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}
end
@ -628,9 +649,9 @@ class CoursesService
return
end
if current_user == @user || current_user.admin?
membership = @user.coursememberships.all
membership = @user.coursememberships.page(1).per(10)
else
membership = @user.coursememberships.all(:conditions => Course.visible_condition(current_user))
membership = @user.coursememberships.page(1).per(10).all(:conditions => Course.visible_condition(current_user))
end
if membership.nil? || membership.count == 0
raise l(:label_no_courses, :locale => get_user_language(current_user))
@ -653,9 +674,10 @@ class CoursesService
end
# 课程讨论区
latest_message = course.journals_for_messages.where("m_parent_id is null").order("created_on desc").first
latest_message = course.boards.first.topics[0]
unless latest_message.nil?
latest_course_dynamics << {:type => 2, :time => latest_message.created_on, :count =>course.journals_for_messages.where('m_parent_id is null').count, :jour_message => latest_message}
latest_course_dynamics << {:type => 2, :time => latest_message.created_on, :count =>course.boards.nil? ? 0 : course.boards.first.topics.count,
:topic => latest_message}
dynamics_count += 1
end
@ -710,7 +732,7 @@ class CoursesService
#计算作业的截止日期,剩余日期
def show_homework_deadline homework
"截止日期:" << homework.end_time.to_s << ",剩余时间:" << (Date.parse(Time.now.to_s) - Date.parse(homework.end_time.to_s)).to_i.to_s << ""
"距作业截止还有" << (Date.parse(Time.now.to_s) - Date.parse(homework.end_time.to_s)).to_i.to_s << ""
end
end