diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index bf964fbaf..63b8294e7 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -318,7 +318,6 @@ class CoursesController < ApplicationController @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' @role = params[:role] @course_groups = @course.course_groups if @course.course_groups - @course_group_id = params[:@course_group_id] unless params[:@course_group_id].nil? @show_serch = params[:role] == '2' case params[:role] when '1' @@ -340,6 +339,15 @@ class CoursesController < ApplicationController render_403 end + end + # 显示每个学生的作业评分详情 + def show_member_score + @member_score = Member.find(params[:member_id]) if params[:member_id] + respond_to do |format| + format.html {render :layout => 'course_base'} + format.js + end + end #判断指定用户是否为课程教师 @@ -840,4 +848,6 @@ class CoursesController < ApplicationController render_404 end end + + end diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 72755dc6a..5c4542944 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -348,7 +348,7 @@ class HomeworkAttachController < ApplicationController else end else - render_403 :message => :notice_not_authorized + render_403 end end diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index 5b6111187..e47cfc2ff 100644 --- a/app/controllers/softapplications_controller.rb +++ b/app/controllers/softapplications_controller.rb @@ -48,7 +48,7 @@ class SoftapplicationsController < ApplicationController def show @softapplication = Softapplication.find(params[:id]) - @project = @softapplication.project + #@project = @softapplication.project # 打分统计 stars_reates = @softapplication. rates(:quality) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index a1199a55a..6f0265132 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -166,9 +166,25 @@ module CoursesHelper def searchStudent project #searchPeopleByRoles(project, StudentRoles) members = [] + project.members.each do |m| - members << m if m && m.user && m.user.allowed_to?(:as_student,project) + if m && m.user && m.user.allowed_to?(:as_student,project) + members << m + + end + end + members + end + def search_student_and_score project + #searchPeopleByRoles(project, StudentRoles) + members = [] + scores = [] + project.members.each do |m| + if m && m.user && m.user.allowed_to?(:as_student,project) + members << m + end + end members end def searchStudent_by_name project, name @@ -392,7 +408,13 @@ module CoursesHelper return teacher_score_for_homework homework end end - + def score_for_homework_new homework + if teacher_score_for_homework(homework) != 0 + return teacher_score_for_homework homework + else + return student_score_for_homework homework + end + end #获取作业的互评得分 def student_score_for_homework homework #member = searchTeacherAndAssistant(homework.bid.courses.first).first#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first diff --git a/app/models/course.rb b/app/models/course.rb index ef42d91e8..196e7168d 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -36,7 +36,7 @@ class Course < ActiveRecord::Base acts_as_attachable :view_permission => :view_course_files, :delete_permission => :manage_files - validates_presence_of :password, :term,:name,:description + validates_presence_of :password, :term,:name validates_format_of :class_period, :with =>/^[1-9]\d*$/ validates_format_of :name,:with =>/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/ validates_length_of :description, :maximum => 10000 diff --git a/app/models/member.rb b/app/models/member.rb index 716f6a7c5..32d0f5c73 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -114,9 +114,50 @@ class Member < ActiveRecord::Base member end + # 查找每个学生每个作业的评分 + def student_homework_score + teachers = find_course_teachers(self.course) + + score_count = 0 + homework_scores = HomeworkAttach.find_by_sql("SELECT homework_attaches.bid_id as bid_id, bids.name as name, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' + AND rateable_id = homework_attaches.id AND rater_id IN (#{teachers}) ) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' + AND rateable_id = homework_attaches.id AND rater_id NOT IN (#{teachers})) AS s_score + FROM homework_attaches, bids where homework_attaches.user_id = #{self.user_id} + and homework_attaches.bid_id IN (SELECT bid_id FROM homework_for_courses where course_id = #{self.course_id} + and homework_attaches.bid_id = bids.id)") + homework_scores.each do |homework| + if !homework.t_score.nil? && homework.t_score != 0 + score = homework.t_score + else + if !homework.s_score.nil? + score= homework.s_score + else + score = 0 + end + end + score_count = score_count + score + end + [homework_scores, format("%0.2f", score_count)] + end protected def validate_role errors.add_on_empty :role if member_roles.empty? && roles.empty? end + + + #获取课程的老师列表 + def find_course_teachers course + searchTeacherAndAssistant(course).map{|teacher| teacher.user_id}.join(",") + end + def searchTeacherAndAssistant project + #searchPeopleByRoles(project, TeacherRoles) + members = [] + project.members.each do |m| + members << m if m && m.user && m.user.allowed_to?(:as_teacher,project) + end + members + end end diff --git a/app/models/user.rb b/app/models/user.rb index 70e4e8187..cae5f1aa2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -90,7 +90,7 @@ class User < Principal has_many :contesting_projects, :dependent => :destroy belongs_to :softapplication, :foreign_key => 'id', :dependent => :destroy ##ended by xianbo - + #####fq has_many :jours, :class_name => 'JournalsForMessage', :dependent => :destroy has_many :journals_messages, :class_name => 'JournalsForMessage', :foreign_key => "user_id", :dependent => :destroy @@ -105,7 +105,7 @@ class User < Principal #has_many :courses, :through => :students_for_courses, :source => :project has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy has_many :file_commit, :class_name => 'Attachment', :foreign_key => 'author_id', :conditions => "container_type = 'Project' or container_type = 'Version'" -#### +#### # added by bai has_many :join_in_contests, :dependent => :destroy has_many :news, :foreign_key => 'author_id' diff --git a/app/views/bids/_alert_anonyoms.html.erb b/app/views/bids/_alert_anonyoms.html.erb index e4e9076a5..f26487126 100644 --- a/app/views/bids/_alert_anonyoms.html.erb +++ b/app/views/bids/_alert_anonyoms.html.erb @@ -50,7 +50,7 @@

开启匿评功能

开启匿评后学生将不能对作业进行 - 提交、修改、删除 + 修改、删除 等操作,目前有 <%= totle_size%>个 学生,共提交了 diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb index e7b58fefc..7937912e4 100644 --- a/app/views/bids/_bid_homework_show.html.erb +++ b/app/views/bids/_bid_homework_show.html.erb @@ -124,14 +124,6 @@ ) <% end %> - - <%= l(:label_students_responses) %> - ( - - <%= bid.commit.nil? ? 0 : bid.commit %> - - ) - diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 7a7d001ed..eac85e2d7 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -1,10 +1,7 @@