From 52dabc6b984c5f70ced86f5209bac77d4f4bac06 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 31 Oct 2014 17:47:39 +0800 Subject: [PATCH 1/4] =?UTF-8?q?1.=E5=8F=96=E6=B6=88=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E6=94=B9=E4=BD=9C=E4=B8=9A=E6=97=B6=E4=BA=92?= =?UTF-8?q?=E8=AF=84=E5=8A=9F=E8=83=BD=E7=9A=84=E6=B7=BB=E5=8A=A0=202.?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E9=A1=B5=E9=9D=A2=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=81=E5=8F=96=E6=B6=88=E5=88=A0=E9=99=A4=E8=80=81=E5=B8=88?= =?UTF-8?q?=E5=B8=83=E7=BD=AE=E4=BD=9C=E4=B8=9A=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/bids/_bid_homework_show.html.erb | 217 +++++++++++++-------- app/views/courses/_homework_form.html.erb | 2 +- 2 files changed, 136 insertions(+), 83 deletions(-) diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb index d452b6d53..469a9e85d 100644 --- a/app/views/bids/_bid_homework_show.html.erb +++ b/app/views/bids/_bid_homework_show.html.erb @@ -5,94 +5,147 @@ <% else %> <% bids.each do |bid|%> - -
<%= link_to(image_tag(url_to_avatar(bid.author), :class => 'avatar'), user_path(bid.author), :class => "avatar") %> - - - - - - - - - - - - - - + + + +
<%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author)) %> - <%= l(:label_user_create_project_homework) %> - <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %> - - <% if(User.current.logged? && (!Member.where('user_id = ? and course_id = ?', User.current.id, bid.courses.first.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0)) %> - <%# 提交作业按钮 %> - - <% cur_user_homework = cur_user_homework_for_bid(bid) %> - <% if cur_user_homework!= nil && cur_user_homework.count == 0 %> - <%= link_to l(:label_commit_homework),new_homework_attach_path(bid) %> - <% else %> - <%= l(:lable_has_commit_homework)%> - <% end %> - <% end %> - <% if (User.current.admin?||User.current.id==bid.author_id) %> - <%= link_to( - l(:button_edit), - {:action => 'edit', :controller=>'bids', :course_id =>@course.id, :bid_id => bid.id}, - :class => 'icon icon-edit' - ) %> - <%= link_to( - l(:button_delete), - {:action => 'homework_destroy', :controller=>'bids', :course_id => bid.id}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :class => 'icon icon-del' - ) %> - <% end %> -
- <% bidding_project = bid.biding_projects.all - temp = [] - bidding_project.each do |pro| - if pro.project && pro.project.project_status - temp << pro - end - temp - end - %> - <% if bid.homework_type == 1%> - <%= l(:label_x_homework_project, :count => bid.homeworks.count) %>(<%= link_to bid.homeworks.count, course_for_bid_path(bid.id) %>) - <% else %> - <%= l(:label_x_homework_project, :count => temp.count) %>(<%= link_to temp.count, course_for_bid_path(bid.id) %>) - <% end %> - <%= l(:label_x_responses, :count => bid.commit) %>(<%= link_to bid.commit, respond_path(bid) %>) - - <% if betweentime(bid.deadline) < 0 %> - <%= l(:label_commit_limit)%> - <% else %> - <% if betweentime(bid.deadline) < 3 %> - <%= l(:label_commit_ar) %> - <% else %> - <% end %> - - - <% end %> -
<% if bid.reward_type.nil? or bid.reward_type == 1 %> <%= l(:label_bids_reward_method) %><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %> - <%= bid.budget%> <% elsif bid.reward_type == 2 %> <%= l(:label_bids_reward_method) %><%= bid.budget%> - <% else %> - - <% end %>
- <%#= bid.description %> - <%= textilizable bid, :description %> -
+ <%= link_to(image_tag(url_to_avatar(bid.author), :class => 'avatar'), user_path(bid.author), :class => "avatar") %> + + + + + + + + + + + + + + + + <%= l(:label_create_time) %> + :  + <%=format_time bid.created_on %> + + + <%= l(:field_deadline) %> + :  + <%=bid.deadline %> + + -
+ + <%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author)) %> + + + <%= l(:label_user_create_project_homework) %> + + + <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %> + + + <% if(User.current.logged? && (!Member.where('user_id = ? and course_id = ?', User.current.id, bid.courses.first.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0)) %> + <% cur_user_homework = cur_user_homework_for_bid(bid) %> + <% if cur_user_homework!= nil && cur_user_homework.count == 0 %> + <%= link_to l(:label_commit_homework),new_homework_attach_path(bid) %> + <% else %> + + <%= l(:lable_has_commit_homework)%> + + <% end %> + <% end %> + <% if (User.current.admin?||User.current.id==bid.author_id) %> + <%= link_to( + l(:button_edit), + {:action => 'edit', :controller=>'bids', :course_id =>@course.id, :bid_id => bid.id}, + :class => 'icon icon-edit' + ) %> + <%#= link_to( + l(:button_delete), + {:action => 'homework_destroy', :controller=>'bids', :course_id => bid.id}, + :method => :post, + :data => {:confirm => l(:text_are_you_sure)}, + :class => 'icon icon-del' + ) %> + <% end %> + +
+ + <% bidding_project = bid.biding_projects.all + temp = [] + bidding_project.each do |pro| + if pro.project && pro.project.project_status + temp << pro + end + temp + end + %> + <% if bid.homework_type == 1%> + <%= l(:label_x_homework_project, :count => bid.homeworks.count) %> + ( + + <%= link_to bid.homeworks.count, course_for_bid_path(bid.id) %> + ) + <% else %> + <%= l(:label_x_homework_project, :count => temp.count) %> + ( + + <%= link_to temp.count, course_for_bid_path(bid.id) %> + ) + <% end %> + + + <%= l(:label_x_responses, :count => bid.commit) %> + ( + + <%= link_to bid.commit, respond_path(bid) %> + + ) + + + <% if betweentime(bid.deadline) < 0 %> + + <%= l(:label_commit_limit)%> + + <% else %> + <% if betweentime(bid.deadline) < 3 %> + + <%= l(:label_commit_ar) %> + + <% end %> + <% end %> + +
+ <% if bid.reward_type.nil? or bid.reward_type == 1 %> + + <%= l(:label_bids_reward_method) %> + + <%= l(:label_call_bonus) %> +   + <%= l(:label_RMB_sign) %> + <%= bid.budget%> + + + <% elsif bid.reward_type == 2 %> + + <%= l(:label_bids_reward_method) %> + + <%= bid.budget%> + + + <% end %> +
+ + <%= textilizable bid, :description %> + +
- <%= l(:label_create_time) %> :  <%=format_time bid.created_on %> <%= l(:field_deadline) %> :  <%=bid.deadline %> -
- <% end %> <% end %> -<% 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_course_new_homework),new_homework_attach_path %> -   (每一个作业都可以是一个精美的作品) -
-<% end %> -
<%= render :partial => 'homework_list' %>
diff --git a/app/views/homework_attach/_homeworks_list.html.erb b/app/views/homework_attach/_homeworks_list.html.erb index f7e2bee59..53b384e2c 100644 --- a/app/views/homework_attach/_homeworks_list.html.erb +++ b/app/views/homework_attach/_homeworks_list.html.erb @@ -1,21 +1,44 @@ <% is_teacher = is_course_teacher(User.current,@bid.courses.first) %> -
- - <%= l(:label_homework_list)%> - ( +<% is_my_homework ||= false %> +<% is_student_batch_homework ||= false %> + +<% unless is_my_homework || is_student_batch_homework %> +
+ + <%= l(:label_homework_list)%> + ( <%= homework_count%> - ) - - 按  - <%= link_to l(:label_work_rating), sort_homework_path(@bid, 'socre', @direction), {:remote => true}%> -  /  - <%= link_to l(:label_time), sort_homework_path(@bid, 'time', @direction), {:remote => true}%> -  <%= l(:label_sort) %> - -
+
) +
+ 按  + <%= link_to l(:label_work_rating), sort_homework_path(@bid, 'socre', @direction), {:remote => true}%> +  /  + <%= link_to l(:label_time), sort_homework_path(@bid, 'time', @direction), {:remote => true}%> +  <%= l(:label_sort) %> + +
+<% end %>
+ <% unless homeworks.nil? %> + <% if !is_teacher && is_my_homework && homeworks.empty? %> + + +
+ <% end %> + <% homeworks.each do |homework| %>
<% end %> <% else %> <% end %> - \ No newline at end of file + +<% unless is_my_homework || is_student_batch_homework %> + +<% end %> \ No newline at end of file diff --git a/app/views/homework_attach/destroy.js.erb b/app/views/homework_attach/destroy.js.erb new file mode 100644 index 000000000..33d132ed4 --- /dev/null +++ b/app/views/homework_attach/destroy.js.erb @@ -0,0 +1,2 @@ +$('#tbc_01').html('<%= escape_javascript(render(:partial => 'homeworks_list', + :locals => {:homeworks => @homework_list, :bid => @bid, :remote => true, :is_my_homework => @is_my_homework} )) %>'); \ No newline at end of file diff --git a/app/views/homework_attach/get_my_homework.js.erb b/app/views/homework_attach/get_my_homework.js.erb index d841d83ae..cb6288391 100644 --- a/app/views/homework_attach/get_my_homework.js.erb +++ b/app/views/homework_attach/get_my_homework.js.erb @@ -1,4 +1,4 @@ $('#tbc_01').html('<%= escape_javascript(render(:partial => 'homeworks_list', - :locals => {:homeworks => @homework_list, :homework_count => @obj_count, :bid => @bid, :remote => true} )) %>'); + :locals => {:homeworks => @homework_list, :homework_count => @obj_count, :bid => @bid, :remote => true, :is_my_homework => @is_my_homework} )) %>'); for(var i=5;i<=8;i++){$("#tb_"+i).removeClass().addClass("normaltab");} $("#tb_6").removeClass().addClass("hovertab"); \ No newline at end of file diff --git a/app/views/homework_attach/get_student_batch_homework.js.erb b/app/views/homework_attach/get_student_batch_homework.js.erb index 15be005da..158d32817 100644 --- a/app/views/homework_attach/get_student_batch_homework.js.erb +++ b/app/views/homework_attach/get_student_batch_homework.js.erb @@ -1,4 +1,4 @@ $('#tbc_01').html('<%= escape_javascript(render(:partial => 'homeworks_list', - :locals => {:homeworks => @homework_list, :homework_count => @obj_count, :bid => @bid, :remote => true} )) %>'); + :locals => {:homeworks => @homework_list, :homework_count => @obj_count, :bid => @bid, :remote => true, :is_student_batch_homework => @is_student_batch_homework} )) %>'); for(var i=5;i<=8;i++){$("#tb_"+i).removeClass().addClass("normaltab");} $("#tb_5").removeClass().addClass("hovertab"); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index c86407980..730d4514d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -701,7 +701,7 @@ RedmineApp::Application.routes.draw do match 'contest/new_contest', :to => 'bids#new_contest' #huang match 'calls/:id/show_project', :to => 'bids#show_project', :as => 'project_for_bid' match 'calls/:id/show_course', :to => 'bids#show_courseEx', :as => 'course_for_bid' # nwb added - match 'calls/:id/new_exercise_book', :to => 'homework_attach#new', :as => 'new_homework_attach' + match 'calls/:id/new_exercise_book', :to => 'homework_attach#new', :as => 'new_exercise_book' match 'calls/:id/add', :to => 'bids#add' match 'calls/:id/delete', :to => 'bids#delete' match 'calls/:id/add_homework', :to => 'bids#add_homework', :via => :post