课程学生列表下啦刷新显示,查看历次作业成绩的下啦刷新显示api改动

This commit is contained in:
lizanle 2015-05-13 09:56:34 +08:00
parent f12a20f85e
commit 3fae37fa90
8 changed files with 75 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -37,7 +37,6 @@ module Mobile
f.send(:attachments)
end
end
#homework_attach_expose :user
end
end
end

View File

@ -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

View File

@ -28,6 +28,7 @@ module Mobile
end
member_expose :student_id
member_expose :score
member_expose :id
end
end
end

View File

@ -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

View File

@ -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

View File

@ -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"