This commit is contained in:
z9hang 2014-06-13 08:37:11 +08:00
commit 621346268f
12 changed files with 124 additions and 84 deletions

View File

@ -18,6 +18,13 @@ class HomeworkAttachController < ApplicationController
@project = @homework.bid.courses[0]
end
#获取作业的成员
def get_homework_member homework
@hoemwork_users = users_for_homework(@homework)
@members = members_for_homework(@homework,@hoemwork_users,params[:q])
@members = paginateHelper @members,10
end
def index
@homeworks = HomeworkAttach.all
respond_to do |format|
@ -28,7 +35,7 @@ class HomeworkAttachController < ApplicationController
#作业添加成员(参与人员)
def add_homework_users
if User.current.admin? || User.current == @homework.user
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
#@homework = HomeworkAttach.find(params[:id])
if params[:membership]
if params[:membership][:user_ids]
@ -40,9 +47,7 @@ class HomeworkAttachController < ApplicationController
end
end
@homework.save
@hoemwork_users = users_for_homework(@homework)
@members = members_for_homework(@homework,@hoemwork_users,params[:q])
@members = paginateHelper @members,10
get_homework_member @homework
respond_to do |format|
format.js
end
@ -54,12 +59,10 @@ class HomeworkAttachController < ApplicationController
#作业删除成员(参与人员)
def destory_homework_users
#@homework = HomeworkAttach.find(params[:id])
if User.current.admin? || User.current == @homework.user
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
homework_user = @homework.homework_users.where("user_id = #{params[:user_id]}").first
homework_user.destroy
@hoemwork_users = users_for_homework(@homework)
@members = members_for_homework(@homework,@hoemwork_users,params[:q])
@members = paginateHelper @members,10
get_homework_member @homework
respond_to do |format|
format.js
end
@ -136,11 +139,7 @@ class HomeworkAttachController < ApplicationController
@homework = HomeworkAttach.find(params[:bid_id])
course = @homework.bid.courses.first
if User.current.admin? || User.current.member_of?(course)
@hoemwork_users = users_for_homework(@homework)
@members = members_for_homework(@homework,@hoemwork_users,params[:q])
#该课程的学生的集合
#@members = course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => [5, 10]})
@members = paginateHelper @members,10
get_homework_member @homework
else
raise "error"
end
@ -157,6 +156,7 @@ class HomeworkAttachController < ApplicationController
#获取可选成员列表
#homework作业
#users该作业所有成员
#q:模糊匹配的用户的昵称
def members_for_homework homework,users,q
homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id not in (:users)", {:role_id => [5, 10],:users => users}).joins(:user).where("users.login like '%#{q}%'")
end
@ -165,9 +165,7 @@ class HomeworkAttachController < ApplicationController
#@homework = HomeworkAttach.find(params[:id])
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
#@members = @homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => [5, 10]})
@hoemwork_users = users_for_homework(@homework)
@members = members_for_homework(@homework,@hoemwork_users,params[:q])
@members = paginateHelper @members,10
get_homework_member @homework
else
render_403 :message => :notice_not_authorized
end
@ -198,7 +196,7 @@ class HomeworkAttachController < ApplicationController
def destroy
#@homework = HomeworkAttach.find(params[:id])
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
if User.current.admin? || User.current == @homework
if @homework.destroy
respond_to do |format|
format.html { redirect_to project_for_bid_path @homework.bid }

View File

@ -177,4 +177,9 @@ module CoursesHelper
seem_count = homework.rates(:quality).where("rater_id = ?",User.current).count
seem_count > 0
end
#获取指定作业的所有成员
def users_for_homework homework
homework.nil? ? [] : (homework.users + [homework.user])
end
end

View File

@ -14,8 +14,8 @@ class HomeworkAttach < ActiveRecord::Base
"user_id"
acts_as_attachable
def addjours user_id,message,status = 0,is_comprehensive_evaluation = 0
jfm = self.journals_for_messages.build(:user_id => user_id,:notes =>message,:status => status,:is_comprehensive_evaluation => is_comprehensive_evaluation)
def addjours user_id,message,status = 0,is_comprehensive_evaluation = 0,reply_id = 0
jfm = self.journals_for_messages.build(:user_id => user_id,:notes =>message,:status => status,:is_comprehensive_evaluation => is_comprehensive_evaluation,:reply_id => reply_id)
jfm.save
jfm
end

View File

@ -122,8 +122,8 @@ class UserScore < ActiveRecord::Base
Rails.logger.error "[UserScore#influence] ===> #{operate} is not define."
return false
end
#rescue => e
#Rails.logger.error "[UserScore#influence] ===> Exception: #{e}."
rescue => e
Rails.logger.error "[UserScore#influence] ===> Exception: #{e}."
end
# 前略·技术得分

View File

@ -90,10 +90,12 @@
<% end %>
</td>
<td>
<% if (User.current == homework.user) || is_teacher %>
<% if (users_for_homework(homework).include?(User.current) || is_teacher) %>
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
<%= link_to(l(:label_bid_respond_delete), homework,
method: :delete, :confirm => l(:text_are_you_sure)) %>
<% if homework.user == User.current || is_teacher %>
<%= link_to(l(:label_bid_respond_delete), homework,
method: :delete, :confirm => l(:text_are_you_sure)) %>
<% end %>
<% end %>
</td>
</tr>
@ -102,4 +104,4 @@
</tr>
</table>
<div class="line_under"></div>
<% end %>
<% end %>

View File

@ -8,6 +8,22 @@
}
</script>
<div class="top-content">
<table>
<tr>
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
<td style="width: auto; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
</tr>
<tr>
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%></a></td>
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
<span><%= link_to(@homework.bid.courses.first.name.to_s, homework_project_path(@homework.bid.courses.first)) if @homework.bid.courses.first%></span> >
<%=link_to(@homework.bid.name, respond_path(@homework.bid)) %> > <span><%= link_to "修改作业",edit_homework_attach_path(@homework)%></span></p></td>
</tr>
</table>
</div>
<p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html"> <%=raw l(:label_edit_homework)%> </p>
<div class="tabs">
<ul>

View File

@ -1,3 +1,19 @@
<div class="top-content">
<table>
<tr>
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
<td style="width: auto; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
</tr>
<tr>
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%></a></td>
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
<span><%= link_to(@bid.courses.first.name.to_s, homework_project_path(@bid.courses.first)) if @bid.courses.first%></span> >
<%=link_to(@bid.name, respond_path(@bid)) %> > <span><%= link_to "创建作业", new_homework_attach_path(@bid)%></span></p></td>
</tr>
</table>
</div>
<p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html"> <%=h l(:label_new_homework)%> </p>
<div class="box">
<%= form_for('new_form', :method => :post,

View File

@ -23,16 +23,9 @@
<td style="width: 570px; padding-left:40px; word-wrap: break-word; word-break: break-all">
发布人员:<%= link_to @homework.user, user_path(@homework.user)%>
</td>
<td>
参与人员:
<% @homework.users.each do |homework_user| %>
<%= link_to homework_user, user_path(homework_user)%>
<% if @homework.users.count > 1 && homework_user != @homework.users.last %>
<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% end %>
<% end %>
<td style="width: 240px; word-wrap: break-word; word-break: break-all">
所属任务:<%= link_to(@homework.bid.name, project_for_bid_path(@homework.bid))%>
</td>
</tr>
<tr>
<td style="padding-left: 40px">
@ -44,15 +37,21 @@
<%= l(:label_cant_download) %>
<% end %>
</td>
<td style="width: 240px; word-wrap: break-word; word-break: break-all">
所属任务:<%= link_to(@homework.bid.name, project_for_bid_path(@homework.bid))%>
<td style="width: 240px; word-wrap: break-word; word-break: break-all">
参与人员:
<% @homework.users.each do |homework_user| %>
<%= link_to homework_user, user_path(homework_user)%>
<% if @homework.users.count > 1 && homework_user != @homework.users.last %>
<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% end %>
<% end %>
</td>
</tr>
<tr>
<td style="padding-left: 40px">平均评分:
<td style=" padding-left: 40px">平均评分:
<%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %>
</td>
<td>发布时间:<%=format_time @homework.created_at %></td>
<td style="width: 240px; word-wrap: break-word; word-break: break-all">发布时间:<%=format_time @homework.created_at %></td>
</tr>
</table>
</td>
@ -106,7 +105,7 @@
</div>
</div>
<%= @stars_status_map["star#{(star/20).to_s}".to_sym] %>
<br>
<br/>
<% end %>
</div>
</div>
@ -142,32 +141,37 @@
</div>
<div class="underline-contests_one"></div>
<div style="height: 50px">
<div style="font-size: 15px"><strong>作业评论:</strong></div>
<% if is_student %>
<% if @is_evaluation %>
<% if @has_evaluation %>
<div style="text-align: center;">
<%= l(:lable_has_evaluation)%>
</div>
<!-- 作业成员(发布人员和参与人员)不能对作业进行评分 -->
<% if !users_for_homework(@homework).include?(User.current) %>
<div style="height: 50px">
<div style="font-size: 15px"><strong>作业评论:</strong></div>
<% if is_student %>
<% if @is_evaluation %>
<% if @has_evaluation %>
<div style="text-align: center;">
<%= l(:lable_has_evaluation)%>
</div>
<% else %>
<%= render :partial => 'evaluation', :locals => {:homework => @homework} %>
<% end %>
<% else %>
<%= render :partial => 'evaluation', :locals => {:homework => @homework} %>
<div style="text-align: center;">
<%= l(:lable_close_evaluation)%>
</div>
<% end %>
<% else %>
<div style="text-align: center;">
<%= l(:lable_close_evaluation)%>
</div>
<% end %>
<% end %>
</div>
</div>
<% end %>
<% if !is_teacher %>
<!--提示登录后对应用进行评价-->
<div id="leave-message">
<%= render :partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0, :is_comprehensive_evaluation => nil} %>
</div>
<!--提示登录后对应用进行评价-->
<div id="leave-message">
<%= render :partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0, :is_comprehensive_evaluation => nil} %>
</div>
<% end %>
<!-- 留言列表区 -->
<div id="message" style="font-size: 14px;">
<%= render :partial => 'showjour', :locals => {:jour => @jour,:homework => @homework} %>

View File

@ -1,4 +1,5 @@
<!--add by huang-->
<% cache "footer" do %>
<div class="clearfix"></div>
<div id="footer" style="margin-left:-5px;padding-top: 20px;clear: both;font-size: 12px;">
<div style="border-top:solid 1px #C6E9F1;"></div>
@ -31,7 +32,9 @@
<div class="debug">
<%= debug(params) if Rails.env.development? %>
<script src="http://s4.cnzz.com/z_stat.php?id=1000482288&web_id=1000482288" language="JavaScript"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
@ -42,3 +45,5 @@
</script>
</div>
<% end %>

View File

@ -74,14 +74,6 @@
</span>
</td>
</tr>
<!-- <tr>
<td></td>
<td align="center">
<span class="bid_course" style="padding-left: 8px"> <% if @user != User.current %>
<%= watcher_link(@bid, User.current) %>
<% end %> </span>
</td>
</tr> -->
</table>
</td>
</tr>
@ -97,7 +89,7 @@
</tr>
<tr>
<td class="font_lighter_sidebar" colspan="2" style="padding-left: 8px;"><%= project.description %></td>
<td class="font_lighter_sidebar" colspan="2" style="padding-left: 8px;"><%= textilizable project.description %></td>
</tr>
<tr>
@ -132,12 +124,6 @@
<div class="inf_user_image">
<table>
<!--
<tr>
<td style="text-align: justify ; text-justify: inter-ideograph; width: 180px"><%= l(:label_teacher_homework) %> : <%= link_to(@user.lastname+@user.firstname, user_path(@user)) %></td>
</tr>
-->
<tr>
<td><%= l(:label_limit_time) %>: <%= @bid.deadline %></td>
</tr>

View File

@ -52,7 +52,9 @@
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", { :controller => 'projects', :action => 'index', :project_type => 0, :host => Setting.project_domain}, :target => "_blank" %></span>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_miracle_project(10, 3).map do |project| %>
<% projects = find_miracle_project(10, 3) %>
<% projects.map do |project| %>
<% cache "welcome_index_hotProject_ul_#{project}_li" do %>
<li style="position:relative;height:6em;" class='<%= cycle("odd", "even") %>'>
<div style="float: left;">
<%= image_tag(get_project_avatar(project), :class => "avatar-4") %>
@ -71,9 +73,9 @@
:title => "项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度",
:class => "tooltip",
:id => "tooltip-#{project.id}" %>
</p>
</div>
</li>
<% end %>
<% end; reset_cycle %>
</ul>
</div>
@ -84,7 +86,9 @@
<h3 style="color: rgb(21, 188, 207)"><strong>用户动态</strong></h3>
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", { :controller => 'users', :action => 'index'}, :target => "_blank" %></span>
<div class="user-message-box-list" style="margin-top: 10px;">
<% find_all_activities.each do |event| %>
<%activities = find_all_activities%>
<% activities.each do |event| %>
<% cache "welcome_index_userActivity_ul_#{event}_li" do %>
<li style="display: block;height:60px; padding-bottom: 4px;">
<div class="inner-right" style="float: left; height: 100%; ">
<%= image_tag url_to_avatar(event.event_author), :class => "avatar-3" %>
@ -95,6 +99,7 @@
<p style="margin-top: 4px;"><span style="color: rgb(172, 174, 177)"><%= l(:field_updated_on) %><%= time_tag_welcome event.event_datetime %>前</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="float: right; color: rgb(172, 174, 177);"><%= show_event_reply event %></span></p>
</div>
</li>
<% end %><!-- cache -->
<% end %>
</div>
</ul>
@ -102,6 +107,7 @@
<div class="right" style="float: right; width: 48%; ">
<ul class="welcome-message-list">
<% cache 'forum_links' do %>
<div class="forum-topic" style="height: 25px; width: 98%; margin-left: 2px;">
<h3 style="color: rgb(21, 188, 207);">
<strong>贴吧动态</strong>
@ -109,8 +115,11 @@
<%= link_to "我要反馈" , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%></h3>
<span style="margin-top: -30px;float: right; display: block;"><%= link_to "更多>>", forums_path %></span>
</div>
<% end %>
<div class="welcome-box-list-new memo_activity">
<% find_new_forum_topics(7).each do |topic|%>
<% topics = find_new_forum_topics(7) %>
<% topics.each do |topic|%>
<% cache "welcome_index_memosActivity_ul_#{topic}_li" do %>
<li class="message-brief-intro">
<div class='memo_title text_nowrap'>
<%= link_to '['+topic.forum.name + ']',forum_path(topic.forum),:class => 'memo_Bar_title' %><%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url,title: topic.subject %>
@ -130,6 +139,7 @@
</span>
</div>
</li>
<% end %> <!-- cache -->
<% end %>
</div>
</ul>

View File

@ -924,13 +924,11 @@ ActiveRecord::Schema.define(:version => 20140609061903) do
add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id"
create_table "user_scores", :force => true do |t|
t.integer "user_id", :null => false
t.integer "collaboration"
t.integer "influence"
t.integer "skill"
t.integer "active"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "user_id"
t.integer "collaboration"
t.integer "influence"
t.integer "skill"
t.integer "activity"
end
create_table "user_statuses", :force => true do |t|