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/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/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 64a9111e0..958d62975 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -13,7 +13,7 @@ <%= javascript_heads %> <%= heads_for_theme %> <%= stylesheet_link_tag 'public', 'pleft', 'project','jquery/jquery-ui-1.9.2' %> - <%= javascript_include_tag 'project', 'header','select_list_move' %> + <%= javascript_include_tag 'cookie','project', 'header','select_list_move' %> <%= call_hook :view_layouts_base_html_head %> <%= yield :header_tags -%> diff --git a/app/views/messages/_form_project.html.erb b/app/views/messages/_form_project.html.erb index 5724acf47..8e72544b5 100644 --- a/app/views/messages/_form_project.html.erb +++ b/app/views/messages/_form_project.html.erb @@ -25,7 +25,7 @@
项目代码请设置好正确的编码方式(utf-8),否则中文会出现乱码
- -建立版本库文件夹,打开命令行执行如下:
+项目代码请设置好正确的编码方式(utf-8),否则中文会出现乱码。
+通过cmd命令提示符进入代码对应文件夹的根目录,假设当前用户的登录名为user,版本库名称为demo,需要操作的版本库分支为branch。 + 如果是首次提交代码,执行如下命令:
git init
@@ -46,19 +46,19 @@git commit -m "first commit"
git remote add origin - http://xianbo_trustie2@repository.trustie.net/xianbo/trustie2.git + http://user_demo@repository.trustie.net/user/demo.git
git config http.postBuffer 524288000 #设置本地post缓存为500MB
-git push -u origin master:master
+git push -u origin branch:branch
已经有本地库,还没有配置远程地址,打开命令行执行如下:
git remote add origin http://xianbo_trustie2@repository.trustie.net/xianbo/trustie2.git
+git remote add origin http://user_demo@repository.trustie.net/user/demo.git
git add .
@@ -66,14 +66,14 @@git config http.postBuffer 524288000 #设置本地post缓存为500MB
-git push -u origin master:master
+git push -u origin branch:branch
已有远程地址,创建一个远程分支,并切换到该分支,打开命令行执行如下:
git clone http://xianbo_trustie2@repository.trustie.net/xianbo/trustie2.git
+git clone http://user_demo@repository.trustie.net/user/demo.git
git push
@@ -87,7 +87,7 @@git remote add trustie - http://xianbo_trustie2@repository.trustie.net/xianbo/trustie2.git + http://user_demo@repository.trustie.net/user/demo.git
git add .
@@ -96,7 +96,7 @@git config http.postBuffer 524288000 #设置本地post缓存为500MB
-git push -u trustie master:master
+git push -u trustie branch:branch
李海提供