加入课程数和创建课程数不正确

去除掉无用代码
This commit is contained in:
sw 2015-07-23 14:42:47 +08:00
parent 76247d74a7
commit 6775008b50
2 changed files with 26 additions and 160 deletions

View File

@ -328,73 +328,41 @@ module UsersHelper
return [0,[]]
end
list = query.order("updated_on desc").limit(10).all
return [count,list];
return [count,list]
end
def get_create_course_count(user)
return Course.where("tea_id = ?",user.id).count()
if user == User.current
user.courses.count
else
user.courses.where("is_public = 1").count
end
end
def get_join_course_count(user)
return user.coursememberships.count() - get_create_course_count(user)
user.coursememberships.count - get_create_course_count(user)
end
def get_homework_commons_count(user)
return HomeworkCommon.where("user_id = ?",user.id).count()
HomeworkCommon.where("user_id = ?",user.id).count
end
def get_projectandcourse_attachment_count(user)
return Attachment.where("author_id = ? and container_type in ('Project','Course')",user.id).count()
Attachment.where("author_id = ? and container_type in ('Project','Course')",user.id).count
end
def get_create_project_count(user)
return Project.where("user_id = ? and project_type = ?",user.id,Project::ProjectType_project).count()
Project.where("user_id = ? and project_type = ?",user.id,Project::ProjectType_project).count
end
def get_join_project_count(user)
return user.memberships.count(conditions: "projects.project_type = #{Project::ProjectType_project}") - get_create_project_count(user)
user.memberships.count(conditions: "projects.project_type = #{Project::ProjectType_project}") - get_create_project_count(user)
end
def get_create_issue_count(user)
return Issue.where("author_id = ?",user.id).count()
Issue.where("author_id = ?",user.id).count
end
def get_resolve_issue_count(user)
return Issue.where("assigned_to_id = ? and status_id=3",user.id).count()
Issue.where("assigned_to_id = ? and status_id=3",user.id).count
end
def get_anonymous_evaluation_count(user)
return StudentWorksScore.where("user_id = ? and reviewer_role=3",user.id).count()
StudentWorksScore.where("user_id = ? and reviewer_role=3",user.id).count
end
# def query_activities(query,type)
# query_rec_count = 8
# # query = query.where("act_type='JournalsForMessage'")
# #query = query.where("act_type not in (?)", ['JournalsForMessage','Message','HomeworkCommon','News','Issue','Journal','Poll'])
# list = query.order("id desc").limit(query_rec_count).all
#
# result = [];
# for item in list
# container = get_activity_container(item,type)
# if( activity_is_show(item,container) )
# result << { :item=>item,:e=>container }
# end
# end
# return [lastid,result]
# end
# def get_activity_container activity,type
# e = nil;
# if type == 'Project'
# if activity.act_type == 'Poll'
# # 项目没有问卷
# # e = Project.find_by_id(activity.act.polls_group_id)
# else
# e = activity.act.project if activity.act.respond_to?('project')
# end
# end
# if type == 'Course'
# if activity.act_type == 'Poll'
# e = Course.find_by_id(activity.act.polls_group_id)
# else
# e = activity.act.course if activity.act.respond_to?('course')
# end
# end
#
# return e;
# end
def query_activities(query)
list = query.limit(8).all
result = [];
@ -406,31 +374,8 @@ module UsersHelper
end
def get_activity_container activity
return activity.activity_container
# if type == 'Project'
# return activity.act.project if activity.act.respond_to?('project')
# end
# if type == 'Course'
# if activity.act_type == 'Poll'
# return Course.find_by_id(activity.act.polls_group_id)
# end
# return activity.act.course if activity.act.respond_to?('course')
# end
# return nil;
end
# def activity_is_show(activity,e)
# if(!e)
# return false
# end
#
# if activity.user_id == User.current.id
# return true
# end
# if( e.visible? )
# return true
# end
# return false
# end
def get_activity_act_showname_htmlclear(activity)
str = get_activity_act_showname(activity)
str = str.gsub(/<.*>/,'')

View File

@ -19,77 +19,8 @@
<%= javascript_heads %>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
<%= yield :header_tags -%>
<!--
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>个人中心st</title>
<link href="css/public.css" rel="stylesheet" type="text/css" />
<link href="css/leftside.css" rel="stylesheet" type="text/css" />
<link href="css/users.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.3.2.js" type="text/javascript"></script>
<script src="js/jquery-1.8.3-ui-1.9.2-ujs-2.0.3.js" type="text/javascript"></script>
<script type="text/javascript" src="js/sidebar.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.4.custom.min.js"></script>
<script type="text/javascript" src="js/jQuery.peSlider.js"></script>
</script>
<script type="text/javascript">
//头部导航
var menuids=["TopUserNav"] //Enter id(s) of SuckerTree UL menus, separated by commas
function buildsubmenus(){
for (var i=0; i<menuids.length; i++){
var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
for (var t=0; t<ultags.length; t++){
ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle"
ultags[t].parentNode.onmouseover=function(){
this.getElementsByTagName("ul")[0].style.display="block"
}
ultags[t].parentNode.onmouseout=function(){
this.getElementsByTagName("ul")[0].style.display="none"
}
}
}
}
if (window.addEventListener)
window.addEventListener("load", buildsubmenus, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus)
</script>
<script type="text/javascript">//侧导航
$(function(){
$(".subNav").click(function(){
$(this).toggleClass("currentDd").siblings(".subNav").removeClass("currentDd")
$(this).toggleClass("currentDt").siblings(".subNav").removeClass("currentDt")
// 修改数字控制速度, slideUp(500)控制卷起速度
$(this).next(".navContent").slideToggle(500).siblings(".navContent").slideUp(500);
})
})
</script>
<script type="text/javascript">
function show_window () {
$('#light').css('display','block');
$('#fade').css('display','block');
}
function close_window(){
$('#light').css('display','none');
$('#fade').css('display','none');
}
//弹框l
</script> -->
</head>
@ -103,12 +34,6 @@ $(".subNav").click(function(){
<%=link_to l(:field_homepage), home_path %> &gt; <%=link_to (@center_flag ? '个人中心' : '个人主页'), user_path(@user) %> &gt; <%=link_to @user.name, user_path(@user) %>
</p>
</div>
<!--<div class="search fl">-->
<!--<form class="search">-->
<!--<input type="text" name="serach" placeholder="输入关键词进行搜索" class="search_text fl">-->
<!--<a href="javascript:void(0);" class="search_btn fl f14 c_white" >搜 索</a>-->
<!--</form>-->
<!--</div>-->
</div><!--TopBar end-->
<div class="cl"></div>
@ -200,22 +125,18 @@ $(".subNav").click(function(){
<% if @center_flag %>
<div class="subNavBox ">
<div class="subNav "><a href="<%=url_for(:controller => 'users', :action => 'show',:id=>@user.id)%>" class=" f14 c_blue02">动态</a></div>
<div class="subNav subNav_jiantou"><a href="<%=url_for(:controller => 'users', :action => 'user_courses',:id=>@user.id)%>" class=" f14 c_blue02">我的课程<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.courses.count%>)</span></a></div>
<!--<ul class="navContent " >-->
<!--<li><a href="javascirpt:void();" >大学计算机基础</a></li>-->
<!--<li><a href="javascirpt:void();" >大牛软件核心知识开放课程</a></li>-->
<!--<li><a href="javascirpt:void();" >大学计算机基础</a></li>-->
<!--<li><a href="javascirpt:void();" >大牛软件核心知识开放课程</a></li>-->
<!--<li><a href="javascirpt:void();" >大学计算机基础</a></li>-->
<!--</ul>-->
<div class="subNav subNav_jiantou"><a href="<%=url_for(:controller => 'users', :action => 'user_projects',:id=>@user.id)%>" class=" f14 c_blue02">我的项目<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.projects.count%>)</span></a></div>
<!--<ul class="navContent " >-->
<!--<li><a href="javascirpt:void();" >Trustie-Forge</a></li>-->
<!--<li><a href="javascirpt:void();" >Trustie-weekly</a></li>-->
<!--<li><a href="javascirpt:void();" >大学计算机基础</a></li>-->
<!--<li><a href="javascirpt:void();" >大牛软件核心知识开放课程</a></li>-->
<!--<li><a href="javascirpt:void();" >大学计算机基础</a></li>-->
<!--</ul>-->
<div class="subNav subNav_jiantou">
<a href="<%=url_for(:controller => 'users', :action => 'user_courses',:id=>@user.id)%>" class=" f14 c_blue02">
我的课程
<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.courses.count%>)</span>
</a>
</div>
<div class="subNav subNav_jiantou">
<a href="<%=url_for(:controller => 'users', :action => 'user_projects',:id=>@user.id)%>" class=" f14 c_blue02">
我的项目
<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.projects.count%>)</span>
</a>
</div>
<div class="subNav "><a href="<%= url_for(:controller => 'my', :action => 'account') %>" class=" f14 c_blue02">编辑资料</a></div>
</div><!--侧导航 end-->
<% end %>