Merge branch 'Homework' of http://repository.trustie.net/xianbo/trustie2 into Homework
Conflicts: app/views/bids/_bid_homework_show.html.erb
This commit is contained in:
commit
5cbbb98536
|
@ -491,24 +491,31 @@ class BidsController < ApplicationController
|
||||||
if @bid.homework_type
|
if @bid.homework_type
|
||||||
@homework = HomeworkAttach.new
|
@homework = HomeworkAttach.new
|
||||||
@is_teacher = is_course_teacher(User.current,@bid.courses.first)
|
@is_teacher = is_course_teacher(User.current,@bid.courses.first)
|
||||||
#if @is_teacher
|
teachers = "("
|
||||||
teachers = "("
|
teacher_members = searchTeacherAndAssistant(@bid.courses.first)
|
||||||
teacher_members = searchTeacherAndAssistant(@bid.courses.first)
|
teacher_members.each do |member|
|
||||||
teacher_members.each do |member|
|
if member == teacher_members.last
|
||||||
if member == teacher_members.last
|
teachers += member.user_id.to_s + ")"
|
||||||
teachers += member.user_id.to_s + ")"
|
else
|
||||||
else
|
teachers += member.user_id.to_s + ","
|
||||||
teachers += member.user_id.to_s + ","
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
if @is_teacher
|
||||||
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*,
|
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 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
|
(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) AS table1
|
FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY s_score DESC,created_at ASC) AS table1
|
||||||
WHERE table1.t_score IS NULL")
|
WHERE table1.t_score IS NULL")
|
||||||
#else
|
else
|
||||||
# all_homework_list = HomeworkAttach.all
|
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM(SELECT homework_attaches.*,
|
||||||
#end
|
(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,
|
||||||
|
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = 3123) AS m_score
|
||||||
|
FROM homework_attaches
|
||||||
|
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
|
||||||
|
WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id}) AS table1
|
||||||
|
WHERE table1.m_score IS NULL")
|
||||||
|
end
|
||||||
|
|
||||||
@homework_list = paginateHelper all_homework_list,10
|
@homework_list = paginateHelper all_homework_list,10
|
||||||
@jours_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count
|
@jours_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count
|
||||||
|
|
|
@ -7,7 +7,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
before_filter :can_show_course,except: []
|
before_filter :can_show_course,except: []
|
||||||
#判断当前角色权限时需先找到当前操作的project
|
#判断当前角色权限时需先找到当前操作的project
|
||||||
before_filter :find_course_by_bid_id, :only => [:new]
|
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_bid_and_course,:only => [:get_not_batch_homework,:get_batch_homeworks,:get_homeworks,:get_homework_jours, :get_student_batch_homework, :get_my_homework]
|
||||||
before_filter :find_course_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users]
|
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]
|
#勿删 before_filter :authorize, :only => [:new,:edit,:update,:destroy]
|
||||||
|
@ -68,6 +68,48 @@ class HomeworkAttachController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#获取学生匿评列表
|
||||||
|
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,
|
||||||
|
(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,
|
||||||
|
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = 3123) AS m_score
|
||||||
|
FROM homework_attaches
|
||||||
|
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
|
||||||
|
WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id}) AS table1
|
||||||
|
WHERE table1.m_score IS NULL")
|
||||||
|
@homework_list = paginateHelper all_homework_list,10
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#获取我的作业
|
||||||
|
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}")
|
||||||
|
#如果我没有创建过作业,就检索我是否参与了某个作业
|
||||||
|
if all_homework_list.empty?
|
||||||
|
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
|
||||||
|
INNER JOIN homework_users ON homework_users.homework_attach_id = homework_attaches.id
|
||||||
|
WHERE homework_attaches.bid_id = #{@bid.id} AND homework_users.user_id = #{User.current.id}")
|
||||||
|
end
|
||||||
|
@homework_list = paginateHelper all_homework_list,10
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
#获取作业的留言列表
|
#获取作业的留言列表
|
||||||
def get_homework_jours
|
def get_homework_jours
|
||||||
#@user = @bid.author
|
#@user = @bid.author
|
||||||
|
@ -270,9 +312,14 @@ class HomeworkAttachController < ApplicationController
|
||||||
def destroy
|
def destroy
|
||||||
if User.current.admin? || User.current == @homework.user
|
if User.current.admin? || User.current == @homework.user
|
||||||
if @homework.destroy
|
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|
|
respond_to do |format|
|
||||||
format.html { redirect_to course_for_bid_url @homework.bid }
|
format.js
|
||||||
format.json { head :no_content }
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
end
|
end
|
||||||
|
@ -406,7 +453,10 @@ class HomeworkAttachController < ApplicationController
|
||||||
|
|
||||||
def find_course_by_hoemwork_id
|
def find_course_by_hoemwork_id
|
||||||
@homework = HomeworkAttach.find(params[:id])
|
@homework = HomeworkAttach.find(params[:id])
|
||||||
@course = @homework.bid.courses[0]
|
@bid = @homework.bid
|
||||||
|
@course = @bid.courses.first
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
#获取课程的老师列表
|
#获取课程的老师列表
|
||||||
|
|
|
@ -28,6 +28,7 @@ class Bid < ActiveRecord::Base
|
||||||
has_many :homework_for_courses, :dependent => :destroy
|
has_many :homework_for_courses, :dependent => :destroy
|
||||||
has_many :courses, :through => :homework_for_courses, :source => :course
|
has_many :courses, :through => :homework_for_courses, :source => :course
|
||||||
has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy
|
has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy
|
||||||
|
has_many :homework_evaluations, :through => :homeworks
|
||||||
has_many :join_in_contests, :dependent => :destroy
|
has_many :join_in_contests, :dependent => :destroy
|
||||||
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
|
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
|
||||||
# has_many :fork_homework, :class_name => 'Bid', :conditions => "#{Bid.table_name}.parent_id = #{id}"
|
# has_many :fork_homework, :class_name => 'Bid', :conditions => "#{Bid.table_name}.parent_id = #{id}"
|
||||||
|
|
|
@ -10,6 +10,7 @@ class HomeworkAttach < ActiveRecord::Base
|
||||||
has_many :users, :through => :homework_users
|
has_many :users, :through => :homework_users
|
||||||
seems_rateable :allow_update => true, :dimensions => :quality
|
seems_rateable :allow_update => true, :dimensions => :quality
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
|
has_many :homework_evaluations, :dependent => :destroy
|
||||||
|
|
||||||
safe_attributes "bid_id",
|
safe_attributes "bid_id",
|
||||||
"user_id"
|
"user_id"
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
class HomeworkEvaluation < ActiveRecord::Base
|
||||||
|
attr_accessible :homework_attach_id, :user_id
|
||||||
|
|
||||||
|
belongs_to :homework_attach
|
||||||
|
belongs_to :user
|
||||||
|
end
|
|
@ -75,6 +75,7 @@ class User < Principal
|
||||||
|
|
||||||
has_many :homework_users
|
has_many :homework_users
|
||||||
has_many :homework_attaches, :through => :homework_users
|
has_many :homework_attaches, :through => :homework_users
|
||||||
|
has_many :homework_evaluations
|
||||||
|
|
||||||
has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)},
|
has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)},
|
||||||
:after_remove => Proc.new {|user, group| group.user_removed(user)}
|
:after_remove => Proc.new {|user, group| group.user_removed(user)}
|
||||||
|
|
|
@ -5,94 +5,147 @@
|
||||||
<% else %>
|
<% else %>
|
||||||
<% bids.each do |bid|%>
|
<% bids.each do |bid|%>
|
||||||
<table class="content-text-list">
|
<table class="content-text-list">
|
||||||
<tr><td colspan="2" valign="top" width="50" ><%= link_to(image_tag(url_to_avatar(bid.author), :class => 'avatar'), user_path(bid.author), :class => "avatar") %></td>
|
<tr>
|
||||||
<td>
|
<td colspan="2" valign="top" width="50" >
|
||||||
<table width="580px" border="0">
|
<%= link_to(image_tag(url_to_avatar(bid.author), :class => 'avatar'), user_path(bid.author), :class => "avatar") %>
|
||||||
<tr>
|
</td>
|
||||||
<td colspan="2" valign="top"><strong><%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author)) %></strong>
|
<td>
|
||||||
<span class="font_lighter"><%= l(:label_user_create_project_homework) %></span>
|
<table width="580px" border="0">
|
||||||
<span><%= link_to(bid.name, course_for_bid_path(bid), :class => 'bid_path') %></span>
|
<tr>
|
||||||
<span style="float: right">
|
<td colspan="2" valign="top">
|
||||||
<% 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)) %>
|
<strong>
|
||||||
<%# 提交作业按钮 %>
|
<%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author)) %>
|
||||||
<!--<%#= link_to l(:label_commit_homework), '#OpenWindow', rel: 'leanModal', onclick: "showSubH(#{bid.id}, '#{bid.name}');" if User.current.member_of?(@course) %>-->
|
</strong>
|
||||||
<% cur_user_homework = cur_user_homework_for_bid(bid) %>
|
<span class="font_lighter">
|
||||||
<% if cur_user_homework!= nil && cur_user_homework.count == 0 %>
|
<%= l(:label_user_create_project_homework) %>
|
||||||
<%= link_to l(:label_commit_homework),new_homework_attach_path(bid) %>
|
</span>
|
||||||
<% else %>
|
<span>
|
||||||
<span style="color: green; float: right"><%= l(:lable_has_commit_homework)%></span>
|
<%= link_to(bid.name, course_for_bid_path(bid), :class => 'bid_path') %>
|
||||||
<% end %>
|
</span>
|
||||||
<% end %>
|
<span style="float: right">
|
||||||
<% if (User.current.admin?||User.current.id==bid.author_id) %>
|
<% 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)) %>
|
||||||
<%= link_to(
|
<% cur_user_homework = cur_user_homework_for_bid(bid) %>
|
||||||
l(:button_edit),
|
<% if cur_user_homework!= nil && cur_user_homework.count == 0 %>
|
||||||
{:action => 'edit', :controller=>'bids', :course_id =>@course.id, :bid_id => bid.id},
|
<%= link_to l(:label_commit_homework),new_homework_attach_path(bid) %>
|
||||||
:class => 'icon icon-edit'
|
<% else %>
|
||||||
) %>
|
<span style="color: green; float: right">
|
||||||
<%= link_to(
|
<%= l(:lable_has_commit_homework)%>
|
||||||
l(:button_delete),
|
</span>
|
||||||
{:action => 'homework_destroy', :controller=>'bids', :course_id => bid.id},
|
<% end %>
|
||||||
:method => :post,
|
<% end %>
|
||||||
:data => {:confirm => l(:text_are_you_sure)},
|
<% if (User.current.admin?||User.current.id==bid.author_id) %>
|
||||||
:class => 'icon icon-del'
|
<%= link_to(
|
||||||
) %></span>
|
l(:button_edit),
|
||||||
<% end %>
|
{:action => 'edit', :controller=>'bids', :course_id =>@course.id, :bid_id => bid.id},
|
||||||
</td>
|
:class => 'icon icon-edit'
|
||||||
</tr>
|
) %>
|
||||||
<tr>
|
<%#= link_to(
|
||||||
<td colspan="2"><span class="font_lighter">
|
l(:button_delete),
|
||||||
<% bidding_project = bid.biding_projects.all
|
{:action => 'homework_destroy', :controller=>'bids', :course_id => bid.id},
|
||||||
temp = []
|
:method => :post,
|
||||||
bidding_project.each do |pro|
|
:data => {:confirm => l(:text_are_you_sure)},
|
||||||
if pro.project && pro.project.project_status
|
:class => 'icon icon-del'
|
||||||
temp << pro
|
) %>
|
||||||
end
|
<% end %>
|
||||||
temp
|
</span>
|
||||||
end
|
</td>
|
||||||
%>
|
</tr>
|
||||||
<% if bid.homework_type == 1%>
|
<tr>
|
||||||
<%= l(:label_x_homework_project, :count => bid.homeworks.count) %>(<strong><%= link_to bid.homeworks.count, course_for_bid_path(bid.id) %></strong>)
|
<td colspan="2">
|
||||||
<% else %>
|
<span class="font_lighter">
|
||||||
<%= l(:label_x_homework_project, :count => temp.count) %>(<strong><%= link_to temp.count, course_for_bid_path(bid.id) %></strong>)
|
<% bidding_project = bid.biding_projects.all
|
||||||
<% end %></span>
|
temp = []
|
||||||
<span class="font_lighter"><%= l(:label_x_responses, :count => bid.commit) %>(<strong><%= bid.commit %></strong>)</span>
|
bidding_project.each do |pro|
|
||||||
<span style="float: right">
|
if pro.project && pro.project.project_status
|
||||||
<% if betweentime(bid.deadline) < 0 %>
|
temp << pro
|
||||||
<span style="color: red; float: right"><%= l(:label_commit_limit)%></span>
|
end
|
||||||
<% else %>
|
temp
|
||||||
<% if betweentime(bid.deadline) < 3 %>
|
end
|
||||||
<span style="color: red"><%= l(:label_commit_ar) %></span>
|
%>
|
||||||
<% else %>
|
<% if bid.homework_type == 1%>
|
||||||
<% end %>
|
<%= l(:label_x_homework_project, :count => bid.homeworks.count) %>
|
||||||
|
(
|
||||||
|
<strong>
|
||||||
<% end %> </span>
|
<%= link_to bid.homeworks.count, course_for_bid_path(bid.id) %>
|
||||||
</td>
|
</strong>)
|
||||||
</tr>
|
<% else %>
|
||||||
<tr>
|
<%= l(:label_x_homework_project, :count => temp.count) %>
|
||||||
<td colspan="2"> <% if bid.reward_type.nil? or bid.reward_type == 1 %> <strong><%= l(:label_bids_reward_method) %><span style="color: #ed8924;font-family: 14px; font-family: '微软雅黑'"><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %>
|
(
|
||||||
<%= bid.budget%></span></strong> <% elsif bid.reward_type == 2 %> <strong><%= l(:label_bids_reward_method) %><span style="color: #15bccf;font-family: 14px; font-family:' 微软雅黑'"><%= bid.budget%></span></strong>
|
<strong>
|
||||||
<% else %>
|
<%= link_to temp.count, course_for_bid_path(bid.id) %>
|
||||||
|
</strong>)
|
||||||
<% end %> <!-- <td style="color: rgb(255, 0, 0);"><strong><%#= l(:label_price) %><%#= l(:label_RMB_sign) %><%#= bid.budget%></strong></td> --></td>
|
<% end %>
|
||||||
</tr>
|
</span>
|
||||||
<tr>
|
<span class="font_lighter">
|
||||||
<td colspan="2" width="580px" ><span class="font_description">
|
<%= l(:label_x_responses, :count => bid.commit) %>
|
||||||
<%#= bid.description %>
|
(
|
||||||
<%= textilizable bid, :description %>
|
<strong>
|
||||||
</span></td>
|
<%= bid.commit %>
|
||||||
</tr>
|
</strong>
|
||||||
<tr>
|
)
|
||||||
|
</span>
|
||||||
|
<span style="float: right">
|
||||||
|
<% if betweentime(bid.deadline) < 0 %>
|
||||||
|
<span style="color: red; float: right">
|
||||||
|
<%= l(:label_commit_limit)%>
|
||||||
|
</span>
|
||||||
|
<% else %>
|
||||||
|
<% if betweentime(bid.deadline) < 3 %>
|
||||||
|
<span style="color: red">
|
||||||
|
<%= l(:label_commit_ar) %>
|
||||||
|
</span>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<% if bid.reward_type.nil? or bid.reward_type == 1 %>
|
||||||
|
<strong>
|
||||||
|
<%= l(:label_bids_reward_method) %>
|
||||||
|
<span style="color: #ed8924;font-family: 14px; font-family: '微软雅黑'">
|
||||||
|
<%= l(:label_call_bonus) %>
|
||||||
|
|
||||||
|
<%= l(:label_RMB_sign) %>
|
||||||
|
<%= bid.budget%>
|
||||||
|
</span>
|
||||||
|
</strong>
|
||||||
|
<% elsif bid.reward_type == 2 %>
|
||||||
|
<strong>
|
||||||
|
<%= l(:label_bids_reward_method) %>
|
||||||
|
<span style="color: #15bccf;font-family: 14px; font-family:' 微软雅黑'">
|
||||||
|
<%= bid.budget%>
|
||||||
|
</span>
|
||||||
|
</strong>
|
||||||
|
<% end %> <!-- <td style="color: rgb(255, 0, 0);"><strong><%#= l(:label_price) %><%#= l(:label_RMB_sign) %><%#= bid.budget%></strong></td> -->
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" width="580px" >
|
||||||
|
<span class="font_description">
|
||||||
|
<%= textilizable bid, :description %>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
<td style="text-align: left">
|
<td style="text-align: left">
|
||||||
<span class="font_lighter">
|
<span class="font_lighter">
|
||||||
<%= l(:label_create_time) %> : <%=format_time bid.created_on %></span><span style="float: right"> <%= l(:field_deadline) %> : <%=bid.deadline %>
|
<%= l(:label_create_time) %>
|
||||||
</span></td>
|
:
|
||||||
|
<%=format_time bid.created_on %>
|
||||||
|
</span>
|
||||||
|
<span style="float: right">
|
||||||
|
<%= l(:field_deadline) %>
|
||||||
|
:
|
||||||
|
<%=bid.deadline %>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table></td>
|
</table></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
|
|
|
@ -28,13 +28,6 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</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'>
|
<div id='bidding_project_list'>
|
||||||
<%= render :partial => 'homework_list' %>
|
<%= render :partial => 'homework_list' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -28,16 +28,16 @@
|
||||||
</ul>
|
</ul>
|
||||||
<% else %>
|
<% else %>
|
||||||
<ul>
|
<ul>
|
||||||
<li id="tb_1" class="hovertab">待评作品
|
<li id="tb_5" class="hovertab">
|
||||||
|
<%= link_to "待评作品", get_student_batch_homework_homework_attach_index_path(:bid_id => @bid.id), {:remote => true}%>
|
||||||
</li>
|
</li>
|
||||||
<li id="tb_2" class="normaltab">我的作品
|
<li id="tb_6" class="normaltab">
|
||||||
|
<%= link_to "我的作品", get_my_homework_homework_attach_index_path(:bid_id => @bid.id), {:remote => true}%>
|
||||||
</li>
|
</li>
|
||||||
<li id="tb_3" class="normaltab">
|
<li id="tb_7" class="normaltab">
|
||||||
<%= link_to "所有作品", get_homeworks_homework_attach_index_path(:bid_id => @bid.id), {:remote => true}%>
|
<%= link_to "所有作品", get_homeworks_homework_attach_index_path(:bid_id => @bid.id), {:remote => true}%>
|
||||||
</li>
|
</li>
|
||||||
<li id="tb_4" class="normaltab">
|
<li id="tb_8" class="normaltab">
|
||||||
<%= link_to "留言", get_homework_jours_homework_attach_index_path(:bid_id => @bid.id), {:remote => true}%>
|
<%= link_to "留言", get_homework_jours_homework_attach_index_path(:bid_id => @bid.id), {:remote => true}%>
|
||||||
(<span id="jours_count" class="c_red f_12"><%= @jours_count %></span>)
|
(<span id="jours_count" class="c_red f_12"><%= @jours_count %></span>)
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
<span id="bid_deadline_span">
|
<span id="bid_deadline_span">
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p style="display: none">
|
||||||
<%= f.select :is_evaluation, is_evaluation_option %>
|
<%= f.select :is_evaluation, is_evaluation_option %>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -1,21 +1,44 @@
|
||||||
<% is_teacher = is_course_teacher(User.current,@bid.courses.first) %>
|
<% is_teacher = is_course_teacher(User.current,@bid.courses.first) %>
|
||||||
<div class="code_list">
|
<% is_my_homework ||= false %>
|
||||||
<span>
|
<% is_student_batch_homework ||= false %>
|
||||||
<%= l(:label_homework_list)%>
|
|
||||||
(<font color="#CC0000">
|
<% unless is_my_homework || is_student_batch_homework %>
|
||||||
|
<div class="code_list">
|
||||||
|
<span>
|
||||||
|
<%= l(:label_homework_list)%>
|
||||||
|
(<font color="#CC0000">
|
||||||
<%= homework_count%>
|
<%= homework_count%>
|
||||||
</font>)
|
</font>)
|
||||||
</span><span class="fr">
|
</span><span class="fr">
|
||||||
按
|
按
|
||||||
<%= link_to l(:label_work_rating), sort_homework_path(@bid, 'socre', @direction), {:remote => true}%>
|
<%= 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}%>
|
<%= link_to l(:label_time), sort_homework_path(@bid, 'time', @direction), {:remote => true}%>
|
||||||
<%= l(:label_sort) %>
|
<%= l(:label_sort) %>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
|
||||||
<% unless homeworks.nil? %>
|
<% 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| %>
|
<% homeworks.each do |homework| %>
|
||||||
<ul>
|
<ul>
|
||||||
<li class="pic_head">
|
<li class="pic_head">
|
||||||
|
@ -50,15 +73,48 @@
|
||||||
<%= homework.s_score.nil? ? l(:label_without_score) : format("%.2f",homework.s_score) %>
|
<%= homework.s_score.nil? ? l(:label_without_score) : format("%.2f",homework.s_score) %>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="wping">
|
<% if is_teacher %>
|
||||||
<%= 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") %>
|
<li class="wping">
|
||||||
<span class="c_red"> 迟交!</span>
|
<%= link_to l(:label_work_rating),homework_attach_path(homework),:remote => true %>
|
||||||
<% end %>
|
<% if Time.parse(bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %>
|
||||||
</li>
|
<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>
|
</ul>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% end %>
|
<% 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,3 +1,6 @@
|
||||||
$('#tbc_01').html('<%= escape_javascript(render(:partial => 'homework_jours',:locals => { :bid => @bid, :journals => @jour, :state => false} )) %>');
|
$('#tbc_01').html('<%= escape_javascript(render(:partial => 'homework_jours',:locals => { :bid => @bid, :journals => @jour, :state => false} )) %>');
|
||||||
for(var i=1;i<=4;i++){$("#tb_"+i).removeClass().addClass("normaltab");}
|
for(var i=1;i<=4;i++){$("#tb_"+i).removeClass().addClass("normaltab");}
|
||||||
$("#tb_4").removeClass().addClass("hovertab");
|
$("#tb_4").removeClass().addClass("hovertab");
|
||||||
|
|
||||||
|
for(var i=5;i<=8;i++){$("#tb_"+i).removeClass().addClass("normaltab");}
|
||||||
|
$("#tb_8").removeClass().addClass("hovertab");
|
||||||
|
|
|
@ -3,3 +3,6 @@ $('#tbc_01').html('<%= escape_javascript(render(:partial => 'homeworks_list',
|
||||||
for(var i=1;i<=4;i++){$("#tb_"+i).removeClass().addClass("normaltab");}
|
for(var i=1;i<=4;i++){$("#tb_"+i).removeClass().addClass("normaltab");}
|
||||||
$("#tb_3").removeClass().addClass("hovertab");
|
$("#tb_3").removeClass().addClass("hovertab");
|
||||||
|
|
||||||
|
for(var i=5;i<=8;i++){$("#tb_"+i).removeClass().addClass("normaltab");}
|
||||||
|
$("#tb_7").removeClass().addClass("hovertab");
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
$('#tbc_01').html('<%= escape_javascript(render(:partial => 'homeworks_list',
|
||||||
|
: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',
|
$('#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} )) %>');
|
||||||
for(var i=1;i<=5;i++){$("#tb_"+i).removeClass().addClass("normaltab");}
|
for(var i=1;i<=4;i++){$("#tb_"+i).removeClass().addClass("normaltab");}
|
||||||
$("#tb_1").removeClass().addClass("hovertab");
|
$("#tb_1").removeClass().addClass("hovertab");
|
|
@ -0,0 +1,4 @@
|
||||||
|
$('#tbc_01').html('<%= escape_javascript(render(:partial => 'homeworks_list',
|
||||||
|
: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");
|
|
@ -48,6 +48,8 @@ RedmineApp::Application.routes.draw do
|
||||||
get 'get_batch_homeworks'
|
get 'get_batch_homeworks'
|
||||||
get 'get_homeworks'
|
get 'get_homeworks'
|
||||||
get 'get_homework_jours'
|
get 'get_homework_jours'
|
||||||
|
get 'get_student_batch_homework'
|
||||||
|
get 'get_my_homework'
|
||||||
end
|
end
|
||||||
member do
|
member do
|
||||||
match 'add_homework_users', :via => [:get,:post]
|
match 'add_homework_users', :via => [:get,:post]
|
||||||
|
@ -699,7 +701,7 @@ RedmineApp::Application.routes.draw do
|
||||||
match 'contest/new_contest', :to => 'bids#new_contest' #huang
|
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_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/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/add', :to => 'bids#add'
|
||||||
match 'calls/:id/delete', :to => 'bids#delete'
|
match 'calls/:id/delete', :to => 'bids#delete'
|
||||||
match 'calls/:id/add_homework', :to => 'bids#add_homework', :via => :post
|
match 'calls/:id/add_homework', :to => 'bids#add_homework', :via => :post
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
class CreateHomeworkEvaluations < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :homework_evaluations do |t|
|
||||||
|
t.string :user_id
|
||||||
|
t.string :homework_attach_id
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20141029065917) do
|
ActiveRecord::Schema.define(:version => 20141031111632) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -478,6 +478,13 @@ ActiveRecord::Schema.define(:version => 20141029065917) do
|
||||||
t.integer "project_id", :default => 0
|
t.integer "project_id", :default => 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "homework_evaluations", :force => true do |t|
|
||||||
|
t.string "user_id"
|
||||||
|
t.string "homework_attach_id"
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "homework_for_courses", :force => true do |t|
|
create_table "homework_for_courses", :force => true do |t|
|
||||||
t.integer "course_id"
|
t.integer "course_id"
|
||||||
t.integer "bid_id"
|
t.integer "bid_id"
|
||||||
|
|
Loading…
Reference in New Issue