This commit is contained in:
alan 2015-05-13 14:34:07 +08:00
commit a8d19a119a
16 changed files with 110 additions and 27 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

@ -244,12 +244,12 @@ update
def show
## TODO: the below will move to filter, done.
# if !User.current.member_of?(@project)
# if @project.hidden_repo
# render_403
# return -1
# end
# end
if !User.current.member_of?(@project)
if @project.hidden_repo
render_403
return -1
end
end
#if( !User.current.member_of?(@project) || @project.hidden_repo)
@repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?

View File

@ -232,6 +232,18 @@ module RepositoriesHelper
:label => l(:label_git_report_last_commit)
))
end
# 判断项目是否有主版本库
def judge_main_repository(pro)
if pro.repositories.blank?
return false
else
pro.repositories.sort.each do |rep|
rep.is_default?
return true
end
end
end
# def cvs_field_tags(form, repository)
# content_tag('p', form.text_field(
# :root_url,

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

@ -34,16 +34,17 @@
<a class="subnav_num">(<%= attaments_num %>)</a>
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:label_upload_files), project_files_path(@project,:flag => true), :class => "subnav_green ml95" %>
<%= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml95" %>
<% end %>
</div>
<% end%>
<% unless @project.enabled_modules.where("name = 'repository'").empty? || @project.repositories.count == 0 %>
<% end %>
<%# --版本库被设置成私有、module中设置不显示、没有创建版本库 三种情况不显示-- %>
<% unless @project.hidden_repo || @project.enabled_modules.where("name = 'repository'").empty? || @project.repositories.count == 0 %>
<div class="subNav">
<%= link_to l(:project_module_repository), {:controller => 'repositories', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
<a class="subnav_num">(<%= @project.repositories.count %>)</a>
</div>
<% end %><!--meny end -->
<% end %><!--meny end -->
<!-- more -->
<div class="subNav subNav_jiantou" onclick="$('#navContent').toggle(500);" id="expand_tools_expand"><%= l(:label_project_more) %></div>

View File

@ -23,7 +23,7 @@
<a class="subnav_num">(<%= attaments_num %>)</a>
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:label_upload_files), project_files_path(@project,:flag => true), :class => "subnav_green ml95" %>
<%= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml95" %>
<% end %>
</div>
<% end %>

View File

@ -34,7 +34,7 @@
<a class="subnav_num">(<%= attaments_num %>)</a>
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:label_upload_files), project_files_path(@project,:flag => true), :class => "subnav_green ml95" %>
<%= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml95" %>
<% end %>
</div>
<% end%>

View File

@ -72,20 +72,22 @@
<span class="c_grey"><%= l(:text_scm_command_not_available) %></span>
<% end %>
</li>
<li >
<label class="label02"><%=l(:field_repository_is_default)%></label>
<%= f.check_box :is_default, :label => "" %></p>
</li>
<% unless judge_main_repository(@project) %>
<li>
<label class="label02"><%=l(:field_repository_is_default)%></label>
<%= f.check_box :is_default, :label => "" %></p>
</li>
<% end %>
<li >
<label class="label02"><span class="c_red">*</span><%=l(:label_repository_name)%></label>
<%= f.text_field :identifier, :disabled =>@repository.nil? || @repository.identifier_frozen? ? true:false,:label=>""%>
<%= f.text_field :identifier, :disabled =>@repository.nil? || @repository.identifier_frozen? ? true:false,:label=>"", :no_label => true %>
<% unless @repository.identifier_frozen? %>
<span class="c_grey"><%=l(:text_length_between,:min=>1,:max=>254)<<l(:text_project_identifier_info)%></span>
<span class="c_grey"><%=l(:text_length_between,:min=>1,:max=>254)<<l(:text_project_identifier_info) %></span>
<% end %>
</li>
<li >
<label class="label02"><span class="c_red">*</span><%=l(:label_password)%></label>
<%= f.password_field :upassword, :label=> "" %>
<%= f.password_field :upassword, :label=> "", :no_label => true %>
<span class="c_grey"><%= l(:label_upassword_info)%></span>
</li>
<div class="cl"></div>

View File

@ -152,9 +152,6 @@
<div class="cl"></div>
</div>
<% content_for :header_tags do %>
<%= stylesheet_link_tag "scm" %>
<% end %>

View File

@ -124,6 +124,7 @@ zh:
#
lable_file_sharingarea: 资源共享区
label_upload_source: 上传资源
label_upload_files: 上传文件
label_slected_to_other_project: 选入我的其他项目
label_slected_to_project: 选入我的项目

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"