This commit is contained in:
z9hang 2014-12-31 09:05:30 +08:00
commit 42b3fd9584
12 changed files with 392 additions and 602 deletions

View File

@ -16,8 +16,6 @@ gem "coderay", "~> 1.0.6"
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "builder", "3.0.0" gem "builder", "3.0.0"
gem 'acts-as-taggable-on', '2.4.1' gem 'acts-as-taggable-on', '2.4.1'
gem 'spreadsheet'
gem 'ruby-ole'
group :development do group :development do
gem 'better_errors', path: 'lib/better_errors' gem 'better_errors', path: 'lib/better_errors'

View File

@ -1,287 +0,0 @@
PATH
remote: lib/better_errors
specs:
better_errors (1.1.0)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
PATH
remote: lib/rack-mini-profiler
specs:
rack-mini-profiler (0.9.1)
rack (>= 1.1.3)
PATH
remote: lib/seems_rateable
specs:
seems_rateable (1.0.13)
jquery-rails
rails
GEM
remote: http://ruby.taobao.org/
remote: https://rubygems.org/
specs:
actionmailer (3.2.13)
actionpack (= 3.2.13)
mail (~> 2.5.3)
actionpack (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
activemodel (3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
activerecord (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
activesupport (3.2.13)
i18n (= 0.6.1)
multi_json (~> 1.0)
acts-as-taggable-on (2.4.1)
rails (>= 3, < 5)
arel (3.0.3)
builder (3.0.0)
capybara (2.4.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
celluloid (0.15.2)
timers (~> 1.1.0)
childprocess (0.5.3)
ffi (~> 1.0, >= 1.0.11)
climate_control (0.0.3)
activesupport (>= 3.0)
cocaine (0.5.4)
climate_control (>= 0.0.3, < 1.0)
coderay (1.0.9)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.3.0)
coffee-script-source
execjs
coffee-script-source (1.7.1)
erubis (2.7.0)
execjs (2.2.1)
factory_girl (4.4.0)
activesupport (>= 3.0.0)
fastercsv (1.5.5)
ffi (1.9.3)
ffi (1.9.3-x86-mingw32)
formatador (0.2.5)
guard (2.6.1)
formatador (>= 0.2.4)
listen (~> 2.7)
lumberjack (~> 1.0)
pry (>= 0.9.12)
thor (>= 0.18.1)
guard-rails (0.5.3)
guard (~> 2.0)
guard-spork (1.5.1)
childprocess (>= 0.2.3)
guard (>= 1.1)
spork (>= 0.8.4)
guard-test (1.0.0)
guard (>= 1.8)
test-unit (~> 2.2)
hike (1.2.3)
htmlentities (4.3.2)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.0.3)
railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
json (1.8.1)
kaminari (0.16.1)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
libv8 (3.16.14.3)
listen (2.7.9)
celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
lumberjack (1.0.9)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.4)
method_source (0.8.2)
mime-types (1.25.1)
mini_portile (0.6.0)
mocha (1.1.0)
metaclass (~> 0.0.1)
multi_json (1.10.1)
mysql2 (0.3.11)
mysql2 (0.3.11-x86-mingw32)
net-ldap (0.3.1)
nokogiri (1.6.3)
mini_portile (= 0.6.0)
nokogiri (1.6.3-x86-mingw32)
mini_portile (= 0.6.0)
paperclip (3.5.4)
activemodel (>= 3.0.0)
activesupport (>= 3.0.0)
cocaine (~> 0.5.3)
mime-types
polyglot (0.3.5)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pry (0.9.12.6-x86-mingw32)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
win32console (~> 1.3)
pry-nav (0.2.3)
pry (~> 0.9.10)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
rack-openid (1.4.2)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-raw-upload (1.1.1)
multi_json
rack-ssl (1.3.4)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.13)
actionmailer (= 3.2.13)
actionpack (= 3.2.13)
activerecord (= 3.2.13)
activeresource (= 3.2.13)
activesupport (= 3.2.13)
bundler (~> 1.0)
railties (= 3.2.13)
railties (3.2.13)
actionpack (= 3.2.13)
activesupport (= 3.2.13)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.3.2)
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
rdoc (3.12.2)
json (~> 1.4)
ref (1.0.5)
rich (1.4.6)
jquery-rails
kaminari
mime-types
paperclip
rack-raw-upload
rails (>= 3.2.0)
sass-rails
rmagick (2.13.2)
ruby-ole (1.2.11.7)
ruby-openid (2.1.8)
rubyzip (1.1.6)
sass (3.3.10)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
selenium-webdriver (2.42.0)
childprocess (>= 0.5.0)
multi_json (~> 1.0)
rubyzip (~> 1.0)
websocket (~> 1.0.4)
shoulda (3.5.0)
shoulda-context (~> 1.0, >= 1.0.1)
shoulda-matchers (>= 1.4.1, < 3.0)
shoulda-context (1.2.1)
shoulda-matchers (2.6.1)
activesupport (>= 3.0.0)
slop (3.5.0)
spork (0.9.2)
spork-testunit (0.0.8)
spork (>= 0.6.0)
spreadsheet (1.0.0)
ruby-ole (>= 1.0)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
test-unit (2.5.5)
therubyracer (0.12.1)
libv8 (~> 3.16.14.0)
ref
thor (0.19.1)
tilt (1.4.1)
timers (1.1.0)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.40)
uglifier (2.5.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
websocket (1.0.7)
win32console (1.3.2-x86-mingw32)
xpath (2.0.0)
nokogiri (~> 1.3)
PLATFORMS
ruby
x86-mingw32
DEPENDENCIES
activerecord-jdbc-adapter (= 1.2.5)
activerecord-jdbcmysql-adapter
acts-as-taggable-on (= 2.4.1)
better_errors!
builder (= 3.0.0)
capybara (~> 2.4.1)
coderay (~> 1.0.6)
coffee-rails (~> 3.2.1)
factory_girl (~> 4.4.0)
fastercsv (~> 1.5.0)
guard-rails (~> 0.5.3)
guard-spork (~> 1.5.1)
guard-test (~> 1.0.0)
htmlentities
i18n (~> 0.6.0)
jquery-rails (~> 2.0.2)
kaminari
mocha (~> 1.1.0)
mysql2 (= 0.3.11)
net-ldap (~> 0.3.1)
nokogiri (~> 1.6.3)
paperclip (~> 3.5.4)
pry
pry-nav
rack-mini-profiler!
rack-openid
rails (= 3.2.13)
rich (= 1.4.6)
rmagick (>= 2.0.0)
ruby-ole
ruby-openid (~> 2.1.4)
sass-rails (~> 3.2.3)
seems_rateable!
selenium-webdriver (~> 2.42.0)
shoulda (~> 3.5.0)
spork-testunit (~> 0.0.8)
spreadsheet
therubyracer
uglifier (>= 1.0.3)

View File

@ -318,7 +318,7 @@ class CoursesController < ApplicationController
else else
page_from = params[:page].nil? ? 0 : (params[:page].to_i - 1) page_from = params[:page].nil? ? 0 : (params[:page].to_i - 1)
@results = student_homework_score(0,page_from, 10,"") @results = student_homework_score(0,page_from, 10,"desc")
@results = paginateHelper_for_members @results, 10 @results = paginateHelper_for_members @results, 10
end end
@ -909,11 +909,47 @@ class CoursesController < ApplicationController
def student_homework_score(groupid,start_from, nums, score_sort_by) def student_homework_score(groupid,start_from, nums, score_sort_by)
#teachers = find_course_teachers(@course) #teachers = find_course_teachers(@course)
start_from = start_from * nums start_from = start_from * nums
sql_select = ""
if groupid == 0
if nums == 0
sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches
WHERE members.course_id = 122 AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = 122) AND members.user_id = homework_attaches.user_id GROUP BY members.user_id
UNION
SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = 122 AND
students_for_courses.course_id = 122 and members.user_id = students_for_courses.student_id AND
members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = 122 )
)
GROUP BY members.user_id ORDER BY score #{score_sort_by}"
else
sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches
WHERE members.course_id = 122 AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = 122) AND members.user_id = homework_attaches.user_id GROUP BY members.user_id
UNION
SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = 122 AND
students_for_courses.course_id = 122 and members.user_id = students_for_courses.student_id AND
members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = 122 )
)
GROUP BY members.user_id ORDER BY score #{score_sort_by} limit #{start_from}, #{nums}"
end
else
sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches
WHERE members.course_id = #{@course.id} AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = #{@course.id}) AND members.user_id = homework_attaches.user_id
and members.course_group_id = #{groupid}
GROUP BY members.user_id
UNION
SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = #{@course.id}
and members.course_group_id = #{groupid} AND
students_for_courses.course_id = #{@course.id} and members.user_id = students_for_courses.student_id AND
members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = 122 )
)
GROUP BY members.user_id ORDER BY score #{score_sort_by}"
end
sql = ActiveRecord::Base.connection() sql = ActiveRecord::Base.connection()
homework_scores = Member.find_by_sql(sql_select)
homework_scores = Member.find_by_sql("call member_score(#{@course.id},#{groupid},#{start_from},#{nums}, '#{score_sort_by}')")
sql.close() sql.close()
homework_scores homework_scores
end end
#获取课程的老师列表 #获取课程的老师列表

View File

@ -435,6 +435,7 @@ class HomeworkAttachController < ApplicationController
@is_teacher,@is_anonymous_comments,@m_score = params[:is_teacher]=="true",params[:is_anonymous_comments]=="true",params[:stars_value] @is_teacher,@is_anonymous_comments,@m_score = params[:is_teacher]=="true",params[:is_anonymous_comments]=="true",params[:stars_value]
@cur_page,@cur_type = params[:cur_page] || 1,params[:cur_type] || 5 @cur_page,@cur_type = params[:cur_page] || 1,params[:cur_type] || 5
@homework = HomeworkAttach.find(params[:homework_id]) @homework = HomeworkAttach.find(params[:homework_id])
homework = @homework
is_teacher = @is_teacher ? 1 : 0 is_teacher = @is_teacher ? 1 : 0
#保存评分@homework.rate(@m_score.to_i,User.current.id,:quality, (@is_teacher ? 1 : 0)) #保存评分@homework.rate(@m_score.to_i,User.current.id,:quality, (@is_teacher ? 1 : 0))
if @m_score if @m_score
@ -445,7 +446,23 @@ class HomeworkAttachController < ApplicationController
else else
@homework.rates(:quality).new(:stars => @m_score, :rater_id => User.current.id, :is_teacher_score => is_teacher).save! @homework.rates(:quality).new(:stars => @m_score, :rater_id => User.current.id, :is_teacher_score => is_teacher).save!
end end
end if homework.is_teacher_score == 0
if is_teacher == 1
homework.score = @m_score
homework.is_teacher_score = 1
else
homework.score = (homework.score.nil? ? 0 : homework.score + @m_score) / homework.rates(:quality).count
end
else
if is_teacher == 1
homework.score = @m_score
homework.is_teacher_score = 1
end
end
homework.save!
end
#保存评论 #保存评论
@is_comprehensive_evaluation = @is_teacher ? 1 : (@is_anonymous_comments ? 2 : 3) #判断当前评论是老师评论?匿评?留言 @is_comprehensive_evaluation = @is_teacher ? 1 : (@is_anonymous_comments ? 2 : 3) #判断当前评论是老师评论?匿评?留言
if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" #有没有留言 if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" #有没有留言

View File

@ -74,7 +74,7 @@
<% end %> <% end %>
</ul> </ul>
<% if @subPage_title == l(:label_student_list) %> <% if @subPage_title == l(:label_student_list) %>
<%= link_to format("%0.2f",member.score.to_s), { <%= link_to format("%0.2f",member.score.nil? ? 0 : member.score.to_s), {
:action => 'show_member_score', :action => 'show_member_score',
:member_id => member.id, :member_id => member.id,
:remote => true}, :remote => true},

View File

@ -1,64 +1,64 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>浮动倒计时公告</title> <title>浮动倒计时公告</title>
<style type="text/css"> <style type="text/css">
/*网页高度*/ /*网页高度*/
body{ height:3000px;} body{ height:3000px;}
div,ul,li,body{margin:0; padding:0;} div,ul,li,body{margin:0; padding:0;}
/*position:absolute;用于元素的定位*/ /*position:absolute;用于元素的定位*/
#roll{ background:url(/images/f_notice.jpg) 0 0 no-repeat;width:140px; height:217px; position:absolute;} #roll{ background:url(/images/f_notice.jpg) 0 0 no-repeat;width:140px; height:217px; position:absolute;}
.timemsg{ margin-left:26px; margin-top:114px;color:#c02b2b; font-size:16px; font-weight:bold;} .timemsg{ margin-left:26px; margin-top:114px;color:#c02b2b; font-size:16px; font-weight:bold;}
</style> </style>
</head> </head>
<body> <body>
<div id="roll"> <div id="roll">
<div class="timemsg"> <div class="timemsg">
<!-- <span id="t_d">00:</span> --> <!-- <span id="t_d">00:</span> -->
<span id="t_h">00:</span> <span id="t_h">00:</span>
<span id="t_m">00:</span> <span id="t_m">00:</span>
<span id="t_s">00</span> <span id="t_s">00</span>
</div> </div>
</div> </div>
</body> </body>
</html> </html>
<script type="text/javascript"> <script type="text/javascript">
function getRTime(){ function getRTime(){
var EndTime= new Date('2014/12/31 12:30:00'); //截止时间 var EndTime= new Date('2014/12/31 12:30:00'); //截止时间
var NowTime = new Date(); var NowTime = new Date();
var t =EndTime.getTime() - NowTime.getTime(); var t =EndTime.getTime() - NowTime.getTime();
// var d=Math.floor(t/1000/60/60/24); // var d=Math.floor(t/1000/60/60/24);
var h=Math.floor(t/1000/60/60%24); var h=Math.floor(t/1000/60/60%24);
var m=Math.floor(t/1000/60%60); var m=Math.floor(t/1000/60%60);
var s=Math.floor(t/1000%60); var s=Math.floor(t/1000%60);
// document.getElementById("t_d").innerHTML = d + ":"; // document.getElementById("t_d").innerHTML = d + ":";
document.getElementById("t_h").innerHTML = h + ":"; document.getElementById("t_h").innerHTML = h + ":";
document.getElementById("t_m").innerHTML = m + ":"; document.getElementById("t_m").innerHTML = m + ":";
document.getElementById("t_s").innerHTML = s ; document.getElementById("t_s").innerHTML = s ;
} }
setInterval(getRTime,1000); setInterval(getRTime,1000);
</script> </script>
<script> <script>
var roll=document.getElementById('roll'), var roll=document.getElementById('roll'),
initX=0, initX=0,
initY, initY,
compY, compY,
sp=15, sp=15,
//可调整时间间隔步进值不宜过大不然IE下有点闪屏 //可调整时间间隔步进值不宜过大不然IE下有点闪屏
timeGap=5, timeGap=5,
doc=document.documentElement, doc=document.documentElement,
docBody=document.body; docBody=document.body;
compY=initY=100; compY=initY=100;
roll.style.right=initX+"px"; roll.style.right=initX+"px";
;(function(){ ;(function(){
var curScrollTop=(doc.scrollTop||docBody.scrollTop||0)-(doc.clientTop||docBody.clientTop||0); var curScrollTop=(doc.scrollTop||docBody.scrollTop||0)-(doc.clientTop||docBody.clientTop||0);
//每次comP的值都不一样直到roll.style.top===doc.scrollTop+initY //每次comP的值都不一样直到roll.style.top===doc.scrollTop+initY
compY+=(curScrollTop+initY-compY)/sp; compY+=(curScrollTop+initY-compY)/sp;
roll.style.top=Math.ceil(compY)+"px"; roll.style.top=Math.ceil(compY)+"px";
setTimeout(arguments.callee,timeGap); setTimeout(arguments.callee,timeGap);
})(); })();
</script> </script>

View File

@ -1,46 +1,46 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<%= current_language %>"> <html lang="<%= current_language %>">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title><%=h html_title %></title> <title><%=h html_title %></title>
<meta name="description" content="<%= Redmine::Info.app_name %>" /> <meta name="description" content="<%= Redmine::Info.app_name %>" />
<meta name="keywords" content="issue,bug,tracker" /> <meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %> <%= csrf_meta_tag %>
<%= favicon %> <%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %> <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %> <%= javascript_heads %>
<%= javascript_include_tag "jquery.leanModal.min" %> <%= javascript_include_tag "jquery.leanModal.min" %>
<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%> <%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%>
<%= heads_for_theme %> <%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %> <%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags --> <!-- page specific tags -->
<%= yield :header_tags -%> <%= yield :header_tags -%>
</head> </head>
<body class="<%=h body_css_classes %>"> <body class="<%=h body_css_classes %>">
<div id="wrapper"> <div id="wrapper">
<div id="wrapper2"> <div id="wrapper2">
<div id="wrapper3"> <div id="wrapper3">
<%=render :partial => 'layouts/base_header'%> <%=render :partial => 'layouts/base_header'%>
<%= render :partial => 'layouts/base_ad' %> <%= render :partial => 'layouts/base_ad' %>
<div id="main" class="nosidebar"> <div id="main" class="nosidebar">
<div id="content_"> <div id="content_">
<%= render_flash_messages %> <%= render_flash_messages %>
<%= yield %> <%= yield %>
<%= call_hook :view_layouts_base_content %> <%= call_hook :view_layouts_base_content %>
<div style="clear:both;"></div> <div style="clear:both;"></div>
<%=render :partial => 'layouts/base_footer'%> <%=render :partial => 'layouts/base_footer'%>
</div> </div>
</div> </div>
</div> </div>
<div id="ajax-indicator" style="display:none;"><span><%= l(:label_loading) %></span></div> <div id="ajax-indicator" style="display:none;"><span><%= l(:label_loading) %></span></div>
<div id="ajax-modal" style="display:none;"></div> <div id="ajax-modal" style="display:none;"></div>
</div> </div>
</div> </div>
<%= call_hook :view_layouts_base_body_bottom %> <%= call_hook :view_layouts_base_body_bottom %>
</body> </body>
</html> </html>

View File

@ -1,94 +1,94 @@
<script type="text/javascript"> <script type="text/javascript">
function searchUser(){ function searchUser(){
var name = $("#name").val(); var name = $("#name").val();
if(name == "") if(name == "")
{ {
alert("搜索条件不能为空"); alert("搜索条件不能为空");
return; return;
} }
$("#search_user_form").submit(); $("#search_user_form").submit();
} }
function searchByChange() function searchByChange()
{ {
$("#search_by_input").val($("#search_by").val()); $("#search_by_input").val($("#search_by").val());
} }
</script> </script>
<div class="top-content"> <div class="top-content">
<%= form_tag( users_search_path, :method => :get, :id => 'search_user_form') do %> <%= form_tag( users_search_path, :method => :get, :id => 'search_user_form') do %>
<table width="940px"> <table width="940px">
<tr> <tr>
<td class="info_font" style="width: 220px; color: #15bccf " rowspan="2"> <td class="info_font" style="width: 220px; color: #15bccf " rowspan="2">
<%= l(:label_software_user ) %> <%= l(:label_software_user ) %>
</td> </td>
<td class="location-list"> <td class="location-list">
<strong><%= l(:label_user_location) %> :</strong> <strong><%= l(:label_user_location) %> :</strong>
</td> </td>
<td rowspan="2"> <td rowspan="2">
</td> </td>
<td rowspan="2" > <td rowspan="2" >
<div class="project-search" style="float: right"> <div class="project-search" style="float: right">
<!--label for="user_browse_label"><%#= l(:label_user_search_type) %></label--> <!--label for="user_browse_label"><%#= l(:label_user_search_type) %></label-->
<%= select_tag(:search_by,options_for_select([["昵称","0"],["姓名","1"],["邮箱","2"]],@search_by), :onchange => "searchByChange();" ) %> <%= select_tag(:search_by,options_for_select([["昵称","0"],["姓名","1"],["邮箱","2"]],@search_by), :onchange => "searchByChange();" ) %>
<%= text_field_tag 'name', params[:name], :size => 30 %> <%= text_field_tag 'name', params[:name], :size => 30 %>
<input type="text" name="search_by_input" hidden="hidden;" id="search_by_input" value="0"> <input type="text" name="search_by_input" hidden="hidden;" id="search_by_input" value="0">
<input type="button" class="enterprise" value="<%= l(:label_search) %>" onclick="searchUser();"/> <input type="button" class="enterprise" value="<%= l(:label_search) %>" onclick="searchUser();"/>
<%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %> <%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
</div> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td > <td >
<%=link_to l(:field_homepage), home_path %> > <%=link_to l(:field_homepage), home_path %> >
<a><%= l(:label_software_user)%></a> <a><%= l(:label_software_user)%></a>
</td> </td>
</tr> </tr>
</table> </table>
</div> </div>
<% end %> <% end %>
<div class="autoscroll"> <div class="autoscroll">
<% if @users.size > 0 %> <% if @users.size > 0 %>
<%= render :partial => 'user_show' %> <%= render :partial => 'user_show' %>
<!-- <!--
<%# @users.each do |user| -%> <%# @users.each do |user| -%>
<%# unless user.id == 1%> <%# unless user.id == 1%>
<div class="well"> <div class="well">
<%#= content_tag "p", "#{format_date(user.created_on)}#{l(:label_member_since)}", :class => "float_right member_since" %> <%#= content_tag "p", "#{format_date(user.created_on)}#{l(:label_member_since)}", :class => "float_right member_since" %>
<%#= image_tag "/images/time_member.png", :class => "img_member_time"%> <%#= image_tag "/images/time_member.png", :class => "img_member_time"%>
<div> <div>
<%#= image_tag(url_to_avatar(user), :class => 'avatar') %> <%#= image_tag(url_to_avatar(user), :class => 'avatar') %>
<%#= content_tag "span", link_to_user(user), :class => "nomargin avatar_name" %> <%#= content_tag "span", link_to_user(user), :class => "nomargin avatar_name" %>
</div> </div>
<div style="margin-top: 20px;margin-left:66px"> <div style="margin-top: 20px;margin-left:66px">
<%#= l(:label_has_fans,:count=>user.watcher_users.count)%> <%#= l(:label_has_fans,:count=>user.watcher_users.count)%>
<%#= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %> <%#= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %>
</div> </div>
<div class="user-bottom"> <div class="user-bottom">
<%# unless user.memberships.empty? %> <%# unless user.memberships.empty? %>
<%#= l(:label_contribute_to, :project_count => "#{user.memberships.count}") %> <%#= l(:label_contribute_to, :project_count => "#{user.memberships.count}") %>
<%# for member in user.memberships %> <%# for member in user.memberships %>
<%#= link_to_project(member.project) %><%#= (user.memberships.last == member) ? '' : '' %> <%#= link_to_project(member.project) %><%#= (user.memberships.last == member) ? '' : '' %>
<%# end %> <%# end %>
<%# end %> <%# end %>
<%#= user.changesets.count == 0 ? '' : ",#{l(:label_total_commit, :total_commit => user.changesets.count)}" %> <%#= user.changesets.count == 0 ? '' : ",#{l(:label_total_commit, :total_commit => user.changesets.count)}" %>
</div> </div>
</div> </div>
<%# end -%> <%# end -%>
<%# end -%> <%# end -%>
--> -->
<% else %> <% else %>
<%= render :partial => "layouts/no_content"%> <%= render :partial => "layouts/no_content"%>
<% end %> <% end %>
</div> </div>
<div class="pagination"> <div class="pagination">
<ul> <ul>
<%= pagination_links_full @user_pages, @user_count %> <%= pagination_links_full @user_pages, @user_count %>
</ul> </ul>
</div> </div>
<% html_title(l(:label_user_plural)) -%> <% html_title(l(:label_user_plural)) -%>

View File

@ -1,99 +1,99 @@
<% <%
select_option = [] select_option = []
(select_option << ['项目', 'projects']) if project_type == Project::ProjectType_project (select_option << ['项目', 'projects']) if project_type == Project::ProjectType_project
(select_option << ['课程', 'courses']) if project_type == Project::ProjectType_course (select_option << ['课程', 'courses']) if project_type == Project::ProjectType_course
select_option << ['用户', 'users'] select_option << ['用户', 'users']
%> %>
<style type="text/css"> <style type="text/css">
form #q, form #search_type{ form #q, form #search_type{
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
display: inline-block; display: inline-block;
margin: 0px; margin: 0px;
padding: 5px; padding: 5px;
height: 33px; height: 33px;
} }
form #q{ form #q{
font-size: 13px; font-size: 13px;
border-top-left-radius: 5px; border-top-left-radius: 5px;
border-bottom-left-radius: 5px; border-bottom-left-radius: 5px;
border-right: none; border-right: none;
} }
form #search_type{ form #search_type{
font-size: 13px; font-size: 13px;
color: #363739; color: #363739;
border-top-right-radius: 5px; border-top-right-radius: 5px;
border-bottom-right-radius: 5px; border-bottom-right-radius: 5px;
border-bottom-left-radius: 0px; border-bottom-left-radius: 0px;
border-top-left-radius: 0px; border-top-left-radius: 0px;
border-left: 1px outset #83A9A9; border-left: 1px outset #83A9A9;
margin-left: -4px; margin-left: -4px;
-webkit-appearance: none; -webkit-appearance: none;
-moz-appearance: none; -moz-appearance: none;
text-indent: 0.01px; text-indent: 0.01px;
text-overflow: ''; text-overflow: '';
} }
form #search_by form #search_by
{ {
font-size: 13px; font-size: 13px;
color: #363739; color: #363739;
border-top-right-radius: 5px; border-top-right-radius: 5px;
border-bottom-right-radius: 5px; border-bottom-right-radius: 5px;
border-bottom-left-radius: 0px; border-bottom-left-radius: 0px;
border-top-left-radius: 0px; border-top-left-radius: 0px;
border-left: 1px outset #83A9A9; border-left: 1px outset #83A9A9;
margin-left: -6px; margin-left: -6px;
-webkit-appearance: none; -webkit-appearance: none;
-moz-appearance: none; -moz-appearance: none;
text-indent: 0.01px; text-indent: 0.01px;
text-overflow: ''; text-overflow: '';
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
display: inline-block; display: inline-block;
padding: 5px; padding: 5px;
height: 33px; height: 33px;
display: none; display: none;
} }
.search_widget{ .search_widget{
display:inline-block; display:inline-block;
border-radius: 5px; border-radius: 5px;
} }
.search_widget:hover{ .search_widget:hover{
box-shadow: 0px 0px 3px #56B4EF; box-shadow: 0px 0px 3px #56B4EF;
} }
<%#完了把上面东西放到 .css 里%> <%#完了把上面东西放到 .css 里%>
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
function searchTypeChange() function searchTypeChange()
{ {
if($("#search_type").val() == "users") if($("#search_type").val() == "users")
{ {
$("#search_by").show(); $("#search_by").show();
} }
else else
{ {
$("#search_by").hide(); $("#search_by").hide();
} }
} }
function searchByChange() function searchByChange()
{ {
$("#search_by_input").val($("#search_by").val()); $("#search_by_input").val($("#search_by").val());
} }
</script> </script>
<%= form_tag({controller: :welcome, action: :search }, method: :get) do %> <%= form_tag({controller: :welcome, action: :search }, method: :get) do %>
<div class="project-search" style="float: right"> <div class="project-search" style="float: right">
<div class='search_widget'> <div class='search_widget'>
<%= text_field_tag :q, nil, placeholder:'请输入要搜索的关键字', :size => 27 %> <%= text_field_tag :q, nil, placeholder:'请输入要搜索的关键字', :size => 27 %>
<input type="text" name="search_by_input" hidden="hidden;" id="search_by_input" value="0"> <input type="text" name="search_by_input" hidden="hidden;" id="search_by_input" value="0">
<%= select_tag(:search_type, options_for_select(select_option), :onchange => "searchTypeChange();" ) %> <%= select_tag(:search_type, options_for_select(select_option), :onchange => "searchTypeChange();" ) %>
<%= select_tag(:search_by,options_for_select([["昵称","0"],["姓名","1"],["邮箱","2"]]), :onchange => "searchByChange();" ) %> <%= select_tag(:search_by,options_for_select([["昵称","0"],["姓名","1"],["邮箱","2"]]), :onchange => "searchByChange();" ) %>
</div> </div>
<%#= hidden_field_tag 'project_type', project_type %> <%#= hidden_field_tag 'project_type', project_type %>
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %> <%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
</div> </div>
<% end %> <% end %>

View File

@ -0,0 +1,6 @@
class AddColumnToHomeworkattaches < ActiveRecord::Migration
def change
add_column :homework_attaches, :score, :float, default: 0
add_column :homework_attaches, :is_teacher_score, :integer, :default => 0
end
end

View File

@ -0,0 +1,18 @@
class UpdateScoreToHomeworkattaches < ActiveRecord::Migration
def up
sql = ("UPDATE homework_attaches set is_teacher_score = 1,
score = (SELECT AVG(seems_rateable_rates.stars) FROM seems_rateable_rates
WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id
AND is_teacher_score = 1 GROUP BY rateable_id);")
sql_student = ("UPDATE homework_attaches set is_teacher_score = 0,
score = (SELECT AVG(seems_rateable_rates.stars) FROM seems_rateable_rates
WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id
AND is_teacher_score = 0 GROUP BY rateable_id) WHERE homework_attaches.score = 0 OR homework_attaches.score is NULL
")
execute(sql)
execute(sql_student)
end
def down
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20141230062844) do ActiveRecord::Schema.define(:version => 20141230081744) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -483,13 +483,15 @@ ActiveRecord::Schema.define(:version => 20141230062844) do
create_table "homework_attaches", :force => true do |t| create_table "homework_attaches", :force => true do |t|
t.integer "bid_id" t.integer "bid_id"
t.integer "user_id" t.integer "user_id"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.string "reward" t.string "reward"
t.string "name" t.string "name"
t.text "description" t.text "description"
t.integer "state" t.integer "state"
t.integer "project_id", :default => 0 t.integer "project_id", :default => 0
t.float "score", :default => 0.0
t.integer "is_teacher_score", :default => 0
end end
create_table "homework_evaluations", :force => true do |t| create_table "homework_evaluations", :force => true do |t|