1.未批作业改为动态页面
2.优化分页查询代码 3.修改页面css样式 4.增加查找未批作业路由以及相应的action
This commit is contained in:
parent
f39d7e374a
commit
afa1ef22d5
|
@ -506,17 +506,19 @@ class BidsController < ApplicationController
|
|||
teachers += member.user_id.to_s + ","
|
||||
end
|
||||
end
|
||||
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*,
|
||||
limit = 10
|
||||
start_item = params['page'].nil? ? 0 : (params['page'].to_i - 1) * limit
|
||||
@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
|
||||
s_score DESC,created_at ASC")
|
||||
FROM homework_attaches WHERE bid_id = #{@bid.id}
|
||||
ORDER BY s_score DESC,created_at ASC
|
||||
limit #{start_item}, #{limit}")
|
||||
|
||||
limit = 10
|
||||
feedback_count = all_homework_list.count
|
||||
@feedback_pages = Paginator.new feedback_count, limit, params['page']
|
||||
offset ||= @feedback_pages.offset
|
||||
@homework_list = all_homework_list[offset, limit]
|
||||
#feedback_count = all_homework_list.count
|
||||
#@feedback_pages = Paginator.new feedback_count, limit, params['page']
|
||||
#offset ||= @feedback_pages.offset
|
||||
#@homework_list = all_homework_list[offset, limit]
|
||||
|
||||
if params[:student_id].present?
|
||||
@temp = []
|
||||
|
|
|
@ -4,21 +4,17 @@ class HomeworkAttachController < ApplicationController
|
|||
###############################
|
||||
before_filter :can_show_course,except: []
|
||||
#判断当前角色权限时需先找到当前操作的project
|
||||
before_filter :find_course_by_bid_id, :only => [:new]
|
||||
before_filter :find_course_by_bid_id, :only => [:new,:get_not_batch_homework]
|
||||
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]
|
||||
|
||||
def find_course_by_bid_id
|
||||
@bid = Bid.find(params[:id])
|
||||
@course = @bid.courses[0]
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def find_course_by_hoemwork_id
|
||||
@homework = HomeworkAttach.find(params[:id])
|
||||
@course = @homework.bid.courses[0]
|
||||
#获取未批作业列表
|
||||
def get_not_batch_homework
|
||||
@homeworks = HomeworkAttach.all
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
#获取作业的成员
|
||||
|
@ -321,6 +317,7 @@ class HomeworkAttachController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
#验证是否显示课程
|
||||
def can_show_course
|
||||
@first_page = FirstPage.find_by_page_type('project')
|
||||
|
@ -328,5 +325,17 @@ class HomeworkAttachController < ApplicationController
|
|||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
def find_course_by_bid_id
|
||||
@bid = Bid.find(params[:id])
|
||||
@course = @bid.courses[0]
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def find_course_by_hoemwork_id
|
||||
@homework = HomeworkAttach.find(params[:id])
|
||||
@course = @homework.bid.courses[0]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<%= render_flash_messages %>
|
||||
<div id="put-bid-form" style="display: none">
|
||||
<%= form_for HomeworkAttach.new, :url => {:controller => 'bids', :action => 'add_homework'}, :update => "bidding_project_list", :complete => '$("#put-bid-form").hide();', :html => {:multipart => true, :id => 'add_homework_form'} do |f| %>
|
||||
<fieldset>
|
||||
<legend>
|
||||
<%= l(:label_attachment_plural) %>
|
||||
</legend>
|
||||
<p id="put-bid-form-partial">
|
||||
<%= render :partial => 'attachments/form' %>
|
||||
</p>
|
||||
</fieldset>
|
||||
<%= submit_tag l(:button_create), :onclick => "return true" %>
|
||||
<fieldset>
|
||||
<legend>
|
||||
<%= l(:label_attachment_plural) %>
|
||||
</legend>
|
||||
<p id="put-bid-form-partial">
|
||||
<%= render :partial => 'attachments/form' %>
|
||||
</p>
|
||||
</fieldset>
|
||||
<%= submit_tag l(:button_create), :onclick => "return true" %>
|
||||
<% end %>
|
||||
<script type="text/javascript">
|
||||
function j_submit () {
|
||||
|
@ -29,10 +29,10 @@
|
|||
</script>
|
||||
</div>
|
||||
<% if User.current.logged? && User.current.member_of_course?(@bid.courses.first) && cur_user_homework_for_bid(@bid).count == 0 && is_cur_course_student(@bid.courses.first) %>
|
||||
<div class='icon icon-add'>
|
||||
<%#= link_to l(:label_commit_homework), new_submit_homework_path, :onclick => "$('#put-bid-form').slideToggle(); this.blur(); return false;" %>
|
||||
<%= link_to l(:label_course_new_homework),new_homework_attach_path %><strong style="color: #a9a9a9"> (每一个作业都可以是一个精美的作品)</strong>
|
||||
</div>
|
||||
<div class='icon icon-add'>
|
||||
<%= link_to l(:label_course_new_homework),new_homework_attach_path %>
|
||||
<strong style="color: #a9a9a9"> (每一个作业都可以是一个精美的作品)</strong>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div id='bidding_project_list'>
|
||||
|
|
|
@ -2,14 +2,21 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>作业列表页_老师界面</title>
|
||||
<script type="text/javascript" language="javascript">
|
||||
//<!CDATA[
|
||||
function g(o){return document.getElementById(o);}
|
||||
function HoverLi(n){
|
||||
//如果有N个标签,就将i<=N;
|
||||
for(var i=1;i<=5;i++){g('tb_'+i).className='normaltab';g('tbc_0'+i).className='undis';}g('tbc_0'+n).className='dis';g('tb_'+n).className='hovertab';
|
||||
}
|
||||
//如果要做成点击后再转到请将<li>中的onmouseover 改成 onclick;
|
||||
//]]>
|
||||
|
||||
function get_not_batch_homework() {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '<%= %>',
|
||||
data: 'text',
|
||||
success: function (data) {
|
||||
alert("1111")
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<%= stylesheet_link_tag 'css', :media => 'all' %>
|
||||
</head>
|
||||
|
@ -18,116 +25,19 @@
|
|||
<div id="content">
|
||||
<div id="tb_" class="tb_">
|
||||
<ul>
|
||||
<li id="tb_1" class="hovertab" onmouseover="x:HoverLi(1);">未批作业</li>
|
||||
<li id="tb_2" class="normaltab" onmouseover="i:HoverLi(2);">已改作业</li>
|
||||
<li id="tb_3" class="normaltab" onmouseover="a:HoverLi(3);">全部作业</li>
|
||||
<li id="tb_4" class="normaltab" onmouseover="o:HoverLi(4);"><a href="#">作业下载</a></li>
|
||||
<li id="tb_5" class="normaltab" onmouseover="g:HoverLi(5);">留言(<span class="c_red f_12">23</span>)</li>
|
||||
<li id="tb_1" class="hovertab" onclick="a:HoverLi(1);">
|
||||
<%= link_to "未批作业", get_not_batch_homework_homework_attach_path(@bid), {:remote => true}%>
|
||||
</li>
|
||||
<li id="tb_2" class="normaltab" onclick="a:HoverLi(2);">已改作业</li>
|
||||
<li id="tb_3" class="normaltab" onclick="a:HoverLi(3);">全部作业</li>
|
||||
<li id="tb_4" class="normaltab" onclick="o:HoverLi(4);"><a href="#">作业下载</a></li>
|
||||
<li id="tb_5" class="normaltab" onclick="g:HoverLi(5);">留言(<span class="c_red f_12">23</span>)</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="ctt">
|
||||
<div class="dis" id="tbc_01">
|
||||
<div class="code_list"><span>作品列表(<font color="#CC0000">20</font>)</span><span class="fr">按 <a href="#">评分</a> / <a href="#">时间</a> 排序</span></div>
|
||||
<div class="cl"></div>
|
||||
<ul>
|
||||
<li class="pic_head"><a href="#" target="_blank"><img src="images/225905790.jpg" width="40" height="40" /><span>gugu01</span></a></li>
|
||||
<li class="wname"><a href="#" target="_blank">科大校园助手最终提交文档及源码科大校园助手最终提交文档及源码</a></li>
|
||||
<li class="wdown"><a href="#" target="_blank">(5个附件)</a></li>
|
||||
<li class="wscore">教师评分:<span class="c_red">4.8</span> </li>
|
||||
<li class="wscore">学生评分:<span class="c_red">未评分</span></li>
|
||||
<li class="wping"><a href="#" target="_blank">评分</a></li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<ul>
|
||||
<li class="pic_head"><a href="#" target="_blank"><img src="images/225905790.jpg" width="40" height="40" /><span>gugu01</span></a></li>
|
||||
<li class="wname"><a href="#" target="_blank">科大校园助手最终提交文档及源码科大校园助手最终提交文档及源码</a></li>
|
||||
<li class="wdown"><a href="#" target="_blank">(5个附件)</a></li>
|
||||
<li class="wscore">教师评分:<span class="c_red">4.8</span> </li>
|
||||
<li class="wscore">学生评分:<span class="c_red">未评分</span></li>
|
||||
<li class="wping"><a href="#" target="_blank">评分</a><span class="c_red"> 迟交!</span></li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<ul>
|
||||
<li class="pic_head"><a href="#" target="_blank"><img src="images/225905790.jpg" width="40" height="40" /><span>gugu01</span></a></li>
|
||||
<li class="wname"><a href="#" target="_blank">科大校园助手最终提交文档及源码科大校园助手最终提交文档及源码</a></li>
|
||||
<li class="wdown"><a href="#" target="_blank">(5个附件)</a></li>
|
||||
<li class="wscore">教师评分:<span class="c_red">4.8</span> </li>
|
||||
<li class="wscore">学生评分:<span class="c_red">未评分</span></li>
|
||||
<li class="wping"><a href="#" target="_blank">评分</a></li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<ul>
|
||||
<li class="pic_head"><a href="#" target="_blank"><img src="images/225905790.jpg" width="40" height="40" /><span>gugu01</span></a></li>
|
||||
<li class="wname"><a href="#" target="_blank">科大校园助手最终提交文档及源码科大校园助手最终提交文档及源码</a></li>
|
||||
<li class="wdown"><a href="#" target="_blank">(5个附件)</a></li>
|
||||
<li class="wscore">教师评分:<span class="c_red">4.8</span> </li>
|
||||
<li class="wscore">学生评分:<span class="c_red">未评分</span></li>
|
||||
<li class="wping"><a href="#" target="_blank">评分</a><span class="c_red"> 迟交!</span></li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<ul>
|
||||
<li class="pic_head"><a href="#" target="_blank"><img src="images/225905790.jpg" width="40" height="40" /><span>gugu01</span></a></li>
|
||||
<li class="wname"><a href="#" target="_blank">科大校园助手最终提交文档及源码科大校园助手最终提交文档及源码</a></li>
|
||||
<li class="wdown"><a href="#" target="_blank">(5个附件)</a></li>
|
||||
<li class="wscore">教师评分:<span class="c_red">4.8</span> </li>
|
||||
<li class="wscore">学生评分:<span class="c_red">未评分</span></li>
|
||||
<li class="wping"><a href="#" target="_blank">评分</a></li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<ul>
|
||||
<li class="pic_head"><a href="#" target="_blank"><img src="images/225905790.jpg" width="40" height="40" /><span>gugu01</span></a></li>
|
||||
<li class="wname"><a href="#" target="_blank">科大校园助手最终提交文档及源码科大校园助手最终提交文档及源码</a></li>
|
||||
<li class="wdown"><a href="#" target="_blank">(5个附件)</a></li>
|
||||
<li class="wscore">教师评分:<span class="c_red">4.8</span> </li>
|
||||
<li class="wscore">学生评分:<span class="c_red">未评分</span></li>
|
||||
<li class="wping"><a href="#" target="_blank">评分</a><span class="c_red"> 迟交!</span></li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<ul>
|
||||
<li class="pic_head"><a href="#" target="_blank"><img src="images/225905790.jpg" width="40" height="40" /><span>gugu01</span></a></li>
|
||||
<li class="wname"><a href="#" target="_blank">科大校园助手最终提交文档及源码科大校园助手最终提交文档及源码</a></li>
|
||||
<li class="wdown"><a href="#" target="_blank">(5个附件)</a></li>
|
||||
<li class="wscore">教师评分:<span class="c_red">4.8</span> </li>
|
||||
<li class="wscore">学生评分:<span class="c_red">未评分</span></li>
|
||||
<li class="wping"><a href="#" target="_blank">评分</a></li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<ul>
|
||||
<li class="pic_head"><a href="#" target="_blank"><img src="images/225905790.jpg" width="40" height="40" /><span>gugu01</span></a></li>
|
||||
<li class="wname"><a href="#" target="_blank">科大校园助手最终提交文档及源码科大校园助手最终提交文档及源码</a></li>
|
||||
<li class="wdown"><a href="#" target="_blank">(5个附件)</a></li>
|
||||
<li class="wscore">教师评分:<span class="c_red">4.8</span> </li>
|
||||
<li class="wscore">学生评分:<span class="c_red">未评分</span></li>
|
||||
<li class="wping"><a href="#" target="_blank">评分</a><span class="c_red"> 迟交!</span></li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<ul>
|
||||
<li class="pic_head"><a href="#" target="_blank"><img src="images/225905790.jpg" width="40" height="40" /><span>gugu01</span></a></li>
|
||||
<li class="wname"><a href="#" target="_blank">科大校园助手最终提交文档及源码科大校园助手最终提交文档及源码</a></li>
|
||||
<li class="wdown"><a href="#" target="_blank">(5个附件)</a></li>
|
||||
<li class="wscore">教师评分:<span class="c_red">4.8</span> </li>
|
||||
<li class="wscore">学生评分:<span class="c_red">未评分</span></li>
|
||||
<li class="wping"><a href="#" target="_blank">评分</a></li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<ul>
|
||||
<li class="pic_head"><a href="#" target="_blank"><img src="images/225905790.jpg" width="40" height="40" /><span>gugu01</span></a></li>
|
||||
<li class="wname"><a href="#" target="_blank">科大校园助手最终提交文档及源码科大校园助手最终提交文档及源码</a></li>
|
||||
<li class="wdown"><a href="#" target="_blank">(5个附件)</a></li>
|
||||
<li class="wscore">教师评分:<span class="c_red">4.8</span> </li>
|
||||
<li class="wscore">学生评分:<span class="c_red">未评分</span></li>
|
||||
<li class="wping"><a href="#" target="_blank">评分</a><span class="c_red"> 迟交!</span></li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<ul class="wlist">
|
||||
<li><a href="#">上一页</a></li>
|
||||
<li><a href="#">1</a></li>
|
||||
<li><a href="#">2</a></li>
|
||||
<li><a href="#">...</a></li>
|
||||
<li><a href="#">下一页</a></li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<%= render :partial => 'homework_attach/not_batch_homwork', :locals => {:homeworks => homework}%>
|
||||
</div><!---未批作业结束-->
|
||||
<div class="undis" id="tbc_02">
|
||||
<div class="code_list"><span>作品列表(<font color="#CC0000">2</font>)</span><span class="fr">按 <a href="#">评分</a> / <a href="#">时间</a> 排序</span></div>
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
<% is_teacher = is_course_teacher(User.current,@bid.courses.first) %>
|
||||
<div class="code_list">
|
||||
<span>
|
||||
<%= l(:label_homework_list)%>
|
||||
(<font color="#CC0000">
|
||||
<%= homeworks.count unless homeworks.nil?%>
|
||||
</font>)
|
||||
</span><span class="fr">
|
||||
按
|
||||
<a href="#">
|
||||
<%= l(:label_work_rating)%>
|
||||
</a>
|
||||
/
|
||||
<a href="#">
|
||||
<%= l(:label_time) %>
|
||||
</a>
|
||||
<%= l(:label_sort) %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="cl"></div>
|
||||
<% unless homeworks.nil? %>
|
||||
<% homeworks.each do |homework| %>
|
||||
<ul>
|
||||
<li class="pic_head">
|
||||
<a href="#" target="_blank">
|
||||
<%= image_tag(url_to_avatar(homework.user), :width => "40", :height => "40")%>
|
||||
<span>
|
||||
<% user_name = is_teacher ? (homework.user.lastname + homework.user.firstname) : homework.user.login %>
|
||||
<%= link_to user_name, user_path(homework.user), :title => user_name %>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="wname">
|
||||
<% if homework.name == nil || homework.name == "" %>
|
||||
<% homework_filename = homework.user.name + "提交的作业" %>
|
||||
<% else %>
|
||||
<% homework_filename = homework.name %>
|
||||
<% end %>
|
||||
<%= link_to homework_filename , homework_attach_path(homework), :title => homework_filename%>
|
||||
</li>
|
||||
<li class="wdown">
|
||||
<%= link_to "#{homework.attachments.count.to_s}个附件", zipdown_download_user_homework_path(:homework => homework)%>
|
||||
</li>
|
||||
<li class="wscore">
|
||||
<%= l(:label_teacher_score)%>:
|
||||
<span class="c_red">
|
||||
<%= homework.t_score.nil? ? l(:label_without_score) : format("%.2f",homework.t_score)%>
|
||||
</span>
|
||||
|
||||
</li>
|
||||
<li class="wscore">
|
||||
<%= l(:label_student_score)%>:
|
||||
<span class="c_red">
|
||||
<%= homework.s_score.nil? ? l(:label_without_score) : format("%.2f",homework.s_score) %>
|
||||
</span>
|
||||
</li>
|
||||
<li class="wping">
|
||||
<a href="#" target="_blank">
|
||||
<%= l(:label_work_rating)%>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% end %>
|
|
@ -2171,3 +2171,8 @@ zh:
|
|||
label_contest_news_title_condition: 竞赛标题超过255个汉字
|
||||
label_subject_empty: 主题不能为空
|
||||
label_course_organizers: 开设单位
|
||||
label_teacher_score: 教师评分
|
||||
label_student_score: 学生评分
|
||||
label_without_score: 未评分
|
||||
label_homework_list: 作品列表
|
||||
label_time: 时间
|
||||
|
|
|
@ -46,6 +46,7 @@ RedmineApp::Application.routes.draw do
|
|||
match 'comprehensive_evaluation_jour', :via => [:get,:post]
|
||||
end
|
||||
member do
|
||||
get 'get_not_batch_homework'
|
||||
match 'add_homework_users', :via => [:get,:post]
|
||||
match 'destory_homework_users', :via => [:get,:post]
|
||||
end
|
||||
|
|
|
@ -35,11 +35,12 @@ a:hover{ text-decoration:underline;}
|
|||
.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;}
|
||||
.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:33px;}
|
||||
.wscore{ padding-top:22px; color:#888888;}
|
||||
.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.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;}
|
||||
|
|
Loading…
Reference in New Issue