parent
662fc02a80
commit
fe55258349
|
@ -336,6 +336,19 @@ module Mobile
|
|||
student_works = cs.student_work_list params,current_user
|
||||
present :data,student_works.all,with:Mobile::Entities::StudentWork
|
||||
end
|
||||
|
||||
desc '开启匿评'
|
||||
params do
|
||||
requires :token,type:String
|
||||
requires :course_id,type:Integer,desc:'课程id'
|
||||
requires :homework_id,type:Integer,desc:'作业id'
|
||||
end
|
||||
get ':course_id/start_anonymous_comment' do
|
||||
cs = CoursesService.new
|
||||
status = cs.start_anonymous_comment params,current_user
|
||||
present :data,status
|
||||
present :status,0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,6 +28,8 @@ module Mobile
|
|||
get_homework_status f
|
||||
when :homework_times
|
||||
f.course.homework_commons.index(f) + 1
|
||||
when :homework_status_desc
|
||||
homework_status_desc f
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -80,7 +82,8 @@ module Mobile
|
|||
expose :submit_student_list ,using: Mobile::Entities::User do |f,opt|
|
||||
get_submit_sutdent_list f
|
||||
end
|
||||
homework_expose :homework_status
|
||||
homework_expose :homework_status #作业的状态
|
||||
homework_expose :homework_status_desc #状态的解释
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -89,6 +89,29 @@ module ApiHelper
|
|||
homework_status
|
||||
end
|
||||
|
||||
#获取作业的是否可以匿评的描述
|
||||
def homework_status_desc homework
|
||||
if homework.homework_type == 1 && homework.homework_detail_manual #匿评作业
|
||||
if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
link = "<span class='fr mr10 pr_join_span ' title='作业截止日期之前不可以启动匿评'>启动匿评</span>".html_safe
|
||||
elsif homework.student_works.count >= 2 #作业份数大于2
|
||||
case homework.homework_detail_manual.comment_status
|
||||
when 1
|
||||
link = '启动匿评'
|
||||
when 2
|
||||
link = '关闭匿评'
|
||||
when 3
|
||||
link = " 匿评结束"
|
||||
end
|
||||
else
|
||||
link = "学生提交作业数大于2时才可以启动匿评"
|
||||
end
|
||||
else
|
||||
link = "未开启匿评作业不可以启动匿评"
|
||||
end
|
||||
link
|
||||
end
|
||||
|
||||
#获取
|
||||
def get_submit_sutdent_list homework
|
||||
studentlist = []
|
||||
|
@ -104,6 +127,11 @@ module ApiHelper
|
|||
|
||||
#计算作业的截止日期,剩余日期
|
||||
def show_homework_deadline homework
|
||||
"距作业截止还有" << (Date.parse(Time.now.to_s) - Date.parse(homework.end_time.to_s)).to_i.to_s << "天"
|
||||
day = 0
|
||||
if (day = (Date.parse(homework.end_time.to_s) - Date.parse(Time.now.to_s)).to_i) > 0
|
||||
"距作业截止还有" << (Date.parse(Time.now.to_s) - Date.parse(homework.end_time.to_s)).to_i.to_s << "天"
|
||||
else
|
||||
"已截止,但可补交"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -651,9 +651,9 @@ class CoursesService
|
|||
return
|
||||
end
|
||||
if current_user == @user || current_user.admin?
|
||||
membership = @user.coursememberships.page(1).per(10)
|
||||
membership = @user.coursememberships.page(1).per(15)
|
||||
else
|
||||
membership = @user.coursememberships.page(1).per(10).all(:conditions => Course.visible_condition(current_user))
|
||||
membership = @user.coursememberships.page(1).per(15).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))
|
||||
|
@ -669,10 +669,11 @@ class CoursesService
|
|||
dynamics_count = 0
|
||||
# 课程学霸 学生总分数排名靠前的5个人
|
||||
homework_count = course.homework_commons.count
|
||||
unless homework_count == 0
|
||||
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" <<
|
||||
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 = #{course.id}) GROUP BY student_works.user_id ORDER BY score limit 0,6"
|
||||
latest_course_dynamics <<{:type=> 6,:time=>Time.now.to_s,:count=> 6,:better_students=> User.find_by_sql(sql)}
|
||||
better_students = User.find_by_sql(sql)
|
||||
if homework_count != 0 && !better_students.empty?
|
||||
latest_course_dynamics <<{:type=> 6,:time=>Time.now.to_s,:count=> 6,:better_students=> better_students}
|
||||
dynamics_count += 1
|
||||
end
|
||||
# 课程通知
|
||||
|
@ -754,5 +755,41 @@ class CoursesService
|
|||
student_works
|
||||
end
|
||||
|
||||
# 开启匿评
|
||||
#statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启,4:没有开启匿评的权限
|
||||
def start_anonymous_comment params,current_user
|
||||
homework = HomeworkCommon.find(params[:homework_id])
|
||||
return {:status=>4} unless current_user.admin? || current_user.allowed_to?(:as_teacher,Course.find(params[:course_id]))
|
||||
return {:status=>5} if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
homework_detail_manual = homework.homework_detail_manual
|
||||
if homework_detail_manual.comment_status == 1
|
||||
student_works = homework.student_works
|
||||
if student_works && student_works.size >=2
|
||||
student_works.each_with_index do |work, index|
|
||||
user = work.user
|
||||
n = homework_detail_manual.evaluation_num
|
||||
n = n < student_works.size ? n : student_works.size - 1
|
||||
assigned_homeworks = get_assigned_homeworks(student_works, n, index)
|
||||
assigned_homeworks.each do |h|
|
||||
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id)
|
||||
student_works_evaluation_distributions.save
|
||||
end
|
||||
end
|
||||
homework_detail_manual.update_column('comment_status', 2)
|
||||
statue = 1
|
||||
else
|
||||
statue = 2
|
||||
end
|
||||
else
|
||||
statue = 3
|
||||
end
|
||||
{:status => statue}
|
||||
end
|
||||
|
||||
def get_assigned_homeworks(student_works, n, index)
|
||||
student_works += student_works
|
||||
student_works[index + 1 .. index + n]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue