Merge remote-tracking branch 'origin/szzh' into szzh

This commit is contained in:
lizanle 2015-07-28 10:27:56 +08:00
commit ad5c4052fb
15 changed files with 186 additions and 129 deletions

View File

@ -337,6 +337,19 @@ class AdminController < ApplicationController
format.html
end
end
#学校列表
def schools
@school_name = params[:school_name]
if @school_name
@schools = School.where("name like '%#{@school_name}%'")
else
@schools = School.all
end
respond_to do |format|
format.html
end
end
#移动端版本管理
def mobile_version
@versions = PhoneAppVersion.reorder('created_at desc')

View File

@ -449,6 +449,8 @@ update
def stats
@project_id = params[:id]
@repository_id = @repository.identifier
# 提交次数统计
@status_commit_count = Changeset.count(:conditions => ["#{Changeset.table_name}.repository_id = ?", @repository.id])
render :layout => 'base_projects'
end

View File

@ -4,28 +4,21 @@ class SchoolController < ApplicationController
def upload
uploaded_io = params[:logo]
school_id = 0
schools = School.where("name = ?", params[:school])
schools.each do |s|
school_id = s.id
end
school_id ||= params[:id]
unless uploaded_io.nil?
File.open(Rails.root.join('public', 'images', 'school', school_id.to_s+'.png'), 'wb') do |file|
file.write(uploaded_io.read)
end
s1 = School.find(school_id)
s1.logo_link = '/images/school/'+school_id.to_s+'.png'
s1.save
end
end
redirect_to admin_schools_url(:school_name => params[:school_name])
end
def upload_logo
@school = School.find params[:id]
@school_name = params[:school_name]
end
#获取制定学校开设的课程数

View File

@ -100,44 +100,6 @@ class WelcomeController < ApplicationController
@course_page = FirstPage.find_by_page_type('course')
@school_id = params[:school_id] || User.current.user_extensions.school.try(:id) || 117
@logoLink ||= logolink()
##3-8月份为查找春季课程9-2月份为查找秋季课程
#month_now = Time.now.strftime("%m").to_i
#year_now = Time.new.strftime("%Y").to_i
#(month_now >= 3 && month_now < 9) ? course_term = l(:label_spring) : course_term = l(:label_autumn)
##year_now -= 1 if year_now < 3
#@school_id.nil? ? @cur_school_course = [] : @cur_school_course = find_miracle_course(10,7,@school_id, year_now, course_term)
##未登录或者当前学校未开设课程
#if @cur_school_course.empty?
# @has_course = false
# User.current.logged? ? course_count = 9 : course_count = 10
# @cur_school_course += find_all_new_hot_course(course_count, @school_id, year_now, course_term)
# while @cur_school_course.count < 9 do
# if course_term == l(:label_spring)
# course_term = l(:label_autumn)
# year_now -= 1
# else
# course_term = l(:label_spring)
# end
# @cur_school_course += find_all_new_hot_course((10-@cur_school_course.count), nil, year_now, course_term)
# end
#else
# if @cur_school_course.count < 9
# @has_course = false
# @cur_school_course += find_all_new_hot_course(9-@cur_school_course.count, @school_id, year_now, course_term)
# if @cur_school_course.count < 9
# if course_term == l(:label_spring)
# course_term = l(:label_autumn)
# year_now -= 1
# else
# course_term = l(:label_spring)
# end
# @cur_school_course += find_all_new_hot_course(9-@cur_school_course.count, nil, year_now, course_term)
# end
# else
# @has_course = true
# end
#end
end
def logolink()

View File

@ -0,0 +1,50 @@
<h3 style="float: left">
<%=l(:label_school_plural)%>
</h3>
<%= form_tag({:controller => 'admin', :action => 'schools' }, :method => :get,:id=>"search_course_form") do %>
<%= submit_tag "搜索",:style => "float: right;margin-right: 15px;"%>
<input style="float: right;margin-right: 10px;" id="v_subject" placeholder="学校名称" type="text" name="school_name" value="<%= @school_name%>">
<% end %>
<div class="cl"></div>
<div class="autoscroll" style="margin-top: 40px;">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 50px;">
序号
</th>
<th style="width: 100px;">
LOGO
</th>
<th>
学校名称
</th>
<th style="width: 100px;"></th>
</tr>
</thead>
<tbody>
<% @schools.each do |school|%>
<tr class="<%= cycle("odd", "even") %>">
<td style="text-align:center;vertical-align: middle;">
<%= school.id %>
</td>
<td align="center">
<%= image_tag(school.logo_link,width:40,height:40) %>
</td>
<td style="text-align:center;vertical-align: middle;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=school.name%>'>
<span>
<%= link_to school.name,"http://#{Setting.host_course}/?school_id=#{school.id}" %>
</span>
</td>
<td class="buttons" style="vertical-align: middle;">
<%= link_to("修改", upload_logo_school_path(school.id,:school_name => @school_name), :class => 'icon icon-copy') %>
<%#= link_to(l(:button_delete), organization_path(school.id), :method => :delete,:confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
</td>
</tr>
<% end%>
</tbody>
</table>
</div>
<% html_title(l(:label_project_plural)) -%>

View File

@ -48,7 +48,7 @@
</div>
<div class="cl"></div>
<% if homework.homework_type == 2 && homework.homework_detail_programing%>
<% if homework.homework_type == 2 && homework.homework_detail_programing && @is_teacher%>
<table class="border_ce" cellpadding="0" cellspacing="0">
<tbody>
<tr class="<%= cycle("", "b_grey") %>">

View File

@ -1,25 +1,30 @@
<div class="project_r_h">
<h2 class="project_h2"><%= l(:label_statistics) %></h2>
</div>
<div class="riviseRed fl"></div><div class="fl">修订 是版本库的提交次数, 显示为橘红色。</div><br>
<div class="changeBlue fl"></div><div class="fl">变更 是对版本库中文件的修改次数, 显示为蓝色。</div>
<p style="padding-top:35px;">
<%= tag("embed", :width => 670, :height => 300, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "commits_per_month")) %>
</p>
<p style="padding-top: 50px;">
<%# 用户每月提交代码次数 %>
<%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "commits_per_author")) %>
</p>
<p style="padding-top: 50px;">
<%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "author_commits_per_month")) %>
</p>
<p style="padding-top: 50px;">
<%# 用户最近六个月的提交次数 %>
<%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "author_commits_six_month")) %>
</p>
<p style="padding-top: 50px;">
<%# 用户最近六个月的代码量 %>
<%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "author_code_six_months")) %>
</p>
<p><%= link_to l(:button_back), :action => 'show', :id => @project %></p>
<% html_title(l(:label_repository), l(:label_statistics)) -%>
<% if @status_commit_count ==0 %>
<div class="flash notice">该项目目前还没有提交过代码!</div>
<% else %>
<div class="riviseRed fl"></div><div class="fl">修订 是版本库的提交次数, 显示为橘红色。</div><br>
<div class="changeBlue fl"></div><div class="fl">变更 是对版本库中文件的修改次数, 显示为蓝色。</div>
<p style="padding-top:35px;">
<%= tag("embed", :width => 670, :height => 300, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "commits_per_month")) %>
</p>
<p style="padding-top: 50px;">
<%# 用户每月提交代码次数 %>
<%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "commits_per_author")) %>
</p>
<p style="padding-top: 50px;">
<%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "author_commits_per_month")) %>
</p>
<p style="padding-top: 50px;">
<%# 用户最近六个月的提交次数 %>
<%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "author_commits_six_month")) %>
</p>
<p style="padding-top: 50px;">
<%# 用户最近六个月的代码量 %>
<%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "author_code_six_months")) %>
</p>
<p><%= link_to l(:button_back), :action => 'show', :id => @project %></p>
<% html_title(l(:label_repository), l(:label_statistics)) -%>
<% end %>

View File

@ -1,5 +1,28 @@
<%= form_tag({action: :upload},method: "post", multipart: true) do %>
<%= text_field_tag 'school'%>
<%= file_field_tag 'logo' %>
<%= submit_tag('Upload') %>
<script>
function showPreview(source) {
var file = source.files[0];
if(window.FileReader) {
var fr = new FileReader();
fr.onloadend = function(e) {
document.getElementById("avatar_image").src = e.target.result;
};
fr.readAsDataURL(file);
}
}
</script>
<%= form_tag(upload_school_path(@school.id),method: "post", multipart: true) do %>
<%#= text_field_tag 'school'%>
<div style="margin: 20px;">
<input type="hidden" value="<%= @school_name%>" name="school_name">
<%= image_tag(@school.logo_link, id: "avatar_image", :class=>"school_avatar")%>
<a type="button" onclick="$('#file').click();" style="margin: 90px 0 0 10px;float: left;padding: 2px 5px;border: 1px solid #eaeaea;cursor: pointer;text-decoration: none;width: 55px;">上传图片</a>
<%= file_field_tag 'logo',:style => "display:none;", :id => "file", :onchange => "showPreview(this)"%>
<div style="clear: both;"></div>
<div style="margin-top: 10px;">
<%= submit_tag('上传') %>
<%= submit_tag('取消') %>
</div>
</div>
<% end %>

View File

@ -24,42 +24,41 @@
<div class="cl"></div>
</li>
<li ><span class="tit_fb ">测试结果:</span>
<table class="border_ce" cellpadding="0" cellspacing="0">
<tbody>
<tr class=" b_lblue fb c_w">
<td class="td_tit ">输入</td>
<td class="td_tit border_l ">输出</td>
<td class="td_50 border_l ">测试结果</td>
</tr>
<%@homework.homework_tests.each do |test|%>
<tr class="<%= cycle("", "b_grey") %>">
<td class="td_tit hidden">
<%= test.input%>
</td>
<td class="td_tit border_l hidden">
<%= test.output%>
</td>
<% student_work_test = StudentWorkTest.where(:homework_test_id => test.id,:student_work_id => @work.id).first%>
<td class="td_50 c_red border_l"><%= student_work_test.nil? ? "正在编译" : student_work_test.status_to_s%></td>
<input type="hidden" value="<%= student_work_test.result if student_work_test%>">
</tr>
<% end%>
<% student_work_test = @work.student_work_test.first%>
<% if student_work_test && student_work_test.error_msg && !student_work_test.error_msg.empty?%>
<tr class="border_t" >
<td colspan="3" class="td_end" >
<%= student_work_test.error_msg%>
</td>
</tr>
<% end%>
</tbody>
</table>
<div class="cl"></div>
</li>
<% if @is_teacher%>
<li ><span class="tit_fb ">测试结果:</span>
<table class="border_ce" cellpadding="0" cellspacing="0">
<tbody>
<tr class=" b_lblue fb c_w">
<td class="td_tit ">输入</td>
<td class="td_tit border_l ">输出</td>
<td class="td_50 border_l ">测试结果</td>
</tr>
<%@homework.homework_tests.each do |test|%>
<tr class="<%= cycle("", "b_grey") %>">
<td class="td_tit hidden">
<%= test.input%>
</td>
<td class="td_tit border_l hidden">
<%= test.output%>
</td>
<% student_work_test = StudentWorkTest.where(:homework_test_id => test.id,:student_work_id => @work.id).first%>
<td class="td_50 c_red border_l"><%= student_work_test.nil? ? "正在编译" : student_work_test.status_to_s%></td>
<input type="hidden" value="<%= student_work_test.result if student_work_test%>">
</tr>
<% end%>
<% student_work_test = @work.student_work_test.first%>
<% if student_work_test && student_work_test.error_msg && !student_work_test.error_msg.empty?%>
<tr class="border_t" >
<td colspan="3" class="td_end" >
<%= student_work_test.error_msg%>
</td>
</tr>
<% end%>
</tbody>
</table>
<div class="cl"></div>
</li>
<!-- 编程作业老师才可以评分 -->
<div id="add_student_score_<%= @work.id%>" class="mt10 evaluation">
<%= render :partial => 'add_score',:locals => {:work => @work,:score => @score}%>

View File

@ -56,21 +56,11 @@
<% end %>
</span>
<span class="font_welcome_trustie">
<!--
@course_page.title存储在first_page表中的title字段
原本代码
<%= @course_page.title %>
!-->
<%= l(:label_welcome_trustie_course) %>
<%= l(:label_welcome_trustie_course) %>
</span>
<% else %>
<% unless @course_page.nil? %>
<span class="font_welcome_trustie">
<!--
@course_page.title存储在first_page表中的title字段
原本代码
<%= @course_page.title %>
!-->
<%= l(:label_welcome_trustie_course) %>
</span>
<span class="font_welcome_tdescription">,
@ -112,7 +102,6 @@
course_term = "春季学期"
end
%>
<%# (month_now >= 3 && month_now < 9) ? course_term = "春季学期" : course_term = "秋季学期" %>
<% cur_school_course = @school_id.nil? ? [] : find_miracle_course(10,7,@school_id, year_now, course_term) %>
<% if cur_school_course.count == 0 %>

View File

@ -381,6 +381,7 @@ zh:
label_organization_choose: --请选择组织--
label_organization_name: 组织名称
label_organization_list: 组织列表
label_school_plural: 学校列表
label_organization_new: 新建组织
label_organization_edit: 修改组织
label_project_plural: 项目列表

View File

@ -39,6 +39,17 @@ RedmineApp::Application.routes.draw do
end
resources :school do
collection do
end
member do
get 'upload_logo'
post 'upload'
end
end
resources :homework_attach do
collection do
get 'get_homework_member_list'
@ -670,6 +681,7 @@ RedmineApp::Application.routes.draw do
match 'admin/test_email', :via => :get
match 'admin/default_configuration', :via => :post
get 'admin/organization'
get 'admin/schools'
resources :auth_sources do
member do
@ -808,9 +820,6 @@ RedmineApp::Application.routes.draw do
post 'school/search_school/', :to => 'school#search_school'
get 'school/search_school/', :to => 'school#search_school'
post 'school/upload', :to => 'school#upload'
get 'school/upload_logo', :to => 'school#upload_logo'
######added by nie
match 'tags/show_projects_tags'
########### added by liuping

View File

@ -369,6 +369,7 @@ Redmine::MenuManager.map :admin_menu do |menu|
menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural
menu.push :courses, {:controller => 'admin', :action => 'courses'}, :caption => :label_course_all
menu.push :users, {:controller => 'admin', :action => 'users'}, :caption => :label_user_plural
menu.push :schools, {:controller => 'admin', :action => 'schools'}, :caption => :label_school_plural
menu.push :first_page_made, {:controller => 'admin',:action => 'first_page_made'},:caption => :label_first_page_made
menu.push :mobile_version, {:controller => 'admin',:action => 'mobile_version'},:caption => :label_mobile_version
menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural

View File

@ -2796,4 +2796,15 @@ div.repos_explain{
.upload_img img{max-width: 100%;}
#activity .upload_img img{max-width: 580px;}
img,embed{max-width: 100%;}
img,embed{max-width: 100%;}
img.school_avatar {
background: rgb(245, 245, 245);
padding: 4px;
border: 1px solid #e5dfc7;
float: left;
display: block;
width: 100px;
height: 100px;
max-width: none;
}

View File

@ -665,7 +665,6 @@ a:hover.ping_pic{border:1px solid #64bdd9;}
.ping_back_tit{ float:left; width:523px; margin-left:10px; }
a.down_btn{ border:1px solid #CCC; color:#999; padding:0px 5px; font-size:12px; text-align:center; display:block;}
a:hover.down_btn{ background:#14ad5a; color:#fff; border:1px solid #14ad5a;}
.fr{ float:right;}
.min_search{ width:140px; height:20px; border:1px solid #d0d0d0; color:#666; background:url(../images/public_icon.png) 185px -193px no-repeat; }
.li_min_search{ float:right; margin-right:-10px;}
.info_ni_download{ width:100px; padding:5px;position: absolute;display:none;-moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; box-shadow:0px 0px 5px #194a81; color:#666; background:#fff; text-align:left;margin-left: 200px;margin-top: 10px;}