diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index f7b03947c..0d0c4651f 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -232,6 +232,7 @@ module Mobile params do requires :token, type: String requires :course_id,type: Integer,desc: '课程id' + optional :name,type:String,desc:'课件名称可能包含的字符' end get ":course_id/attachments" do cs = CoursesService.new @@ -244,6 +245,7 @@ module Mobile params do requires :token,type:String requires :course_id,type:Integer,desc: '课程id' + optional :name,type:String,desc:'学生的姓名或者昵称或者学号可能包含的字符' end get ":course_id/members" do cs = CoursesService.new diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 4982a4b6b..523e430fb 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -445,7 +445,8 @@ class HomeworkAttachController < ApplicationController is_teacher = @is_teacher ? 1 : 0 #保存评分@homework.rate(@m_score.to_i,User.current.id,:quality, (@is_teacher ? 1 : 0)) @is_comprehensive_evaluation = @is_teacher ? 1 : (@is_anonymous_comments ? 2 : 3) #判断当前评论是老师评论?匿评?留言 - if @m_score && (@is_teacher || @is_anonymous_comments) + if @is_teacher || @is_anonymous_comments + @m_score ||= 0 rate = @homework.rates(:quality).where(:rater_id => User.current.id, :is_teacher_score => is_teacher).first if rate rate.stars = @m_score diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 80be8c5d5..12ee4bc3b 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -75,7 +75,11 @@ class IssuesController < ApplicationController else @limit = 10#per_page_option end - + @assign_to_id = params[:assigned_to_id] + @author_id = params[:author_id] + @priority_id = params[:priority_id] + @status_id = params[:status_id] + @subject = params[:subject] @issue_count = @query.issue_count @issue_pages = Paginator.new @issue_count, @limit, params['page'] @offset ||= @issue_pages.offset diff --git a/app/controllers/trackers_controller.rb b/app/controllers/trackers_controller.rb index 01bc47a2f..64ad9c83a 100644 --- a/app/controllers/trackers_controller.rb +++ b/app/controllers/trackers_controller.rb @@ -38,12 +38,13 @@ class TrackersController < ApplicationController @tracker ||= Tracker.new(params[:tracker]) @trackers = Tracker.sorted.all @projects = Project.where("project_type = #{Project::ProjectType_project}").all - @courses = Course.all - @course_activity_count=Hash.new - @courses.each do |course| - @course_activity_count[course.id]=0 - end - @course_activity_count=get_course_activity @courses,@course_activity_count + # 去掉原因,这块代码已经没有用到 + # @courses = Course.all + # @course_activity_count=Hash.new + # @courses.each do |course| + # @course_activity_count[course.id]=0 + # end + # @course_activity_count=get_course_activity @courses,@course_activity_count end def create diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index f35210f01..6e067fb83 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -58,12 +58,18 @@ class WelcomeController < ApplicationController else case @first_page.sort_type when 0 + @my_projects = find_my_projects + @other_projects = @my_projects.count < 9 ? find_miracle_project( 9 - @my_projects.count, 3,"score desc") : [] @projects = find_miracle_project(10, 3,"created_on desc") #@projects = @projects_all.order("created_on desc") when 1 + @my_projects = find_my_projects + @other_projects = @my_projects.count < 9 ? find_miracle_project( 9 - @my_projects.count, 3,"score desc") : [] @projects = find_miracle_project(10, 3,"score desc") #@projects = @projects_all.order("grade desc") when 2 + @my_projects = find_my_projects + @other_projects = @my_projects.count < 9 ? find_miracle_project( 9 - @my_projects.count, 3,"score desc") : [] @projects = find_miracle_project(10, 3,"watchers_count desc") #@projects = @projects_all.order("watchers_count desc") diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index f6e205e82..4800a949a 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -443,6 +443,10 @@ module WelcomeHelper resultSet.take(limit) end + def find_my_projects + my_projects = User.current.memberships.all(conditions: "projects.project_type = 0") + end + def sort_project_by_hot_rails project_type=0, order_by='score DESC', limit=15 # Project.find_by_sql(" # SELECT p.id, p.name, p.description, p.identifier, t.project_id diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 42bf8fe3f..94efb375a 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -433,18 +433,48 @@ class CoursesService result = [] @course = Course.find(params[:course_id]) @attachments = @course.attachments.order("created_on desc") - @attachments.each do |atta| - result << {:filename => atta.filename,:description => atta.description,:downloads => atta.downloads,:quotes => atta.quotes.nil? ? 0 :atta.quotes } + if !params[:name].nil? && params[:name] != "" + @attachments.each do |atta| + result << {:filename => atta.filename, + :description => atta.description, + :downloads => atta.downloads, + :quotes => atta.quotes.nil? ? 0 :atta.quotes } if atta.filename.include?(params[:name]) + + end + else + @attachments.each do |atta| + result << {:filename => atta.filename, + :description => atta.description, + :downloads => atta.downloads, + :quotes => atta.quotes.nil? ? 0 :atta.quotes } + + end end result end # 课程学生列表 def course_members params - @all_members = student_homework_score(0,params[:course_id], 10,"desc") + @all_members = searchmember_by_name(student_homework_score(0,params[:course_id], 10,"desc"),params[:name]) end private + def searchmember_by_name members, name + #searchPeopleByRoles(project, StudentRoles) + mems = [] + if name != "" + name = name.to_s.downcase + members.each do |m| + 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 + else + mems = members + end + mems + end def show_homework_info course,bid,current_user,is_course_teacher author_real_name = bid.author.lastname + bid.author.firstname many_times = course.homeworks.index(bid) + 1 diff --git a/app/views/bids/_new_homework_form.html.erb b/app/views/bids/_new_homework_form.html.erb index 16f78491b..7a5f628f9 100644 --- a/app/views/bids/_new_homework_form.html.erb +++ b/app/views/bids/_new_homework_form.html.erb @@ -35,7 +35,7 @@
<%= content_tag('span', link_to("#{@course_activity_count[@course.id]}", course_path(@course)), :class => "info") %> <%= content_tag('span', l(:label_x_activity, :count => @course_activity_count[@course.id])) %>
- +