diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 21b3cc531..d38846ea0 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -490,7 +490,7 @@ class BidsController < ApplicationController (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score, (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY s_score DESC,created_at ASC) AS table1 - WHERE table1.t_score IS NULL") + WHERE table1.t_score IS NULL OR table1.t_score = 0") @not_batch_homework = true @cur_type = 1 else diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 1c2419305..8710b624e 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -429,7 +429,7 @@ class CoursesController < ApplicationController else respond_to do |format| format.html { - render :layout => 'base_courses' + # render :layout => 'base_courses' flash[:notice] = l(:notice_successful_create) if params[:continue] redirect_to new_course_url(attrs, :course => '0') diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index ba7e92467..c90d078e2 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -22,6 +22,7 @@ class HomeworkAttachController < ApplicationController #获取未批作业列表 def get_not_batch_homework @not_batch_homework = true + @search_name = params[:name] sort, direction = params[:sort] || "s_socre", params[:direction] || "desc" get_not_batch_homework_list sort,direction, @bid.id @cur_page = params[:page] || 1 @@ -39,6 +40,7 @@ class HomeworkAttachController < ApplicationController #获取已评作业列表 def get_batch_homeworks + @search_name = params[:name] sort, direction = params[:sort] || "s_socre", params[:direction] || "desc" @is_batch_homeworks = true if sort == 't_socre' @@ -49,11 +51,12 @@ class HomeworkAttachController < ApplicationController order_by = "created_at #{direction}" end all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*, - (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score, + (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL AND stars > 0 ORDER BY updated_at DESC limit 0,1) AS t_score, (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY #{order_by}) AS table1 WHERE table1.t_score IS NOT NULL") + all_homework_list = search_homework_member(all_homework_list,@search_name.to_s.downcase) if @search_name @cur_page = params[:page] || 1 @cur_type = 2 @homework_list = paginateHelper all_homework_list,10 @@ -72,6 +75,7 @@ class HomeworkAttachController < ApplicationController #获取所有作业列表 def get_homeworks @is_all_homeworks = true + @search_name = params[:name] sort, direction = params[:sort] || "s_socre", params[:direction] || "desc" if sort == 't_socre' order_by = "t_score #{direction}" @@ -85,6 +89,8 @@ class HomeworkAttachController < ApplicationController (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY #{order_by}") + + all_homework_list = search_homework_member(all_homework_list,@search_name.to_s.downcase) if @search_name @cur_page = params[:page] || 1 @cur_type = 3 @homework_list = paginateHelper all_homework_list,10 @@ -477,7 +483,7 @@ class HomeworkAttachController < ApplicationController get_not_batch_homework_list params[:cur_sort] || "s_socre",params[:cur_direction] || "desc",@homework.bid_id elsif @cur_type == "2" #老师已批列表 @result_homework = HomeworkAttach.find_by_sql("SELECT homework_attaches.*, - (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score, + (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL AND stars > 0 ORDER BY updated_at DESC limit 0,1) AS t_score, (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score FROM homework_attaches WHERE id = #{@homework.id}").first elsif @cur_type == "3" #全部作业列表 @@ -538,6 +544,14 @@ class HomeworkAttachController < ApplicationController end private + #根据条件过滤作业结果 + def search_homework_member homeworks,name + select_homework = homeworks.select{ |homework| + homework.user[:login].to_s.downcase.include?(name) || homework.user.user_extensions[:student_id].to_s.downcase.include?(name) || (homework.user[:lastname].to_s.downcase + homework.user[:firstname].to_s.downcase).include?(name) + } + select_homework + end + #验证是否显示课程 def can_show_course @first_page = FirstPage.find_by_page_type('project') @@ -596,7 +610,8 @@ class HomeworkAttachController < ApplicationController (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score FROM homework_attaches WHERE bid_id = #{bid_id} ORDER BY #{order_by}) AS table1 - WHERE table1.t_score IS NULL") + WHERE table1.t_score IS NULL OR table1.t_score = 0 ") + @all_homework_list = search_homework_member(@all_homework_list,@search_name.to_s.downcase) if @search_name @homework_list = paginateHelper @all_homework_list,10 end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 55f216ab9..5b311acd7 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -233,10 +233,10 @@ module CoursesHelper #searchPeopleByRoles(project, StudentRoles) mems = [] if name != "" + name = name.to_s.downcase members.each do |m| - - username = m.user[:lastname].to_s + m.user[:firstname].to_s - if(m.user[:login].to_s.include?(name) || m.user.user_extensions[:student_id].to_s.include?(name) || username.include?(name)) + username = m.user[:lastname].to_s.downcase + m.user[:firstname].to_s.downcase + if(m.user[:login].to_s.downcase.include?(name) || m.user.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name)) mems << m end end diff --git a/app/models/comment.rb b/app/models/comment.rb index 1f6655bc4..bdb642d3c 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -27,7 +27,7 @@ class Comment < ActiveRecord::Base def send_mail if self.commented.is_a?(News) && Setting.notified_events.include?('news_comment_added') - Mailer.news_comment_added(self) + Mailer.run.news_comment_added(self) end end after_destroy :delete_kindeditor_assets diff --git a/app/models/principal.rb b/app/models/principal.rb index 5aa21768f..dfec5b911 100644 --- a/app/models/principal.rb +++ b/app/models/principal.rb @@ -42,7 +42,8 @@ class Principal < ActiveRecord::Base where({}) else pattern = "%#{q}%" - sql = %w(login firstname lastname mail).map {|column| "LOWER(#{table_name}.#{column}) LIKE LOWER(:p)"}.join(" OR ") + # sql = %w(login firstname lastname mail).map {|column| "LOWER(#{table_name}.#{column}) LIKE LOWER(:p)"}.join(" OR ") + sql= "LOWER(concat(lastname,firstname)) LIKE LOWER(:p) or LOWER(login) LIKE LOWER(:p) or LOWER(mail) LIKE LOWER(:p)" params = {:p => pattern} if q =~ /^(.+)\s+(.+)$/ a, b = "#{$1}%", "#{$2}%" diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb index 05bec9874..a7a703c05 100644 --- a/app/views/bids/_homework.html.erb +++ b/app/views/bids/_homework.html.erb @@ -58,54 +58,17 @@ function hidden_homework_atert_form(cur_page,cur_type) { hideModal($("#popbox")); - // 评了分的则刷新列表 -// switch (cur_type) -// { -// case 1: -// $.ajax({ -// type: "GET", -// url: "<%#= get_not_batch_homework_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, -// data: 'text', -// success: function (data) { -// -// } -// }); -// break; -// case 2: -// $.ajax({ -// type: "GET", -// url: "<%#= get_batch_homeworks_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, -// data: 'text', -// success: function (data) { -// -// } -// }); -// break; -// case 3: -// $.ajax({ -// type: "GET", -// url: "<%#= get_homeworks_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, -// data: 'text', -// success: function (data) { -// -// } -// }); -// break; -// case 4: -// $.ajax({ -// type: "GET", -// url: "<%#= get_student_batch_homework_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, -// data: 'text', -// success: function (data) { -// -// } -// }); -// break; -// case 5: -// break; -// default : -// break; -// } + } + + function search_homework_member(url) + { + $.get( + url, + { name: $.trim($("#homework_member_search").val()) }, + function (data) { + + } + ); } diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 62fdc3082..44dd50c5e 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -1,8 +1,3 @@ -<% attachmenttypes = @course.attachmenttypes %> -<% sufixtypes = @course.contenttypes %> - - -