parent
58d2306728
commit
2dc79889b9
|
@ -70,6 +70,7 @@ class HomeworkAttachController < ApplicationController
|
|||
|
||||
#获取学生匿评列表
|
||||
def get_student_batch_homework
|
||||
@is_student_batch_homework = true
|
||||
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,
|
||||
|
@ -87,12 +88,13 @@ class HomeworkAttachController < ApplicationController
|
|||
|
||||
#获取我的作业
|
||||
def get_my_homework
|
||||
@is_my_homework = true
|
||||
teachers = find_course_teachers @course
|
||||
all_homework_list = HomeworkAttach.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 homework_attaches.bid_id = #{@bid.id} AND homework_attaches.user_id = #{User.current.id}");
|
||||
WHERE homework_attaches.bid_id = #{@bid.id} AND homework_attaches.user_id = #{User.current.id}")
|
||||
#如果我没有创建过作业,就检索我是否参与了某个作业
|
||||
if all_homework_list.empty?
|
||||
all_homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*,
|
||||
|
@ -314,9 +316,14 @@ class HomeworkAttachController < ApplicationController
|
|||
def destroy
|
||||
if User.current.admin? || User.current == @homework.user
|
||||
if @homework.destroy
|
||||
#respond_to do |format|
|
||||
# format.html { redirect_to course_for_bid_url @homework.bid }
|
||||
# format.json { head :no_content }
|
||||
#end
|
||||
@homework_list = []
|
||||
@is_my_homework = true
|
||||
respond_to do |format|
|
||||
format.html { redirect_to course_for_bid_url @homework.bid }
|
||||
format.json { head :no_content }
|
||||
format.js
|
||||
end
|
||||
else
|
||||
end
|
||||
|
@ -450,7 +457,10 @@ class HomeworkAttachController < ApplicationController
|
|||
|
||||
def find_course_by_hoemwork_id
|
||||
@homework = HomeworkAttach.find(params[:id])
|
||||
@course = @homework.bid.courses[0]
|
||||
@bid = @homework.bid
|
||||
@course = @bid.courses.first
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
#获取课程的老师列表
|
||||
|
|
|
@ -28,13 +28,6 @@
|
|||
}
|
||||
</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_course_new_homework),new_homework_attach_path %>
|
||||
<strong style="color: #a9a9a9"> (每一个作业都可以是一个精美的作品)</strong>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div id='bidding_project_list'>
|
||||
<%= render :partial => 'homework_list' %>
|
||||
</div>
|
||||
|
|
|
@ -1,21 +1,44 @@
|
|||
<% is_teacher = is_course_teacher(User.current,@bid.courses.first) %>
|
||||
<div class="code_list">
|
||||
<span>
|
||||
<%= l(:label_homework_list)%>
|
||||
(<font color="#CC0000">
|
||||
<% is_my_homework ||= false %>
|
||||
<% is_student_batch_homework ||= false %>
|
||||
|
||||
<% unless is_my_homework || is_student_batch_homework %>
|
||||
<div class="code_list">
|
||||
<span>
|
||||
<%= l(:label_homework_list)%>
|
||||
(<font color="#CC0000">
|
||||
<%= homework_count%>
|
||||
</font>)
|
||||
</span><span class="fr">
|
||||
按
|
||||
<%= 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) %>
|
||||
</span>
|
||||
</div>
|
||||
</font>)
|
||||
</span><span class="fr">
|
||||
按
|
||||
<%= 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) %>
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="cl"></div>
|
||||
|
||||
<% unless homeworks.nil? %>
|
||||
<% if !is_teacher && is_my_homework && homeworks.empty? %>
|
||||
<!-- 是学生,我的作业,且作业列表为空,即我未提交作业 -->
|
||||
<ul>
|
||||
<li class="pic_head">
|
||||
<%= link_to image_tag(url_to_avatar(User.current), :width => "40", :height => "40"), user_path(User.current) %>
|
||||
<span>
|
||||
<%= link_to User.current.login, user_path(User.current), :title => User.current.login%>
|
||||
</span>
|
||||
</li>
|
||||
<li class="c_red" style="margin:25px 0 0 20px;"> 您还没交作业,请创建作业!</li>
|
||||
<li class="wping">
|
||||
<%= link_to "创建作业", new_exercise_book_path(@bid), :style => "width:80px; margin:20px 0 0 350px;" %>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
|
||||
<% homeworks.each do |homework| %>
|
||||
<ul>
|
||||
<li class="pic_head">
|
||||
|
@ -50,15 +73,48 @@
|
|||
<%= homework.s_score.nil? ? l(:label_without_score) : format("%.2f",homework.s_score) %>
|
||||
</span>
|
||||
</li>
|
||||
<li class="wping">
|
||||
<%= link_to l(:label_work_rating),homework_attach_path(homework),:remote => true %>
|
||||
<% if Time.parse(bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %>
|
||||
<span class="c_red"> 迟交!</span>
|
||||
<% end %>
|
||||
</li>
|
||||
<% if is_teacher %>
|
||||
<!-- 是老师,所有列表正常显示 -->
|
||||
<li class="wping">
|
||||
<%= link_to l(:label_work_rating),homework_attach_path(homework),:remote => true %>
|
||||
<% if Time.parse(bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %>
|
||||
<span class="c_red"> 迟交!</span>
|
||||
<% end %>
|
||||
</li>
|
||||
<% else %>
|
||||
<!-- 是学生 -->
|
||||
<% if is_my_homework %>
|
||||
<!-- 我的作品,显示为编辑和删除 -->
|
||||
<li class="wmine">
|
||||
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
|
||||
<% if homework.user == User.current || User.current.admin? %>
|
||||
<%= link_to(l(:label_bid_respond_delete), homework,
|
||||
method: :delete, :confirm => l(:text_are_you_sure), :remote => true ) %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% elsif is_student_batch_homework%>
|
||||
<!-- 学生匿评列表,正常显示 -->
|
||||
<li class="wping">
|
||||
<%= link_to l(:label_work_rating),homework_attach_path(homework),:remote => true %>
|
||||
<% if Time.parse(bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %>
|
||||
<span class="c_red"> 迟交!</span>
|
||||
<% end %>
|
||||
</li>
|
||||
<% else %>
|
||||
<!-- 学生众评列表,显示为点赞 -->
|
||||
<li class="wping">
|
||||
<a href="#" target="_blank" >点赞</a>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% end %>
|
||||
<ul class="wlist"><%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => remote, :flag => true%></ul>
|
||||
<!-- 如果是我的作业或者匿评列表界面不现实分页控件 -->
|
||||
<% unless is_my_homework || is_student_batch_homework %>
|
||||
<ul class="wlist">
|
||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => remote, :flag => true%>
|
||||
</ul>
|
||||
<% end %>
|
|
@ -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} )) %>');
|
|
@ -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");
|
|
@ -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");
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue