From ddba71decf5d5edee2ffa11aecaef0ac05eff902 Mon Sep 17 00:00:00 2001 From: z9han Date: Fri, 19 Dec 2014 17:37:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E7=9A=84=E6=89=80=E6=9C=89?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=8E=A5=E5=8F=A3=E3=80=81=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E7=9A=84=E6=89=80=E6=9C=89=E8=AF=BE=E7=A8=8B=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=8F=8A=E7=95=99=E8=A8=80=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/courses_service.rb | 63 ++++++++++++++++++++++++++++++++ app/services/homework_service.rb | 2 +- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 09e4289b5..96766acfd 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -228,4 +228,67 @@ class CoursesService end end + #我的课程列表 + def my_course_list params,current_user + unless current_user.admin? + if !current_user.active? + raise '404' #当前账户不可访问,返回404(可视为当前用户不存在) + end + end + membership = @user.coursememberships.all + membership.sort! {|older, newer| newer.created_on <=> older.created_on } + + end + + #课程作业列表 + def course_homework_list course,current_user + if course.is_public != 0 || current_user.member_of_course?(course) || current_user.admin? + @bids = course.homeworks.order('deadline DESC') + else + raise '403' + end + end + + #obj 回复所属父留言的留言对象 + def create_reply params,obj + parent_id = params[:reference_id] + author_id = User.current.id + reply_user_id = params[:reference_user_id] + reply_id = params[:reference_message_id] # 暂时不实现 + content = params[:user_notes] + @show_name = params[:show_name] == "true" + options = {:user_id => author_id, + :status => true, + :m_parent_id => parent_id, + :m_reply_id => reply_id, + :reply_id => reply_user_id, + :notes => content, + :is_readed => false} + @jfm = add_reply_adapter options,obj + [@show_name,@jfm] + end + + def add_reply_adapter options,obj + #添加对课程留言的支持 + #留言回复应该不关系其所属的Class,而关心的是其所属的父留言 + #obj = obj_distinguish_url_origin || User.find_by_id(2) + if obj.kind_of? User + obj.add_jour(nil, nil, nil, options) + elsif obj.kind_of? Project + Project.add_new_jour(nil, nil, obj.id, options) + elsif obj.kind_of? Course + Course.add_new_jour(nil, nil, obj.id, options) + elsif obj.kind_of? Bid + obj.add_jour(nil, nil, nil, options) + elsif obj.kind_of? Contest + obj.add_jour(nil, nil, obj.id, options) #new added + elsif obj.kind_of? Softapplication + obj.add_jour(nil, nil, obj.id, options) #new added + elsif obj.kind_of? HomeworkAttach + obj.add_jour(nil, nil, obj.id, options) #new added + else + raise "create reply obj unknow type.#{obj.class}" + end + end + end \ No newline at end of file diff --git a/app/services/homework_service.rb b/app/services/homework_service.rb index dd5fb9dca..a27757917 100644 --- a/app/services/homework_service.rb +++ b/app/services/homework_service.rb @@ -18,7 +18,7 @@ class HomeworkService description = @bid.description if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2 @state = bid.comment_status - end + end end #启动作业匿评