diff --git a/app/api/mobile/apis/comments.rb b/app/api/mobile/apis/comments.rb index 86132a93a..7fa676161 100644 --- a/app/api/mobile/apis/comments.rb +++ b/app/api/mobile/apis/comments.rb @@ -113,6 +113,20 @@ module Mobile present :status, 0 end + desc '通知评论列表' + params do + requires :token, type: String + requires :notice_id,type:Integer,desc:'通知id' + optional :page,type:Integer,desc:'页码' + end + get ':notice_id/notice_comments' do + cs = CommentService.new + comments = cs.notice_comments params,current_user + present :data, comments, with: Mobile::Entities::Comment + present :status, 0 + end + + end end end diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 3d05ab3f3..39d2ebe9d 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -312,11 +312,12 @@ module Mobile present :status,0 end - desc '课程历次作业总成绩列表' + desc '总成绩 or 活跃度列表' params do requires :token,type:String requires :course_id,type:Integer,desc:'课程id' optional :page,type:Integer,desc:'页码' + optional :type,type:Integer,desc:'0是活跃度,1是成绩' end get ':course_id/students_score_list' do cs = CoursesService.new @@ -337,18 +338,7 @@ module Mobile 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 diff --git a/app/api/mobile/apis/homeworks.rb b/app/api/mobile/apis/homeworks.rb index 5bf454e32..e9efcb1fa 100644 --- a/app/api/mobile/apis/homeworks.rb +++ b/app/api/mobile/apis/homeworks.rb @@ -31,33 +31,33 @@ module Mobile present :status, 0 end - desc "启动匿评" - params do - requires :token, type: String - end - post ':id/start_anonymous_comment' do - statue = Homeworks.get_service.start_anonymous_comment params,current_user.nil? ? User.find(2):current_user - messages = "" - case statue - when 1 - messages = "启动成功" - when 2 - messages = "启动失败,作业总数大于等于2份时才能启动匿评" - when 3 - messages = "已开启匿评,请务重复开启" - end - present :data,messages - present :status, statue - end - - desc "关闭匿评" - params do - requires :token, type: String - end - post ':id/stop_anonymous_comment' do - Homeworks.get_service.stop_anonymous_comment params,current_user.nil? ? User.find(2):current_user - present :status, 0 - end + # desc "启动匿评" + # params do + # requires :token, type: String + # end + # post ':id/start_anonymous_comment' do + # statue = Homeworks.get_service.start_anonymous_comment params,current_user.nil? ? User.find(2):current_user + # messages = "" + # case statue + # when 1 + # messages = "启动成功" + # when 2 + # messages = "启动失败,作业总数大于等于2份时才能启动匿评" + # when 3 + # messages = "已开启匿评,请务重复开启" + # end + # present :data,messages + # present :status, statue + # end + # + # desc "关闭匿评" + # params do + # requires :token, type: String + # end + # post ':id/stop_anonymous_comment' do + # Homeworks.get_service.stop_anonymous_comment params,current_user.nil? ? User.find(2):current_user + # present :status, 0 + # end desc "匿评作品详情" params do @@ -111,6 +111,45 @@ module Mobile present :status, 0 end + desc '开启匿评' + params do + requires :token,type:String + requires :course_id,type:Integer,desc:'课程id' + requires :homework_id,type:Integer,desc:'作业id' + end + post ':homework_id/start_anonymous_comment' do + hs = Homeworks.get_service + status = hs.start_anonymous_comment params,current_user + messages = "" + case status[:status] + when 1 + messages = "启动成功" + when 2 + messages = "启动失败,作业总数大于等于2份时才能启动匿评" + when 3 + messages = "已开启匿评,请务重复开启" + when 4 + messages = "没有开启匿评的权限" + when 5 + messages = "截止日期之前不可启动匿评" + end + present :data,messages + present :status,0 + end + + desc '关闭匿评' + params do + requires :token,type:String + requires :course_id,type:Integer,desc:'课程id' + requires :homework_id,type:Integer,desc:'作业id' + end + post ':homework_id/stop_anonymous_comment' do + hs = Homeworks.get_service + hs.stop_anonymous_comment params,current_user + message = "成功关闭" + present :data, message + present :status,0 + end end end diff --git a/app/api/mobile/entities/course_dynamic.rb b/app/api/mobile/entities/course_dynamic.rb index 46ab5b272..fe31668ff 100644 --- a/app/api/mobile/entities/course_dynamic.rb +++ b/app/api/mobile/entities/course_dynamic.rb @@ -58,7 +58,11 @@ module Mobile course_dynamic_expose :document_count course_dynamic_expose :topic_count course_dynamic_expose :homework_count - #在dynamics里解析出四种动态 + course_dynamic_expose :course_student_num + course_dynamic_expose :time_from_now + course_dynamic_expose :current_user_is_member + course_dynamic_expose :current_user_is_teacher + expose :documents,using:Mobile::Entities::Attachment do |f,opt| obj = nil f[:dynamics].each do |d| @@ -107,6 +111,16 @@ module Mobile obj end + expose :active_students,using:Mobile::Entities::User do |f,opt| + obj = nil + f[:dynamics].each do |d| + if d[:type] == 7 + obj = d[:active_students] + end + end + obj + end + end end end \ No newline at end of file diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb index e78689bfb..db3e44119 100644 --- a/app/api/mobile/entities/homework.rb +++ b/app/api/mobile/entities/homework.rb @@ -24,12 +24,19 @@ module Mobile f.course.members.count - f.student_works.count when :homework_submit_num f.student_works.count - when :homework_status + when :homework_status_student get_homework_status f when :homework_times f.course.homework_commons.index(f) + 1 - when :homework_status_desc + when :homework_status_teacher homework_status_desc f + when :student_evaluation_part + get_evaluation_part f ,3 + when :ta_evaluation_part + get_evaluation_part f , 2 + when :homework_anony_type + val = f.homework_type == 1 && !f.homework_detail_manual.nil? + val end end end @@ -79,11 +86,13 @@ module Mobile homework_expose :homework_submit_num homework_expose :homework_notsubmit_num - 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_desc #状态的解释 + homework_expose :homework_status_student #学生看到的作业的状态 + homework_expose :homework_status_teacher #老师看到的状态 + + homework_expose :student_evaluation_part #学生匿评比率 + homework_expose :ta_evaluation_part #教辅评价比率 + + homework_expose :homework_anony_type #是否是匿评作业 end end diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb index 5ed3958ba..36893d16f 100644 --- a/app/api/mobile/entities/news.rb +++ b/app/api/mobile/entities/news.rb @@ -56,6 +56,8 @@ module Mobile expose :comments, using: Mobile::Entities::Comment do |f, opt| if f.is_a?(Hash) && f.key?(:comments) f[:comments] + elsif f.is_a?(::News) && f.respond_to?(:comments) + f.send(:comments) end end diff --git a/app/api/mobile/entities/user.rb b/app/api/mobile/entities/user.rb index 2b3483625..16048c61a 100644 --- a/app/api/mobile/entities/user.rb +++ b/app/api/mobile/entities/user.rb @@ -53,6 +53,8 @@ module Mobile user_expose :score #学号 user_expose :student_num + # 活跃值 + user_expose :active_count end end diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb index d3dc441ae..ac0357f53 100644 --- a/app/helpers/api_helper.rb +++ b/app/helpers/api_helper.rb @@ -129,9 +129,39 @@ module ApiHelper def show_homework_deadline homework 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 << "天" + "距作业截止还有" << day.to_s << "天" else "已截止,但可补交" end end + + #获取作业中学生的匿评比率 + # 匿评比率 = 学生总共评价的作业的作业份数 / 作业份数 * 分配数 * 100% + # 教辅匿评比率 = 教辅已经评价的作业份数 / 总的作业份数 * 100% + def get_evaluation_part homework,role + homework_eva_completed_task_num = 0 + homework_eva_task_num = 0 + #匿评作业 # 且匿评状态不是还没有开启匿评 + if homework.homework_type == 1 && homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 + # 总共需要评价的任务数 + homework_eva_task_num = homework.homework_detail_manual.evaluation_num * homework.student_works.count + unless homework_eva_task_num == 0 #总任务数不为0 的情况下 + #获取已经评价了多少的份作业 student_work_score里记录了评价情况,每条记录有提交作业的id + #先求出提交作业的id集合 + work_ids = "(" + homework.student_works.map(&:id).join(",") + ")" + #只要 student_work_score 中的 student_work_id在work_ids集合中,那么久说明这个任务被完成了 + + sql = "select count(1) from student_works_scores where reviewer_role = #{role} and student_work_id in #{work_ids} " + homework_eva_completed_task_num = ActiveRecord::Base.connection().select_value(sql) + end + end + if homework_eva_task_num == 0 + 0 + else + ( homework_eva_completed_task_num / homework_eva_task_num.to_f * 100 ) .round(2) + end + + end + + end \ No newline at end of file diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index aae150728..4f0821449 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -68,24 +68,36 @@ module IssuesHelper end #获取跟踪类型及样式 - #REDO:时间紧可以优化. def get_issue_type(value) issuetype = [] if value == "缺陷" || value == 1 - issuetype << "red_btn_cir ml10" - issuetype << "缺陷" + issuetype << "issues fl" elsif value == "功能" || value == 2 - issuetype << "blue_btn_cir ml10" - issuetype << "功能" + issuetype << "duty fl" elsif value == "支持" || value == 3 - issuetype << "green_btn_cir ml10" - issuetype << "支持" + issuetype << "support fl" elsif value == "任务" || value == 4 + issuetype << "function fl" + else + issuetype << "weekly fl" + end + end + + # 获取优先级样式 + def get_issue_priority(value) + issuetype = [] + if value == "紧急" || value == 1 + issuetype << "red_btn_cir ml10" + issuetype << "紧急" + elsif value == "正常" || value == 3 + issuetype << "green_btn_cir ml10" + issuetype << "正常" + elsif value == "高" || value == 4 issuetype << "orange_btn_cir ml10" - issuetype << "任务" + issuetype << "高" else issuetype << "bgreen_btn_cir ml10" - issuetype << "周报" + issuetype << "低" end end diff --git a/app/helpers/user_score_helper.rb b/app/helpers/user_score_helper.rb index c94763e31..41f76a792 100644 --- a/app/helpers/user_score_helper.rb +++ b/app/helpers/user_score_helper.rb @@ -433,7 +433,7 @@ module UserScoreHelper #协同得分 def collaboration(option_number) - option_number.memo * 2 + option_number.messages_for_issues + option_number.issues_status + option_number.replay_for_message + option_number.replay_for_memo + option_number.messages_for_issues + option_number.issues_status + option_number.replay_for_message + option_number.replay_for_memo end #影响力得分 def influence(option_number) @@ -445,7 +445,7 @@ module UserScoreHelper end #项目贡献得分 def active(option_number) - option_number.changeset * 4 + option_number.document * 4 + option_number.attachment * 4 + option_number.issue_done_ratio * 2 + option_number.post_issue * 4 + option_number.changeset * 4 + option_number.document * 4 + option_number.attachment * 4 + option_number.issue_done_ratio * 2 + option_number.post_issue * 4 + option_number.memo * 2 end #更新发帖数 diff --git a/app/models/option_number.rb b/app/models/option_number.rb index 0ddea1bff..b4a3caac4 100644 --- a/app/models/option_number.rb +++ b/app/models/option_number.rb @@ -1,5 +1,6 @@ class OptionNumber < ActiveRecord::Base - attr_accessible :attachment, :changeset, :document, :follow, :issue_done_ratio, :issues_status, :memo, :messages_for_issues, :post_issue, :praise_by_one, :praise_by_three, :praise_by_two, :replay_for_memo, :replay_for_message, :score_type, :total_score, :tread, :tread_by_one, :tread_by_three, :tread_by_two, :user_id + attr_accessible :attachment, :changeset, :document, :follow, :issue_done_ratio, :issues_status, :memo, :messages_for_issues, :post_issue, + :praise_by_one, :praise_by_three, :praise_by_two, :replay_for_memo, :replay_for_message, :score_type, :total_score, :tread, :tread_by_one, :tread_by_three, :tread_by_two, :user_id def self.get_user_option_number user_id result = nil diff --git a/app/services/comment_service.rb b/app/services/comment_service.rb index 2464297da..62955905b 100644 --- a/app/services/comment_service.rb +++ b/app/services/comment_service.rb @@ -112,6 +112,9 @@ class CommentService end end - + # 获取课程里的某个通知的所有回复 + def notice_comments params,current_user + News.find(params[:notice_id]).comments.page(params[:page] || 1).per(10) + end end \ No newline at end of file diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 7efe76b3a..00a8ffd8b 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -4,6 +4,7 @@ class CoursesService include CoursesHelper include HomeworkAttachHelper include ApiHelper + include ActionView::Helpers::DateHelper #参数school_id为0或不传时返回所有课程,否则返回对应学校的课程 #参数per_page_count分页功能,每页显示的课程数 @@ -657,22 +658,12 @@ class CoursesService membership.each do |mp| course = mp.course latest_course_dynamics = [] - dynamics_count = 0 - # 课程学霸 学生总分数排名靠前的5个人 - homework_count = course.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 = #{course.id}) GROUP BY student_works.user_id ORDER BY score limit 0,6" - 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 + # 课程通知 latest_news = course.news.page(1).per(2).order("created_on desc") unless latest_news.first.nil? latest_course_dynamics << {:type => 1, :time => latest_news.first.created_on,:count=>course.news.count, :news => latest_news.all} - dynamics_count += 1 end # 课程讨论区 @@ -694,12 +685,31 @@ class CoursesService homeworks = course.homework_commons.page(1).per(2).order('created_at desc') unless homeworks.first.nil? latest_course_dynamics << {:type => 4, :time => homeworks.first.updated_at, :count=>course.homework_commons.count , :homeworks => homeworks} - dynamics_count += 1 end - latest_course_dynamics.sort! { |order, newer| newer[:time] <=> order[:time] } + latest_course_dynamics.sort! { |order, newer| newer[:time] <=> order[:time] } + # 课程学霸 学生总分数排名靠前的5个人 + homework_count = course.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 = #{course.id}) GROUP BY student_works.user_id ORDER BY score limit 0,4" + better_students = User.find_by_sql(sql) + # 找出在课程讨论区发帖回帖数最多的 + active_students = [] + sql1 = " select users.*,count(author_id) 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 = #{course.id} ) " << + " GROUP BY messages.author_id ORDER BY count(author_id) desc " << + " limit 0,4" + active_students = User.find_by_sql(sql1) + if homework_count != 0 && !better_students.empty? + latest_course_dynamics <<{:type=> 6,:time=>Time.now.to_s,:count=> 4,:better_students=> better_students} + end + unless active_students.empty? + latest_course_dynamics <<{:type=> 7,:time=>Time.now.to_s,:count=> 4,:active_students=>active_students} + end latest_course_dynamic = latest_course_dynamics.first unless latest_course_dynamic.nil? - result << {:course_name => course.name, :course_id => course.id, :course_img_url => url_to_avatar(course), :course_time => course.time, :course_term => course.term,:message => dynamics_count, :dynamics => latest_course_dynamics, :count => dynamics_count} + result << {:course_name => course.name,:current_user_is_member => current_user.member_of_course?(course),:current_user_is_teacher => is_course_teacher(current_user,course), :course_id => course.id, :course_img_url => url_to_avatar(course), :course_time => course.time, :course_term => course.term,:message => "", :dynamics => latest_course_dynamics, + :course_student_num=>course ? course.members.count : 0,:time_from_now=> distance_of_time_in_words(Time.now, latest_course_dynamic[:time].to_time) << "前"} end end #返回数组集合 @@ -709,11 +719,21 @@ class CoursesService # 获取课程历次作业的学生总成绩 def students_score_list params,current_user - homework_count = Course.find(params[:course_id]).homework_commons.count page = (params[:page] || 1) - 1 - 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) + 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) + 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) + end end # 获取某次作业的所有作业列表 @@ -746,41 +766,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 + # # 开启匿评 + # #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 diff --git a/app/services/homework_service.rb b/app/services/homework_service.rb index 2a2c6613c..dd42795b1 100644 --- a/app/services/homework_service.rb +++ b/app/services/homework_service.rb @@ -57,47 +57,97 @@ class HomeworkService [@bid,@totle_size,@cur_size,@percent] end - #启动匿评 - #statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启 - def start_anonymous_comment params,current_user - @bid = Bid.find(params[:id]) - @course = @bid.courses.first - unless is_course_teacher(current_user,@course) || current_user.admin? - @statue = 4 - raise '403' - end - if(@bid.comment_status == 0) - homeworks = @bid.homeworks - if(homeworks && homeworks.size >= 2) - homeworks.each_with_index do |homework, index| - user = homework.user - n = @bid.evaluation_num - n = n < homeworks.size ? n : homeworks.size - 1 - assigned_homeworks = get_assigned_homeworks(homeworks, n, index) - assigned_homeworks.each do |h| - @homework_evaluation = HomeworkEvaluation.new(user_id: user.id, homework_attach_id: h.id) - @homework_evaluation.save - end - end - @bid.update_column('comment_status', 1) - @statue = 1 - else - @statue = 2 - end - else - @statue = 3 - end - @statue - end - #关闭匿评 - def stop_anonymous_comment params,current_user - @bid = Bid.find(params[:id]) - @course = @bid.courses.first - unless is_course_teacher(current_user,@course) || current_user.admin? - raise '403' - end - @bid.update_column('comment_status', 2) - end + # 启动匿评 操作 逻辑改变,暂不删除 + # #启动匿评 + # #statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启 + # def start_anonymous_comment params,current_user + # @bid = Bid.find(params[:id]) + # @course = @bid.courses.first + # unless is_course_teacher(current_user,@course) || current_user.admin? + # @statue = 4 + # raise '403' + # end + # if(@bid.comment_status == 0) + # homeworks = @bid.homeworks + # if(homeworks && homeworks.size >= 2) + # homeworks.each_with_index do |homework, index| + # user = homework.user + # n = @bid.evaluation_num + # n = n < homeworks.size ? n : homeworks.size - 1 + # assigned_homeworks = get_assigned_homeworks(homeworks, n, index) + # assigned_homeworks.each do |h| + # @homework_evaluation = HomeworkEvaluation.new(user_id: user.id, homework_attach_id: h.id) + # @homework_evaluation.save + # end + # end + # @bid.update_column('comment_status', 1) + # @statue = 1 + # else + # @statue = 2 + # end + # else + # @statue = 3 + # end + # @statue + # end + # #关闭匿评 + # def stop_anonymous_comment params,current_user + # @bid = Bid.find(params[:id]) + # @course = @bid.courses.first + # unless is_course_teacher(current_user,@course) || current_user.admin? + # raise '403' + # end + # @bid.update_column('comment_status', 2) + # 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 + + def stop_anonymous_comment params,current_user + homework = HomeworkCommon.find(params[:homework_id]) + homework_detail_manual = homework.homework_detail_manual + homework_detail_manual.update_column('comment_status', 3) + + work_ids = "(" << homework.student_works.map(&:id).join(",") << ")" + homework.student_works.each do |student_work| + absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count + student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0 + student_work.save + end + end # 匿评作品详情 # attachs 该作品的所有附件 diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb index 0fcb37021..4549b32e0 100644 --- a/app/views/issues/_list.html.erb +++ b/app/views/issues/_list.html.erb @@ -7,12 +7,12 @@
<% column_content = ( query.inline_columns.map {|column| "#{column_content_new(column, issue)}"}) %> <% unless issue.author.nil? || issue.author.name == "Anonymous" %> - +
<%= link_to issue.author.name, user_path(issue.author), :class => "problem_name c_orange fl" %> <%= l(:label_post_on_issue) %>(<%= "#{raw column_content[2]}" %>):
- <%=link_to "#{column_content[4]}#{get_issue_type(column_content[1])[1]}".html_safe, issue_path(issue.id), :class => "problem_tit_a break_word",:target => "_blank" %> + <%=link_to "#{column_content[4]}#{get_issue_priority(column_content[3])[1]}".html_safe, issue_path(issue.id), :class => "problem_tit_a break_word",:target => "_blank" %>

diff --git a/app/views/users/_influence_new_score_index.html.erb b/app/views/users/_influence_new_score_index.html.erb index c0a89536a..505785351 100644 --- a/app/views/users/_influence_new_score_index.html.erb +++ b/app/views/users/_influence_new_score_index.html.erb @@ -4,4 +4,5 @@

    <%= l('userscore.active.commit.attachments')%> * 4 = <%= option_num.attachment %> * 4 = <%= option_num.attachment * 4 %>
    <%= l('userscore.active.update_issues')%> * 2 = <%= option_num.issue_done_ratio %> * 2 = <%= option_num.issue_done_ratio * 2 %>
    <%= l('userscore.active.release_issues')%> * 4 = <%= option_num.post_issue %> * 4 = <%= option_num.post_issue * 4 %>
-
    <%= l(:label_user_score_of_active)%> = <%= option_num.changeset * 4 %> + <%= option_num.document * 4 %> + <%= option_num.attachment * 4 %> + <%= option_num.issue_done_ratio * 2 %> + <%= option_num.post_issue * 4 %> = <%= active(option_num) %>
\ No newline at end of file +
    <%= l('userscore.active.release_messages')%> * 1 = <%= option_num.memo %> * 2 = <%= option_num.memo * 2 %>
+
    <%= l(:label_user_score_of_active)%> = <%= option_num.changeset * 4 %> + <%= option_num.document * 4 %> + <%= option_num.attachment * 4 %> + <%= option_num.issue_done_ratio * 2 %> + <%= option_num.post_issue * 4 %> + <%= option_num.memo * 2 %> = <%= active(option_num) %>
\ No newline at end of file diff --git a/app/views/users/_topic_new_score_index.html.erb b/app/views/users/_topic_new_score_index.html.erb index af2ff0da3..86dc1f80f 100644 --- a/app/views/users/_topic_new_score_index.html.erb +++ b/app/views/users/_topic_new_score_index.html.erb @@ -1,7 +1,5 @@ - -
    <%= l('userscore.collaboration.memos')%> * 2 = <%= option_num.memo %> * 2 = <%= option_num.memo * 2 %>
    <%= l('userscore.collaboration.message_for_issues')%> * 1 = <%= option_num.messages_for_issues %> * 1 = <%= option_num.messages_for_issues * 1 %>
    <%= l('userscore.collaboration.issue_status')%> * 1 = <%= option_num.issues_status %> * 1= <%= option_num.issues_status * 1 %>
    <%= l('userscore.collaboration.reply_for_messages')%> * 1 = <%= option_num.replay_for_message %> * 1 = <%= option_num.replay_for_message * 1 %>
    <%= l('userscore.collaboration.reply_for_memos')%> * 1 = <%= option_num.replay_for_memo %> * 1 = <%= option_num.replay_for_memo * 1 %>
-
    <%= l(:label_user_score_of_collaboration)%> = <%= option_num.memo * 2 %> + <%= option_num.messages_for_issues * 1 %> + <%= option_num.issues_status * 1 %> + <%= option_num.replay_for_message * 1 %> + <%= option_num.replay_for_memo * 1 %> = <%= collaboration(option_num) %>  
+
    <%= l(:label_user_score_of_collaboration)%> = <%= option_num.messages_for_issues * 1 %> + <%= option_num.issues_status * 1 %> + <%= option_num.replay_for_message * 1 %> + <%= option_num.replay_for_memo * 1 %> = <%= collaboration(option_num) %>  
diff --git a/config/locales/users/zh.yml b/config/locales/users/zh.yml index 4c792ef82..d90d8c537 100644 --- a/config/locales/users/zh.yml +++ b/config/locales/users/zh.yml @@ -67,7 +67,8 @@ zh: documents: 提交文档次数 attachments: 提交附件次数 update_issues: 更新缺陷完成度次数 - release_issues: 发布缺陷数量 + release_issues: 发布缺陷数量 + release_messages: 发布帖子数量 label_score_less_than_zero: 得分小于0,修正为0 label_user_info: "个人简介" diff --git a/db/schema.rb b/db/schema.rb index 988d5649a..78dfb5eee 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -721,6 +721,16 @@ ActiveRecord::Schema.define(:version => 20150702073308) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" + create_table "journal_details_copy", :force => true do |t| + t.integer "journal_id", :default => 0, :null => false + t.string "property", :limit => 30, :default => "", :null => false + t.string "prop_key", :limit => 30, :default => "", :null => false + t.text "old_value" + t.text "value" + end + + add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" + create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" diff --git a/public/images/public_icon.png b/public/images/public_icon.png index 1fa463e4e..b915af086 100644 Binary files a/public/images/public_icon.png and b/public/images/public_icon.png differ diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index 5574dc82a..28399462d 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -95,6 +95,12 @@ a.pro_mes_w_news{ height:20px; float:right;display:block; color:#999999;} .pro_info_box ul li{ height:24px;} .pro_info_p{color:#0781b4 !important; float:left; width:80px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } .edit_pro_box{overflow:hidden;display:none; margin-bottom:30px; border-bottom:1px dashed #CCC; padding-bottom:10px;} +/*问题状态图片*/ +.issues{ background:url(../images/public_icon.png) -66px 5px no-repeat; width:16px; height:21px;} +.duty{ background:url(../images/public_icon.png) -66px -18px no-repeat; width:16px; height:21px;} +.support{ background:url(../images/public_icon.png) -66px -45px no-repeat; width:16px; height:21px;} +.function{ background:url(../images/public_icon.png) -66px -70px no-repeat; width:16px; height:21px;} +.weekly{ background:url(../images/public_icon.png) -66px -95px no-repeat; width:16px; height:21px;} /****翻页***/ ul.wlist{ float:right; border-bottom:none; height:30px; margin-top:20px; } ul.wlist li{float: left;}