diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 1184cb275..771e77136 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -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") - - 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] + FROM homework_attaches WHERE bid_id = #{@bid.id} + ORDER BY s_score DESC,created_at ASC + limit #{start_item}, #{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 = [] diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 041c63a8e..4a9e3bb1f 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -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 diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb index 5071444f4..a118dbc43 100644 --- a/app/views/bids/_homework.html.erb +++ b/app/views/bids/_homework.html.erb @@ -1,15 +1,15 @@ <%= render_flash_messages %> <% 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) %> -
- <%#= 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 %>  (每一个作业都可以是一个精美的作品) -
+
+ <%= link_to l(:label_course_new_homework),new_homework_attach_path %> +   (每一个作业都可以是一个精美的作品) +
<% end %>
diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 8a8317d07..947dd455f 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -2,14 +2,21 @@ 作业列表页_老师界面 <%= stylesheet_link_tag 'css', :media => 'all' %> @@ -18,116 +25,19 @@
    -
  • 未批作业
  • -
  • 已改作业
  • -
  • 全部作业
  • -
  • 作业下载
  • -
  • 留言(23)
  • +
  • + <%= link_to "未批作业", get_not_batch_homework_homework_attach_path(@bid), {:remote => true}%> +
  • +
  • 已改作业
  • +
  • 全部作业
  • +
  • 作业下载
  • +
  • 留言(23)
-
作品列表(20)按 评分 / 时间 排序
-
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
+ <%= render :partial => 'homework_attach/not_batch_homwork', :locals => {:homeworks => homework}%>
作品列表(2)按 评分 / 时间 排序
diff --git a/app/views/homework_attach/_not_batch_homwork.html.erb b/app/views/homework_attach/_not_batch_homwork.html.erb new file mode 100644 index 000000000..ab981b83f --- /dev/null +++ b/app/views/homework_attach/_not_batch_homwork.html.erb @@ -0,0 +1,67 @@ +<% is_teacher = is_course_teacher(User.current,@bid.courses.first) %> +
+ + <%= l(:label_homework_list)%> + ( + <%= homeworks.count unless homeworks.nil?%> + ) + + 按  + + <%= l(:label_work_rating)%> + +  /  + + <%= l(:label_time) %> + +  <%= l(:label_sort) %> + +
+ +
+<% unless homeworks.nil? %> + <% homeworks.each do |homework| %> + +
+ <% end %> +<% else %> +<% end %> \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 02a79397a..68b60d31a 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -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: 时间 diff --git a/config/routes.rb b/config/routes.rb index 96cde02b3..43181d6db 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/public/stylesheets/css.css b/public/stylesheets/css.css index 9d62bfd4d..879871350 100644 --- a/public/stylesheets/css.css +++ b/public/stylesheets/css.css @@ -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;}