diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 0d0c4651f..b2a2532bc 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -168,6 +168,14 @@ module Mobile present :status, 0 end + desc "设置教辅" + params do + + end + post 'set_user_as_assitant' do + + end + desc "返回单个课程" params do requires :id, type: Integer @@ -254,6 +262,18 @@ module Mobile present :status, 0 end + desc '查看用户历次作业成绩' + params do + requires :token,type:String + requires :member_id,type:Integer,desc:'课程member_id' + optional :homeworkName,type:String,desc:'作业名称以及作业名称可能包含的字符' + end + get '/show_member_score/:member_id' do + cs = CoursesService.new + homeworkscore = cs.show_member_score params + present :data,homeworkscore,with: Mobile::Entities::Homeworkscore + present :status,0 + end end end end diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 063cfafae..3ef2c3237 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -83,6 +83,7 @@ module Mobile params do requires :name, type: String, desc: '用户名关键字' requires :search_by, type: String,desc: '搜索依据:0 昵称,1 用户名,2 邮箱,3 昵称和姓名' + optional :is_search_assitant,type:Integer,desc:'是否搜索注册用户来作为助教' end get 'search/search_user' do us = UsersService.new diff --git a/app/api/mobile/entities/homework_attach.rb b/app/api/mobile/entities/homework_attach.rb index 690ec8e94..2ad11fe36 100644 --- a/app/api/mobile/entities/homework_attach.rb +++ b/app/api/mobile/entities/homework_attach.rb @@ -37,7 +37,6 @@ module Mobile f.send(:attachments) end end - #homework_attach_expose :user end end end \ No newline at end of file diff --git a/app/api/mobile/entities/homeworkscore.rb b/app/api/mobile/entities/homeworkscore.rb new file mode 100644 index 000000000..e0c501c58 --- /dev/null +++ b/app/api/mobile/entities/homeworkscore.rb @@ -0,0 +1,18 @@ +module Mobile + module Entities + class Homeworkscore < Grape::Entity + include Redmine::I18n + include ApplicationHelper + def self.homeworkscore_expose(field) + expose field do |f,opt| + if f.is_a?(Hash) && f.key?(field) + f[field] + end + end + end + + homeworkscore_expose :name + homeworkscore_expose :score + end + end +end \ No newline at end of file diff --git a/app/api/mobile/entities/member.rb b/app/api/mobile/entities/member.rb index 837ec788a..f9dd1e849 100644 --- a/app/api/mobile/entities/member.rb +++ b/app/api/mobile/entities/member.rb @@ -28,6 +28,7 @@ module Mobile end member_expose :student_id member_expose :score + member_expose :id end end end \ No newline at end of file diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 22249b953..fd7ec55fb 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -458,6 +458,21 @@ class CoursesService @all_members = searchmember_by_name(student_homework_score(0,params[:course_id], 10,"desc"),params[:name]) end + def show_member_score params + @member_score = Member.find(params[:member_id]) if params[:member_id] + atta = @member_score.student_homework_score[0] + result = [] + atta.each do |t| + if !params[:homeworkName].nil? && params[:homeworkName] != "" + result << {:name=>t[:name],:score=>t[:score]} if t[:name].include?(params[:homeworkName]) + else + result << {:name=>t[:name],:score=>t[:score]} + end + + end + result + end + private def searchmember_by_name members, name #searchPeopleByRoles(project, StudentRoles) @@ -559,4 +574,6 @@ class CoursesService end + + end \ No newline at end of file diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 3a92bf8f1..17557872b 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -205,10 +205,14 @@ class UsersService "show_changesets" => true } scope = User.logged.status(status) - watcher = User.watched_by(params[:user_id]) - watcher.push(params[:user_id]) - search_by = params[:search_by] ? params[:search_by] : "0" - scope = scope.where("id not in (?)",watcher).like(params[:name],search_by) if params[:name].present? + if params[:is_search_assitant].nil? + watcher = User.watched_by(params[:user_id]) + watcher.push(params[:user_id]) + search_by = params[:search_by] ? params[:search_by] : "0" + scope = scope.where("id not in (?)",watcher).like(params[:name],search_by) if params[:name].present? + else + scope = scope.like(params[:name],search_by) if params[:name].present? + end scope end diff --git a/db/schema.rb b/db/schema.rb index e798dba1c..94210e8f2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -659,6 +659,16 @@ ActiveRecord::Schema.define(:version => 20150505025537) 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"