Merge branch 'Homework' of http://repository.trustie.net/xianbo/trustie2 into Homework

This commit is contained in:
z9hang 2014-10-31 14:06:50 +08:00
commit 15b4cedaba
17 changed files with 126 additions and 56 deletions

View File

@ -6,7 +6,8 @@ class HomeworkAttachController < ApplicationController
###############################
before_filter :can_show_course,except: []
#判断当前角色权限时需先找到当前操作的project
before_filter :find_course_by_bid_id, :only => [:new,:get_not_batch_homework,:get_batch_homeworks,:get_homeworks,:get_homework_jours]
before_filter :find_course_by_bid_id, :only => [:new]
before_filter :find_bid_and_course,:only => [:get_not_batch_homework,:get_batch_homeworks,:get_homeworks,:get_homework_jours]
before_filter :find_course_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users]
#判断当前角色是否有操作权限
#勿删 before_filter :authorize, :only => [:new,:edit,:update,:destroy]
@ -14,13 +15,13 @@ class HomeworkAttachController < ApplicationController
#获取未批作业列表
def get_not_batch_homework
sort, direction = params[:sort], params[:direction]
order_by = sort == 'score'? "s_score #{direction}" : "created_at #{direction}"
order_by = sort == 'socre'? "s_score #{direction}" : "created_at #{direction}"
teachers = find_course_teachers @course
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers}) AS t_score,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score
FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY #{order_by}) AS table1
FROM homework_attaches WHERE bid_id = #{@bid.id}
ORDER BY #{order_by}) AS table1
WHERE table1.t_score IS NULL")
@homework_list = paginateHelper all_homework_list,10
@ -33,13 +34,14 @@ class HomeworkAttachController < ApplicationController
#获取已评作业列表
def get_batch_homeworks
sort, direction = params[:sort], params[:direction]
teachers = find_course_teachers @course
teacher_proportion = get_teacher_proportion @bid
order_by = sort == 'socre'? "(CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{teacher_proportion} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - teacher_proportion} END) #{direction}" : "created_at #{direction}"
teachers = find_course_teachers @course
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers} and stars IS NOT NULL) AS t_score,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score
FROM homework_attaches WHERE bid_id = #{@bid.id}
ORDER BY (CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{teacher_proportion} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - teacher_proportion} END) DESC,created_at ASC) AS table1
ORDER BY #{order_by}) AS table1
WHERE table1.t_score IS NOT NULL")
@homework_list = paginateHelper all_homework_list,10
@direction = direction == 'asc'? 'desc' : 'asc'
@ -51,13 +53,14 @@ class HomeworkAttachController < ApplicationController
#获取所有作业列表
def get_homeworks
sort, direction = params[:sort], params[:direction]
teachers = find_course_teachers @course
teacher_proportion = get_teacher_proportion @bid
order_by = sort == 'socre'? "(CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{teacher_proportion} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - teacher_proportion} END) #{direction}" : "created_at #{direction}"
teachers = find_course_teachers @course
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id in #{teachers}) AS t_score,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id not in #{teachers}) AS s_score
FROM homework_attaches WHERE bid_id = #{@bid.id}
ORDER BY (CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{teacher_proportion} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - teacher_proportion} END) DESC,created_at ASC")
ORDER BY #{order_by}")
@homework_list = paginateHelper all_homework_list,10
@direction = direction == 'asc'? 'desc' : 'asc'
respond_to do |format|
@ -391,6 +394,13 @@ class HomeworkAttachController < ApplicationController
end
end
def find_bid_and_course
@bid = Bid.find(params[:bid_id])
@course = @bid.courses.first
rescue ActiveRecord::RecordNotFound
render_404
end
def find_course_by_bid_id
@bid = Bid.find(params[:id])
@course = @bid.courses.first

View File

@ -1896,13 +1896,13 @@ module ApplicationHelper
def sort_homework_path(bid, sort, direction)
case self.action_name
when 'show_courseEx'
get_not_batch_homework_homework_attach_path(bid, sort: sort, direction: 'asc')
get_not_batch_homework_homework_attach_index_path(bid_id: bid.id, sort: sort, direction: 'asc')
when 'get_not_batch_homework'
get_not_batch_homework_homework_attach_path(bid, sort: sort, direction: direction)
get_not_batch_homework_homework_attach_index_path(bid_id: bid.id, sort: sort, direction: direction)
when 'get_batch_homeworks'
get_batch_homeworks_homework_attach_path(bid, sort: sort, direction: direction)
get_batch_homeworks_homework_attach_index_path(bid_id: bid.id, sort: sort, direction: direction)
when 'get_homeworks'
get_homeworks_homework_attach_path(bid, sort: sort, direction: direction)
get_homeworks_homework_attach_index_path(bid_id: bid.id, sort: sort, direction: direction)
else
'#'
end

View File

@ -14,17 +14,17 @@
<div id="tb_" class="tb_">
<ul>
<li id="tb_1" class="hovertab">
<%= link_to "未批作业", get_not_batch_homework_homework_attach_path(@bid), {:remote => true}%>
<%= link_to "未批作业", get_not_batch_homework_homework_attach_index_path(:bid_id => @bid.id), {:remote => true}%>
</li>
<li id="tb_2" class="normaltab">
<%= link_to "已改作业", get_batch_homeworks_homework_attach_path(@bid), {:remote => true}%>
<%= link_to "已改作业", get_batch_homeworks_homework_attach_index_path(:bid_id => @bid.id), {:remote => true}%>
</li>
<li id="tb_3" class="normaltab">
<%= link_to "全部作业", get_homeworks_homework_attach_path(@bid), {:remote => true}%>
<%= link_to "全部作业", get_homeworks_homework_attach_index_path(:bid_id => @bid.id), {:remote => true}%>
</li>
<li id="tb_4" class="normaltab" onclick="o:HoverLi(4);"><a href="#">作业下载</a></li>
<li id="tb_5" class="normaltab">
<%= link_to "留言", get_homework_jours_homework_attach_path(@bid), {:remote => true}%>
<%= link_to "留言", get_homework_jours_homework_attach_index_path(:bid_id => @bid.id), {:remote => true}%>
(<span class="c_red f_12">23</span>)
</li>
</ul>
@ -32,7 +32,7 @@
<div class="cl"></div>
<div class="ctt">
<div class="dis" id="tbc_01">
<%= render :partial => 'homework_attach/homeworks_list', :locals => {:homeworks => @homework_list, :homework_count => @obj_count, :bid => @bid}%>
<%= render :partial => 'homework_attach/homeworks_list', :locals => {:homeworks => @homework_list, :homework_count => @obj_count, :bid => @bid, :remote => false}%>
</div><!---未批作业结束-->
</div>
</div>

View File

@ -20,9 +20,10 @@
<ul>
<li class="pic_head">
<a href="#" target="_blank">
<%= image_tag(url_to_avatar(homework.user), :width => "40", :height => "40")%>
<%= link_to image_tag(url_to_avatar(homework.user), :width => "40", :height => "40"), user_path(homework.user) %>
<span>
<% user_name = is_teacher ? (homework.user.lastname + homework.user.firstname) : homework.user.login %>
<% user_realname = homework.user.lastname.to_s + homework.user.firstname.to_s %>
<% user_name = is_teacher ? (user_realname.empty? ? homework.user.login : user_realname) : homework.user.login %>
<%= link_to user_name, user_path(homework.user), :title => user_name %>
</span>
</a>
@ -61,4 +62,5 @@
<div class="cl"></div>
<% end %>
<% else %>
<% end %>
<% end %>
<ul class="wlist"><%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => remote, :flag => true%></ul>

View File

@ -15,12 +15,12 @@
<body>
<div id="popbox">
<div class="alert" style="position: fixed;">
<div>
<!--<div class="alert" style="position: fixed;">-->
<!--<div>-->
<span class="close" style="display: block;" onclick="hideModal(this)"></span>
</div>
</div> <!---- alert end---->
<!--<span class="close" style="display: block;" onclick="hideModal(this)"></span>-->
<!--</div>-->
<!--</div> &lt;!&ndash;-- alert end--&ndash;&gt;-->
<div class="ping_con">
<h2>科大校园助手最终提交文档及源码</h2>
<ul>

View File

@ -60,7 +60,7 @@
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong style="vertical-align: top">描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述&nbsp;&nbsp;</strong>&nbsp;
<span style="margin-left:-10px;padding-right: 20px;">
<%= f.text_area :description, :rows => 8, :name => "homework_description", :class => 'wiki-edit', :maxlength => 65534, :style => "font-size:small;width:490px;margin-left:10px;" %>
<%= f.text_area :description, :rows => 8, :name => "homework_description", :class => 'wiki-edit', :maxlength => 3000, :style => "font-size:small;width:490px;margin-left:10px;" %>
</span>
</p>
<p style="padding-left: 60px">

View File

@ -1,3 +1,4 @@
$('#tbc_01').html('<%= escape_javascript(render(:partial => 'homeworks_list', :locals => {:homeworks => @homework_list, :homework_count => @obj_count, :bid => @bid} )) %>');
$('#tbc_01').html('<%= escape_javascript(render(:partial => 'homeworks_list',
:locals => {:homeworks => @homework_list, :homework_count => @obj_count, :bid => @bid, :remote => true} )) %>');
for(var i=1;i<=5;i++){$("#tb_"+i).removeClass().addClass("normaltab");}
$("#tb_2").removeClass().addClass("hovertab");

View File

@ -1,4 +1,5 @@
$('#tbc_01').html('<%= escape_javascript(render(:partial => 'homeworks_list', :locals => {:homeworks => @homework_list, :homework_count => @obj_count, :bid => @bid} )) %>');
$('#tbc_01').html('<%= escape_javascript(render(:partial => 'homeworks_list',
:locals => {:homeworks => @homework_list, :homework_count => @obj_count, :bid => @bid, :remote => true} )) %>');
for(var i=1;i<=5;i++){$("#tb_"+i).removeClass().addClass("normaltab");}
$("#tb_3").removeClass().addClass("hovertab");

View File

@ -1,3 +1,4 @@
$('#tbc_01').html('<%= escape_javascript(render(:partial => 'homeworks_list', :locals => {:homeworks => @homework_list, :homework_count => @obj_count, :bid => @bid} )) %>');
$('#tbc_01').html('<%= escape_javascript(render(:partial => 'homeworks_list',
:locals => {:homeworks => @homework_list, :homework_count => @obj_count, :bid => @bid, :remote => true} )) %>');
for(var i=1;i<=5;i++){$("#tb_"+i).removeClass().addClass("normaltab");}
$("#tb_1").removeClass().addClass("hovertab");

View File

@ -1,3 +1,3 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'show') %>');
showModal('ajax-modal', '510px');
$('#ajax-modal').css('height','500px');
showModal('ajax-modal', '503px');
$('#ajax-modal').css('height','569px');

View File

@ -44,12 +44,12 @@ RedmineApp::Application.routes.draw do
match 'add_jour_reply', :via => [:get,:post]
match 'destroy_jour', :via => [:get,:post]
match 'comprehensive_evaluation_jour', :via => [:get,:post]
end
member do
get 'get_not_batch_homework'
get 'get_batch_homeworks'
get 'get_homeworks'
get 'get_homework_jours'
end
member do
match 'add_homework_users', :via => [:get,:post]
match 'destory_homework_users', :via => [:get,:post]
end

View File

@ -219,50 +219,75 @@ module Redmine
#Added by Nie guanghui
#Designed for pagination.
def pagination_links_each(paginator, count=nil, options={}, &block)
options.assert_valid_keys :per_page_links
#options.assert_valid_keys :per_page_links
per_page_links = options.delete(:per_page_links)
#per_page_links = options.delete(:per_page_links)
per_page_links = options[:per_page_links]
remote = options[:remote] ? options[:remote] : false
flag = options[:flag] ? options[:flag] : false
per_page_links = false if count.nil?
page_param = paginator.page_param
html = ''
if paginator.previous_page
# \xc2\xab(utf-8) = &#171;
text = "\xc2\xab " + l(:label_previous)
html << '<li>' << yield(text, {page_param => paginator.previous_page}, :class => 'previous') << '</li>' + ' '
if flag
text = l(:label_previous)
else
text = "\xc2\xab " + l(:label_previous)
end
html << '<li>' << yield(text, {page_param => paginator.previous_page}, :class => 'previous', :remote => remote) << '</li>' + ' '
end
unless paginator.previous_page
if paginator.next_page
text = "\xc2\xab " + l(:label_previous)
html << '<li>' << yield(text, {page_param => paginator.previous_page}, :class => 'previous') << '</li>' + ' '
if flag
text = l(:label_previous)
else
text = "\xc2\xab " + l(:label_previous)
end
html << '<li>' << yield(text, {page_param => paginator.previous_page}, :class => 'previous', :remote => remote) << '</li>' + ' '
end
end
previous = nil
paginator.linked_pages.each do |page|
if previous && previous != page - 1
html << '<li>' << content_tag('span', '...', :class => 'spacer') << '</li>' + ' '
if flag
html << '<li>' << content_tag('a', '...') << '</li>' + ' '
else
html << '<li>' << content_tag('span', '...', :class => 'spacer') << '</li>' + ' '
end
end
if page == paginator.page
html << '<li>' << content_tag('span', page.to_s, :class => 'current-page') << '</li>'
if flag
html << '<li class = "wlist_select">' << page.to_s << '</li>'
else
html << '<li>' << content_tag('span', page.to_s, :class => 'current-page') << '</li>'
end
else
html << '<li>' << yield(page.to_s, {page_param => page}, :class => 'page') << '</li>'
html << '<li>' << yield(page.to_s, {page_param => page}, :class => 'page', :remote => remote) << '</li>'
end
html << ' '
previous = page
end
if paginator.next_page
# \xc2\xbb(utf-8) = &#187;
text = l(:label_next) + " \xc2\xbb"
html << '<li>' << yield(text, {page_param => paginator.next_page}, :class => 'next') << '</li>' + ' '
if flag
text = l(:label_next)
else
text = l(:label_next) + " \xc2\xbb"
end
html << '<li>' << yield(text, {page_param => paginator.next_page}, :class => 'next', :remote => remote) << '</li>' + ' '
end
unless paginator.next_page
if paginator.previous_page
# \xc2\xbb(utf-8) = &#187;
text = l(:label_front) + " \xc2\xbb"
html << "<li>" << yield(text, {page_param => paginator.next_page}, :class => 'next') << "</li>" + ' '
if flag
text = l(:label_next)
else
text = l(:label_next) + " \xc2\xbb"
end
html << "<li>" << yield(text, {page_param => paginator.next_page}, :class => 'next', :remote => remote) << "</li>" + ' '
end
end

View File

@ -1,7 +1,7 @@
/* CSS Document */
body{ font-size:12px; font-family:"微软雅黑","宋体"; line-height:1.9; background:#fff; font-style:normal;}
div,html,img,ul,li,p,body,h1,h2,h3,h4,p,a,table,tr,td,fieldset,input,span{ margin:0; padding:0;}
div,img,tr,td{ border:0;}
div,html,img,ul,li,p,body,h1,h2,h3,h4,p,a,table,tr,td,fieldset,input,span,textarea{ margin:0; padding:0;}
div,img,tr,td,textarea{ border:0;}
table,tr,td{border:0; cellspacing:0; cellpadding:0;}
ul,li{ list-style-type:none}
.cl{ clear:both; overflow:hidden; }
@ -19,6 +19,8 @@ a:hover{ text-decoration:underline;}
.tb_{ background-color: #eaeaea; height:40px; }
.tb_ ul{height:40px; }
.tb_ li{float:left;height:35px;width: 90px;cursor:pointer; font-size:14px; padding-top:5px; text-align:center; }
a.tb_all{ margin-left:235px; font-size:12px; display:block; height:23px; padding-top:4px; width:90px; color:#7a7a7a; border:1px solid #cbcbcb; background:#fff; text-align: center;}
a:hover.tb_all{ background:#eaeaea; text-decoration:none;}
/* 控制显示与隐藏css类 */
.normaltab { color:#64bdd9 ; }
@ -30,27 +32,33 @@ a:hover{ text-decoration:underline;}
.c_red{ color:#de030d;}
.f_12{ font-size:12px;}
.w_40{ width:40px; border:1px solid red;}
.dis ul{ height:75px; border-bottom:1px dashed #64bdd9;}
.dis ul li{ float:left;}
.dis ul li a{ display:block; color:#15bccf;}
.pic_head{ width:40px; padding:8px 15px 0 8px; }
.pic_head a{ text-align:center; width:40px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;}
.dis ul li a{ display:block; color:#15bccf; }
.pic_head{ width:42px; padding:8px 15px 0 8px;}
.pic_head a{ text-align:center; width:42px; overflow:hidden;text-overflow:ellipsis; white-space:nowrap;}
.pic_head img{ border:1px solid #fff;}
.pic_head img:hover{border:1px solid #15bccf;}
.dis ul li.wname a{ width:260px; font-size:14px; color:#595959; padding:20px 0 0 15px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.dis ul li.wdown a{padding-top:22px; color:#3d7ec2; margin-right:43px;}
.wscore{ padding-top:22px; color:#888888;width:96px;}
.dis ul li.wping{margin-left:16px; }
.dis ul li.wdown a{padding-top:22px; color:#3d7ec2; margin-right:35px;}
.wscore{ padding-top:22px; color:#888888; width:96px;}
.dis ul li.wping{margin-left:12px; }
.dis ul li.wping a{ margin-top:18px; margin-bottom:3px; width:43px; height:23px; background:#15bccf; color:#fff; text-align:center; padding-top:3px;}
.dis ul li.wping a:hover{ background-color:#03a1b3;}
ul.wlist{ float:right; border-bottom:none; height:30px; margin-top:20px; }
.wlist span{ border:1px solid #15bccf; padding:0 5px; margin-left:3px;}
.wlist a{ border:1px solid #15bccf; padding:0 5px; margin-left:3px;}
.wlist a:hover{ background:#15bccf; color:#fff; text-decoration:none;}
.wlist_select { background-color:#64bdd9; color:#fff; padding:0 5px; margin-left:3px; border:1px solid #64bdd9;}
.code_list{ float:right; font-size:12px; color:#484848; padding:5px 3px; border-bottom:2px solid #15bccf; width:687px; }
.code_list a{ color:#787878;}
.fr{ float:right;}
.c_grey{ color:#999; font-weight:normal;}
.dis ul li.wname02 a{ width:200px; font-size:14px; color:#595959; padding:20px 0 0 15px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.dis ul li.wmine{ margin:12px 0 0 10px;}
.dis ul li.wmine a{ color:#3d7ec2; text-align:center; width:50px; font-weight: bold;}
.msg_box{ width:693px; height:170px; border-bottom:1px dashed #CCC; padding-top:20px;}
.msg_box h4{ margin-left:15px;border-style: none;}
@ -99,6 +107,28 @@ a:hover.ping_sub{ background:#14a8b9;}
.ping_distop span a{ float:right; width:20px; height:20px; background:url(images/star.png) -24px 0 no-repeat; margin-right:3px;}
/* 创建作业 */
.Newwork{ width:918px; height:418px; border:1px solid #c3c3c3;}
.N_top{ height:35px; background:#e5e5e5; border:1px solid #fff; width:891px; padding:5px 10px 0 15px;}
.N_top h2{ color:#616161; font-size:14px; float:left;}
.N_top a{ float:right; font-size:14px; color:#15bccf; display:block; background:url(images/pic_ad.png) 0 5px no-repeat; height:20px; width:60px; padding-left:16px;}
.N_con{ color:#484747; font-weight:bold; width:720px; margin:15px auto;}
.N_con p{ margin-bottom:15px;}
.w430{ width:430px;}
.w350{ width:350px;}
.w620{ width:580px; height:160px; border:1px solid #CCC;}
.bo{height:26px; border:1px solid #CCC; }
a.tijiao{ height:28px; display:block; width:80px; color:#fff; background:#15bccf; text-align:center; padding-top:4px; float:left; margin-right:10px;}
a:hover.tijiao{ background:#0f99a9;}
/* 匿名评分弹框 */
#popbox02{width:480px;height:200px;position:absolute;z-index:100;left:50%;top:50%;margin:-215px 0 0 -300px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;}
.alert .close02{width:26px;height:26px;overflow:hidden;position:absolute;top:-10px;right:-490px;background:url(images/close.png) no-repeat;cursor:pointer;}
.ni_con { width:425px; margin:25px 30px;}
.ni_con h2{ display:block; height:40px; width:188px; margin:0 auto;}
.ni_con p{ color:#808181;}
.ni_con a:hover{ text-decoration:none;}

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB